diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 1b5dc400b..0a40b9d77 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.39.0" + ".": "0.40.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 5776427f3..715ea230c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 103 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-c8fc7d0bf70bf7ed91a141f346a02929e4d25a6fac7b59f58b68136ed6ff024f.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-48084a007f009b4358484f09a3a7b74a990c402669f9d15adfbb60e4f835f951.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index dc29c2738..94504c3c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,32 @@ # Changelog +## 0.40.0 (2025-03-05) + +Full Changelog: [v0.39.0...v0.40.0](https://github.com/orbcorp/orb-java/compare/v0.39.0...v0.40.0) + +### ⚠ BREAKING CHANGES + +* **client:** refactor multipart formdata impl ([#296](https://github.com/orbcorp/orb-java/issues/296)) + +### Features + +* **api:** api update ([#300](https://github.com/orbcorp/orb-java/issues/300)) ([d5cb74a](https://github.com/orbcorp/orb-java/commit/d5cb74a47458809ba335447204b1b21166df0ede)) +* **client:** allow configuring timeouts granularly ([#294](https://github.com/orbcorp/orb-java/issues/294)) ([fd71049](https://github.com/orbcorp/orb-java/commit/fd7104918a50f62d44769d167cd3d0c665710c5e)) +* **client:** support raw response access ([#295](https://github.com/orbcorp/orb-java/issues/295)) ([70b0eb8](https://github.com/orbcorp/orb-java/commit/70b0eb8d409fdf3c4c1369d089c9c0f52f674268)) + + +### Chores + +* **client:** expose `Optional`, not nullable, from `ClientOptions` ([#299](https://github.com/orbcorp/orb-java/issues/299)) ([20f1914](https://github.com/orbcorp/orb-java/commit/20f191444e7d58a9ed38174f7a7f5ce027e39101)) +* **client:** refactor multipart formdata impl ([#296](https://github.com/orbcorp/orb-java/issues/296)) ([22e538b](https://github.com/orbcorp/orb-java/commit/22e538b1422b5bef07a22d0d84bf4a86dd77cea1)) +* **internal:** refactor `ErrorHandlingTest` ([#292](https://github.com/orbcorp/orb-java/issues/292)) ([d1ec6ff](https://github.com/orbcorp/orb-java/commit/d1ec6ff7570f4751c55862bd687009ff1f9e4b74)) + + +### Documentation + +* add raw response readme documentation ([#297](https://github.com/orbcorp/orb-java/issues/297)) ([648e2e6](https://github.com/orbcorp/orb-java/commit/648e2e6fe04d533a22fdbd730d84a39705f85561)) +* note required fields in `builder` javadoc ([#298](https://github.com/orbcorp/orb-java/issues/298)) ([1af73ac](https://github.com/orbcorp/orb-java/commit/1af73ac23511ae32f4c4c051c45e95384cbb7c25)) + ## 0.39.0 (2025-03-01) Full Changelog: [v0.38.0...v0.39.0](https://github.com/orbcorp/orb-java/compare/v0.38.0...v0.39.0) diff --git a/README.md b/README.md index 7ee11951e..d2dd42fba 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.withorb.api/orb-java)](https://central.sonatype.com/artifact/com.withorb.api/orb-java/0.39.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.withorb.api/orb-java)](https://central.sonatype.com/artifact/com.withorb.api/orb-java/0.40.0) @@ -19,7 +19,7 @@ The REST API documentation can be found on [docs.withorb.com](https://docs.witho ### Gradle ```kotlin -implementation("com.withorb.api:orb-java:0.39.0") +implementation("com.withorb.api:orb-java:0.40.0") ``` ### Maven @@ -28,7 +28,7 @@ implementation("com.withorb.api:orb-java:0.39.0") com.withorb.api orb-java - 0.39.0 + 0.40.0 ``` @@ -43,8 +43,8 @@ This library requires Java 8 or later. ```java import com.withorb.api.client.OrbClient; import com.withorb.api.client.okhttp.OrbOkHttpClient; -import com.withorb.api.models.Customer; import com.withorb.api.models.CustomerCreateParams; +import com.withorb.api.models.CustomerModel; // Configures using the `ORB_API_KEY` and `ORB_WEBHOOK_SECRET` environment variables OrbClient client = OrbOkHttpClient.fromEnv(); @@ -53,7 +53,7 @@ CustomerCreateParams params = CustomerCreateParams.builder() .email("example-customer@withorb.com") .name("My Customer") .build(); -Customer customer = client.customers().create(params); +CustomerModel customerModel = client.customers().create(params); ``` ## Client configuration @@ -107,7 +107,7 @@ See this table for the available options: To send a request to the Orb API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class. -For example, `client.customers().create(...)` should be called with an instance of `CustomerCreateParams`, and it will return an instance of `Customer`. +For example, `client.customers().create(...)` should be called with an instance of `CustomerCreateParams`, and it will return an instance of `CustomerModel`. ## Immutability @@ -124,8 +124,8 @@ The default client is synchronous. To switch to asynchronous execution, call the ```java import com.withorb.api.client.OrbClient; import com.withorb.api.client.okhttp.OrbOkHttpClient; -import com.withorb.api.models.Customer; import com.withorb.api.models.CustomerCreateParams; +import com.withorb.api.models.CustomerModel; import java.util.concurrent.CompletableFuture; // Configures using the `ORB_API_KEY` and `ORB_WEBHOOK_SECRET` environment variables @@ -135,7 +135,7 @@ CustomerCreateParams params = CustomerCreateParams.builder() .email("example-customer@withorb.com") .name("My Customer") .build(); -CompletableFuture customer = client.async().customers().create(params); +CompletableFuture customerModel = client.async().customers().create(params); ``` Or create an asynchronous client from the beginning: @@ -143,8 +143,8 @@ Or create an asynchronous client from the beginning: ```java import com.withorb.api.client.OrbClientAsync; import com.withorb.api.client.okhttp.OrbOkHttpClientAsync; -import com.withorb.api.models.Customer; import com.withorb.api.models.CustomerCreateParams; +import com.withorb.api.models.CustomerModel; import java.util.concurrent.CompletableFuture; // Configures using the `ORB_API_KEY` and `ORB_WEBHOOK_SECRET` environment variables @@ -154,11 +154,41 @@ CustomerCreateParams params = CustomerCreateParams.builder() .email("example-customer@withorb.com") .name("My Customer") .build(); -CompletableFuture customer = client.customers().create(params); +CompletableFuture customerModel = client.customers().create(params); ``` The asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s. +## Raw responses + +The SDK defines methods that deserialize responses into instances of Java classes. However, these methods don't provide access to the response headers, status code, or the raw response body. + +To access this data, prefix any HTTP method call on a client or service with `withRawResponse()`: + +```java +import com.withorb.api.core.http.Headers; +import com.withorb.api.core.http.HttpResponseFor; +import com.withorb.api.models.CustomerCreateParams; +import com.withorb.api.models.CustomerModel; + +CustomerCreateParams params = CustomerCreateParams.builder() + .email("example-customer@withorb.com") + .name("My Customer") + .build(); +HttpResponseFor customerModel = client.customers().withRawResponse().create(params); + +int statusCode = customerModel.statusCode(); +Headers headers = customerModel.headers(); +``` + +You can still deserialize the response into an instance of a Java class if needed: + +```java +import com.withorb.api.models.CustomerModel; + +CustomerModel parsedCustomerModel = customerModel.parse(); +``` + ## Error handling The SDK throws custom unchecked exception types: @@ -193,12 +223,12 @@ To iterate through all results across all pages, you can use `autoPager`, which ### Synchronous ```java -import com.withorb.api.models.Coupon; import com.withorb.api.models.CouponListPage; +import com.withorb.api.models.CouponModel; // As an Iterable: CouponListPage page = client.coupons().list(params); -for (Coupon coupon : page.autoPager()) { +for (CouponModel coupon : page.autoPager()) { System.out.println(coupon); }; @@ -221,12 +251,12 @@ asyncClient.coupons().list(params).autoPager() If none of the above helpers meet your needs, you can also manually request pages one-by-one. A page of results has a `data()` method to fetch the list of objects, as well as top-level `response` and other methods to fetch top-level data about the page. It also has methods `hasNextPage`, `getNextPage`, and `getNextPageParams` methods to help with pagination. ```java -import com.withorb.api.models.Coupon; import com.withorb.api.models.CouponListPage; +import com.withorb.api.models.CouponModel; CouponListPage page = client.coupons().list(params); while (page != null) { - for (Coupon coupon : page.data()) { + for (CouponModel coupon : page.data()) { System.out.println(coupon); } @@ -295,10 +325,10 @@ Requests time out after 1 minute by default. To set a custom timeout, configure the method call using the `timeout` method: ```java -import com.withorb.api.models.Customer; import com.withorb.api.models.CustomerCreateParams; +import com.withorb.api.models.CustomerModel; -Customer customer = client.customers().create( +CustomerModel customerModel = client.customers().create( params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build() ); ``` @@ -432,18 +462,18 @@ By default, the SDK will not throw an exception in this case. It will throw [`Or If you would prefer to check that the response is completely well-typed upfront, then either call `validate()`: ```java -import com.withorb.api.models.Customer; +import com.withorb.api.models.CustomerModel; -Customer customer = client.customers().create(params).validate(); +CustomerModel customerModel = client.customers().create(params).validate(); ``` Or configure the method call to validate the response using the `responseValidation` method: ```java -import com.withorb.api.models.Customer; import com.withorb.api.models.CustomerCreateParams; +import com.withorb.api.models.CustomerModel; -Customer customer = client.customers().create( +CustomerModel customerModel = client.customers().create( params, RequestOptions.builder().responseValidation(true).build() ); ``` diff --git a/build.gradle.kts b/build.gradle.kts index 0300a4717..d0b92cf0d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,4 +1,4 @@ allprojects { group = "com.withorb.api" - version = "0.39.0" // x-release-please-version + version = "0.40.0" // x-release-please-version } 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 7cdd0e026..655da4e8b 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 @@ -1,6 +1,7 @@ package com.withorb.api.client.okhttp import com.withorb.api.core.RequestOptions +import com.withorb.api.core.Timeout import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.HttpClient @@ -88,13 +89,12 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val ) } - val timeout = requestOptions.timeout - if (timeout != null) { + requestOptions.timeout?.let { clientBuilder - .connectTimeout(timeout) - .readTimeout(timeout) - .writeTimeout(timeout) - .callTimeout(if (timeout.seconds == 0L) timeout else timeout.plusSeconds(30)) + .connectTimeout(it.connect()) + .readTimeout(it.read()) + .writeTimeout(it.write()) + .callTimeout(it.request()) } val client = clientBuilder.build() @@ -195,23 +195,24 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val class Builder internal constructor() { private var baseUrl: HttpUrl? = null - // The default timeout is 1 minute. - private var timeout: Duration = Duration.ofSeconds(60) + private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl.toHttpUrl() } - fun timeout(timeout: Duration) = apply { this.timeout = timeout } + fun timeout(timeout: Timeout) = apply { this.timeout = timeout } + + fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } fun build(): OkHttpClient = OkHttpClient( okhttp3.OkHttpClient.Builder() - .connectTimeout(timeout) - .readTimeout(timeout) - .writeTimeout(timeout) - .callTimeout(if (timeout.seconds == 0L) timeout else timeout.plusSeconds(30)) + .connectTimeout(timeout.connect()) + .readTimeout(timeout.read()) + .writeTimeout(timeout.write()) + .callTimeout(timeout.request()) .proxy(proxy) .build(), checkRequired("baseUrl", baseUrl), 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 442c58242..ba060e8a7 100644 --- a/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClient.kt +++ b/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClient.kt @@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.json.JsonMapper import com.withorb.api.client.OrbClient import com.withorb.api.client.OrbClientImpl import com.withorb.api.core.ClientOptions +import com.withorb.api.core.Timeout import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.net.Proxy @@ -17,6 +18,7 @@ class OrbOkHttpClient private constructor() { companion object { + /** Returns a mutable builder for constructing an instance of [OrbOkHttpClient]. */ @JvmStatic fun builder() = Builder() @JvmStatic fun fromEnv(): OrbClient = builder().fromEnv().build() @@ -27,8 +29,7 @@ class OrbOkHttpClient private constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() private var baseUrl: String = ClientOptions.PRODUCTION_URL - // The default timeout for the client is 1 minute. - private var timeout: Duration = Duration.ofSeconds(60) + private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null fun baseUrl(baseUrl: String) = apply { @@ -120,7 +121,19 @@ class OrbOkHttpClient private constructor() { clientOptions.removeAllQueryParams(keys) } - fun timeout(timeout: Duration) = apply { this.timeout = timeout } + fun timeout(timeout: Timeout) = apply { + clientOptions.timeout(timeout) + this.timeout = timeout + } + + /** + * Sets the maximum time allowed for a complete HTTP call, not including retries. + * + * See [Timeout.request] for more details. + * + * For fine-grained control, pass a [Timeout] object. + */ + fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } 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 3c9e6f228..b8ec34517 100644 --- a/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClientAsync.kt +++ b/orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClientAsync.kt @@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.json.JsonMapper import com.withorb.api.client.OrbClientAsync import com.withorb.api.client.OrbClientAsyncImpl import com.withorb.api.core.ClientOptions +import com.withorb.api.core.Timeout import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.net.Proxy @@ -17,6 +18,7 @@ class OrbOkHttpClientAsync private constructor() { companion object { + /** Returns a mutable builder for constructing an instance of [OrbOkHttpClientAsync]. */ @JvmStatic fun builder() = Builder() @JvmStatic fun fromEnv(): OrbClientAsync = builder().fromEnv().build() @@ -27,8 +29,7 @@ class OrbOkHttpClientAsync private constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() private var baseUrl: String = ClientOptions.PRODUCTION_URL - // The default timeout for the client is 1 minute. - private var timeout: Duration = Duration.ofSeconds(60) + private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null fun baseUrl(baseUrl: String) = apply { @@ -120,7 +121,19 @@ class OrbOkHttpClientAsync private constructor() { clientOptions.removeAllQueryParams(keys) } - fun timeout(timeout: Duration) = apply { this.timeout = timeout } + fun timeout(timeout: Timeout) = apply { + clientOptions.timeout(timeout) + this.timeout = timeout + } + + /** + * Sets the maximum time allowed for a complete HTTP call, not including retries. + * + * See [Timeout.request] for more details. + * + * For fine-grained control, pass a [Timeout] object. + */ + fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } diff --git a/orb-java-core/build.gradle.kts b/orb-java-core/build.gradle.kts index 8d8043759..b53bd811e 100644 --- a/orb-java-core/build.gradle.kts +++ b/orb-java-core/build.gradle.kts @@ -6,6 +6,7 @@ plugins { dependencies { api("com.fasterxml.jackson.core:jackson-core:2.18.1") api("com.fasterxml.jackson.core:jackson-databind:2.18.1") + api("com.google.errorprone:error_prone_annotations:2.33.0") implementation("com.fasterxml.jackson.core:jackson-annotations:2.18.1") implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.18.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 b256deff2..a35901a57 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 @@ -42,6 +42,11 @@ interface OrbClient { */ fun async(): OrbClientAsync + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + fun topLevel(): TopLevelService fun coupons(): CouponService @@ -84,4 +89,36 @@ interface OrbClient { * method. */ fun close() + + /** A view of [OrbClient] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + fun topLevel(): TopLevelService.WithRawResponse + + fun coupons(): CouponService.WithRawResponse + + fun creditNotes(): CreditNoteService.WithRawResponse + + fun customers(): CustomerService.WithRawResponse + + fun events(): EventService.WithRawResponse + + fun invoiceLineItems(): InvoiceLineItemService.WithRawResponse + + fun invoices(): InvoiceService.WithRawResponse + + fun items(): ItemService.WithRawResponse + + fun metrics(): MetricService.WithRawResponse + + fun plans(): PlanService.WithRawResponse + + fun prices(): PriceService.WithRawResponse + + fun subscriptions(): SubscriptionService.WithRawResponse + + fun alerts(): AlertService.WithRawResponse + + fun dimensionalPriceGroups(): DimensionalPriceGroupService.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 61f2d9d71..20b04b5ce 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 @@ -41,6 +41,11 @@ interface OrbClientAsync { */ fun sync(): OrbClient + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + fun topLevel(): TopLevelServiceAsync fun coupons(): CouponServiceAsync @@ -81,4 +86,36 @@ interface OrbClientAsync { * method. */ fun close() + + /** A view of [OrbClientAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + fun topLevel(): TopLevelServiceAsync.WithRawResponse + + fun coupons(): CouponServiceAsync.WithRawResponse + + fun creditNotes(): CreditNoteServiceAsync.WithRawResponse + + fun customers(): CustomerServiceAsync.WithRawResponse + + fun events(): EventServiceAsync.WithRawResponse + + fun invoiceLineItems(): InvoiceLineItemServiceAsync.WithRawResponse + + fun invoices(): InvoiceServiceAsync.WithRawResponse + + fun items(): ItemServiceAsync.WithRawResponse + + fun metrics(): MetricServiceAsync.WithRawResponse + + fun plans(): PlanServiceAsync.WithRawResponse + + fun prices(): PriceServiceAsync.WithRawResponse + + fun subscriptions(): SubscriptionServiceAsync.WithRawResponse + + fun alerts(): AlertServiceAsync.WithRawResponse + + fun dimensionalPriceGroups(): DimensionalPriceGroupServiceAsync.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 6f8eadd5e..c74456d9b 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 @@ -46,6 +46,10 @@ class OrbClientAsyncImpl(private val clientOptions: ClientOptions) : OrbClientAs // Pass the original clientOptions so that this client sets its own User-Agent. private val sync: OrbClient by lazy { OrbClientImpl(clientOptions) } + private val withRawResponse: OrbClientAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + private val topLevel: TopLevelServiceAsync by lazy { TopLevelServiceAsyncImpl(clientOptionsWithUserAgent) } @@ -100,6 +104,8 @@ class OrbClientAsyncImpl(private val clientOptions: ClientOptions) : OrbClientAs override fun sync(): OrbClient = sync + override fun withRawResponse(): OrbClientAsync.WithRawResponse = withRawResponse + override fun topLevel(): TopLevelServiceAsync = topLevel override fun coupons(): CouponServiceAsync = coupons @@ -130,4 +136,95 @@ class OrbClientAsyncImpl(private val clientOptions: ClientOptions) : OrbClientAs dimensionalPriceGroups override fun close() = clientOptions.httpClient.close() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + OrbClientAsync.WithRawResponse { + + private val topLevel: TopLevelServiceAsync.WithRawResponse by lazy { + TopLevelServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val coupons: CouponServiceAsync.WithRawResponse by lazy { + CouponServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val creditNotes: CreditNoteServiceAsync.WithRawResponse by lazy { + CreditNoteServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val customers: CustomerServiceAsync.WithRawResponse by lazy { + CustomerServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val events: EventServiceAsync.WithRawResponse by lazy { + EventServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val invoiceLineItems: InvoiceLineItemServiceAsync.WithRawResponse by lazy { + InvoiceLineItemServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val invoices: InvoiceServiceAsync.WithRawResponse by lazy { + InvoiceServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val items: ItemServiceAsync.WithRawResponse by lazy { + ItemServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val metrics: MetricServiceAsync.WithRawResponse by lazy { + MetricServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val plans: PlanServiceAsync.WithRawResponse by lazy { + PlanServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val prices: PriceServiceAsync.WithRawResponse by lazy { + PriceServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val subscriptions: SubscriptionServiceAsync.WithRawResponse by lazy { + SubscriptionServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val alerts: AlertServiceAsync.WithRawResponse by lazy { + AlertServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val dimensionalPriceGroups: + DimensionalPriceGroupServiceAsync.WithRawResponse by lazy { + DimensionalPriceGroupServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun topLevel(): TopLevelServiceAsync.WithRawResponse = topLevel + + override fun coupons(): CouponServiceAsync.WithRawResponse = coupons + + override fun creditNotes(): CreditNoteServiceAsync.WithRawResponse = creditNotes + + override fun customers(): CustomerServiceAsync.WithRawResponse = customers + + override fun events(): EventServiceAsync.WithRawResponse = events + + override fun invoiceLineItems(): InvoiceLineItemServiceAsync.WithRawResponse = + invoiceLineItems + + override fun invoices(): InvoiceServiceAsync.WithRawResponse = invoices + + override fun items(): ItemServiceAsync.WithRawResponse = items + + override fun metrics(): MetricServiceAsync.WithRawResponse = metrics + + override fun plans(): PlanServiceAsync.WithRawResponse = plans + + override fun prices(): PriceServiceAsync.WithRawResponse = prices + + override fun subscriptions(): SubscriptionServiceAsync.WithRawResponse = subscriptions + + override fun alerts(): AlertServiceAsync.WithRawResponse = alerts + + override fun dimensionalPriceGroups(): DimensionalPriceGroupServiceAsync.WithRawResponse = + dimensionalPriceGroups + } } 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 46d45ebf7..1c5d79f42 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 @@ -48,6 +48,10 @@ class OrbClientImpl(private val clientOptions: ClientOptions) : OrbClient { // Pass the original clientOptions so that this client sets its own User-Agent. private val async: OrbClientAsync by lazy { OrbClientAsyncImpl(clientOptions) } + private val withRawResponse: OrbClient.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + private val topLevel: TopLevelService by lazy { TopLevelServiceImpl(clientOptionsWithUserAgent) } @@ -92,6 +96,8 @@ class OrbClientImpl(private val clientOptions: ClientOptions) : OrbClient { override fun async(): OrbClientAsync = async + override fun withRawResponse(): OrbClient.WithRawResponse = withRawResponse + override fun topLevel(): TopLevelService = topLevel override fun coupons(): CouponService = coupons @@ -123,4 +129,93 @@ class OrbClientImpl(private val clientOptions: ClientOptions) : OrbClient { override fun dimensionalPriceGroups(): DimensionalPriceGroupService = dimensionalPriceGroups override fun close() = clientOptions.httpClient.close() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + OrbClient.WithRawResponse { + + private val topLevel: TopLevelService.WithRawResponse by lazy { + TopLevelServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val coupons: CouponService.WithRawResponse by lazy { + CouponServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val creditNotes: CreditNoteService.WithRawResponse by lazy { + CreditNoteServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val customers: CustomerService.WithRawResponse by lazy { + CustomerServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val events: EventService.WithRawResponse by lazy { + EventServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val invoiceLineItems: InvoiceLineItemService.WithRawResponse by lazy { + InvoiceLineItemServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val invoices: InvoiceService.WithRawResponse by lazy { + InvoiceServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val items: ItemService.WithRawResponse by lazy { + ItemServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val metrics: MetricService.WithRawResponse by lazy { + MetricServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val plans: PlanService.WithRawResponse by lazy { + PlanServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val prices: PriceService.WithRawResponse by lazy { + PriceServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val subscriptions: SubscriptionService.WithRawResponse by lazy { + SubscriptionServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val alerts: AlertService.WithRawResponse by lazy { + AlertServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val dimensionalPriceGroups: DimensionalPriceGroupService.WithRawResponse by lazy { + DimensionalPriceGroupServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun topLevel(): TopLevelService.WithRawResponse = topLevel + + override fun coupons(): CouponService.WithRawResponse = coupons + + override fun creditNotes(): CreditNoteService.WithRawResponse = creditNotes + + override fun customers(): CustomerService.WithRawResponse = customers + + override fun events(): EventService.WithRawResponse = events + + override fun invoiceLineItems(): InvoiceLineItemService.WithRawResponse = invoiceLineItems + + override fun invoices(): InvoiceService.WithRawResponse = invoices + + override fun items(): ItemService.WithRawResponse = items + + override fun metrics(): MetricService.WithRawResponse = metrics + + override fun plans(): PlanService.WithRawResponse = plans + + override fun prices(): PriceService.WithRawResponse = prices + + override fun subscriptions(): SubscriptionService.WithRawResponse = subscriptions + + override fun alerts(): AlertService.WithRawResponse = alerts + + override fun dimensionalPriceGroups(): DimensionalPriceGroupService.WithRawResponse = + dimensionalPriceGroups + } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/Check.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/Check.kt index 561abe1d9..4a68492fc 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/core/Check.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/Check.kt @@ -5,6 +5,18 @@ package com.withorb.api.core fun checkRequired(name: String, value: T?): T = checkNotNull(value) { "`$name` is required, but was not set" } +@JvmSynthetic +internal fun checkKnown(name: String, value: JsonField): T = + value.asKnown().orElseThrow { + IllegalStateException("`$name` is not a known type: ${value.javaClass.simpleName}") + } + +@JvmSynthetic +internal fun checkKnown(name: String, value: MultipartField): T = + value.value.asKnown().orElseThrow { + IllegalStateException("`$name` is not a known type: ${value.javaClass.simpleName}") + } + @JvmSynthetic internal fun checkLength(name: String, value: String, length: Int): String = value.also { 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 796f695d9..2c3ce89b9 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 @@ -21,17 +21,29 @@ private constructor( @get:JvmName("headers") val headers: Headers, @get:JvmName("queryParams") val queryParams: QueryParams, @get:JvmName("responseValidation") val responseValidation: Boolean, + @get:JvmName("timeout") val timeout: Timeout, @get:JvmName("maxRetries") val maxRetries: Int, @get:JvmName("apiKey") val apiKey: String, - @get:JvmName("webhookSecret") val webhookSecret: String?, + private val webhookSecret: String?, ) { + fun webhookSecret(): Optional = Optional.ofNullable(webhookSecret) + fun toBuilder() = Builder().from(this) companion object { const val PRODUCTION_URL = "https://api.withorb.com/v1" + /** + * Returns a mutable builder for constructing an instance of [ClientOptions]. + * + * The following fields are required: + * ```java + * .httpClient() + * .apiKey() + * ``` + */ @JvmStatic fun builder() = Builder() @JvmStatic fun fromEnv(): ClientOptions = builder().fromEnv().build() @@ -47,6 +59,7 @@ private constructor( private var headers: Headers.Builder = Headers.builder() private var queryParams: QueryParams.Builder = QueryParams.builder() private var responseValidation: Boolean = false + private var timeout: Timeout = Timeout.default() private var maxRetries: Int = 2 private var apiKey: String? = null private var webhookSecret: String? = null @@ -60,6 +73,7 @@ private constructor( headers = clientOptions.headers.toBuilder() queryParams = clientOptions.queryParams.toBuilder() responseValidation = clientOptions.responseValidation + timeout = clientOptions.timeout maxRetries = clientOptions.maxRetries apiKey = clientOptions.apiKey webhookSecret = clientOptions.webhookSecret @@ -77,6 +91,8 @@ private constructor( this.responseValidation = responseValidation } + fun timeout(timeout: Timeout) = apply { this.timeout = timeout } + fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } fun apiKey(apiKey: String) = apply { this.apiKey = apiKey } @@ -208,6 +224,7 @@ private constructor( headers.build(), queryParams.build(), responseValidation, + timeout, maxRetries, apiKey, webhookSecret, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/HttpRequestBodies.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/HttpRequestBodies.kt deleted file mode 100644 index 020e86467..000000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/core/HttpRequestBodies.kt +++ /dev/null @@ -1,108 +0,0 @@ -@file:JvmName("HttpRequestBodies") - -package com.withorb.api.core - -import com.fasterxml.jackson.databind.json.JsonMapper -import com.withorb.api.core.http.HttpRequestBody -import com.withorb.api.errors.OrbException -import java.io.ByteArrayOutputStream -import java.io.OutputStream -import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder - -@JvmSynthetic -internal inline fun json(jsonMapper: JsonMapper, value: T): HttpRequestBody { - return object : HttpRequestBody { - private var cachedBytes: ByteArray? = null - - private fun serialize(): ByteArray { - if (cachedBytes != null) return cachedBytes!! - - val buffer = ByteArrayOutputStream() - try { - jsonMapper.writeValue(buffer, value) - cachedBytes = buffer.toByteArray() - return cachedBytes!! - } catch (e: Exception) { - throw OrbException("Error writing request", e) - } - } - - override fun writeTo(outputStream: OutputStream) { - outputStream.write(serialize()) - } - - override fun contentType(): String = "application/json" - - override fun contentLength(): Long { - return serialize().size.toLong() - } - - override fun repeatable(): Boolean = true - - override fun close() {} - } -} - -@JvmSynthetic -internal fun multipartFormData( - jsonMapper: JsonMapper, - parts: Array?>, -): HttpRequestBody { - val builder = MultipartEntityBuilder.create() - parts.forEach { part -> - if (part?.value != null) { - when (part.value) { - is JsonValue -> { - val buffer = ByteArrayOutputStream() - try { - jsonMapper.writeValue(buffer, part.value) - } catch (e: Exception) { - throw OrbException("Error serializing value to json", e) - } - builder.addBinaryBody( - part.name, - buffer.toByteArray(), - part.contentType, - part.filename, - ) - } - is Boolean -> - builder.addTextBody( - part.name, - if (part.value) "true" else "false", - part.contentType, - ) - is Int -> builder.addTextBody(part.name, part.value.toString(), part.contentType) - is Long -> builder.addTextBody(part.name, part.value.toString(), part.contentType) - is Double -> builder.addTextBody(part.name, part.value.toString(), part.contentType) - is ByteArray -> - builder.addBinaryBody(part.name, part.value, part.contentType, part.filename) - is String -> builder.addTextBody(part.name, part.value, part.contentType) - is Enum -> builder.addTextBody(part.name, part.value.toString(), part.contentType) - else -> - throw IllegalArgumentException( - "Unsupported content type: ${part.value::class.java.simpleName}" - ) - } - } - } - val entity = builder.build() - - return object : HttpRequestBody { - override fun writeTo(outputStream: OutputStream) { - try { - return entity.writeTo(outputStream) - } catch (e: Exception) { - throw OrbException("Error writing request", e) - } - } - - override fun contentType(): String = entity.contentType - - override fun contentLength(): Long = -1 - - override fun repeatable(): Boolean = entity.isRepeatable - - override fun close() = entity.close() - } -} 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 c1c6b76bd..1f3b64291 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 @@ -2,13 +2,7 @@ package com.withorb.api.core import java.time.Duration -class RequestOptions private constructor(val responseValidation: Boolean?, val timeout: Duration?) { - fun applyDefaults(options: RequestOptions): RequestOptions { - return RequestOptions( - responseValidation = this.responseValidation ?: options.responseValidation, - timeout = this.timeout ?: options.timeout, - ) - } +class RequestOptions private constructor(val responseValidation: Boolean?, val timeout: Timeout?) { companion object { @@ -16,22 +10,37 @@ class RequestOptions private constructor(val responseValidation: Boolean?, val t @JvmStatic fun none() = NONE + @JvmSynthetic + internal fun from(clientOptions: ClientOptions): RequestOptions = + builder() + .responseValidation(clientOptions.responseValidation) + .timeout(clientOptions.timeout) + .build() + @JvmStatic fun builder() = Builder() } + fun applyDefaults(options: RequestOptions): RequestOptions = + RequestOptions( + responseValidation = responseValidation ?: options.responseValidation, + timeout = + if (options.timeout != null && timeout != null) timeout.assign(options.timeout) + else timeout ?: options.timeout, + ) + class Builder internal constructor() { private var responseValidation: Boolean? = null - private var timeout: Duration? = null + private var timeout: Timeout? = null fun responseValidation(responseValidation: Boolean) = apply { this.responseValidation = responseValidation } - fun timeout(timeout: Duration) = apply { this.timeout = timeout } + fun timeout(timeout: Timeout) = apply { this.timeout = timeout } - fun build(): RequestOptions { - return RequestOptions(responseValidation, timeout) - } + fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) + + fun build(): RequestOptions = RequestOptions(responseValidation, timeout) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/Timeout.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/Timeout.kt new file mode 100644 index 000000000..65438bf43 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/Timeout.kt @@ -0,0 +1,188 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.core + +import java.time.Duration +import java.util.Objects +import java.util.Optional + +/** A class containing timeouts for various processing phases of a request. */ +class Timeout +private constructor( + private val connect: Duration?, + private val read: Duration?, + private val write: Duration?, + private val request: Duration?, +) { + + /** + * The maximum time allowed to establish a connection with a host. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `Duration.ofMinutes(1)`. + */ + fun connect(): Duration = connect ?: Duration.ofMinutes(1) + + /** + * The maximum time allowed between two data packets when waiting for the server’s response. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `request()`. + */ + fun read(): Duration = read ?: request() + + /** + * The maximum time allowed between two data packets when sending the request to the server. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `request()`. + */ + fun write(): Duration = write ?: request() + + /** + * The maximum time allowed for a complete HTTP call, not including retries. + * + * This includes resolving DNS, connecting, writing the request body, server processing, as well + * as reading the response body. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `Duration.ofMinutes(1)`. + */ + fun request(): Duration = request ?: Duration.ofMinutes(1) + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun default() = builder().build() + + /** Returns a mutable builder for constructing an instance of [Timeout]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Timeout]. */ + class Builder internal constructor() { + + private var connect: Duration? = null + private var read: Duration? = null + private var write: Duration? = null + private var request: Duration? = null + + @JvmSynthetic + internal fun from(timeout: Timeout) = apply { + connect = timeout.connect + read = timeout.read + write = timeout.write + request = timeout.request + } + + /** + * The maximum time allowed to establish a connection with a host. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `Duration.ofMinutes(1)`. + */ + fun connect(connect: Duration?) = apply { this.connect = connect } + + /** + * The maximum time allowed to establish a connection with a host. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `Duration.ofMinutes(1)`. + */ + fun connect(connect: Optional) = connect(connect.orElse(null)) + + /** + * The maximum time allowed between two data packets when waiting for the server’s response. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `request()`. + */ + fun read(read: Duration?) = apply { this.read = read } + + /** + * The maximum time allowed between two data packets when waiting for the server’s response. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `request()`. + */ + fun read(read: Optional) = read(read.orElse(null)) + + /** + * The maximum time allowed between two data packets when sending the request to the server. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `request()`. + */ + fun write(write: Duration?) = apply { this.write = write } + + /** + * The maximum time allowed between two data packets when sending the request to the server. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `request()`. + */ + fun write(write: Optional) = write(write.orElse(null)) + + /** + * The maximum time allowed for a complete HTTP call, not including retries. + * + * This includes resolving DNS, connecting, writing the request body, server processing, as + * well as reading the response body. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `Duration.ofMinutes(1)`. + */ + fun request(request: Duration?) = apply { this.request = request } + + /** + * The maximum time allowed for a complete HTTP call, not including retries. + * + * This includes resolving DNS, connecting, writing the request body, server processing, as + * well as reading the response body. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `Duration.ofMinutes(1)`. + */ + fun request(request: Optional) = request(request.orElse(null)) + + fun build(): Timeout = Timeout(connect, read, write, request) + } + + @JvmSynthetic + internal fun assign(target: Timeout): Timeout = + target + .toBuilder() + .apply { + connect?.let(this::connect) + read?.let(this::read) + write?.let(this::write) + request?.let(this::request) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Timeout && connect == other.connect && read == other.read && write == other.write && request == other.request /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(connect, read, write, request) /* spotless:on */ + + override fun toString() = + "Timeout{connect=$connect, read=$read, write=$write, request=$request}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/Values.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/Values.kt index 8f2344cb9..79149391d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/core/Values.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/Values.kt @@ -27,10 +27,8 @@ import com.fasterxml.jackson.databind.node.JsonNodeType.POJO import com.fasterxml.jackson.databind.node.JsonNodeType.STRING import com.fasterxml.jackson.databind.ser.std.NullSerializer import com.withorb.api.errors.OrbInvalidDataException -import java.nio.charset.Charset import java.util.Objects import java.util.Optional -import org.apache.hc.core5.http.ContentType @JsonDeserialize(using = JsonField.Deserializer::class) sealed class JsonField { @@ -287,12 +285,12 @@ private constructor( return true } - return other is KnownValue<*> && value == other.value + return other is KnownValue<*> && value contentEquals other.value } - override fun hashCode() = value.hashCode() + override fun hashCode() = contentHash(value) - override fun toString() = value.toString() + override fun toString() = value.contentToString() companion object { @JsonCreator @JvmStatic fun of(value: T) = KnownValue(value) @@ -462,15 +460,63 @@ annotation class ExcludeMissing ) annotation class NoAutoDetect -class MultipartFormValue -internal constructor( - val name: String, - val value: T, - val contentType: ContentType, - val filename: String? = null, +class MultipartField +private constructor( + @get:JvmName("value") val value: JsonField, + @get:JvmName("contentType") val contentType: String, + private val filename: String?, ) { - private val hashCode: Int by lazy { contentHash(name, value, contentType, filename) } + companion object { + + @JvmStatic fun of(value: T?) = builder().value(value).build() + + @JvmStatic fun of(value: JsonField) = builder().value(value).build() + + @JvmStatic fun builder() = Builder() + } + + fun filename(): Optional = Optional.ofNullable(filename) + + @JvmSynthetic + internal fun map(transform: (T) -> R): MultipartField = + MultipartField.builder() + .value(value.map(transform)) + .contentType(contentType) + .filename(filename) + .build() + + /** A builder for [MultipartField]. */ + class Builder internal constructor() { + + private var value: JsonField? = null + private var contentType: String? = null + private var filename: String? = null + + fun value(value: JsonField) = apply { this.value = value } + + fun value(value: T?) = value(JsonField.ofNullable(value)) + + fun contentType(contentType: String) = apply { this.contentType = contentType } + + fun filename(filename: String?) = apply { this.filename = filename } + + fun filename(filename: Optional) = filename(filename.orElse(null)) + + fun build(): MultipartField { + val value = checkRequired("value", value) + return MultipartField( + value, + contentType + ?: if (value is KnownValue && value.value is ByteArray) + "application/octet-stream" + else "text/plain; charset=utf-8", + filename, + ) + } + } + + private val hashCode: Int by lazy { contentHash(value, contentType, filename) } override fun hashCode(): Int = hashCode @@ -479,63 +525,12 @@ internal constructor( return true } - return other is MultipartFormValue<*> && - name == other.name && - value contentEquals other.value && + return other is MultipartField<*> && + value == other.value && contentType == other.contentType && filename == other.filename } override fun toString(): String = - "MultipartFormValue{name=$name, contentType=$contentType, filename=$filename, value=${valueToString()}}" - - private fun valueToString(): String = - when (value) { - is ByteArray -> "ByteArray of size ${value.size}" - else -> value.toString() - } - - companion object { - internal fun fromString( - name: String, - value: String, - contentType: ContentType, - ): MultipartFormValue = MultipartFormValue(name, value, contentType) - - internal fun fromBoolean( - name: String, - value: Boolean, - contentType: ContentType, - ): MultipartFormValue = MultipartFormValue(name, value, contentType) - - internal fun fromLong( - name: String, - value: Long, - contentType: ContentType, - ): MultipartFormValue = MultipartFormValue(name, value, contentType) - - internal fun fromDouble( - name: String, - value: Double, - contentType: ContentType, - ): MultipartFormValue = MultipartFormValue(name, value, contentType) - - internal fun fromEnum( - name: String, - value: T, - contentType: ContentType, - ): MultipartFormValue = MultipartFormValue(name, value, contentType) - - internal fun fromByteArray( - name: String, - value: ByteArray, - contentType: ContentType, - filename: String? = null, - ): MultipartFormValue = MultipartFormValue(name, value, contentType, filename) - } -} - -internal object ContentTypes { - val DefaultText = ContentType.create(ContentType.TEXT_PLAIN.mimeType, Charset.forName("UTF-8")) - val DefaultBinary = ContentType.DEFAULT_BINARY + "MultipartField{value=$value, contentType=$contentType, filename=$filename}" } 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 new file mode 100644 index 000000000..e49836bd4 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/HttpRequestBodies.kt @@ -0,0 +1,89 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:JvmName("HttpRequestBodies") + +package com.withorb.api.core.http + +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.errors.OrbInvalidDataException +import java.io.OutputStream +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 = + object : HttpRequestBody { + private val bytes: ByteArray by lazy { jsonMapper.writeValueAsBytes(value) } + + override fun writeTo(outputStream: OutputStream) = outputStream.write(bytes) + + override fun contentType(): String = "application/json" + + override fun contentLength(): Long = bytes.size.toLong() + + override fun repeatable(): Boolean = true + + override fun close() {} + } + +@JvmSynthetic +internal fun multipartFormData( + jsonMapper: JsonMapper, + fields: Map>, +): HttpRequestBody = + object : HttpRequestBody { + private val entity: HttpEntity by lazy { + MultipartEntityBuilder.create() + .apply { + fields.forEach { (name, field) -> + val node = jsonMapper.valueToTree(field.value) + serializePart(name, node).forEach { (name, bytes) -> + addBinaryBody( + name, + bytes, + ContentType.parseLenient(field.contentType), + field.filename().getOrNull(), + ) + } + } + } + .build() + } + + private fun serializePart(name: String, node: JsonNode): Sequence> = + when (node.nodeType) { + JsonNodeType.MISSING, + JsonNodeType.NULL -> emptySequence() + JsonNodeType.BINARY -> sequenceOf(name to node.binaryValue()) + JsonNodeType.STRING -> sequenceOf(name to node.textValue().toByteArray()) + JsonNodeType.BOOLEAN -> + sequenceOf(name to node.booleanValue().toString().toByteArray()) + JsonNodeType.NUMBER -> + sequenceOf(name to node.numberValue().toString().toByteArray()) + 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}") + } + + override fun writeTo(outputStream: OutputStream) = entity.writeTo(outputStream) + + override fun contentType(): String = entity.contentType + + override fun contentLength(): Long = entity.contentLength + + override fun repeatable(): Boolean = entity.isRepeatable + + override fun close() = entity.close() + } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/http/HttpResponseFor.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/HttpResponseFor.kt new file mode 100644 index 000000000..0f8e55198 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/HttpResponseFor.kt @@ -0,0 +1,23 @@ +package com.withorb.api.core.http + +import java.io.InputStream + +interface HttpResponseFor : HttpResponse { + + fun parse(): T +} + +@JvmSynthetic +internal fun HttpResponse.parseable(parse: () -> T): HttpResponseFor = + object : HttpResponseFor { + + override fun parse(): T = parse() + + override fun statusCode(): Int = this@parseable.statusCode() + + override fun headers(): Headers = this@parseable.headers() + + override fun body(): InputStream = this@parseable.body() + + override fun close() = this@parseable.close() + } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/errors/OrbError.kt b/orb-java-core/src/main/kotlin/com/withorb/api/errors/OrbError.kt index 2479f3e03..7860890be 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/errors/OrbError.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/errors/OrbError.kt @@ -27,6 +27,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [OrbError]. */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AddCreditLedgerEntryRequest.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AddCreditLedgerEntryRequest.kt new file mode 100644 index 000000000..a534f8e0c --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AddCreditLedgerEntryRequest.kt @@ -0,0 +1,3344 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.BaseDeserializer +import com.withorb.api.core.BaseSerializer +import com.withorb.api.core.Enum +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.getOrThrow +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.time.LocalDate +import java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +@JsonDeserialize(using = AddCreditLedgerEntryRequest.Deserializer::class) +@JsonSerialize(using = AddCreditLedgerEntryRequest.Serializer::class) +class AddCreditLedgerEntryRequest +private constructor( + private val incrementCreditLedgerEntryRequestParams: + AddIncrementCreditLedgerEntryRequestParams? = + null, + private val decrementCreditLedgerEntryRequestParams: + AddDecrementCreditLedgerEntryRequestParams? = + null, + private val expirationChangeCreditLedgerEntryRequestParams: + AddExpirationChangeCreditLedgerEntryRequestParams? = + null, + private val voidCreditLedgerEntryRequestParams: AddVoidCreditLedgerEntryRequestParams? = null, + private val amendmentCreditLedgerEntryRequestParams: + AddAmendmentCreditLedgerEntryRequestParams? = + null, + private val _json: JsonValue? = null, +) { + + fun incrementCreditLedgerEntryRequestParams(): + Optional = + Optional.ofNullable(incrementCreditLedgerEntryRequestParams) + + fun decrementCreditLedgerEntryRequestParams(): + Optional = + Optional.ofNullable(decrementCreditLedgerEntryRequestParams) + + fun expirationChangeCreditLedgerEntryRequestParams(): + Optional = + Optional.ofNullable(expirationChangeCreditLedgerEntryRequestParams) + + fun voidCreditLedgerEntryRequestParams(): Optional = + Optional.ofNullable(voidCreditLedgerEntryRequestParams) + + fun amendmentCreditLedgerEntryRequestParams(): + Optional = + Optional.ofNullable(amendmentCreditLedgerEntryRequestParams) + + fun isIncrementCreditLedgerEntryRequestParams(): Boolean = + incrementCreditLedgerEntryRequestParams != null + + fun isDecrementCreditLedgerEntryRequestParams(): Boolean = + decrementCreditLedgerEntryRequestParams != null + + fun isExpirationChangeCreditLedgerEntryRequestParams(): Boolean = + expirationChangeCreditLedgerEntryRequestParams != null + + fun isVoidCreditLedgerEntryRequestParams(): Boolean = voidCreditLedgerEntryRequestParams != null + + fun isAmendmentCreditLedgerEntryRequestParams(): Boolean = + amendmentCreditLedgerEntryRequestParams != null + + fun asIncrementCreditLedgerEntryRequestParams(): AddIncrementCreditLedgerEntryRequestParams = + incrementCreditLedgerEntryRequestParams.getOrThrow( + "incrementCreditLedgerEntryRequestParams" + ) + + fun asDecrementCreditLedgerEntryRequestParams(): AddDecrementCreditLedgerEntryRequestParams = + decrementCreditLedgerEntryRequestParams.getOrThrow( + "decrementCreditLedgerEntryRequestParams" + ) + + fun asExpirationChangeCreditLedgerEntryRequestParams(): + AddExpirationChangeCreditLedgerEntryRequestParams = + expirationChangeCreditLedgerEntryRequestParams.getOrThrow( + "expirationChangeCreditLedgerEntryRequestParams" + ) + + fun asVoidCreditLedgerEntryRequestParams(): AddVoidCreditLedgerEntryRequestParams = + voidCreditLedgerEntryRequestParams.getOrThrow("voidCreditLedgerEntryRequestParams") + + fun asAmendmentCreditLedgerEntryRequestParams(): AddAmendmentCreditLedgerEntryRequestParams = + amendmentCreditLedgerEntryRequestParams.getOrThrow( + "amendmentCreditLedgerEntryRequestParams" + ) + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + incrementCreditLedgerEntryRequestParams != null -> + visitor.visitIncrementCreditLedgerEntryRequestParams( + incrementCreditLedgerEntryRequestParams + ) + decrementCreditLedgerEntryRequestParams != null -> + visitor.visitDecrementCreditLedgerEntryRequestParams( + decrementCreditLedgerEntryRequestParams + ) + expirationChangeCreditLedgerEntryRequestParams != null -> + visitor.visitExpirationChangeCreditLedgerEntryRequestParams( + expirationChangeCreditLedgerEntryRequestParams + ) + voidCreditLedgerEntryRequestParams != null -> + visitor.visitVoidCreditLedgerEntryRequestParams(voidCreditLedgerEntryRequestParams) + amendmentCreditLedgerEntryRequestParams != null -> + visitor.visitAmendmentCreditLedgerEntryRequestParams( + amendmentCreditLedgerEntryRequestParams + ) + else -> visitor.unknown(_json) + } + } + + private var validated: Boolean = false + + fun validate(): AddCreditLedgerEntryRequest = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitIncrementCreditLedgerEntryRequestParams( + incrementCreditLedgerEntryRequestParams: + AddIncrementCreditLedgerEntryRequestParams + ) { + incrementCreditLedgerEntryRequestParams.validate() + } + + override fun visitDecrementCreditLedgerEntryRequestParams( + decrementCreditLedgerEntryRequestParams: + AddDecrementCreditLedgerEntryRequestParams + ) { + decrementCreditLedgerEntryRequestParams.validate() + } + + override fun visitExpirationChangeCreditLedgerEntryRequestParams( + expirationChangeCreditLedgerEntryRequestParams: + AddExpirationChangeCreditLedgerEntryRequestParams + ) { + expirationChangeCreditLedgerEntryRequestParams.validate() + } + + override fun visitVoidCreditLedgerEntryRequestParams( + voidCreditLedgerEntryRequestParams: AddVoidCreditLedgerEntryRequestParams + ) { + voidCreditLedgerEntryRequestParams.validate() + } + + override fun visitAmendmentCreditLedgerEntryRequestParams( + amendmentCreditLedgerEntryRequestParams: + AddAmendmentCreditLedgerEntryRequestParams + ) { + amendmentCreditLedgerEntryRequestParams.validate() + } + } + ) + validated = true + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AddCreditLedgerEntryRequest && incrementCreditLedgerEntryRequestParams == other.incrementCreditLedgerEntryRequestParams && decrementCreditLedgerEntryRequestParams == other.decrementCreditLedgerEntryRequestParams && expirationChangeCreditLedgerEntryRequestParams == other.expirationChangeCreditLedgerEntryRequestParams && voidCreditLedgerEntryRequestParams == other.voidCreditLedgerEntryRequestParams && amendmentCreditLedgerEntryRequestParams == other.amendmentCreditLedgerEntryRequestParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(incrementCreditLedgerEntryRequestParams, decrementCreditLedgerEntryRequestParams, expirationChangeCreditLedgerEntryRequestParams, voidCreditLedgerEntryRequestParams, amendmentCreditLedgerEntryRequestParams) /* spotless:on */ + + override fun toString(): String = + when { + incrementCreditLedgerEntryRequestParams != null -> + "AddCreditLedgerEntryRequest{incrementCreditLedgerEntryRequestParams=$incrementCreditLedgerEntryRequestParams}" + decrementCreditLedgerEntryRequestParams != null -> + "AddCreditLedgerEntryRequest{decrementCreditLedgerEntryRequestParams=$decrementCreditLedgerEntryRequestParams}" + expirationChangeCreditLedgerEntryRequestParams != null -> + "AddCreditLedgerEntryRequest{expirationChangeCreditLedgerEntryRequestParams=$expirationChangeCreditLedgerEntryRequestParams}" + voidCreditLedgerEntryRequestParams != null -> + "AddCreditLedgerEntryRequest{voidCreditLedgerEntryRequestParams=$voidCreditLedgerEntryRequestParams}" + amendmentCreditLedgerEntryRequestParams != null -> + "AddCreditLedgerEntryRequest{amendmentCreditLedgerEntryRequestParams=$amendmentCreditLedgerEntryRequestParams}" + _json != null -> "AddCreditLedgerEntryRequest{_unknown=$_json}" + else -> throw IllegalStateException("Invalid AddCreditLedgerEntryRequest") + } + + companion object { + + @JvmStatic + fun ofIncrementCreditLedgerEntryRequestParams( + incrementCreditLedgerEntryRequestParams: AddIncrementCreditLedgerEntryRequestParams + ) = + AddCreditLedgerEntryRequest( + incrementCreditLedgerEntryRequestParams = incrementCreditLedgerEntryRequestParams + ) + + @JvmStatic + fun ofDecrementCreditLedgerEntryRequestParams( + decrementCreditLedgerEntryRequestParams: AddDecrementCreditLedgerEntryRequestParams + ) = + AddCreditLedgerEntryRequest( + decrementCreditLedgerEntryRequestParams = decrementCreditLedgerEntryRequestParams + ) + + @JvmStatic + fun ofExpirationChangeCreditLedgerEntryRequestParams( + expirationChangeCreditLedgerEntryRequestParams: + AddExpirationChangeCreditLedgerEntryRequestParams + ) = + AddCreditLedgerEntryRequest( + expirationChangeCreditLedgerEntryRequestParams = + expirationChangeCreditLedgerEntryRequestParams + ) + + @JvmStatic + fun ofVoidCreditLedgerEntryRequestParams( + voidCreditLedgerEntryRequestParams: AddVoidCreditLedgerEntryRequestParams + ) = + AddCreditLedgerEntryRequest( + voidCreditLedgerEntryRequestParams = voidCreditLedgerEntryRequestParams + ) + + @JvmStatic + fun ofAmendmentCreditLedgerEntryRequestParams( + amendmentCreditLedgerEntryRequestParams: AddAmendmentCreditLedgerEntryRequestParams + ) = + AddCreditLedgerEntryRequest( + amendmentCreditLedgerEntryRequestParams = amendmentCreditLedgerEntryRequestParams + ) + } + + /** + * An interface that defines how to map each variant of [AddCreditLedgerEntryRequest] to a value + * of type [T]. + */ + interface Visitor { + + fun visitIncrementCreditLedgerEntryRequestParams( + incrementCreditLedgerEntryRequestParams: AddIncrementCreditLedgerEntryRequestParams + ): T + + fun visitDecrementCreditLedgerEntryRequestParams( + decrementCreditLedgerEntryRequestParams: AddDecrementCreditLedgerEntryRequestParams + ): T + + fun visitExpirationChangeCreditLedgerEntryRequestParams( + expirationChangeCreditLedgerEntryRequestParams: + AddExpirationChangeCreditLedgerEntryRequestParams + ): T + + fun visitVoidCreditLedgerEntryRequestParams( + voidCreditLedgerEntryRequestParams: AddVoidCreditLedgerEntryRequestParams + ): T + + fun visitAmendmentCreditLedgerEntryRequestParams( + amendmentCreditLedgerEntryRequestParams: AddAmendmentCreditLedgerEntryRequestParams + ): T + + /** + * Maps an unknown variant of [AddCreditLedgerEntryRequest] to a value of type [T]. + * + * An instance of [AddCreditLedgerEntryRequest] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the SDK is + * on an older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown AddCreditLedgerEntryRequest: $json") + } + } + + internal class Deserializer : + BaseDeserializer(AddCreditLedgerEntryRequest::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): AddCreditLedgerEntryRequest { + val json = JsonValue.fromJsonNode(node) + val entryType = json.asObject().getOrNull()?.get("entry_type")?.asString()?.getOrNull() + + when (entryType) { + "increment" -> { + tryDeserialize( + node, + jacksonTypeRef(), + ) { + it.validate() + } + ?.let { + return AddCreditLedgerEntryRequest( + incrementCreditLedgerEntryRequestParams = it, + _json = json, + ) + } + } + "decrement" -> { + tryDeserialize( + node, + jacksonTypeRef(), + ) { + it.validate() + } + ?.let { + return AddCreditLedgerEntryRequest( + decrementCreditLedgerEntryRequestParams = it, + _json = json, + ) + } + } + "expiration_change" -> { + tryDeserialize( + node, + jacksonTypeRef(), + ) { + it.validate() + } + ?.let { + return AddCreditLedgerEntryRequest( + expirationChangeCreditLedgerEntryRequestParams = it, + _json = json, + ) + } + } + "void" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return AddCreditLedgerEntryRequest( + voidCreditLedgerEntryRequestParams = it, + _json = json, + ) + } + } + "amendment" -> { + tryDeserialize( + node, + jacksonTypeRef(), + ) { + it.validate() + } + ?.let { + return AddCreditLedgerEntryRequest( + amendmentCreditLedgerEntryRequestParams = it, + _json = json, + ) + } + } + } + + return AddCreditLedgerEntryRequest(_json = json) + } + } + + internal class Serializer : + BaseSerializer(AddCreditLedgerEntryRequest::class) { + + override fun serialize( + value: AddCreditLedgerEntryRequest, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.incrementCreditLedgerEntryRequestParams != null -> + generator.writeObject(value.incrementCreditLedgerEntryRequestParams) + value.decrementCreditLedgerEntryRequestParams != null -> + generator.writeObject(value.decrementCreditLedgerEntryRequestParams) + value.expirationChangeCreditLedgerEntryRequestParams != null -> + generator.writeObject(value.expirationChangeCreditLedgerEntryRequestParams) + value.voidCreditLedgerEntryRequestParams != null -> + generator.writeObject(value.voidCreditLedgerEntryRequestParams) + value.amendmentCreditLedgerEntryRequestParams != null -> + generator.writeObject(value.amendmentCreditLedgerEntryRequestParams) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid AddCreditLedgerEntryRequest") + } + } + } + + @NoAutoDetect + class AddIncrementCreditLedgerEntryRequestParams + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") + @ExcludeMissing + private val entryType: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("effective_date") + @ExcludeMissing + private val effectiveDate: JsonField = JsonMissing.of(), + @JsonProperty("expiry_date") + @ExcludeMissing + private val expiryDate: JsonField = JsonMissing.of(), + @JsonProperty("invoice_settings") + @ExcludeMissing + private val invoiceSettings: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_cost_basis") + @ExcludeMissing + private val perUnitCostBasis: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** + * The number of credits to effect. Note that this is required for increment, decrement, + * void, or undo operations. + */ + fun amount(): Double = amount.getRequired("amount") + + fun entryType(): EntryType = entryType.getRequired("entry_type") + + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a real-world + * currency, it must match the customer's invoicing currency. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** + * An ISO 8601 format date that denotes when this credit balance should become available for + * use. + */ + fun effectiveDate(): Optional = + Optional.ofNullable(effectiveDate.getNullable("effective_date")) + + /** An ISO 8601 format date that denotes when this credit balance should expire. */ + fun expiryDate(): Optional = + Optional.ofNullable(expiryDate.getNullable("expiry_date")) + + /** + * Passing `invoice_settings` automatically generates an invoice for the newly added + * credits. If `invoice_settings` is passed, you must specify per_unit_cost_basis, as the + * calculation of the invoice total is done on that basis. + */ + fun invoiceSettings(): Optional = + Optional.ofNullable(invoiceSettings.getNullable("invoice_settings")) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * Can only be specified when entry_type=increment. How much, in the customer's currency, a + * customer paid for a single credit in this block + */ + fun perUnitCostBasis(): Optional = + Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) + + /** + * The number of credits to effect. Note that this is required for increment, decrement, + * void, or undo operations. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType + + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a real-world + * currency, it must match the customer's invoicing currency. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * An ISO 8601 format date that denotes when this credit balance should become available for + * use. + */ + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate + + /** An ISO 8601 format date that denotes when this credit balance should expire. */ + @JsonProperty("expiry_date") + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate + + /** + * Passing `invoice_settings` automatically generates an invoice for the newly added + * credits. If `invoice_settings` is passed, you must specify per_unit_cost_basis, as the + * calculation of the invoice total is done on that basis. + */ + @JsonProperty("invoice_settings") + @ExcludeMissing + fun _invoiceSettings(): JsonField = invoiceSettings + + /** + * User-specified key/value pairs for the resource. 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Can only be specified when entry_type=increment. How much, in the customer's currency, a + * customer paid for a single credit in this block + */ + @JsonProperty("per_unit_cost_basis") + @ExcludeMissing + fun _perUnitCostBasis(): JsonField = perUnitCostBasis + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): AddIncrementCreditLedgerEntryRequestParams = apply { + if (validated) { + return@apply + } + + amount() + entryType() + currency() + description() + effectiveDate() + expiryDate() + invoiceSettings().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + perUnitCostBasis() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AddIncrementCreditLedgerEntryRequestParams]. + * + * The following fields are required: + * ```java + * .amount() + * .entryType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AddIncrementCreditLedgerEntryRequestParams]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var entryType: JsonField? = null + private var currency: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var effectiveDate: JsonField = JsonMissing.of() + private var expiryDate: JsonField = JsonMissing.of() + private var invoiceSettings: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var perUnitCostBasis: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + addIncrementCreditLedgerEntryRequestParams: + AddIncrementCreditLedgerEntryRequestParams + ) = apply { + amount = addIncrementCreditLedgerEntryRequestParams.amount + entryType = addIncrementCreditLedgerEntryRequestParams.entryType + currency = addIncrementCreditLedgerEntryRequestParams.currency + description = addIncrementCreditLedgerEntryRequestParams.description + effectiveDate = addIncrementCreditLedgerEntryRequestParams.effectiveDate + expiryDate = addIncrementCreditLedgerEntryRequestParams.expiryDate + invoiceSettings = addIncrementCreditLedgerEntryRequestParams.invoiceSettings + metadata = addIncrementCreditLedgerEntryRequestParams.metadata + perUnitCostBasis = addIncrementCreditLedgerEntryRequestParams.perUnitCostBasis + additionalProperties = + addIncrementCreditLedgerEntryRequestParams.additionalProperties.toMutableMap() + } + + /** + * The number of credits to effect. Note that this is required for increment, decrement, + * void, or undo operations. + */ + fun amount(amount: Double) = amount(JsonField.of(amount)) + + /** + * The number of credits to effect. Note that this is required for increment, decrement, + * void, or undo operations. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) + + fun entryType(entryType: JsonField) = apply { this.entryType = entryType } + + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a + * real-world currency, it must match the customer's invoicing currency. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a + * real-world currency, it must match the customer's invoicing currency. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) + + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a + * real-world currency, it must match the customer's invoicing currency. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(description: Optional) = description(description.orElse(null)) + + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + /** + * An ISO 8601 format date that denotes when this credit balance should become available + * for use. + */ + fun effectiveDate(effectiveDate: OffsetDateTime?) = + effectiveDate(JsonField.ofNullable(effectiveDate)) + + /** + * An ISO 8601 format date that denotes when this credit balance should become available + * for use. + */ + fun effectiveDate(effectiveDate: Optional) = + effectiveDate(effectiveDate.orElse(null)) + + /** + * An ISO 8601 format date that denotes when this credit balance should become available + * for use. + */ + fun effectiveDate(effectiveDate: JsonField) = apply { + this.effectiveDate = effectiveDate + } + + /** An ISO 8601 format date that denotes when this credit balance should expire. */ + fun expiryDate(expiryDate: OffsetDateTime?) = + expiryDate(JsonField.ofNullable(expiryDate)) + + /** An ISO 8601 format date that denotes when this credit balance should expire. */ + fun expiryDate(expiryDate: Optional) = + expiryDate(expiryDate.orElse(null)) + + /** An ISO 8601 format date that denotes when this credit balance should expire. */ + fun expiryDate(expiryDate: JsonField) = apply { + this.expiryDate = expiryDate + } + + /** + * Passing `invoice_settings` automatically generates an invoice for the newly added + * credits. If `invoice_settings` is passed, you must specify per_unit_cost_basis, as + * the calculation of the invoice total is done on that basis. + */ + fun invoiceSettings(invoiceSettings: InvoiceSettings?) = + invoiceSettings(JsonField.ofNullable(invoiceSettings)) + + /** + * Passing `invoice_settings` automatically generates an invoice for the newly added + * credits. If `invoice_settings` is passed, you must specify per_unit_cost_basis, as + * the calculation of the invoice total is done on that basis. + */ + fun invoiceSettings(invoiceSettings: Optional) = + invoiceSettings(invoiceSettings.orElse(null)) + + /** + * Passing `invoice_settings` automatically generates an invoice for the newly added + * credits. If `invoice_settings` is passed, you must specify per_unit_cost_basis, as + * the calculation of the invoice total is done on that basis. + */ + fun invoiceSettings(invoiceSettings: JsonField) = apply { + this.invoiceSettings = invoiceSettings + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: JsonField) = apply { this.metadata = metadata } + + /** + * Can only be specified when entry_type=increment. How much, in the customer's + * currency, a customer paid for a single credit in this block + */ + fun perUnitCostBasis(perUnitCostBasis: String?) = + perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) + + /** + * Can only be specified when entry_type=increment. How much, in the customer's + * currency, a customer paid for a single credit in this block + */ + fun perUnitCostBasis(perUnitCostBasis: Optional) = + perUnitCostBasis(perUnitCostBasis.orElse(null)) + + /** + * Can only be specified when entry_type=increment. How much, in the customer's + * currency, a customer paid for a single credit in this block + */ + fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { + this.perUnitCostBasis = perUnitCostBasis + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): AddIncrementCreditLedgerEntryRequestParams = + AddIncrementCreditLedgerEntryRequestParams( + checkRequired("amount", amount), + checkRequired("entryType", entryType), + currency, + description, + effectiveDate, + expiryDate, + invoiceSettings, + metadata, + perUnitCostBasis, + additionalProperties.toImmutable(), + ) + } + + class EntryType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val INCREMENT = of("increment") + + @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) + } + + /** An enum containing [EntryType]'s known values. */ + enum class Known { + INCREMENT + } + + /** + * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [EntryType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INCREMENT, + /** + * An enum member indicating that [EntryType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INCREMENT -> Value.INCREMENT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INCREMENT -> Known.INCREMENT + else -> throw OrbInvalidDataException("Unknown EntryType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Passing `invoice_settings` automatically generates an invoice for the newly added + * credits. If `invoice_settings` is passed, you must specify per_unit_cost_basis, as the + * calculation of the invoice total is done on that basis. + */ + @NoAutoDetect + class InvoiceSettings + @JsonCreator + private constructor( + @JsonProperty("auto_collection") + @ExcludeMissing + private val autoCollection: JsonField = JsonMissing.of(), + @JsonProperty("net_terms") + @ExcludeMissing + private val netTerms: JsonField = JsonMissing.of(), + @JsonProperty("memo") + @ExcludeMissing + private val memo: JsonField = JsonMissing.of(), + @JsonProperty("require_successful_payment") + @ExcludeMissing + private val requireSuccessfulPayment: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** + * Whether the credits purchase invoice should auto collect with the customer's saved + * payment method. + */ + fun autoCollection(): Boolean = autoCollection.getRequired("auto_collection") + + /** + * The net terms determines the difference between the invoice date and the issue date + * for the invoice. If you intend the invoice to be due on issue, set this to 0. + */ + fun netTerms(): Long = netTerms.getRequired("net_terms") + + /** An optional memo to display on the invoice. */ + fun memo(): Optional = Optional.ofNullable(memo.getNullable("memo")) + + /** + * If true, the new credit block will require that the corresponding invoice is paid + * before it can be drawn down from. + */ + fun requireSuccessfulPayment(): Optional = + Optional.ofNullable( + requireSuccessfulPayment.getNullable("require_successful_payment") + ) + + /** + * Whether the credits purchase invoice should auto collect with the customer's saved + * payment method. + */ + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection + + /** + * The net terms determines the difference between the invoice date and the issue date + * for the invoice. If you intend the invoice to be due on issue, set this to 0. + */ + @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms + + /** An optional memo to display on the invoice. */ + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo + + /** + * If true, the new credit block will require that the corresponding invoice is paid + * before it can be drawn down from. + */ + @JsonProperty("require_successful_payment") + @ExcludeMissing + fun _requireSuccessfulPayment(): JsonField = requireSuccessfulPayment + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): InvoiceSettings = apply { + if (validated) { + return@apply + } + + autoCollection() + netTerms() + memo() + requireSuccessfulPayment() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InvoiceSettings]. + * + * The following fields are required: + * ```java + * .autoCollection() + * .netTerms() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InvoiceSettings]. */ + class Builder internal constructor() { + + private var autoCollection: JsonField? = null + private var netTerms: JsonField? = null + private var memo: JsonField = JsonMissing.of() + private var requireSuccessfulPayment: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(invoiceSettings: InvoiceSettings) = apply { + autoCollection = invoiceSettings.autoCollection + netTerms = invoiceSettings.netTerms + memo = invoiceSettings.memo + requireSuccessfulPayment = invoiceSettings.requireSuccessfulPayment + additionalProperties = invoiceSettings.additionalProperties.toMutableMap() + } + + /** + * Whether the credits purchase invoice should auto collect with the customer's + * saved payment method. + */ + fun autoCollection(autoCollection: Boolean) = + autoCollection(JsonField.of(autoCollection)) + + /** + * Whether the credits purchase invoice should auto collect with the customer's + * saved payment method. + */ + fun autoCollection(autoCollection: JsonField) = apply { + this.autoCollection = autoCollection + } + + /** + * The net terms determines the difference between the invoice date and the issue + * date for the invoice. If you intend the invoice to be due on issue, set this + * to 0. + */ + fun netTerms(netTerms: Long) = netTerms(JsonField.of(netTerms)) + + /** + * The net terms determines the difference between the invoice date and the issue + * date for the invoice. If you intend the invoice to be due on issue, set this + * to 0. + */ + fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } + + /** An optional memo to display on the invoice. */ + fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) + + /** An optional memo to display on the invoice. */ + fun memo(memo: Optional) = memo(memo.orElse(null)) + + /** An optional memo to display on the invoice. */ + fun memo(memo: JsonField) = apply { this.memo = memo } + + /** + * If true, the new credit block will require that the corresponding invoice is paid + * before it can be drawn down from. + */ + fun requireSuccessfulPayment(requireSuccessfulPayment: Boolean) = + requireSuccessfulPayment(JsonField.of(requireSuccessfulPayment)) + + /** + * If true, the new credit block will require that the corresponding invoice is paid + * before it can be drawn down from. + */ + fun requireSuccessfulPayment(requireSuccessfulPayment: JsonField) = apply { + this.requireSuccessfulPayment = requireSuccessfulPayment + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): InvoiceSettings = + InvoiceSettings( + checkRequired("autoCollection", autoCollection), + checkRequired("netTerms", netTerms), + memo, + requireSuccessfulPayment, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InvoiceSettings && autoCollection == other.autoCollection && netTerms == other.netTerms && memo == other.memo && requireSuccessfulPayment == other.requireSuccessfulPayment && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(autoCollection, netTerms, memo, requireSuccessfulPayment, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InvoiceSettings{autoCollection=$autoCollection, netTerms=$netTerms, memo=$memo, requireSuccessfulPayment=$requireSuccessfulPayment, 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`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AddIncrementCreditLedgerEntryRequestParams && amount == other.amount && entryType == other.entryType && currency == other.currency && description == other.description && effectiveDate == other.effectiveDate && expiryDate == other.expiryDate && invoiceSettings == other.invoiceSettings && metadata == other.metadata && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(amount, entryType, currency, description, effectiveDate, expiryDate, invoiceSettings, metadata, perUnitCostBasis, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AddIncrementCreditLedgerEntryRequestParams{amount=$amount, entryType=$entryType, currency=$currency, description=$description, effectiveDate=$effectiveDate, expiryDate=$expiryDate, invoiceSettings=$invoiceSettings, metadata=$metadata, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class AddDecrementCreditLedgerEntryRequestParams + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") + @ExcludeMissing + private val entryType: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** + * The number of credits to effect. Note that this is required for increment, decrement, + * void, or undo operations. + */ + fun amount(): Double = amount.getRequired("amount") + + fun entryType(): EntryType = entryType.getRequired("entry_type") + + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a real-world + * currency, it must match the customer's invoicing currency. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * The number of credits to effect. Note that this is required for increment, decrement, + * void, or undo operations. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType + + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a real-world + * currency, it must match the customer's invoicing currency. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * User-specified key/value pairs for the resource. 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): AddDecrementCreditLedgerEntryRequestParams = apply { + if (validated) { + return@apply + } + + amount() + entryType() + currency() + description() + metadata().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AddDecrementCreditLedgerEntryRequestParams]. + * + * The following fields are required: + * ```java + * .amount() + * .entryType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AddDecrementCreditLedgerEntryRequestParams]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var entryType: JsonField? = null + private var currency: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + addDecrementCreditLedgerEntryRequestParams: + AddDecrementCreditLedgerEntryRequestParams + ) = apply { + amount = addDecrementCreditLedgerEntryRequestParams.amount + entryType = addDecrementCreditLedgerEntryRequestParams.entryType + currency = addDecrementCreditLedgerEntryRequestParams.currency + description = addDecrementCreditLedgerEntryRequestParams.description + metadata = addDecrementCreditLedgerEntryRequestParams.metadata + additionalProperties = + addDecrementCreditLedgerEntryRequestParams.additionalProperties.toMutableMap() + } + + /** + * The number of credits to effect. Note that this is required for increment, decrement, + * void, or undo operations. + */ + fun amount(amount: Double) = amount(JsonField.of(amount)) + + /** + * The number of credits to effect. Note that this is required for increment, decrement, + * void, or undo operations. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) + + fun entryType(entryType: JsonField) = apply { this.entryType = entryType } + + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a + * real-world currency, it must match the customer's invoicing currency. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a + * real-world currency, it must match the customer's invoicing currency. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) + + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a + * real-world currency, it must match the customer's invoicing currency. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(description: Optional) = description(description.orElse(null)) + + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) + } + + fun build(): AddDecrementCreditLedgerEntryRequestParams = + AddDecrementCreditLedgerEntryRequestParams( + checkRequired("amount", amount), + checkRequired("entryType", entryType), + currency, + description, + metadata, + additionalProperties.toImmutable(), + ) + } + + class EntryType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val DECREMENT = of("decrement") + + @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) + } + + /** An enum containing [EntryType]'s known values. */ + enum class Known { + DECREMENT + } + + /** + * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [EntryType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + DECREMENT, + /** + * An enum member indicating that [EntryType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + DECREMENT -> Value.DECREMENT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + DECREMENT -> Known.DECREMENT + else -> throw OrbInvalidDataException("Unknown EntryType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AddDecrementCreditLedgerEntryRequestParams && amount == other.amount && entryType == other.entryType && currency == other.currency && description == other.description && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(amount, entryType, currency, description, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AddDecrementCreditLedgerEntryRequestParams{amount=$amount, entryType=$entryType, currency=$currency, description=$description, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class AddExpirationChangeCreditLedgerEntryRequestParams + @JsonCreator + private constructor( + @JsonProperty("entry_type") + @ExcludeMissing + private val entryType: JsonField = JsonMissing.of(), + @JsonProperty("expiry_date") + @ExcludeMissing + private val expiryDate: JsonField = JsonMissing.of(), + @JsonProperty("target_expiry_date") + @ExcludeMissing + private val targetExpiryDate: JsonField = JsonMissing.of(), + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("block_id") + @ExcludeMissing + private val blockId: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun entryType(): EntryType = entryType.getRequired("entry_type") + + /** An ISO 8601 format date that identifies the origination credit block to expire */ + fun expiryDate(): Optional = + Optional.ofNullable(expiryDate.getNullable("expiry_date")) + + /** + * 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. + */ + fun targetExpiryDate(): LocalDate = targetExpiryDate.getRequired("target_expiry_date") + + /** + * The number of credits to effect. Note that this is required for increment, decrement, + * void, or undo operations. + */ + fun amount(): Optional = Optional.ofNullable(amount.getNullable("amount")) + + /** + * The ID of the block affected by an expiration_change, used to differentiate between + * multiple blocks with the same `expiry_date`. + */ + fun blockId(): Optional = Optional.ofNullable(blockId.getNullable("block_id")) + + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a real-world + * currency, it must match the customer's invoicing currency. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType + + /** An ISO 8601 format date that identifies the origination credit block to expire */ + @JsonProperty("expiry_date") + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate + + /** + * 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. + */ + @JsonProperty("target_expiry_date") + @ExcludeMissing + fun _targetExpiryDate(): JsonField = targetExpiryDate + + /** + * The number of credits to effect. Note that this is required for increment, decrement, + * void, or undo operations. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * The ID of the block affected by an expiration_change, used to differentiate between + * multiple blocks with the same `expiry_date`. + */ + @JsonProperty("block_id") @ExcludeMissing fun _blockId(): JsonField = blockId + + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a real-world + * currency, it must match the customer's invoicing currency. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * User-specified key/value pairs for the resource. 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): AddExpirationChangeCreditLedgerEntryRequestParams = apply { + if (validated) { + return@apply + } + + entryType() + expiryDate() + targetExpiryDate() + amount() + blockId() + currency() + description() + metadata().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AddExpirationChangeCreditLedgerEntryRequestParams]. + * + * The following fields are required: + * ```java + * .entryType() + * .expiryDate() + * .targetExpiryDate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AddExpirationChangeCreditLedgerEntryRequestParams]. */ + class Builder internal constructor() { + + private var entryType: JsonField? = null + private var expiryDate: JsonField? = null + private var targetExpiryDate: JsonField? = null + private var amount: JsonField = JsonMissing.of() + private var blockId: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + addExpirationChangeCreditLedgerEntryRequestParams: + AddExpirationChangeCreditLedgerEntryRequestParams + ) = apply { + entryType = addExpirationChangeCreditLedgerEntryRequestParams.entryType + expiryDate = addExpirationChangeCreditLedgerEntryRequestParams.expiryDate + targetExpiryDate = + addExpirationChangeCreditLedgerEntryRequestParams.targetExpiryDate + amount = addExpirationChangeCreditLedgerEntryRequestParams.amount + blockId = addExpirationChangeCreditLedgerEntryRequestParams.blockId + currency = addExpirationChangeCreditLedgerEntryRequestParams.currency + description = addExpirationChangeCreditLedgerEntryRequestParams.description + metadata = addExpirationChangeCreditLedgerEntryRequestParams.metadata + additionalProperties = + addExpirationChangeCreditLedgerEntryRequestParams.additionalProperties + .toMutableMap() + } + + fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) + + fun entryType(entryType: JsonField) = apply { this.entryType = entryType } + + /** An ISO 8601 format date that identifies the origination credit block to expire */ + fun expiryDate(expiryDate: OffsetDateTime?) = + expiryDate(JsonField.ofNullable(expiryDate)) + + /** An ISO 8601 format date that identifies the origination credit block to expire */ + fun expiryDate(expiryDate: Optional) = + expiryDate(expiryDate.orElse(null)) + + /** An ISO 8601 format date that identifies the origination credit block to expire */ + fun expiryDate(expiryDate: JsonField) = apply { + this.expiryDate = expiryDate + } + + /** + * 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. + */ + fun targetExpiryDate(targetExpiryDate: LocalDate) = + targetExpiryDate(JsonField.of(targetExpiryDate)) + + /** + * 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. + */ + fun targetExpiryDate(targetExpiryDate: JsonField) = apply { + this.targetExpiryDate = targetExpiryDate + } + + /** + * The number of credits to effect. Note that this is required for increment, decrement, + * void, or undo operations. + */ + fun amount(amount: Double?) = amount(JsonField.ofNullable(amount)) + + /** + * The number of credits to effect. Note that this is required for increment, decrement, + * void, or undo operations. + */ + fun amount(amount: Double) = amount(amount as Double?) + + /** + * The number of credits to effect. Note that this is required for increment, decrement, + * void, or undo operations. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun amount(amount: Optional) = amount(amount.orElse(null) as Double?) + + /** + * The number of credits to effect. Note that this is required for increment, decrement, + * void, or undo operations. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** + * The ID of the block affected by an expiration_change, used to differentiate between + * multiple blocks with the same `expiry_date`. + */ + fun blockId(blockId: String?) = blockId(JsonField.ofNullable(blockId)) + + /** + * The ID of the block affected by an expiration_change, used to differentiate between + * multiple blocks with the same `expiry_date`. + */ + fun blockId(blockId: Optional) = blockId(blockId.orElse(null)) + + /** + * The ID of the block affected by an expiration_change, used to differentiate between + * multiple blocks with the same `expiry_date`. + */ + fun blockId(blockId: JsonField) = apply { this.blockId = blockId } + + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a + * real-world currency, it must match the customer's invoicing currency. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a + * real-world currency, it must match the customer's invoicing currency. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) + + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a + * real-world currency, it must match the customer's invoicing currency. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(description: Optional) = description(description.orElse(null)) + + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) + } + + fun build(): AddExpirationChangeCreditLedgerEntryRequestParams = + AddExpirationChangeCreditLedgerEntryRequestParams( + checkRequired("entryType", entryType), + checkRequired("expiryDate", expiryDate), + checkRequired("targetExpiryDate", targetExpiryDate), + amount, + blockId, + currency, + description, + metadata, + additionalProperties.toImmutable(), + ) + } + + class EntryType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val EXPIRATION_CHANGE = of("expiration_change") + + @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) + } + + /** An enum containing [EntryType]'s known values. */ + enum class Known { + EXPIRATION_CHANGE + } + + /** + * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [EntryType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + EXPIRATION_CHANGE, + /** + * An enum member indicating that [EntryType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + EXPIRATION_CHANGE -> Value.EXPIRATION_CHANGE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + EXPIRATION_CHANGE -> Known.EXPIRATION_CHANGE + else -> throw OrbInvalidDataException("Unknown EntryType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AddExpirationChangeCreditLedgerEntryRequestParams && entryType == other.entryType && expiryDate == other.expiryDate && targetExpiryDate == other.targetExpiryDate && amount == other.amount && blockId == other.blockId && currency == other.currency && description == other.description && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(entryType, expiryDate, targetExpiryDate, amount, blockId, currency, description, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AddExpirationChangeCreditLedgerEntryRequestParams{entryType=$entryType, expiryDate=$expiryDate, targetExpiryDate=$targetExpiryDate, amount=$amount, blockId=$blockId, currency=$currency, description=$description, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class AddVoidCreditLedgerEntryRequestParams + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("block_id") + @ExcludeMissing + private val blockId: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") + @ExcludeMissing + private val entryType: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("void_reason") + @ExcludeMissing + private val voidReason: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** + * The number of credits to effect. Note that this is required for increment, decrement, + * void, or undo operations. + */ + fun amount(): Double = amount.getRequired("amount") + + /** The ID of the block to void. */ + fun blockId(): String = blockId.getRequired("block_id") + + fun entryType(): EntryType = entryType.getRequired("entry_type") + + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a real-world + * currency, it must match the customer's invoicing currency. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** Can only be specified when `entry_type=void`. The reason for the void. */ + fun voidReason(): Optional = + Optional.ofNullable(voidReason.getNullable("void_reason")) + + /** + * The number of credits to effect. Note that this is required for increment, decrement, + * void, or undo operations. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** The ID of the block to void. */ + @JsonProperty("block_id") @ExcludeMissing fun _blockId(): JsonField = blockId + + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType + + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a real-world + * currency, it must match the customer's invoicing currency. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * User-specified key/value pairs for the resource. 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** Can only be specified when `entry_type=void`. The reason for the void. */ + @JsonProperty("void_reason") + @ExcludeMissing + fun _voidReason(): JsonField = voidReason + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): AddVoidCreditLedgerEntryRequestParams = apply { + if (validated) { + return@apply + } + + amount() + blockId() + entryType() + currency() + description() + metadata().ifPresent { it.validate() } + voidReason() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AddVoidCreditLedgerEntryRequestParams]. + * + * The following fields are required: + * ```java + * .amount() + * .blockId() + * .entryType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AddVoidCreditLedgerEntryRequestParams]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var blockId: JsonField? = null + private var entryType: JsonField? = null + private var currency: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var voidReason: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + addVoidCreditLedgerEntryRequestParams: AddVoidCreditLedgerEntryRequestParams + ) = apply { + amount = addVoidCreditLedgerEntryRequestParams.amount + blockId = addVoidCreditLedgerEntryRequestParams.blockId + entryType = addVoidCreditLedgerEntryRequestParams.entryType + currency = addVoidCreditLedgerEntryRequestParams.currency + description = addVoidCreditLedgerEntryRequestParams.description + metadata = addVoidCreditLedgerEntryRequestParams.metadata + voidReason = addVoidCreditLedgerEntryRequestParams.voidReason + additionalProperties = + addVoidCreditLedgerEntryRequestParams.additionalProperties.toMutableMap() + } + + /** + * The number of credits to effect. Note that this is required for increment, decrement, + * void, or undo operations. + */ + fun amount(amount: Double) = amount(JsonField.of(amount)) + + /** + * The number of credits to effect. Note that this is required for increment, decrement, + * void, or undo operations. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The ID of the block to void. */ + fun blockId(blockId: String) = blockId(JsonField.of(blockId)) + + /** The ID of the block to void. */ + fun blockId(blockId: JsonField) = apply { this.blockId = blockId } + + fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) + + fun entryType(entryType: JsonField) = apply { this.entryType = entryType } + + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a + * real-world currency, it must match the customer's invoicing currency. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a + * real-world currency, it must match the customer's invoicing currency. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) + + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a + * real-world currency, it must match the customer's invoicing currency. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(description: Optional) = description(description.orElse(null)) + + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: JsonField) = apply { this.metadata = metadata } + + /** Can only be specified when `entry_type=void`. The reason for the void. */ + fun voidReason(voidReason: VoidReason?) = voidReason(JsonField.ofNullable(voidReason)) + + /** Can only be specified when `entry_type=void`. The reason for the void. */ + fun voidReason(voidReason: Optional) = voidReason(voidReason.orElse(null)) + + /** Can only be specified when `entry_type=void`. The reason for the void. */ + fun voidReason(voidReason: JsonField) = apply { + this.voidReason = voidReason + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): AddVoidCreditLedgerEntryRequestParams = + AddVoidCreditLedgerEntryRequestParams( + checkRequired("amount", amount), + checkRequired("blockId", blockId), + checkRequired("entryType", entryType), + currency, + description, + metadata, + voidReason, + additionalProperties.toImmutable(), + ) + } + + class EntryType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val VOID = of("void") + + @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) + } + + /** An enum containing [EntryType]'s known values. */ + enum class Known { + VOID + } + + /** + * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [EntryType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + VOID, + /** + * An enum member indicating that [EntryType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + VOID -> Value.VOID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + VOID -> Known.VOID + else -> throw OrbInvalidDataException("Unknown EntryType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + /** Can only be specified when `entry_type=void`. The reason for the void. */ + class VoidReason @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val REFUND = of("refund") + + @JvmStatic fun of(value: String) = VoidReason(JsonField.of(value)) + } + + /** An enum containing [VoidReason]'s known values. */ + enum class Known { + REFUND + } + + /** + * An enum containing [VoidReason]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [VoidReason] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + REFUND, + /** + * An enum member indicating that [VoidReason] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + REFUND -> Value.REFUND + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + REFUND -> Known.REFUND + else -> throw OrbInvalidDataException("Unknown VoidReason: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if 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 + } + + return /* spotless:off */ other is VoidReason && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AddVoidCreditLedgerEntryRequestParams && amount == other.amount && blockId == other.blockId && entryType == other.entryType && currency == other.currency && description == other.description && metadata == other.metadata && voidReason == other.voidReason && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(amount, blockId, entryType, currency, description, metadata, voidReason, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AddVoidCreditLedgerEntryRequestParams{amount=$amount, blockId=$blockId, entryType=$entryType, currency=$currency, description=$description, metadata=$metadata, voidReason=$voidReason, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class AddAmendmentCreditLedgerEntryRequestParams + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("block_id") + @ExcludeMissing + private val blockId: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") + @ExcludeMissing + private val entryType: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** + * The number of credits to effect. Note that this is required for increment, decrement or + * void operations. + */ + fun amount(): Double = amount.getRequired("amount") + + /** The ID of the block to reverse a decrement from. */ + fun blockId(): String = blockId.getRequired("block_id") + + fun entryType(): EntryType = entryType.getRequired("entry_type") + + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a real-world + * currency, it must match the customer's invoicing currency. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * The number of credits to effect. Note that this is required for increment, decrement or + * void operations. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** The ID of the block to reverse a decrement from. */ + @JsonProperty("block_id") @ExcludeMissing fun _blockId(): JsonField = blockId + + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType + + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a real-world + * currency, it must match the customer's invoicing currency. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * User-specified key/value pairs for the resource. 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): AddAmendmentCreditLedgerEntryRequestParams = apply { + if (validated) { + return@apply + } + + amount() + blockId() + entryType() + currency() + description() + metadata().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AddAmendmentCreditLedgerEntryRequestParams]. + * + * The following fields are required: + * ```java + * .amount() + * .blockId() + * .entryType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AddAmendmentCreditLedgerEntryRequestParams]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var blockId: JsonField? = null + private var entryType: JsonField? = null + private var currency: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + addAmendmentCreditLedgerEntryRequestParams: + AddAmendmentCreditLedgerEntryRequestParams + ) = apply { + amount = addAmendmentCreditLedgerEntryRequestParams.amount + blockId = addAmendmentCreditLedgerEntryRequestParams.blockId + entryType = addAmendmentCreditLedgerEntryRequestParams.entryType + currency = addAmendmentCreditLedgerEntryRequestParams.currency + description = addAmendmentCreditLedgerEntryRequestParams.description + metadata = addAmendmentCreditLedgerEntryRequestParams.metadata + additionalProperties = + addAmendmentCreditLedgerEntryRequestParams.additionalProperties.toMutableMap() + } + + /** + * The number of credits to effect. Note that this is required for increment, decrement + * or void operations. + */ + fun amount(amount: Double) = amount(JsonField.of(amount)) + + /** + * The number of credits to effect. Note that this is required for increment, decrement + * or void operations. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The ID of the block to reverse a decrement from. */ + fun blockId(blockId: String) = blockId(JsonField.of(blockId)) + + /** The ID of the block to reverse a decrement from. */ + fun blockId(blockId: JsonField) = apply { this.blockId = blockId } + + fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) + + fun entryType(entryType: JsonField) = apply { this.entryType = entryType } + + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a + * real-world currency, it must match the customer's invoicing currency. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a + * real-world currency, it must match the customer's invoicing currency. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) + + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a + * real-world currency, it must match the customer's invoicing currency. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(description: Optional) = description(description.orElse(null)) + + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) + } + + fun build(): AddAmendmentCreditLedgerEntryRequestParams = + AddAmendmentCreditLedgerEntryRequestParams( + checkRequired("amount", amount), + checkRequired("blockId", blockId), + checkRequired("entryType", entryType), + currency, + description, + metadata, + additionalProperties.toImmutable(), + ) + } + + class EntryType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val AMENDMENT = of("amendment") + + @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) + } + + /** An enum containing [EntryType]'s known values. */ + enum class Known { + AMENDMENT + } + + /** + * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [EntryType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AMENDMENT, + /** + * An enum member indicating that [EntryType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AMENDMENT -> Value.AMENDMENT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + AMENDMENT -> Known.AMENDMENT + else -> throw OrbInvalidDataException("Unknown EntryType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AddAmendmentCreditLedgerEntryRequestParams && amount == other.amount && blockId == other.blockId && entryType == other.entryType && currency == other.currency && description == other.description && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(amount, blockId, entryType, currency, description, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AddAmendmentCreditLedgerEntryRequestParams{amount=$amount, blockId=$blockId, entryType=$entryType, currency=$currency, description=$description, metadata=$metadata, additionalProperties=$additionalProperties}" + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AddCreditTopUpRequest.kt similarity index 85% rename from orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdResponse.kt rename to orb-java-core/src/main/kotlin/com/withorb/api/models/AddCreditTopUpRequest.kt index bd690674a..265af29fe 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/AddCreditTopUpRequest.kt @@ -16,14 +16,14 @@ import com.withorb.api.core.checkRequired import com.withorb.api.core.immutableEmptyMap import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime import java.util.Objects import java.util.Optional @NoAutoDetect -class CustomerCreditTopUpCreateByExternalIdResponse +class AddCreditTopUpRequest @JsonCreator private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("amount") @ExcludeMissing private val amount: JsonField = JsonMissing.of(), @@ -39,6 +39,9 @@ private constructor( @JsonProperty("threshold") @ExcludeMissing private val threshold: JsonField = JsonMissing.of(), + @JsonProperty("active_from") + @ExcludeMissing + private val activeFrom: JsonField = JsonMissing.of(), @JsonProperty("expires_after") @ExcludeMissing private val expiresAfter: JsonField = JsonMissing.of(), @@ -48,8 +51,6 @@ private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun id(): String = id.getRequired("id") - /** The amount to increment when the threshold is reached. */ fun amount(): String = amount.getRequired("amount") @@ -71,6 +72,12 @@ private constructor( */ fun threshold(): String = threshold.getRequired("threshold") + /** + * The date from which the top-up is active. If unspecified, the top-up is active immediately. + */ + fun activeFrom(): Optional = + Optional.ofNullable(activeFrom.getNullable("active_from")) + /** * The number of days or months after which the top-up expires. If unspecified, it does not * expire. @@ -82,8 +89,6 @@ private constructor( fun expiresAfterUnit(): Optional = Optional.ofNullable(expiresAfterUnit.getNullable("expires_after_unit")) - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** The amount to increment when the threshold is reached. */ @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount @@ -109,6 +114,13 @@ private constructor( */ @JsonProperty("threshold") @ExcludeMissing fun _threshold(): JsonField = threshold + /** + * The date from which the top-up is active. If unspecified, the top-up is active immediately. + */ + @JsonProperty("active_from") + @ExcludeMissing + fun _activeFrom(): JsonField = activeFrom + /** * The number of days or months after which the top-up expires. If unspecified, it does not * expire. @@ -128,17 +140,17 @@ private constructor( private var validated: Boolean = false - fun validate(): CustomerCreditTopUpCreateByExternalIdResponse = apply { + fun validate(): AddCreditTopUpRequest = apply { if (validated) { return@apply } - id() amount() currency() invoiceSettings().validate() perUnitCostBasis() threshold() + activeFrom() expiresAfter() expiresAfterUnit() validated = true @@ -148,43 +160,47 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [AddCreditTopUpRequest]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * .invoiceSettings() + * .perUnitCostBasis() + * .threshold() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [CustomerCreditTopUpCreateByExternalIdResponse]. */ + /** A builder for [AddCreditTopUpRequest]. */ class Builder internal constructor() { - private var id: JsonField? = null private var amount: JsonField? = null private var currency: JsonField? = null private var invoiceSettings: JsonField? = null private var perUnitCostBasis: JsonField? = null private var threshold: JsonField? = null + private var activeFrom: JsonField = JsonMissing.of() private var expiresAfter: JsonField = JsonMissing.of() private var expiresAfterUnit: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - customerCreditTopUpCreateByExternalIdResponse: - CustomerCreditTopUpCreateByExternalIdResponse - ) = apply { - id = customerCreditTopUpCreateByExternalIdResponse.id - amount = customerCreditTopUpCreateByExternalIdResponse.amount - currency = customerCreditTopUpCreateByExternalIdResponse.currency - invoiceSettings = customerCreditTopUpCreateByExternalIdResponse.invoiceSettings - perUnitCostBasis = customerCreditTopUpCreateByExternalIdResponse.perUnitCostBasis - threshold = customerCreditTopUpCreateByExternalIdResponse.threshold - expiresAfter = customerCreditTopUpCreateByExternalIdResponse.expiresAfter - expiresAfterUnit = customerCreditTopUpCreateByExternalIdResponse.expiresAfterUnit - additionalProperties = - customerCreditTopUpCreateByExternalIdResponse.additionalProperties.toMutableMap() + internal fun from(addCreditTopUpRequest: AddCreditTopUpRequest) = apply { + amount = addCreditTopUpRequest.amount + currency = addCreditTopUpRequest.currency + invoiceSettings = addCreditTopUpRequest.invoiceSettings + perUnitCostBasis = addCreditTopUpRequest.perUnitCostBasis + threshold = addCreditTopUpRequest.threshold + activeFrom = addCreditTopUpRequest.activeFrom + expiresAfter = addCreditTopUpRequest.expiresAfter + expiresAfterUnit = addCreditTopUpRequest.expiresAfterUnit + additionalProperties = addCreditTopUpRequest.additionalProperties.toMutableMap() } - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - /** The amount to increment when the threshold is reached. */ fun amount(amount: String) = amount(JsonField.of(amount)) @@ -233,6 +249,26 @@ private constructor( */ fun threshold(threshold: JsonField) = apply { this.threshold = threshold } + /** + * The date from which the top-up is active. If unspecified, the top-up is active + * immediately. + */ + fun activeFrom(activeFrom: OffsetDateTime?) = activeFrom(JsonField.ofNullable(activeFrom)) + + /** + * The date from which the top-up is active. If unspecified, the top-up is active + * immediately. + */ + fun activeFrom(activeFrom: Optional) = activeFrom(activeFrom.orElse(null)) + + /** + * The date from which the top-up is active. If unspecified, the top-up is active + * immediately. + */ + fun activeFrom(activeFrom: JsonField) = apply { + this.activeFrom = activeFrom + } + /** * The number of days or months after which the top-up expires. If unspecified, it does not * expire. @@ -291,14 +327,14 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): CustomerCreditTopUpCreateByExternalIdResponse = - CustomerCreditTopUpCreateByExternalIdResponse( - checkRequired("id", id), + fun build(): AddCreditTopUpRequest = + AddCreditTopUpRequest( checkRequired("amount", amount), checkRequired("currency", currency), checkRequired("invoiceSettings", invoiceSettings), checkRequired("perUnitCostBasis", perUnitCostBasis), checkRequired("threshold", threshold), + activeFrom, expiresAfter, expiresAfterUnit, additionalProperties.toImmutable(), @@ -395,6 +431,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [InvoiceSettings]. + * + * The following fields are required: + * ```java + * .autoCollection() + * .netTerms() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -621,15 +666,15 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditTopUpCreateByExternalIdResponse && id == other.id && amount == other.amount && currency == other.currency && invoiceSettings == other.invoiceSettings && perUnitCostBasis == other.perUnitCostBasis && threshold == other.threshold && expiresAfter == other.expiresAfter && expiresAfterUnit == other.expiresAfterUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AddCreditTopUpRequest && amount == other.amount && currency == other.currency && invoiceSettings == other.invoiceSettings && perUnitCostBasis == other.perUnitCostBasis && threshold == other.threshold && activeFrom == other.activeFrom && expiresAfter == other.expiresAfter && expiresAfterUnit == other.expiresAfterUnit && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, currency, invoiceSettings, perUnitCostBasis, threshold, expiresAfter, expiresAfterUnit, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(amount, currency, invoiceSettings, perUnitCostBasis, threshold, activeFrom, expiresAfter, expiresAfterUnit, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "CustomerCreditTopUpCreateByExternalIdResponse{id=$id, amount=$amount, currency=$currency, invoiceSettings=$invoiceSettings, perUnitCostBasis=$perUnitCostBasis, threshold=$threshold, expiresAfter=$expiresAfter, expiresAfterUnit=$expiresAfterUnit, additionalProperties=$additionalProperties}" + "AddCreditTopUpRequest{amount=$amount, currency=$currency, invoiceSettings=$invoiceSettings, perUnitCostBasis=$perUnitCostBasis, threshold=$threshold, activeFrom=$activeFrom, expiresAfter=$expiresAfter, expiresAfterUnit=$expiresAfterUnit, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AddSubscriptionAdjustmentParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AddSubscriptionAdjustmentParams.kt new file mode 100644 index 000000000..2c210c936 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AddSubscriptionAdjustmentParams.kt @@ -0,0 +1,269 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class AddSubscriptionAdjustmentParams +@JsonCreator +private constructor( + @JsonProperty("adjustment") + @ExcludeMissing + private val adjustment: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + private val endDate: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + private val startDate: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(): NewAdjustmentModel = adjustment.getRequired("adjustment") + + /** + * The end date of the adjustment interval. This is the date that the adjustment will stop + * affecting prices on the subscription. + */ + fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) + + /** The phase to add this adjustment to. */ + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + /** + * The start date of the adjustment interval. This is the date that the adjustment will start + * affecting prices on the subscription. If null, the adjustment will start when the phase or + * subscription starts. + */ + fun startDate(): Optional = + Optional.ofNullable(startDate.getNullable("start_date")) + + /** The definition of a new adjustment to create and add to the subscription. */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment + + /** + * The end date of the adjustment interval. This is the date that the adjustment will stop + * affecting prices on the subscription. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + /** The phase to add this adjustment to. */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** + * The start date of the adjustment interval. This is the date that the adjustment will start + * affecting prices on the subscription. If null, the adjustment will start when the phase or + * subscription starts. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): AddSubscriptionAdjustmentParams = apply { + if (validated) { + return@apply + } + + adjustment().validate() + endDate() + planPhaseOrder() + startDate() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AddSubscriptionAdjustmentParams]. + * + * The following fields are required: + * ```java + * .adjustment() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AddSubscriptionAdjustmentParams]. */ + class Builder internal constructor() { + + private var adjustment: JsonField? = null + private var endDate: JsonField = JsonMissing.of() + private var planPhaseOrder: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(addSubscriptionAdjustmentParams: AddSubscriptionAdjustmentParams) = + apply { + adjustment = addSubscriptionAdjustmentParams.adjustment + endDate = addSubscriptionAdjustmentParams.endDate + planPhaseOrder = addSubscriptionAdjustmentParams.planPhaseOrder + startDate = addSubscriptionAdjustmentParams.startDate + additionalProperties = + addSubscriptionAdjustmentParams.additionalProperties.toMutableMap() + } + + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(adjustment: NewAdjustmentModel) = adjustment(JsonField.of(adjustment)) + + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } + + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(percentageDiscount: NewAdjustmentModel.NewPercentageDiscount) = + adjustment(NewAdjustmentModel.ofPercentageDiscount(percentageDiscount)) + + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(usageDiscount: NewAdjustmentModel.NewUsageDiscount) = + adjustment(NewAdjustmentModel.ofUsageDiscount(usageDiscount)) + + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(amountDiscount: NewAdjustmentModel.NewAmountDiscount) = + adjustment(NewAdjustmentModel.ofAmountDiscount(amountDiscount)) + + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(minimum: NewAdjustmentModel.NewMinimum) = + adjustment(NewAdjustmentModel.ofMinimum(minimum)) + + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(maximum: NewAdjustmentModel.NewMaximum) = + adjustment(NewAdjustmentModel.ofMaximum(maximum)) + + /** + * The end date of the adjustment interval. This is the date that the adjustment will stop + * affecting prices on the subscription. + */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** + * The end date of the adjustment interval. This is the date that the adjustment will stop + * affecting prices on the subscription. + */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) + + /** + * The end date of the adjustment interval. This is the date that the adjustment will stop + * affecting prices on the subscription. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** The phase to add this adjustment to. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** The phase to add this adjustment to. */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** The phase to add this adjustment to. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) + + /** The phase to add this adjustment to. */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + /** + * The start date of the adjustment interval. This is the date that the adjustment will + * start affecting prices on the subscription. If null, the adjustment will start when the + * phase or subscription starts. + */ + fun startDate(startDate: OffsetDateTime?) = startDate(JsonField.ofNullable(startDate)) + + /** + * The start date of the adjustment interval. This is the date that the adjustment will + * start affecting prices on the subscription. If null, the adjustment will start when the + * phase or subscription starts. + */ + fun startDate(startDate: Optional) = startDate(startDate.orElse(null)) + + /** + * The start date of the adjustment interval. This is the date that the adjustment will + * start affecting prices on the subscription. If null, the adjustment will start when the + * phase or subscription starts. + */ + 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) + } + + fun build(): AddSubscriptionAdjustmentParams = + AddSubscriptionAdjustmentParams( + checkRequired("adjustment", adjustment), + endDate, + planPhaseOrder, + startDate, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AddSubscriptionAdjustmentParams && adjustment == other.adjustment && endDate == other.endDate && planPhaseOrder == other.planPhaseOrder && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(adjustment, endDate, planPhaseOrder, startDate, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AddSubscriptionAdjustmentParams{adjustment=$adjustment, endDate=$endDate, planPhaseOrder=$planPhaseOrder, startDate=$startDate, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AddSubscriptionPriceParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AddSubscriptionPriceParams.kt new file mode 100644 index 000000000..430cde48d --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AddSubscriptionPriceParams.kt @@ -0,0 +1,621 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class AddSubscriptionPriceParams +@JsonCreator +private constructor( + @JsonProperty("allocation_price") + @ExcludeMissing + private val allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("discounts") + @ExcludeMissing + private val discounts: JsonField> = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + private val endDate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price") + @ExcludeMissing + private val price: JsonField = JsonMissing.of(), + @JsonProperty("price_id") + @ExcludeMissing + private val priceId: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + private val startDate: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** The definition of a new allocation price to create and add to the subscription. */ + fun allocationPrice(): Optional = + Optional.ofNullable(allocationPrice.getNullable("allocation_price")) + + /** [DEPRECATED] Use add_adjustments instead. The subscription's discounts for this price. */ + @Deprecated("deprecated") + fun discounts(): Optional> = + Optional.ofNullable(discounts.getNullable("discounts")) + + /** + * The end date of the price interval. This is the date that the price will stop billing on the + * subscription. If null, billing will end when the phase or subscription ends. + */ + fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) + + /** The external price id of the price to add to the subscription. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for this price. + */ + @Deprecated("deprecated") + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for this price. + */ + @Deprecated("deprecated") + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + /** The phase to add this price to. */ + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + /** The definition of a new price to create and add to the subscription. */ + fun price(): Optional = + Optional.ofNullable(price.getNullable("price")) + + /** The id of the price to add to the subscription. */ + fun priceId(): Optional = Optional.ofNullable(priceId.getNullable("price_id")) + + /** + * The start date of the price interval. This is the date that the price will start billing on + * the subscription. If null, billing will start when the phase or subscription starts. + */ + fun startDate(): Optional = + Optional.ofNullable(startDate.getNullable("start_date")) + + /** The definition of a new allocation price to create and add to the subscription. */ + @JsonProperty("allocation_price") + @ExcludeMissing + fun _allocationPrice(): JsonField = allocationPrice + + /** [DEPRECATED] Use add_adjustments instead. The subscription's discounts for this price. */ + @Deprecated("deprecated") + @JsonProperty("discounts") + @ExcludeMissing + fun _discounts(): JsonField> = discounts + + /** + * The end date of the price interval. This is the date that the price will stop billing on the + * subscription. If null, billing will end when the phase or subscription ends. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + /** The external price id of the price to add to the subscription. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for this price. + */ + @Deprecated("deprecated") + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for this price. + */ + @Deprecated("deprecated") + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** The phase to add this price to. */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** The definition of a new price to create and add to the subscription. */ + @JsonProperty("price") + @ExcludeMissing + fun _price(): JsonField = price + + /** The id of the price to add to the subscription. */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + + /** + * The start date of the price interval. This is the date that the price will start billing on + * the subscription. If null, billing will start when the phase or subscription starts. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): AddSubscriptionPriceParams = apply { + if (validated) { + return@apply + } + + allocationPrice().ifPresent { it.validate() } + discounts().ifPresent { it.forEach { it.validate() } } + endDate() + externalPriceId() + maximumAmount() + minimumAmount() + planPhaseOrder() + price().ifPresent { it.validate() } + priceId() + startDate() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AddSubscriptionPriceParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AddSubscriptionPriceParams]. */ + class Builder internal constructor() { + + private var allocationPrice: JsonField = JsonMissing.of() + private var discounts: JsonField>? = null + private var endDate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var planPhaseOrder: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(addSubscriptionPriceParams: AddSubscriptionPriceParams) = apply { + allocationPrice = addSubscriptionPriceParams.allocationPrice + discounts = addSubscriptionPriceParams.discounts.map { it.toMutableList() } + endDate = addSubscriptionPriceParams.endDate + externalPriceId = addSubscriptionPriceParams.externalPriceId + maximumAmount = addSubscriptionPriceParams.maximumAmount + minimumAmount = addSubscriptionPriceParams.minimumAmount + planPhaseOrder = addSubscriptionPriceParams.planPhaseOrder + price = addSubscriptionPriceParams.price + priceId = addSubscriptionPriceParams.priceId + startDate = addSubscriptionPriceParams.startDate + additionalProperties = addSubscriptionPriceParams.additionalProperties.toMutableMap() + } + + /** The definition of a new allocation price to create and add to the subscription. */ + fun allocationPrice(allocationPrice: NewAllocationPriceModel?) = + allocationPrice(JsonField.ofNullable(allocationPrice)) + + /** The definition of a new allocation price to create and add to the subscription. */ + fun allocationPrice(allocationPrice: Optional) = + allocationPrice(allocationPrice.orElse(null)) + + /** The definition of a new allocation price to create and add to the subscription. */ + fun allocationPrice(allocationPrice: JsonField) = apply { + this.allocationPrice = allocationPrice + } + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for this price. + */ + @Deprecated("deprecated") + fun discounts(discounts: List?) = + discounts(JsonField.ofNullable(discounts)) + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for this price. + */ + @Deprecated("deprecated") + fun discounts(discounts: Optional>) = + discounts(discounts.orElse(null)) + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for this price. + */ + @Deprecated("deprecated") + fun discounts(discounts: JsonField>) = apply { + this.discounts = discounts.map { it.toMutableList() } + } + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for this price. + */ + @Deprecated("deprecated") + fun addDiscount(discount: DiscountOverrideModel) = apply { + discounts = + (discounts ?: JsonField.of(mutableListOf())).also { + checkKnown("discounts", it).add(discount) + } + } + + /** + * The end date of the price interval. This is the date that the price will stop billing on + * the subscription. If null, billing will end when the phase or subscription ends. + */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** + * The end date of the price interval. This is the date that the price will stop billing on + * the subscription. If null, billing will end when the phase or subscription ends. + */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) + + /** + * The end date of the price interval. This is the date that the price will stop billing on + * the subscription. If null, billing will end when the phase or subscription ends. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** The external price id of the price to add to the subscription. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** The external price id of the price to add to the subscription. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** The external price id of the price to add to the subscription. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for this + * price. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for this + * price. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for this + * price. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for this + * price. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for this + * price. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for this + * price. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** The phase to add this price to. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** The phase to add this price to. */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** The phase to add this price to. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) + + /** The phase to add this price to. */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + /** The definition of a new price to create and add to the subscription. */ + fun price(price: NewSubscriptionPriceModel?) = price(JsonField.ofNullable(price)) + + /** The definition of a new price to create and add to the subscription. */ + fun price(price: Optional) = price(price.orElse(null)) + + /** The definition of a new price to create and add to the subscription. */ + fun price(price: JsonField) = apply { this.price = price } + + /** The definition of a new price to create and add to the subscription. */ + fun price(unitPrice: NewSubscriptionPriceModel.NewSubscriptionUnitPrice) = + price(NewSubscriptionPriceModel.ofUnitPrice(unitPrice)) + + /** The definition of a new price to create and add to the subscription. */ + fun price(packagePrice: NewSubscriptionPriceModel.NewSubscriptionPackagePrice) = + price(NewSubscriptionPriceModel.ofPackagePrice(packagePrice)) + + /** The definition of a new price to create and add to the subscription. */ + fun price(matrixPrice: NewSubscriptionPriceModel.NewSubscriptionMatrixPrice) = + price(NewSubscriptionPriceModel.ofMatrixPrice(matrixPrice)) + + /** The definition of a new price to create and add to the subscription. */ + fun price(tieredPrice: NewSubscriptionPriceModel.NewSubscriptionTieredPrice) = + price(NewSubscriptionPriceModel.ofTieredPrice(tieredPrice)) + + /** The definition of a new price to create and add to the subscription. */ + fun price(tieredBpsPrice: NewSubscriptionPriceModel.NewSubscriptionTieredBpsPrice) = + price(NewSubscriptionPriceModel.ofTieredBpsPrice(tieredBpsPrice)) + + /** The definition of a new price to create and add to the subscription. */ + fun price(bpsPrice: NewSubscriptionPriceModel.NewSubscriptionBpsPrice) = + price(NewSubscriptionPriceModel.ofBpsPrice(bpsPrice)) + + /** The definition of a new price to create and add to the subscription. */ + fun price(bulkBpsPrice: NewSubscriptionPriceModel.NewSubscriptionBulkBpsPrice) = + price(NewSubscriptionPriceModel.ofBulkBpsPrice(bulkBpsPrice)) + + /** The definition of a new price to create and add to the subscription. */ + fun price(bulkPrice: NewSubscriptionPriceModel.NewSubscriptionBulkPrice) = + price(NewSubscriptionPriceModel.ofBulkPrice(bulkPrice)) + + /** The definition of a new price to create and add to the subscription. */ + fun price( + thresholdTotalAmountPrice: + NewSubscriptionPriceModel.NewSubscriptionThresholdTotalAmountPrice + ) = price(NewSubscriptionPriceModel.ofThresholdTotalAmountPrice(thresholdTotalAmountPrice)) + + /** The definition of a new price to create and add to the subscription. */ + fun price(tieredPackagePrice: NewSubscriptionPriceModel.NewSubscriptionTieredPackagePrice) = + price(NewSubscriptionPriceModel.ofTieredPackagePrice(tieredPackagePrice)) + + /** The definition of a new price to create and add to the subscription. */ + fun price( + tieredWithMinimumPrice: NewSubscriptionPriceModel.NewSubscriptionTieredWithMinimumPrice + ) = price(NewSubscriptionPriceModel.ofTieredWithMinimumPrice(tieredWithMinimumPrice)) + + /** The definition of a new price to create and add to the subscription. */ + fun price( + unitWithPercentPrice: NewSubscriptionPriceModel.NewSubscriptionUnitWithPercentPrice + ) = price(NewSubscriptionPriceModel.ofUnitWithPercentPrice(unitWithPercentPrice)) + + /** The definition of a new price to create and add to the subscription. */ + fun price( + packageWithAllocationPrice: + NewSubscriptionPriceModel.NewSubscriptionPackageWithAllocationPrice + ) = + price( + NewSubscriptionPriceModel.ofPackageWithAllocationPrice(packageWithAllocationPrice) + ) + + /** The definition of a new price to create and add to the subscription. */ + fun price( + tierWithProrationPrice: NewSubscriptionPriceModel.NewSubscriptionTierWithProrationPrice + ) = price(NewSubscriptionPriceModel.ofTierWithProrationPrice(tierWithProrationPrice)) + + /** The definition of a new price to create and add to the subscription. */ + fun price( + unitWithProrationPrice: NewSubscriptionPriceModel.NewSubscriptionUnitWithProrationPrice + ) = price(NewSubscriptionPriceModel.ofUnitWithProrationPrice(unitWithProrationPrice)) + + /** The definition of a new price to create and add to the subscription. */ + fun price( + groupedAllocationPrice: NewSubscriptionPriceModel.NewSubscriptionGroupedAllocationPrice + ) = price(NewSubscriptionPriceModel.ofGroupedAllocationPrice(groupedAllocationPrice)) + + /** The definition of a new price to create and add to the subscription. */ + fun price( + groupedWithProratedMinimumPrice: + NewSubscriptionPriceModel.NewSubscriptionGroupedWithProratedMinimumPrice + ) = + price( + NewSubscriptionPriceModel.ofGroupedWithProratedMinimumPrice( + groupedWithProratedMinimumPrice + ) + ) + + /** The definition of a new price to create and add to the subscription. */ + fun price( + bulkWithProrationPrice: NewSubscriptionPriceModel.NewSubscriptionBulkWithProrationPrice + ) = price(NewSubscriptionPriceModel.ofBulkWithProrationPrice(bulkWithProrationPrice)) + + /** The definition of a new price to create and add to the subscription. */ + fun price( + scalableMatrixWithUnitPricingPrice: + NewSubscriptionPriceModel.NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = + price( + NewSubscriptionPriceModel.ofScalableMatrixWithUnitPricingPrice( + scalableMatrixWithUnitPricingPrice + ) + ) + + /** The definition of a new price to create and add to the subscription. */ + fun price( + scalableMatrixWithTieredPricingPrice: + NewSubscriptionPriceModel.NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = + price( + NewSubscriptionPriceModel.ofScalableMatrixWithTieredPricingPrice( + scalableMatrixWithTieredPricingPrice + ) + ) + + /** The definition of a new price to create and add to the subscription. */ + fun price( + cumulativeGroupedBulkPrice: + NewSubscriptionPriceModel.NewSubscriptionCumulativeGroupedBulkPrice + ) = + price( + NewSubscriptionPriceModel.ofCumulativeGroupedBulkPrice(cumulativeGroupedBulkPrice) + ) + + /** The definition of a new price to create and add to the subscription. */ + fun price( + maxGroupTieredPackagePrice: + NewSubscriptionPriceModel.NewSubscriptionMaxGroupTieredPackagePrice + ) = + price( + NewSubscriptionPriceModel.ofMaxGroupTieredPackagePrice(maxGroupTieredPackagePrice) + ) + + /** The definition of a new price to create and add to the subscription. */ + fun price( + groupedWithMeteredMinimumPrice: + NewSubscriptionPriceModel.NewSubscriptionGroupedWithMeteredMinimumPrice + ) = + price( + NewSubscriptionPriceModel.ofGroupedWithMeteredMinimumPrice( + groupedWithMeteredMinimumPrice + ) + ) + + /** The definition of a new price to create and add to the subscription. */ + fun price( + matrixWithDisplayNamePrice: + NewSubscriptionPriceModel.NewSubscriptionMatrixWithDisplayNamePrice + ) = + price( + NewSubscriptionPriceModel.ofMatrixWithDisplayNamePrice(matrixWithDisplayNamePrice) + ) + + /** The definition of a new price to create and add to the subscription. */ + fun price( + groupedTieredPackagePrice: + NewSubscriptionPriceModel.NewSubscriptionGroupedTieredPackagePrice + ) = price(NewSubscriptionPriceModel.ofGroupedTieredPackagePrice(groupedTieredPackagePrice)) + + /** The id of the price to add to the subscription. */ + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + + /** The id of the price to add to the subscription. */ + fun priceId(priceId: Optional) = priceId(priceId.orElse(null)) + + /** The id of the price to add to the subscription. */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + /** + * The start date of the price interval. This is the date that the price will start billing + * on the subscription. If null, billing will start when the phase or subscription starts. + */ + fun startDate(startDate: OffsetDateTime?) = startDate(JsonField.ofNullable(startDate)) + + /** + * The start date of the price interval. This is the date that the price will start billing + * on the subscription. If null, billing will start when the phase or subscription starts. + */ + fun startDate(startDate: Optional) = startDate(startDate.orElse(null)) + + /** + * The start date of the price interval. This is the date that the price will start billing + * on the subscription. If null, billing will start when the phase or subscription starts. + */ + 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) + } + + fun build(): AddSubscriptionPriceParams = + AddSubscriptionPriceParams( + allocationPrice, + (discounts ?: JsonMissing.of()).map { it.toImmutable() }, + endDate, + externalPriceId, + maximumAmount, + minimumAmount, + planPhaseOrder, + price, + priceId, + startDate, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AddSubscriptionPriceParams && allocationPrice == other.allocationPrice && discounts == other.discounts && endDate == other.endDate && externalPriceId == other.externalPriceId && maximumAmount == other.maximumAmount && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && price == other.price && priceId == other.priceId && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(allocationPrice, discounts, endDate, externalPriceId, maximumAmount, minimumAmount, planPhaseOrder, price, priceId, startDate, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AddSubscriptionPriceParams{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AddressInputModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AddressInputModel.kt new file mode 100644 index 000000000..05e6635ef --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AddressInputModel.kt @@ -0,0 +1,193 @@ +// 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.NoAutoDetect +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class AddressInputModel +@JsonCreator +private constructor( + @JsonProperty("city") @ExcludeMissing private val city: JsonField = JsonMissing.of(), + @JsonProperty("country") + @ExcludeMissing + private val country: JsonField = JsonMissing.of(), + @JsonProperty("line1") @ExcludeMissing private val line1: JsonField = JsonMissing.of(), + @JsonProperty("line2") @ExcludeMissing private val line2: JsonField = JsonMissing.of(), + @JsonProperty("postal_code") + @ExcludeMissing + private val postalCode: JsonField = JsonMissing.of(), + @JsonProperty("state") @ExcludeMissing private val state: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun city(): Optional = Optional.ofNullable(city.getNullable("city")) + + fun country(): Optional = Optional.ofNullable(country.getNullable("country")) + + fun line1(): Optional = Optional.ofNullable(line1.getNullable("line1")) + + fun line2(): Optional = Optional.ofNullable(line2.getNullable("line2")) + + fun postalCode(): Optional = Optional.ofNullable(postalCode.getNullable("postal_code")) + + fun state(): Optional = Optional.ofNullable(state.getNullable("state")) + + @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city + + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country + + @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField = line1 + + @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 + + @JsonProperty("postal_code") @ExcludeMissing fun _postalCode(): JsonField = postalCode + + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): AddressInputModel = apply { + if (validated) { + return@apply + } + + city() + country() + line1() + line2() + postalCode() + state() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [AddressInputModel]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AddressInputModel]. */ + class Builder internal constructor() { + + private var city: JsonField = JsonMissing.of() + private var country: JsonField = JsonMissing.of() + private var line1: JsonField = JsonMissing.of() + private var line2: JsonField = JsonMissing.of() + private var postalCode: JsonField = JsonMissing.of() + private var state: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(addressInputModel: AddressInputModel) = apply { + city = addressInputModel.city + country = addressInputModel.country + line1 = addressInputModel.line1 + line2 = addressInputModel.line2 + postalCode = addressInputModel.postalCode + state = addressInputModel.state + additionalProperties = addressInputModel.additionalProperties.toMutableMap() + } + + fun city(city: String?) = city(JsonField.ofNullable(city)) + + fun city(city: Optional) = city(city.orElse(null)) + + fun city(city: JsonField) = apply { this.city = city } + + fun country(country: String?) = country(JsonField.ofNullable(country)) + + fun country(country: Optional) = country(country.orElse(null)) + + fun country(country: JsonField) = apply { this.country = country } + + fun line1(line1: String?) = line1(JsonField.ofNullable(line1)) + + fun line1(line1: Optional) = line1(line1.orElse(null)) + + fun line1(line1: JsonField) = apply { this.line1 = line1 } + + fun line2(line2: String?) = line2(JsonField.ofNullable(line2)) + + fun line2(line2: Optional) = line2(line2.orElse(null)) + + fun line2(line2: JsonField) = apply { this.line2 = line2 } + + fun postalCode(postalCode: String?) = postalCode(JsonField.ofNullable(postalCode)) + + fun postalCode(postalCode: Optional) = postalCode(postalCode.orElse(null)) + + fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode } + + fun state(state: String?) = state(JsonField.ofNullable(state)) + + fun state(state: Optional) = state(state.orElse(null)) + + fun state(state: JsonField) = apply { this.state = state } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): AddressInputModel = + AddressInputModel( + city, + country, + line1, + line2, + postalCode, + state, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AddressInputModel && city == other.city && country == other.country && line1 == other.line1 && line2 == other.line2 && postalCode == other.postalCode && state == other.state && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(city, country, line1, line2, postalCode, state, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AddressInputModel{city=$city, country=$country, line1=$line1, line2=$line2, postalCode=$postalCode, state=$state, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AddressModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AddressModel.kt new file mode 100644 index 000000000..fe94a0d43 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AddressModel.kt @@ -0,0 +1,206 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class AddressModel +@JsonCreator +private constructor( + @JsonProperty("city") @ExcludeMissing private val city: JsonField = JsonMissing.of(), + @JsonProperty("country") + @ExcludeMissing + private val country: JsonField = JsonMissing.of(), + @JsonProperty("line1") @ExcludeMissing private val line1: JsonField = JsonMissing.of(), + @JsonProperty("line2") @ExcludeMissing private val line2: JsonField = JsonMissing.of(), + @JsonProperty("postal_code") + @ExcludeMissing + private val postalCode: JsonField = JsonMissing.of(), + @JsonProperty("state") @ExcludeMissing private val state: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun city(): Optional = Optional.ofNullable(city.getNullable("city")) + + fun country(): Optional = Optional.ofNullable(country.getNullable("country")) + + fun line1(): Optional = Optional.ofNullable(line1.getNullable("line1")) + + fun line2(): Optional = Optional.ofNullable(line2.getNullable("line2")) + + fun postalCode(): Optional = Optional.ofNullable(postalCode.getNullable("postal_code")) + + fun state(): Optional = Optional.ofNullable(state.getNullable("state")) + + @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city + + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country + + @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField = line1 + + @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 + + @JsonProperty("postal_code") @ExcludeMissing fun _postalCode(): JsonField = postalCode + + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): AddressModel = apply { + if (validated) { + return@apply + } + + city() + country() + line1() + line2() + postalCode() + state() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AddressModel]. + * + * The following fields are required: + * ```java + * .city() + * .country() + * .line1() + * .line2() + * .postalCode() + * .state() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AddressModel]. */ + class Builder internal constructor() { + + private var city: JsonField? = null + private var country: JsonField? = null + private var line1: JsonField? = null + private var line2: JsonField? = null + private var postalCode: JsonField? = null + private var state: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(addressModel: AddressModel) = apply { + city = addressModel.city + country = addressModel.country + line1 = addressModel.line1 + line2 = addressModel.line2 + postalCode = addressModel.postalCode + state = addressModel.state + additionalProperties = addressModel.additionalProperties.toMutableMap() + } + + fun city(city: String?) = city(JsonField.ofNullable(city)) + + fun city(city: Optional) = city(city.orElse(null)) + + fun city(city: JsonField) = apply { this.city = city } + + fun country(country: String?) = country(JsonField.ofNullable(country)) + + fun country(country: Optional) = country(country.orElse(null)) + + fun country(country: JsonField) = apply { this.country = country } + + fun line1(line1: String?) = line1(JsonField.ofNullable(line1)) + + fun line1(line1: Optional) = line1(line1.orElse(null)) + + fun line1(line1: JsonField) = apply { this.line1 = line1 } + + fun line2(line2: String?) = line2(JsonField.ofNullable(line2)) + + fun line2(line2: Optional) = line2(line2.orElse(null)) + + fun line2(line2: JsonField) = apply { this.line2 = line2 } + + fun postalCode(postalCode: String?) = postalCode(JsonField.ofNullable(postalCode)) + + fun postalCode(postalCode: Optional) = postalCode(postalCode.orElse(null)) + + fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode } + + fun state(state: String?) = state(JsonField.ofNullable(state)) + + fun state(state: Optional) = state(state.orElse(null)) + + fun state(state: JsonField) = apply { this.state = state } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): AddressModel = + AddressModel( + checkRequired("city", city), + checkRequired("country", country), + checkRequired("line1", line1), + checkRequired("line2", line2), + checkRequired("postalCode", postalCode), + checkRequired("state", state), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AddressModel && city == other.city && country == other.country && line1 == other.line1 && line2 == other.line2 && postalCode == other.postalCode && state == other.state && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(city, country, line1, line2, postalCode, state, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AddressModel{city=$city, country=$country, line1=$line1, line2=$line2, postalCode=$postalCode, state=$state, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AdjustmentIntervalModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AdjustmentIntervalModel.kt new file mode 100644 index 000000000..11f5d2d0a --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AdjustmentIntervalModel.kt @@ -0,0 +1,256 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class AdjustmentIntervalModel +@JsonCreator +private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("adjustment") + @ExcludeMissing + private val adjustment: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + private val endDate: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + private val startDate: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun id(): String = id.getRequired("id") + + fun adjustment(): AdjustmentModel = adjustment.getRequired("adjustment") + + /** The price interval IDs that this adjustment applies to. */ + fun appliesToPriceIntervalIds(): List = + appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") + + /** The end date of the adjustment interval. */ + fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) + + /** The start date of the adjustment interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment + + /** The price interval IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds + + /** The end date of the adjustment interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + /** The start date of the adjustment interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): AdjustmentIntervalModel = apply { + if (validated) { + return@apply + } + + id() + adjustment().validate() + appliesToPriceIntervalIds() + endDate() + startDate() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AdjustmentIntervalModel]. + * + * The following fields are required: + * ```java + * .id() + * .adjustment() + * .appliesToPriceIntervalIds() + * .endDate() + * .startDate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AdjustmentIntervalModel]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var adjustment: JsonField? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(adjustmentIntervalModel: AdjustmentIntervalModel) = apply { + id = adjustmentIntervalModel.id + adjustment = adjustmentIntervalModel.adjustment + appliesToPriceIntervalIds = + adjustmentIntervalModel.appliesToPriceIntervalIds.map { it.toMutableList() } + endDate = adjustmentIntervalModel.endDate + startDate = adjustmentIntervalModel.startDate + additionalProperties = adjustmentIntervalModel.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun adjustment(adjustment: AdjustmentModel) = adjustment(JsonField.of(adjustment)) + + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } + + fun adjustment( + planPhaseUsageDiscountAdjustment: AdjustmentModel.PlanPhaseUsageDiscountAdjustment + ) = + adjustment( + AdjustmentModel.ofPlanPhaseUsageDiscountAdjustment(planPhaseUsageDiscountAdjustment) + ) + + fun adjustment( + planPhaseAmountDiscountAdjustment: AdjustmentModel.PlanPhaseAmountDiscountAdjustment + ) = + adjustment( + AdjustmentModel.ofPlanPhaseAmountDiscountAdjustment( + planPhaseAmountDiscountAdjustment + ) + ) + + fun adjustment( + planPhasePercentageDiscountAdjustment: + AdjustmentModel.PlanPhasePercentageDiscountAdjustment + ) = + adjustment( + AdjustmentModel.ofPlanPhasePercentageDiscountAdjustment( + planPhasePercentageDiscountAdjustment + ) + ) + + fun adjustment(planPhaseMinimumAdjustment: AdjustmentModel.PlanPhaseMinimumAdjustment) = + adjustment(AdjustmentModel.ofPlanPhaseMinimumAdjustment(planPhaseMinimumAdjustment)) + + fun adjustment(planPhaseMaximumAdjustment: AdjustmentModel.PlanPhaseMaximumAdjustment) = + adjustment(AdjustmentModel.ofPlanPhaseMaximumAdjustment(planPhaseMaximumAdjustment)) + + /** The price interval IDs that this adjustment applies to. */ + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = + appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) + + /** The price interval IDs that this adjustment applies to. */ + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds.map { it.toMutableList() } + } + + /** The price interval IDs that this adjustment applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIntervalIds", it).add(appliesToPriceIntervalId) + } + } + + /** The end date of the adjustment interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the adjustment interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) + + /** The end date of the adjustment interval. */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** The start date of the adjustment interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the adjustment interval. */ + 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) + } + + fun build(): AdjustmentIntervalModel = + AdjustmentIntervalModel( + checkRequired("id", id), + checkRequired("adjustment", adjustment), + checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { + it.toImmutable() + }, + checkRequired("endDate", endDate), + checkRequired("startDate", startDate), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentIntervalModel && id == other.id && adjustment == other.adjustment && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, adjustment, appliesToPriceIntervalIds, endDate, startDate, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AdjustmentIntervalModel{id=$id, adjustment=$adjustment, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AdjustmentModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AdjustmentModel.kt new file mode 100644 index 000000000..f286e1981 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AdjustmentModel.kt @@ -0,0 +1,2304 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.BaseDeserializer +import com.withorb.api.core.BaseSerializer +import com.withorb.api.core.Enum +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.getOrThrow +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +@JsonDeserialize(using = AdjustmentModel.Deserializer::class) +@JsonSerialize(using = AdjustmentModel.Serializer::class) +class AdjustmentModel +private constructor( + private val planPhaseUsageDiscountAdjustment: PlanPhaseUsageDiscountAdjustment? = null, + private val planPhaseAmountDiscountAdjustment: PlanPhaseAmountDiscountAdjustment? = null, + private val planPhasePercentageDiscountAdjustment: PlanPhasePercentageDiscountAdjustment? = + null, + private val planPhaseMinimumAdjustment: PlanPhaseMinimumAdjustment? = null, + private val planPhaseMaximumAdjustment: PlanPhaseMaximumAdjustment? = null, + private val _json: JsonValue? = null, +) { + + fun planPhaseUsageDiscountAdjustment(): Optional = + Optional.ofNullable(planPhaseUsageDiscountAdjustment) + + fun planPhaseAmountDiscountAdjustment(): Optional = + Optional.ofNullable(planPhaseAmountDiscountAdjustment) + + fun planPhasePercentageDiscountAdjustment(): Optional = + Optional.ofNullable(planPhasePercentageDiscountAdjustment) + + fun planPhaseMinimumAdjustment(): Optional = + Optional.ofNullable(planPhaseMinimumAdjustment) + + fun planPhaseMaximumAdjustment(): Optional = + Optional.ofNullable(planPhaseMaximumAdjustment) + + fun isPlanPhaseUsageDiscountAdjustment(): Boolean = planPhaseUsageDiscountAdjustment != null + + fun isPlanPhaseAmountDiscountAdjustment(): Boolean = planPhaseAmountDiscountAdjustment != null + + fun isPlanPhasePercentageDiscountAdjustment(): Boolean = + planPhasePercentageDiscountAdjustment != null + + fun isPlanPhaseMinimumAdjustment(): Boolean = planPhaseMinimumAdjustment != null + + fun isPlanPhaseMaximumAdjustment(): Boolean = planPhaseMaximumAdjustment != null + + fun asPlanPhaseUsageDiscountAdjustment(): PlanPhaseUsageDiscountAdjustment = + planPhaseUsageDiscountAdjustment.getOrThrow("planPhaseUsageDiscountAdjustment") + + fun asPlanPhaseAmountDiscountAdjustment(): PlanPhaseAmountDiscountAdjustment = + planPhaseAmountDiscountAdjustment.getOrThrow("planPhaseAmountDiscountAdjustment") + + fun asPlanPhasePercentageDiscountAdjustment(): PlanPhasePercentageDiscountAdjustment = + planPhasePercentageDiscountAdjustment.getOrThrow("planPhasePercentageDiscountAdjustment") + + fun asPlanPhaseMinimumAdjustment(): PlanPhaseMinimumAdjustment = + planPhaseMinimumAdjustment.getOrThrow("planPhaseMinimumAdjustment") + + fun asPlanPhaseMaximumAdjustment(): PlanPhaseMaximumAdjustment = + planPhaseMaximumAdjustment.getOrThrow("planPhaseMaximumAdjustment") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + planPhaseUsageDiscountAdjustment != null -> + visitor.visitPlanPhaseUsageDiscountAdjustment(planPhaseUsageDiscountAdjustment) + planPhaseAmountDiscountAdjustment != null -> + visitor.visitPlanPhaseAmountDiscountAdjustment(planPhaseAmountDiscountAdjustment) + planPhasePercentageDiscountAdjustment != null -> + visitor.visitPlanPhasePercentageDiscountAdjustment( + planPhasePercentageDiscountAdjustment + ) + planPhaseMinimumAdjustment != null -> + visitor.visitPlanPhaseMinimumAdjustment(planPhaseMinimumAdjustment) + planPhaseMaximumAdjustment != null -> + visitor.visitPlanPhaseMaximumAdjustment(planPhaseMaximumAdjustment) + else -> visitor.unknown(_json) + } + } + + private var validated: Boolean = false + + fun validate(): AdjustmentModel = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitPlanPhaseUsageDiscountAdjustment( + planPhaseUsageDiscountAdjustment: PlanPhaseUsageDiscountAdjustment + ) { + planPhaseUsageDiscountAdjustment.validate() + } + + override fun visitPlanPhaseAmountDiscountAdjustment( + planPhaseAmountDiscountAdjustment: PlanPhaseAmountDiscountAdjustment + ) { + planPhaseAmountDiscountAdjustment.validate() + } + + override fun visitPlanPhasePercentageDiscountAdjustment( + planPhasePercentageDiscountAdjustment: PlanPhasePercentageDiscountAdjustment + ) { + planPhasePercentageDiscountAdjustment.validate() + } + + override fun visitPlanPhaseMinimumAdjustment( + planPhaseMinimumAdjustment: PlanPhaseMinimumAdjustment + ) { + planPhaseMinimumAdjustment.validate() + } + + override fun visitPlanPhaseMaximumAdjustment( + planPhaseMaximumAdjustment: PlanPhaseMaximumAdjustment + ) { + planPhaseMaximumAdjustment.validate() + } + } + ) + validated = true + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentModel && planPhaseUsageDiscountAdjustment == other.planPhaseUsageDiscountAdjustment && planPhaseAmountDiscountAdjustment == other.planPhaseAmountDiscountAdjustment && planPhasePercentageDiscountAdjustment == other.planPhasePercentageDiscountAdjustment && planPhaseMinimumAdjustment == other.planPhaseMinimumAdjustment && planPhaseMaximumAdjustment == other.planPhaseMaximumAdjustment /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(planPhaseUsageDiscountAdjustment, planPhaseAmountDiscountAdjustment, planPhasePercentageDiscountAdjustment, planPhaseMinimumAdjustment, planPhaseMaximumAdjustment) /* spotless:on */ + + override fun toString(): String = + when { + planPhaseUsageDiscountAdjustment != null -> + "AdjustmentModel{planPhaseUsageDiscountAdjustment=$planPhaseUsageDiscountAdjustment}" + planPhaseAmountDiscountAdjustment != null -> + "AdjustmentModel{planPhaseAmountDiscountAdjustment=$planPhaseAmountDiscountAdjustment}" + planPhasePercentageDiscountAdjustment != null -> + "AdjustmentModel{planPhasePercentageDiscountAdjustment=$planPhasePercentageDiscountAdjustment}" + planPhaseMinimumAdjustment != null -> + "AdjustmentModel{planPhaseMinimumAdjustment=$planPhaseMinimumAdjustment}" + planPhaseMaximumAdjustment != null -> + "AdjustmentModel{planPhaseMaximumAdjustment=$planPhaseMaximumAdjustment}" + _json != null -> "AdjustmentModel{_unknown=$_json}" + else -> throw IllegalStateException("Invalid AdjustmentModel") + } + + companion object { + + @JvmStatic + fun ofPlanPhaseUsageDiscountAdjustment( + planPhaseUsageDiscountAdjustment: PlanPhaseUsageDiscountAdjustment + ) = AdjustmentModel(planPhaseUsageDiscountAdjustment = planPhaseUsageDiscountAdjustment) + + @JvmStatic + fun ofPlanPhaseAmountDiscountAdjustment( + planPhaseAmountDiscountAdjustment: PlanPhaseAmountDiscountAdjustment + ) = AdjustmentModel(planPhaseAmountDiscountAdjustment = planPhaseAmountDiscountAdjustment) + + @JvmStatic + fun ofPlanPhasePercentageDiscountAdjustment( + planPhasePercentageDiscountAdjustment: PlanPhasePercentageDiscountAdjustment + ) = + AdjustmentModel( + planPhasePercentageDiscountAdjustment = planPhasePercentageDiscountAdjustment + ) + + @JvmStatic + fun ofPlanPhaseMinimumAdjustment(planPhaseMinimumAdjustment: PlanPhaseMinimumAdjustment) = + AdjustmentModel(planPhaseMinimumAdjustment = planPhaseMinimumAdjustment) + + @JvmStatic + fun ofPlanPhaseMaximumAdjustment(planPhaseMaximumAdjustment: PlanPhaseMaximumAdjustment) = + AdjustmentModel(planPhaseMaximumAdjustment = planPhaseMaximumAdjustment) + } + + /** + * An interface that defines how to map each variant of [AdjustmentModel] to a value of type + * [T]. + */ + interface Visitor { + + fun visitPlanPhaseUsageDiscountAdjustment( + planPhaseUsageDiscountAdjustment: PlanPhaseUsageDiscountAdjustment + ): T + + fun visitPlanPhaseAmountDiscountAdjustment( + planPhaseAmountDiscountAdjustment: PlanPhaseAmountDiscountAdjustment + ): T + + fun visitPlanPhasePercentageDiscountAdjustment( + planPhasePercentageDiscountAdjustment: PlanPhasePercentageDiscountAdjustment + ): T + + fun visitPlanPhaseMinimumAdjustment( + planPhaseMinimumAdjustment: PlanPhaseMinimumAdjustment + ): T + + fun visitPlanPhaseMaximumAdjustment( + planPhaseMaximumAdjustment: PlanPhaseMaximumAdjustment + ): T + + /** + * Maps an unknown variant of [AdjustmentModel] to a value of type [T]. + * + * An instance of [AdjustmentModel] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is unaware + * of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown AdjustmentModel: $json") + } + } + + internal class Deserializer : BaseDeserializer(AdjustmentModel::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): AdjustmentModel { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = + json.asObject().getOrNull()?.get("adjustment_type")?.asString()?.getOrNull() + + when (adjustmentType) { + "usage_discount" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return AdjustmentModel( + planPhaseUsageDiscountAdjustment = it, + _json = json, + ) + } + } + "amount_discount" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return AdjustmentModel( + planPhaseAmountDiscountAdjustment = it, + _json = json, + ) + } + } + "percentage_discount" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return AdjustmentModel( + planPhasePercentageDiscountAdjustment = it, + _json = json, + ) + } + } + "minimum" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return AdjustmentModel(planPhaseMinimumAdjustment = it, _json = json) + } + } + "maximum" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return AdjustmentModel(planPhaseMaximumAdjustment = it, _json = json) + } + } + } + + return AdjustmentModel(_json = json) + } + } + + internal class Serializer : BaseSerializer(AdjustmentModel::class) { + + override fun serialize( + value: AdjustmentModel, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.planPhaseUsageDiscountAdjustment != null -> + generator.writeObject(value.planPhaseUsageDiscountAdjustment) + value.planPhaseAmountDiscountAdjustment != null -> + generator.writeObject(value.planPhaseAmountDiscountAdjustment) + value.planPhasePercentageDiscountAdjustment != null -> + generator.writeObject(value.planPhasePercentageDiscountAdjustment) + value.planPhaseMinimumAdjustment != null -> + generator.writeObject(value.planPhaseMinimumAdjustment) + value.planPhaseMaximumAdjustment != null -> + generator.writeObject(value.planPhaseMaximumAdjustment) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid AdjustmentModel") + } + } + } + + @NoAutoDetect + class PlanPhaseUsageDiscountAdjustment + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("adjustment_type") + @ExcludeMissing + private val adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + private val isInvoiceLevel: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + private val reason: JsonField = JsonMissing.of(), + @JsonProperty("usage_discount") + @ExcludeMissing + private val usageDiscount: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * True for adjustments that apply to an entire invocice, false for adjustments that apply + * to only one price. + */ + fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + /** + * The number of usage units by which to discount the price this adjustment applies to in a + * given billing period. + */ + fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** + * True for adjustments that apply to an entire invocice, false for adjustments that apply + * to only one price. + */ + @JsonProperty("is_invoice_level") + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel + + /** The plan phase in which this adjustment is active. */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + + /** + * The number of usage units by which to discount the price this adjustment applies to in a + * given billing period. + */ + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): PlanPhaseUsageDiscountAdjustment = apply { + if (validated) { + return@apply + } + + id() + adjustmentType() + appliesToPriceIds() + isInvoiceLevel() + planPhaseOrder() + reason() + usageDiscount() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PlanPhaseUsageDiscountAdjustment]. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .planPhaseOrder() + * .reason() + * .usageDiscount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PlanPhaseUsageDiscountAdjustment]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null + private var usageDiscount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(planPhaseUsageDiscountAdjustment: PlanPhaseUsageDiscountAdjustment) = + apply { + id = planPhaseUsageDiscountAdjustment.id + adjustmentType = planPhaseUsageDiscountAdjustment.adjustmentType + appliesToPriceIds = + planPhaseUsageDiscountAdjustment.appliesToPriceIds.map { + it.toMutableList() + } + isInvoiceLevel = planPhaseUsageDiscountAdjustment.isInvoiceLevel + planPhaseOrder = planPhaseUsageDiscountAdjustment.planPhaseOrder + reason = planPhaseUsageDiscountAdjustment.reason + usageDiscount = planPhaseUsageDiscountAdjustment.usageDiscount + additionalProperties = + planPhaseUsageDiscountAdjustment.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** + * True for adjustments that apply to an entire invocice, false for adjustments that + * apply to only one price. + */ + fun isInvoiceLevel(isInvoiceLevel: Boolean) = + isInvoiceLevel(JsonField.of(isInvoiceLevel)) + + /** + * True for adjustments that apply to an entire invocice, false for adjustments that + * apply to only one price. + */ + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + /** The reason for the adjustment. */ + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) + + /** The reason for the adjustment. */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + /** + * The number of usage units by which to discount the price this adjustment applies to + * in a given billing period. + */ + fun usageDiscount(usageDiscount: Double) = usageDiscount(JsonField.of(usageDiscount)) + + /** + * The number of usage units by which to discount the price this adjustment applies to + * in a given billing period. + */ + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): PlanPhaseUsageDiscountAdjustment = + PlanPhaseUsageDiscountAdjustment( + checkRequired("id", id), + checkRequired("adjustmentType", adjustmentType), + checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, + checkRequired("isInvoiceLevel", isInvoiceLevel), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("reason", reason), + checkRequired("usageDiscount", usageDiscount), + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_DISCOUNT = of("usage_discount") + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + /** An enum containing [AdjustmentType]'s known values. */ + enum class Known { + USAGE_DISCOUNT + } + + /** + * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AdjustmentType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_DISCOUNT, + /** + * An enum member indicating that [AdjustmentType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_DISCOUNT -> Value.USAGE_DISCOUNT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_DISCOUNT -> Known.USAGE_DISCOUNT + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PlanPhaseUsageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, planPhaseOrder, reason, usageDiscount, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PlanPhaseUsageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class PlanPhaseAmountDiscountAdjustment + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("adjustment_type") + @ExcludeMissing + private val adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("amount_discount") + @ExcludeMissing + private val amountDiscount: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + private val isInvoiceLevel: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + private val reason: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** + * The amount by which to discount the prices this adjustment applies to in a given billing + * period. + */ + fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * True for adjustments that apply to an entire invocice, false for adjustments that apply + * to only one price. + */ + fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType + + /** + * The amount by which to discount the prices this adjustment applies to in a given billing + * period. + */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount(): JsonField = amountDiscount + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** + * True for adjustments that apply to an entire invocice, false for adjustments that apply + * to only one price. + */ + @JsonProperty("is_invoice_level") + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel + + /** The plan phase in which this adjustment is active. */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): PlanPhaseAmountDiscountAdjustment = apply { + if (validated) { + return@apply + } + + id() + adjustmentType() + amountDiscount() + appliesToPriceIds() + isInvoiceLevel() + planPhaseOrder() + reason() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PlanPhaseAmountDiscountAdjustment]. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .amountDiscount() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .planPhaseOrder() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PlanPhaseAmountDiscountAdjustment]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var amountDiscount: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + planPhaseAmountDiscountAdjustment: PlanPhaseAmountDiscountAdjustment + ) = apply { + id = planPhaseAmountDiscountAdjustment.id + adjustmentType = planPhaseAmountDiscountAdjustment.adjustmentType + amountDiscount = planPhaseAmountDiscountAdjustment.amountDiscount + appliesToPriceIds = + planPhaseAmountDiscountAdjustment.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = planPhaseAmountDiscountAdjustment.isInvoiceLevel + planPhaseOrder = planPhaseAmountDiscountAdjustment.planPhaseOrder + reason = planPhaseAmountDiscountAdjustment.reason + additionalProperties = + planPhaseAmountDiscountAdjustment.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** + * The amount by which to discount the prices this adjustment applies to in a given + * billing period. + */ + fun amountDiscount(amountDiscount: String) = + amountDiscount(JsonField.of(amountDiscount)) + + /** + * The amount by which to discount the prices this adjustment applies to in a given + * billing period. + */ + fun amountDiscount(amountDiscount: JsonField) = apply { + this.amountDiscount = amountDiscount + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** + * True for adjustments that apply to an entire invocice, false for adjustments that + * apply to only one price. + */ + fun isInvoiceLevel(isInvoiceLevel: Boolean) = + isInvoiceLevel(JsonField.of(isInvoiceLevel)) + + /** + * True for adjustments that apply to an entire invocice, false for adjustments that + * apply to only one price. + */ + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + /** The reason for the adjustment. */ + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) + + /** The reason for the adjustment. */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): PlanPhaseAmountDiscountAdjustment = + PlanPhaseAmountDiscountAdjustment( + checkRequired("id", id), + checkRequired("adjustmentType", adjustmentType), + checkRequired("amountDiscount", amountDiscount), + checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, + checkRequired("isInvoiceLevel", isInvoiceLevel), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("reason", reason), + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val AMOUNT_DISCOUNT = of("amount_discount") + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + /** An enum containing [AdjustmentType]'s known values. */ + enum class Known { + AMOUNT_DISCOUNT + } + + /** + * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AdjustmentType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AMOUNT_DISCOUNT, + /** + * An enum member indicating that [AdjustmentType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PlanPhaseAmountDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, amountDiscount, appliesToPriceIds, isInvoiceLevel, planPhaseOrder, reason, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PlanPhaseAmountDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class PlanPhasePercentageDiscountAdjustment + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("adjustment_type") + @ExcludeMissing + private val adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + private val isInvoiceLevel: JsonField = JsonMissing.of(), + @JsonProperty("percentage_discount") + @ExcludeMissing + private val percentageDiscount: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + private val reason: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * True for adjustments that apply to an entire invocice, false for adjustments that apply + * to only one price. + */ + fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") + + /** + * The percentage (as a value between 0 and 1) by which to discount the price intervals this + * adjustment applies to in a given billing period. + */ + fun percentageDiscount(): Double = percentageDiscount.getRequired("percentage_discount") + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** + * True for adjustments that apply to an entire invocice, false for adjustments that apply + * to only one price. + */ + @JsonProperty("is_invoice_level") + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel + + /** + * The percentage (as a value between 0 and 1) by which to discount the price intervals this + * adjustment applies to in a given billing period. + */ + @JsonProperty("percentage_discount") + @ExcludeMissing + fun _percentageDiscount(): JsonField = percentageDiscount + + /** The plan phase in which this adjustment is active. */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): PlanPhasePercentageDiscountAdjustment = apply { + if (validated) { + return@apply + } + + id() + adjustmentType() + appliesToPriceIds() + isInvoiceLevel() + percentageDiscount() + planPhaseOrder() + reason() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PlanPhasePercentageDiscountAdjustment]. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .percentageDiscount() + * .planPhaseOrder() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PlanPhasePercentageDiscountAdjustment]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var percentageDiscount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + planPhasePercentageDiscountAdjustment: PlanPhasePercentageDiscountAdjustment + ) = apply { + id = planPhasePercentageDiscountAdjustment.id + adjustmentType = planPhasePercentageDiscountAdjustment.adjustmentType + appliesToPriceIds = + planPhasePercentageDiscountAdjustment.appliesToPriceIds.map { + it.toMutableList() + } + isInvoiceLevel = planPhasePercentageDiscountAdjustment.isInvoiceLevel + percentageDiscount = planPhasePercentageDiscountAdjustment.percentageDiscount + planPhaseOrder = planPhasePercentageDiscountAdjustment.planPhaseOrder + reason = planPhasePercentageDiscountAdjustment.reason + additionalProperties = + planPhasePercentageDiscountAdjustment.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** + * True for adjustments that apply to an entire invocice, false for adjustments that + * apply to only one price. + */ + fun isInvoiceLevel(isInvoiceLevel: Boolean) = + isInvoiceLevel(JsonField.of(isInvoiceLevel)) + + /** + * True for adjustments that apply to an entire invocice, false for adjustments that + * apply to only one price. + */ + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } + + /** + * The percentage (as a value between 0 and 1) by which to discount the price intervals + * this adjustment applies to in a given billing period. + */ + fun percentageDiscount(percentageDiscount: Double) = + percentageDiscount(JsonField.of(percentageDiscount)) + + /** + * The percentage (as a value between 0 and 1) by which to discount the price intervals + * this adjustment applies to in a given billing period. + */ + fun percentageDiscount(percentageDiscount: JsonField) = apply { + this.percentageDiscount = percentageDiscount + } + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + /** The reason for the adjustment. */ + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) + + /** The reason for the adjustment. */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): PlanPhasePercentageDiscountAdjustment = + PlanPhasePercentageDiscountAdjustment( + checkRequired("id", id), + checkRequired("adjustmentType", adjustmentType), + checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, + checkRequired("isInvoiceLevel", isInvoiceLevel), + checkRequired("percentageDiscount", percentageDiscount), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("reason", reason), + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PERCENTAGE_DISCOUNT = of("percentage_discount") + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + /** An enum containing [AdjustmentType]'s known values. */ + enum class Known { + PERCENTAGE_DISCOUNT + } + + /** + * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AdjustmentType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PERCENTAGE_DISCOUNT, + /** + * An enum member indicating that [AdjustmentType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PlanPhasePercentageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, percentageDiscount, planPhaseOrder, reason, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PlanPhasePercentageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class PlanPhaseMinimumAdjustment + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("adjustment_type") + @ExcludeMissing + private val adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + private val isInvoiceLevel: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + private val reason: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * True for adjustments that apply to an entire invocice, false for adjustments that apply + * to only one price. + */ + fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") + + /** The item ID that revenue from this minimum will be attributed to. */ + fun itemId(): String = itemId.getRequired("item_id") + + /** + * The minimum amount to charge in a given billing period for the prices this adjustment + * applies to. + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** + * True for adjustments that apply to an entire invocice, false for adjustments that apply + * to only one price. + */ + @JsonProperty("is_invoice_level") + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel + + /** The item ID that revenue from this minimum will be attributed to. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** + * The minimum amount to charge in a given billing period for the prices this adjustment + * applies to. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** The plan phase in which this adjustment is active. */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): PlanPhaseMinimumAdjustment = apply { + if (validated) { + return@apply + } + + id() + adjustmentType() + appliesToPriceIds() + isInvoiceLevel() + itemId() + minimumAmount() + planPhaseOrder() + reason() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PlanPhaseMinimumAdjustment]. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .itemId() + * .minimumAmount() + * .planPhaseOrder() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PlanPhaseMinimumAdjustment]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var itemId: JsonField? = null + private var minimumAmount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(planPhaseMinimumAdjustment: PlanPhaseMinimumAdjustment) = apply { + id = planPhaseMinimumAdjustment.id + adjustmentType = planPhaseMinimumAdjustment.adjustmentType + appliesToPriceIds = + planPhaseMinimumAdjustment.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = planPhaseMinimumAdjustment.isInvoiceLevel + itemId = planPhaseMinimumAdjustment.itemId + minimumAmount = planPhaseMinimumAdjustment.minimumAmount + planPhaseOrder = planPhaseMinimumAdjustment.planPhaseOrder + reason = planPhaseMinimumAdjustment.reason + additionalProperties = + planPhaseMinimumAdjustment.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** + * True for adjustments that apply to an entire invocice, false for adjustments that + * apply to only one price. + */ + fun isInvoiceLevel(isInvoiceLevel: Boolean) = + isInvoiceLevel(JsonField.of(isInvoiceLevel)) + + /** + * True for adjustments that apply to an entire invocice, false for adjustments that + * apply to only one price. + */ + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } + + /** The item ID that revenue from this minimum will be attributed to. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** The item ID that revenue from this minimum will be attributed to. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** + * The minimum amount to charge in a given billing period for the prices this adjustment + * applies to. + */ + fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) + + /** + * The minimum amount to charge in a given billing period for the prices this adjustment + * applies to. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + /** The reason for the adjustment. */ + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) + + /** The reason for the adjustment. */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): PlanPhaseMinimumAdjustment = + PlanPhaseMinimumAdjustment( + checkRequired("id", id), + checkRequired("adjustmentType", adjustmentType), + checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, + checkRequired("isInvoiceLevel", isInvoiceLevel), + checkRequired("itemId", itemId), + checkRequired("minimumAmount", minimumAmount), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("reason", reason), + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val MINIMUM = of("minimum") + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + /** An enum containing [AdjustmentType]'s known values. */ + enum class Known { + MINIMUM + } + + /** + * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AdjustmentType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MINIMUM, + /** + * An enum member indicating that [AdjustmentType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MINIMUM -> Value.MINIMUM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MINIMUM -> Known.MINIMUM + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PlanPhaseMinimumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, itemId, minimumAmount, planPhaseOrder, reason, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PlanPhaseMinimumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class PlanPhaseMaximumAdjustment + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("adjustment_type") + @ExcludeMissing + private val adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + private val isInvoiceLevel: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + private val reason: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * True for adjustments that apply to an entire invocice, false for adjustments that apply + * to only one price. + */ + fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") + + /** + * The maximum amount to charge in a given billing period for the prices this adjustment + * applies to. + */ + fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + /** The reason for the adjustment. */ + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType + + /** The price IDs that this adjustment applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** + * True for adjustments that apply to an entire invocice, false for adjustments that apply + * to only one price. + */ + @JsonProperty("is_invoice_level") + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel + + /** + * The maximum amount to charge in a given billing period for the prices this adjustment + * applies to. + */ + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount + + /** The plan phase in which this adjustment is active. */ + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + /** The reason for the adjustment. */ + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): PlanPhaseMaximumAdjustment = apply { + if (validated) { + return@apply + } + + id() + adjustmentType() + appliesToPriceIds() + isInvoiceLevel() + maximumAmount() + planPhaseOrder() + reason() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PlanPhaseMaximumAdjustment]. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .maximumAmount() + * .planPhaseOrder() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PlanPhaseMaximumAdjustment]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var maximumAmount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(planPhaseMaximumAdjustment: PlanPhaseMaximumAdjustment) = apply { + id = planPhaseMaximumAdjustment.id + adjustmentType = planPhaseMaximumAdjustment.adjustmentType + appliesToPriceIds = + planPhaseMaximumAdjustment.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = planPhaseMaximumAdjustment.isInvoiceLevel + maximumAmount = planPhaseMaximumAdjustment.maximumAmount + planPhaseOrder = planPhaseMaximumAdjustment.planPhaseOrder + reason = planPhaseMaximumAdjustment.reason + additionalProperties = + planPhaseMaximumAdjustment.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price IDs that this adjustment applies to. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** + * True for adjustments that apply to an entire invocice, false for adjustments that + * apply to only one price. + */ + fun isInvoiceLevel(isInvoiceLevel: Boolean) = + isInvoiceLevel(JsonField.of(isInvoiceLevel)) + + /** + * True for adjustments that apply to an entire invocice, false for adjustments that + * apply to only one price. + */ + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } + + /** + * The maximum amount to charge in a given billing period for the prices this adjustment + * applies to. + */ + fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) + + /** + * The maximum amount to charge in a given billing period for the prices this adjustment + * applies to. + */ + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + /** The reason for the adjustment. */ + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) + + /** The reason for the adjustment. */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): PlanPhaseMaximumAdjustment = + PlanPhaseMaximumAdjustment( + checkRequired("id", id), + checkRequired("adjustmentType", adjustmentType), + checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, + checkRequired("isInvoiceLevel", isInvoiceLevel), + checkRequired("maximumAmount", maximumAmount), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("reason", reason), + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val MAXIMUM = of("maximum") + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + /** An enum containing [AdjustmentType]'s known values. */ + enum class Known { + MAXIMUM + } + + /** + * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AdjustmentType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MAXIMUM, + /** + * An enum member indicating that [AdjustmentType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MAXIMUM -> Value.MAXIMUM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MAXIMUM -> Known.MAXIMUM + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PlanPhaseMaximumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, maximumAmount, planPhaseOrder, reason, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PlanPhaseMaximumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AffectedBlockModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AffectedBlockModel.kt new file mode 100644 index 000000000..2e66223e1 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AffectedBlockModel.kt @@ -0,0 +1,169 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class AffectedBlockModel +@JsonCreator +private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("expiry_date") + @ExcludeMissing + private val expiryDate: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_cost_basis") + @ExcludeMissing + private val perUnitCostBasis: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun id(): String = id.getRequired("id") + + fun expiryDate(): Optional = + Optional.ofNullable(expiryDate.getNullable("expiry_date")) + + fun perUnitCostBasis(): Optional = + Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("expiry_date") + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate + + @JsonProperty("per_unit_cost_basis") + @ExcludeMissing + fun _perUnitCostBasis(): JsonField = perUnitCostBasis + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): AffectedBlockModel = apply { + if (validated) { + return@apply + } + + id() + expiryDate() + perUnitCostBasis() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AffectedBlockModel]. + * + * The following fields are required: + * ```java + * .id() + * .expiryDate() + * .perUnitCostBasis() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AffectedBlockModel]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var expiryDate: JsonField? = null + private var perUnitCostBasis: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(affectedBlockModel: AffectedBlockModel) = apply { + id = affectedBlockModel.id + expiryDate = affectedBlockModel.expiryDate + perUnitCostBasis = affectedBlockModel.perUnitCostBasis + additionalProperties = affectedBlockModel.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun expiryDate(expiryDate: OffsetDateTime?) = expiryDate(JsonField.ofNullable(expiryDate)) + + fun expiryDate(expiryDate: Optional) = expiryDate(expiryDate.orElse(null)) + + fun expiryDate(expiryDate: JsonField) = apply { + this.expiryDate = expiryDate + } + + fun perUnitCostBasis(perUnitCostBasis: String?) = + perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) + + fun perUnitCostBasis(perUnitCostBasis: Optional) = + perUnitCostBasis(perUnitCostBasis.orElse(null)) + + fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { + this.perUnitCostBasis = perUnitCostBasis + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): AffectedBlockModel = + AffectedBlockModel( + checkRequired("id", id), + checkRequired("expiryDate", expiryDate), + checkRequired("perUnitCostBasis", perUnitCostBasis), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AffectedBlockModel && id == other.id && expiryDate == other.expiryDate && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, expiryDate, perUnitCostBasis, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AffectedBlockModel{id=$id, expiryDate=$expiryDate, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AggregatedCostModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AggregatedCostModel.kt new file mode 100644 index 000000000..14c9b7229 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AggregatedCostModel.kt @@ -0,0 +1,532 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class AggregatedCostModel +@JsonCreator +private constructor( + @JsonProperty("per_price_costs") + @ExcludeMissing + private val perPriceCosts: JsonField> = JsonMissing.of(), + @JsonProperty("subtotal") + @ExcludeMissing + private val subtotal: JsonField = JsonMissing.of(), + @JsonProperty("timeframe_end") + @ExcludeMissing + private val timeframeEnd: JsonField = JsonMissing.of(), + @JsonProperty("timeframe_start") + @ExcludeMissing + private val timeframeStart: JsonField = JsonMissing.of(), + @JsonProperty("total") @ExcludeMissing private val total: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun perPriceCosts(): List = perPriceCosts.getRequired("per_price_costs") + + /** Total costs for the timeframe, excluding any minimums and discounts. */ + fun subtotal(): String = subtotal.getRequired("subtotal") + + fun timeframeEnd(): OffsetDateTime = timeframeEnd.getRequired("timeframe_end") + + fun timeframeStart(): OffsetDateTime = timeframeStart.getRequired("timeframe_start") + + /** Total costs for the timeframe, including any minimums and discounts. */ + fun total(): String = total.getRequired("total") + + @JsonProperty("per_price_costs") + @ExcludeMissing + fun _perPriceCosts(): JsonField> = perPriceCosts + + /** Total costs for the timeframe, excluding any minimums and discounts. */ + @JsonProperty("subtotal") @ExcludeMissing fun _subtotal(): JsonField = subtotal + + @JsonProperty("timeframe_end") + @ExcludeMissing + fun _timeframeEnd(): JsonField = timeframeEnd + + @JsonProperty("timeframe_start") + @ExcludeMissing + fun _timeframeStart(): JsonField = timeframeStart + + /** Total costs for the timeframe, including any minimums and discounts. */ + @JsonProperty("total") @ExcludeMissing fun _total(): JsonField = total + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): AggregatedCostModel = apply { + if (validated) { + return@apply + } + + perPriceCosts().forEach { it.validate() } + subtotal() + timeframeEnd() + timeframeStart() + total() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AggregatedCostModel]. + * + * The following fields are required: + * ```java + * .perPriceCosts() + * .subtotal() + * .timeframeEnd() + * .timeframeStart() + * .total() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AggregatedCostModel]. */ + class Builder internal constructor() { + + private var perPriceCosts: JsonField>? = null + private var subtotal: JsonField? = null + private var timeframeEnd: JsonField? = null + private var timeframeStart: JsonField? = null + private var total: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(aggregatedCostModel: AggregatedCostModel) = apply { + perPriceCosts = aggregatedCostModel.perPriceCosts.map { it.toMutableList() } + subtotal = aggregatedCostModel.subtotal + timeframeEnd = aggregatedCostModel.timeframeEnd + timeframeStart = aggregatedCostModel.timeframeStart + total = aggregatedCostModel.total + additionalProperties = aggregatedCostModel.additionalProperties.toMutableMap() + } + + fun perPriceCosts(perPriceCosts: List) = + perPriceCosts(JsonField.of(perPriceCosts)) + + fun perPriceCosts(perPriceCosts: JsonField>) = apply { + this.perPriceCosts = perPriceCosts.map { it.toMutableList() } + } + + fun addPerPriceCost(perPriceCost: PerPriceCost) = apply { + perPriceCosts = + (perPriceCosts ?: JsonField.of(mutableListOf())).also { + checkKnown("perPriceCosts", it).add(perPriceCost) + } + } + + /** Total costs for the timeframe, excluding any minimums and discounts. */ + fun subtotal(subtotal: String) = subtotal(JsonField.of(subtotal)) + + /** Total costs for the timeframe, excluding any minimums and discounts. */ + fun subtotal(subtotal: JsonField) = apply { this.subtotal = subtotal } + + fun timeframeEnd(timeframeEnd: OffsetDateTime) = timeframeEnd(JsonField.of(timeframeEnd)) + + fun timeframeEnd(timeframeEnd: JsonField) = apply { + this.timeframeEnd = timeframeEnd + } + + fun timeframeStart(timeframeStart: OffsetDateTime) = + timeframeStart(JsonField.of(timeframeStart)) + + fun timeframeStart(timeframeStart: JsonField) = apply { + this.timeframeStart = timeframeStart + } + + /** Total costs for the timeframe, including any minimums and discounts. */ + fun total(total: String) = total(JsonField.of(total)) + + /** Total costs for the timeframe, including any minimums and discounts. */ + fun total(total: JsonField) = apply { this.total = total } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): AggregatedCostModel = + AggregatedCostModel( + checkRequired("perPriceCosts", perPriceCosts).map { it.toImmutable() }, + checkRequired("subtotal", subtotal), + checkRequired("timeframeEnd", timeframeEnd), + checkRequired("timeframeStart", timeframeStart), + checkRequired("total", total), + additionalProperties.toImmutable(), + ) + } + + @NoAutoDetect + class PerPriceCost + @JsonCreator + private constructor( + @JsonProperty("price") + @ExcludeMissing + private val price: JsonField = JsonMissing.of(), + @JsonProperty("price_id") + @ExcludeMissing + private val priceId: JsonField = JsonMissing.of(), + @JsonProperty("subtotal") + @ExcludeMissing + private val subtotal: JsonField = JsonMissing.of(), + @JsonProperty("total") + @ExcludeMissing + private val total: JsonField = JsonMissing.of(), + @JsonProperty("quantity") + @ExcludeMissing + private val quantity: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The price object */ + fun price(): PriceModel = price.getRequired("price") + + /** The price the cost is associated with */ + fun priceId(): String = priceId.getRequired("price_id") + + /** Price's contributions for the timeframe, excluding any minimums and discounts. */ + fun subtotal(): String = subtotal.getRequired("subtotal") + + /** Price's contributions for the timeframe, including minimums and discounts. */ + fun total(): String = total.getRequired("total") + + /** The price's quantity for the timeframe */ + fun quantity(): Optional = Optional.ofNullable(quantity.getNullable("quantity")) + + /** The price object */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + + /** The price the cost is associated with */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + + /** Price's contributions for the timeframe, excluding any minimums and discounts. */ + @JsonProperty("subtotal") @ExcludeMissing fun _subtotal(): JsonField = subtotal + + /** Price's contributions for the timeframe, including minimums and discounts. */ + @JsonProperty("total") @ExcludeMissing fun _total(): JsonField = total + + /** The price's quantity for the timeframe */ + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): PerPriceCost = apply { + if (validated) { + return@apply + } + + price().validate() + priceId() + subtotal() + total() + quantity() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PerPriceCost]. + * + * The following fields are required: + * ```java + * .price() + * .priceId() + * .subtotal() + * .total() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PerPriceCost]. */ + class Builder internal constructor() { + + private var price: JsonField? = null + private var priceId: JsonField? = null + private var subtotal: JsonField? = null + private var total: JsonField? = null + private var quantity: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(perPriceCost: PerPriceCost) = apply { + price = perPriceCost.price + priceId = perPriceCost.priceId + subtotal = perPriceCost.subtotal + total = perPriceCost.total + quantity = perPriceCost.quantity + additionalProperties = perPriceCost.additionalProperties.toMutableMap() + } + + /** The price object */ + fun price(price: PriceModel) = price(JsonField.of(price)) + + /** The price object */ + fun price(price: JsonField) = apply { this.price = price } + + /** The price object */ + fun price(unitPrice: PriceModel.UnitPrice) = price(PriceModel.ofUnitPrice(unitPrice)) + + /** The price object */ + fun price(packagePrice: PriceModel.PackagePrice) = + price(PriceModel.ofPackagePrice(packagePrice)) + + /** The price object */ + fun price(matrixPrice: PriceModel.MatrixPrice) = + price(PriceModel.ofMatrixPrice(matrixPrice)) + + /** The price object */ + fun price(tieredPrice: PriceModel.TieredPrice) = + price(PriceModel.ofTieredPrice(tieredPrice)) + + /** The price object */ + fun price(tieredBpsPrice: PriceModel.TieredBpsPrice) = + price(PriceModel.ofTieredBpsPrice(tieredBpsPrice)) + + /** The price object */ + fun price(bpsPrice: PriceModel.BpsPrice) = price(PriceModel.ofBpsPrice(bpsPrice)) + + /** The price object */ + fun price(bulkBpsPrice: PriceModel.BulkBpsPrice) = + price(PriceModel.ofBulkBpsPrice(bulkBpsPrice)) + + /** The price object */ + fun price(bulkPrice: PriceModel.BulkPrice) = price(PriceModel.ofBulkPrice(bulkPrice)) + + /** The price object */ + fun price(thresholdTotalAmountPrice: PriceModel.ThresholdTotalAmountPrice) = + price(PriceModel.ofThresholdTotalAmountPrice(thresholdTotalAmountPrice)) + + /** The price object */ + fun price(tieredPackagePrice: PriceModel.TieredPackagePrice) = + price(PriceModel.ofTieredPackagePrice(tieredPackagePrice)) + + /** The price object */ + fun price(groupedTieredPrice: PriceModel.GroupedTieredPrice) = + price(PriceModel.ofGroupedTieredPrice(groupedTieredPrice)) + + /** The price object */ + fun price(tieredWithMinimumPrice: PriceModel.TieredWithMinimumPrice) = + price(PriceModel.ofTieredWithMinimumPrice(tieredWithMinimumPrice)) + + /** The price object */ + fun price(tieredPackageWithMinimumPrice: PriceModel.TieredPackageWithMinimumPrice) = + price(PriceModel.ofTieredPackageWithMinimumPrice(tieredPackageWithMinimumPrice)) + + /** The price object */ + fun price(packageWithAllocationPrice: PriceModel.PackageWithAllocationPrice) = + price(PriceModel.ofPackageWithAllocationPrice(packageWithAllocationPrice)) + + /** The price object */ + fun price(unitWithPercentPrice: PriceModel.UnitWithPercentPrice) = + price(PriceModel.ofUnitWithPercentPrice(unitWithPercentPrice)) + + /** The price object */ + fun price(matrixWithAllocationPrice: PriceModel.MatrixWithAllocationPrice) = + price(PriceModel.ofMatrixWithAllocationPrice(matrixWithAllocationPrice)) + + /** The price object */ + fun price(tieredWithProrationPrice: PriceModel.TieredWithProrationPrice) = + price(PriceModel.ofTieredWithProrationPrice(tieredWithProrationPrice)) + + /** The price object */ + fun price(unitWithProrationPrice: PriceModel.UnitWithProrationPrice) = + price(PriceModel.ofUnitWithProrationPrice(unitWithProrationPrice)) + + /** The price object */ + fun price(groupedAllocationPrice: PriceModel.GroupedAllocationPrice) = + price(PriceModel.ofGroupedAllocationPrice(groupedAllocationPrice)) + + /** The price object */ + fun price(groupedWithProratedMinimumPrice: PriceModel.GroupedWithProratedMinimumPrice) = + price(PriceModel.ofGroupedWithProratedMinimumPrice(groupedWithProratedMinimumPrice)) + + /** The price object */ + fun price(groupedWithMeteredMinimumPrice: PriceModel.GroupedWithMeteredMinimumPrice) = + price(PriceModel.ofGroupedWithMeteredMinimumPrice(groupedWithMeteredMinimumPrice)) + + /** The price object */ + fun price(matrixWithDisplayNamePrice: PriceModel.MatrixWithDisplayNamePrice) = + price(PriceModel.ofMatrixWithDisplayNamePrice(matrixWithDisplayNamePrice)) + + /** The price object */ + fun price(bulkWithProrationPrice: PriceModel.BulkWithProrationPrice) = + price(PriceModel.ofBulkWithProrationPrice(bulkWithProrationPrice)) + + /** The price object */ + fun price(groupedTieredPackagePrice: PriceModel.GroupedTieredPackagePrice) = + price(PriceModel.ofGroupedTieredPackagePrice(groupedTieredPackagePrice)) + + /** The price object */ + fun price(maxGroupTieredPackagePrice: PriceModel.MaxGroupTieredPackagePrice) = + price(PriceModel.ofMaxGroupTieredPackagePrice(maxGroupTieredPackagePrice)) + + /** The price object */ + fun price( + scalableMatrixWithUnitPricingPrice: PriceModel.ScalableMatrixWithUnitPricingPrice + ) = + price( + PriceModel.ofScalableMatrixWithUnitPricingPrice( + scalableMatrixWithUnitPricingPrice + ) + ) + + /** The price object */ + fun price( + scalableMatrixWithTieredPricingPrice: + PriceModel.ScalableMatrixWithTieredPricingPrice + ) = + price( + PriceModel.ofScalableMatrixWithTieredPricingPrice( + scalableMatrixWithTieredPricingPrice + ) + ) + + /** The price object */ + fun price(cumulativeGroupedBulkPrice: PriceModel.CumulativeGroupedBulkPrice) = + price(PriceModel.ofCumulativeGroupedBulkPrice(cumulativeGroupedBulkPrice)) + + /** The price the cost is associated with */ + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + /** The price the cost is associated with */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + /** Price's contributions for the timeframe, excluding any minimums and discounts. */ + fun subtotal(subtotal: String) = subtotal(JsonField.of(subtotal)) + + /** Price's contributions for the timeframe, excluding any minimums and discounts. */ + fun subtotal(subtotal: JsonField) = apply { this.subtotal = subtotal } + + /** Price's contributions for the timeframe, including minimums and discounts. */ + fun total(total: String) = total(JsonField.of(total)) + + /** Price's contributions for the timeframe, including minimums and discounts. */ + fun total(total: JsonField) = apply { this.total = total } + + /** The price's quantity for the timeframe */ + fun quantity(quantity: Double?) = quantity(JsonField.ofNullable(quantity)) + + /** The price's quantity for the timeframe */ + fun quantity(quantity: Double) = quantity(quantity as Double?) + + /** The price's quantity for the timeframe */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun quantity(quantity: Optional) = quantity(quantity.orElse(null) as Double?) + + /** The price's quantity for the timeframe */ + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): PerPriceCost = + PerPriceCost( + checkRequired("price", price), + checkRequired("priceId", priceId), + checkRequired("subtotal", subtotal), + checkRequired("total", total), + quantity, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PerPriceCost && price == other.price && priceId == other.priceId && subtotal == other.subtotal && total == other.total && quantity == other.quantity && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(price, priceId, subtotal, total, quantity, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PerPriceCost{price=$price, priceId=$priceId, subtotal=$subtotal, total=$total, quantity=$quantity, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AggregatedCostModel && perPriceCosts == other.perPriceCosts && subtotal == other.subtotal && timeframeEnd == other.timeframeEnd && timeframeStart == other.timeframeStart && total == other.total && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(perPriceCosts, subtotal, timeframeEnd, timeframeStart, total, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AggregatedCostModel{perPriceCosts=$perPriceCosts, subtotal=$subtotal, timeframeEnd=$timeframeEnd, timeframeStart=$timeframeStart, total=$total, additionalProperties=$additionalProperties}" +} 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 c6a067700..a28ea6690 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 @@ -12,6 +12,7 @@ import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.immutableEmptyMap import com.withorb.api.core.toImmutable @@ -39,7 +40,7 @@ private constructor( private val currency: JsonField = JsonMissing.of(), @JsonProperty("customer") @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), + private val customer: JsonField = JsonMissing.of(), @JsonProperty("enabled") @ExcludeMissing private val enabled: JsonField = JsonMissing.of(), @@ -49,10 +50,10 @@ private constructor( @JsonProperty("plan") @ExcludeMissing private val plan: JsonField = JsonMissing.of(), @JsonProperty("subscription") @ExcludeMissing - private val subscription: JsonField = JsonMissing.of(), + private val subscription: JsonField = JsonMissing.of(), @JsonProperty("thresholds") @ExcludeMissing - private val thresholds: JsonField> = JsonMissing.of(), + private val thresholds: JsonField> = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -67,7 +68,8 @@ private constructor( fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) /** The customer the alert applies to. */ - fun customer(): Optional = Optional.ofNullable(customer.getNullable("customer")) + fun customer(): Optional = + Optional.ofNullable(customer.getNullable("customer")) /** Whether the alert is enabled or disabled. */ fun enabled(): Boolean = enabled.getRequired("enabled") @@ -79,11 +81,11 @@ private constructor( fun plan(): Optional = Optional.ofNullable(plan.getNullable("plan")) /** The subscription the alert applies to. */ - fun subscription(): Optional = + fun subscription(): Optional = Optional.ofNullable(subscription.getNullable("subscription")) /** The thresholds that define the conditions under which the alert will be triggered. */ - fun thresholds(): Optional> = + fun thresholds(): Optional> = Optional.ofNullable(thresholds.getNullable("thresholds")) /** The type of alert. This must be a valid alert type. */ @@ -101,7 +103,9 @@ private constructor( @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** The customer the alert applies to. */ - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer + @JsonProperty("customer") + @ExcludeMissing + fun _customer(): JsonField = customer /** Whether the alert is enabled or disabled. */ @JsonProperty("enabled") @ExcludeMissing fun _enabled(): JsonField = enabled @@ -115,12 +119,12 @@ private constructor( /** The subscription the alert applies to. */ @JsonProperty("subscription") @ExcludeMissing - fun _subscription(): JsonField = subscription + fun _subscription(): JsonField = subscription /** The thresholds that define the conditions under which the alert will be triggered. */ @JsonProperty("thresholds") @ExcludeMissing - fun _thresholds(): JsonField> = thresholds + fun _thresholds(): JsonField> = thresholds /** The type of alert. This must be a valid alert type. */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @@ -153,6 +157,23 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Alert]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .currency() + * .customer() + * .enabled() + * .metric() + * .plan() + * .subscription() + * .thresholds() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -162,12 +183,12 @@ private constructor( private var id: JsonField? = null private var createdAt: JsonField? = null private var currency: JsonField? = null - private var customer: JsonField? = null + private var customer: JsonField? = null private var enabled: JsonField? = null private var metric: JsonField? = null private var plan: JsonField? = null - private var subscription: JsonField? = null - private var thresholds: JsonField>? = null + private var subscription: JsonField? = null + private var thresholds: JsonField>? = null private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -208,13 +229,15 @@ private constructor( fun currency(currency: JsonField) = apply { this.currency = currency } /** The customer the alert applies to. */ - fun customer(customer: Customer?) = customer(JsonField.ofNullable(customer)) + fun customer(customer: CustomerMinifiedModel?) = customer(JsonField.ofNullable(customer)) /** The customer the alert applies to. */ - fun customer(customer: Optional) = customer(customer.orElse(null)) + fun customer(customer: Optional) = customer(customer.orElse(null)) /** The customer the alert applies to. */ - fun customer(customer: JsonField) = apply { this.customer = customer } + fun customer(customer: JsonField) = apply { + this.customer = customer + } /** Whether the alert is enabled or disabled. */ fun enabled(enabled: Boolean) = enabled(JsonField.of(enabled)) @@ -241,40 +264,36 @@ private constructor( fun plan(plan: JsonField) = apply { this.plan = plan } /** The subscription the alert applies to. */ - fun subscription(subscription: Subscription?) = + fun subscription(subscription: SubscriptionMinifiedModel?) = subscription(JsonField.ofNullable(subscription)) /** The subscription the alert applies to. */ - fun subscription(subscription: Optional) = + fun subscription(subscription: Optional) = subscription(subscription.orElse(null)) /** The subscription the alert applies to. */ - fun subscription(subscription: JsonField) = apply { + fun subscription(subscription: JsonField) = apply { this.subscription = subscription } /** The thresholds that define the conditions under which the alert will be triggered. */ - fun thresholds(thresholds: List?) = thresholds(JsonField.ofNullable(thresholds)) + fun thresholds(thresholds: List?) = + thresholds(JsonField.ofNullable(thresholds)) /** The thresholds that define the conditions under which the alert will be triggered. */ - fun thresholds(thresholds: Optional>) = thresholds(thresholds.orElse(null)) + fun thresholds(thresholds: Optional>) = + thresholds(thresholds.orElse(null)) /** The thresholds that define the conditions under which the alert will be triggered. */ - fun thresholds(thresholds: JsonField>) = apply { + fun thresholds(thresholds: JsonField>) = apply { this.thresholds = thresholds.map { it.toMutableList() } } /** The thresholds that define the conditions under which the alert will be triggered. */ - fun addThreshold(threshold: Threshold) = apply { + fun addThreshold(threshold: ThresholdModel) = apply { thresholds = - (thresholds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(threshold) + (thresholds ?: JsonField.of(mutableListOf())).also { + checkKnown("thresholds", it).add(threshold) } } @@ -319,126 +338,6 @@ private constructor( ) } - /** The customer the alert applies to. */ - @NoAutoDetect - class Customer - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("external_customer_id") - @ExcludeMissing - private val externalCustomerId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun externalCustomerId(): Optional = - Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("external_customer_id") - @ExcludeMissing - fun _externalCustomerId(): JsonField = externalCustomerId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Customer = apply { - if (validated) { - return@apply - } - - id() - externalCustomerId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Customer]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var externalCustomerId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customer: Customer) = apply { - id = customer.id - externalCustomerId = customer.externalCustomerId - additionalProperties = customer.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun externalCustomerId(externalCustomerId: String?) = - externalCustomerId(JsonField.ofNullable(externalCustomerId)) - - fun externalCustomerId(externalCustomerId: Optional) = - externalCustomerId(externalCustomerId.orElse(null)) - - fun externalCustomerId(externalCustomerId: JsonField) = apply { - this.externalCustomerId = externalCustomerId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Customer = - Customer( - checkRequired("id", id), - checkRequired("externalCustomerId", externalCustomerId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Customer && id == other.id && externalCustomerId == other.externalCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, externalCustomerId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Customer{id=$id, externalCustomerId=$externalCustomerId, additionalProperties=$additionalProperties}" - } - /** The metric the alert applies to. */ @NoAutoDetect class Metric @@ -472,6 +371,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Metric]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -603,6 +510,17 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Plan]. + * + * The following fields are required: + * ```java + * .id() + * .externalPlanId() + * .name() + * .planVersion() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -714,213 +632,6 @@ private constructor( "Plan{id=$id, externalPlanId=$externalPlanId, name=$name, planVersion=$planVersion, additionalProperties=$additionalProperties}" } - /** The subscription the alert applies to. */ - @NoAutoDetect - class Subscription - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Subscription = apply { - if (validated) { - return@apply - } - - id() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Subscription]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(subscription: Subscription) = apply { - id = subscription.id - additionalProperties = subscription.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - 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) - } - - fun build(): Subscription = - Subscription(checkRequired("id", id), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Subscription && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Subscription{id=$id, additionalProperties=$additionalProperties}" - } - - /** Thresholds are used to define the conditions under which an alert will be triggered. */ - @NoAutoDetect - class Threshold - @JsonCreator - private constructor( - @JsonProperty("value") - @ExcludeMissing - private val value: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * The value at which an alert will fire. For credit balance alerts, the alert will fire at - * or below this value. For usage and cost alerts, the alert will fire at or above this - * value. - */ - fun value(): Double = value.getRequired("value") - - /** - * The value at which an alert will fire. For credit balance alerts, the alert will fire at - * or below this value. For usage and cost alerts, the alert will fire at or above this - * value. - */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Threshold = apply { - if (validated) { - return@apply - } - - value() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Threshold]. */ - class Builder internal constructor() { - - private var value: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(threshold: Threshold) = apply { - value = threshold.value - additionalProperties = threshold.additionalProperties.toMutableMap() - } - - /** - * The value at which an alert will fire. For credit balance alerts, the alert will fire - * at or below this value. For usage and cost alerts, the alert will fire at or above - * this value. - */ - fun value(value: Double) = value(JsonField.of(value)) - - /** - * The value at which an alert will fire. For credit balance alerts, the alert will fire - * at or below this value. For usage and cost alerts, the alert will fire at or above - * this value. - */ - fun value(value: JsonField) = apply { this.value = 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) - } - - fun build(): Threshold = - Threshold(checkRequired("value", value), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Threshold && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(value, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Threshold{value=$value, additionalProperties=$additionalProperties}" - } - /** The type of alert. This must be a valid alert type. */ class Type @JsonCreator private constructor(private val value: JsonField) : Enum { 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 746d8a22d..74664b59b 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 @@ -2,25 +2,13 @@ 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.NoAutoDetect 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.immutableEmptyMap -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException import java.util.Objects -import java.util.Optional /** * This endpoint creates a new alert to monitor a customer's credit balance. There are three types @@ -33,38 +21,23 @@ import java.util.Optional class AlertCreateForCustomerParams private constructor( private val customerId: String, - private val body: Body, + private val createCustomerAlertRequest: CreateCustomerAlertRequest, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { fun customerId(): String = customerId - /** The case sensitive currency or custom pricing unit to use for this alert. */ - fun currency(): String = body.currency() + fun createCustomerAlertRequest(): CreateCustomerAlertRequest = createCustomerAlertRequest - /** The type of alert to create. This must be a valid alert type. */ - fun type(): Type = body.type() - - /** The thresholds that define the values at which the alert will be triggered. */ - fun thresholds(): Optional> = body.thresholds() - - /** The case sensitive currency or custom pricing unit to use for this alert. */ - fun _currency(): JsonField = body._currency() - - /** The type of alert to create. This must be a valid alert type. */ - fun _type(): JsonField = body._type() - - /** The thresholds that define the values at which the alert will be triggered. */ - fun _thresholds(): JsonField> = body._thresholds() - - fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalBodyProperties(): Map = + createCustomerAlertRequest._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): CreateCustomerAlertRequest = createCustomerAlertRequest override fun _headers(): Headers = additionalHeaders @@ -77,171 +50,19 @@ private constructor( } } - @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonProperty("thresholds") - @ExcludeMissing - private val thresholds: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The case sensitive currency or custom pricing unit to use for this alert. */ - fun currency(): String = currency.getRequired("currency") - - /** The type of alert to create. This must be a valid alert type. */ - fun type(): Type = type.getRequired("type") - - /** The thresholds that define the values at which the alert will be triggered. */ - fun thresholds(): Optional> = - Optional.ofNullable(thresholds.getNullable("thresholds")) - - /** The case sensitive currency or custom pricing unit to use for this alert. */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** The type of alert to create. This must be a valid alert type. */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - /** The thresholds that define the values at which the alert will be triggered. */ - @JsonProperty("thresholds") - @ExcludeMissing - fun _thresholds(): JsonField> = thresholds - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - currency() - type() - thresholds().ifPresent { it.forEach { it.validate() } } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var currency: JsonField? = null - private var type: JsonField? = null - private var thresholds: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - currency = body.currency - type = body.type - thresholds = body.thresholds.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } - - /** The case sensitive currency or custom pricing unit to use for this alert. */ - fun currency(currency: String) = currency(JsonField.of(currency)) - - /** The case sensitive currency or custom pricing unit to use for this alert. */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** The type of alert to create. This must be a valid alert type. */ - fun type(type: Type) = type(JsonField.of(type)) - - /** The type of alert to create. This must be a valid alert type. */ - fun type(type: JsonField) = apply { this.type = type } - - /** The thresholds that define the values at which the alert will be triggered. */ - fun thresholds(thresholds: List?) = - thresholds(JsonField.ofNullable(thresholds)) - - /** The thresholds that define the values at which the alert will be triggered. */ - fun thresholds(thresholds: Optional>) = - thresholds(thresholds.orElse(null)) - - /** The thresholds that define the values at which the alert will be triggered. */ - fun thresholds(thresholds: JsonField>) = apply { - this.thresholds = thresholds.map { it.toMutableList() } - } - - /** The thresholds that define the values at which the alert will be triggered. */ - fun addThreshold(threshold: Threshold) = apply { - thresholds = - (thresholds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): Body = - Body( - checkRequired("currency", currency), - checkRequired("type", type), - (thresholds ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Body && currency == other.currency && type == other.type && thresholds == other.thresholds && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(currency, type, thresholds, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{currency=$currency, type=$type, thresholds=$thresholds, additionalProperties=$additionalProperties}" - } - fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of [AlertCreateForCustomerParams]. + * + * The following fields are required: + * ```java + * .customerId() + * .createCustomerAlertRequest() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -250,65 +71,25 @@ private constructor( class Builder internal constructor() { private var customerId: String? = null - private var body: Body.Builder = Body.builder() + private var createCustomerAlertRequest: CreateCustomerAlertRequest? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(alertCreateForCustomerParams: AlertCreateForCustomerParams) = apply { customerId = alertCreateForCustomerParams.customerId - body = alertCreateForCustomerParams.body.toBuilder() + createCustomerAlertRequest = alertCreateForCustomerParams.createCustomerAlertRequest additionalHeaders = alertCreateForCustomerParams.additionalHeaders.toBuilder() additionalQueryParams = alertCreateForCustomerParams.additionalQueryParams.toBuilder() } fun customerId(customerId: String) = apply { this.customerId = customerId } - /** The case sensitive currency or custom pricing unit to use for this alert. */ - fun currency(currency: String) = apply { body.currency(currency) } - - /** The case sensitive currency or custom pricing unit to use for this alert. */ - fun currency(currency: JsonField) = apply { body.currency(currency) } - - /** The type of alert to create. This must be a valid alert type. */ - fun type(type: Type) = apply { body.type(type) } - - /** The type of alert to create. This must be a valid alert type. */ - fun type(type: JsonField) = apply { body.type(type) } - - /** The thresholds that define the values at which the alert will be triggered. */ - fun thresholds(thresholds: List?) = apply { body.thresholds(thresholds) } - - /** The thresholds that define the values at which the alert will be triggered. */ - fun thresholds(thresholds: Optional>) = thresholds(thresholds.orElse(null)) - - /** The thresholds that define the values at which the alert will be triggered. */ - fun thresholds(thresholds: JsonField>) = apply { - body.thresholds(thresholds) - } - - /** The thresholds that define the values at which the alert will be triggered. */ - fun addThreshold(threshold: Threshold) = apply { body.addThreshold(threshold) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + fun createCustomerAlertRequest(createCustomerAlertRequest: CreateCustomerAlertRequest) = apply { - body.putAllAdditionalProperties(additionalBodyProperties) + this.createCustomerAlertRequest = createCustomerAlertRequest } - 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) @@ -410,253 +191,22 @@ private constructor( fun build(): AlertCreateForCustomerParams = AlertCreateForCustomerParams( checkRequired("customerId", customerId), - body.build(), + checkRequired("createCustomerAlertRequest", createCustomerAlertRequest), additionalHeaders.build(), additionalQueryParams.build(), ) } - /** The type of alert to create. This must be a valid alert type. */ - 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 USAGE_EXCEEDED = of("usage_exceeded") - - @JvmField val COST_EXCEEDED = of("cost_exceeded") - - @JvmField val CREDIT_BALANCE_DEPLETED = of("credit_balance_depleted") - - @JvmField val CREDIT_BALANCE_DROPPED = of("credit_balance_dropped") - - @JvmField val CREDIT_BALANCE_RECOVERED = of("credit_balance_recovered") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - USAGE_EXCEEDED, - COST_EXCEEDED, - CREDIT_BALANCE_DEPLETED, - CREDIT_BALANCE_DROPPED, - CREDIT_BALANCE_RECOVERED, - } - - /** - * 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 { - USAGE_EXCEEDED, - COST_EXCEEDED, - CREDIT_BALANCE_DEPLETED, - CREDIT_BALANCE_DROPPED, - CREDIT_BALANCE_RECOVERED, - /** 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) { - USAGE_EXCEEDED -> Value.USAGE_EXCEEDED - COST_EXCEEDED -> Value.COST_EXCEEDED - CREDIT_BALANCE_DEPLETED -> Value.CREDIT_BALANCE_DEPLETED - CREDIT_BALANCE_DROPPED -> Value.CREDIT_BALANCE_DROPPED - CREDIT_BALANCE_RECOVERED -> Value.CREDIT_BALANCE_RECOVERED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to 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_EXCEEDED -> Known.USAGE_EXCEEDED - COST_EXCEEDED -> Known.COST_EXCEEDED - CREDIT_BALANCE_DEPLETED -> Known.CREDIT_BALANCE_DEPLETED - CREDIT_BALANCE_DROPPED -> Known.CREDIT_BALANCE_DROPPED - CREDIT_BALANCE_RECOVERED -> Known.CREDIT_BALANCE_RECOVERED - 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Thresholds are used to define the conditions under which an alert will be triggered. */ - @NoAutoDetect - class Threshold - @JsonCreator - private constructor( - @JsonProperty("value") - @ExcludeMissing - private val value: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * The value at which an alert will fire. For credit balance alerts, the alert will fire at - * or below this value. For usage and cost alerts, the alert will fire at or above this - * value. - */ - fun value(): Double = value.getRequired("value") - - /** - * The value at which an alert will fire. For credit balance alerts, the alert will fire at - * or below this value. For usage and cost alerts, the alert will fire at or above this - * value. - */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Threshold = apply { - if (validated) { - return@apply - } - - value() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Threshold]. */ - class Builder internal constructor() { - - private var value: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(threshold: Threshold) = apply { - value = threshold.value - additionalProperties = threshold.additionalProperties.toMutableMap() - } - - /** - * The value at which an alert will fire. For credit balance alerts, the alert will fire - * at or below this value. For usage and cost alerts, the alert will fire at or above - * this value. - */ - fun value(value: Double) = value(JsonField.of(value)) - - /** - * The value at which an alert will fire. For credit balance alerts, the alert will fire - * at or below this value. For usage and cost alerts, the alert will fire at or above - * this value. - */ - fun value(value: JsonField) = apply { this.value = 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) - } - - fun build(): Threshold = - Threshold(checkRequired("value", value), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Threshold && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(value, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Threshold{value=$value, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is AlertCreateForCustomerParams && customerId == other.customerId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is AlertCreateForCustomerParams && customerId == other.customerId && createCustomerAlertRequest == other.createCustomerAlertRequest && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(customerId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(customerId, createCustomerAlertRequest, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "AlertCreateForCustomerParams{customerId=$customerId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "AlertCreateForCustomerParams{customerId=$customerId, createCustomerAlertRequest=$createCustomerAlertRequest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForExternalCustomerParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForExternalCustomerParams.kt index 66b4981b8..61b4583b8 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 @@ -2,25 +2,13 @@ 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.NoAutoDetect 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.immutableEmptyMap -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException import java.util.Objects -import java.util.Optional /** * This endpoint creates a new alert to monitor a customer's credit balance. There are three types @@ -33,38 +21,23 @@ import java.util.Optional class AlertCreateForExternalCustomerParams private constructor( private val externalCustomerId: String, - private val body: Body, + private val createCustomerAlertRequest: CreateCustomerAlertRequest, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { fun externalCustomerId(): String = externalCustomerId - /** The case sensitive currency or custom pricing unit to use for this alert. */ - fun currency(): String = body.currency() + fun createCustomerAlertRequest(): CreateCustomerAlertRequest = createCustomerAlertRequest - /** The type of alert to create. This must be a valid alert type. */ - fun type(): Type = body.type() - - /** The thresholds that define the values at which the alert will be triggered. */ - fun thresholds(): Optional> = body.thresholds() - - /** The case sensitive currency or custom pricing unit to use for this alert. */ - fun _currency(): JsonField = body._currency() - - /** The type of alert to create. This must be a valid alert type. */ - fun _type(): JsonField = body._type() - - /** The thresholds that define the values at which the alert will be triggered. */ - fun _thresholds(): JsonField> = body._thresholds() - - fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalBodyProperties(): Map = + createCustomerAlertRequest._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): CreateCustomerAlertRequest = createCustomerAlertRequest override fun _headers(): Headers = additionalHeaders @@ -77,171 +50,20 @@ private constructor( } } - @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonProperty("thresholds") - @ExcludeMissing - private val thresholds: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The case sensitive currency or custom pricing unit to use for this alert. */ - fun currency(): String = currency.getRequired("currency") - - /** The type of alert to create. This must be a valid alert type. */ - fun type(): Type = type.getRequired("type") - - /** The thresholds that define the values at which the alert will be triggered. */ - fun thresholds(): Optional> = - Optional.ofNullable(thresholds.getNullable("thresholds")) - - /** The case sensitive currency or custom pricing unit to use for this alert. */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** The type of alert to create. This must be a valid alert type. */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - /** The thresholds that define the values at which the alert will be triggered. */ - @JsonProperty("thresholds") - @ExcludeMissing - fun _thresholds(): JsonField> = thresholds - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - currency() - type() - thresholds().ifPresent { it.forEach { it.validate() } } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var currency: JsonField? = null - private var type: JsonField? = null - private var thresholds: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - currency = body.currency - type = body.type - thresholds = body.thresholds.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } - - /** The case sensitive currency or custom pricing unit to use for this alert. */ - fun currency(currency: String) = currency(JsonField.of(currency)) - - /** The case sensitive currency or custom pricing unit to use for this alert. */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** The type of alert to create. This must be a valid alert type. */ - fun type(type: Type) = type(JsonField.of(type)) - - /** The type of alert to create. This must be a valid alert type. */ - fun type(type: JsonField) = apply { this.type = type } - - /** The thresholds that define the values at which the alert will be triggered. */ - fun thresholds(thresholds: List?) = - thresholds(JsonField.ofNullable(thresholds)) - - /** The thresholds that define the values at which the alert will be triggered. */ - fun thresholds(thresholds: Optional>) = - thresholds(thresholds.orElse(null)) - - /** The thresholds that define the values at which the alert will be triggered. */ - fun thresholds(thresholds: JsonField>) = apply { - this.thresholds = thresholds.map { it.toMutableList() } - } - - /** The thresholds that define the values at which the alert will be triggered. */ - fun addThreshold(threshold: Threshold) = apply { - thresholds = - (thresholds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): Body = - Body( - checkRequired("currency", currency), - checkRequired("type", type), - (thresholds ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Body && currency == other.currency && type == other.type && thresholds == other.thresholds && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(currency, type, thresholds, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{currency=$currency, type=$type, thresholds=$thresholds, additionalProperties=$additionalProperties}" - } - fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of + * [AlertCreateForExternalCustomerParams]. + * + * The following fields are required: + * ```java + * .externalCustomerId() + * .createCustomerAlertRequest() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -250,7 +72,7 @@ private constructor( class Builder internal constructor() { private var externalCustomerId: String? = null - private var body: Body.Builder = Body.builder() + private var createCustomerAlertRequest: CreateCustomerAlertRequest? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -259,7 +81,8 @@ private constructor( alertCreateForExternalCustomerParams: AlertCreateForExternalCustomerParams ) = apply { externalCustomerId = alertCreateForExternalCustomerParams.externalCustomerId - body = alertCreateForExternalCustomerParams.body.toBuilder() + createCustomerAlertRequest = + alertCreateForExternalCustomerParams.createCustomerAlertRequest additionalHeaders = alertCreateForExternalCustomerParams.additionalHeaders.toBuilder() additionalQueryParams = alertCreateForExternalCustomerParams.additionalQueryParams.toBuilder() @@ -269,51 +92,11 @@ private constructor( this.externalCustomerId = externalCustomerId } - /** The case sensitive currency or custom pricing unit to use for this alert. */ - fun currency(currency: String) = apply { body.currency(currency) } - - /** The case sensitive currency or custom pricing unit to use for this alert. */ - fun currency(currency: JsonField) = apply { body.currency(currency) } - - /** The type of alert to create. This must be a valid alert type. */ - fun type(type: Type) = apply { body.type(type) } - - /** The type of alert to create. This must be a valid alert type. */ - fun type(type: JsonField) = apply { body.type(type) } - - /** The thresholds that define the values at which the alert will be triggered. */ - fun thresholds(thresholds: List?) = apply { body.thresholds(thresholds) } - - /** The thresholds that define the values at which the alert will be triggered. */ - fun thresholds(thresholds: Optional>) = thresholds(thresholds.orElse(null)) - - /** The thresholds that define the values at which the alert will be triggered. */ - fun thresholds(thresholds: JsonField>) = apply { - body.thresholds(thresholds) - } - - /** The thresholds that define the values at which the alert will be triggered. */ - fun addThreshold(threshold: Threshold) = apply { body.addThreshold(threshold) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + fun createCustomerAlertRequest(createCustomerAlertRequest: CreateCustomerAlertRequest) = apply { - body.putAllAdditionalProperties(additionalBodyProperties) + this.createCustomerAlertRequest = createCustomerAlertRequest } - 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) @@ -415,253 +198,22 @@ private constructor( fun build(): AlertCreateForExternalCustomerParams = AlertCreateForExternalCustomerParams( checkRequired("externalCustomerId", externalCustomerId), - body.build(), + checkRequired("createCustomerAlertRequest", createCustomerAlertRequest), additionalHeaders.build(), additionalQueryParams.build(), ) } - /** The type of alert to create. This must be a valid alert type. */ - 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 USAGE_EXCEEDED = of("usage_exceeded") - - @JvmField val COST_EXCEEDED = of("cost_exceeded") - - @JvmField val CREDIT_BALANCE_DEPLETED = of("credit_balance_depleted") - - @JvmField val CREDIT_BALANCE_DROPPED = of("credit_balance_dropped") - - @JvmField val CREDIT_BALANCE_RECOVERED = of("credit_balance_recovered") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - USAGE_EXCEEDED, - COST_EXCEEDED, - CREDIT_BALANCE_DEPLETED, - CREDIT_BALANCE_DROPPED, - CREDIT_BALANCE_RECOVERED, - } - - /** - * 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 { - USAGE_EXCEEDED, - COST_EXCEEDED, - CREDIT_BALANCE_DEPLETED, - CREDIT_BALANCE_DROPPED, - CREDIT_BALANCE_RECOVERED, - /** 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) { - USAGE_EXCEEDED -> Value.USAGE_EXCEEDED - COST_EXCEEDED -> Value.COST_EXCEEDED - CREDIT_BALANCE_DEPLETED -> Value.CREDIT_BALANCE_DEPLETED - CREDIT_BALANCE_DROPPED -> Value.CREDIT_BALANCE_DROPPED - CREDIT_BALANCE_RECOVERED -> Value.CREDIT_BALANCE_RECOVERED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to 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_EXCEEDED -> Known.USAGE_EXCEEDED - COST_EXCEEDED -> Known.COST_EXCEEDED - CREDIT_BALANCE_DEPLETED -> Known.CREDIT_BALANCE_DEPLETED - CREDIT_BALANCE_DROPPED -> Known.CREDIT_BALANCE_DROPPED - CREDIT_BALANCE_RECOVERED -> Known.CREDIT_BALANCE_RECOVERED - 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Thresholds are used to define the conditions under which an alert will be triggered. */ - @NoAutoDetect - class Threshold - @JsonCreator - private constructor( - @JsonProperty("value") - @ExcludeMissing - private val value: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * The value at which an alert will fire. For credit balance alerts, the alert will fire at - * or below this value. For usage and cost alerts, the alert will fire at or above this - * value. - */ - fun value(): Double = value.getRequired("value") - - /** - * The value at which an alert will fire. For credit balance alerts, the alert will fire at - * or below this value. For usage and cost alerts, the alert will fire at or above this - * value. - */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Threshold = apply { - if (validated) { - return@apply - } - - value() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Threshold]. */ - class Builder internal constructor() { - - private var value: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(threshold: Threshold) = apply { - value = threshold.value - additionalProperties = threshold.additionalProperties.toMutableMap() - } - - /** - * The value at which an alert will fire. For credit balance alerts, the alert will fire - * at or below this value. For usage and cost alerts, the alert will fire at or above - * this value. - */ - fun value(value: Double) = value(JsonField.of(value)) - - /** - * The value at which an alert will fire. For credit balance alerts, the alert will fire - * at or below this value. For usage and cost alerts, the alert will fire at or above - * this value. - */ - fun value(value: JsonField) = apply { this.value = 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) - } - - fun build(): Threshold = - Threshold(checkRequired("value", value), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Threshold && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(value, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Threshold{value=$value, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is AlertCreateForExternalCustomerParams && externalCustomerId == other.externalCustomerId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is AlertCreateForExternalCustomerParams && externalCustomerId == other.externalCustomerId && createCustomerAlertRequest == other.createCustomerAlertRequest && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(externalCustomerId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(externalCustomerId, createCustomerAlertRequest, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "AlertCreateForExternalCustomerParams{externalCustomerId=$externalCustomerId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "AlertCreateForExternalCustomerParams{externalCustomerId=$externalCustomerId, createCustomerAlertRequest=$createCustomerAlertRequest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParams.kt index aaceb6a54..ca91a8cda 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 @@ -13,6 +13,7 @@ import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.Params +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams @@ -45,7 +46,7 @@ private constructor( fun subscriptionId(): String = subscriptionId /** The thresholds that define the values at which the alert will be triggered. */ - fun thresholds(): List = body.thresholds() + fun thresholds(): List = body.thresholds() /** The type of alert to create. This must be a valid alert type. */ fun type(): Type = body.type() @@ -54,7 +55,7 @@ private constructor( fun metricId(): Optional = body.metricId() /** The thresholds that define the values at which the alert will be triggered. */ - fun _thresholds(): JsonField> = body._thresholds() + fun _thresholds(): JsonField> = body._thresholds() /** The type of alert to create. This must be a valid alert type. */ fun _type(): JsonField = body._type() @@ -87,7 +88,7 @@ private constructor( private constructor( @JsonProperty("thresholds") @ExcludeMissing - private val thresholds: JsonField> = JsonMissing.of(), + private val thresholds: JsonField> = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), @JsonProperty("metric_id") @ExcludeMissing @@ -97,7 +98,7 @@ private constructor( ) { /** The thresholds that define the values at which the alert will be triggered. */ - fun thresholds(): List = thresholds.getRequired("thresholds") + fun thresholds(): List = thresholds.getRequired("thresholds") /** The type of alert to create. This must be a valid alert type. */ fun type(): Type = type.getRequired("type") @@ -108,7 +109,7 @@ private constructor( /** The thresholds that define the values at which the alert will be triggered. */ @JsonProperty("thresholds") @ExcludeMissing - fun _thresholds(): JsonField> = thresholds + fun _thresholds(): JsonField> = thresholds /** The type of alert to create. This must be a valid alert type. */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @@ -137,13 +138,22 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .thresholds() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ class Builder internal constructor() { - private var thresholds: JsonField>? = null + private var thresholds: JsonField>? = null private var type: JsonField? = null private var metricId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -157,24 +167,18 @@ private constructor( } /** The thresholds that define the values at which the alert will be triggered. */ - fun thresholds(thresholds: List) = thresholds(JsonField.of(thresholds)) + fun thresholds(thresholds: List) = thresholds(JsonField.of(thresholds)) /** The thresholds that define the values at which the alert will be triggered. */ - fun thresholds(thresholds: JsonField>) = apply { + fun thresholds(thresholds: JsonField>) = apply { this.thresholds = thresholds.map { it.toMutableList() } } /** The thresholds that define the values at which the alert will be triggered. */ - fun addThreshold(threshold: Threshold) = apply { + fun addThreshold(threshold: ThresholdModel) = apply { thresholds = - (thresholds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(threshold) + (thresholds ?: JsonField.of(mutableListOf())).also { + checkKnown("thresholds", it).add(threshold) } } @@ -243,6 +247,17 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [AlertCreateForSubscriptionParams]. + * + * The following fields are required: + * ```java + * .subscriptionId() + * .thresholds() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -268,15 +283,15 @@ private constructor( fun subscriptionId(subscriptionId: String) = apply { this.subscriptionId = subscriptionId } /** The thresholds that define the values at which the alert will be triggered. */ - fun thresholds(thresholds: List) = apply { body.thresholds(thresholds) } + fun thresholds(thresholds: List) = apply { body.thresholds(thresholds) } /** The thresholds that define the values at which the alert will be triggered. */ - fun thresholds(thresholds: JsonField>) = apply { + fun thresholds(thresholds: JsonField>) = apply { body.thresholds(thresholds) } /** The thresholds that define the values at which the alert will be triggered. */ - fun addThreshold(threshold: Threshold) = apply { body.addThreshold(threshold) } + fun addThreshold(threshold: ThresholdModel) = apply { body.addThreshold(threshold) } /** The type of alert to create. This must be a valid alert type. */ fun type(type: Type) = apply { body.type(type) } @@ -419,121 +434,6 @@ private constructor( ) } - /** Thresholds are used to define the conditions under which an alert will be triggered. */ - @NoAutoDetect - class Threshold - @JsonCreator - private constructor( - @JsonProperty("value") - @ExcludeMissing - private val value: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * The value at which an alert will fire. For credit balance alerts, the alert will fire at - * or below this value. For usage and cost alerts, the alert will fire at or above this - * value. - */ - fun value(): Double = value.getRequired("value") - - /** - * The value at which an alert will fire. For credit balance alerts, the alert will fire at - * or below this value. For usage and cost alerts, the alert will fire at or above this - * value. - */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Threshold = apply { - if (validated) { - return@apply - } - - value() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Threshold]. */ - class Builder internal constructor() { - - private var value: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(threshold: Threshold) = apply { - value = threshold.value - additionalProperties = threshold.additionalProperties.toMutableMap() - } - - /** - * The value at which an alert will fire. For credit balance alerts, the alert will fire - * at or below this value. For usage and cost alerts, the alert will fire at or above - * this value. - */ - fun value(value: Double) = value(JsonField.of(value)) - - /** - * The value at which an alert will fire. For credit balance alerts, the alert will fire - * at or below this value. For usage and cost alerts, the alert will fire at or above - * this value. - */ - fun value(value: JsonField) = apply { this.value = 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) - } - - fun build(): Threshold = - Threshold(checkRequired("value", value), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Threshold && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(value, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Threshold{value=$value, additionalProperties=$additionalProperties}" - } - /** The type of alert to create. This must be a valid alert type. */ class Type @JsonCreator private constructor(private val value: JsonField) : Enum { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertDisableParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertDisableParams.kt index a96e969e5..548ba857c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertDisableParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertDisableParams.kt @@ -61,6 +61,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [AlertDisableParams]. + * + * The following fields are required: + * ```java + * .alertConfigurationId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertEnableParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertEnableParams.kt index f4af9ee32..c73bf5676 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertEnableParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertEnableParams.kt @@ -61,6 +61,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [AlertEnableParams]. + * + * The following fields are required: + * ```java + * .alertConfigurationId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPage.kt index 8b7674a3c..487d4c1b9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPage.kt @@ -39,7 +39,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -94,20 +94,20 @@ private constructor( class Response @JsonCreator constructor( - @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), + @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = Optional.ofNullable(data) + fun _data(): Optional>> = Optional.ofNullable(data) @JsonProperty("pagination_metadata") fun _paginationMetadata(): Optional> = @@ -146,12 +146,13 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [AlertListPage]. */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -162,9 +163,9 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { this.data = data } fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) @@ -181,9 +182,9 @@ private constructor( } } - class AutoPager(private val firstPage: AlertListPage) : Iterable { + class AutoPager(private val firstPage: AlertListPage) : Iterable { - override fun iterator(): Iterator = iterator { + override fun iterator(): Iterator = iterator { var page = firstPage var index = 0 while (true) { @@ -195,7 +196,7 @@ private constructor( } } - fun stream(): Stream { + fun stream(): Stream { return StreamSupport.stream(spliterator(), false) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPageAsync.kt index 8d9ba767b..758ca1fcc 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListPageAsync.kt @@ -40,7 +40,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -97,20 +97,20 @@ private constructor( class Response @JsonCreator constructor( - @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), + @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = Optional.ofNullable(data) + fun _data(): Optional>> = Optional.ofNullable(data) @JsonProperty("pagination_metadata") fun _paginationMetadata(): Optional> = @@ -149,12 +149,13 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [AlertListPageAsync]. */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -165,9 +166,9 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { this.data = data } fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) @@ -186,9 +187,9 @@ private constructor( class AutoPager(private val firstPage: AlertListPageAsync) { - fun forEach(action: Predicate, executor: Executor): CompletableFuture { + fun forEach(action: Predicate, executor: Executor): CompletableFuture { fun CompletableFuture>.forEach( - action: (Alert) -> Boolean, + action: (AlertModel) -> Boolean, executor: Executor, ): CompletableFuture = thenComposeAsync( @@ -204,8 +205,8 @@ private constructor( .forEach(action::test, executor) } - fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() + fun toList(executor: Executor): CompletableFuture> { + val values = mutableListOf() return forEach(values::add, executor).thenApply { values } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListParams.kt index 30d4da29e..cbde92a07 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListParams.kt @@ -112,6 +112,7 @@ private constructor( @JvmStatic fun none(): AlertListParams = builder().build() + /** Returns a mutable builder for constructing an instance of [AlertListParams]. */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertModel.kt new file mode 100644 index 000000000..728c77d86 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertModel.kt @@ -0,0 +1,767 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +/** + * [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. + */ +@NoAutoDetect +class AlertModel +@JsonCreator +private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("customer") + @ExcludeMissing + private val customer: JsonField = JsonMissing.of(), + @JsonProperty("enabled") + @ExcludeMissing + private val enabled: JsonField = JsonMissing.of(), + @JsonProperty("metric") + @ExcludeMissing + private val metric: JsonField = JsonMissing.of(), + @JsonProperty("plan") @ExcludeMissing private val plan: JsonField = JsonMissing.of(), + @JsonProperty("subscription") + @ExcludeMissing + private val subscription: JsonField = JsonMissing.of(), + @JsonProperty("thresholds") + @ExcludeMissing + private val thresholds: JsonField> = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** Also referred to as alert_id in this documentation. */ + fun id(): String = id.getRequired("id") + + /** The creation time of the resource in Orb. */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** The name of the currency the credit balance or invoice cost is denominated in. */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** The customer the alert applies to. */ + fun customer(): Optional = + Optional.ofNullable(customer.getNullable("customer")) + + /** Whether the alert is enabled or disabled. */ + fun enabled(): Boolean = enabled.getRequired("enabled") + + /** The metric the alert applies to. */ + fun metric(): Optional = Optional.ofNullable(metric.getNullable("metric")) + + /** The plan the alert applies to. */ + fun plan(): Optional = Optional.ofNullable(plan.getNullable("plan")) + + /** The subscription the alert applies to. */ + fun subscription(): Optional = + Optional.ofNullable(subscription.getNullable("subscription")) + + /** The thresholds that define the conditions under which the alert will be triggered. */ + fun thresholds(): Optional> = + Optional.ofNullable(thresholds.getNullable("thresholds")) + + /** The type of alert. This must be a valid alert type. */ + fun type(): Type = type.getRequired("type") + + /** Also referred to as alert_id in this documentation. */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** The creation time of the resource in Orb. */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** The name of the currency the credit balance or invoice cost is denominated in. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** The customer the alert applies to. */ + @JsonProperty("customer") + @ExcludeMissing + fun _customer(): JsonField = customer + + /** Whether the alert is enabled or disabled. */ + @JsonProperty("enabled") @ExcludeMissing fun _enabled(): JsonField = enabled + + /** The metric the alert applies to. */ + @JsonProperty("metric") @ExcludeMissing fun _metric(): JsonField = metric + + /** The plan the alert applies to. */ + @JsonProperty("plan") @ExcludeMissing fun _plan(): JsonField = plan + + /** The subscription the alert applies to. */ + @JsonProperty("subscription") + @ExcludeMissing + fun _subscription(): JsonField = subscription + + /** The thresholds that define the conditions under which the alert will be triggered. */ + @JsonProperty("thresholds") + @ExcludeMissing + fun _thresholds(): JsonField> = thresholds + + /** The type of alert. This must be a valid alert type. */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): AlertModel = apply { + if (validated) { + return@apply + } + + id() + createdAt() + currency() + customer().ifPresent { it.validate() } + enabled() + metric().ifPresent { it.validate() } + plan().ifPresent { it.validate() } + subscription().ifPresent { it.validate() } + thresholds().ifPresent { it.forEach { it.validate() } } + type() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AlertModel]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .currency() + * .customer() + * .enabled() + * .metric() + * .plan() + * .subscription() + * .thresholds() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AlertModel]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var createdAt: JsonField? = null + private var currency: JsonField? = null + private var customer: JsonField? = null + private var enabled: JsonField? = null + private var metric: JsonField? = null + private var plan: JsonField? = null + private var subscription: JsonField? = null + private var thresholds: JsonField>? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(alertModel: AlertModel) = apply { + id = alertModel.id + createdAt = alertModel.createdAt + currency = alertModel.currency + customer = alertModel.customer + enabled = alertModel.enabled + metric = alertModel.metric + plan = alertModel.plan + subscription = alertModel.subscription + thresholds = alertModel.thresholds.map { it.toMutableList() } + type = alertModel.type + additionalProperties = alertModel.additionalProperties.toMutableMap() + } + + /** Also referred to as alert_id in this documentation. */ + fun id(id: String) = id(JsonField.of(id)) + + /** Also referred to as alert_id in this documentation. */ + fun id(id: JsonField) = apply { this.id = id } + + /** The creation time of the resource in Orb. */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** The creation time of the resource in Orb. */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + /** The name of the currency the credit balance or invoice cost is denominated in. */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** The name of the currency the credit balance or invoice cost is denominated in. */ + fun currency(currency: Optional) = currency(currency.orElse(null)) + + /** The name of the currency the credit balance or invoice cost is denominated in. */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The customer the alert applies to. */ + fun customer(customer: CustomerMinifiedModel?) = customer(JsonField.ofNullable(customer)) + + /** The customer the alert applies to. */ + fun customer(customer: Optional) = customer(customer.orElse(null)) + + /** The customer the alert applies to. */ + fun customer(customer: JsonField) = apply { + this.customer = customer + } + + /** Whether the alert is enabled or disabled. */ + fun enabled(enabled: Boolean) = enabled(JsonField.of(enabled)) + + /** Whether the alert is enabled or disabled. */ + fun enabled(enabled: JsonField) = apply { this.enabled = enabled } + + /** The metric the alert applies to. */ + fun metric(metric: Metric?) = metric(JsonField.ofNullable(metric)) + + /** The metric the alert applies to. */ + fun metric(metric: Optional) = metric(metric.orElse(null)) + + /** The metric the alert applies to. */ + fun metric(metric: JsonField) = apply { this.metric = metric } + + /** The plan the alert applies to. */ + fun plan(plan: Plan?) = plan(JsonField.ofNullable(plan)) + + /** The plan the alert applies to. */ + fun plan(plan: Optional) = plan(plan.orElse(null)) + + /** The plan the alert applies to. */ + fun plan(plan: JsonField) = apply { this.plan = plan } + + /** The subscription the alert applies to. */ + fun subscription(subscription: SubscriptionMinifiedModel?) = + subscription(JsonField.ofNullable(subscription)) + + /** The subscription the alert applies to. */ + fun subscription(subscription: Optional) = + subscription(subscription.orElse(null)) + + /** The subscription the alert applies to. */ + fun subscription(subscription: JsonField) = apply { + this.subscription = subscription + } + + /** The thresholds that define the conditions under which the alert will be triggered. */ + fun thresholds(thresholds: List?) = + thresholds(JsonField.ofNullable(thresholds)) + + /** The thresholds that define the conditions under which the alert will be triggered. */ + fun thresholds(thresholds: Optional>) = + thresholds(thresholds.orElse(null)) + + /** The thresholds that define the conditions under which the alert will be triggered. */ + fun thresholds(thresholds: JsonField>) = apply { + this.thresholds = thresholds.map { it.toMutableList() } + } + + /** The thresholds that define the conditions under which the alert will be triggered. */ + fun addThreshold(threshold: ThresholdModel) = apply { + thresholds = + (thresholds ?: JsonField.of(mutableListOf())).also { + checkKnown("thresholds", it).add(threshold) + } + } + + /** The type of alert. This must be a valid alert type. */ + fun type(type: Type) = type(JsonField.of(type)) + + /** The type of alert. This must be a valid alert type. */ + 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) + } + + fun build(): AlertModel = + AlertModel( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("currency", currency), + checkRequired("customer", customer), + checkRequired("enabled", enabled), + checkRequired("metric", metric), + checkRequired("plan", plan), + checkRequired("subscription", subscription), + checkRequired("thresholds", thresholds).map { it.toImmutable() }, + checkRequired("type", type), + additionalProperties.toImmutable(), + ) + } + + /** The metric the alert applies to. */ + @NoAutoDetect + class Metric + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metric = apply { + if (validated) { + return@apply + } + + id() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Metric]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metric]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metric: Metric) = apply { + id = metric.id + additionalProperties = metric.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + 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) + } + + fun build(): Metric = + Metric(checkRequired("id", id), additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metric && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metric{id=$id, additionalProperties=$additionalProperties}" + } + + /** The plan the alert applies to. */ + @NoAutoDetect + class Plan + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("external_plan_id") + @ExcludeMissing + private val externalPlanId: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("plan_version") + @ExcludeMissing + private val planVersion: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): Optional = Optional.ofNullable(id.getNullable("id")) + + /** + * An optional user-defined ID for this plan resource, used throughout the system as an + * alias for this Plan. Use this field to identify a plan by an existing identifier in your + * system. + */ + fun externalPlanId(): Optional = + Optional.ofNullable(externalPlanId.getNullable("external_plan_id")) + + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + fun planVersion(): String = planVersion.getRequired("plan_version") + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * An optional user-defined ID for this plan resource, used throughout the system as an + * alias for this Plan. Use this field to identify a plan by an existing identifier in your + * system. + */ + @JsonProperty("external_plan_id") + @ExcludeMissing + fun _externalPlanId(): JsonField = externalPlanId + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("plan_version") + @ExcludeMissing + fun _planVersion(): JsonField = planVersion + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Plan = apply { + if (validated) { + return@apply + } + + id() + externalPlanId() + name() + planVersion() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Plan]. + * + * The following fields are required: + * ```java + * .id() + * .externalPlanId() + * .name() + * .planVersion() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Plan]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var externalPlanId: JsonField? = null + private var name: JsonField? = null + private var planVersion: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(plan: Plan) = apply { + id = plan.id + externalPlanId = plan.externalPlanId + name = plan.name + planVersion = plan.planVersion + additionalProperties = plan.additionalProperties.toMutableMap() + } + + fun id(id: String?) = id(JsonField.ofNullable(id)) + + fun id(id: Optional) = id(id.orElse(null)) + + fun id(id: JsonField) = apply { this.id = id } + + /** + * An optional user-defined ID for this plan resource, used throughout the system as an + * alias for this Plan. Use this field to identify a plan by an existing identifier in + * your system. + */ + fun externalPlanId(externalPlanId: String?) = + externalPlanId(JsonField.ofNullable(externalPlanId)) + + /** + * An optional user-defined ID for this plan resource, used throughout the system as an + * alias for this Plan. Use this field to identify a plan by an existing identifier in + * your system. + */ + fun externalPlanId(externalPlanId: Optional) = + externalPlanId(externalPlanId.orElse(null)) + + /** + * An optional user-defined ID for this plan resource, used throughout the system as an + * alias for this Plan. Use this field to identify a plan by an existing identifier in + * your system. + */ + fun externalPlanId(externalPlanId: JsonField) = apply { + this.externalPlanId = externalPlanId + } + + fun name(name: String?) = name(JsonField.ofNullable(name)) + + fun name(name: Optional) = name(name.orElse(null)) + + fun name(name: JsonField) = apply { this.name = name } + + fun planVersion(planVersion: String) = planVersion(JsonField.of(planVersion)) + + fun planVersion(planVersion: JsonField) = apply { + this.planVersion = planVersion + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): Plan = + Plan( + checkRequired("id", id), + checkRequired("externalPlanId", externalPlanId), + checkRequired("name", name), + checkRequired("planVersion", planVersion), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Plan && id == other.id && externalPlanId == other.externalPlanId && name == other.name && planVersion == other.planVersion && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, externalPlanId, name, planVersion, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Plan{id=$id, externalPlanId=$externalPlanId, name=$name, planVersion=$planVersion, additionalProperties=$additionalProperties}" + } + + /** The type of alert. This must be a valid alert type. */ + 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 USAGE_EXCEEDED = of("usage_exceeded") + + @JvmField val COST_EXCEEDED = of("cost_exceeded") + + @JvmField val CREDIT_BALANCE_DEPLETED = of("credit_balance_depleted") + + @JvmField val CREDIT_BALANCE_DROPPED = of("credit_balance_dropped") + + @JvmField val CREDIT_BALANCE_RECOVERED = of("credit_balance_recovered") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + USAGE_EXCEEDED, + COST_EXCEEDED, + CREDIT_BALANCE_DEPLETED, + CREDIT_BALANCE_DROPPED, + CREDIT_BALANCE_RECOVERED, + } + + /** + * 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 { + USAGE_EXCEEDED, + COST_EXCEEDED, + CREDIT_BALANCE_DEPLETED, + CREDIT_BALANCE_DROPPED, + CREDIT_BALANCE_RECOVERED, + /** 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) { + USAGE_EXCEEDED -> Value.USAGE_EXCEEDED + COST_EXCEEDED -> Value.COST_EXCEEDED + CREDIT_BALANCE_DEPLETED -> Value.CREDIT_BALANCE_DEPLETED + CREDIT_BALANCE_DROPPED -> Value.CREDIT_BALANCE_DROPPED + CREDIT_BALANCE_RECOVERED -> Value.CREDIT_BALANCE_RECOVERED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to 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_EXCEEDED -> Known.USAGE_EXCEEDED + COST_EXCEEDED -> Known.COST_EXCEEDED + CREDIT_BALANCE_DEPLETED -> Known.CREDIT_BALANCE_DEPLETED + CREDIT_BALANCE_DROPPED -> Known.CREDIT_BALANCE_DROPPED + CREDIT_BALANCE_RECOVERED -> Known.CREDIT_BALANCE_RECOVERED + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AlertModel && id == other.id && createdAt == other.createdAt && currency == other.currency && customer == other.customer && enabled == other.enabled && metric == other.metric && plan == other.plan && subscription == other.subscription && thresholds == other.thresholds && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, createdAt, currency, customer, enabled, metric, plan, subscription, thresholds, type, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AlertModel{id=$id, createdAt=$createdAt, currency=$currency, customer=$customer, enabled=$enabled, metric=$metric, plan=$plan, subscription=$subscription, thresholds=$thresholds, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertRetrieveParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertRetrieveParams.kt index eb9566300..3f8970fc6 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertRetrieveParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertRetrieveParams.kt @@ -38,6 +38,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [AlertRetrieveParams]. + * + * The following fields are required: + * ```java + * .alertId() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 be397f6e7..fd53c3bf2 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 @@ -12,6 +12,7 @@ import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.Params +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams @@ -31,10 +32,10 @@ private constructor( fun alertConfigurationId(): String = alertConfigurationId /** The thresholds that define the values at which the alert will be triggered. */ - fun thresholds(): List = body.thresholds() + fun thresholds(): List = body.thresholds() /** The thresholds that define the values at which the alert will be triggered. */ - fun _thresholds(): JsonField> = body._thresholds() + fun _thresholds(): JsonField> = body._thresholds() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -61,18 +62,18 @@ private constructor( private constructor( @JsonProperty("thresholds") @ExcludeMissing - private val thresholds: JsonField> = JsonMissing.of(), + private val thresholds: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The thresholds that define the values at which the alert will be triggered. */ - fun thresholds(): List = thresholds.getRequired("thresholds") + fun thresholds(): List = thresholds.getRequired("thresholds") /** The thresholds that define the values at which the alert will be triggered. */ @JsonProperty("thresholds") @ExcludeMissing - fun _thresholds(): JsonField> = thresholds + fun _thresholds(): JsonField> = thresholds @JsonAnyGetter @ExcludeMissing @@ -93,13 +94,21 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .thresholds() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Body]. */ class Builder internal constructor() { - private var thresholds: JsonField>? = null + private var thresholds: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -109,24 +118,18 @@ private constructor( } /** The thresholds that define the values at which the alert will be triggered. */ - fun thresholds(thresholds: List) = thresholds(JsonField.of(thresholds)) + fun thresholds(thresholds: List) = thresholds(JsonField.of(thresholds)) /** The thresholds that define the values at which the alert will be triggered. */ - fun thresholds(thresholds: JsonField>) = apply { + fun thresholds(thresholds: JsonField>) = apply { this.thresholds = thresholds.map { it.toMutableList() } } /** The thresholds that define the values at which the alert will be triggered. */ - fun addThreshold(threshold: Threshold) = apply { + fun addThreshold(threshold: ThresholdModel) = apply { thresholds = - (thresholds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(threshold) + (thresholds ?: JsonField.of(mutableListOf())).also { + checkKnown("thresholds", it).add(threshold) } } @@ -178,6 +181,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [AlertUpdateParams]. + * + * The following fields are required: + * ```java + * .alertConfigurationId() + * .thresholds() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -203,15 +215,15 @@ private constructor( } /** The thresholds that define the values at which the alert will be triggered. */ - fun thresholds(thresholds: List) = apply { body.thresholds(thresholds) } + fun thresholds(thresholds: List) = apply { body.thresholds(thresholds) } /** The thresholds that define the values at which the alert will be triggered. */ - fun thresholds(thresholds: JsonField>) = apply { + fun thresholds(thresholds: JsonField>) = apply { body.thresholds(thresholds) } /** The thresholds that define the values at which the alert will be triggered. */ - fun addThreshold(threshold: Threshold) = apply { body.addThreshold(threshold) } + fun addThreshold(threshold: ThresholdModel) = apply { body.addThreshold(threshold) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { body.additionalProperties(additionalBodyProperties) @@ -339,121 +351,6 @@ private constructor( ) } - /** Thresholds are used to define the conditions under which an alert will be triggered. */ - @NoAutoDetect - class Threshold - @JsonCreator - private constructor( - @JsonProperty("value") - @ExcludeMissing - private val value: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * The value at which an alert will fire. For credit balance alerts, the alert will fire at - * or below this value. For usage and cost alerts, the alert will fire at or above this - * value. - */ - fun value(): Double = value.getRequired("value") - - /** - * The value at which an alert will fire. For credit balance alerts, the alert will fire at - * or below this value. For usage and cost alerts, the alert will fire at or above this - * value. - */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Threshold = apply { - if (validated) { - return@apply - } - - value() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Threshold]. */ - class Builder internal constructor() { - - private var value: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(threshold: Threshold) = apply { - value = threshold.value - additionalProperties = threshold.additionalProperties.toMutableMap() - } - - /** - * The value at which an alert will fire. For credit balance alerts, the alert will fire - * at or below this value. For usage and cost alerts, the alert will fire at or above - * this value. - */ - fun value(value: Double) = value(JsonField.of(value)) - - /** - * The value at which an alert will fire. For credit balance alerts, the alert will fire - * at or below this value. For usage and cost alerts, the alert will fire at or above - * this value. - */ - fun value(value: JsonField) = apply { this.value = 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) - } - - fun build(): Threshold = - Threshold(checkRequired("value", value), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Threshold && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(value, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Threshold{value=$value, 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/AllocationModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AllocationModel.kt new file mode 100644 index 000000000..1e4a0b034 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AllocationModel.kt @@ -0,0 +1,141 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects + +@NoAutoDetect +class AllocationModel +@JsonCreator +private constructor( + @JsonProperty("allows_rollover") + @ExcludeMissing + private val allowsRollover: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun allowsRollover(): Boolean = allowsRollover.getRequired("allows_rollover") + + fun currency(): String = currency.getRequired("currency") + + @JsonProperty("allows_rollover") + @ExcludeMissing + fun _allowsRollover(): JsonField = allowsRollover + + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): AllocationModel = apply { + if (validated) { + return@apply + } + + allowsRollover() + currency() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AllocationModel]. + * + * The following fields are required: + * ```java + * .allowsRollover() + * .currency() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AllocationModel]. */ + class Builder internal constructor() { + + private var allowsRollover: JsonField? = null + private var currency: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(allocationModel: AllocationModel) = apply { + allowsRollover = allocationModel.allowsRollover + currency = allocationModel.currency + additionalProperties = allocationModel.additionalProperties.toMutableMap() + } + + fun allowsRollover(allowsRollover: Boolean) = allowsRollover(JsonField.of(allowsRollover)) + + fun allowsRollover(allowsRollover: JsonField) = apply { + this.allowsRollover = allowsRollover + } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): AllocationModel = + AllocationModel( + checkRequired("allowsRollover", allowsRollover), + checkRequired("currency", currency), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AllocationModel && allowsRollover == other.allowsRollover && currency == other.currency && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(allowsRollover, currency, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AllocationModel{allowsRollover=$allowsRollover, currency=$currency, additionalProperties=$additionalProperties}" +} 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 c5debfe08..6e629c90d 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 @@ -12,6 +12,7 @@ import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.immutableEmptyMap import com.withorb.api.core.toImmutable @@ -92,6 +93,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [AmountDiscount]. + * + * The following fields are required: + * ```java + * .amountDiscount() + * .appliesToPriceIds() + * .discountType() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -142,14 +153,8 @@ private constructor( */ fun addAppliesToPriceId(appliesToPriceId: String) = apply { appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AmountDiscountIntervalModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AmountDiscountIntervalModel.kt new file mode 100644 index 000000000..f4e28fc6f --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AmountDiscountIntervalModel.kt @@ -0,0 +1,364 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class AmountDiscountIntervalModel +@JsonCreator +private constructor( + @JsonProperty("amount_discount") + @ExcludeMissing + private val amountDiscount: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), + @JsonProperty("discount_type") + @ExcludeMissing + private val discountType: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + private val endDate: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + private val startDate: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** Only available if discount_type is `amount`. */ + fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") + + /** The price ids that this discount interval applies to. */ + fun appliesToPriceIds(): List = appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The price interval ids that this discount interval applies to. */ + fun appliesToPriceIntervalIds(): List = + appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") + + fun discountType(): DiscountType = discountType.getRequired("discount_type") + + /** The end date of the discount interval. */ + fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) + + /** The start date of the discount interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** Only available if discount_type is `amount`. */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount(): JsonField = amountDiscount + + /** The price ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** The price interval ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds + + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType + + /** The end date of the discount interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + /** The start date of the discount interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): AmountDiscountIntervalModel = apply { + if (validated) { + return@apply + } + + amountDiscount() + appliesToPriceIds() + appliesToPriceIntervalIds() + discountType() + endDate() + startDate() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AmountDiscountIntervalModel]. + * + * The following fields are required: + * ```java + * .amountDiscount() + * .appliesToPriceIds() + * .appliesToPriceIntervalIds() + * .discountType() + * .endDate() + * .startDate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AmountDiscountIntervalModel]. */ + class Builder internal constructor() { + + private var amountDiscount: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(amountDiscountIntervalModel: AmountDiscountIntervalModel) = apply { + amountDiscount = amountDiscountIntervalModel.amountDiscount + appliesToPriceIds = + amountDiscountIntervalModel.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + amountDiscountIntervalModel.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = amountDiscountIntervalModel.discountType + endDate = amountDiscountIntervalModel.endDate + startDate = amountDiscountIntervalModel.startDate + additionalProperties = amountDiscountIntervalModel.additionalProperties.toMutableMap() + } + + /** Only available if discount_type is `amount`. */ + fun amountDiscount(amountDiscount: String) = amountDiscount(JsonField.of(amountDiscount)) + + /** Only available if discount_type is `amount`. */ + fun amountDiscount(amountDiscount: JsonField) = apply { + this.amountDiscount = amountDiscount + } + + /** The price ids that this discount interval applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price ids that this discount interval applies to. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this discount interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** The price interval ids that this discount interval applies to. */ + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = + appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) + + /** The price interval ids that this discount interval applies to. */ + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds.map { it.toMutableList() } + } + + /** The price interval ids that this discount interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIntervalIds", it).add(appliesToPriceIntervalId) + } + } + + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) + + fun discountType(discountType: JsonField) = apply { + this.discountType = discountType + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the discount interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) + + /** The end date of the discount interval. */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** The start date of the discount interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the discount interval. */ + 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) + } + + fun build(): AmountDiscountIntervalModel = + AmountDiscountIntervalModel( + checkRequired("amountDiscount", amountDiscount), + checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, + checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { + it.toImmutable() + }, + checkRequired("discountType", discountType), + checkRequired("endDate", endDate), + checkRequired("startDate", startDate), + additionalProperties.toImmutable(), + ) + } + + class DiscountType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val AMOUNT = of("amount") + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + /** An enum containing [DiscountType]'s known values. */ + enum class Known { + AMOUNT + } + + /** + * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [DiscountType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AMOUNT, + /** + * An enum member indicating that [DiscountType] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AMOUNT -> Value.AMOUNT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + AMOUNT -> Known.AMOUNT + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AmountDiscountIntervalModel && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(amountDiscount, appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, startDate, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AmountDiscountIntervalModel{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AmountDiscountModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AmountDiscountModel.kt new file mode 100644 index 000000000..f68e5bfec --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AmountDiscountModel.kt @@ -0,0 +1,312 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class AmountDiscountModel +@JsonCreator +private constructor( + @JsonProperty("amount_discount") + @ExcludeMissing + private val amountDiscount: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("discount_type") + @ExcludeMissing + private val discountType: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + private val reason: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** Only available if discount_type is `amount`. */ + fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") + + /** + * List of price_ids that this discount applies to. For plan/plan phase discounts, this can be a + * subset of prices. + */ + fun appliesToPriceIds(): List = appliesToPriceIds.getRequired("applies_to_price_ids") + + fun discountType(): DiscountType = discountType.getRequired("discount_type") + + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + /** Only available if discount_type is `amount`. */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount(): JsonField = amountDiscount + + /** + * List of price_ids that this discount applies to. For plan/plan phase discounts, this can be a + * subset of prices. + */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType + + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): AmountDiscountModel = apply { + if (validated) { + return@apply + } + + amountDiscount() + appliesToPriceIds() + discountType() + reason() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AmountDiscountModel]. + * + * The following fields are required: + * ```java + * .amountDiscount() + * .appliesToPriceIds() + * .discountType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AmountDiscountModel]. */ + class Builder internal constructor() { + + private var amountDiscount: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var discountType: JsonField? = null + private var reason: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(amountDiscountModel: AmountDiscountModel) = apply { + amountDiscount = amountDiscountModel.amountDiscount + appliesToPriceIds = amountDiscountModel.appliesToPriceIds.map { it.toMutableList() } + discountType = amountDiscountModel.discountType + reason = amountDiscountModel.reason + additionalProperties = amountDiscountModel.additionalProperties.toMutableMap() + } + + /** Only available if discount_type is `amount`. */ + fun amountDiscount(amountDiscount: String) = amountDiscount(JsonField.of(amountDiscount)) + + /** Only available if discount_type is `amount`. */ + fun amountDiscount(amountDiscount: JsonField) = apply { + this.amountDiscount = amountDiscount + } + + /** + * List of price_ids that this discount applies to. For plan/plan phase discounts, this can + * be a subset of prices. + */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** + * List of price_ids that this discount applies to. For plan/plan phase discounts, this can + * be a subset of prices. + */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this discount applies to. For plan/plan phase discounts, this can + * be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) + + fun discountType(discountType: JsonField) = apply { + this.discountType = discountType + } + + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + fun reason(reason: Optional) = reason(reason.orElse(null)) + + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): AmountDiscountModel = + AmountDiscountModel( + checkRequired("amountDiscount", amountDiscount), + checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, + checkRequired("discountType", discountType), + reason, + additionalProperties.toImmutable(), + ) + } + + class DiscountType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val AMOUNT = of("amount") + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + /** An enum containing [DiscountType]'s known values. */ + enum class Known { + AMOUNT + } + + /** + * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [DiscountType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AMOUNT, + /** + * An enum member indicating that [DiscountType] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AMOUNT -> Value.AMOUNT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + AMOUNT -> Known.AMOUNT + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AmountDiscountModel && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && discountType == other.discountType && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(amountDiscount, appliesToPriceIds, discountType, reason, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AmountDiscountModel{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, discountType=$discountType, reason=$reason, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AutoCollectionModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AutoCollectionModel.kt new file mode 100644 index 000000000..ebd97bc84 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AutoCollectionModel.kt @@ -0,0 +1,275 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class AutoCollectionModel +@JsonCreator +private constructor( + @JsonProperty("enabled") + @ExcludeMissing + private val enabled: JsonField = JsonMissing.of(), + @JsonProperty("next_attempt_at") + @ExcludeMissing + private val nextAttemptAt: JsonField = JsonMissing.of(), + @JsonProperty("num_attempts") + @ExcludeMissing + private val numAttempts: JsonField = JsonMissing.of(), + @JsonProperty("previously_attempted_at") + @ExcludeMissing + private val previouslyAttemptedAt: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** True only if auto-collection is enabled for this invoice. */ + fun enabled(): Optional = Optional.ofNullable(enabled.getNullable("enabled")) + + /** + * If the invoice is scheduled for auto-collection, this field will reflect when the next + * attempt will occur. If dunning has been exhausted, or auto-collection is not enabled for this + * invoice, this field will be `null`. + */ + fun nextAttemptAt(): Optional = + Optional.ofNullable(nextAttemptAt.getNullable("next_attempt_at")) + + /** Number of auto-collection payment attempts. */ + fun numAttempts(): Optional = Optional.ofNullable(numAttempts.getNullable("num_attempts")) + + /** + * If Orb has ever attempted payment auto-collection for this invoice, this field will reflect + * when that attempt occurred. In conjunction with `next_attempt_at`, this can be used to tell + * whether the invoice is currently in dunning (that is, `previously_attempted_at` is non-null, + * and `next_attempt_time` is non-null), or if dunning has been exhausted + * (`previously_attempted_at` is non-null, but `next_attempt_time` is null). + */ + fun previouslyAttemptedAt(): Optional = + Optional.ofNullable(previouslyAttemptedAt.getNullable("previously_attempted_at")) + + /** True only if auto-collection is enabled for this invoice. */ + @JsonProperty("enabled") @ExcludeMissing fun _enabled(): JsonField = 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`. + */ + @JsonProperty("next_attempt_at") + @ExcludeMissing + fun _nextAttemptAt(): JsonField = nextAttemptAt + + /** Number of auto-collection payment attempts. */ + @JsonProperty("num_attempts") @ExcludeMissing fun _numAttempts(): JsonField = 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). + */ + @JsonProperty("previously_attempted_at") + @ExcludeMissing + fun _previouslyAttemptedAt(): JsonField = previouslyAttemptedAt + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): AutoCollectionModel = apply { + if (validated) { + return@apply + } + + enabled() + nextAttemptAt() + numAttempts() + previouslyAttemptedAt() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AutoCollectionModel]. + * + * The following fields are required: + * ```java + * .enabled() + * .nextAttemptAt() + * .numAttempts() + * .previouslyAttemptedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AutoCollectionModel]. */ + 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(autoCollectionModel: AutoCollectionModel) = apply { + enabled = autoCollectionModel.enabled + nextAttemptAt = autoCollectionModel.nextAttemptAt + numAttempts = autoCollectionModel.numAttempts + previouslyAttemptedAt = autoCollectionModel.previouslyAttemptedAt + additionalProperties = autoCollectionModel.additionalProperties.toMutableMap() + } + + /** True only if auto-collection is enabled for this invoice. */ + fun enabled(enabled: Boolean?) = enabled(JsonField.ofNullable(enabled)) + + /** True only if auto-collection is enabled for this invoice. */ + fun enabled(enabled: Boolean) = enabled(enabled as Boolean?) + + /** True only if auto-collection is enabled for this invoice. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun enabled(enabled: Optional) = enabled(enabled.orElse(null) as Boolean?) + + /** True only if auto-collection is enabled for this invoice. */ + 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)) + + /** + * 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: Optional) = + nextAttemptAt(nextAttemptAt.orElse(null)) + + /** + * 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: JsonField) = apply { + this.nextAttemptAt = nextAttemptAt + } + + /** Number of auto-collection payment attempts. */ + fun numAttempts(numAttempts: Long?) = numAttempts(JsonField.ofNullable(numAttempts)) + + /** Number of auto-collection payment attempts. */ + fun numAttempts(numAttempts: Long) = numAttempts(numAttempts as Long?) + + /** Number of auto-collection payment attempts. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun numAttempts(numAttempts: Optional) = + numAttempts(numAttempts.orElse(null) as Long?) + + /** Number of auto-collection payment attempts. */ + 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)) + + /** + * 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: Optional) = + previouslyAttemptedAt(previouslyAttemptedAt.orElse(null)) + + /** + * 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: 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) + } + + fun build(): AutoCollectionModel = + AutoCollectionModel( + checkRequired("enabled", enabled), + checkRequired("nextAttemptAt", nextAttemptAt), + checkRequired("numAttempts", numAttempts), + checkRequired("previouslyAttemptedAt", previouslyAttemptedAt), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AutoCollectionModel && enabled == other.enabled && nextAttemptAt == other.nextAttemptAt && numAttempts == other.numAttempts && previouslyAttemptedAt == other.previouslyAttemptedAt && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(enabled, nextAttemptAt, numAttempts, previouslyAttemptedAt, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AutoCollectionModel{enabled=$enabled, nextAttemptAt=$nextAttemptAt, numAttempts=$numAttempts, previouslyAttemptedAt=$previouslyAttemptedAt, additionalProperties=$additionalProperties}" +} 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/BackfillModel.kt similarity index 89% rename from orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchResponse.kt rename to orb-java-core/src/main/kotlin/com/withorb/api/models/BackfillModel.kt index 53a0a868d..f4016122a 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/BackfillModel.kt @@ -25,7 +25,7 @@ import java.util.Optional * timeframe. */ @NoAutoDetect -class EventBackfillFetchResponse +class BackfillModel @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @@ -172,7 +172,7 @@ private constructor( private var validated: Boolean = false - fun validate(): EventBackfillFetchResponse = apply { + fun validate(): BackfillModel = apply { if (validated) { return@apply } @@ -195,10 +195,27 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [BackfillModel]. + * + * The following fields are required: + * ```java + * .id() + * .closeTime() + * .createdAt() + * .customerId() + * .eventsIngested() + * .replaceExistingEvents() + * .revertedAt() + * .status() + * .timeframeEnd() + * .timeframeStart() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [EventBackfillFetchResponse]. */ + /** A builder for [BackfillModel]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -215,19 +232,19 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(eventBackfillFetchResponse: EventBackfillFetchResponse) = apply { - id = eventBackfillFetchResponse.id - closeTime = eventBackfillFetchResponse.closeTime - createdAt = eventBackfillFetchResponse.createdAt - customerId = eventBackfillFetchResponse.customerId - eventsIngested = eventBackfillFetchResponse.eventsIngested - replaceExistingEvents = eventBackfillFetchResponse.replaceExistingEvents - revertedAt = eventBackfillFetchResponse.revertedAt - status = eventBackfillFetchResponse.status - timeframeEnd = eventBackfillFetchResponse.timeframeEnd - timeframeStart = eventBackfillFetchResponse.timeframeStart - deprecationFilter = eventBackfillFetchResponse.deprecationFilter - additionalProperties = eventBackfillFetchResponse.additionalProperties.toMutableMap() + internal fun from(backfillModel: BackfillModel) = apply { + id = backfillModel.id + closeTime = backfillModel.closeTime + createdAt = backfillModel.createdAt + customerId = backfillModel.customerId + eventsIngested = backfillModel.eventsIngested + replaceExistingEvents = backfillModel.replaceExistingEvents + revertedAt = backfillModel.revertedAt + status = backfillModel.status + timeframeEnd = backfillModel.timeframeEnd + timeframeStart = backfillModel.timeframeStart + deprecationFilter = backfillModel.deprecationFilter + additionalProperties = backfillModel.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -370,8 +387,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): EventBackfillFetchResponse = - EventBackfillFetchResponse( + fun build(): BackfillModel = + BackfillModel( checkRequired("id", id), checkRequired("closeTime", closeTime), checkRequired("createdAt", createdAt), @@ -502,7 +519,7 @@ private constructor( return true } - return /* spotless:off */ other is EventBackfillFetchResponse && id == other.id && closeTime == other.closeTime && createdAt == other.createdAt && customerId == other.customerId && eventsIngested == other.eventsIngested && replaceExistingEvents == other.replaceExistingEvents && revertedAt == other.revertedAt && status == other.status && timeframeEnd == other.timeframeEnd && timeframeStart == other.timeframeStart && deprecationFilter == other.deprecationFilter && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is BackfillModel && id == other.id && closeTime == other.closeTime && createdAt == other.createdAt && customerId == other.customerId && eventsIngested == other.eventsIngested && replaceExistingEvents == other.replaceExistingEvents && revertedAt == other.revertedAt && status == other.status && timeframeEnd == other.timeframeEnd && timeframeStart == other.timeframeStart && deprecationFilter == other.deprecationFilter && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -512,5 +529,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EventBackfillFetchResponse{id=$id, closeTime=$closeTime, createdAt=$createdAt, customerId=$customerId, eventsIngested=$eventsIngested, replaceExistingEvents=$replaceExistingEvents, revertedAt=$revertedAt, status=$status, timeframeEnd=$timeframeEnd, timeframeStart=$timeframeStart, deprecationFilter=$deprecationFilter, additionalProperties=$additionalProperties}" + "BackfillModel{id=$id, closeTime=$closeTime, createdAt=$createdAt, customerId=$customerId, eventsIngested=$eventsIngested, replaceExistingEvents=$replaceExistingEvents, revertedAt=$revertedAt, status=$status, timeframeEnd=$timeframeEnd, timeframeStart=$timeframeStart, deprecationFilter=$deprecationFilter, additionalProperties=$additionalProperties}" } 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 ed9de075c..0026eda33 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 @@ -31,7 +31,7 @@ private constructor( @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), - @JsonProperty("item") @ExcludeMissing private val item: JsonField = JsonMissing.of(), + @JsonProperty("item") @ExcludeMissing private val item: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), @@ -52,7 +52,7 @@ private constructor( * items, billable metrics, and prices and are used for defining external sync behavior for * invoices and tax calculation purposes. */ - fun item(): Item = item.getRequired("item") + fun item(): ItemModel = item.getRequired("item") /** * User specified key-value pairs for the resource. If not present, this defaults to an empty @@ -74,7 +74,7 @@ private constructor( * items, billable metrics, and prices and are used for defining external sync behavior for * invoices and tax calculation purposes. */ - @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item /** * User specified key-value pairs for the resource. If not present, this defaults to an empty @@ -111,6 +111,19 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [BillableMetric]. + * + * The following fields are required: + * ```java + * .id() + * .description() + * .item() + * .metadata() + * .name() + * .status() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -119,7 +132,7 @@ private constructor( private var id: JsonField? = null private var description: JsonField? = null - private var item: JsonField? = null + private var item: JsonField? = null private var metadata: JsonField? = null private var name: JsonField? = null private var status: JsonField? = null @@ -151,14 +164,14 @@ private constructor( * line items, billable metrics, and prices and are used for defining external sync behavior * for invoices and tax calculation purposes. */ - fun item(item: Item) = item(JsonField.of(item)) + fun item(item: ItemModel) = item(JsonField.of(item)) /** * 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 item(item: JsonField) = apply { this.item = item } + fun item(item: JsonField) = apply { this.item = item } /** * User specified key-value pairs for the resource. If not present, this defaults to an @@ -244,6 +257,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/BillableMetricModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BillableMetricModel.kt new file mode 100644 index 000000000..a8b938cee --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/BillableMetricModel.kt @@ -0,0 +1,432 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Objects +import java.util.Optional + +/** + * 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. + */ +@NoAutoDetect +class BillableMetricModel +@JsonCreator +private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("item") @ExcludeMissing private val item: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + private val status: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun id(): String = id.getRequired("id") + + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** + * 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 item(): ItemModel = item.getRequired("item") + + /** + * 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.getRequired("metadata") + + fun name(): String = name.getRequired("name") + + fun status(): Status = status.getRequired("status") + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + + /** + * 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. + */ + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + /** + * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): BillableMetricModel = apply { + if (validated) { + return@apply + } + + id() + description() + item().validate() + metadata().validate() + name() + status() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BillableMetricModel]. + * + * The following fields are required: + * ```java + * .id() + * .description() + * .item() + * .metadata() + * .name() + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BillableMetricModel]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var description: JsonField? = null + private var item: JsonField? = null + private var metadata: JsonField? = null + private var name: JsonField? = null + private var status: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(billableMetricModel: BillableMetricModel) = apply { + id = billableMetricModel.id + description = billableMetricModel.description + item = billableMetricModel.item + metadata = billableMetricModel.metadata + name = billableMetricModel.name + status = billableMetricModel.status + additionalProperties = billableMetricModel.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + fun description(description: Optional) = description(description.orElse(null)) + + fun description(description: JsonField) = apply { this.description = description } + + /** + * 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 item(item: ItemModel) = item(JsonField.of(item)) + + /** + * 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 item(item: JsonField) = apply { this.item = item } + + /** + * 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)) + + /** + * 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: JsonField) = apply { this.metadata = metadata } + + fun name(name: String) = name(JsonField.of(name)) + + fun name(name: JsonField) = apply { this.name = name } + + fun status(status: Status) = status(JsonField.of(status)) + + 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) + } + + fun build(): BillableMetricModel = + BillableMetricModel( + checkRequired("id", id), + checkRequired("description", description), + checkRequired("item", item), + checkRequired("metadata", metadata), + checkRequired("name", name), + checkRequired("status", status), + additionalProperties.toImmutable(), + ) + } + + /** + * 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`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class 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 DRAFT = of("draft") + + @JvmField val ARCHIVED = of("archived") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + DRAFT, + ARCHIVED, + } + + /** + * 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, + DRAFT, + ARCHIVED, + /** 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 + DRAFT -> Value.DRAFT + ARCHIVED -> Value.ARCHIVED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to 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 + DRAFT -> Known.DRAFT + ARCHIVED -> Known.ARCHIVED + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BillableMetricModel && id == other.id && description == other.description && item == other.item && metadata == other.metadata && name == other.name && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, description, item, metadata, name, status, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BillableMetricModel{id=$id, description=$description, item=$item, metadata=$metadata, name=$name, status=$status, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/BillableMetricSimpleModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BillableMetricSimpleModel.kt new file mode 100644 index 000000000..9640659c1 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/BillableMetricSimpleModel.kt @@ -0,0 +1,133 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects + +@NoAutoDetect +class BillableMetricSimpleModel +@JsonCreator +private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun id(): String = id.getRequired("id") + + fun name(): String = name.getRequired("name") + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): BillableMetricSimpleModel = apply { + if (validated) { + return@apply + } + + id() + name() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BillableMetricSimpleModel]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BillableMetricSimpleModel]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(billableMetricSimpleModel: BillableMetricSimpleModel) = apply { + id = billableMetricSimpleModel.id + name = billableMetricSimpleModel.name + additionalProperties = billableMetricSimpleModel.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun name(name: String) = name(JsonField.of(name)) + + 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) + } + + fun build(): BillableMetricSimpleModel = + BillableMetricSimpleModel( + checkRequired("id", id), + checkRequired("name", name), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BillableMetricSimpleModel && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BillableMetricSimpleModel{id=$id, name=$name, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/BillableMetricTinyModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BillableMetricTinyModel.kt new file mode 100644 index 000000000..cdd06458f --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/BillableMetricTinyModel.kt @@ -0,0 +1,116 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects + +@NoAutoDetect +class BillableMetricTinyModel +@JsonCreator +private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun id(): String = id.getRequired("id") + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): BillableMetricTinyModel = apply { + if (validated) { + return@apply + } + + id() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BillableMetricTinyModel]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BillableMetricTinyModel]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(billableMetricTinyModel: BillableMetricTinyModel) = apply { + id = billableMetricTinyModel.id + additionalProperties = billableMetricTinyModel.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + 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) + } + + fun build(): BillableMetricTinyModel = + BillableMetricTinyModel(checkRequired("id", id), additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BillableMetricTinyModel && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BillableMetricTinyModel{id=$id, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/BillingCycleAnchorConfigurationModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BillingCycleAnchorConfigurationModel.kt new file mode 100644 index 000000000..52bfe625f --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/BillingCycleAnchorConfigurationModel.kt @@ -0,0 +1,230 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class BillingCycleAnchorConfigurationModel +@JsonCreator +private constructor( + @JsonProperty("day") @ExcludeMissing private val day: JsonField = JsonMissing.of(), + @JsonProperty("month") @ExcludeMissing private val month: JsonField = JsonMissing.of(), + @JsonProperty("year") @ExcludeMissing private val year: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** + * The day of the month on which the billing cycle is anchored. If the maximum number of days in + * a month is greater than this value, the last day of the month is the billing cycle day (e.g. + * billing_cycle_day=31 for April means the billing period begins on the 30th. + */ + fun day(): Long = day.getRequired("day") + + /** + * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in February + * would have cycles starting February, May, August, and November). + */ + fun month(): Optional = Optional.ofNullable(month.getNullable("month")) + + /** + * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on 2021 + * would have cycles starting on 2021, 2023, 2025, etc.). + */ + fun year(): Optional = Optional.ofNullable(year.getNullable("year")) + + /** + * The day of the month on which the billing cycle is anchored. If the maximum number of days in + * a month is greater than this value, the last day of the month is the billing cycle day (e.g. + * billing_cycle_day=31 for April means the billing period begins on the 30th. + */ + @JsonProperty("day") @ExcludeMissing fun _day(): JsonField = day + + /** + * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in February + * would have cycles starting February, May, August, and November). + */ + @JsonProperty("month") @ExcludeMissing fun _month(): JsonField = month + + /** + * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on 2021 + * would have cycles starting on 2021, 2023, 2025, etc.). + */ + @JsonProperty("year") @ExcludeMissing fun _year(): JsonField = year + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): BillingCycleAnchorConfigurationModel = apply { + if (validated) { + return@apply + } + + day() + month() + year() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BillingCycleAnchorConfigurationModel]. + * + * The following fields are required: + * ```java + * .day() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BillingCycleAnchorConfigurationModel]. */ + class Builder internal constructor() { + + private var day: JsonField? = null + private var month: JsonField = JsonMissing.of() + private var year: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + billingCycleAnchorConfigurationModel: BillingCycleAnchorConfigurationModel + ) = apply { + day = billingCycleAnchorConfigurationModel.day + month = billingCycleAnchorConfigurationModel.month + year = billingCycleAnchorConfigurationModel.year + additionalProperties = + billingCycleAnchorConfigurationModel.additionalProperties.toMutableMap() + } + + /** + * The day of the month on which the billing cycle is anchored. If the maximum number of + * days in a month is greater than this value, the last day of the month is the billing + * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the + * 30th. + */ + fun day(day: Long) = day(JsonField.of(day)) + + /** + * The day of the month on which the billing cycle is anchored. If the maximum number of + * days in a month is greater than this value, the last day of the month is the billing + * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the + * 30th. + */ + fun day(day: JsonField) = apply { this.day = day } + + /** + * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in + * February would have cycles starting February, May, August, and November). + */ + fun month(month: Long?) = month(JsonField.ofNullable(month)) + + /** + * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in + * February would have cycles starting February, May, August, and November). + */ + fun month(month: Long) = month(month as Long?) + + /** + * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in + * February would have cycles starting February, May, August, and November). + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun month(month: Optional) = month(month.orElse(null) as Long?) + + /** + * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in + * February would have cycles starting February, May, August, and November). + */ + fun month(month: JsonField) = apply { this.month = month } + + /** + * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on + * 2021 would have cycles starting on 2021, 2023, 2025, etc.). + */ + fun year(year: Long?) = year(JsonField.ofNullable(year)) + + /** + * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on + * 2021 would have cycles starting on 2021, 2023, 2025, etc.). + */ + fun year(year: Long) = year(year as Long?) + + /** + * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on + * 2021 would have cycles starting on 2021, 2023, 2025, etc.). + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun year(year: Optional) = year(year.orElse(null) as Long?) + + /** + * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on + * 2021 would have cycles starting on 2021, 2023, 2025, etc.). + */ + fun year(year: JsonField) = apply { this.year = year } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): BillingCycleAnchorConfigurationModel = + BillingCycleAnchorConfigurationModel( + checkRequired("day", day), + month, + year, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BillingCycleAnchorConfigurationModel && day == other.day && month == other.month && year == other.year && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(day, month, year, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BillingCycleAnchorConfigurationModel{day=$day, month=$month, year=$year, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/BillingCycleConfigurationModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BillingCycleConfigurationModel.kt new file mode 100644 index 000000000..074abcc9f --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/BillingCycleConfigurationModel.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.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.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Objects + +@NoAutoDetect +class BillingCycleConfigurationModel +@JsonCreator +private constructor( + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun duration(): Long = duration.getRequired("duration") + + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): BillingCycleConfigurationModel = apply { + if (validated) { + return@apply + } + + duration() + durationUnit() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BillingCycleConfigurationModel]. + * + * The following fields are required: + * ```java + * .duration() + * .durationUnit() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BillingCycleConfigurationModel]. */ + class Builder internal constructor() { + + private var duration: JsonField? = null + private var durationUnit: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(billingCycleConfigurationModel: BillingCycleConfigurationModel) = apply { + duration = billingCycleConfigurationModel.duration + durationUnit = billingCycleConfigurationModel.durationUnit + additionalProperties = + billingCycleConfigurationModel.additionalProperties.toMutableMap() + } + + fun duration(duration: Long) = duration(JsonField.of(duration)) + + fun duration(duration: JsonField) = apply { this.duration = duration } + + fun durationUnit(durationUnit: DurationUnit) = durationUnit(JsonField.of(durationUnit)) + + fun durationUnit(durationUnit: JsonField) = apply { + this.durationUnit = durationUnit + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): BillingCycleConfigurationModel = + BillingCycleConfigurationModel( + checkRequired("duration", duration), + checkRequired("durationUnit", durationUnit), + additionalProperties.toImmutable(), + ) + } + + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val DAY = of("day") + + @JvmField val MONTH = of("month") + + @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) + } + + /** An enum containing [DurationUnit]'s known values. */ + enum class Known { + DAY, + MONTH, + } + + /** + * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [DurationUnit] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + DAY, + MONTH, + /** + * An enum member indicating that [DurationUnit] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + DAY -> Value.DAY + MONTH -> Value.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) { + DAY -> Known.DAY + MONTH -> Known.MONTH + else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if 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 + } + + return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BillingCycleConfigurationModel && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BillingCycleConfigurationModel{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/BpsConfigModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BpsConfigModel.kt new file mode 100644 index 000000000..28d07edda --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/BpsConfigModel.kt @@ -0,0 +1,153 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class BpsConfigModel +@JsonCreator +private constructor( + @JsonProperty("bps") @ExcludeMissing private val bps: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_maximum") + @ExcludeMissing + private val perUnitMaximum: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** Basis point take rate per event */ + fun bps(): Double = bps.getRequired("bps") + + /** Optional currency amount maximum to cap spend per event */ + fun perUnitMaximum(): Optional = + Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) + + /** Basis point take rate per event */ + @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps + + /** Optional currency amount maximum to cap spend per event */ + @JsonProperty("per_unit_maximum") + @ExcludeMissing + fun _perUnitMaximum(): JsonField = perUnitMaximum + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): BpsConfigModel = apply { + if (validated) { + return@apply + } + + bps() + perUnitMaximum() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BpsConfigModel]. + * + * The following fields are required: + * ```java + * .bps() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BpsConfigModel]. */ + class Builder internal constructor() { + + private var bps: JsonField? = null + private var perUnitMaximum: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bpsConfigModel: BpsConfigModel) = apply { + bps = bpsConfigModel.bps + perUnitMaximum = bpsConfigModel.perUnitMaximum + additionalProperties = bpsConfigModel.additionalProperties.toMutableMap() + } + + /** Basis point take rate per event */ + fun bps(bps: Double) = bps(JsonField.of(bps)) + + /** Basis point take rate per event */ + fun bps(bps: JsonField) = apply { this.bps = bps } + + /** Optional currency amount maximum to cap spend per event */ + fun perUnitMaximum(perUnitMaximum: String?) = + perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) + + /** Optional currency amount maximum to cap spend per event */ + fun perUnitMaximum(perUnitMaximum: Optional) = + perUnitMaximum(perUnitMaximum.orElse(null)) + + /** Optional currency amount maximum to cap spend per event */ + fun perUnitMaximum(perUnitMaximum: JsonField) = apply { + this.perUnitMaximum = perUnitMaximum + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): BpsConfigModel = + BpsConfigModel( + checkRequired("bps", bps), + perUnitMaximum, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BpsConfigModel && bps == other.bps && perUnitMaximum == other.perUnitMaximum && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(bps, perUnitMaximum, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BpsConfigModel{bps=$bps, perUnitMaximum=$perUnitMaximum, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/BulkBpsConfigModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BulkBpsConfigModel.kt new file mode 100644 index 000000000..afe38843c --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/BulkBpsConfigModel.kt @@ -0,0 +1,315 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class BulkBpsConfigModel +@JsonCreator +private constructor( + @JsonProperty("tiers") + @ExcludeMissing + private val tiers: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** + * Tiers for a bulk BPS pricing model where all usage is aggregated to a single tier based on + * total volume + */ + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Tiers for a bulk BPS pricing model where all usage is aggregated to a single tier based on + * total volume + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): BulkBpsConfigModel = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BulkBpsConfigModel]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkBpsConfigModel]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkBpsConfigModel: BulkBpsConfigModel) = apply { + tiers = bulkBpsConfigModel.tiers.map { it.toMutableList() } + additionalProperties = bulkBpsConfigModel.additionalProperties.toMutableMap() + } + + /** + * Tiers for a bulk BPS pricing model where all usage is aggregated to a single tier based + * on total volume + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Tiers for a bulk BPS pricing model where all usage is aggregated to a single tier based + * on total volume + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Tiers for a bulk BPS pricing model where all usage is aggregated to a single tier based + * on total volume + */ + 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) + } + + fun build(): BulkBpsConfigModel = + BulkBpsConfigModel( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + @NoAutoDetect + class Tier + @JsonCreator + private constructor( + @JsonProperty("bps") @ExcludeMissing private val bps: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_maximum") + @ExcludeMissing + private val perUnitMaximum: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** Basis points to rate on */ + fun bps(): Double = bps.getRequired("bps") + + /** Upper bound for tier */ + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** The maximum amount to charge for any one event */ + fun perUnitMaximum(): Optional = + Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) + + /** Basis points to rate on */ + @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps + + /** Upper bound for tier */ + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount + + /** The maximum amount to charge for any one event */ + @JsonProperty("per_unit_maximum") + @ExcludeMissing + fun _perUnitMaximum(): JsonField = perUnitMaximum + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + bps() + maximumAmount() + perUnitMaximum() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```java + * .bps() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var bps: JsonField? = null + private var maximumAmount: JsonField = JsonMissing.of() + private var perUnitMaximum: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + bps = tier.bps + maximumAmount = tier.maximumAmount + perUnitMaximum = tier.perUnitMaximum + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Basis points to rate on */ + fun bps(bps: Double) = bps(JsonField.of(bps)) + + /** Basis points to rate on */ + fun bps(bps: JsonField) = apply { this.bps = bps } + + /** Upper bound for tier */ + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + /** Upper bound for tier */ + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) + + /** Upper bound for tier */ + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + /** The maximum amount to charge for any one event */ + fun perUnitMaximum(perUnitMaximum: String?) = + perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) + + /** The maximum amount to charge for any one event */ + fun perUnitMaximum(perUnitMaximum: Optional) = + perUnitMaximum(perUnitMaximum.orElse(null)) + + /** The maximum amount to charge for any one event */ + fun perUnitMaximum(perUnitMaximum: JsonField) = apply { + this.perUnitMaximum = perUnitMaximum + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): Tier = + Tier( + checkRequired("bps", bps), + maximumAmount, + perUnitMaximum, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Tier && bps == other.bps && maximumAmount == other.maximumAmount && perUnitMaximum == other.perUnitMaximum && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(bps, maximumAmount, perUnitMaximum, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{bps=$bps, maximumAmount=$maximumAmount, perUnitMaximum=$perUnitMaximum, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BulkBpsConfigModel && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkBpsConfigModel{tiers=$tiers, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/BulkConfigModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BulkConfigModel.kt new file mode 100644 index 000000000..035c18d5e --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/BulkConfigModel.kt @@ -0,0 +1,279 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class BulkConfigModel +@JsonCreator +private constructor( + @JsonProperty("tiers") + @ExcludeMissing + private val tiers: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(): List = tiers.getRequired("tiers") + + /** Bulk tiers for rating based on total usage volume */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): BulkConfigModel = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BulkConfigModel]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkConfigModel]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkConfigModel: BulkConfigModel) = apply { + tiers = bulkConfigModel.tiers.map { it.toMutableList() } + additionalProperties = bulkConfigModel.additionalProperties.toMutableMap() + } + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** Bulk tiers for rating based on total usage volume */ + 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) + } + + fun build(): BulkConfigModel = + BulkConfigModel( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + @NoAutoDetect + class Tier + @JsonCreator + private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + private val unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("maximum_units") + @ExcludeMissing + private val maximumUnits: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** Amount per unit */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** Upper bound for this tier */ + fun maximumUnits(): Optional = + Optional.ofNullable(maximumUnits.getNullable("maximum_units")) + + /** Amount per unit */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** Upper bound for this tier */ + @JsonProperty("maximum_units") + @ExcludeMissing + fun _maximumUnits(): JsonField = maximumUnits + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + unitAmount() + maximumUnits() + validated = true + } + + 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 maximumUnits: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + unitAmount = tier.unitAmount + maximumUnits = tier.maximumUnits + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** Amount per unit */ + fun unitAmount(unitAmount: JsonField) = apply { this.unitAmount = unitAmount } + + /** Upper bound for this tier */ + fun maximumUnits(maximumUnits: Double?) = + maximumUnits(JsonField.ofNullable(maximumUnits)) + + /** Upper bound for this tier */ + fun maximumUnits(maximumUnits: Double) = maximumUnits(maximumUnits as Double?) + + /** Upper bound for this tier */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun maximumUnits(maximumUnits: Optional) = + maximumUnits(maximumUnits.orElse(null) as Double?) + + /** Upper bound for this tier */ + fun maximumUnits(maximumUnits: JsonField) = apply { + this.maximumUnits = maximumUnits + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): Tier = + Tier( + checkRequired("unitAmount", unitAmount), + maximumUnits, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Tier && unitAmount == other.unitAmount && maximumUnits == other.maximumUnits && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(unitAmount, maximumUnits, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{unitAmount=$unitAmount, maximumUnits=$maximumUnits, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BulkConfigModel && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkConfigModel{tiers=$tiers, additionalProperties=$additionalProperties}" +} 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 fe82de01e..51a886f44 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 @@ -158,6 +158,20 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Coupon]. + * + * The following fields are required: + * ```java + * .id() + * .archivedAt() + * .discount() + * .durationInMonths() + * .maxRedemptions() + * .redemptionCode() + * .timesRedeemed() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponArchiveParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponArchiveParams.kt index 8f07cb7a3..bde9d8238 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponArchiveParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponArchiveParams.kt @@ -52,6 +52,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [CouponArchiveParams]. + * + * The following fields are required: + * ```java + * .couponId() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 b22ea288e..372298203 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 @@ -174,6 +174,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .discount() + * .redemptionCode() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -345,6 +354,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [CouponCreateParams]. + * + * The following fields are required: + * ```java + * .discount() + * .redemptionCode() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -778,6 +796,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [NewCouponPercentageDiscount]. + * + * The following fields are required: + * ```java + * .discountType() + * .percentageDiscount() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1005,6 +1033,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [NewCouponAmountDiscount]. + * + * The following fields are required: + * ```java + * .amountDiscount() + * .discountType() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponFetchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponFetchParams.kt index 9b65c9961..55577e28c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponFetchParams.kt @@ -41,6 +41,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [CouponFetchParams]. + * + * The following fields are required: + * ```java + * .couponId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListPage.kt index 1f96b804d..8900a723e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListPage.kt @@ -35,7 +35,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -90,20 +90,20 @@ private constructor( class Response @JsonCreator constructor( - @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), + @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = Optional.ofNullable(data) + fun _data(): Optional>> = Optional.ofNullable(data) @JsonProperty("pagination_metadata") fun _paginationMetadata(): Optional> = @@ -142,12 +142,13 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [CouponListPage]. */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -158,9 +159,9 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { this.data = data } fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) @@ -177,9 +178,9 @@ private constructor( } } - class AutoPager(private val firstPage: CouponListPage) : Iterable { + class AutoPager(private val firstPage: CouponListPage) : Iterable { - override fun iterator(): Iterator = iterator { + override fun iterator(): Iterator = iterator { var page = firstPage var index = 0 while (true) { @@ -191,7 +192,7 @@ private constructor( } } - fun stream(): Stream { + fun stream(): Stream { return StreamSupport.stream(spliterator(), false) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListPageAsync.kt index 80198d160..60f354ce9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListPageAsync.kt @@ -36,7 +36,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -93,20 +93,20 @@ private constructor( class Response @JsonCreator constructor( - @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), + @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = Optional.ofNullable(data) + fun _data(): Optional>> = Optional.ofNullable(data) @JsonProperty("pagination_metadata") fun _paginationMetadata(): Optional> = @@ -145,12 +145,13 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [CouponListPageAsync]. */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -161,9 +162,9 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { this.data = data } fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) @@ -182,9 +183,9 @@ private constructor( class AutoPager(private val firstPage: CouponListPageAsync) { - fun forEach(action: Predicate, executor: Executor): CompletableFuture { + fun forEach(action: Predicate, executor: Executor): CompletableFuture { fun CompletableFuture>.forEach( - action: (Coupon) -> Boolean, + action: (CouponModel) -> Boolean, executor: Executor, ): CompletableFuture = thenComposeAsync( @@ -200,8 +201,8 @@ private constructor( .forEach(action::test, executor) } - fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() + fun toList(executor: Executor): CompletableFuture> { + val values = mutableListOf() return forEach(values::add, executor).thenApply { values } } } 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 60e63453a..77b3bfd84 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 @@ -63,6 +63,7 @@ private constructor( @JvmStatic fun none(): CouponListParams = builder().build() + /** Returns a mutable builder for constructing an instance of [CouponListParams]. */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponModel.kt new file mode 100644 index 000000000..b3f866c35 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponModel.kt @@ -0,0 +1,503 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.BaseDeserializer +import com.withorb.api.core.BaseSerializer +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.getOrThrow +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional +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. + */ +@NoAutoDetect +class CouponModel +@JsonCreator +private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("archived_at") + @ExcludeMissing + private val archivedAt: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("duration_in_months") + @ExcludeMissing + private val durationInMonths: JsonField = JsonMissing.of(), + @JsonProperty("max_redemptions") + @ExcludeMissing + private val maxRedemptions: JsonField = JsonMissing.of(), + @JsonProperty("redemption_code") + @ExcludeMissing + private val redemptionCode: JsonField = JsonMissing.of(), + @JsonProperty("times_redeemed") + @ExcludeMissing + private val timesRedeemed: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** Also referred to as coupon_id in this documentation. */ + fun id(): String = id.getRequired("id") + + /** + * An archived coupon can no longer be redeemed. Active coupons will have a value of null for + * `archived_at`; this field will be non-null for archived coupons. + */ + fun archivedAt(): Optional = + Optional.ofNullable(archivedAt.getNullable("archived_at")) + + fun discount(): Discount = discount.getRequired("discount") + + /** + * This allows for a coupon's discount to apply for a limited time (determined in months); a + * `null` value here means "unlimited time". + */ + fun durationInMonths(): Optional = + Optional.ofNullable(durationInMonths.getNullable("duration_in_months")) + + /** + * The maximum number of redemptions allowed for this coupon before it is exhausted; `null` here + * means "unlimited". + */ + fun maxRedemptions(): Optional = + Optional.ofNullable(maxRedemptions.getNullable("max_redemptions")) + + /** This string can be used to redeem this coupon for a given subscription. */ + fun redemptionCode(): String = redemptionCode.getRequired("redemption_code") + + /** The number of times this coupon has been redeemed. */ + fun timesRedeemed(): Long = timesRedeemed.getRequired("times_redeemed") + + /** Also referred to as coupon_id in this documentation. */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * An archived coupon can no longer be redeemed. Active coupons will have a value of null for + * `archived_at`; this field will be non-null for archived coupons. + */ + @JsonProperty("archived_at") + @ExcludeMissing + fun _archivedAt(): JsonField = archivedAt + + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount + + /** + * This allows for a coupon's discount to apply for a limited time (determined in months); a + * `null` value here means "unlimited time". + */ + @JsonProperty("duration_in_months") + @ExcludeMissing + fun _durationInMonths(): JsonField = durationInMonths + + /** + * The maximum number of redemptions allowed for this coupon before it is exhausted; `null` here + * means "unlimited". + */ + @JsonProperty("max_redemptions") + @ExcludeMissing + fun _maxRedemptions(): JsonField = maxRedemptions + + /** This string can be used to redeem this coupon for a given subscription. */ + @JsonProperty("redemption_code") + @ExcludeMissing + fun _redemptionCode(): JsonField = redemptionCode + + /** The number of times this coupon has been redeemed. */ + @JsonProperty("times_redeemed") + @ExcludeMissing + fun _timesRedeemed(): JsonField = timesRedeemed + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): CouponModel = apply { + if (validated) { + return@apply + } + + id() + archivedAt() + discount().validate() + durationInMonths() + maxRedemptions() + redemptionCode() + timesRedeemed() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CouponModel]. + * + * The following fields are required: + * ```java + * .id() + * .archivedAt() + * .discount() + * .durationInMonths() + * .maxRedemptions() + * .redemptionCode() + * .timesRedeemed() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CouponModel]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var archivedAt: JsonField? = null + private var discount: JsonField? = null + private var durationInMonths: JsonField? = null + private var maxRedemptions: JsonField? = null + private var redemptionCode: JsonField? = null + private var timesRedeemed: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(couponModel: CouponModel) = apply { + id = couponModel.id + archivedAt = couponModel.archivedAt + discount = couponModel.discount + durationInMonths = couponModel.durationInMonths + maxRedemptions = couponModel.maxRedemptions + redemptionCode = couponModel.redemptionCode + timesRedeemed = couponModel.timesRedeemed + additionalProperties = couponModel.additionalProperties.toMutableMap() + } + + /** Also referred to as coupon_id in this documentation. */ + fun id(id: String) = id(JsonField.of(id)) + + /** Also referred to as coupon_id in this documentation. */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * An archived coupon can no longer be redeemed. Active coupons will have a value of null + * for `archived_at`; this field will be non-null for archived coupons. + */ + fun archivedAt(archivedAt: OffsetDateTime?) = archivedAt(JsonField.ofNullable(archivedAt)) + + /** + * An archived coupon can no longer be redeemed. Active coupons will have a value of null + * for `archived_at`; this field will be non-null for archived coupons. + */ + fun archivedAt(archivedAt: Optional) = archivedAt(archivedAt.orElse(null)) + + /** + * An archived coupon can no longer be redeemed. Active coupons will have a value of null + * for `archived_at`; this field will be non-null for archived coupons. + */ + fun archivedAt(archivedAt: JsonField) = apply { + this.archivedAt = archivedAt + } + + fun discount(discount: Discount) = discount(JsonField.of(discount)) + + fun discount(discount: JsonField) = apply { this.discount = discount } + + fun discount(percentage: PercentageDiscount) = discount(Discount.ofPercentage(percentage)) + + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + /** + * This allows for a coupon's discount to apply for a limited time (determined in months); a + * `null` value here means "unlimited time". + */ + fun durationInMonths(durationInMonths: Long?) = + durationInMonths(JsonField.ofNullable(durationInMonths)) + + /** + * This allows for a coupon's discount to apply for a limited time (determined in months); a + * `null` value here means "unlimited time". + */ + fun durationInMonths(durationInMonths: Long) = durationInMonths(durationInMonths as Long?) + + /** + * This allows for a coupon's discount to apply for a limited time (determined in months); a + * `null` value here means "unlimited time". + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun durationInMonths(durationInMonths: Optional) = + durationInMonths(durationInMonths.orElse(null) as Long?) + + /** + * This allows for a coupon's discount to apply for a limited time (determined in months); a + * `null` value here means "unlimited time". + */ + fun durationInMonths(durationInMonths: JsonField) = apply { + this.durationInMonths = durationInMonths + } + + /** + * The maximum number of redemptions allowed for this coupon before it is exhausted; `null` + * here means "unlimited". + */ + fun maxRedemptions(maxRedemptions: Long?) = + maxRedemptions(JsonField.ofNullable(maxRedemptions)) + + /** + * The maximum number of redemptions allowed for this coupon before it is exhausted; `null` + * here means "unlimited". + */ + fun maxRedemptions(maxRedemptions: Long) = maxRedemptions(maxRedemptions as Long?) + + /** + * The maximum number of redemptions allowed for this coupon before it is exhausted; `null` + * here means "unlimited". + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun maxRedemptions(maxRedemptions: Optional) = + maxRedemptions(maxRedemptions.orElse(null) as Long?) + + /** + * The maximum number of redemptions allowed for this coupon before it is exhausted; `null` + * here means "unlimited". + */ + fun maxRedemptions(maxRedemptions: JsonField) = apply { + this.maxRedemptions = maxRedemptions + } + + /** This string can be used to redeem this coupon for a given subscription. */ + fun redemptionCode(redemptionCode: String) = redemptionCode(JsonField.of(redemptionCode)) + + /** This string can be used to redeem this coupon for a given subscription. */ + fun redemptionCode(redemptionCode: JsonField) = apply { + this.redemptionCode = redemptionCode + } + + /** The number of times this coupon has been redeemed. */ + fun timesRedeemed(timesRedeemed: Long) = timesRedeemed(JsonField.of(timesRedeemed)) + + /** The number of times this coupon has been redeemed. */ + fun timesRedeemed(timesRedeemed: JsonField) = apply { + this.timesRedeemed = timesRedeemed + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): CouponModel = + CouponModel( + checkRequired("id", id), + checkRequired("archivedAt", archivedAt), + checkRequired("discount", discount), + checkRequired("durationInMonths", durationInMonths), + checkRequired("maxRedemptions", maxRedemptions), + checkRequired("redemptionCode", redemptionCode), + checkRequired("timesRedeemed", timesRedeemed), + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(using = Discount.Deserializer::class) + @JsonSerialize(using = Discount.Serializer::class) + class Discount + private constructor( + private val percentage: PercentageDiscount? = null, + private val amount: AmountDiscount? = null, + private val _json: JsonValue? = null, + ) { + + fun percentage(): Optional = Optional.ofNullable(percentage) + + fun amount(): Optional = Optional.ofNullable(amount) + + fun isPercentage(): Boolean = percentage != null + + fun isAmount(): Boolean = amount != null + + fun asPercentage(): PercentageDiscount = percentage.getOrThrow("percentage") + + fun asAmount(): AmountDiscount = amount.getOrThrow("amount") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + percentage != null -> visitor.visitPercentage(percentage) + amount != null -> visitor.visitAmount(amount) + else -> visitor.unknown(_json) + } + } + + private var validated: Boolean = false + + fun validate(): Discount = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitPercentage(percentage: PercentageDiscount) { + percentage.validate() + } + + override fun visitAmount(amount: AmountDiscount) { + amount.validate() + } + } + ) + validated = true + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Discount && percentage == other.percentage && amount == other.amount /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(percentage, amount) /* spotless:on */ + + override fun toString(): String = + when { + percentage != null -> "Discount{percentage=$percentage}" + amount != null -> "Discount{amount=$amount}" + _json != null -> "Discount{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Discount") + } + + companion object { + + @JvmStatic + fun ofPercentage(percentage: PercentageDiscount) = Discount(percentage = percentage) + + @JvmStatic fun ofAmount(amount: AmountDiscount) = Discount(amount = amount) + } + + /** + * An interface that defines how to map each variant of [Discount] to a value of type [T]. + */ + interface Visitor { + + fun visitPercentage(percentage: PercentageDiscount): T + + fun visitAmount(amount: AmountDiscount): T + + /** + * Maps an unknown variant of [Discount] to a value of type [T]. + * + * An instance of [Discount] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown Discount: $json") + } + } + + internal class Deserializer : BaseDeserializer(Discount::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Discount { + val json = JsonValue.fromJsonNode(node) + val discountType = + json.asObject().getOrNull()?.get("discount_type")?.asString()?.getOrNull() + + when (discountType) { + "percentage" -> { + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Discount(percentage = it, _json = json) + } + } + "amount" -> { + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Discount(amount = it, _json = json) + } + } + } + + return Discount(_json = json) + } + } + + internal class Serializer : BaseSerializer(Discount::class) { + + override fun serialize( + value: Discount, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.percentage != null -> generator.writeObject(value.percentage) + value.amount != null -> generator.writeObject(value.amount) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Discount") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CouponModel && id == other.id && archivedAt == other.archivedAt && discount == other.discount && durationInMonths == other.durationInMonths && maxRedemptions == other.maxRedemptions && redemptionCode == other.redemptionCode && timesRedeemed == other.timesRedeemed && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, archivedAt, discount, durationInMonths, maxRedemptions, redemptionCode, timesRedeemed, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CouponModel{id=$id, archivedAt=$archivedAt, discount=$discount, durationInMonths=$durationInMonths, maxRedemptions=$maxRedemptions, redemptionCode=$redemptionCode, timesRedeemed=$timesRedeemed, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponRedemptionModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponRedemptionModel.kt new file mode 100644 index 000000000..434f20663 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponRedemptionModel.kt @@ -0,0 +1,159 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class CouponRedemptionModel +@JsonCreator +private constructor( + @JsonProperty("coupon_id") + @ExcludeMissing + private val couponId: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + private val endDate: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + private val startDate: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun couponId(): String = couponId.getRequired("coupon_id") + + fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) + + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + @JsonProperty("coupon_id") @ExcludeMissing fun _couponId(): JsonField = couponId + + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): CouponRedemptionModel = apply { + if (validated) { + return@apply + } + + couponId() + endDate() + startDate() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CouponRedemptionModel]. + * + * The following fields are required: + * ```java + * .couponId() + * .endDate() + * .startDate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CouponRedemptionModel]. */ + class Builder internal constructor() { + + private var couponId: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(couponRedemptionModel: CouponRedemptionModel) = apply { + couponId = couponRedemptionModel.couponId + endDate = couponRedemptionModel.endDate + startDate = couponRedemptionModel.startDate + additionalProperties = couponRedemptionModel.additionalProperties.toMutableMap() + } + + fun couponId(couponId: String) = couponId(JsonField.of(couponId)) + + fun couponId(couponId: JsonField) = apply { this.couponId = couponId } + + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) + + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + 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) + } + + fun build(): CouponRedemptionModel = + CouponRedemptionModel( + checkRequired("couponId", couponId), + checkRequired("endDate", endDate), + checkRequired("startDate", startDate), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CouponRedemptionModel && couponId == other.couponId && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(couponId, endDate, startDate, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CouponRedemptionModel{couponId=$couponId, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPage.kt index 63dee1ce0..75bbeceeb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPage.kt @@ -34,7 +34,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -92,20 +92,21 @@ private constructor( class Response @JsonCreator constructor( - @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), + @JsonProperty("data") + private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = Optional.ofNullable(data) + fun _data(): Optional>> = Optional.ofNullable(data) @JsonProperty("pagination_metadata") fun _paginationMetadata(): Optional> = @@ -144,12 +145,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [CouponSubscriptionListPage]. + */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -160,9 +165,9 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { this.data = data } fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) @@ -179,9 +184,10 @@ private constructor( } } - class AutoPager(private val firstPage: CouponSubscriptionListPage) : Iterable { + class AutoPager(private val firstPage: CouponSubscriptionListPage) : + Iterable { - override fun iterator(): Iterator = iterator { + override fun iterator(): Iterator = iterator { var page = firstPage var index = 0 while (true) { @@ -193,7 +199,7 @@ private constructor( } } - fun stream(): Stream { + fun stream(): Stream { return StreamSupport.stream(spliterator(), false) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPageAsync.kt index e9fb4c04d..e1965d2aa 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListPageAsync.kt @@ -35,7 +35,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -95,20 +95,21 @@ private constructor( class Response @JsonCreator constructor( - @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), + @JsonProperty("data") + private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = Optional.ofNullable(data) + fun _data(): Optional>> = Optional.ofNullable(data) @JsonProperty("pagination_metadata") fun _paginationMetadata(): Optional> = @@ -147,12 +148,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [CouponSubscriptionListPageAsync]. + */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -163,9 +168,9 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { this.data = data } fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) @@ -184,9 +189,12 @@ private constructor( class AutoPager(private val firstPage: CouponSubscriptionListPageAsync) { - fun forEach(action: Predicate, executor: Executor): CompletableFuture { + fun forEach( + action: Predicate, + executor: Executor, + ): CompletableFuture { fun CompletableFuture>.forEach( - action: (Subscription) -> Boolean, + action: (SubscriptionModel) -> Boolean, executor: Executor, ): CompletableFuture = thenComposeAsync( @@ -202,8 +210,8 @@ private constructor( .forEach(action::test, executor) } - fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() + fun toList(executor: Executor): CompletableFuture> { + val values = mutableListOf() return forEach(values::add, executor).thenApply { values } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListParams.kt index 4abb23501..886608b5d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListParams.kt @@ -61,6 +61,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [CouponSubscriptionListParams]. + * + * The following fields are required: + * ```java + * .couponId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreateCustomerAlertRequest.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreateCustomerAlertRequest.kt new file mode 100644 index 000000000..298013ca4 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreateCustomerAlertRequest.kt @@ -0,0 +1,300 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class CreateCustomerAlertRequest +@JsonCreator +private constructor( + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonProperty("thresholds") + @ExcludeMissing + private val thresholds: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** The case sensitive currency or custom pricing unit to use for this alert. */ + fun currency(): String = currency.getRequired("currency") + + /** The type of alert to create. This must be a valid alert type. */ + fun type(): Type = type.getRequired("type") + + /** The thresholds that define the values at which the alert will be triggered. */ + fun thresholds(): Optional> = + Optional.ofNullable(thresholds.getNullable("thresholds")) + + /** The case sensitive currency or custom pricing unit to use for this alert. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** The type of alert to create. This must be a valid alert type. */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** The thresholds that define the values at which the alert will be triggered. */ + @JsonProperty("thresholds") + @ExcludeMissing + fun _thresholds(): JsonField> = thresholds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): CreateCustomerAlertRequest = apply { + if (validated) { + return@apply + } + + currency() + type() + thresholds().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CreateCustomerAlertRequest]. + * + * The following fields are required: + * ```java + * .currency() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreateCustomerAlertRequest]. */ + class Builder internal constructor() { + + private var currency: JsonField? = null + private var type: JsonField? = null + private var thresholds: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(createCustomerAlertRequest: CreateCustomerAlertRequest) = apply { + currency = createCustomerAlertRequest.currency + type = createCustomerAlertRequest.type + thresholds = createCustomerAlertRequest.thresholds.map { it.toMutableList() } + additionalProperties = createCustomerAlertRequest.additionalProperties.toMutableMap() + } + + /** The case sensitive currency or custom pricing unit to use for this alert. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** The case sensitive currency or custom pricing unit to use for this alert. */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The type of alert to create. This must be a valid alert type. */ + fun type(type: Type) = type(JsonField.of(type)) + + /** The type of alert to create. This must be a valid alert type. */ + fun type(type: JsonField) = apply { this.type = type } + + /** The thresholds that define the values at which the alert will be triggered. */ + fun thresholds(thresholds: List?) = + thresholds(JsonField.ofNullable(thresholds)) + + /** The thresholds that define the values at which the alert will be triggered. */ + fun thresholds(thresholds: Optional>) = + thresholds(thresholds.orElse(null)) + + /** The thresholds that define the values at which the alert will be triggered. */ + fun thresholds(thresholds: JsonField>) = apply { + this.thresholds = thresholds.map { it.toMutableList() } + } + + /** The thresholds that define the values at which the alert will be triggered. */ + fun addThreshold(threshold: ThresholdModel) = 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) + } + + fun build(): CreateCustomerAlertRequest = + CreateCustomerAlertRequest( + checkRequired("currency", currency), + checkRequired("type", type), + (thresholds ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + /** The type of alert to create. This must be a valid alert type. */ + 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 USAGE_EXCEEDED = of("usage_exceeded") + + @JvmField val COST_EXCEEDED = of("cost_exceeded") + + @JvmField val CREDIT_BALANCE_DEPLETED = of("credit_balance_depleted") + + @JvmField val CREDIT_BALANCE_DROPPED = of("credit_balance_dropped") + + @JvmField val CREDIT_BALANCE_RECOVERED = of("credit_balance_recovered") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + USAGE_EXCEEDED, + COST_EXCEEDED, + CREDIT_BALANCE_DEPLETED, + CREDIT_BALANCE_DROPPED, + CREDIT_BALANCE_RECOVERED, + } + + /** + * 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 { + USAGE_EXCEEDED, + COST_EXCEEDED, + CREDIT_BALANCE_DEPLETED, + CREDIT_BALANCE_DROPPED, + CREDIT_BALANCE_RECOVERED, + /** 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) { + USAGE_EXCEEDED -> Value.USAGE_EXCEEDED + COST_EXCEEDED -> Value.COST_EXCEEDED + CREDIT_BALANCE_DEPLETED -> Value.CREDIT_BALANCE_DEPLETED + CREDIT_BALANCE_DROPPED -> Value.CREDIT_BALANCE_DROPPED + CREDIT_BALANCE_RECOVERED -> Value.CREDIT_BALANCE_RECOVERED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to 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_EXCEEDED -> Known.USAGE_EXCEEDED + COST_EXCEEDED -> Known.COST_EXCEEDED + CREDIT_BALANCE_DEPLETED -> Known.CREDIT_BALANCE_DEPLETED + CREDIT_BALANCE_DROPPED -> Known.CREDIT_BALANCE_DROPPED + CREDIT_BALANCE_RECOVERED -> Known.CREDIT_BALANCE_RECOVERED + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CreateCustomerAlertRequest && currency == other.currency && type == other.type && thresholds == other.thresholds && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(currency, type, thresholds, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CreateCustomerAlertRequest{currency=$currency, type=$type, thresholds=$thresholds, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditLedgerEntriesModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditLedgerEntriesModel.kt new file mode 100644 index 000000000..e48edca4a --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditLedgerEntriesModel.kt @@ -0,0 +1,180 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects + +@NoAutoDetect +class CreditLedgerEntriesModel +@JsonCreator +private constructor( + @JsonProperty("data") + @ExcludeMissing + private val data: JsonField> = JsonMissing.of(), + @JsonProperty("pagination_metadata") + @ExcludeMissing + private val paginationMetadata: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun data(): List = data.getRequired("data") + + fun paginationMetadata(): PaginationMetadata = + paginationMetadata.getRequired("pagination_metadata") + + @JsonProperty("data") + @ExcludeMissing + fun _data(): JsonField> = data + + @JsonProperty("pagination_metadata") + @ExcludeMissing + fun _paginationMetadata(): JsonField = paginationMetadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): CreditLedgerEntriesModel = apply { + if (validated) { + return@apply + } + + data().forEach { it.validate() } + paginationMetadata().validate() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CreditLedgerEntriesModel]. + * + * The following fields are required: + * ```java + * .data() + * .paginationMetadata() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreditLedgerEntriesModel]. */ + class Builder internal constructor() { + + private var data: JsonField>? = null + private var paginationMetadata: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(creditLedgerEntriesModel: CreditLedgerEntriesModel) = apply { + data = creditLedgerEntriesModel.data.map { it.toMutableList() } + paginationMetadata = creditLedgerEntriesModel.paginationMetadata + additionalProperties = creditLedgerEntriesModel.additionalProperties.toMutableMap() + } + + fun data(data: List) = data(JsonField.of(data)) + + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + fun addData(data: CreditLedgerEntryModel) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) + } + } + + fun addData(incrementLedgerEntry: CreditLedgerEntryModel.IncrementLedgerEntry) = + addData(CreditLedgerEntryModel.ofIncrementLedgerEntry(incrementLedgerEntry)) + + fun addData(decrementLedgerEntry: CreditLedgerEntryModel.DecrementLedgerEntry) = + addData(CreditLedgerEntryModel.ofDecrementLedgerEntry(decrementLedgerEntry)) + + fun addData( + expirationChangeLedgerEntry: CreditLedgerEntryModel.ExpirationChangeLedgerEntry + ) = + addData( + CreditLedgerEntryModel.ofExpirationChangeLedgerEntry(expirationChangeLedgerEntry) + ) + + fun addData(blockExpiryLedgerEntry: CreditLedgerEntryModel.CreditBlockExpiryLedgerEntry) = + addData(CreditLedgerEntryModel.ofBlockExpiryLedgerEntry(blockExpiryLedgerEntry)) + + fun addData(voidLedgerEntry: CreditLedgerEntryModel.VoidLedgerEntry) = + addData(CreditLedgerEntryModel.ofVoidLedgerEntry(voidLedgerEntry)) + + fun addData(voidInitiatedLedgerEntry: CreditLedgerEntryModel.VoidInitiatedLedgerEntry) = + addData(CreditLedgerEntryModel.ofVoidInitiatedLedgerEntry(voidInitiatedLedgerEntry)) + + fun addData(amendmentLedgerEntry: CreditLedgerEntryModel.AmendmentLedgerEntry) = + addData(CreditLedgerEntryModel.ofAmendmentLedgerEntry(amendmentLedgerEntry)) + + fun paginationMetadata(paginationMetadata: PaginationMetadata) = + paginationMetadata(JsonField.of(paginationMetadata)) + + 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) + } + + fun build(): CreditLedgerEntriesModel = + CreditLedgerEntriesModel( + checkRequired("data", data).map { it.toImmutable() }, + checkRequired("paginationMetadata", paginationMetadata), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CreditLedgerEntriesModel && data == other.data && paginationMetadata == other.paginationMetadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(data, paginationMetadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CreditLedgerEntriesModel{data=$data, paginationMetadata=$paginationMetadata, additionalProperties=$additionalProperties}" +} 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/CreditLedgerEntryModel.kt similarity index 69% rename from orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponse.kt rename to orb-java-core/src/main/kotlin/com/withorb/api/models/CreditLedgerEntryModel.kt index 01811c3fb..f3455ee0b 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/CreditLedgerEntryModel.kt @@ -35,14 +35,14 @@ import kotlin.jvm.optionals.getOrNull * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within * Orb. */ -@JsonDeserialize(using = CustomerCreditLedgerListResponse.Deserializer::class) -@JsonSerialize(using = CustomerCreditLedgerListResponse.Serializer::class) -class CustomerCreditLedgerListResponse +@JsonDeserialize(using = CreditLedgerEntryModel.Deserializer::class) +@JsonSerialize(using = CreditLedgerEntryModel.Serializer::class) +class CreditLedgerEntryModel private constructor( private val incrementLedgerEntry: IncrementLedgerEntry? = null, private val decrementLedgerEntry: DecrementLedgerEntry? = null, private val expirationChangeLedgerEntry: ExpirationChangeLedgerEntry? = null, - private val creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry? = null, + private val blockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry? = null, private val voidLedgerEntry: VoidLedgerEntry? = null, private val voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry? = null, private val amendmentLedgerEntry: AmendmentLedgerEntry? = null, @@ -58,8 +58,8 @@ private constructor( fun expirationChangeLedgerEntry(): Optional = Optional.ofNullable(expirationChangeLedgerEntry) - fun creditBlockExpiryLedgerEntry(): Optional = - Optional.ofNullable(creditBlockExpiryLedgerEntry) + fun blockExpiryLedgerEntry(): Optional = + Optional.ofNullable(blockExpiryLedgerEntry) fun voidLedgerEntry(): Optional = Optional.ofNullable(voidLedgerEntry) @@ -75,7 +75,7 @@ private constructor( fun isExpirationChangeLedgerEntry(): Boolean = expirationChangeLedgerEntry != null - fun isCreditBlockExpiryLedgerEntry(): Boolean = creditBlockExpiryLedgerEntry != null + fun isBlockExpiryLedgerEntry(): Boolean = blockExpiryLedgerEntry != null fun isVoidLedgerEntry(): Boolean = voidLedgerEntry != null @@ -92,8 +92,8 @@ private constructor( fun asExpirationChangeLedgerEntry(): ExpirationChangeLedgerEntry = expirationChangeLedgerEntry.getOrThrow("expirationChangeLedgerEntry") - fun asCreditBlockExpiryLedgerEntry(): CreditBlockExpiryLedgerEntry = - creditBlockExpiryLedgerEntry.getOrThrow("creditBlockExpiryLedgerEntry") + fun asBlockExpiryLedgerEntry(): CreditBlockExpiryLedgerEntry = + blockExpiryLedgerEntry.getOrThrow("blockExpiryLedgerEntry") fun asVoidLedgerEntry(): VoidLedgerEntry = voidLedgerEntry.getOrThrow("voidLedgerEntry") @@ -111,8 +111,8 @@ private constructor( decrementLedgerEntry != null -> visitor.visitDecrementLedgerEntry(decrementLedgerEntry) expirationChangeLedgerEntry != null -> visitor.visitExpirationChangeLedgerEntry(expirationChangeLedgerEntry) - creditBlockExpiryLedgerEntry != null -> - visitor.visitCreditBlockExpiryLedgerEntry(creditBlockExpiryLedgerEntry) + blockExpiryLedgerEntry != null -> + visitor.visitBlockExpiryLedgerEntry(blockExpiryLedgerEntry) voidLedgerEntry != null -> visitor.visitVoidLedgerEntry(voidLedgerEntry) voidInitiatedLedgerEntry != null -> visitor.visitVoidInitiatedLedgerEntry(voidInitiatedLedgerEntry) @@ -123,7 +123,7 @@ private constructor( private var validated: Boolean = false - fun validate(): CustomerCreditLedgerListResponse = apply { + fun validate(): CreditLedgerEntryModel = apply { if (validated) { return@apply } @@ -144,10 +144,10 @@ private constructor( expirationChangeLedgerEntry.validate() } - override fun visitCreditBlockExpiryLedgerEntry( - creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry + override fun visitBlockExpiryLedgerEntry( + blockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry ) { - creditBlockExpiryLedgerEntry.validate() + blockExpiryLedgerEntry.validate() } override fun visitVoidLedgerEntry(voidLedgerEntry: VoidLedgerEntry) { @@ -173,73 +173,65 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditLedgerListResponse && incrementLedgerEntry == other.incrementLedgerEntry && decrementLedgerEntry == other.decrementLedgerEntry && expirationChangeLedgerEntry == other.expirationChangeLedgerEntry && creditBlockExpiryLedgerEntry == other.creditBlockExpiryLedgerEntry && voidLedgerEntry == other.voidLedgerEntry && voidInitiatedLedgerEntry == other.voidInitiatedLedgerEntry && amendmentLedgerEntry == other.amendmentLedgerEntry /* spotless:on */ + return /* spotless:off */ other is CreditLedgerEntryModel && incrementLedgerEntry == other.incrementLedgerEntry && decrementLedgerEntry == other.decrementLedgerEntry && expirationChangeLedgerEntry == other.expirationChangeLedgerEntry && blockExpiryLedgerEntry == other.blockExpiryLedgerEntry && voidLedgerEntry == other.voidLedgerEntry && voidInitiatedLedgerEntry == other.voidInitiatedLedgerEntry && amendmentLedgerEntry == other.amendmentLedgerEntry /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(incrementLedgerEntry, decrementLedgerEntry, expirationChangeLedgerEntry, creditBlockExpiryLedgerEntry, voidLedgerEntry, voidInitiatedLedgerEntry, amendmentLedgerEntry) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(incrementLedgerEntry, decrementLedgerEntry, expirationChangeLedgerEntry, blockExpiryLedgerEntry, voidLedgerEntry, voidInitiatedLedgerEntry, amendmentLedgerEntry) /* spotless:on */ override fun toString(): String = when { incrementLedgerEntry != null -> - "CustomerCreditLedgerListResponse{incrementLedgerEntry=$incrementLedgerEntry}" + "CreditLedgerEntryModel{incrementLedgerEntry=$incrementLedgerEntry}" decrementLedgerEntry != null -> - "CustomerCreditLedgerListResponse{decrementLedgerEntry=$decrementLedgerEntry}" + "CreditLedgerEntryModel{decrementLedgerEntry=$decrementLedgerEntry}" expirationChangeLedgerEntry != null -> - "CustomerCreditLedgerListResponse{expirationChangeLedgerEntry=$expirationChangeLedgerEntry}" - creditBlockExpiryLedgerEntry != null -> - "CustomerCreditLedgerListResponse{creditBlockExpiryLedgerEntry=$creditBlockExpiryLedgerEntry}" - voidLedgerEntry != null -> - "CustomerCreditLedgerListResponse{voidLedgerEntry=$voidLedgerEntry}" + "CreditLedgerEntryModel{expirationChangeLedgerEntry=$expirationChangeLedgerEntry}" + blockExpiryLedgerEntry != null -> + "CreditLedgerEntryModel{blockExpiryLedgerEntry=$blockExpiryLedgerEntry}" + voidLedgerEntry != null -> "CreditLedgerEntryModel{voidLedgerEntry=$voidLedgerEntry}" voidInitiatedLedgerEntry != null -> - "CustomerCreditLedgerListResponse{voidInitiatedLedgerEntry=$voidInitiatedLedgerEntry}" + "CreditLedgerEntryModel{voidInitiatedLedgerEntry=$voidInitiatedLedgerEntry}" amendmentLedgerEntry != null -> - "CustomerCreditLedgerListResponse{amendmentLedgerEntry=$amendmentLedgerEntry}" - _json != null -> "CustomerCreditLedgerListResponse{_unknown=$_json}" - else -> throw IllegalStateException("Invalid CustomerCreditLedgerListResponse") + "CreditLedgerEntryModel{amendmentLedgerEntry=$amendmentLedgerEntry}" + _json != null -> "CreditLedgerEntryModel{_unknown=$_json}" + else -> throw IllegalStateException("Invalid CreditLedgerEntryModel") } companion object { @JvmStatic fun ofIncrementLedgerEntry(incrementLedgerEntry: IncrementLedgerEntry) = - CustomerCreditLedgerListResponse(incrementLedgerEntry = incrementLedgerEntry) + CreditLedgerEntryModel(incrementLedgerEntry = incrementLedgerEntry) @JvmStatic fun ofDecrementLedgerEntry(decrementLedgerEntry: DecrementLedgerEntry) = - CustomerCreditLedgerListResponse(decrementLedgerEntry = decrementLedgerEntry) + CreditLedgerEntryModel(decrementLedgerEntry = decrementLedgerEntry) @JvmStatic fun ofExpirationChangeLedgerEntry( expirationChangeLedgerEntry: ExpirationChangeLedgerEntry - ) = - CustomerCreditLedgerListResponse( - expirationChangeLedgerEntry = expirationChangeLedgerEntry - ) + ) = CreditLedgerEntryModel(expirationChangeLedgerEntry = expirationChangeLedgerEntry) @JvmStatic - fun ofCreditBlockExpiryLedgerEntry( - creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry - ) = - CustomerCreditLedgerListResponse( - creditBlockExpiryLedgerEntry = creditBlockExpiryLedgerEntry - ) + fun ofBlockExpiryLedgerEntry(blockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry) = + CreditLedgerEntryModel(blockExpiryLedgerEntry = blockExpiryLedgerEntry) @JvmStatic fun ofVoidLedgerEntry(voidLedgerEntry: VoidLedgerEntry) = - CustomerCreditLedgerListResponse(voidLedgerEntry = voidLedgerEntry) + CreditLedgerEntryModel(voidLedgerEntry = voidLedgerEntry) @JvmStatic fun ofVoidInitiatedLedgerEntry(voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry) = - CustomerCreditLedgerListResponse(voidInitiatedLedgerEntry = voidInitiatedLedgerEntry) + CreditLedgerEntryModel(voidInitiatedLedgerEntry = voidInitiatedLedgerEntry) @JvmStatic fun ofAmendmentLedgerEntry(amendmentLedgerEntry: AmendmentLedgerEntry) = - CustomerCreditLedgerListResponse(amendmentLedgerEntry = amendmentLedgerEntry) + CreditLedgerEntryModel(amendmentLedgerEntry = amendmentLedgerEntry) } /** - * An interface that defines how to map each variant of [CustomerCreditLedgerListResponse] to a - * value of type [T]. + * An interface that defines how to map each variant of [CreditLedgerEntryModel] to a value of + * type [T]. */ interface Visitor { @@ -251,9 +243,7 @@ private constructor( expirationChangeLedgerEntry: ExpirationChangeLedgerEntry ): T - fun visitCreditBlockExpiryLedgerEntry( - creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry - ): T + fun visitBlockExpiryLedgerEntry(blockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry): T fun visitVoidLedgerEntry(voidLedgerEntry: VoidLedgerEntry): T @@ -262,26 +252,24 @@ private constructor( fun visitAmendmentLedgerEntry(amendmentLedgerEntry: AmendmentLedgerEntry): T /** - * Maps an unknown variant of [CustomerCreditLedgerListResponse] to a value of type [T]. + * Maps an unknown variant of [CreditLedgerEntryModel] to a value of type [T]. * - * An instance of [CustomerCreditLedgerListResponse] can contain an unknown variant if it - * was deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An instance of [CreditLedgerEntryModel] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the SDK is + * on an older version than the API, then the API may respond with new variants that the SDK + * is unaware of. * * @throws OrbInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown CustomerCreditLedgerListResponse: $json") + throw OrbInvalidDataException("Unknown CreditLedgerEntryModel: $json") } } internal class Deserializer : - BaseDeserializer( - CustomerCreditLedgerListResponse::class - ) { + BaseDeserializer(CreditLedgerEntryModel::class) { - override fun ObjectCodec.deserialize(node: JsonNode): CustomerCreditLedgerListResponse { + override fun ObjectCodec.deserialize(node: JsonNode): CreditLedgerEntryModel { val json = JsonValue.fromJsonNode(node) val entryType = json.asObject().getOrNull()?.get("entry_type")?.asString()?.getOrNull() @@ -289,19 +277,13 @@ private constructor( "increment" -> { tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return CustomerCreditLedgerListResponse( - incrementLedgerEntry = it, - _json = json, - ) + return CreditLedgerEntryModel(incrementLedgerEntry = it, _json = json) } } "decrement" -> { tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return CustomerCreditLedgerListResponse( - decrementLedgerEntry = it, - _json = json, - ) + return CreditLedgerEntryModel(decrementLedgerEntry = it, _json = json) } } "expiration_change" -> { @@ -309,7 +291,7 @@ private constructor( it.validate() } ?.let { - return CustomerCreditLedgerListResponse( + return CreditLedgerEntryModel( expirationChangeLedgerEntry = it, _json = json, ) @@ -320,19 +302,13 @@ private constructor( it.validate() } ?.let { - return CustomerCreditLedgerListResponse( - creditBlockExpiryLedgerEntry = it, - _json = json, - ) + return CreditLedgerEntryModel(blockExpiryLedgerEntry = it, _json = json) } } "void" -> { tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return CustomerCreditLedgerListResponse( - voidLedgerEntry = it, - _json = json, - ) + return CreditLedgerEntryModel(voidLedgerEntry = it, _json = json) } } "void_initiated" -> { @@ -340,7 +316,7 @@ private constructor( it.validate() } ?.let { - return CustomerCreditLedgerListResponse( + return CreditLedgerEntryModel( voidInitiatedLedgerEntry = it, _json = json, ) @@ -349,23 +325,20 @@ private constructor( "amendment" -> { tryDeserialize(node, jacksonTypeRef()) { it.validate() } ?.let { - return CustomerCreditLedgerListResponse( - amendmentLedgerEntry = it, - _json = json, - ) + return CreditLedgerEntryModel(amendmentLedgerEntry = it, _json = json) } } } - return CustomerCreditLedgerListResponse(_json = json) + return CreditLedgerEntryModel(_json = json) } } internal class Serializer : - BaseSerializer(CustomerCreditLedgerListResponse::class) { + BaseSerializer(CreditLedgerEntryModel::class) { override fun serialize( - value: CustomerCreditLedgerListResponse, + value: CreditLedgerEntryModel, generator: JsonGenerator, provider: SerializerProvider, ) { @@ -376,15 +349,15 @@ private constructor( generator.writeObject(value.decrementLedgerEntry) value.expirationChangeLedgerEntry != null -> generator.writeObject(value.expirationChangeLedgerEntry) - value.creditBlockExpiryLedgerEntry != null -> - generator.writeObject(value.creditBlockExpiryLedgerEntry) + value.blockExpiryLedgerEntry != null -> + generator.writeObject(value.blockExpiryLedgerEntry) value.voidLedgerEntry != null -> generator.writeObject(value.voidLedgerEntry) value.voidInitiatedLedgerEntry != null -> generator.writeObject(value.voidInitiatedLedgerEntry) value.amendmentLedgerEntry != null -> generator.writeObject(value.amendmentLedgerEntry) value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid CustomerCreditLedgerListResponse") + else -> throw IllegalStateException("Invalid CreditLedgerEntryModel") } } } @@ -402,13 +375,13 @@ private constructor( private val createdAt: JsonField = JsonMissing.of(), @JsonProperty("credit_block") @ExcludeMissing - private val creditBlock: JsonField = JsonMissing.of(), + private val creditBlock: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing private val currency: JsonField = JsonMissing.of(), @JsonProperty("customer") @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), + private val customer: JsonField = JsonMissing.of(), @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), @@ -440,11 +413,11 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - fun creditBlock(): CreditBlock = creditBlock.getRequired("credit_block") + fun creditBlock(): AffectedBlockModel = creditBlock.getRequired("credit_block") fun currency(): String = currency.getRequired("currency") - fun customer(): Customer = customer.getRequired("customer") + fun customer(): CustomerMinifiedModel = customer.getRequired("customer") fun description(): Optional = Optional.ofNullable(description.getNullable("description")) @@ -477,11 +450,13 @@ private constructor( @JsonProperty("credit_block") @ExcludeMissing - fun _creditBlock(): JsonField = creditBlock + fun _creditBlock(): JsonField = creditBlock @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer + @JsonProperty("customer") + @ExcludeMissing + fun _customer(): JsonField = customer @JsonProperty("description") @ExcludeMissing @@ -545,6 +520,26 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [IncrementLedgerEntry]. + * + * The following fields are required: + * ```java + * .id() + * .amount() + * .createdAt() + * .creditBlock() + * .currency() + * .customer() + * .description() + * .endingBalance() + * .entryStatus() + * .entryType() + * .ledgerSequenceNumber() + * .metadata() + * .startingBalance() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -554,9 +549,9 @@ private constructor( private var id: JsonField? = null private var amount: JsonField? = null private var createdAt: JsonField? = null - private var creditBlock: JsonField? = null + private var creditBlock: JsonField? = null private var currency: JsonField? = null - private var customer: JsonField? = null + private var customer: JsonField? = null private var description: JsonField? = null private var endingBalance: JsonField? = null private var entryStatus: JsonField? = null @@ -598,9 +593,10 @@ private constructor( this.createdAt = createdAt } - fun creditBlock(creditBlock: CreditBlock) = creditBlock(JsonField.of(creditBlock)) + fun creditBlock(creditBlock: AffectedBlockModel) = + creditBlock(JsonField.of(creditBlock)) - fun creditBlock(creditBlock: JsonField) = apply { + fun creditBlock(creditBlock: JsonField) = apply { this.creditBlock = creditBlock } @@ -608,9 +604,11 @@ private constructor( fun currency(currency: JsonField) = apply { this.currency = currency } - fun customer(customer: Customer) = customer(JsonField.of(customer)) + fun customer(customer: CustomerMinifiedModel) = customer(JsonField.of(customer)) - fun customer(customer: JsonField) = apply { this.customer = customer } + fun customer(customer: JsonField) = apply { + this.customer = customer + } fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -702,278 +700,6 @@ private constructor( ) } - @NoAutoDetect - class CreditBlock - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("expiry_date") - @ExcludeMissing - private val expiryDate: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - private val perUnitCostBasis: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun expiryDate(): Optional = - Optional.ofNullable(expiryDate.getNullable("expiry_date")) - - fun perUnitCostBasis(): Optional = - Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("expiry_date") - @ExcludeMissing - fun _expiryDate(): JsonField = expiryDate - - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - fun _perUnitCostBasis(): JsonField = perUnitCostBasis - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditBlock = apply { - if (validated) { - return@apply - } - - id() - expiryDate() - perUnitCostBasis() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditBlock]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var expiryDate: JsonField? = null - private var perUnitCostBasis: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditBlock: CreditBlock) = apply { - id = creditBlock.id - expiryDate = creditBlock.expiryDate - perUnitCostBasis = creditBlock.perUnitCostBasis - additionalProperties = creditBlock.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun expiryDate(expiryDate: OffsetDateTime?) = - expiryDate(JsonField.ofNullable(expiryDate)) - - fun expiryDate(expiryDate: Optional) = - expiryDate(expiryDate.orElse(null)) - - fun expiryDate(expiryDate: JsonField) = apply { - this.expiryDate = expiryDate - } - - fun perUnitCostBasis(perUnitCostBasis: String?) = - perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) - - fun perUnitCostBasis(perUnitCostBasis: Optional) = - perUnitCostBasis(perUnitCostBasis.orElse(null)) - - fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { - this.perUnitCostBasis = perUnitCostBasis - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditBlock = - CreditBlock( - checkRequired("id", id), - checkRequired("expiryDate", expiryDate), - checkRequired("perUnitCostBasis", perUnitCostBasis), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditBlock && id == other.id && expiryDate == other.expiryDate && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, expiryDate, perUnitCostBasis, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditBlock{id=$id, expiryDate=$expiryDate, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Customer - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("external_customer_id") - @ExcludeMissing - private val externalCustomerId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun externalCustomerId(): Optional = - Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("external_customer_id") - @ExcludeMissing - fun _externalCustomerId(): JsonField = externalCustomerId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Customer = apply { - if (validated) { - return@apply - } - - id() - externalCustomerId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Customer]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var externalCustomerId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customer: Customer) = apply { - id = customer.id - externalCustomerId = customer.externalCustomerId - additionalProperties = customer.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun externalCustomerId(externalCustomerId: String?) = - externalCustomerId(JsonField.ofNullable(externalCustomerId)) - - fun externalCustomerId(externalCustomerId: Optional) = - externalCustomerId(externalCustomerId.orElse(null)) - - fun externalCustomerId(externalCustomerId: JsonField) = apply { - this.externalCustomerId = externalCustomerId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Customer = - Customer( - checkRequired("id", id), - checkRequired("externalCustomerId", externalCustomerId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Customer && id == other.id && externalCustomerId == other.externalCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, externalCustomerId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Customer{id=$id, externalCustomerId=$externalCustomerId, additionalProperties=$additionalProperties}" - } - class EntryStatus @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -1203,6 +929,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } @@ -1289,13 +1016,13 @@ private constructor( private val createdAt: JsonField = JsonMissing.of(), @JsonProperty("credit_block") @ExcludeMissing - private val creditBlock: JsonField = JsonMissing.of(), + private val creditBlock: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing private val currency: JsonField = JsonMissing.of(), @JsonProperty("customer") @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), + private val customer: JsonField = JsonMissing.of(), @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), @@ -1336,11 +1063,11 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - fun creditBlock(): CreditBlock = creditBlock.getRequired("credit_block") + fun creditBlock(): AffectedBlockModel = creditBlock.getRequired("credit_block") fun currency(): String = currency.getRequired("currency") - fun customer(): Customer = customer.getRequired("customer") + fun customer(): CustomerMinifiedModel = customer.getRequired("customer") fun description(): Optional = Optional.ofNullable(description.getNullable("description")) @@ -1379,11 +1106,13 @@ private constructor( @JsonProperty("credit_block") @ExcludeMissing - fun _creditBlock(): JsonField = creditBlock + fun _creditBlock(): JsonField = creditBlock @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer + @JsonProperty("customer") + @ExcludeMissing + fun _customer(): JsonField = customer @JsonProperty("description") @ExcludeMissing @@ -1456,6 +1185,26 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [DecrementLedgerEntry]. + * + * The following fields are required: + * ```java + * .id() + * .amount() + * .createdAt() + * .creditBlock() + * .currency() + * .customer() + * .description() + * .endingBalance() + * .entryStatus() + * .entryType() + * .ledgerSequenceNumber() + * .metadata() + * .startingBalance() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1465,9 +1214,9 @@ private constructor( private var id: JsonField? = null private var amount: JsonField? = null private var createdAt: JsonField? = null - private var creditBlock: JsonField? = null + private var creditBlock: JsonField? = null private var currency: JsonField? = null - private var customer: JsonField? = null + private var customer: JsonField? = null private var description: JsonField? = null private var endingBalance: JsonField? = null private var entryStatus: JsonField? = null @@ -1515,9 +1264,10 @@ private constructor( this.createdAt = createdAt } - fun creditBlock(creditBlock: CreditBlock) = creditBlock(JsonField.of(creditBlock)) + fun creditBlock(creditBlock: AffectedBlockModel) = + creditBlock(JsonField.of(creditBlock)) - fun creditBlock(creditBlock: JsonField) = apply { + fun creditBlock(creditBlock: JsonField) = apply { this.creditBlock = creditBlock } @@ -1525,9 +1275,11 @@ private constructor( fun currency(currency: JsonField) = apply { this.currency = currency } - fun customer(customer: Customer) = customer(JsonField.of(customer)) + fun customer(customer: CustomerMinifiedModel) = customer(JsonField.of(customer)) - fun customer(customer: JsonField) = apply { this.customer = customer } + fun customer(customer: JsonField) = apply { + this.customer = customer + } fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -1640,304 +1392,32 @@ private constructor( ) } - @NoAutoDetect - class CreditBlock - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("expiry_date") - @ExcludeMissing - private val expiryDate: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - private val perUnitCostBasis: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun expiryDate(): Optional = - Optional.ofNullable(expiryDate.getNullable("expiry_date")) - - fun perUnitCostBasis(): Optional = - Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("expiry_date") - @ExcludeMissing - fun _expiryDate(): JsonField = expiryDate + class EntryStatus @JsonCreator private constructor(private val value: JsonField) : + Enum { - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - fun _perUnitCostBasis(): JsonField = perUnitCostBasis + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + companion object { - private var validated: Boolean = false + @JvmField val COMMITTED = of("committed") - fun validate(): CreditBlock = apply { - if (validated) { - return@apply - } + @JvmField val PENDING = of("pending") - id() - expiryDate() - perUnitCostBasis() - validated = true + @JvmStatic fun of(value: String) = EntryStatus(JsonField.of(value)) } - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditBlock]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var expiryDate: JsonField? = null - private var perUnitCostBasis: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditBlock: CreditBlock) = apply { - id = creditBlock.id - expiryDate = creditBlock.expiryDate - perUnitCostBasis = creditBlock.perUnitCostBasis - additionalProperties = creditBlock.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun expiryDate(expiryDate: OffsetDateTime?) = - expiryDate(JsonField.ofNullable(expiryDate)) - - fun expiryDate(expiryDate: Optional) = - expiryDate(expiryDate.orElse(null)) - - fun expiryDate(expiryDate: JsonField) = apply { - this.expiryDate = expiryDate - } - - fun perUnitCostBasis(perUnitCostBasis: String?) = - perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) - - fun perUnitCostBasis(perUnitCostBasis: Optional) = - perUnitCostBasis(perUnitCostBasis.orElse(null)) - - fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { - this.perUnitCostBasis = perUnitCostBasis - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditBlock = - CreditBlock( - checkRequired("id", id), - checkRequired("expiryDate", expiryDate), - checkRequired("perUnitCostBasis", perUnitCostBasis), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditBlock && id == other.id && expiryDate == other.expiryDate && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, expiryDate, perUnitCostBasis, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditBlock{id=$id, expiryDate=$expiryDate, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Customer - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("external_customer_id") - @ExcludeMissing - private val externalCustomerId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun externalCustomerId(): Optional = - Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("external_customer_id") - @ExcludeMissing - fun _externalCustomerId(): JsonField = externalCustomerId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Customer = apply { - if (validated) { - return@apply - } - - id() - externalCustomerId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Customer]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var externalCustomerId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customer: Customer) = apply { - id = customer.id - externalCustomerId = customer.externalCustomerId - additionalProperties = customer.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun externalCustomerId(externalCustomerId: String?) = - externalCustomerId(JsonField.ofNullable(externalCustomerId)) - - fun externalCustomerId(externalCustomerId: Optional) = - externalCustomerId(externalCustomerId.orElse(null)) - - fun externalCustomerId(externalCustomerId: JsonField) = apply { - this.externalCustomerId = externalCustomerId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Customer = - Customer( - checkRequired("id", id), - checkRequired("externalCustomerId", externalCustomerId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Customer && id == other.id && externalCustomerId == other.externalCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, externalCustomerId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Customer{id=$id, externalCustomerId=$externalCustomerId, additionalProperties=$additionalProperties}" - } - - class EntryStatus @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val COMMITTED = of("committed") - - @JvmField val PENDING = of("pending") - - @JvmStatic fun of(value: String) = EntryStatus(JsonField.of(value)) - } - - /** An enum containing [EntryStatus]'s known values. */ - enum class Known { - COMMITTED, - PENDING, + /** An enum containing [EntryStatus]'s known values. */ + enum class Known { + COMMITTED, + PENDING, } /** @@ -2141,6 +1621,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } @@ -2227,13 +1708,13 @@ private constructor( private val createdAt: JsonField = JsonMissing.of(), @JsonProperty("credit_block") @ExcludeMissing - private val creditBlock: JsonField = JsonMissing.of(), + private val creditBlock: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing private val currency: JsonField = JsonMissing.of(), @JsonProperty("customer") @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), + private val customer: JsonField = JsonMissing.of(), @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), @@ -2268,11 +1749,11 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - fun creditBlock(): CreditBlock = creditBlock.getRequired("credit_block") + fun creditBlock(): AffectedBlockModel = creditBlock.getRequired("credit_block") fun currency(): String = currency.getRequired("currency") - fun customer(): Customer = customer.getRequired("customer") + fun customer(): CustomerMinifiedModel = customer.getRequired("customer") fun description(): Optional = Optional.ofNullable(description.getNullable("description")) @@ -2308,11 +1789,13 @@ private constructor( @JsonProperty("credit_block") @ExcludeMissing - fun _creditBlock(): JsonField = creditBlock + fun _creditBlock(): JsonField = creditBlock @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer + @JsonProperty("customer") + @ExcludeMissing + fun _customer(): JsonField = customer @JsonProperty("description") @ExcludeMissing @@ -2381,6 +1864,28 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [ExpirationChangeLedgerEntry]. + * + * The following fields are required: + * ```java + * .id() + * .amount() + * .createdAt() + * .creditBlock() + * .currency() + * .customer() + * .description() + * .endingBalance() + * .entryStatus() + * .entryType() + * .ledgerSequenceNumber() + * .metadata() + * .newBlockExpiryDate() + * .startingBalance() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -2390,9 +1895,9 @@ private constructor( private var id: JsonField? = null private var amount: JsonField? = null private var createdAt: JsonField? = null - private var creditBlock: JsonField? = null + private var creditBlock: JsonField? = null private var currency: JsonField? = null - private var customer: JsonField? = null + private var customer: JsonField? = null private var description: JsonField? = null private var endingBalance: JsonField? = null private var entryStatus: JsonField? = null @@ -2437,9 +1942,10 @@ private constructor( this.createdAt = createdAt } - fun creditBlock(creditBlock: CreditBlock) = creditBlock(JsonField.of(creditBlock)) + fun creditBlock(creditBlock: AffectedBlockModel) = + creditBlock(JsonField.of(creditBlock)) - fun creditBlock(creditBlock: JsonField) = apply { + fun creditBlock(creditBlock: JsonField) = apply { this.creditBlock = creditBlock } @@ -2447,9 +1953,11 @@ private constructor( fun currency(currency: JsonField) = apply { this.currency = currency } - fun customer(customer: Customer) = customer(JsonField.of(customer)) + fun customer(customer: CustomerMinifiedModel) = customer(JsonField.of(customer)) - fun customer(customer: JsonField) = apply { this.customer = customer } + fun customer(customer: JsonField) = apply { + this.customer = customer + } fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -2552,337 +2060,65 @@ private constructor( ) } - @NoAutoDetect - class CreditBlock - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("expiry_date") - @ExcludeMissing - private val expiryDate: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - private val perUnitCostBasis: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun expiryDate(): Optional = - Optional.ofNullable(expiryDate.getNullable("expiry_date")) - - fun perUnitCostBasis(): Optional = - Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("expiry_date") - @ExcludeMissing - fun _expiryDate(): JsonField = expiryDate + class EntryStatus @JsonCreator private constructor(private val value: JsonField) : + Enum { - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - fun _perUnitCostBasis(): JsonField = perUnitCostBasis + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + companion object { - private var validated: Boolean = false + @JvmField val COMMITTED = of("committed") - fun validate(): CreditBlock = apply { - if (validated) { - return@apply - } + @JvmField val PENDING = of("pending") - id() - expiryDate() - perUnitCostBasis() - validated = true + @JvmStatic fun of(value: String) = EntryStatus(JsonField.of(value)) } - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() + /** An enum containing [EntryStatus]'s known values. */ + enum class Known { + COMMITTED, + PENDING, } - /** A builder for [CreditBlock]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var expiryDate: JsonField? = null - private var perUnitCostBasis: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditBlock: CreditBlock) = apply { - id = creditBlock.id - expiryDate = creditBlock.expiryDate - perUnitCostBasis = creditBlock.perUnitCostBasis - additionalProperties = creditBlock.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun expiryDate(expiryDate: OffsetDateTime?) = - expiryDate(JsonField.ofNullable(expiryDate)) - - fun expiryDate(expiryDate: Optional) = - expiryDate(expiryDate.orElse(null)) - - fun expiryDate(expiryDate: JsonField) = apply { - this.expiryDate = expiryDate - } - - fun perUnitCostBasis(perUnitCostBasis: String?) = - perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) - - fun perUnitCostBasis(perUnitCostBasis: Optional) = - perUnitCostBasis(perUnitCostBasis.orElse(null)) + /** + * An enum containing [EntryStatus]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [EntryStatus] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + COMMITTED, + PENDING, + /** + * An enum member indicating that [EntryStatus] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { - this.perUnitCostBasis = perUnitCostBasis - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditBlock = - CreditBlock( - checkRequired("id", id), - checkRequired("expiryDate", expiryDate), - checkRequired("perUnitCostBasis", perUnitCostBasis), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditBlock && id == other.id && expiryDate == other.expiryDate && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, expiryDate, perUnitCostBasis, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditBlock{id=$id, expiryDate=$expiryDate, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Customer - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("external_customer_id") - @ExcludeMissing - private val externalCustomerId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun externalCustomerId(): Optional = - Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("external_customer_id") - @ExcludeMissing - fun _externalCustomerId(): JsonField = externalCustomerId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Customer = apply { - if (validated) { - return@apply - } - - id() - externalCustomerId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Customer]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var externalCustomerId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customer: Customer) = apply { - id = customer.id - externalCustomerId = customer.externalCustomerId - additionalProperties = customer.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun externalCustomerId(externalCustomerId: String?) = - externalCustomerId(JsonField.ofNullable(externalCustomerId)) - - fun externalCustomerId(externalCustomerId: Optional) = - externalCustomerId(externalCustomerId.orElse(null)) - - fun externalCustomerId(externalCustomerId: JsonField) = apply { - this.externalCustomerId = externalCustomerId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Customer = - Customer( - checkRequired("id", id), - checkRequired("externalCustomerId", externalCustomerId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Customer && id == other.id && externalCustomerId == other.externalCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, externalCustomerId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Customer{id=$id, externalCustomerId=$externalCustomerId, additionalProperties=$additionalProperties}" - } - - class EntryStatus @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val COMMITTED = of("committed") - - @JvmField val PENDING = of("pending") - - @JvmStatic fun of(value: String) = EntryStatus(JsonField.of(value)) - } - - /** An enum containing [EntryStatus]'s known values. */ - enum class Known { - COMMITTED, - PENDING, - } - - /** - * An enum containing [EntryStatus]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryStatus] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - COMMITTED, - PENDING, - /** - * An enum member indicating that [EntryStatus] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - COMMITTED -> Value.COMMITTED - PENDING -> Value.PENDING - else -> Value._UNKNOWN + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + COMMITTED -> Value.COMMITTED + PENDING -> Value.PENDING + else -> Value._UNKNOWN } /** @@ -3053,6 +2289,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } @@ -3139,13 +2376,13 @@ private constructor( private val createdAt: JsonField = JsonMissing.of(), @JsonProperty("credit_block") @ExcludeMissing - private val creditBlock: JsonField = JsonMissing.of(), + private val creditBlock: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing private val currency: JsonField = JsonMissing.of(), @JsonProperty("customer") @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), + private val customer: JsonField = JsonMissing.of(), @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), @@ -3177,11 +2414,11 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - fun creditBlock(): CreditBlock = creditBlock.getRequired("credit_block") + fun creditBlock(): AffectedBlockModel = creditBlock.getRequired("credit_block") fun currency(): String = currency.getRequired("currency") - fun customer(): Customer = customer.getRequired("customer") + fun customer(): CustomerMinifiedModel = customer.getRequired("customer") fun description(): Optional = Optional.ofNullable(description.getNullable("description")) @@ -3214,11 +2451,13 @@ private constructor( @JsonProperty("credit_block") @ExcludeMissing - fun _creditBlock(): JsonField = creditBlock + fun _creditBlock(): JsonField = creditBlock @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer + @JsonProperty("customer") + @ExcludeMissing + fun _customer(): JsonField = customer @JsonProperty("description") @ExcludeMissing @@ -3282,6 +2521,27 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [CreditBlockExpiryLedgerEntry]. + * + * The following fields are required: + * ```java + * .id() + * .amount() + * .createdAt() + * .creditBlock() + * .currency() + * .customer() + * .description() + * .endingBalance() + * .entryStatus() + * .entryType() + * .ledgerSequenceNumber() + * .metadata() + * .startingBalance() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -3291,9 +2551,9 @@ private constructor( private var id: JsonField? = null private var amount: JsonField? = null private var createdAt: JsonField? = null - private var creditBlock: JsonField? = null + private var creditBlock: JsonField? = null private var currency: JsonField? = null - private var customer: JsonField? = null + private var customer: JsonField? = null private var description: JsonField? = null private var endingBalance: JsonField? = null private var entryStatus: JsonField? = null @@ -3336,9 +2596,10 @@ private constructor( this.createdAt = createdAt } - fun creditBlock(creditBlock: CreditBlock) = creditBlock(JsonField.of(creditBlock)) + fun creditBlock(creditBlock: AffectedBlockModel) = + creditBlock(JsonField.of(creditBlock)) - fun creditBlock(creditBlock: JsonField) = apply { + fun creditBlock(creditBlock: JsonField) = apply { this.creditBlock = creditBlock } @@ -3346,9 +2607,11 @@ private constructor( fun currency(currency: JsonField) = apply { this.currency = currency } - fun customer(customer: Customer) = customer(JsonField.of(customer)) + fun customer(customer: CustomerMinifiedModel) = customer(JsonField.of(customer)) - fun customer(customer: JsonField) = apply { this.customer = customer } + fun customer(customer: JsonField) = apply { + this.customer = customer + } fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -3391,325 +2654,53 @@ private constructor( /** * 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: JsonField) = apply { this.metadata = metadata } - - fun startingBalance(startingBalance: Double) = - startingBalance(JsonField.of(startingBalance)) - - fun startingBalance(startingBalance: JsonField) = apply { - this.startingBalance = startingBalance - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditBlockExpiryLedgerEntry = - CreditBlockExpiryLedgerEntry( - checkRequired("id", id), - checkRequired("amount", amount), - checkRequired("createdAt", createdAt), - checkRequired("creditBlock", creditBlock), - checkRequired("currency", currency), - checkRequired("customer", customer), - checkRequired("description", description), - checkRequired("endingBalance", endingBalance), - checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), - checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), - checkRequired("metadata", metadata), - checkRequired("startingBalance", startingBalance), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class CreditBlock - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("expiry_date") - @ExcludeMissing - private val expiryDate: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - private val perUnitCostBasis: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun expiryDate(): Optional = - Optional.ofNullable(expiryDate.getNullable("expiry_date")) - - fun perUnitCostBasis(): Optional = - Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("expiry_date") - @ExcludeMissing - fun _expiryDate(): JsonField = expiryDate - - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - fun _perUnitCostBasis(): JsonField = perUnitCostBasis - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditBlock = apply { - if (validated) { - return@apply - } - - id() - expiryDate() - perUnitCostBasis() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditBlock]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var expiryDate: JsonField? = null - private var perUnitCostBasis: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditBlock: CreditBlock) = apply { - id = creditBlock.id - expiryDate = creditBlock.expiryDate - perUnitCostBasis = creditBlock.perUnitCostBasis - additionalProperties = creditBlock.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun expiryDate(expiryDate: OffsetDateTime?) = - expiryDate(JsonField.ofNullable(expiryDate)) - - fun expiryDate(expiryDate: Optional) = - expiryDate(expiryDate.orElse(null)) - - fun expiryDate(expiryDate: JsonField) = apply { - this.expiryDate = expiryDate - } - - fun perUnitCostBasis(perUnitCostBasis: String?) = - perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) - - fun perUnitCostBasis(perUnitCostBasis: Optional) = - perUnitCostBasis(perUnitCostBasis.orElse(null)) - - fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { - this.perUnitCostBasis = perUnitCostBasis - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditBlock = - CreditBlock( - checkRequired("id", id), - checkRequired("expiryDate", expiryDate), - checkRequired("perUnitCostBasis", perUnitCostBasis), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditBlock && id == other.id && expiryDate == other.expiryDate && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, expiryDate, perUnitCostBasis, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditBlock{id=$id, expiryDate=$expiryDate, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Customer - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("external_customer_id") - @ExcludeMissing - private val externalCustomerId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun externalCustomerId(): Optional = - Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("external_customer_id") - @ExcludeMissing - fun _externalCustomerId(): JsonField = externalCustomerId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Customer = apply { - if (validated) { - return@apply - } - - id() - externalCustomerId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Customer]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var externalCustomerId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customer: Customer) = apply { - id = customer.id - externalCustomerId = customer.externalCustomerId - additionalProperties = customer.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun externalCustomerId(externalCustomerId: String?) = - externalCustomerId(JsonField.ofNullable(externalCustomerId)) - - fun externalCustomerId(externalCustomerId: Optional) = - externalCustomerId(externalCustomerId.orElse(null)) - - fun externalCustomerId(externalCustomerId: JsonField) = apply { - this.externalCustomerId = externalCustomerId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + * the entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun startingBalance(startingBalance: Double) = + startingBalance(JsonField.of(startingBalance)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun startingBalance(startingBalance: JsonField) = apply { + this.startingBalance = startingBalance + } - fun build(): Customer = - Customer( - checkRequired("id", id), - checkRequired("externalCustomerId", externalCustomerId), - additionalProperties.toImmutable(), - ) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - return /* spotless:off */ other is Customer && id == other.id && externalCustomerId == other.externalCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, externalCustomerId, additionalProperties) } - /* spotless:on */ + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - override fun hashCode(): Int = hashCode + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun toString() = - "Customer{id=$id, externalCustomerId=$externalCustomerId, additionalProperties=$additionalProperties}" + fun build(): CreditBlockExpiryLedgerEntry = + CreditBlockExpiryLedgerEntry( + checkRequired("id", id), + checkRequired("amount", amount), + checkRequired("createdAt", createdAt), + checkRequired("creditBlock", creditBlock), + checkRequired("currency", currency), + checkRequired("customer", customer), + checkRequired("description", description), + checkRequired("endingBalance", endingBalance), + checkRequired("entryStatus", entryStatus), + checkRequired("entryType", entryType), + checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), + checkRequired("metadata", metadata), + checkRequired("startingBalance", startingBalance), + additionalProperties.toImmutable(), + ) } class EntryStatus @JsonCreator private constructor(private val value: JsonField) : @@ -3941,6 +2932,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } @@ -4027,13 +3019,13 @@ private constructor( private val createdAt: JsonField = JsonMissing.of(), @JsonProperty("credit_block") @ExcludeMissing - private val creditBlock: JsonField = JsonMissing.of(), + private val creditBlock: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing private val currency: JsonField = JsonMissing.of(), @JsonProperty("customer") @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), + private val customer: JsonField = JsonMissing.of(), @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), @@ -4071,11 +3063,11 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - fun creditBlock(): CreditBlock = creditBlock.getRequired("credit_block") + fun creditBlock(): AffectedBlockModel = creditBlock.getRequired("credit_block") fun currency(): String = currency.getRequired("currency") - fun customer(): Customer = customer.getRequired("customer") + fun customer(): CustomerMinifiedModel = customer.getRequired("customer") fun description(): Optional = Optional.ofNullable(description.getNullable("description")) @@ -4113,11 +3105,13 @@ private constructor( @JsonProperty("credit_block") @ExcludeMissing - fun _creditBlock(): JsonField = creditBlock + fun _creditBlock(): JsonField = creditBlock @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer + @JsonProperty("customer") + @ExcludeMissing + fun _customer(): JsonField = customer @JsonProperty("description") @ExcludeMissing @@ -4191,6 +3185,28 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [VoidLedgerEntry]. + * + * The following fields are required: + * ```java + * .id() + * .amount() + * .createdAt() + * .creditBlock() + * .currency() + * .customer() + * .description() + * .endingBalance() + * .entryStatus() + * .entryType() + * .ledgerSequenceNumber() + * .metadata() + * .startingBalance() + * .voidAmount() + * .voidReason() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -4200,9 +3216,9 @@ private constructor( private var id: JsonField? = null private var amount: JsonField? = null private var createdAt: JsonField? = null - private var creditBlock: JsonField? = null + private var creditBlock: JsonField? = null private var currency: JsonField? = null - private var customer: JsonField? = null + private var customer: JsonField? = null private var description: JsonField? = null private var endingBalance: JsonField? = null private var entryStatus: JsonField? = null @@ -4248,9 +3264,10 @@ private constructor( this.createdAt = createdAt } - fun creditBlock(creditBlock: CreditBlock) = creditBlock(JsonField.of(creditBlock)) + fun creditBlock(creditBlock: AffectedBlockModel) = + creditBlock(JsonField.of(creditBlock)) - fun creditBlock(creditBlock: JsonField) = apply { + fun creditBlock(creditBlock: JsonField) = apply { this.creditBlock = creditBlock } @@ -4258,9 +3275,11 @@ private constructor( fun currency(currency: JsonField) = apply { this.currency = currency } - fun customer(customer: Customer) = customer(JsonField.of(customer)) + fun customer(customer: CustomerMinifiedModel) = customer(JsonField.of(customer)) - fun customer(customer: JsonField) = apply { this.customer = customer } + fun customer(customer: JsonField) = apply { + this.customer = customer + } fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -4316,324 +3335,52 @@ private constructor( fun voidAmount(voidAmount: Double) = voidAmount(JsonField.of(voidAmount)) - fun voidAmount(voidAmount: JsonField) = apply { this.voidAmount = voidAmount } - - fun voidReason(voidReason: String?) = voidReason(JsonField.ofNullable(voidReason)) - - fun voidReason(voidReason: Optional) = voidReason(voidReason.orElse(null)) - - fun voidReason(voidReason: JsonField) = apply { this.voidReason = voidReason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): VoidLedgerEntry = - VoidLedgerEntry( - checkRequired("id", id), - checkRequired("amount", amount), - checkRequired("createdAt", createdAt), - checkRequired("creditBlock", creditBlock), - checkRequired("currency", currency), - checkRequired("customer", customer), - checkRequired("description", description), - checkRequired("endingBalance", endingBalance), - checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), - checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), - checkRequired("metadata", metadata), - checkRequired("startingBalance", startingBalance), - checkRequired("voidAmount", voidAmount), - checkRequired("voidReason", voidReason), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class CreditBlock - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("expiry_date") - @ExcludeMissing - private val expiryDate: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - private val perUnitCostBasis: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun expiryDate(): Optional = - Optional.ofNullable(expiryDate.getNullable("expiry_date")) - - fun perUnitCostBasis(): Optional = - Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("expiry_date") - @ExcludeMissing - fun _expiryDate(): JsonField = expiryDate - - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - fun _perUnitCostBasis(): JsonField = perUnitCostBasis - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditBlock = apply { - if (validated) { - return@apply - } - - id() - expiryDate() - perUnitCostBasis() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditBlock]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var expiryDate: JsonField? = null - private var perUnitCostBasis: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditBlock: CreditBlock) = apply { - id = creditBlock.id - expiryDate = creditBlock.expiryDate - perUnitCostBasis = creditBlock.perUnitCostBasis - additionalProperties = creditBlock.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun expiryDate(expiryDate: OffsetDateTime?) = - expiryDate(JsonField.ofNullable(expiryDate)) - - fun expiryDate(expiryDate: Optional) = - expiryDate(expiryDate.orElse(null)) - - fun expiryDate(expiryDate: JsonField) = apply { - this.expiryDate = expiryDate - } - - fun perUnitCostBasis(perUnitCostBasis: String?) = - perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) - - fun perUnitCostBasis(perUnitCostBasis: Optional) = - perUnitCostBasis(perUnitCostBasis.orElse(null)) - - fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { - this.perUnitCostBasis = perUnitCostBasis - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditBlock = - CreditBlock( - checkRequired("id", id), - checkRequired("expiryDate", expiryDate), - checkRequired("perUnitCostBasis", perUnitCostBasis), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditBlock && id == other.id && expiryDate == other.expiryDate && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, expiryDate, perUnitCostBasis, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditBlock{id=$id, expiryDate=$expiryDate, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Customer - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("external_customer_id") - @ExcludeMissing - private val externalCustomerId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun externalCustomerId(): Optional = - Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("external_customer_id") - @ExcludeMissing - fun _externalCustomerId(): JsonField = externalCustomerId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Customer = apply { - if (validated) { - return@apply - } - - id() - externalCustomerId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Customer]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var externalCustomerId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customer: Customer) = apply { - id = customer.id - externalCustomerId = customer.externalCustomerId - additionalProperties = customer.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun externalCustomerId(externalCustomerId: String?) = - externalCustomerId(JsonField.ofNullable(externalCustomerId)) - - fun externalCustomerId(externalCustomerId: Optional) = - externalCustomerId(externalCustomerId.orElse(null)) - - fun externalCustomerId(externalCustomerId: JsonField) = apply { - this.externalCustomerId = externalCustomerId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun voidAmount(voidAmount: JsonField) = apply { this.voidAmount = voidAmount } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun voidReason(voidReason: String?) = voidReason(JsonField.ofNullable(voidReason)) - fun build(): Customer = - Customer( - checkRequired("id", id), - checkRequired("externalCustomerId", externalCustomerId), - additionalProperties.toImmutable(), - ) + fun voidReason(voidReason: Optional) = voidReason(voidReason.orElse(null)) + + fun voidReason(voidReason: JsonField) = apply { this.voidReason = voidReason } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - return /* spotless:off */ other is Customer && id == other.id && externalCustomerId == other.externalCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, externalCustomerId, additionalProperties) } - /* spotless:on */ + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - override fun hashCode(): Int = hashCode + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun toString() = - "Customer{id=$id, externalCustomerId=$externalCustomerId, additionalProperties=$additionalProperties}" + fun build(): VoidLedgerEntry = + VoidLedgerEntry( + checkRequired("id", id), + checkRequired("amount", amount), + checkRequired("createdAt", createdAt), + checkRequired("creditBlock", creditBlock), + checkRequired("currency", currency), + checkRequired("customer", customer), + checkRequired("description", description), + checkRequired("endingBalance", endingBalance), + checkRequired("entryStatus", entryStatus), + checkRequired("entryType", entryType), + checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), + checkRequired("metadata", metadata), + checkRequired("startingBalance", startingBalance), + checkRequired("voidAmount", voidAmount), + checkRequired("voidReason", voidReason), + additionalProperties.toImmutable(), + ) } class EntryStatus @JsonCreator private constructor(private val value: JsonField) : @@ -4865,6 +3612,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } @@ -4951,13 +3699,13 @@ private constructor( private val createdAt: JsonField = JsonMissing.of(), @JsonProperty("credit_block") @ExcludeMissing - private val creditBlock: JsonField = JsonMissing.of(), + private val creditBlock: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing private val currency: JsonField = JsonMissing.of(), @JsonProperty("customer") @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), + private val customer: JsonField = JsonMissing.of(), @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), @@ -4998,11 +3746,11 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - fun creditBlock(): CreditBlock = creditBlock.getRequired("credit_block") + fun creditBlock(): AffectedBlockModel = creditBlock.getRequired("credit_block") fun currency(): String = currency.getRequired("currency") - fun customer(): Customer = customer.getRequired("customer") + fun customer(): CustomerMinifiedModel = customer.getRequired("customer") fun description(): Optional = Optional.ofNullable(description.getNullable("description")) @@ -5043,11 +3791,13 @@ private constructor( @JsonProperty("credit_block") @ExcludeMissing - fun _creditBlock(): JsonField = creditBlock + fun _creditBlock(): JsonField = creditBlock @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer + @JsonProperty("customer") + @ExcludeMissing + fun _customer(): JsonField = customer @JsonProperty("description") @ExcludeMissing @@ -5126,6 +3876,29 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [VoidInitiatedLedgerEntry]. + * + * The following fields are required: + * ```java + * .id() + * .amount() + * .createdAt() + * .creditBlock() + * .currency() + * .customer() + * .description() + * .endingBalance() + * .entryStatus() + * .entryType() + * .ledgerSequenceNumber() + * .metadata() + * .newBlockExpiryDate() + * .startingBalance() + * .voidAmount() + * .voidReason() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -5135,9 +3908,9 @@ private constructor( private var id: JsonField? = null private var amount: JsonField? = null private var createdAt: JsonField? = null - private var creditBlock: JsonField? = null + private var creditBlock: JsonField? = null private var currency: JsonField? = null - private var customer: JsonField? = null + private var customer: JsonField? = null private var description: JsonField? = null private var endingBalance: JsonField? = null private var entryStatus: JsonField? = null @@ -5185,9 +3958,10 @@ private constructor( this.createdAt = createdAt } - fun creditBlock(creditBlock: CreditBlock) = creditBlock(JsonField.of(creditBlock)) + fun creditBlock(creditBlock: AffectedBlockModel) = + creditBlock(JsonField.of(creditBlock)) - fun creditBlock(creditBlock: JsonField) = apply { + fun creditBlock(creditBlock: JsonField) = apply { this.creditBlock = creditBlock } @@ -5195,9 +3969,11 @@ private constructor( fun currency(currency: JsonField) = apply { this.currency = currency } - fun customer(customer: Customer) = customer(JsonField.of(customer)) + fun customer(customer: CustomerMinifiedModel) = customer(JsonField.of(customer)) - fun customer(customer: JsonField) = apply { this.customer = customer } + fun customer(customer: JsonField) = apply { + this.customer = customer + } fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -5241,344 +4017,72 @@ private constructor( * 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: JsonField) = apply { this.metadata = metadata } - - fun newBlockExpiryDate(newBlockExpiryDate: OffsetDateTime) = - newBlockExpiryDate(JsonField.of(newBlockExpiryDate)) - - fun newBlockExpiryDate(newBlockExpiryDate: JsonField) = apply { - this.newBlockExpiryDate = newBlockExpiryDate - } - - fun startingBalance(startingBalance: Double) = - startingBalance(JsonField.of(startingBalance)) - - fun startingBalance(startingBalance: JsonField) = apply { - this.startingBalance = startingBalance - } - - fun voidAmount(voidAmount: Double) = voidAmount(JsonField.of(voidAmount)) - - fun voidAmount(voidAmount: JsonField) = apply { this.voidAmount = voidAmount } - - fun voidReason(voidReason: String?) = voidReason(JsonField.ofNullable(voidReason)) - - fun voidReason(voidReason: Optional) = voidReason(voidReason.orElse(null)) - - fun voidReason(voidReason: JsonField) = apply { this.voidReason = voidReason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): VoidInitiatedLedgerEntry = - VoidInitiatedLedgerEntry( - checkRequired("id", id), - checkRequired("amount", amount), - checkRequired("createdAt", createdAt), - checkRequired("creditBlock", creditBlock), - checkRequired("currency", currency), - checkRequired("customer", customer), - checkRequired("description", description), - checkRequired("endingBalance", endingBalance), - checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), - checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), - checkRequired("metadata", metadata), - checkRequired("newBlockExpiryDate", newBlockExpiryDate), - checkRequired("startingBalance", startingBalance), - checkRequired("voidAmount", voidAmount), - checkRequired("voidReason", voidReason), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class CreditBlock - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("expiry_date") - @ExcludeMissing - private val expiryDate: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - private val perUnitCostBasis: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun expiryDate(): Optional = - Optional.ofNullable(expiryDate.getNullable("expiry_date")) - - fun perUnitCostBasis(): Optional = - Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("expiry_date") - @ExcludeMissing - fun _expiryDate(): JsonField = expiryDate - - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - fun _perUnitCostBasis(): JsonField = perUnitCostBasis - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditBlock = apply { - if (validated) { - return@apply - } - - id() - expiryDate() - perUnitCostBasis() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditBlock]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var expiryDate: JsonField? = null - private var perUnitCostBasis: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditBlock: CreditBlock) = apply { - id = creditBlock.id - expiryDate = creditBlock.expiryDate - perUnitCostBasis = creditBlock.perUnitCostBasis - additionalProperties = creditBlock.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun expiryDate(expiryDate: OffsetDateTime?) = - expiryDate(JsonField.ofNullable(expiryDate)) - - fun expiryDate(expiryDate: Optional) = - expiryDate(expiryDate.orElse(null)) - - fun expiryDate(expiryDate: JsonField) = apply { - this.expiryDate = expiryDate - } - - fun perUnitCostBasis(perUnitCostBasis: String?) = - perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) - - fun perUnitCostBasis(perUnitCostBasis: Optional) = - perUnitCostBasis(perUnitCostBasis.orElse(null)) - - fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { - this.perUnitCostBasis = perUnitCostBasis - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditBlock = - CreditBlock( - checkRequired("id", id), - checkRequired("expiryDate", expiryDate), - checkRequired("perUnitCostBasis", perUnitCostBasis), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditBlock && id == other.id && expiryDate == other.expiryDate && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, expiryDate, perUnitCostBasis, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditBlock{id=$id, expiryDate=$expiryDate, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Customer - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("external_customer_id") - @ExcludeMissing - private val externalCustomerId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun externalCustomerId(): Optional = - Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("external_customer_id") - @ExcludeMissing - fun _externalCustomerId(): JsonField = externalCustomerId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Customer = apply { - if (validated) { - return@apply - } - - id() - externalCustomerId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Customer]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var externalCustomerId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customer: Customer) = apply { - id = customer.id - externalCustomerId = customer.externalCustomerId - additionalProperties = customer.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun id(id: JsonField) = apply { this.id = id } + fun newBlockExpiryDate(newBlockExpiryDate: OffsetDateTime) = + newBlockExpiryDate(JsonField.of(newBlockExpiryDate)) - fun externalCustomerId(externalCustomerId: String?) = - externalCustomerId(JsonField.ofNullable(externalCustomerId)) + fun newBlockExpiryDate(newBlockExpiryDate: JsonField) = apply { + this.newBlockExpiryDate = newBlockExpiryDate + } - fun externalCustomerId(externalCustomerId: Optional) = - externalCustomerId(externalCustomerId.orElse(null)) + fun startingBalance(startingBalance: Double) = + startingBalance(JsonField.of(startingBalance)) - fun externalCustomerId(externalCustomerId: JsonField) = apply { - this.externalCustomerId = externalCustomerId - } + fun startingBalance(startingBalance: JsonField) = apply { + this.startingBalance = startingBalance + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun voidAmount(voidAmount: Double) = voidAmount(JsonField.of(voidAmount)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun voidAmount(voidAmount: JsonField) = apply { this.voidAmount = voidAmount } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun voidReason(voidReason: String?) = voidReason(JsonField.ofNullable(voidReason)) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun voidReason(voidReason: Optional) = voidReason(voidReason.orElse(null)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun voidReason(voidReason: JsonField) = apply { this.voidReason = voidReason } - fun build(): Customer = - Customer( - checkRequired("id", id), - checkRequired("externalCustomerId", externalCustomerId), - additionalProperties.toImmutable(), - ) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - return /* spotless:off */ other is Customer && id == other.id && externalCustomerId == other.externalCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, externalCustomerId, additionalProperties) } - /* spotless:on */ + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - override fun hashCode(): Int = hashCode + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun toString() = - "Customer{id=$id, externalCustomerId=$externalCustomerId, additionalProperties=$additionalProperties}" + fun build(): VoidInitiatedLedgerEntry = + VoidInitiatedLedgerEntry( + checkRequired("id", id), + checkRequired("amount", amount), + checkRequired("createdAt", createdAt), + checkRequired("creditBlock", creditBlock), + checkRequired("currency", currency), + checkRequired("customer", customer), + checkRequired("description", description), + checkRequired("endingBalance", endingBalance), + checkRequired("entryStatus", entryStatus), + checkRequired("entryType", entryType), + checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), + checkRequired("metadata", metadata), + checkRequired("newBlockExpiryDate", newBlockExpiryDate), + checkRequired("startingBalance", startingBalance), + checkRequired("voidAmount", voidAmount), + checkRequired("voidReason", voidReason), + additionalProperties.toImmutable(), + ) } class EntryStatus @JsonCreator private constructor(private val value: JsonField) : @@ -5810,6 +4314,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } @@ -5896,13 +4401,13 @@ private constructor( private val createdAt: JsonField = JsonMissing.of(), @JsonProperty("credit_block") @ExcludeMissing - private val creditBlock: JsonField = JsonMissing.of(), + private val creditBlock: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing private val currency: JsonField = JsonMissing.of(), @JsonProperty("customer") @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), + private val customer: JsonField = JsonMissing.of(), @JsonProperty("description") @ExcludeMissing private val description: JsonField = JsonMissing.of(), @@ -5934,11 +4439,11 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - fun creditBlock(): CreditBlock = creditBlock.getRequired("credit_block") + fun creditBlock(): AffectedBlockModel = creditBlock.getRequired("credit_block") fun currency(): String = currency.getRequired("currency") - fun customer(): Customer = customer.getRequired("customer") + fun customer(): CustomerMinifiedModel = customer.getRequired("customer") fun description(): Optional = Optional.ofNullable(description.getNullable("description")) @@ -5971,11 +4476,13 @@ private constructor( @JsonProperty("credit_block") @ExcludeMissing - fun _creditBlock(): JsonField = creditBlock + fun _creditBlock(): JsonField = creditBlock @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer + @JsonProperty("customer") + @ExcludeMissing + fun _customer(): JsonField = customer @JsonProperty("description") @ExcludeMissing @@ -6039,6 +4546,26 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [AmendmentLedgerEntry]. + * + * The following fields are required: + * ```java + * .id() + * .amount() + * .createdAt() + * .creditBlock() + * .currency() + * .customer() + * .description() + * .endingBalance() + * .entryStatus() + * .entryType() + * .ledgerSequenceNumber() + * .metadata() + * .startingBalance() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -6048,9 +4575,9 @@ private constructor( private var id: JsonField? = null private var amount: JsonField? = null private var createdAt: JsonField? = null - private var creditBlock: JsonField? = null + private var creditBlock: JsonField? = null private var currency: JsonField? = null - private var customer: JsonField? = null + private var customer: JsonField? = null private var description: JsonField? = null private var endingBalance: JsonField? = null private var entryStatus: JsonField? = null @@ -6092,9 +4619,10 @@ private constructor( this.createdAt = createdAt } - fun creditBlock(creditBlock: CreditBlock) = creditBlock(JsonField.of(creditBlock)) + fun creditBlock(creditBlock: AffectedBlockModel) = + creditBlock(JsonField.of(creditBlock)) - fun creditBlock(creditBlock: JsonField) = apply { + fun creditBlock(creditBlock: JsonField) = apply { this.creditBlock = creditBlock } @@ -6102,9 +4630,11 @@ private constructor( fun currency(currency: JsonField) = apply { this.currency = currency } - fun customer(customer: Customer) = customer(JsonField.of(customer)) + fun customer(customer: CustomerMinifiedModel) = customer(JsonField.of(customer)) - fun customer(customer: JsonField) = apply { this.customer = customer } + fun customer(customer: JsonField) = apply { + this.customer = customer + } fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -6196,278 +4726,6 @@ private constructor( ) } - @NoAutoDetect - class CreditBlock - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("expiry_date") - @ExcludeMissing - private val expiryDate: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - private val perUnitCostBasis: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun expiryDate(): Optional = - Optional.ofNullable(expiryDate.getNullable("expiry_date")) - - fun perUnitCostBasis(): Optional = - Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("expiry_date") - @ExcludeMissing - fun _expiryDate(): JsonField = expiryDate - - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - fun _perUnitCostBasis(): JsonField = perUnitCostBasis - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditBlock = apply { - if (validated) { - return@apply - } - - id() - expiryDate() - perUnitCostBasis() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditBlock]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var expiryDate: JsonField? = null - private var perUnitCostBasis: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditBlock: CreditBlock) = apply { - id = creditBlock.id - expiryDate = creditBlock.expiryDate - perUnitCostBasis = creditBlock.perUnitCostBasis - additionalProperties = creditBlock.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun expiryDate(expiryDate: OffsetDateTime?) = - expiryDate(JsonField.ofNullable(expiryDate)) - - fun expiryDate(expiryDate: Optional) = - expiryDate(expiryDate.orElse(null)) - - fun expiryDate(expiryDate: JsonField) = apply { - this.expiryDate = expiryDate - } - - fun perUnitCostBasis(perUnitCostBasis: String?) = - perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) - - fun perUnitCostBasis(perUnitCostBasis: Optional) = - perUnitCostBasis(perUnitCostBasis.orElse(null)) - - fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { - this.perUnitCostBasis = perUnitCostBasis - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditBlock = - CreditBlock( - checkRequired("id", id), - checkRequired("expiryDate", expiryDate), - checkRequired("perUnitCostBasis", perUnitCostBasis), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditBlock && id == other.id && expiryDate == other.expiryDate && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, expiryDate, perUnitCostBasis, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditBlock{id=$id, expiryDate=$expiryDate, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Customer - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("external_customer_id") - @ExcludeMissing - private val externalCustomerId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun externalCustomerId(): Optional = - Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("external_customer_id") - @ExcludeMissing - fun _externalCustomerId(): JsonField = externalCustomerId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Customer = apply { - if (validated) { - return@apply - } - - id() - externalCustomerId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Customer]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var externalCustomerId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customer: Customer) = apply { - id = customer.id - externalCustomerId = customer.externalCustomerId - additionalProperties = customer.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun externalCustomerId(externalCustomerId: String?) = - externalCustomerId(JsonField.ofNullable(externalCustomerId)) - - fun externalCustomerId(externalCustomerId: Optional) = - externalCustomerId(externalCustomerId.orElse(null)) - - fun externalCustomerId(externalCustomerId: JsonField) = apply { - this.externalCustomerId = externalCustomerId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Customer = - Customer( - checkRequired("id", id), - checkRequired("externalCustomerId", externalCustomerId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Customer && id == other.id && externalCustomerId == other.externalCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, externalCustomerId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Customer{id=$id, externalCustomerId=$externalCustomerId, additionalProperties=$additionalProperties}" - } - class EntryStatus @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -6697,6 +4955,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } 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 d2d5cf421..72838841f 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 @@ -12,6 +12,7 @@ import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.immutableEmptyMap import com.withorb.api.core.toImmutable @@ -40,7 +41,7 @@ private constructor( private val creditNotePdf: JsonField = JsonMissing.of(), @JsonProperty("customer") @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), + private val customer: JsonField = JsonMissing.of(), @JsonProperty("invoice_id") @ExcludeMissing private val invoiceId: JsonField = JsonMissing.of(), @@ -49,7 +50,7 @@ private constructor( private val lineItems: JsonField> = JsonMissing.of(), @JsonProperty("maximum_amount_adjustment") @ExcludeMissing - private val maximumAmountAdjustment: JsonField = JsonMissing.of(), + private val maximumAmountAdjustment: JsonField = JsonMissing.of(), @JsonProperty("memo") @ExcludeMissing private val memo: JsonField = JsonMissing.of(), @JsonProperty("minimum_amount_refunded") @ExcludeMissing @@ -67,7 +68,7 @@ private constructor( private val voidedAt: JsonField = JsonMissing.of(), @JsonProperty("discounts") @ExcludeMissing - private val discounts: JsonField> = JsonMissing.of(), + private val discounts: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -84,7 +85,7 @@ private constructor( fun creditNotePdf(): Optional = Optional.ofNullable(creditNotePdf.getNullable("credit_note_pdf")) - fun customer(): Customer = customer.getRequired("customer") + fun customer(): CustomerMinifiedModel = customer.getRequired("customer") /** The id of the invoice resource that this credit note is applied to. */ fun invoiceId(): String = invoiceId.getRequired("invoice_id") @@ -93,7 +94,7 @@ private constructor( fun lineItems(): List = lineItems.getRequired("line_items") /** The maximum amount applied on the original invoice */ - fun maximumAmountAdjustment(): Optional = + fun maximumAmountAdjustment(): Optional = Optional.ofNullable(maximumAmountAdjustment.getNullable("maximum_amount_adjustment")) /** An optional memo supplied on the credit note. */ @@ -118,7 +119,7 @@ private constructor( Optional.ofNullable(voidedAt.getNullable("voided_at")) /** Any discounts applied on the original invoice. */ - fun discounts(): Optional> = + fun discounts(): Optional> = Optional.ofNullable(discounts.getNullable("discounts")) /** The Orb id of this credit note. */ @@ -139,7 +140,9 @@ private constructor( @ExcludeMissing fun _creditNotePdf(): JsonField = creditNotePdf - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer + @JsonProperty("customer") + @ExcludeMissing + fun _customer(): JsonField = customer /** The id of the invoice resource that this credit note is applied to. */ @JsonProperty("invoice_id") @ExcludeMissing fun _invoiceId(): JsonField = invoiceId @@ -152,7 +155,7 @@ private constructor( /** The maximum amount applied on the original invoice */ @JsonProperty("maximum_amount_adjustment") @ExcludeMissing - fun _maximumAmountAdjustment(): JsonField = maximumAmountAdjustment + fun _maximumAmountAdjustment(): JsonField = maximumAmountAdjustment /** An optional memo supplied on the credit note. */ @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo @@ -178,7 +181,7 @@ private constructor( /** Any discounts applied on the original invoice. */ @JsonProperty("discounts") @ExcludeMissing - fun _discounts(): JsonField> = discounts + fun _discounts(): JsonField> = discounts @JsonAnyGetter @ExcludeMissing @@ -214,6 +217,28 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [CreditNote]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .creditNoteNumber() + * .creditNotePdf() + * .customer() + * .invoiceId() + * .lineItems() + * .maximumAmountAdjustment() + * .memo() + * .minimumAmountRefunded() + * .reason() + * .subtotal() + * .total() + * .type() + * .voidedAt() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -224,10 +249,10 @@ private constructor( private var createdAt: JsonField? = null private var creditNoteNumber: JsonField? = null private var creditNotePdf: JsonField? = null - private var customer: JsonField? = null + private var customer: JsonField? = null private var invoiceId: JsonField? = null private var lineItems: JsonField>? = null - private var maximumAmountAdjustment: JsonField? = null + private var maximumAmountAdjustment: JsonField? = null private var memo: JsonField? = null private var minimumAmountRefunded: JsonField? = null private var reason: JsonField? = null @@ -235,7 +260,7 @@ private constructor( private var total: JsonField? = null private var type: JsonField? = null private var voidedAt: JsonField? = null - private var discounts: JsonField>? = null + private var discounts: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -293,9 +318,11 @@ private constructor( this.creditNotePdf = creditNotePdf } - fun customer(customer: Customer) = customer(JsonField.of(customer)) + fun customer(customer: CustomerMinifiedModel) = customer(JsonField.of(customer)) - fun customer(customer: JsonField) = apply { this.customer = customer } + fun customer(customer: JsonField) = apply { + this.customer = customer + } /** The id of the invoice resource that this credit note is applied to. */ fun invoiceId(invoiceId: String) = invoiceId(JsonField.of(invoiceId)) @@ -314,27 +341,21 @@ private constructor( /** All of the line items associated with this credit note. */ fun addLineItem(lineItem: LineItem) = apply { lineItems = - (lineItems ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(lineItem) + (lineItems ?: JsonField.of(mutableListOf())).also { + checkKnown("lineItems", it).add(lineItem) } } /** The maximum amount applied on the original invoice */ - fun maximumAmountAdjustment(maximumAmountAdjustment: MaximumAmountAdjustment?) = + fun maximumAmountAdjustment(maximumAmountAdjustment: CreditNoteDiscountModel?) = maximumAmountAdjustment(JsonField.ofNullable(maximumAmountAdjustment)) /** The maximum amount applied on the original invoice */ - fun maximumAmountAdjustment(maximumAmountAdjustment: Optional) = + fun maximumAmountAdjustment(maximumAmountAdjustment: Optional) = maximumAmountAdjustment(maximumAmountAdjustment.orElse(null)) /** The maximum amount applied on the original invoice */ - fun maximumAmountAdjustment(maximumAmountAdjustment: JsonField) = + fun maximumAmountAdjustment(maximumAmountAdjustment: JsonField) = apply { this.maximumAmountAdjustment = maximumAmountAdjustment } @@ -393,24 +414,18 @@ private constructor( fun voidedAt(voidedAt: JsonField) = apply { this.voidedAt = voidedAt } /** Any discounts applied on the original invoice. */ - fun discounts(discounts: List) = discounts(JsonField.of(discounts)) + fun discounts(discounts: List) = discounts(JsonField.of(discounts)) /** Any discounts applied on the original invoice. */ - fun discounts(discounts: JsonField>) = apply { + fun discounts(discounts: JsonField>) = apply { this.discounts = discounts.map { it.toMutableList() } } /** Any discounts applied on the original invoice. */ - fun addDiscount(discount: Discount) = apply { + fun addDiscount(discount: CreditNoteDiscountModel) = apply { discounts = - (discounts ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(discount) + (discounts ?: JsonField.of(mutableListOf())).also { + checkKnown("discounts", it).add(discount) } } @@ -455,125 +470,6 @@ private constructor( ) } - @NoAutoDetect - class Customer - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("external_customer_id") - @ExcludeMissing - private val externalCustomerId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun externalCustomerId(): Optional = - Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("external_customer_id") - @ExcludeMissing - fun _externalCustomerId(): JsonField = externalCustomerId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Customer = apply { - if (validated) { - return@apply - } - - id() - externalCustomerId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Customer]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var externalCustomerId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customer: Customer) = apply { - id = customer.id - externalCustomerId = customer.externalCustomerId - additionalProperties = customer.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun externalCustomerId(externalCustomerId: String?) = - externalCustomerId(JsonField.ofNullable(externalCustomerId)) - - fun externalCustomerId(externalCustomerId: Optional) = - externalCustomerId(externalCustomerId.orElse(null)) - - fun externalCustomerId(externalCustomerId: JsonField) = apply { - this.externalCustomerId = externalCustomerId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Customer = - Customer( - checkRequired("id", id), - checkRequired("externalCustomerId", externalCustomerId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Customer && id == other.id && externalCustomerId == other.externalCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, externalCustomerId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Customer{id=$id, externalCustomerId=$externalCustomerId, additionalProperties=$additionalProperties}" - } - @NoAutoDetect class LineItem @JsonCreator @@ -596,7 +492,7 @@ private constructor( private val subtotal: JsonField = JsonMissing.of(), @JsonProperty("tax_amounts") @ExcludeMissing - private val taxAmounts: JsonField> = JsonMissing.of(), + private val taxAmounts: JsonField> = JsonMissing.of(), @JsonProperty("discounts") @ExcludeMissing private val discounts: JsonField> = JsonMissing.of(), @@ -623,7 +519,7 @@ private constructor( fun subtotal(): String = subtotal.getRequired("subtotal") /** Any tax amounts applied onto the line item. */ - fun taxAmounts(): List = taxAmounts.getRequired("tax_amounts") + fun taxAmounts(): List = taxAmounts.getRequired("tax_amounts") /** Any line item discounts from the invoice's line item. */ fun discounts(): Optional> = @@ -650,7 +546,7 @@ private constructor( /** Any tax amounts applied onto the line item. */ @JsonProperty("tax_amounts") @ExcludeMissing - fun _taxAmounts(): JsonField> = taxAmounts + fun _taxAmounts(): JsonField> = taxAmounts /** Any line item discounts from the invoice's line item. */ @JsonProperty("discounts") @@ -683,6 +579,20 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [LineItem]. + * + * The following fields are required: + * ```java + * .id() + * .amount() + * .itemId() + * .name() + * .quantity() + * .subtotal() + * .taxAmounts() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -695,7 +605,7 @@ private constructor( private var name: JsonField? = null private var quantity: JsonField? = null private var subtotal: JsonField? = null - private var taxAmounts: JsonField>? = null + private var taxAmounts: JsonField>? = null private var discounts: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -756,24 +666,18 @@ private constructor( fun subtotal(subtotal: JsonField) = apply { this.subtotal = subtotal } /** Any tax amounts applied onto the line item. */ - fun taxAmounts(taxAmounts: List) = taxAmounts(JsonField.of(taxAmounts)) + fun taxAmounts(taxAmounts: List) = taxAmounts(JsonField.of(taxAmounts)) /** Any tax amounts applied onto the line item. */ - fun taxAmounts(taxAmounts: JsonField>) = apply { + fun taxAmounts(taxAmounts: JsonField>) = apply { this.taxAmounts = taxAmounts.map { it.toMutableList() } } /** Any tax amounts applied onto the line item. */ - fun addTaxAmount(taxAmount: TaxAmount) = apply { + fun addTaxAmount(taxAmount: TaxAmountModel) = apply { taxAmounts = - (taxAmounts ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(taxAmount) + (taxAmounts ?: JsonField.of(mutableListOf())).also { + checkKnown("taxAmounts", it).add(taxAmount) } } @@ -788,14 +692,8 @@ private constructor( /** Any line item discounts from the invoice's line item. */ fun addDiscount(discount: Discount) = apply { discounts = - (discounts ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(discount) + (discounts ?: JsonField.of(mutableListOf())).also { + checkKnown("discounts", it).add(discount) } } @@ -832,164 +730,6 @@ private constructor( ) } - @NoAutoDetect - class TaxAmount - @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("tax_rate_description") - @ExcludeMissing - private val taxRateDescription: JsonField = JsonMissing.of(), - @JsonProperty("tax_rate_percentage") - @ExcludeMissing - private val taxRatePercentage: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The amount of additional tax incurred by this tax rate. */ - fun amount(): String = amount.getRequired("amount") - - /** The human-readable description of the applied tax rate. */ - fun taxRateDescription(): String = - taxRateDescription.getRequired("tax_rate_description") - - /** The tax rate percentage, out of 100. */ - fun taxRatePercentage(): Optional = - Optional.ofNullable(taxRatePercentage.getNullable("tax_rate_percentage")) - - /** The amount of additional tax incurred by this tax rate. */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** The human-readable description of the applied tax rate. */ - @JsonProperty("tax_rate_description") - @ExcludeMissing - fun _taxRateDescription(): JsonField = taxRateDescription - - /** The tax rate percentage, out of 100. */ - @JsonProperty("tax_rate_percentage") - @ExcludeMissing - fun _taxRatePercentage(): JsonField = taxRatePercentage - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TaxAmount = apply { - if (validated) { - return@apply - } - - amount() - taxRateDescription() - taxRatePercentage() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TaxAmount]. */ - class Builder internal constructor() { - - private var amount: JsonField? = null - private var taxRateDescription: JsonField? = null - private var taxRatePercentage: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(taxAmount: TaxAmount) = apply { - amount = taxAmount.amount - taxRateDescription = taxAmount.taxRateDescription - taxRatePercentage = taxAmount.taxRatePercentage - additionalProperties = taxAmount.additionalProperties.toMutableMap() - } - - /** The amount of additional tax incurred by this tax rate. */ - fun amount(amount: String) = amount(JsonField.of(amount)) - - /** The amount of additional tax incurred by this tax rate. */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** The human-readable description of the applied tax rate. */ - fun taxRateDescription(taxRateDescription: String) = - taxRateDescription(JsonField.of(taxRateDescription)) - - /** The human-readable description of the applied tax rate. */ - fun taxRateDescription(taxRateDescription: JsonField) = apply { - this.taxRateDescription = taxRateDescription - } - - /** The tax rate percentage, out of 100. */ - fun taxRatePercentage(taxRatePercentage: String?) = - taxRatePercentage(JsonField.ofNullable(taxRatePercentage)) - - /** The tax rate percentage, out of 100. */ - fun taxRatePercentage(taxRatePercentage: Optional) = - taxRatePercentage(taxRatePercentage.orElse(null)) - - /** The tax rate percentage, out of 100. */ - fun taxRatePercentage(taxRatePercentage: JsonField) = apply { - this.taxRatePercentage = taxRatePercentage - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): TaxAmount = - TaxAmount( - checkRequired("amount", amount), - checkRequired("taxRateDescription", taxRateDescription), - checkRequired("taxRatePercentage", taxRatePercentage), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TaxAmount && amount == other.amount && taxRateDescription == other.taxRateDescription && taxRatePercentage == other.taxRatePercentage && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, taxRateDescription, taxRatePercentage, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TaxAmount{amount=$amount, taxRateDescription=$taxRateDescription, taxRatePercentage=$taxRatePercentage, additionalProperties=$additionalProperties}" - } - @NoAutoDetect class Discount @JsonCreator @@ -1084,6 +824,18 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Discount]. + * + * The following fields are required: + * ```java + * .id() + * .amountApplied() + * .appliesToPriceIds() + * .discountType() + * .percentageDiscount() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1131,14 +883,8 @@ private constructor( fun addAppliesToPriceId(appliesToPriceId: String) = apply { appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) } } @@ -1351,444 +1097,38 @@ private constructor( "LineItem{id=$id, amount=$amount, itemId=$itemId, name=$name, quantity=$quantity, subtotal=$subtotal, taxAmounts=$taxAmounts, discounts=$discounts, additionalProperties=$additionalProperties}" } - /** The maximum amount applied on the original invoice */ - @NoAutoDetect - class MaximumAmountAdjustment - @JsonCreator - private constructor( - @JsonProperty("amount_applied") - @ExcludeMissing - private val amountApplied: JsonField = JsonMissing.of(), - @JsonProperty("discount_type") - @ExcludeMissing - private val discountType: JsonField = JsonMissing.of(), - @JsonProperty("percentage_discount") - @ExcludeMissing - private val percentageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_prices") - @ExcludeMissing - private val appliesToPrices: JsonField> = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun amountApplied(): String = amountApplied.getRequired("amount_applied") - - fun discountType(): DiscountType = discountType.getRequired("discount_type") - - fun percentageDiscount(): Double = percentageDiscount.getRequired("percentage_discount") - - fun appliesToPrices(): Optional> = - Optional.ofNullable(appliesToPrices.getNullable("applies_to_prices")) - - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("amount_applied") - @ExcludeMissing - fun _amountApplied(): JsonField = amountApplied - - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType + class Reason @JsonCreator private constructor(private val value: JsonField) : Enum { - @JsonProperty("percentage_discount") - @ExcludeMissing - fun _percentageDiscount(): JsonField = percentageDiscount + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - @JsonProperty("applies_to_prices") - @ExcludeMissing - fun _appliesToPrices(): JsonField> = appliesToPrices + companion object { - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + @JvmField val DUPLICATE = of("Duplicate") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + @JvmField val FRAUDULENT = of("Fraudulent") - private var validated: Boolean = false + @JvmField val ORDER_CHANGE = of("Order change") - fun validate(): MaximumAmountAdjustment = apply { - if (validated) { - return@apply - } + @JvmField val PRODUCT_UNSATISFACTORY = of("Product unsatisfactory") - amountApplied() - discountType() - percentageDiscount() - appliesToPrices().ifPresent { it.forEach { it.validate() } } - reason() - validated = true + @JvmStatic fun of(value: String) = Reason(JsonField.of(value)) } - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MaximumAmountAdjustment]. */ - class Builder internal constructor() { - - private var amountApplied: JsonField? = null - private var discountType: JsonField? = null - private var percentageDiscount: JsonField? = null - private var appliesToPrices: JsonField>? = null - private var reason: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximumAmountAdjustment: MaximumAmountAdjustment) = apply { - amountApplied = maximumAmountAdjustment.amountApplied - discountType = maximumAmountAdjustment.discountType - percentageDiscount = maximumAmountAdjustment.percentageDiscount - appliesToPrices = maximumAmountAdjustment.appliesToPrices.map { it.toMutableList() } - reason = maximumAmountAdjustment.reason - additionalProperties = maximumAmountAdjustment.additionalProperties.toMutableMap() - } - - fun amountApplied(amountApplied: String) = amountApplied(JsonField.of(amountApplied)) - - fun amountApplied(amountApplied: JsonField) = apply { - this.amountApplied = amountApplied - } - - fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) - - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - fun percentageDiscount(percentageDiscount: Double) = - percentageDiscount(JsonField.of(percentageDiscount)) - - fun percentageDiscount(percentageDiscount: JsonField) = apply { - this.percentageDiscount = percentageDiscount - } - - fun appliesToPrices(appliesToPrices: List?) = - appliesToPrices(JsonField.ofNullable(appliesToPrices)) - - fun appliesToPrices(appliesToPrices: Optional>) = - appliesToPrices(appliesToPrices.orElse(null)) - - fun appliesToPrices(appliesToPrices: JsonField>) = apply { - this.appliesToPrices = appliesToPrices.map { it.toMutableList() } - } - - fun addAppliesToPrice(appliesToPrice: AppliesToPrice) = apply { - appliesToPrices = - (appliesToPrices ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPrice) - } - } - - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - fun reason(reason: Optional) = reason(reason.orElse(null)) - - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): MaximumAmountAdjustment = - MaximumAmountAdjustment( - checkRequired("amountApplied", amountApplied), - checkRequired("discountType", discountType), - checkRequired("percentageDiscount", percentageDiscount), - (appliesToPrices ?: JsonMissing.of()).map { it.toImmutable() }, - reason, - additionalProperties.toImmutable(), - ) - } - - class DiscountType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val PERCENTAGE = of("percentage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - PERCENTAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE -> Value.PERCENTAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PERCENTAGE -> Known.PERCENTAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class AppliesToPrice - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun name(): String = name.getRequired("name") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AppliesToPrice = apply { - if (validated) { - return@apply - } - - id() - name() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AppliesToPrice]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(appliesToPrice: AppliesToPrice) = apply { - id = appliesToPrice.id - name = appliesToPrice.name - additionalProperties = appliesToPrice.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun name(name: String) = name(JsonField.of(name)) - - 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) - } - - fun build(): AppliesToPrice = - AppliesToPrice( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AppliesToPrice && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AppliesToPrice{id=$id, name=$name, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MaximumAmountAdjustment && amountApplied == other.amountApplied && discountType == other.discountType && percentageDiscount == other.percentageDiscount && appliesToPrices == other.appliesToPrices && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amountApplied, discountType, percentageDiscount, appliesToPrices, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MaximumAmountAdjustment{amountApplied=$amountApplied, discountType=$discountType, percentageDiscount=$percentageDiscount, appliesToPrices=$appliesToPrices, reason=$reason, additionalProperties=$additionalProperties}" - } - - class Reason @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DUPLICATE = of("Duplicate") - - @JvmField val FRAUDULENT = of("Fraudulent") - - @JvmField val ORDER_CHANGE = of("Order change") - - @JvmField val PRODUCT_UNSATISFACTORY = of("Product unsatisfactory") - - @JvmStatic fun of(value: String) = Reason(JsonField.of(value)) - } - - /** An enum containing [Reason]'s known values. */ - enum class Known { - DUPLICATE, - FRAUDULENT, - ORDER_CHANGE, - PRODUCT_UNSATISFACTORY, - } + /** An enum containing [Reason]'s known values. */ + enum class Known { + DUPLICATE, + FRAUDULENT, + ORDER_CHANGE, + PRODUCT_UNSATISFACTORY, + } /** * An enum containing [Reason]'s known values, as well as an [_UNKNOWN] member. @@ -1963,411 +1303,6 @@ private constructor( override fun toString() = value.toString() } - @NoAutoDetect - class Discount - @JsonCreator - private constructor( - @JsonProperty("amount_applied") - @ExcludeMissing - private val amountApplied: JsonField = JsonMissing.of(), - @JsonProperty("discount_type") - @ExcludeMissing - private val discountType: JsonField = JsonMissing.of(), - @JsonProperty("percentage_discount") - @ExcludeMissing - private val percentageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_prices") - @ExcludeMissing - private val appliesToPrices: JsonField> = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun amountApplied(): String = amountApplied.getRequired("amount_applied") - - fun discountType(): DiscountType = discountType.getRequired("discount_type") - - fun percentageDiscount(): Double = percentageDiscount.getRequired("percentage_discount") - - fun appliesToPrices(): Optional> = - Optional.ofNullable(appliesToPrices.getNullable("applies_to_prices")) - - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("amount_applied") - @ExcludeMissing - fun _amountApplied(): JsonField = amountApplied - - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - - @JsonProperty("percentage_discount") - @ExcludeMissing - fun _percentageDiscount(): JsonField = percentageDiscount - - @JsonProperty("applies_to_prices") - @ExcludeMissing - fun _appliesToPrices(): JsonField> = appliesToPrices - - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Discount = apply { - if (validated) { - return@apply - } - - amountApplied() - discountType() - percentageDiscount() - appliesToPrices().ifPresent { it.forEach { it.validate() } } - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Discount]. */ - class Builder internal constructor() { - - private var amountApplied: JsonField? = null - private var discountType: JsonField? = null - private var percentageDiscount: JsonField? = null - private var appliesToPrices: JsonField>? = null - private var reason: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(discount: Discount) = apply { - amountApplied = discount.amountApplied - discountType = discount.discountType - percentageDiscount = discount.percentageDiscount - appliesToPrices = discount.appliesToPrices.map { it.toMutableList() } - reason = discount.reason - additionalProperties = discount.additionalProperties.toMutableMap() - } - - fun amountApplied(amountApplied: String) = amountApplied(JsonField.of(amountApplied)) - - fun amountApplied(amountApplied: JsonField) = apply { - this.amountApplied = amountApplied - } - - fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) - - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - fun percentageDiscount(percentageDiscount: Double) = - percentageDiscount(JsonField.of(percentageDiscount)) - - fun percentageDiscount(percentageDiscount: JsonField) = apply { - this.percentageDiscount = percentageDiscount - } - - fun appliesToPrices(appliesToPrices: List?) = - appliesToPrices(JsonField.ofNullable(appliesToPrices)) - - fun appliesToPrices(appliesToPrices: Optional>) = - appliesToPrices(appliesToPrices.orElse(null)) - - fun appliesToPrices(appliesToPrices: JsonField>) = apply { - this.appliesToPrices = appliesToPrices.map { it.toMutableList() } - } - - fun addAppliesToPrice(appliesToPrice: AppliesToPrice) = apply { - appliesToPrices = - (appliesToPrices ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPrice) - } - } - - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - fun reason(reason: Optional) = reason(reason.orElse(null)) - - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Discount = - Discount( - checkRequired("amountApplied", amountApplied), - checkRequired("discountType", discountType), - checkRequired("percentageDiscount", percentageDiscount), - (appliesToPrices ?: JsonMissing.of()).map { it.toImmutable() }, - reason, - additionalProperties.toImmutable(), - ) - } - - class DiscountType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val PERCENTAGE = of("percentage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - PERCENTAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE -> Value.PERCENTAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PERCENTAGE -> Known.PERCENTAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class AppliesToPrice - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun name(): String = name.getRequired("name") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AppliesToPrice = apply { - if (validated) { - return@apply - } - - id() - name() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AppliesToPrice]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(appliesToPrice: AppliesToPrice) = apply { - id = appliesToPrice.id - name = appliesToPrice.name - additionalProperties = appliesToPrice.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun name(name: String) = name(JsonField.of(name)) - - 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) - } - - fun build(): AppliesToPrice = - AppliesToPrice( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AppliesToPrice && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AppliesToPrice{id=$id, name=$name, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Discount && amountApplied == other.amountApplied && discountType == other.discountType && percentageDiscount == other.percentageDiscount && appliesToPrices == other.appliesToPrices && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amountApplied, discountType, percentageDiscount, appliesToPrices, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Discount{amountApplied=$amountApplied, discountType=$discountType, percentageDiscount=$percentageDiscount, appliesToPrices=$appliesToPrices, reason=$reason, 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/CreditNoteCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteCreateParams.kt index b5d061447..2c1746f49 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 @@ -13,6 +13,7 @@ import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.Params +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams @@ -114,6 +115,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .lineItems() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -141,14 +150,8 @@ private constructor( fun addLineItem(lineItem: LineItem) = apply { lineItems = - (lineItems ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(lineItem) + (lineItems ?: JsonField.of(mutableListOf())).also { + checkKnown("lineItems", it).add(lineItem) } } @@ -220,6 +223,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [CreditNoteCreateParams]. + * + * The following fields are required: + * ```java + * .lineItems() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -435,6 +446,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [LineItem]. + * + * The following fields are required: + * ```java + * .amount() + * .invoiceLineItemId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteDiscountModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteDiscountModel.kt new file mode 100644 index 000000000..25f0515e6 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteDiscountModel.kt @@ -0,0 +1,431 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class CreditNoteDiscountModel +@JsonCreator +private constructor( + @JsonProperty("amount_applied") + @ExcludeMissing + private val amountApplied: JsonField = JsonMissing.of(), + @JsonProperty("discount_type") + @ExcludeMissing + private val discountType: JsonField = JsonMissing.of(), + @JsonProperty("percentage_discount") + @ExcludeMissing + private val percentageDiscount: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_prices") + @ExcludeMissing + private val appliesToPrices: JsonField> = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + private val reason: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun amountApplied(): String = amountApplied.getRequired("amount_applied") + + fun discountType(): DiscountType = discountType.getRequired("discount_type") + + fun percentageDiscount(): Double = percentageDiscount.getRequired("percentage_discount") + + fun appliesToPrices(): Optional> = + Optional.ofNullable(appliesToPrices.getNullable("applies_to_prices")) + + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + @JsonProperty("amount_applied") + @ExcludeMissing + fun _amountApplied(): JsonField = amountApplied + + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType + + @JsonProperty("percentage_discount") + @ExcludeMissing + fun _percentageDiscount(): JsonField = percentageDiscount + + @JsonProperty("applies_to_prices") + @ExcludeMissing + fun _appliesToPrices(): JsonField> = appliesToPrices + + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): CreditNoteDiscountModel = apply { + if (validated) { + return@apply + } + + amountApplied() + discountType() + percentageDiscount() + appliesToPrices().ifPresent { it.forEach { it.validate() } } + reason() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CreditNoteDiscountModel]. + * + * The following fields are required: + * ```java + * .amountApplied() + * .discountType() + * .percentageDiscount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreditNoteDiscountModel]. */ + class Builder internal constructor() { + + private var amountApplied: JsonField? = null + private var discountType: JsonField? = null + private var percentageDiscount: JsonField? = null + private var appliesToPrices: JsonField>? = null + private var reason: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(creditNoteDiscountModel: CreditNoteDiscountModel) = apply { + amountApplied = creditNoteDiscountModel.amountApplied + discountType = creditNoteDiscountModel.discountType + percentageDiscount = creditNoteDiscountModel.percentageDiscount + appliesToPrices = creditNoteDiscountModel.appliesToPrices.map { it.toMutableList() } + reason = creditNoteDiscountModel.reason + additionalProperties = creditNoteDiscountModel.additionalProperties.toMutableMap() + } + + fun amountApplied(amountApplied: String) = amountApplied(JsonField.of(amountApplied)) + + fun amountApplied(amountApplied: JsonField) = apply { + this.amountApplied = amountApplied + } + + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) + + fun discountType(discountType: JsonField) = apply { + this.discountType = discountType + } + + fun percentageDiscount(percentageDiscount: Double) = + percentageDiscount(JsonField.of(percentageDiscount)) + + fun percentageDiscount(percentageDiscount: JsonField) = apply { + this.percentageDiscount = percentageDiscount + } + + fun appliesToPrices(appliesToPrices: List?) = + appliesToPrices(JsonField.ofNullable(appliesToPrices)) + + fun appliesToPrices(appliesToPrices: Optional>) = + appliesToPrices(appliesToPrices.orElse(null)) + + fun appliesToPrices(appliesToPrices: JsonField>) = apply { + this.appliesToPrices = appliesToPrices.map { it.toMutableList() } + } + + fun addAppliesToPrice(appliesToPrice: AppliesToPrice) = apply { + appliesToPrices = + (appliesToPrices ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPrices", it).add(appliesToPrice) + } + } + + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + fun reason(reason: Optional) = reason(reason.orElse(null)) + + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): CreditNoteDiscountModel = + CreditNoteDiscountModel( + checkRequired("amountApplied", amountApplied), + checkRequired("discountType", discountType), + checkRequired("percentageDiscount", percentageDiscount), + (appliesToPrices ?: JsonMissing.of()).map { it.toImmutable() }, + reason, + additionalProperties.toImmutable(), + ) + } + + class DiscountType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PERCENTAGE = of("percentage") + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + /** An enum containing [DiscountType]'s known values. */ + enum class Known { + PERCENTAGE + } + + /** + * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [DiscountType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PERCENTAGE, + /** + * An enum member indicating that [DiscountType] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PERCENTAGE -> Value.PERCENTAGE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + PERCENTAGE -> Known.PERCENTAGE + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + @NoAutoDetect + class AppliesToPrice + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + fun name(): String = name.getRequired("name") + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): AppliesToPrice = apply { + if (validated) { + return@apply + } + + id() + name() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AppliesToPrice]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AppliesToPrice]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(appliesToPrice: AppliesToPrice) = apply { + id = appliesToPrice.id + name = appliesToPrice.name + additionalProperties = appliesToPrice.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun name(name: String) = name(JsonField.of(name)) + + 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) + } + + fun build(): AppliesToPrice = + AppliesToPrice( + checkRequired("id", id), + checkRequired("name", name), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AppliesToPrice && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AppliesToPrice{id=$id, name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CreditNoteDiscountModel && amountApplied == other.amountApplied && discountType == other.discountType && percentageDiscount == other.percentageDiscount && appliesToPrices == other.appliesToPrices && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(amountApplied, discountType, percentageDiscount, appliesToPrices, reason, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CreditNoteDiscountModel{amountApplied=$amountApplied, discountType=$discountType, percentageDiscount=$percentageDiscount, appliesToPrices=$appliesToPrices, reason=$reason, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteFetchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteFetchParams.kt index 26e906b21..5db34c8c8 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteFetchParams.kt @@ -41,6 +41,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [CreditNoteFetchParams]. + * + * The following fields are required: + * ```java + * .creditNoteId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPage.kt index 41714fb88..f24d45c68 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPage.kt @@ -33,7 +33,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -91,20 +91,20 @@ private constructor( class Response @JsonCreator constructor( - @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), + @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = Optional.ofNullable(data) + fun _data(): Optional>> = Optional.ofNullable(data) @JsonProperty("pagination_metadata") fun _paginationMetadata(): Optional> = @@ -143,12 +143,13 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [CreditNoteListPage]. */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -159,9 +160,9 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { this.data = data } fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) @@ -178,9 +179,9 @@ private constructor( } } - class AutoPager(private val firstPage: CreditNoteListPage) : Iterable { + class AutoPager(private val firstPage: CreditNoteListPage) : Iterable { - override fun iterator(): Iterator = iterator { + override fun iterator(): Iterator = iterator { var page = firstPage var index = 0 while (true) { @@ -192,7 +193,7 @@ private constructor( } } - fun stream(): Stream { + fun stream(): Stream { return StreamSupport.stream(spliterator(), false) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPageAsync.kt index 412d467ba..c48833262 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListPageAsync.kt @@ -34,7 +34,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -94,20 +94,20 @@ private constructor( class Response @JsonCreator constructor( - @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), + @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = Optional.ofNullable(data) + fun _data(): Optional>> = Optional.ofNullable(data) @JsonProperty("pagination_metadata") fun _paginationMetadata(): Optional> = @@ -146,12 +146,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [CreditNoteListPageAsync]. + */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -162,9 +165,9 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { this.data = data } fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) @@ -183,9 +186,12 @@ private constructor( class AutoPager(private val firstPage: CreditNoteListPageAsync) { - fun forEach(action: Predicate, executor: Executor): CompletableFuture { + fun forEach( + action: Predicate, + executor: Executor, + ): CompletableFuture { fun CompletableFuture>.forEach( - action: (CreditNote) -> Boolean, + action: (CreditNoteModel) -> Boolean, executor: Executor, ): CompletableFuture = thenComposeAsync( @@ -201,8 +207,8 @@ private constructor( .forEach(action::test, executor) } - fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() + fun toList(executor: Executor): CompletableFuture> { + val values = mutableListOf() return forEach(values::add, executor).thenApply { values } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListParams.kt index 3b303e1bb..d7419e76c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListParams.kt @@ -51,6 +51,7 @@ private constructor( @JvmStatic fun none(): CreditNoteListParams = builder().build() + /** Returns a mutable builder for constructing an instance of [CreditNoteListParams]. */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteModel.kt new file mode 100644 index 000000000..44b5d9434 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteModel.kt @@ -0,0 +1,1322 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +/** + * The [Credit Note](/invoicing/credit-notes) resource represents a credit that has been applied to + * a particular invoice. + */ +@NoAutoDetect +class CreditNoteModel +@JsonCreator +private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_note_number") + @ExcludeMissing + private val creditNoteNumber: JsonField = JsonMissing.of(), + @JsonProperty("credit_note_pdf") + @ExcludeMissing + private val creditNotePdf: JsonField = JsonMissing.of(), + @JsonProperty("customer") + @ExcludeMissing + private val customer: JsonField = JsonMissing.of(), + @JsonProperty("invoice_id") + @ExcludeMissing + private val invoiceId: JsonField = JsonMissing.of(), + @JsonProperty("line_items") + @ExcludeMissing + private val lineItems: JsonField> = JsonMissing.of(), + @JsonProperty("maximum_amount_adjustment") + @ExcludeMissing + private val maximumAmountAdjustment: JsonField = JsonMissing.of(), + @JsonProperty("memo") @ExcludeMissing private val memo: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount_refunded") + @ExcludeMissing + private val minimumAmountRefunded: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + private val reason: JsonField = JsonMissing.of(), + @JsonProperty("subtotal") + @ExcludeMissing + private val subtotal: JsonField = JsonMissing.of(), + @JsonProperty("total") @ExcludeMissing private val total: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonProperty("voided_at") + @ExcludeMissing + private val voidedAt: JsonField = JsonMissing.of(), + @JsonProperty("discounts") + @ExcludeMissing + private val discounts: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** The Orb id of this credit note. */ + fun id(): String = id.getRequired("id") + + /** The creation time of the resource in Orb. */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** The unique identifier for credit notes. */ + fun creditNoteNumber(): String = creditNoteNumber.getRequired("credit_note_number") + + /** A URL to a PDF of the credit note. */ + fun creditNotePdf(): Optional = + Optional.ofNullable(creditNotePdf.getNullable("credit_note_pdf")) + + fun customer(): CustomerMinifiedModel = customer.getRequired("customer") + + /** The id of the invoice resource that this credit note is applied to. */ + fun invoiceId(): String = invoiceId.getRequired("invoice_id") + + /** All of the line items associated with this credit note. */ + fun lineItems(): List = lineItems.getRequired("line_items") + + /** The maximum amount applied on the original invoice */ + fun maximumAmountAdjustment(): Optional = + Optional.ofNullable(maximumAmountAdjustment.getNullable("maximum_amount_adjustment")) + + /** An optional memo supplied on the credit note. */ + fun memo(): Optional = Optional.ofNullable(memo.getNullable("memo")) + + /** Any credited amount from the applied minimum on the invoice. */ + fun minimumAmountRefunded(): Optional = + Optional.ofNullable(minimumAmountRefunded.getNullable("minimum_amount_refunded")) + + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + /** The total prior to any creditable invoice-level discounts or minimums. */ + fun subtotal(): String = subtotal.getRequired("subtotal") + + /** The total including creditable invoice-level discounts or minimums, and tax. */ + fun total(): String = total.getRequired("total") + + fun type(): Type = type.getRequired("type") + + /** The time at which the credit note was voided in Orb, if applicable. */ + fun voidedAt(): Optional = + Optional.ofNullable(voidedAt.getNullable("voided_at")) + + /** Any discounts applied on the original invoice. */ + fun discounts(): Optional> = + Optional.ofNullable(discounts.getNullable("discounts")) + + /** The Orb id of this credit note. */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** The creation time of the resource in Orb. */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** The unique identifier for credit notes. */ + @JsonProperty("credit_note_number") + @ExcludeMissing + fun _creditNoteNumber(): JsonField = creditNoteNumber + + /** A URL to a PDF of the credit note. */ + @JsonProperty("credit_note_pdf") + @ExcludeMissing + fun _creditNotePdf(): JsonField = creditNotePdf + + @JsonProperty("customer") + @ExcludeMissing + fun _customer(): JsonField = customer + + /** The id of the invoice resource that this credit note is applied to. */ + @JsonProperty("invoice_id") @ExcludeMissing fun _invoiceId(): JsonField = invoiceId + + /** All of the line items associated with this credit note. */ + @JsonProperty("line_items") + @ExcludeMissing + fun _lineItems(): JsonField> = lineItems + + /** The maximum amount applied on the original invoice */ + @JsonProperty("maximum_amount_adjustment") + @ExcludeMissing + fun _maximumAmountAdjustment(): JsonField = maximumAmountAdjustment + + /** An optional memo supplied on the credit note. */ + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo + + /** Any credited amount from the applied minimum on the invoice. */ + @JsonProperty("minimum_amount_refunded") + @ExcludeMissing + fun _minimumAmountRefunded(): JsonField = minimumAmountRefunded + + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + + /** The total prior to any creditable invoice-level discounts or minimums. */ + @JsonProperty("subtotal") @ExcludeMissing fun _subtotal(): JsonField = subtotal + + /** The total including creditable invoice-level discounts or minimums, and tax. */ + @JsonProperty("total") @ExcludeMissing fun _total(): JsonField = total + + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** The time at which the credit note was voided in Orb, if applicable. */ + @JsonProperty("voided_at") @ExcludeMissing fun _voidedAt(): JsonField = voidedAt + + /** Any discounts applied on the original invoice. */ + @JsonProperty("discounts") + @ExcludeMissing + fun _discounts(): JsonField> = discounts + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): CreditNoteModel = apply { + if (validated) { + return@apply + } + + id() + createdAt() + creditNoteNumber() + creditNotePdf() + customer().validate() + invoiceId() + lineItems().forEach { it.validate() } + maximumAmountAdjustment().ifPresent { it.validate() } + memo() + minimumAmountRefunded() + reason() + subtotal() + total() + type() + voidedAt() + discounts().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CreditNoteModel]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .creditNoteNumber() + * .creditNotePdf() + * .customer() + * .invoiceId() + * .lineItems() + * .maximumAmountAdjustment() + * .memo() + * .minimumAmountRefunded() + * .reason() + * .subtotal() + * .total() + * .type() + * .voidedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreditNoteModel]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var createdAt: JsonField? = null + private var creditNoteNumber: JsonField? = null + private var creditNotePdf: JsonField? = null + private var customer: JsonField? = null + private var invoiceId: JsonField? = null + private var lineItems: JsonField>? = null + private var maximumAmountAdjustment: JsonField? = null + private var memo: JsonField? = null + private var minimumAmountRefunded: JsonField? = null + private var reason: JsonField? = null + private var subtotal: JsonField? = null + private var total: JsonField? = null + private var type: JsonField? = null + private var voidedAt: JsonField? = null + private var discounts: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(creditNoteModel: CreditNoteModel) = apply { + id = creditNoteModel.id + createdAt = creditNoteModel.createdAt + creditNoteNumber = creditNoteModel.creditNoteNumber + creditNotePdf = creditNoteModel.creditNotePdf + customer = creditNoteModel.customer + invoiceId = creditNoteModel.invoiceId + lineItems = creditNoteModel.lineItems.map { it.toMutableList() } + maximumAmountAdjustment = creditNoteModel.maximumAmountAdjustment + memo = creditNoteModel.memo + minimumAmountRefunded = creditNoteModel.minimumAmountRefunded + reason = creditNoteModel.reason + subtotal = creditNoteModel.subtotal + total = creditNoteModel.total + type = creditNoteModel.type + voidedAt = creditNoteModel.voidedAt + discounts = creditNoteModel.discounts.map { it.toMutableList() } + additionalProperties = creditNoteModel.additionalProperties.toMutableMap() + } + + /** The Orb id of this credit note. */ + fun id(id: String) = id(JsonField.of(id)) + + /** The Orb id of this credit note. */ + fun id(id: JsonField) = apply { this.id = id } + + /** The creation time of the resource in Orb. */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** The creation time of the resource in Orb. */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + /** The unique identifier for credit notes. */ + fun creditNoteNumber(creditNoteNumber: String) = + creditNoteNumber(JsonField.of(creditNoteNumber)) + + /** The unique identifier for credit notes. */ + fun creditNoteNumber(creditNoteNumber: JsonField) = apply { + this.creditNoteNumber = creditNoteNumber + } + + /** A URL to a PDF of the credit note. */ + fun creditNotePdf(creditNotePdf: String?) = + creditNotePdf(JsonField.ofNullable(creditNotePdf)) + + /** A URL to a PDF of the credit note. */ + fun creditNotePdf(creditNotePdf: Optional) = + creditNotePdf(creditNotePdf.orElse(null)) + + /** A URL to a PDF of the credit note. */ + fun creditNotePdf(creditNotePdf: JsonField) = apply { + this.creditNotePdf = creditNotePdf + } + + fun customer(customer: CustomerMinifiedModel) = customer(JsonField.of(customer)) + + fun customer(customer: JsonField) = apply { + this.customer = customer + } + + /** The id of the invoice resource that this credit note is applied to. */ + fun invoiceId(invoiceId: String) = invoiceId(JsonField.of(invoiceId)) + + /** The id of the invoice resource that this credit note is applied to. */ + fun invoiceId(invoiceId: JsonField) = apply { this.invoiceId = invoiceId } + + /** All of the line items associated with this credit note. */ + fun lineItems(lineItems: List) = lineItems(JsonField.of(lineItems)) + + /** All of the line items associated with this credit note. */ + fun lineItems(lineItems: JsonField>) = apply { + this.lineItems = lineItems.map { it.toMutableList() } + } + + /** All of the line items associated with this credit note. */ + fun addLineItem(lineItem: LineItem) = apply { + lineItems = + (lineItems ?: JsonField.of(mutableListOf())).also { + checkKnown("lineItems", it).add(lineItem) + } + } + + /** The maximum amount applied on the original invoice */ + fun maximumAmountAdjustment(maximumAmountAdjustment: CreditNoteDiscountModel?) = + maximumAmountAdjustment(JsonField.ofNullable(maximumAmountAdjustment)) + + /** The maximum amount applied on the original invoice */ + fun maximumAmountAdjustment(maximumAmountAdjustment: Optional) = + maximumAmountAdjustment(maximumAmountAdjustment.orElse(null)) + + /** The maximum amount applied on the original invoice */ + fun maximumAmountAdjustment(maximumAmountAdjustment: JsonField) = + apply { + this.maximumAmountAdjustment = maximumAmountAdjustment + } + + /** An optional memo supplied on the credit note. */ + fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) + + /** An optional memo supplied on the credit note. */ + fun memo(memo: Optional) = memo(memo.orElse(null)) + + /** An optional memo supplied on the credit note. */ + fun memo(memo: JsonField) = apply { this.memo = memo } + + /** Any credited amount from the applied minimum on the invoice. */ + fun minimumAmountRefunded(minimumAmountRefunded: String?) = + minimumAmountRefunded(JsonField.ofNullable(minimumAmountRefunded)) + + /** Any credited amount from the applied minimum on the invoice. */ + fun minimumAmountRefunded(minimumAmountRefunded: Optional) = + minimumAmountRefunded(minimumAmountRefunded.orElse(null)) + + /** Any credited amount from the applied minimum on the invoice. */ + fun minimumAmountRefunded(minimumAmountRefunded: JsonField) = apply { + this.minimumAmountRefunded = minimumAmountRefunded + } + + fun reason(reason: Reason?) = reason(JsonField.ofNullable(reason)) + + fun reason(reason: Optional) = reason(reason.orElse(null)) + + fun reason(reason: JsonField) = apply { this.reason = reason } + + /** The total prior to any creditable invoice-level discounts or minimums. */ + fun subtotal(subtotal: String) = subtotal(JsonField.of(subtotal)) + + /** The total prior to any creditable invoice-level discounts or minimums. */ + fun subtotal(subtotal: JsonField) = apply { this.subtotal = subtotal } + + /** The total including creditable invoice-level discounts or minimums, and tax. */ + fun total(total: String) = total(JsonField.of(total)) + + /** The total including creditable invoice-level discounts or minimums, and tax. */ + fun total(total: JsonField) = apply { this.total = total } + + fun type(type: Type) = type(JsonField.of(type)) + + fun type(type: JsonField) = apply { this.type = type } + + /** The time at which the credit note was voided in Orb, if applicable. */ + fun voidedAt(voidedAt: OffsetDateTime?) = voidedAt(JsonField.ofNullable(voidedAt)) + + /** The time at which the credit note was voided in Orb, if applicable. */ + fun voidedAt(voidedAt: Optional) = voidedAt(voidedAt.orElse(null)) + + /** The time at which the credit note was voided in Orb, if applicable. */ + fun voidedAt(voidedAt: JsonField) = apply { this.voidedAt = voidedAt } + + /** Any discounts applied on the original invoice. */ + fun discounts(discounts: List) = discounts(JsonField.of(discounts)) + + /** Any discounts applied on the original invoice. */ + fun discounts(discounts: JsonField>) = apply { + this.discounts = discounts.map { it.toMutableList() } + } + + /** Any discounts applied on the original invoice. */ + fun addDiscount(discount: CreditNoteDiscountModel) = apply { + discounts = + (discounts ?: JsonField.of(mutableListOf())).also { + checkKnown("discounts", it).add(discount) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): CreditNoteModel = + CreditNoteModel( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("creditNoteNumber", creditNoteNumber), + checkRequired("creditNotePdf", creditNotePdf), + checkRequired("customer", customer), + checkRequired("invoiceId", invoiceId), + checkRequired("lineItems", lineItems).map { it.toImmutable() }, + checkRequired("maximumAmountAdjustment", maximumAmountAdjustment), + checkRequired("memo", memo), + checkRequired("minimumAmountRefunded", minimumAmountRefunded), + checkRequired("reason", reason), + checkRequired("subtotal", subtotal), + checkRequired("total", total), + checkRequired("type", type), + checkRequired("voidedAt", voidedAt), + (discounts ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + @NoAutoDetect + class LineItem + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("quantity") + @ExcludeMissing + private val quantity: JsonField = JsonMissing.of(), + @JsonProperty("subtotal") + @ExcludeMissing + private val subtotal: JsonField = JsonMissing.of(), + @JsonProperty("tax_amounts") + @ExcludeMissing + private val taxAmounts: JsonField> = JsonMissing.of(), + @JsonProperty("discounts") + @ExcludeMissing + private val discounts: JsonField> = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The Orb id of this resource. */ + fun id(): String = id.getRequired("id") + + /** The amount of the line item, including any line item minimums and discounts. */ + fun amount(): String = amount.getRequired("amount") + + /** The id of the item associated with this line item. */ + fun itemId(): String = itemId.getRequired("item_id") + + /** The name of the corresponding invoice line item. */ + fun name(): String = name.getRequired("name") + + /** An optional quantity credited. */ + fun quantity(): Optional = Optional.ofNullable(quantity.getNullable("quantity")) + + /** The amount of the line item, excluding any line item minimums and discounts. */ + fun subtotal(): String = subtotal.getRequired("subtotal") + + /** Any tax amounts applied onto the line item. */ + fun taxAmounts(): List = taxAmounts.getRequired("tax_amounts") + + /** Any line item discounts from the invoice's line item. */ + fun discounts(): Optional> = + Optional.ofNullable(discounts.getNullable("discounts")) + + /** The Orb id of this resource. */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** The amount of the line item, including any line item minimums and discounts. */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** The id of the item associated with this line item. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + /** The name of the corresponding invoice line item. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** An optional quantity credited. */ + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity + + /** The amount of the line item, excluding any line item minimums and discounts. */ + @JsonProperty("subtotal") @ExcludeMissing fun _subtotal(): JsonField = subtotal + + /** Any tax amounts applied onto the line item. */ + @JsonProperty("tax_amounts") + @ExcludeMissing + fun _taxAmounts(): JsonField> = taxAmounts + + /** Any line item discounts from the invoice's line item. */ + @JsonProperty("discounts") + @ExcludeMissing + fun _discounts(): JsonField> = discounts + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): LineItem = apply { + if (validated) { + return@apply + } + + id() + amount() + itemId() + name() + quantity() + subtotal() + taxAmounts().forEach { it.validate() } + discounts().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LineItem]. + * + * The following fields are required: + * ```java + * .id() + * .amount() + * .itemId() + * .name() + * .quantity() + * .subtotal() + * .taxAmounts() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LineItem]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var amount: JsonField? = null + private var itemId: JsonField? = null + private var name: JsonField? = null + private var quantity: JsonField? = null + private var subtotal: JsonField? = null + private var taxAmounts: JsonField>? = null + private var discounts: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(lineItem: LineItem) = apply { + id = lineItem.id + amount = lineItem.amount + itemId = lineItem.itemId + name = lineItem.name + quantity = lineItem.quantity + subtotal = lineItem.subtotal + taxAmounts = lineItem.taxAmounts.map { it.toMutableList() } + discounts = lineItem.discounts.map { it.toMutableList() } + additionalProperties = lineItem.additionalProperties.toMutableMap() + } + + /** The Orb id of this resource. */ + fun id(id: String) = id(JsonField.of(id)) + + /** The Orb id of this resource. */ + fun id(id: JsonField) = apply { this.id = id } + + /** The amount of the line item, including any line item minimums and discounts. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** The amount of the line item, including any line item minimums and discounts. */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The id of the item associated with this line item. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** The id of the item associated with this line item. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + /** The name of the corresponding invoice line item. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the corresponding invoice line item. */ + fun name(name: JsonField) = apply { this.name = name } + + /** An optional quantity credited. */ + fun quantity(quantity: Double?) = quantity(JsonField.ofNullable(quantity)) + + /** An optional quantity credited. */ + fun quantity(quantity: Double) = quantity(quantity as Double?) + + /** An optional quantity credited. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun quantity(quantity: Optional) = quantity(quantity.orElse(null) as Double?) + + /** An optional quantity credited. */ + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + /** The amount of the line item, excluding any line item minimums and discounts. */ + fun subtotal(subtotal: String) = subtotal(JsonField.of(subtotal)) + + /** The amount of the line item, excluding any line item minimums and discounts. */ + fun subtotal(subtotal: JsonField) = apply { this.subtotal = subtotal } + + /** Any tax amounts applied onto the line item. */ + fun taxAmounts(taxAmounts: List) = taxAmounts(JsonField.of(taxAmounts)) + + /** Any tax amounts applied onto the line item. */ + fun taxAmounts(taxAmounts: JsonField>) = apply { + this.taxAmounts = taxAmounts.map { it.toMutableList() } + } + + /** Any tax amounts applied onto the line item. */ + fun addTaxAmount(taxAmount: TaxAmountModel) = apply { + taxAmounts = + (taxAmounts ?: JsonField.of(mutableListOf())).also { + checkKnown("taxAmounts", it).add(taxAmount) + } + } + + /** Any line item discounts from the invoice's line item. */ + fun discounts(discounts: List) = discounts(JsonField.of(discounts)) + + /** Any line item discounts from the invoice's line item. */ + fun discounts(discounts: JsonField>) = apply { + this.discounts = discounts.map { it.toMutableList() } + } + + /** Any line item discounts from the invoice's line item. */ + fun addDiscount(discount: Discount) = apply { + discounts = + (discounts ?: JsonField.of(mutableListOf())).also { + checkKnown("discounts", it).add(discount) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): LineItem = + LineItem( + checkRequired("id", id), + checkRequired("amount", amount), + checkRequired("itemId", itemId), + checkRequired("name", name), + checkRequired("quantity", quantity), + checkRequired("subtotal", subtotal), + checkRequired("taxAmounts", taxAmounts).map { it.toImmutable() }, + (discounts ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + @NoAutoDetect + class Discount + @JsonCreator + private constructor( + @JsonProperty("id") + @ExcludeMissing + private val id: JsonField = JsonMissing.of(), + @JsonProperty("amount_applied") + @ExcludeMissing + private val amountApplied: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("discount_type") + @ExcludeMissing + private val discountType: JsonField = JsonMissing.of(), + @JsonProperty("percentage_discount") + @ExcludeMissing + private val percentageDiscount: JsonField = JsonMissing.of(), + @JsonProperty("amount_discount") + @ExcludeMissing + private val amountDiscount: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + private val reason: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + fun amountApplied(): String = amountApplied.getRequired("amount_applied") + + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + fun discountType(): DiscountType = discountType.getRequired("discount_type") + + fun percentageDiscount(): Double = percentageDiscount.getRequired("percentage_discount") + + fun amountDiscount(): Optional = + Optional.ofNullable(amountDiscount.getNullable("amount_discount")) + + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("amount_applied") + @ExcludeMissing + fun _amountApplied(): JsonField = amountApplied + + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType + + @JsonProperty("percentage_discount") + @ExcludeMissing + fun _percentageDiscount(): JsonField = percentageDiscount + + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount(): JsonField = amountDiscount + + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Discount = apply { + if (validated) { + return@apply + } + + id() + amountApplied() + appliesToPriceIds() + discountType() + percentageDiscount() + amountDiscount() + reason() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Discount]. + * + * The following fields are required: + * ```java + * .id() + * .amountApplied() + * .appliesToPriceIds() + * .discountType() + * .percentageDiscount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Discount]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var amountApplied: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var discountType: JsonField? = null + private var percentageDiscount: JsonField? = null + private var amountDiscount: JsonField = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(discount: Discount) = apply { + id = discount.id + amountApplied = discount.amountApplied + appliesToPriceIds = discount.appliesToPriceIds.map { it.toMutableList() } + discountType = discount.discountType + percentageDiscount = discount.percentageDiscount + amountDiscount = discount.amountDiscount + reason = discount.reason + additionalProperties = discount.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun amountApplied(amountApplied: String) = + amountApplied(JsonField.of(amountApplied)) + + fun amountApplied(amountApplied: JsonField) = apply { + this.amountApplied = amountApplied + } + + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + fun discountType(discountType: JsonField) = apply { + this.discountType = discountType + } + + fun percentageDiscount(percentageDiscount: Double) = + percentageDiscount(JsonField.of(percentageDiscount)) + + fun percentageDiscount(percentageDiscount: JsonField) = apply { + this.percentageDiscount = percentageDiscount + } + + fun amountDiscount(amountDiscount: String?) = + amountDiscount(JsonField.ofNullable(amountDiscount)) + + fun amountDiscount(amountDiscount: Optional) = + amountDiscount(amountDiscount.orElse(null)) + + fun amountDiscount(amountDiscount: JsonField) = apply { + this.amountDiscount = amountDiscount + } + + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + fun reason(reason: Optional) = reason(reason.orElse(null)) + + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): Discount = + Discount( + checkRequired("id", id), + checkRequired("amountApplied", amountApplied), + checkRequired("appliesToPriceIds", appliesToPriceIds).map { + it.toImmutable() + }, + checkRequired("discountType", discountType), + checkRequired("percentageDiscount", percentageDiscount), + amountDiscount, + reason, + additionalProperties.toImmutable(), + ) + } + + class DiscountType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PERCENTAGE = of("percentage") + + @JvmField val AMOUNT = of("amount") + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + /** An enum containing [DiscountType]'s known values. */ + enum class Known { + PERCENTAGE, + AMOUNT, + } + + /** + * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [DiscountType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PERCENTAGE, + AMOUNT, + /** + * An enum member indicating that [DiscountType] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PERCENTAGE -> Value.PERCENTAGE + AMOUNT -> Value.AMOUNT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PERCENTAGE -> Known.PERCENTAGE + AMOUNT -> Known.AMOUNT + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Discount && id == other.id && amountApplied == other.amountApplied && appliesToPriceIds == other.appliesToPriceIds && discountType == other.discountType && percentageDiscount == other.percentageDiscount && amountDiscount == other.amountDiscount && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, amountApplied, appliesToPriceIds, discountType, percentageDiscount, amountDiscount, reason, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Discount{id=$id, amountApplied=$amountApplied, appliesToPriceIds=$appliesToPriceIds, discountType=$discountType, percentageDiscount=$percentageDiscount, amountDiscount=$amountDiscount, reason=$reason, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is LineItem && id == other.id && amount == other.amount && itemId == other.itemId && name == other.name && quantity == other.quantity && subtotal == other.subtotal && taxAmounts == other.taxAmounts && discounts == other.discounts && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, amount, itemId, name, quantity, subtotal, taxAmounts, discounts, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LineItem{id=$id, amount=$amount, itemId=$itemId, name=$name, quantity=$quantity, subtotal=$subtotal, taxAmounts=$taxAmounts, discounts=$discounts, additionalProperties=$additionalProperties}" + } + + class Reason @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val DUPLICATE = of("Duplicate") + + @JvmField val FRAUDULENT = of("Fraudulent") + + @JvmField val ORDER_CHANGE = of("Order change") + + @JvmField val PRODUCT_UNSATISFACTORY = of("Product unsatisfactory") + + @JvmStatic fun of(value: String) = Reason(JsonField.of(value)) + } + + /** An enum containing [Reason]'s known values. */ + enum class Known { + DUPLICATE, + FRAUDULENT, + ORDER_CHANGE, + PRODUCT_UNSATISFACTORY, + } + + /** + * An enum containing [Reason]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Reason] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + DUPLICATE, + FRAUDULENT, + ORDER_CHANGE, + PRODUCT_UNSATISFACTORY, + /** An enum member indicating that [Reason] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + DUPLICATE -> Value.DUPLICATE + FRAUDULENT -> Value.FRAUDULENT + ORDER_CHANGE -> Value.ORDER_CHANGE + PRODUCT_UNSATISFACTORY -> Value.PRODUCT_UNSATISFACTORY + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + DUPLICATE -> Known.DUPLICATE + FRAUDULENT -> Known.FRAUDULENT + ORDER_CHANGE -> Known.ORDER_CHANGE + PRODUCT_UNSATISFACTORY -> Known.PRODUCT_UNSATISFACTORY + else -> throw OrbInvalidDataException("Unknown Reason: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if 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 + } + + return /* spotless:off */ other is Reason && value == other.value /* spotless:on */ + } + + 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 REFUND = of("refund") + + @JvmField val ADJUSTMENT = of("adjustment") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + REFUND, + ADJUSTMENT, + } + + /** + * 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 { + REFUND, + ADJUSTMENT, + /** 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) { + REFUND -> Value.REFUND + ADJUSTMENT -> Value.ADJUSTMENT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + REFUND -> Known.REFUND + ADJUSTMENT -> Known.ADJUSTMENT + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CreditNoteModel && id == other.id && createdAt == other.createdAt && creditNoteNumber == other.creditNoteNumber && creditNotePdf == other.creditNotePdf && customer == other.customer && invoiceId == other.invoiceId && lineItems == other.lineItems && maximumAmountAdjustment == other.maximumAmountAdjustment && memo == other.memo && minimumAmountRefunded == other.minimumAmountRefunded && reason == other.reason && subtotal == other.subtotal && total == other.total && type == other.type && voidedAt == other.voidedAt && discounts == other.discounts && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, createdAt, creditNoteNumber, creditNotePdf, customer, invoiceId, lineItems, maximumAmountAdjustment, memo, minimumAmountRefunded, reason, subtotal, total, type, voidedAt, discounts, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CreditNoteModel{id=$id, createdAt=$createdAt, creditNoteNumber=$creditNoteNumber, creditNotePdf=$creditNotePdf, customer=$customer, invoiceId=$invoiceId, lineItems=$lineItems, maximumAmountAdjustment=$maximumAmountAdjustment, memo=$memo, minimumAmountRefunded=$minimumAmountRefunded, reason=$reason, subtotal=$subtotal, total=$total, type=$type, voidedAt=$voidedAt, discounts=$discounts, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteSummaryModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteSummaryModel.kt new file mode 100644 index 000000000..c08e41ae5 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteSummaryModel.kt @@ -0,0 +1,246 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class CreditNoteSummaryModel +@JsonCreator +private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("credit_note_number") + @ExcludeMissing + private val creditNoteNumber: JsonField = JsonMissing.of(), + @JsonProperty("memo") @ExcludeMissing private val memo: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + private val reason: JsonField = JsonMissing.of(), + @JsonProperty("total") @ExcludeMissing private val total: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonProperty("voided_at") + @ExcludeMissing + private val voidedAt: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun id(): String = id.getRequired("id") + + fun creditNoteNumber(): String = creditNoteNumber.getRequired("credit_note_number") + + /** An optional memo supplied on the credit note. */ + fun memo(): Optional = Optional.ofNullable(memo.getNullable("memo")) + + fun reason(): String = reason.getRequired("reason") + + fun total(): String = total.getRequired("total") + + 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. + */ + fun voidedAt(): Optional = + Optional.ofNullable(voidedAt.getNullable("voided_at")) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("credit_note_number") + @ExcludeMissing + fun _creditNoteNumber(): JsonField = creditNoteNumber + + /** An optional memo supplied on the credit note. */ + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo + + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + + @JsonProperty("total") @ExcludeMissing fun _total(): JsonField = total + + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * If the credit note has a status of `void`, this gives a timestamp when the credit note was + * voided. + */ + @JsonProperty("voided_at") @ExcludeMissing fun _voidedAt(): JsonField = voidedAt + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): CreditNoteSummaryModel = apply { + if (validated) { + return@apply + } + + id() + creditNoteNumber() + memo() + reason() + total() + type() + voidedAt() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CreditNoteSummaryModel]. + * + * The following fields are required: + * ```java + * .id() + * .creditNoteNumber() + * .memo() + * .reason() + * .total() + * .type() + * .voidedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreditNoteSummaryModel]. */ + 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(creditNoteSummaryModel: CreditNoteSummaryModel) = apply { + id = creditNoteSummaryModel.id + creditNoteNumber = creditNoteSummaryModel.creditNoteNumber + memo = creditNoteSummaryModel.memo + reason = creditNoteSummaryModel.reason + total = creditNoteSummaryModel.total + type = creditNoteSummaryModel.type + voidedAt = creditNoteSummaryModel.voidedAt + additionalProperties = creditNoteSummaryModel.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun creditNoteNumber(creditNoteNumber: String) = + creditNoteNumber(JsonField.of(creditNoteNumber)) + + fun creditNoteNumber(creditNoteNumber: JsonField) = apply { + this.creditNoteNumber = creditNoteNumber + } + + /** An optional memo supplied on the credit note. */ + fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) + + /** An optional memo supplied on the credit note. */ + fun memo(memo: Optional) = memo(memo.orElse(null)) + + /** An optional memo supplied on the credit note. */ + fun memo(memo: JsonField) = apply { this.memo = memo } + + fun reason(reason: String) = reason(JsonField.of(reason)) + + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun total(total: String) = total(JsonField.of(total)) + + fun total(total: JsonField) = apply { this.total = total } + + fun type(type: String) = type(JsonField.of(type)) + + 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)) + + /** + * If the credit note has a status of `void`, this gives a timestamp when the credit note + * was voided. + */ + fun voidedAt(voidedAt: Optional) = voidedAt(voidedAt.orElse(null)) + + /** + * If the credit note has a status of `void`, this gives a timestamp when the credit note + * was voided. + */ + 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) + } + + fun build(): CreditNoteSummaryModel = + CreditNoteSummaryModel( + checkRequired("id", id), + checkRequired("creditNoteNumber", creditNoteNumber), + checkRequired("memo", memo), + checkRequired("reason", reason), + checkRequired("total", total), + checkRequired("type", type), + checkRequired("voidedAt", voidedAt), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CreditNoteSummaryModel && id == other.id && creditNoteNumber == other.creditNoteNumber && memo == other.memo && reason == other.reason && total == other.total && type == other.type && voidedAt == other.voidedAt && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, creditNoteNumber, memo, reason, total, type, voidedAt, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CreditNoteSummaryModel{id=$id, creditNoteNumber=$creditNoteNumber, memo=$memo, reason=$reason, total=$total, type=$type, voidedAt=$voidedAt, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomRatingFunctionConfigModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomRatingFunctionConfigModel.kt new file mode 100644 index 000000000..262592006 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomRatingFunctionConfigModel.kt @@ -0,0 +1,98 @@ +// 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.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.NoAutoDetect +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects + +@NoAutoDetect +class CustomRatingFunctionConfigModel +@JsonCreator +private constructor( + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap() +) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): CustomRatingFunctionConfigModel = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CustomRatingFunctionConfigModel]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomRatingFunctionConfigModel]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(customRatingFunctionConfigModel: CustomRatingFunctionConfigModel) = + apply { + additionalProperties = + customRatingFunctionConfigModel.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) + } + + fun build(): CustomRatingFunctionConfigModel = + CustomRatingFunctionConfigModel(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CustomRatingFunctionConfigModel && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomRatingFunctionConfigModel{additionalProperties=$additionalProperties}" +} 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 9ddfbdf16..bde238221 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 @@ -12,6 +12,7 @@ import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.immutableEmptyMap import com.withorb.api.core.toImmutable @@ -54,7 +55,7 @@ private constructor( private val balance: JsonField = JsonMissing.of(), @JsonProperty("billing_address") @ExcludeMissing - private val billingAddress: JsonField = JsonMissing.of(), + private val billingAddress: JsonField = JsonMissing.of(), @JsonProperty("created_at") @ExcludeMissing private val createdAt: JsonField = JsonMissing.of(), @@ -89,8 +90,10 @@ private constructor( private val portalUrl: JsonField = JsonMissing.of(), @JsonProperty("shipping_address") @ExcludeMissing - private val shippingAddress: JsonField = JsonMissing.of(), - @JsonProperty("tax_id") @ExcludeMissing private val taxId: JsonField = JsonMissing.of(), + private val shippingAddress: JsonField = JsonMissing.of(), + @JsonProperty("tax_id") + @ExcludeMissing + private val taxId: JsonField = JsonMissing.of(), @JsonProperty("timezone") @ExcludeMissing private val timezone: JsonField = JsonMissing.of(), @@ -113,7 +116,7 @@ private constructor( /** The customer's current balance in their currency. */ fun balance(): String = balance.getRequired("balance") - fun billingAddress(): Optional = + fun billingAddress(): Optional = Optional.ofNullable(billingAddress.getNullable("billing_address")) fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") @@ -168,7 +171,7 @@ private constructor( fun portalUrl(): Optional = Optional.ofNullable(portalUrl.getNullable("portal_url")) - fun shippingAddress(): Optional = + fun shippingAddress(): Optional = Optional.ofNullable(shippingAddress.getNullable("shipping_address")) /** @@ -277,7 +280,7 @@ private constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - fun taxId(): Optional = Optional.ofNullable(taxId.getNullable("tax_id")) + fun taxId(): Optional = Optional.ofNullable(taxId.getNullable("tax_id")) /** * A timezone identifier from the IANA timezone database, such as "America/Los_Angeles". This @@ -309,7 +312,7 @@ private constructor( @JsonProperty("billing_address") @ExcludeMissing - fun _billingAddress(): JsonField = billingAddress + fun _billingAddress(): JsonField = billingAddress @JsonProperty("created_at") @ExcludeMissing @@ -373,7 +376,7 @@ private constructor( @JsonProperty("shipping_address") @ExcludeMissing - fun _shippingAddress(): JsonField = shippingAddress + fun _shippingAddress(): JsonField = shippingAddress /** * Tax IDs are commonly required to be displayed on customer invoices, which are added to the @@ -481,7 +484,7 @@ private constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - @JsonProperty("tax_id") @ExcludeMissing fun _taxId(): JsonField = taxId + @JsonProperty("tax_id") @ExcludeMissing fun _taxId(): JsonField = taxId /** * A timezone identifier from the IANA timezone database, such as "America/Los_Angeles". This @@ -539,6 +542,33 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Customer]. + * + * The following fields are required: + * ```java + * .id() + * .additionalEmails() + * .autoCollection() + * .balance() + * .billingAddress() + * .createdAt() + * .currency() + * .email() + * .emailDelivery() + * .exemptFromAutomatedTax() + * .externalCustomerId() + * .hierarchy() + * .metadata() + * .name() + * .paymentProvider() + * .paymentProviderId() + * .portalUrl() + * .shippingAddress() + * .taxId() + * .timezone() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -549,7 +579,7 @@ private constructor( private var additionalEmails: JsonField>? = null private var autoCollection: JsonField? = null private var balance: JsonField? = null - private var billingAddress: JsonField? = null + private var billingAddress: JsonField? = null private var createdAt: JsonField? = null private var currency: JsonField? = null private var email: JsonField? = null @@ -562,8 +592,8 @@ private constructor( private var paymentProvider: JsonField? = null private var paymentProviderId: JsonField? = null private var portalUrl: JsonField? = null - private var shippingAddress: JsonField? = null - private var taxId: JsonField? = null + private var shippingAddress: JsonField? = null + private var taxId: JsonField? = null private var timezone: JsonField? = null private var accountingSyncConfiguration: JsonField = JsonMissing.of() @@ -610,14 +640,8 @@ private constructor( fun addAdditionalEmail(additionalEmail: String) = apply { additionalEmails = - (additionalEmails ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(additionalEmail) + (additionalEmails ?: JsonField.of(mutableListOf())).also { + checkKnown("additionalEmails", it).add(additionalEmail) } } @@ -633,13 +657,13 @@ private constructor( /** The customer's current balance in their currency. */ fun balance(balance: JsonField) = apply { this.balance = balance } - fun billingAddress(billingAddress: BillingAddress?) = + fun billingAddress(billingAddress: AddressModel?) = billingAddress(JsonField.ofNullable(billingAddress)) - fun billingAddress(billingAddress: Optional) = + fun billingAddress(billingAddress: Optional) = billingAddress(billingAddress.orElse(null)) - fun billingAddress(billingAddress: JsonField) = apply { + fun billingAddress(billingAddress: JsonField) = apply { this.billingAddress = billingAddress } @@ -786,13 +810,13 @@ private constructor( fun portalUrl(portalUrl: JsonField) = apply { this.portalUrl = portalUrl } - fun shippingAddress(shippingAddress: ShippingAddress?) = + fun shippingAddress(shippingAddress: AddressModel?) = shippingAddress(JsonField.ofNullable(shippingAddress)) - fun shippingAddress(shippingAddress: Optional) = + fun shippingAddress(shippingAddress: Optional) = shippingAddress(shippingAddress.orElse(null)) - fun shippingAddress(shippingAddress: JsonField) = apply { + fun shippingAddress(shippingAddress: JsonField) = apply { this.shippingAddress = shippingAddress } @@ -902,7 +926,7 @@ private constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - fun taxId(taxId: TaxId?) = taxId(JsonField.ofNullable(taxId)) + fun taxId(taxId: CustomerTaxIdModel?) = taxId(JsonField.ofNullable(taxId)) /** * Tax IDs are commonly required to be displayed on customer invoices, which are added to @@ -1010,7 +1034,7 @@ private constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - fun taxId(taxId: Optional) = taxId(taxId.orElse(null)) + fun taxId(taxId: Optional) = taxId(taxId.orElse(null)) /** * Tax IDs are commonly required to be displayed on customer invoices, which are added to @@ -1118,7 +1142,7 @@ private constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - fun taxId(taxId: JsonField) = apply { this.taxId = taxId } + fun taxId(taxId: JsonField) = apply { this.taxId = taxId } /** * A timezone identifier from the IANA timezone database, such as "America/Los_Angeles". @@ -1203,58 +1227,33 @@ private constructor( ) } + /** The hierarchical relationships for this customer. */ @NoAutoDetect - class BillingAddress + class Hierarchy @JsonCreator private constructor( - @JsonProperty("city") - @ExcludeMissing - private val city: JsonField = JsonMissing.of(), - @JsonProperty("country") - @ExcludeMissing - private val country: JsonField = JsonMissing.of(), - @JsonProperty("line1") - @ExcludeMissing - private val line1: JsonField = JsonMissing.of(), - @JsonProperty("line2") - @ExcludeMissing - private val line2: JsonField = JsonMissing.of(), - @JsonProperty("postal_code") + @JsonProperty("children") @ExcludeMissing - private val postalCode: JsonField = JsonMissing.of(), - @JsonProperty("state") + private val children: JsonField> = JsonMissing.of(), + @JsonProperty("parent") @ExcludeMissing - private val state: JsonField = JsonMissing.of(), + private val parent: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun city(): Optional = Optional.ofNullable(city.getNullable("city")) - - fun country(): Optional = Optional.ofNullable(country.getNullable("country")) - - fun line1(): Optional = Optional.ofNullable(line1.getNullable("line1")) - - fun line2(): Optional = Optional.ofNullable(line2.getNullable("line2")) - - fun postalCode(): Optional = - Optional.ofNullable(postalCode.getNullable("postal_code")) + fun children(): List = children.getRequired("children") - fun state(): Optional = Optional.ofNullable(state.getNullable("state")) + fun parent(): Optional = + Optional.ofNullable(parent.getNullable("parent")) - @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city - - @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country - - @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField = line1 - - @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 - - @JsonProperty("postal_code") + @JsonProperty("children") @ExcludeMissing - fun _postalCode(): JsonField = postalCode + fun _children(): JsonField> = children - @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state + @JsonProperty("parent") + @ExcludeMissing + fun _parent(): JsonField = parent @JsonAnyGetter @ExcludeMissing @@ -1262,17 +1261,13 @@ private constructor( private var validated: Boolean = false - fun validate(): BillingAddress = apply { + fun validate(): Hierarchy = apply { if (validated) { return@apply } - city() - country() - line1() - line2() - postalCode() - state() + children().forEach { it.validate() } + parent().ifPresent { it.validate() } validated = true } @@ -1280,66 +1275,50 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Hierarchy]. + * + * The following fields are required: + * ```java + * .children() + * .parent() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [BillingAddress]. */ + /** A builder for [Hierarchy]. */ class Builder internal constructor() { - private var city: JsonField? = null - private var country: JsonField? = null - private var line1: JsonField? = null - private var line2: JsonField? = null - private var postalCode: JsonField? = null - private var state: JsonField? = null + private var children: JsonField>? = null + private var parent: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(billingAddress: BillingAddress) = apply { - city = billingAddress.city - country = billingAddress.country - line1 = billingAddress.line1 - line2 = billingAddress.line2 - postalCode = billingAddress.postalCode - state = billingAddress.state - additionalProperties = billingAddress.additionalProperties.toMutableMap() + internal fun from(hierarchy: Hierarchy) = apply { + children = hierarchy.children.map { it.toMutableList() } + parent = hierarchy.parent + additionalProperties = hierarchy.additionalProperties.toMutableMap() } - fun city(city: String?) = city(JsonField.ofNullable(city)) - - fun city(city: Optional) = city(city.orElse(null)) - - fun city(city: JsonField) = apply { this.city = city } - - fun country(country: String?) = country(JsonField.ofNullable(country)) - - fun country(country: Optional) = country(country.orElse(null)) - - fun country(country: JsonField) = apply { this.country = country } - - fun line1(line1: String?) = line1(JsonField.ofNullable(line1)) + fun children(children: List) = children(JsonField.of(children)) - fun line1(line1: Optional) = line1(line1.orElse(null)) - - fun line1(line1: JsonField) = apply { this.line1 = line1 } - - fun line2(line2: String?) = line2(JsonField.ofNullable(line2)) - - fun line2(line2: Optional) = line2(line2.orElse(null)) - - fun line2(line2: JsonField) = apply { this.line2 = line2 } - - fun postalCode(postalCode: String?) = postalCode(JsonField.ofNullable(postalCode)) - - fun postalCode(postalCode: Optional) = postalCode(postalCode.orElse(null)) + fun children(children: JsonField>) = apply { + this.children = children.map { it.toMutableList() } + } - fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode } + fun addChild(child: CustomerMinifiedModel) = apply { + children = + (children ?: JsonField.of(mutableListOf())).also { + checkKnown("children", it).add(child) + } + } - fun state(state: String?) = state(JsonField.ofNullable(state)) + fun parent(parent: CustomerMinifiedModel?) = parent(JsonField.ofNullable(parent)) - fun state(state: Optional) = state(state.orElse(null)) + fun parent(parent: Optional) = parent(parent.orElse(null)) - fun state(state: JsonField) = apply { this.state = state } + fun parent(parent: JsonField) = apply { this.parent = parent } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1360,14 +1339,10 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): BillingAddress = - BillingAddress( - checkRequired("city", city), - checkRequired("country", country), - checkRequired("line1", line1), - checkRequired("line2", line2), - checkRequired("postalCode", postalCode), - checkRequired("state", state), + fun build(): Hierarchy = + Hierarchy( + checkRequired("children", children).map { it.toImmutable() }, + checkRequired("parent", parent), additionalProperties.toImmutable(), ) } @@ -1377,55 +1352,43 @@ private constructor( return true } - return /* spotless:off */ other is BillingAddress && city == other.city && country == other.country && line1 == other.line1 && line2 == other.line2 && postalCode == other.postalCode && state == other.state && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Hierarchy && children == other.children && parent == other.parent && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(city, country, line1, line2, postalCode, state, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(children, parent, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "BillingAddress{city=$city, country=$country, line1=$line1, line2=$line2, postalCode=$postalCode, state=$state, additionalProperties=$additionalProperties}" + "Hierarchy{children=$children, parent=$parent, additionalProperties=$additionalProperties}" } - /** The hierarchical relationships for this customer. */ + /** + * 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`. + */ @NoAutoDetect - class Hierarchy + class Metadata @JsonCreator private constructor( - @JsonProperty("children") - @ExcludeMissing - private val children: JsonField> = JsonMissing.of(), - @JsonProperty("parent") - @ExcludeMissing - private val parent: JsonField = JsonMissing.of(), @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { - fun children(): List = children.getRequired("children") - - fun parent(): Optional = Optional.ofNullable(parent.getNullable("parent")) - - @JsonProperty("children") @ExcludeMissing fun _children(): JsonField> = children - - @JsonProperty("parent") @ExcludeMissing fun _parent(): JsonField = parent - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties private var validated: Boolean = false - fun validate(): Hierarchy = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } - children().forEach { it.validate() } - parent().ifPresent { it.validate() } validated = true } @@ -1433,48 +1396,20 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [Hierarchy]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { - private var children: JsonField>? = null - private var parent: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(hierarchy: Hierarchy) = apply { - children = hierarchy.children.map { it.toMutableList() } - parent = hierarchy.parent - additionalProperties = hierarchy.additionalProperties.toMutableMap() - } - - fun children(children: List) = children(JsonField.of(children)) - - fun children(children: JsonField>) = apply { - this.children = children.map { it.toMutableList() } - } - - fun addChild(child: Child) = apply { - children = - (children ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(child) - } + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - fun parent(parent: Parent?) = parent(JsonField.ofNullable(parent)) - - fun parent(parent: Optional) = parent(parent.orElse(null)) - - fun parent(parent: JsonField) = apply { this.parent = parent } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1494,1971 +1429,147 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): Hierarchy = - Hierarchy( - checkRequired("children", children).map { it.toImmutable() }, - checkRequired("parent", parent), - additionalProperties.toImmutable(), - ) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } - @NoAutoDetect - class Child - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("external_customer_id") - @ExcludeMissing - private val externalCustomerId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun id(): String = id.getRequired("id") + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } - fun externalCustomerId(): Optional = - Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + override fun hashCode(): Int = hashCode - @JsonProperty("external_customer_id") - @ExcludeMissing - fun _externalCustomerId(): JsonField = externalCustomerId + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** + * This is used for creating charges or invoices in an external system via Orb. When not in test + * mode, the connection must first be configured in the Orb webapp. + */ + class PaymentProvider @JsonCreator private constructor(private val value: JsonField) : + Enum { - private var validated: Boolean = false + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - fun validate(): Child = apply { - if (validated) { - return@apply - } + companion object { - id() - externalCustomerId() - validated = true - } + @JvmField val QUICKBOOKS = of("quickbooks") - fun toBuilder() = Builder().from(this) + @JvmField val BILL_COM = of("bill.com") - companion object { + @JvmField val STRIPE_CHARGE = of("stripe_charge") - @JvmStatic fun builder() = Builder() - } + @JvmField val STRIPE_INVOICE = of("stripe_invoice") - /** A builder for [Child]. */ - class Builder internal constructor() { + @JvmField val NETSUITE = of("netsuite") - private var id: JsonField? = null - private var externalCustomerId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + @JvmStatic fun of(value: String) = PaymentProvider(JsonField.of(value)) + } - @JvmSynthetic - internal fun from(child: Child) = apply { - id = child.id - externalCustomerId = child.externalCustomerId - additionalProperties = child.additionalProperties.toMutableMap() - } + /** An enum containing [PaymentProvider]'s known values. */ + enum class Known { + QUICKBOOKS, + BILL_COM, + STRIPE_CHARGE, + STRIPE_INVOICE, + NETSUITE, + } - fun id(id: String) = id(JsonField.of(id)) + /** + * 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 { + QUICKBOOKS, + BILL_COM, + STRIPE_CHARGE, + STRIPE_INVOICE, + NETSUITE, + /** + * An enum member indicating that [PaymentProvider] was instantiated with an unknown + * 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) { + QUICKBOOKS -> Value.QUICKBOOKS + BILL_COM -> Value.BILL_COM + STRIPE_CHARGE -> Value.STRIPE_CHARGE + STRIPE_INVOICE -> Value.STRIPE_INVOICE + NETSUITE -> Value.NETSUITE + else -> Value._UNKNOWN + } - fun externalCustomerId(externalCustomerId: String?) = - externalCustomerId(JsonField.ofNullable(externalCustomerId)) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to 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 + BILL_COM -> Known.BILL_COM + STRIPE_CHARGE -> Known.STRIPE_CHARGE + STRIPE_INVOICE -> Known.STRIPE_INVOICE + NETSUITE -> Known.NETSUITE + else -> throw OrbInvalidDataException("Unknown PaymentProvider: $value") + } - fun externalCustomerId(externalCustomerId: Optional) = - externalCustomerId(externalCustomerId.orElse(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 externalCustomerId(externalCustomerId: JsonField) = apply { - this.externalCustomerId = externalCustomerId - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + return /* spotless:off */ other is PaymentProvider && value == other.value /* spotless:on */ + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + override fun hashCode() = value.hashCode() - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): Child = - Child( - checkRequired("id", id), - checkRequired("externalCustomerId", externalCustomerId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Child && id == other.id && externalCustomerId == other.externalCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, externalCustomerId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Child{id=$id, externalCustomerId=$externalCustomerId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Parent - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("external_customer_id") - @ExcludeMissing - private val externalCustomerId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun externalCustomerId(): Optional = - Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("external_customer_id") - @ExcludeMissing - fun _externalCustomerId(): JsonField = externalCustomerId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Parent = apply { - if (validated) { - return@apply - } - - id() - externalCustomerId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Parent]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var externalCustomerId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(parent: Parent) = apply { - id = parent.id - externalCustomerId = parent.externalCustomerId - additionalProperties = parent.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun externalCustomerId(externalCustomerId: String?) = - externalCustomerId(JsonField.ofNullable(externalCustomerId)) - - fun externalCustomerId(externalCustomerId: Optional) = - externalCustomerId(externalCustomerId.orElse(null)) - - fun externalCustomerId(externalCustomerId: JsonField) = apply { - this.externalCustomerId = externalCustomerId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Parent = - Parent( - checkRequired("id", id), - checkRequired("externalCustomerId", externalCustomerId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Parent && id == other.id && externalCustomerId == other.externalCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, externalCustomerId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Parent{id=$id, externalCustomerId=$externalCustomerId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Hierarchy && children == other.children && parent == other.parent && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(children, parent, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Hierarchy{children=$children, parent=$parent, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - /** - * This is used for creating charges or invoices in an external system via Orb. When not in test - * mode, the connection must first be configured in the Orb webapp. - */ - 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 QUICKBOOKS = of("quickbooks") - - @JvmField val BILL_COM = of("bill.com") - - @JvmField val STRIPE_CHARGE = of("stripe_charge") - - @JvmField val STRIPE_INVOICE = of("stripe_invoice") - - @JvmField val NETSUITE = of("netsuite") - - @JvmStatic fun of(value: String) = PaymentProvider(JsonField.of(value)) - } - - /** An enum containing [PaymentProvider]'s known values. */ - enum class Known { - QUICKBOOKS, - BILL_COM, - STRIPE_CHARGE, - STRIPE_INVOICE, - NETSUITE, - } - - /** - * 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 { - QUICKBOOKS, - BILL_COM, - STRIPE_CHARGE, - STRIPE_INVOICE, - NETSUITE, - /** - * 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) { - QUICKBOOKS -> Value.QUICKBOOKS - BILL_COM -> Value.BILL_COM - STRIPE_CHARGE -> Value.STRIPE_CHARGE - STRIPE_INVOICE -> Value.STRIPE_INVOICE - 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 - BILL_COM -> Known.BILL_COM - STRIPE_CHARGE -> Known.STRIPE_CHARGE - STRIPE_INVOICE -> Known.STRIPE_INVOICE - NETSUITE -> Known.NETSUITE - 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PaymentProvider && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class ShippingAddress - @JsonCreator - private constructor( - @JsonProperty("city") - @ExcludeMissing - private val city: JsonField = JsonMissing.of(), - @JsonProperty("country") - @ExcludeMissing - private val country: JsonField = JsonMissing.of(), - @JsonProperty("line1") - @ExcludeMissing - private val line1: JsonField = JsonMissing.of(), - @JsonProperty("line2") - @ExcludeMissing - private val line2: JsonField = JsonMissing.of(), - @JsonProperty("postal_code") - @ExcludeMissing - private val postalCode: JsonField = JsonMissing.of(), - @JsonProperty("state") - @ExcludeMissing - private val state: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun city(): Optional = Optional.ofNullable(city.getNullable("city")) - - fun country(): Optional = Optional.ofNullable(country.getNullable("country")) - - fun line1(): Optional = Optional.ofNullable(line1.getNullable("line1")) - - fun line2(): Optional = Optional.ofNullable(line2.getNullable("line2")) - - fun postalCode(): Optional = - Optional.ofNullable(postalCode.getNullable("postal_code")) - - fun state(): Optional = Optional.ofNullable(state.getNullable("state")) - - @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city - - @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country - - @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField = line1 - - @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 - - @JsonProperty("postal_code") - @ExcludeMissing - fun _postalCode(): JsonField = postalCode - - @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): ShippingAddress = apply { - if (validated) { - return@apply - } - - city() - country() - line1() - line2() - postalCode() - state() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ShippingAddress]. */ - class Builder internal constructor() { - - private var city: JsonField? = null - private var country: JsonField? = null - private var line1: JsonField? = null - private var line2: JsonField? = null - private var postalCode: JsonField? = null - private var state: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(shippingAddress: ShippingAddress) = apply { - city = shippingAddress.city - country = shippingAddress.country - line1 = shippingAddress.line1 - line2 = shippingAddress.line2 - postalCode = shippingAddress.postalCode - state = shippingAddress.state - additionalProperties = shippingAddress.additionalProperties.toMutableMap() - } - - fun city(city: String?) = city(JsonField.ofNullable(city)) - - fun city(city: Optional) = city(city.orElse(null)) - - fun city(city: JsonField) = apply { this.city = city } - - fun country(country: String?) = country(JsonField.ofNullable(country)) - - fun country(country: Optional) = country(country.orElse(null)) - - fun country(country: JsonField) = apply { this.country = country } - - fun line1(line1: String?) = line1(JsonField.ofNullable(line1)) - - fun line1(line1: Optional) = line1(line1.orElse(null)) - - fun line1(line1: JsonField) = apply { this.line1 = line1 } - - fun line2(line2: String?) = line2(JsonField.ofNullable(line2)) - - fun line2(line2: Optional) = line2(line2.orElse(null)) - - fun line2(line2: JsonField) = apply { this.line2 = line2 } - - fun postalCode(postalCode: String?) = postalCode(JsonField.ofNullable(postalCode)) - - fun postalCode(postalCode: Optional) = postalCode(postalCode.orElse(null)) - - fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode } - - fun state(state: String?) = state(JsonField.ofNullable(state)) - - fun state(state: Optional) = state(state.orElse(null)) - - fun state(state: JsonField) = apply { this.state = state } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): ShippingAddress = - ShippingAddress( - checkRequired("city", city), - checkRequired("country", country), - checkRequired("line1", line1), - checkRequired("line2", line2), - checkRequired("postalCode", postalCode), - checkRequired("state", state), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ShippingAddress && city == other.city && country == other.country && line1 == other.line1 && line2 == other.line2 && postalCode == other.postalCode && state == other.state && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(city, country, line1, line2, postalCode, state, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ShippingAddress{city=$city, country=$country, line1=$line1, line2=$line2, postalCode=$postalCode, state=$state, additionalProperties=$additionalProperties}" - } - - /** - * 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 | - * |--------------------|------------|-------------------------------------------------------------------------------------------------------| - * |Andorra |`ad_nrt` |Andorran NRT Number | - * |Argentina |`ar_cuit` |Argentinian Tax ID Number | - * |Australia |`au_abn` |Australian Business Number (AU ABN) | - * |Australia |`au_arn` |Australian Taxation Office Reference Number | - * |Austria |`eu_vat` |European VAT Number | - * |Bahrain |`bh_vat` |Bahraini VAT Number | - * |Belgium |`eu_vat` |European VAT Number | - * |Bolivia |`bo_tin` |Bolivian Tax ID | - * |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 | - * |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) | - * |Chile |`cl_tin` |Chilean TIN | - * |China |`cn_tin` |Chinese Tax ID | - * |Colombia |`co_nit` |Colombian NIT Number | - * |Costa Rica |`cr_tin` |Costa Rican Tax ID | - * |Croatia |`eu_vat` |European VAT Number | - * |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 | - * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | - * |Finland |`eu_vat` |European VAT Number | - * |France |`eu_vat` |European VAT Number | - * |Georgia |`ge_vat` |Georgian VAT | - * |Germany |`eu_vat` |European VAT Number | - * |Greece |`eu_vat` |European VAT Number | - * |Hong Kong |`hk_br` |Hong Kong BR Number | - * |Hungary |`eu_vat` |European VAT Number | - * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | - * |Iceland |`is_vat` |Icelandic VAT | - * |India |`in_gst` |Indian GST Number | - * |Indonesia |`id_npwp` |Indonesian NPWP Number | - * |Ireland |`eu_vat` |European VAT Number | - * |Israel |`il_vat` |Israel VAT | - * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | - * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | - * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | - * |Latvia |`eu_vat` |European VAT Number | - * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | - * |Mexico |`mx_rfc` |Mexican RFC Number | - * |Netherlands |`eu_vat` |European VAT Number | - * |New Zealand |`nz_gst` |New Zealand GST Number | - * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | - * |Norway |`no_vat` |Norwegian VAT Number | - * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | - * |Oman |`om_vat` |Omani VAT Number | - * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | - * |Poland |`eu_vat` |European VAT Number | - * |Portugal |`eu_vat` |European VAT Number | - * |Romania |`eu_vat` |European VAT Number | - * |Romania |`ro_tin` |Romanian Tax ID Number | - * |Russia |`ru_inn` |Russian INN | - * |Russia |`ru_kpp` |Russian KPP | - * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | - * |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 | - * |Sweden |`eu_vat` |European VAT Number | - * |Switzerland |`ch_vat` |Switzerland VAT Number | - * |Taiwan |`tw_vat` |Taiwanese VAT | - * |Thailand |`th_vat` |Thai VAT | - * |Turkey |`tr_tin` |Turkish Tax Identification Number | - * |Ukraine |`ua_vat` |Ukrainian VAT | - * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | - * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | - * |United Kingdom |`gb_vat` |United Kingdom VAT Number | - * |United States |`us_ein` |United States EIN | - * |Uruguay |`uy_ruc` |Uruguayan RUC Number | - * |Venezuela |`ve_rif` |Venezuelan RIF Number | - * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | - */ - @NoAutoDetect - class TaxId - @JsonCreator - private constructor( - @JsonProperty("country") - @ExcludeMissing - private val country: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonProperty("value") - @ExcludeMissing - private val value: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun country(): Country = country.getRequired("country") - - fun type(): Type = type.getRequired("type") - - fun value(): String = value.getRequired("value") - - @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country - - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TaxId = apply { - if (validated) { - return@apply - } - - country() - type() - value() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TaxId]. */ - class Builder internal constructor() { - - private var country: JsonField? = null - private var type: JsonField? = null - private var value: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(taxId: TaxId) = apply { - country = taxId.country - type = taxId.type - value = taxId.value - additionalProperties = taxId.additionalProperties.toMutableMap() - } - - fun country(country: Country) = country(JsonField.of(country)) - - fun country(country: JsonField) = apply { this.country = country } - - fun type(type: Type) = type(JsonField.of(type)) - - fun type(type: JsonField) = apply { this.type = type } - - fun value(value: String) = value(JsonField.of(value)) - - fun value(value: JsonField) = apply { this.value = 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) - } - - fun build(): TaxId = - TaxId( - checkRequired("country", country), - checkRequired("type", type), - checkRequired("value", value), - additionalProperties.toImmutable(), - ) - } - - class Country @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val AD = of("AD") - - @JvmField val AE = of("AE") - - @JvmField val AR = of("AR") - - @JvmField val AT = of("AT") - - @JvmField val AU = of("AU") - - @JvmField val BE = of("BE") - - @JvmField val BG = of("BG") - - @JvmField val BH = of("BH") - - @JvmField val BO = of("BO") - - @JvmField val BR = of("BR") - - @JvmField val CA = of("CA") - - @JvmField val CH = of("CH") - - @JvmField val CL = of("CL") - - @JvmField val CN = of("CN") - - @JvmField val CO = of("CO") - - @JvmField val CR = of("CR") - - @JvmField val CY = of("CY") - - @JvmField val CZ = of("CZ") - - @JvmField val DE = of("DE") - - @JvmField val DK = of("DK") - - @JvmField val EE = of("EE") - - @JvmField val DO = of("DO") - - @JvmField val EC = of("EC") - - @JvmField val EG = of("EG") - - @JvmField val ES = of("ES") - - @JvmField val EU = of("EU") - - @JvmField val FI = of("FI") - - @JvmField val FR = of("FR") - - @JvmField val GB = of("GB") - - @JvmField val GE = of("GE") - - @JvmField val GR = of("GR") - - @JvmField val HK = of("HK") - - @JvmField val HR = of("HR") - - @JvmField val HU = of("HU") - - @JvmField val ID = of("ID") - - @JvmField val IE = of("IE") - - @JvmField val IL = of("IL") - - @JvmField val IN = of("IN") - - @JvmField val IS = of("IS") - - @JvmField val IT = of("IT") - - @JvmField val JP = of("JP") - - @JvmField val KE = of("KE") - - @JvmField val KR = of("KR") - - @JvmField val KZ = of("KZ") - - @JvmField val LI = of("LI") - - @JvmField val LT = of("LT") - - @JvmField val LU = of("LU") - - @JvmField val LV = of("LV") - - @JvmField val MT = of("MT") - - @JvmField val MX = of("MX") - - @JvmField val MY = of("MY") - - @JvmField val NG = of("NG") - - @JvmField val NL = of("NL") - - @JvmField val NO = of("NO") - - @JvmField val NZ = of("NZ") - - @JvmField val OM = of("OM") - - @JvmField val PE = of("PE") - - @JvmField val PH = of("PH") - - @JvmField val PL = of("PL") - - @JvmField val PT = of("PT") - - @JvmField val RO = of("RO") - - @JvmField val RS = of("RS") - - @JvmField val RU = of("RU") - - @JvmField val SA = of("SA") - - @JvmField val SE = of("SE") - - @JvmField val SG = of("SG") - - @JvmField val SI = of("SI") - - @JvmField val SK = of("SK") - - @JvmField val SV = of("SV") - - @JvmField val TH = of("TH") - - @JvmField val TR = of("TR") - - @JvmField val TW = of("TW") - - @JvmField val UA = of("UA") - - @JvmField val US = of("US") - - @JvmField val UY = of("UY") - - @JvmField val VE = of("VE") - - @JvmField val VN = of("VN") - - @JvmField val ZA = of("ZA") - - @JvmStatic fun of(value: String) = Country(JsonField.of(value)) - } - - /** An enum containing [Country]'s known values. */ - enum class Known { - AD, - AE, - AR, - AT, - AU, - BE, - BG, - BH, - BO, - BR, - CA, - CH, - CL, - CN, - CO, - CR, - CY, - CZ, - DE, - DK, - EE, - DO, - EC, - EG, - ES, - EU, - FI, - FR, - GB, - GE, - GR, - HK, - HR, - HU, - ID, - IE, - IL, - IN, - IS, - IT, - JP, - KE, - KR, - KZ, - LI, - LT, - LU, - LV, - MT, - MX, - MY, - NG, - NL, - NO, - NZ, - OM, - PE, - PH, - PL, - PT, - RO, - RS, - RU, - SA, - SE, - SG, - SI, - SK, - SV, - TH, - TR, - TW, - UA, - US, - UY, - VE, - VN, - ZA, - } - - /** - * An enum containing [Country]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Country] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AD, - AE, - AR, - AT, - AU, - BE, - BG, - BH, - BO, - BR, - CA, - CH, - CL, - CN, - CO, - CR, - CY, - CZ, - DE, - DK, - EE, - DO, - EC, - EG, - ES, - EU, - FI, - FR, - GB, - GE, - GR, - HK, - HR, - HU, - ID, - IE, - IL, - IN, - IS, - IT, - JP, - KE, - KR, - KZ, - LI, - LT, - LU, - LV, - MT, - MX, - MY, - NG, - NL, - NO, - NZ, - OM, - PE, - PH, - PL, - PT, - RO, - RS, - RU, - SA, - SE, - SG, - SI, - SK, - SV, - TH, - TR, - TW, - UA, - US, - UY, - VE, - VN, - ZA, - /** - * An enum member indicating that [Country] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AD -> Value.AD - AE -> Value.AE - AR -> Value.AR - AT -> Value.AT - AU -> Value.AU - BE -> Value.BE - BG -> Value.BG - BH -> Value.BH - BO -> Value.BO - BR -> Value.BR - CA -> Value.CA - CH -> Value.CH - CL -> Value.CL - CN -> Value.CN - CO -> Value.CO - CR -> Value.CR - CY -> Value.CY - CZ -> Value.CZ - DE -> Value.DE - DK -> Value.DK - EE -> Value.EE - DO -> Value.DO - EC -> Value.EC - EG -> Value.EG - ES -> Value.ES - EU -> Value.EU - FI -> Value.FI - FR -> Value.FR - GB -> Value.GB - GE -> Value.GE - GR -> Value.GR - HK -> Value.HK - HR -> Value.HR - HU -> Value.HU - ID -> Value.ID - IE -> Value.IE - IL -> Value.IL - IN -> Value.IN - IS -> Value.IS - IT -> Value.IT - JP -> Value.JP - KE -> Value.KE - KR -> Value.KR - KZ -> Value.KZ - LI -> Value.LI - LT -> Value.LT - LU -> Value.LU - LV -> Value.LV - MT -> Value.MT - MX -> Value.MX - MY -> Value.MY - NG -> Value.NG - NL -> Value.NL - NO -> Value.NO - NZ -> Value.NZ - OM -> Value.OM - PE -> Value.PE - PH -> Value.PH - PL -> Value.PL - PT -> Value.PT - RO -> Value.RO - RS -> Value.RS - RU -> Value.RU - SA -> Value.SA - SE -> Value.SE - SG -> Value.SG - SI -> Value.SI - SK -> Value.SK - SV -> Value.SV - TH -> Value.TH - TR -> Value.TR - TW -> Value.TW - UA -> Value.UA - US -> Value.US - UY -> Value.UY - VE -> Value.VE - VN -> Value.VN - ZA -> Value.ZA - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AD -> Known.AD - AE -> Known.AE - AR -> Known.AR - AT -> Known.AT - AU -> Known.AU - BE -> Known.BE - BG -> Known.BG - BH -> Known.BH - BO -> Known.BO - BR -> Known.BR - CA -> Known.CA - CH -> Known.CH - CL -> Known.CL - CN -> Known.CN - CO -> Known.CO - CR -> Known.CR - CY -> Known.CY - CZ -> Known.CZ - DE -> Known.DE - DK -> Known.DK - EE -> Known.EE - DO -> Known.DO - EC -> Known.EC - EG -> Known.EG - ES -> Known.ES - EU -> Known.EU - FI -> Known.FI - FR -> Known.FR - GB -> Known.GB - GE -> Known.GE - GR -> Known.GR - HK -> Known.HK - HR -> Known.HR - HU -> Known.HU - ID -> Known.ID - IE -> Known.IE - IL -> Known.IL - IN -> Known.IN - IS -> Known.IS - IT -> Known.IT - JP -> Known.JP - KE -> Known.KE - KR -> Known.KR - KZ -> Known.KZ - LI -> Known.LI - LT -> Known.LT - LU -> Known.LU - LV -> Known.LV - MT -> Known.MT - MX -> Known.MX - MY -> Known.MY - NG -> Known.NG - NL -> Known.NL - NO -> Known.NO - NZ -> Known.NZ - OM -> Known.OM - PE -> Known.PE - PH -> Known.PH - PL -> Known.PL - PT -> Known.PT - RO -> Known.RO - RS -> Known.RS - RU -> Known.RU - SA -> Known.SA - SE -> Known.SE - SG -> Known.SG - SI -> Known.SI - SK -> Known.SK - SV -> Known.SV - TH -> Known.TH - TR -> Known.TR - TW -> Known.TW - UA -> Known.UA - US -> Known.US - UY -> Known.UY - VE -> Known.VE - VN -> Known.VN - ZA -> Known.ZA - else -> throw OrbInvalidDataException("Unknown Country: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is Country && value == other.value /* spotless:on */ - } - - 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 AD_NRT = of("ad_nrt") - - @JvmField val AE_TRN = of("ae_trn") - - @JvmField val AR_CUIT = of("ar_cuit") - - @JvmField val EU_VAT = of("eu_vat") - - @JvmField val AU_ABN = of("au_abn") - - @JvmField val AU_ARN = of("au_arn") - - @JvmField val BG_UIC = of("bg_uic") - - @JvmField val BH_VAT = of("bh_vat") - - @JvmField val BO_TIN = of("bo_tin") - - @JvmField val BR_CNPJ = of("br_cnpj") - - @JvmField val BR_CPF = of("br_cpf") - - @JvmField val CA_BN = of("ca_bn") - - @JvmField val CA_GST_HST = of("ca_gst_hst") - - @JvmField val CA_PST_BC = of("ca_pst_bc") - - @JvmField val CA_PST_MB = of("ca_pst_mb") - - @JvmField val CA_PST_SK = of("ca_pst_sk") - - @JvmField val CA_QST = of("ca_qst") - - @JvmField val CH_VAT = of("ch_vat") - - @JvmField val CL_TIN = of("cl_tin") - - @JvmField val CN_TIN = of("cn_tin") - - @JvmField val CO_NIT = of("co_nit") - - @JvmField val CR_TIN = of("cr_tin") - - @JvmField val DO_RCN = of("do_rcn") - - @JvmField val EC_RUC = of("ec_ruc") - - @JvmField val EG_TIN = of("eg_tin") - - @JvmField val ES_CIF = of("es_cif") - - @JvmField val EU_OSS_VAT = of("eu_oss_vat") - - @JvmField val GB_VAT = of("gb_vat") - - @JvmField val GE_VAT = of("ge_vat") - - @JvmField val HK_BR = of("hk_br") - - @JvmField val HU_TIN = of("hu_tin") - - @JvmField val ID_NPWP = of("id_npwp") - - @JvmField val IL_VAT = of("il_vat") - - @JvmField val IN_GST = of("in_gst") - - @JvmField val IS_VAT = of("is_vat") - - @JvmField val JP_CN = of("jp_cn") - - @JvmField val JP_RN = of("jp_rn") - - @JvmField val JP_TRN = of("jp_trn") - - @JvmField val KE_PIN = of("ke_pin") - - @JvmField val KR_BRN = of("kr_brn") - - @JvmField val KZ_BIN = of("kz_bin") - - @JvmField val LI_UID = of("li_uid") - - @JvmField val MX_RFC = of("mx_rfc") - - @JvmField val MY_FRP = of("my_frp") - - @JvmField val MY_ITN = of("my_itn") - - @JvmField val MY_SST = of("my_sst") - - @JvmField val NG_TIN = of("ng_tin") - - @JvmField val NO_VAT = of("no_vat") - - @JvmField val NO_VOEC = of("no_voec") - - @JvmField val NZ_GST = of("nz_gst") - - @JvmField val OM_VAT = of("om_vat") - - @JvmField val PE_RUC = of("pe_ruc") - - @JvmField val PH_TIN = of("ph_tin") - - @JvmField val RO_TIN = of("ro_tin") - - @JvmField val RS_PIB = of("rs_pib") - - @JvmField val RU_INN = of("ru_inn") - - @JvmField val RU_KPP = of("ru_kpp") - - @JvmField val SA_VAT = of("sa_vat") - - @JvmField val SG_GST = of("sg_gst") - - @JvmField val SG_UEN = of("sg_uen") - - @JvmField val SI_TIN = of("si_tin") - - @JvmField val SV_NIT = of("sv_nit") - - @JvmField val TH_VAT = of("th_vat") - - @JvmField val TR_TIN = of("tr_tin") - - @JvmField val TW_VAT = of("tw_vat") - - @JvmField val UA_VAT = of("ua_vat") - - @JvmField val US_EIN = of("us_ein") - - @JvmField val UY_RUC = of("uy_ruc") - - @JvmField val VE_RIF = of("ve_rif") - - @JvmField val VN_TIN = of("vn_tin") - - @JvmField val ZA_VAT = of("za_vat") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - AD_NRT, - AE_TRN, - AR_CUIT, - EU_VAT, - AU_ABN, - AU_ARN, - BG_UIC, - BH_VAT, - BO_TIN, - BR_CNPJ, - BR_CPF, - CA_BN, - CA_GST_HST, - CA_PST_BC, - CA_PST_MB, - CA_PST_SK, - CA_QST, - CH_VAT, - CL_TIN, - CN_TIN, - CO_NIT, - CR_TIN, - DO_RCN, - EC_RUC, - EG_TIN, - ES_CIF, - EU_OSS_VAT, - GB_VAT, - GE_VAT, - HK_BR, - HU_TIN, - ID_NPWP, - IL_VAT, - IN_GST, - IS_VAT, - JP_CN, - JP_RN, - JP_TRN, - KE_PIN, - KR_BRN, - KZ_BIN, - LI_UID, - MX_RFC, - MY_FRP, - MY_ITN, - MY_SST, - NG_TIN, - NO_VAT, - NO_VOEC, - NZ_GST, - OM_VAT, - PE_RUC, - PH_TIN, - RO_TIN, - RS_PIB, - RU_INN, - RU_KPP, - SA_VAT, - SG_GST, - SG_UEN, - SI_TIN, - SV_NIT, - TH_VAT, - TR_TIN, - TW_VAT, - UA_VAT, - US_EIN, - UY_RUC, - VE_RIF, - VN_TIN, - ZA_VAT, - } - - /** - * 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 { - AD_NRT, - AE_TRN, - AR_CUIT, - EU_VAT, - AU_ABN, - AU_ARN, - BG_UIC, - BH_VAT, - BO_TIN, - BR_CNPJ, - BR_CPF, - CA_BN, - CA_GST_HST, - CA_PST_BC, - CA_PST_MB, - CA_PST_SK, - CA_QST, - CH_VAT, - CL_TIN, - CN_TIN, - CO_NIT, - CR_TIN, - DO_RCN, - EC_RUC, - EG_TIN, - ES_CIF, - EU_OSS_VAT, - GB_VAT, - GE_VAT, - HK_BR, - HU_TIN, - ID_NPWP, - IL_VAT, - IN_GST, - IS_VAT, - JP_CN, - JP_RN, - JP_TRN, - KE_PIN, - KR_BRN, - KZ_BIN, - LI_UID, - MX_RFC, - MY_FRP, - MY_ITN, - MY_SST, - NG_TIN, - NO_VAT, - NO_VOEC, - NZ_GST, - OM_VAT, - PE_RUC, - PH_TIN, - RO_TIN, - RS_PIB, - RU_INN, - RU_KPP, - SA_VAT, - SG_GST, - SG_UEN, - SI_TIN, - SV_NIT, - TH_VAT, - TR_TIN, - TW_VAT, - UA_VAT, - US_EIN, - UY_RUC, - VE_RIF, - VN_TIN, - ZA_VAT, - /** 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) { - AD_NRT -> Value.AD_NRT - AE_TRN -> Value.AE_TRN - AR_CUIT -> Value.AR_CUIT - EU_VAT -> Value.EU_VAT - AU_ABN -> Value.AU_ABN - AU_ARN -> Value.AU_ARN - BG_UIC -> Value.BG_UIC - BH_VAT -> Value.BH_VAT - BO_TIN -> Value.BO_TIN - BR_CNPJ -> Value.BR_CNPJ - BR_CPF -> Value.BR_CPF - CA_BN -> Value.CA_BN - CA_GST_HST -> Value.CA_GST_HST - CA_PST_BC -> Value.CA_PST_BC - CA_PST_MB -> Value.CA_PST_MB - CA_PST_SK -> Value.CA_PST_SK - CA_QST -> Value.CA_QST - CH_VAT -> Value.CH_VAT - CL_TIN -> Value.CL_TIN - CN_TIN -> Value.CN_TIN - CO_NIT -> Value.CO_NIT - CR_TIN -> Value.CR_TIN - DO_RCN -> Value.DO_RCN - EC_RUC -> Value.EC_RUC - EG_TIN -> Value.EG_TIN - ES_CIF -> Value.ES_CIF - EU_OSS_VAT -> Value.EU_OSS_VAT - GB_VAT -> Value.GB_VAT - GE_VAT -> Value.GE_VAT - HK_BR -> Value.HK_BR - HU_TIN -> Value.HU_TIN - ID_NPWP -> Value.ID_NPWP - IL_VAT -> Value.IL_VAT - IN_GST -> Value.IN_GST - IS_VAT -> Value.IS_VAT - JP_CN -> Value.JP_CN - JP_RN -> Value.JP_RN - JP_TRN -> Value.JP_TRN - KE_PIN -> Value.KE_PIN - KR_BRN -> Value.KR_BRN - KZ_BIN -> Value.KZ_BIN - LI_UID -> Value.LI_UID - MX_RFC -> Value.MX_RFC - MY_FRP -> Value.MY_FRP - MY_ITN -> Value.MY_ITN - MY_SST -> Value.MY_SST - NG_TIN -> Value.NG_TIN - NO_VAT -> Value.NO_VAT - NO_VOEC -> Value.NO_VOEC - NZ_GST -> Value.NZ_GST - OM_VAT -> Value.OM_VAT - PE_RUC -> Value.PE_RUC - PH_TIN -> Value.PH_TIN - RO_TIN -> Value.RO_TIN - RS_PIB -> Value.RS_PIB - RU_INN -> Value.RU_INN - RU_KPP -> Value.RU_KPP - SA_VAT -> Value.SA_VAT - SG_GST -> Value.SG_GST - SG_UEN -> Value.SG_UEN - SI_TIN -> Value.SI_TIN - SV_NIT -> Value.SV_NIT - TH_VAT -> Value.TH_VAT - TR_TIN -> Value.TR_TIN - TW_VAT -> Value.TW_VAT - UA_VAT -> Value.UA_VAT - US_EIN -> Value.US_EIN - UY_RUC -> Value.UY_RUC - VE_RIF -> Value.VE_RIF - VN_TIN -> Value.VN_TIN - ZA_VAT -> Value.ZA_VAT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AD_NRT -> Known.AD_NRT - AE_TRN -> Known.AE_TRN - AR_CUIT -> Known.AR_CUIT - EU_VAT -> Known.EU_VAT - AU_ABN -> Known.AU_ABN - AU_ARN -> Known.AU_ARN - BG_UIC -> Known.BG_UIC - BH_VAT -> Known.BH_VAT - BO_TIN -> Known.BO_TIN - BR_CNPJ -> Known.BR_CNPJ - BR_CPF -> Known.BR_CPF - CA_BN -> Known.CA_BN - CA_GST_HST -> Known.CA_GST_HST - CA_PST_BC -> Known.CA_PST_BC - CA_PST_MB -> Known.CA_PST_MB - CA_PST_SK -> Known.CA_PST_SK - CA_QST -> Known.CA_QST - CH_VAT -> Known.CH_VAT - CL_TIN -> Known.CL_TIN - CN_TIN -> Known.CN_TIN - CO_NIT -> Known.CO_NIT - CR_TIN -> Known.CR_TIN - DO_RCN -> Known.DO_RCN - EC_RUC -> Known.EC_RUC - EG_TIN -> Known.EG_TIN - ES_CIF -> Known.ES_CIF - EU_OSS_VAT -> Known.EU_OSS_VAT - GB_VAT -> Known.GB_VAT - GE_VAT -> Known.GE_VAT - HK_BR -> Known.HK_BR - HU_TIN -> Known.HU_TIN - ID_NPWP -> Known.ID_NPWP - IL_VAT -> Known.IL_VAT - IN_GST -> Known.IN_GST - IS_VAT -> Known.IS_VAT - JP_CN -> Known.JP_CN - JP_RN -> Known.JP_RN - JP_TRN -> Known.JP_TRN - KE_PIN -> Known.KE_PIN - KR_BRN -> Known.KR_BRN - KZ_BIN -> Known.KZ_BIN - LI_UID -> Known.LI_UID - MX_RFC -> Known.MX_RFC - MY_FRP -> Known.MY_FRP - MY_ITN -> Known.MY_ITN - MY_SST -> Known.MY_SST - NG_TIN -> Known.NG_TIN - NO_VAT -> Known.NO_VAT - NO_VOEC -> Known.NO_VOEC - NZ_GST -> Known.NZ_GST - OM_VAT -> Known.OM_VAT - PE_RUC -> Known.PE_RUC - PH_TIN -> Known.PH_TIN - RO_TIN -> Known.RO_TIN - RS_PIB -> Known.RS_PIB - RU_INN -> Known.RU_INN - RU_KPP -> Known.RU_KPP - SA_VAT -> Known.SA_VAT - SG_GST -> Known.SG_GST - SG_UEN -> Known.SG_UEN - SI_TIN -> Known.SI_TIN - SV_NIT -> Known.SV_NIT - TH_VAT -> Known.TH_VAT - TR_TIN -> Known.TR_TIN - TW_VAT -> Known.TW_VAT - UA_VAT -> Known.UA_VAT - US_EIN -> Known.US_EIN - UY_RUC -> Known.UY_RUC - VE_RIF -> Known.VE_RIF - VN_TIN -> Known.VN_TIN - ZA_VAT -> Known.ZA_VAT - 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TaxId && country == other.country && type == other.type && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(country, type, value, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TaxId{country=$country, type=$type, value=$value, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } @NoAutoDetect @@ -3506,6 +1617,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [AccountingSyncConfiguration]. + * + * The following fields are required: + * ```java + * .accountingProviders() + * .excluded() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -3535,14 +1656,8 @@ private constructor( fun addAccountingProvider(accountingProvider: AccountingProvider) = apply { accountingProviders = - (accountingProviders ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(accountingProvider) + (accountingProviders ?: JsonField.of(mutableListOf())).also { + checkKnown("accountingProviders", it).add(accountingProvider) } } @@ -3626,6 +1741,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [AccountingProvider]. + * + * The following fields are required: + * ```java + * .externalProviderId() + * .providerType() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -3866,6 +1990,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ReportingConfiguration]. + * + * The following fields are required: + * ```java + * .exempt() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 eba3fa47d..706a90651 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 @@ -122,6 +122,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .amount() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -210,6 +219,17 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [CustomerBalanceTransactionCreateParams]. + * + * The following fields are required: + * ```java + * .customerId() + * .amount() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPage.kt index 651251502..8e864a2d3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPage.kt @@ -54,7 +54,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -113,22 +113,20 @@ private constructor( @JsonCreator constructor( @JsonProperty("data") - private val data: JsonField> = - JsonMissing.of(), + private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = - data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = + fun _data(): Optional>> = Optional.ofNullable(data) @JsonProperty("pagination_metadata") @@ -168,13 +166,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [CustomerBalanceTransactionListPage]. + */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = - JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -185,9 +186,9 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { + fun data(data: JsonField>) = apply { this.data = data } @@ -207,9 +208,9 @@ private constructor( } class AutoPager(private val firstPage: CustomerBalanceTransactionListPage) : - Iterable { + Iterable { - override fun iterator(): Iterator = iterator { + override fun iterator(): Iterator = iterator { var page = firstPage var index = 0 while (true) { @@ -221,7 +222,7 @@ private constructor( } } - fun stream(): Stream { + fun stream(): Stream { return StreamSupport.stream(spliterator(), false) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPageAsync.kt index d9de8ceb9..38853dacb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListPageAsync.kt @@ -55,7 +55,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -116,22 +116,20 @@ private constructor( @JsonCreator constructor( @JsonProperty("data") - private val data: JsonField> = - JsonMissing.of(), + private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = - data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = + fun _data(): Optional>> = Optional.ofNullable(data) @JsonProperty("pagination_metadata") @@ -171,13 +169,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [CustomerBalanceTransactionListPageAsync]. + */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = - JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -188,9 +189,9 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { + fun data(data: JsonField>) = apply { this.data = data } @@ -212,11 +213,11 @@ private constructor( class AutoPager(private val firstPage: CustomerBalanceTransactionListPageAsync) { fun forEach( - action: Predicate, + action: Predicate, executor: Executor, ): CompletableFuture { fun CompletableFuture>.forEach( - action: (CustomerBalanceTransactionListResponse) -> Boolean, + action: (CustomerBalanceTransactionModel) -> Boolean, executor: Executor, ): CompletableFuture = thenComposeAsync( @@ -232,10 +233,8 @@ private constructor( .forEach(action::test, executor) } - fun toList( - executor: Executor - ): CompletableFuture> { - val values = mutableListOf() + fun toList(executor: Executor): CompletableFuture> { + val values = mutableListOf() return forEach(values::add, executor).thenApply { values } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListParams.kt index 56e7978e1..90c577f74 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListParams.kt @@ -119,6 +119,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [CustomerBalanceTransactionListParams]. + * + * The following fields are required: + * ```java + * .customerId() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 deleted file mode 100644 index c5443cdae..000000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponse.kt +++ /dev/null @@ -1,745 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.withorb.api.core.Enum -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.checkRequired -import com.withorb.api.core.immutableEmptyMap -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional - -@NoAutoDetect -class CustomerBalanceTransactionListResponse -@JsonCreator -private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("action") - @ExcludeMissing - private val action: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("credit_note") - @ExcludeMissing - private val creditNote: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("ending_balance") - @ExcludeMissing - private val endingBalance: JsonField = JsonMissing.of(), - @JsonProperty("invoice") - @ExcludeMissing - private val invoice: JsonField = JsonMissing.of(), - @JsonProperty("starting_balance") - @ExcludeMissing - private val startingBalance: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - /** A unique id for this transaction. */ - fun id(): String = id.getRequired("id") - - fun action(): Action = action.getRequired("action") - - /** The value of the amount changed in the transaction. */ - fun amount(): String = amount.getRequired("amount") - - /** The creation time of this transaction. */ - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - fun creditNote(): Optional = - Optional.ofNullable(creditNote.getNullable("credit_note")) - - /** An optional description provided for manual customer balance adjustments. */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - /** - * The new value of the customer's balance prior to the transaction, in the customer's currency. - */ - fun endingBalance(): String = endingBalance.getRequired("ending_balance") - - fun invoice(): Optional = Optional.ofNullable(invoice.getNullable("invoice")) - - /** - * The original value of the customer's balance prior to the transaction, in the customer's - * currency. - */ - fun startingBalance(): String = startingBalance.getRequired("starting_balance") - - fun type(): Type = type.getRequired("type") - - /** A unique id for this transaction. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("action") @ExcludeMissing fun _action(): JsonField = action - - /** The value of the amount changed in the transaction. */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** The creation time of this transaction. */ - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - @JsonProperty("credit_note") - @ExcludeMissing - fun _creditNote(): JsonField = creditNote - - /** An optional description provided for manual customer balance adjustments. */ - @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description - - /** - * The new value of the customer's balance prior to the transaction, in the customer's currency. - */ - @JsonProperty("ending_balance") - @ExcludeMissing - fun _endingBalance(): JsonField = endingBalance - - @JsonProperty("invoice") @ExcludeMissing fun _invoice(): JsonField = invoice - - /** - * The original value of the customer's balance prior to the transaction, in the customer's - * currency. - */ - @JsonProperty("starting_balance") - @ExcludeMissing - fun _startingBalance(): JsonField = startingBalance - - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CustomerBalanceTransactionListResponse = apply { - if (validated) { - return@apply - } - - id() - action() - amount() - createdAt() - creditNote().ifPresent { it.validate() } - description() - endingBalance() - invoice().ifPresent { it.validate() } - startingBalance() - type() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CustomerBalanceTransactionListResponse]. */ - 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( - customerBalanceTransactionListResponse: CustomerBalanceTransactionListResponse - ) = apply { - id = customerBalanceTransactionListResponse.id - action = customerBalanceTransactionListResponse.action - amount = customerBalanceTransactionListResponse.amount - createdAt = customerBalanceTransactionListResponse.createdAt - creditNote = customerBalanceTransactionListResponse.creditNote - description = customerBalanceTransactionListResponse.description - endingBalance = customerBalanceTransactionListResponse.endingBalance - invoice = customerBalanceTransactionListResponse.invoice - startingBalance = customerBalanceTransactionListResponse.startingBalance - type = customerBalanceTransactionListResponse.type - additionalProperties = - customerBalanceTransactionListResponse.additionalProperties.toMutableMap() - } - - /** A unique id for this transaction. */ - fun id(id: String) = id(JsonField.of(id)) - - /** A unique id for this transaction. */ - fun id(id: JsonField) = apply { this.id = id } - - fun action(action: Action) = action(JsonField.of(action)) - - 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)) - - /** The value of the amount changed in the transaction. */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** The creation time of this transaction. */ - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - /** The creation time of this transaction. */ - fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - - fun creditNote(creditNote: CreditNote?) = creditNote(JsonField.ofNullable(creditNote)) - - fun creditNote(creditNote: Optional) = creditNote(creditNote.orElse(null)) - - 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)) - - /** An optional description provided for manual customer balance adjustments. */ - fun description(description: Optional) = description(description.orElse(null)) - - /** An optional description provided for manual customer balance adjustments. */ - 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)) - - /** - * The new value of the customer's balance prior to the transaction, in the customer's - * currency. - */ - fun endingBalance(endingBalance: JsonField) = apply { - this.endingBalance = endingBalance - } - - fun invoice(invoice: Invoice?) = invoice(JsonField.ofNullable(invoice)) - - fun invoice(invoice: Optional) = invoice(invoice.orElse(null)) - - 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)) - - /** - * The original value of the customer's balance prior to the transaction, in the customer's - * currency. - */ - fun startingBalance(startingBalance: JsonField) = apply { - this.startingBalance = startingBalance - } - - fun type(type: Type) = type(JsonField.of(type)) - - 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) - } - - fun build(): CustomerBalanceTransactionListResponse = - CustomerBalanceTransactionListResponse( - 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.toImmutable(), - ) - } - - 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") - - @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, - } - - /** - * 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, - /** 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 - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to 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 - 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Action && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class CreditNote - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The id of the Credit note */ - fun id(): String = id.getRequired("id") - - /** The id of the Credit note */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditNote = apply { - if (validated) { - return@apply - } - - id() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditNote]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditNote: CreditNote) = apply { - id = creditNote.id - additionalProperties = creditNote.additionalProperties.toMutableMap() - } - - /** The id of the Credit note */ - fun id(id: String) = id(JsonField.of(id)) - - /** The id of the Credit note */ - 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) - } - - fun build(): CreditNote = - CreditNote(checkRequired("id", id), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditNote && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "CreditNote{id=$id, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Invoice - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The Invoice id */ - fun id(): String = id.getRequired("id") - - /** The Invoice id */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Invoice = apply { - if (validated) { - return@apply - } - - id() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Invoice]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoice: Invoice) = apply { - id = invoice.id - additionalProperties = invoice.additionalProperties.toMutableMap() - } - - /** The Invoice id */ - fun id(id: String) = id(JsonField.of(id)) - - /** The Invoice id */ - 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) - } - - fun build(): Invoice = - Invoice(checkRequired("id", id), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Invoice && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Invoice{id=$id, additionalProperties=$additionalProperties}" - } - - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CustomerBalanceTransactionListResponse && id == other.id && action == other.action && amount == other.amount && createdAt == other.createdAt && creditNote == other.creditNote && description == other.description && endingBalance == other.endingBalance && invoice == other.invoice && startingBalance == other.startingBalance && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, action, amount, createdAt, creditNote, description, endingBalance, invoice, startingBalance, type, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CustomerBalanceTransactionListResponse{id=$id, action=$action, amount=$amount, createdAt=$createdAt, creditNote=$creditNote, description=$description, endingBalance=$endingBalance, invoice=$invoice, startingBalance=$startingBalance, type=$type, additionalProperties=$additionalProperties}" -} 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/CustomerBalanceTransactionModel.kt similarity index 90% rename from orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponse.kt rename to orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionModel.kt index a6a515f96..c519a4d26 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/CustomerBalanceTransactionModel.kt @@ -21,7 +21,7 @@ import java.util.Objects import java.util.Optional @NoAutoDetect -class CustomerBalanceTransactionCreateResponse +class CustomerBalanceTransactionModel @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @@ -131,7 +131,7 @@ private constructor( private var validated: Boolean = false - fun validate(): CustomerBalanceTransactionCreateResponse = apply { + fun validate(): CustomerBalanceTransactionModel = apply { if (validated) { return@apply } @@ -153,10 +153,28 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [CustomerBalanceTransactionModel]. + * + * The following fields are required: + * ```java + * .id() + * .action() + * .amount() + * .createdAt() + * .creditNote() + * .description() + * .endingBalance() + * .invoice() + * .startingBalance() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [CustomerBalanceTransactionCreateResponse]. */ + /** A builder for [CustomerBalanceTransactionModel]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -172,22 +190,21 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - customerBalanceTransactionCreateResponse: CustomerBalanceTransactionCreateResponse - ) = apply { - id = customerBalanceTransactionCreateResponse.id - action = customerBalanceTransactionCreateResponse.action - amount = customerBalanceTransactionCreateResponse.amount - createdAt = customerBalanceTransactionCreateResponse.createdAt - creditNote = customerBalanceTransactionCreateResponse.creditNote - description = customerBalanceTransactionCreateResponse.description - endingBalance = customerBalanceTransactionCreateResponse.endingBalance - invoice = customerBalanceTransactionCreateResponse.invoice - startingBalance = customerBalanceTransactionCreateResponse.startingBalance - type = customerBalanceTransactionCreateResponse.type - additionalProperties = - customerBalanceTransactionCreateResponse.additionalProperties.toMutableMap() - } + internal fun from(customerBalanceTransactionModel: CustomerBalanceTransactionModel) = + apply { + id = customerBalanceTransactionModel.id + action = customerBalanceTransactionModel.action + amount = customerBalanceTransactionModel.amount + createdAt = customerBalanceTransactionModel.createdAt + creditNote = customerBalanceTransactionModel.creditNote + description = customerBalanceTransactionModel.description + endingBalance = customerBalanceTransactionModel.endingBalance + invoice = customerBalanceTransactionModel.invoice + startingBalance = customerBalanceTransactionModel.startingBalance + type = customerBalanceTransactionModel.type + additionalProperties = + customerBalanceTransactionModel.additionalProperties.toMutableMap() + } /** A unique id for this transaction. */ fun id(id: String) = id(JsonField.of(id)) @@ -284,8 +301,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): CustomerBalanceTransactionCreateResponse = - CustomerBalanceTransactionCreateResponse( + fun build(): CustomerBalanceTransactionModel = + CustomerBalanceTransactionModel( checkRequired("id", id), checkRequired("action", action), checkRequired("amount", amount), @@ -473,6 +490,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [CreditNote]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -568,6 +593,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Invoice]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -731,7 +764,7 @@ private constructor( return true } - return /* spotless:off */ other is CustomerBalanceTransactionCreateResponse && id == other.id && action == other.action && amount == other.amount && createdAt == other.createdAt && creditNote == other.creditNote && description == other.description && endingBalance == other.endingBalance && invoice == other.invoice && startingBalance == other.startingBalance && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is CustomerBalanceTransactionModel && id == other.id && action == other.action && amount == other.amount && createdAt == other.createdAt && creditNote == other.creditNote && description == other.description && endingBalance == other.endingBalance && invoice == other.invoice && startingBalance == other.startingBalance && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -741,5 +774,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CustomerBalanceTransactionCreateResponse{id=$id, action=$action, amount=$amount, createdAt=$createdAt, creditNote=$creditNote, description=$description, endingBalance=$endingBalance, invoice=$invoice, startingBalance=$startingBalance, type=$type, additionalProperties=$additionalProperties}" + "CustomerBalanceTransactionModel{id=$id, action=$action, amount=$amount, createdAt=$createdAt, creditNote=$creditNote, description=$description, endingBalance=$endingBalance, invoice=$invoice, startingBalance=$startingBalance, type=$type, additionalProperties=$additionalProperties}" } 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 a9dd66ca4..273d0c489 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 @@ -190,6 +190,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [CustomerCostListByExternalIdParams]. + * + * The following fields are required: + * ```java + * .externalCustomerId() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 deleted file mode 100644 index 1f6b42bc2..000000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponse.kt +++ /dev/null @@ -1,624 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.checkRequired -import com.withorb.api.core.immutableEmptyMap -import com.withorb.api.core.toImmutable -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional - -@NoAutoDetect -class CustomerCostListByExternalIdResponse -@JsonCreator -private constructor( - @JsonProperty("data") - @ExcludeMissing - private val data: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun data(): List = data.getRequired("data") - - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CustomerCostListByExternalIdResponse = apply { - if (validated) { - return@apply - } - - data().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CustomerCostListByExternalIdResponse]. */ - class Builder internal constructor() { - - private var data: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - customerCostListByExternalIdResponse: CustomerCostListByExternalIdResponse - ) = apply { - data = customerCostListByExternalIdResponse.data.map { it.toMutableList() } - additionalProperties = - customerCostListByExternalIdResponse.additionalProperties.toMutableMap() - } - - fun data(data: List) = data(JsonField.of(data)) - - fun data(data: JsonField>) = apply { - this.data = data.map { it.toMutableList() } - } - - fun addData(data: Data) = apply { - this.data = - (this.data ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(data) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CustomerCostListByExternalIdResponse = - CustomerCostListByExternalIdResponse( - checkRequired("data", data).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Data - @JsonCreator - private constructor( - @JsonProperty("per_price_costs") - @ExcludeMissing - private val perPriceCosts: JsonField> = JsonMissing.of(), - @JsonProperty("subtotal") - @ExcludeMissing - private val subtotal: JsonField = JsonMissing.of(), - @JsonProperty("timeframe_end") - @ExcludeMissing - private val timeframeEnd: JsonField = JsonMissing.of(), - @JsonProperty("timeframe_start") - @ExcludeMissing - private val timeframeStart: JsonField = JsonMissing.of(), - @JsonProperty("total") - @ExcludeMissing - private val total: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun perPriceCosts(): List = perPriceCosts.getRequired("per_price_costs") - - /** Total costs for the timeframe, excluding any minimums and discounts. */ - fun subtotal(): String = subtotal.getRequired("subtotal") - - fun timeframeEnd(): OffsetDateTime = timeframeEnd.getRequired("timeframe_end") - - fun timeframeStart(): OffsetDateTime = timeframeStart.getRequired("timeframe_start") - - /** Total costs for the timeframe, including any minimums and discounts. */ - fun total(): String = total.getRequired("total") - - @JsonProperty("per_price_costs") - @ExcludeMissing - fun _perPriceCosts(): JsonField> = perPriceCosts - - /** Total costs for the timeframe, excluding any minimums and discounts. */ - @JsonProperty("subtotal") @ExcludeMissing fun _subtotal(): JsonField = subtotal - - @JsonProperty("timeframe_end") - @ExcludeMissing - fun _timeframeEnd(): JsonField = timeframeEnd - - @JsonProperty("timeframe_start") - @ExcludeMissing - fun _timeframeStart(): JsonField = timeframeStart - - /** Total costs for the timeframe, including any minimums and discounts. */ - @JsonProperty("total") @ExcludeMissing fun _total(): JsonField = total - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - perPriceCosts().forEach { it.validate() } - subtotal() - timeframeEnd() - timeframeStart() - total() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Data]. */ - class Builder internal constructor() { - - private var perPriceCosts: JsonField>? = null - private var subtotal: JsonField? = null - private var timeframeEnd: JsonField? = null - private var timeframeStart: JsonField? = null - private var total: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - perPriceCosts = data.perPriceCosts.map { it.toMutableList() } - subtotal = data.subtotal - timeframeEnd = data.timeframeEnd - timeframeStart = data.timeframeStart - total = data.total - additionalProperties = data.additionalProperties.toMutableMap() - } - - fun perPriceCosts(perPriceCosts: List) = - perPriceCosts(JsonField.of(perPriceCosts)) - - fun perPriceCosts(perPriceCosts: JsonField>) = apply { - this.perPriceCosts = perPriceCosts.map { it.toMutableList() } - } - - fun addPerPriceCost(perPriceCost: PerPriceCost) = apply { - perPriceCosts = - (perPriceCosts ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(perPriceCost) - } - } - - /** Total costs for the timeframe, excluding any minimums and discounts. */ - fun subtotal(subtotal: String) = subtotal(JsonField.of(subtotal)) - - /** Total costs for the timeframe, excluding any minimums and discounts. */ - fun subtotal(subtotal: JsonField) = apply { this.subtotal = subtotal } - - fun timeframeEnd(timeframeEnd: OffsetDateTime) = - timeframeEnd(JsonField.of(timeframeEnd)) - - fun timeframeEnd(timeframeEnd: JsonField) = apply { - this.timeframeEnd = timeframeEnd - } - - fun timeframeStart(timeframeStart: OffsetDateTime) = - timeframeStart(JsonField.of(timeframeStart)) - - fun timeframeStart(timeframeStart: JsonField) = apply { - this.timeframeStart = timeframeStart - } - - /** Total costs for the timeframe, including any minimums and discounts. */ - fun total(total: String) = total(JsonField.of(total)) - - /** Total costs for the timeframe, including any minimums and discounts. */ - fun total(total: JsonField) = apply { this.total = total } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Data = - Data( - checkRequired("perPriceCosts", perPriceCosts).map { it.toImmutable() }, - checkRequired("subtotal", subtotal), - checkRequired("timeframeEnd", timeframeEnd), - checkRequired("timeframeStart", timeframeStart), - checkRequired("total", total), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class PerPriceCost - @JsonCreator - private constructor( - @JsonProperty("price") - @ExcludeMissing - private val price: JsonField = JsonMissing.of(), - @JsonProperty("price_id") - @ExcludeMissing - private val priceId: JsonField = JsonMissing.of(), - @JsonProperty("subtotal") - @ExcludeMissing - private val subtotal: JsonField = JsonMissing.of(), - @JsonProperty("total") - @ExcludeMissing - private val total: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - private val quantity: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price object */ - fun price(): Price = price.getRequired("price") - - /** The price the cost is associated with */ - fun priceId(): String = priceId.getRequired("price_id") - - /** Price's contributions for the timeframe, excluding any minimums and discounts. */ - fun subtotal(): String = subtotal.getRequired("subtotal") - - /** Price's contributions for the timeframe, including minimums and discounts. */ - fun total(): String = total.getRequired("total") - - /** The price's quantity for the timeframe */ - fun quantity(): Optional = Optional.ofNullable(quantity.getNullable("quantity")) - - /** The price object */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - - /** The price the cost is associated with */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - - /** Price's contributions for the timeframe, excluding any minimums and discounts. */ - @JsonProperty("subtotal") @ExcludeMissing fun _subtotal(): JsonField = subtotal - - /** Price's contributions for the timeframe, including minimums and discounts. */ - @JsonProperty("total") @ExcludeMissing fun _total(): JsonField = total - - /** The price's quantity for the timeframe */ - @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PerPriceCost = apply { - if (validated) { - return@apply - } - - price().validate() - priceId() - subtotal() - total() - quantity() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PerPriceCost]. */ - class Builder internal constructor() { - - private var price: JsonField? = null - private var priceId: JsonField? = null - private var subtotal: JsonField? = null - private var total: JsonField? = null - private var quantity: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(perPriceCost: PerPriceCost) = apply { - price = perPriceCost.price - priceId = perPriceCost.priceId - subtotal = perPriceCost.subtotal - total = perPriceCost.total - quantity = perPriceCost.quantity - additionalProperties = perPriceCost.additionalProperties.toMutableMap() - } - - /** The price object */ - fun price(price: Price) = price(JsonField.of(price)) - - /** The price object */ - fun price(price: JsonField) = apply { this.price = price } - - /** The price object */ - fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) - - /** The price object */ - fun price(packagePrice: Price.PackagePrice) = - price(Price.ofPackagePrice(packagePrice)) - - /** The price object */ - fun price(matrix: Price.MatrixPrice) = price(Price.ofMatrix(matrix)) - - /** The price object */ - fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) - - /** The price object */ - fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) - - /** The price object */ - fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) - - /** The price object */ - fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) - - /** The price object */ - fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) - - /** The price object */ - fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - - /** The price object */ - fun price(tieredPackage: Price.TieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) - - /** The price object */ - fun price(groupedTiered: Price.GroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) - - /** The price object */ - fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) - - /** The price object */ - fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - - /** The price object */ - fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) - - /** The price object */ - fun price(unitWithPercent: Price.UnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) - - /** The price object */ - fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - - /** The price object */ - fun price(tieredWithProration: Price.TieredWithProrationPrice) = - price(Price.ofTieredWithProration(tieredWithProration)) - - /** The price object */ - fun price(unitWithProration: Price.UnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) - - /** The price object */ - fun price(groupedAllocation: Price.GroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) - - /** The price object */ - fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - - /** The price object */ - fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - - /** The price object */ - fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - - /** The price object */ - fun price(bulkWithProration: Price.BulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) - - /** The price object */ - fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) - - /** The price object */ - fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - - /** The price object */ - fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = - price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - - /** The price object */ - fun price( - scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - - /** The price object */ - fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - - /** The price the cost is associated with */ - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) - - /** The price the cost is associated with */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - - /** - * Price's contributions for the timeframe, excluding any minimums and discounts. - */ - fun subtotal(subtotal: String) = subtotal(JsonField.of(subtotal)) - - /** - * Price's contributions for the timeframe, excluding any minimums and discounts. - */ - fun subtotal(subtotal: JsonField) = apply { this.subtotal = subtotal } - - /** Price's contributions for the timeframe, including minimums and discounts. */ - fun total(total: String) = total(JsonField.of(total)) - - /** Price's contributions for the timeframe, including minimums and discounts. */ - fun total(total: JsonField) = apply { this.total = total } - - /** The price's quantity for the timeframe */ - fun quantity(quantity: Double?) = quantity(JsonField.ofNullable(quantity)) - - /** The price's quantity for the timeframe */ - fun quantity(quantity: Double) = quantity(quantity as Double?) - - /** The price's quantity for the timeframe */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun quantity(quantity: Optional) = - quantity(quantity.orElse(null) as Double?) - - /** The price's quantity for the timeframe */ - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PerPriceCost = - PerPriceCost( - checkRequired("price", price), - checkRequired("priceId", priceId), - checkRequired("subtotal", subtotal), - checkRequired("total", total), - quantity, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PerPriceCost && price == other.price && priceId == other.priceId && subtotal == other.subtotal && total == other.total && quantity == other.quantity && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(price, priceId, subtotal, total, quantity, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PerPriceCost{price=$price, priceId=$priceId, subtotal=$subtotal, total=$total, quantity=$quantity, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && perPriceCosts == other.perPriceCosts && subtotal == other.subtotal && timeframeEnd == other.timeframeEnd && timeframeStart == other.timeframeStart && total == other.total && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(perPriceCosts, subtotal, timeframeEnd, timeframeStart, total, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Data{perPriceCosts=$perPriceCosts, subtotal=$subtotal, timeframeEnd=$timeframeEnd, timeframeStart=$timeframeStart, total=$total, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CustomerCostListByExternalIdResponse && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(data, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CustomerCostListByExternalIdResponse{data=$data, additionalProperties=$additionalProperties}" -} 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 ef8969896..33da10e6c 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 @@ -190,6 +190,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [CustomerCostListParams]. + * + * The following fields are required: + * ```java + * .customerId() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 deleted file mode 100644 index 561c33f92..000000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListResponse.kt +++ /dev/null @@ -1,621 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.checkRequired -import com.withorb.api.core.immutableEmptyMap -import com.withorb.api.core.toImmutable -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional - -@NoAutoDetect -class CustomerCostListResponse -@JsonCreator -private constructor( - @JsonProperty("data") - @ExcludeMissing - private val data: JsonField> = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun data(): List = data.getRequired("data") - - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CustomerCostListResponse = apply { - if (validated) { - return@apply - } - - data().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CustomerCostListResponse]. */ - class Builder internal constructor() { - - private var data: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customerCostListResponse: CustomerCostListResponse) = apply { - data = customerCostListResponse.data.map { it.toMutableList() } - additionalProperties = customerCostListResponse.additionalProperties.toMutableMap() - } - - fun data(data: List) = data(JsonField.of(data)) - - fun data(data: JsonField>) = apply { - this.data = data.map { it.toMutableList() } - } - - fun addData(data: Data) = apply { - this.data = - (this.data ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(data) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CustomerCostListResponse = - CustomerCostListResponse( - checkRequired("data", data).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Data - @JsonCreator - private constructor( - @JsonProperty("per_price_costs") - @ExcludeMissing - private val perPriceCosts: JsonField> = JsonMissing.of(), - @JsonProperty("subtotal") - @ExcludeMissing - private val subtotal: JsonField = JsonMissing.of(), - @JsonProperty("timeframe_end") - @ExcludeMissing - private val timeframeEnd: JsonField = JsonMissing.of(), - @JsonProperty("timeframe_start") - @ExcludeMissing - private val timeframeStart: JsonField = JsonMissing.of(), - @JsonProperty("total") - @ExcludeMissing - private val total: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun perPriceCosts(): List = perPriceCosts.getRequired("per_price_costs") - - /** Total costs for the timeframe, excluding any minimums and discounts. */ - fun subtotal(): String = subtotal.getRequired("subtotal") - - fun timeframeEnd(): OffsetDateTime = timeframeEnd.getRequired("timeframe_end") - - fun timeframeStart(): OffsetDateTime = timeframeStart.getRequired("timeframe_start") - - /** Total costs for the timeframe, including any minimums and discounts. */ - fun total(): String = total.getRequired("total") - - @JsonProperty("per_price_costs") - @ExcludeMissing - fun _perPriceCosts(): JsonField> = perPriceCosts - - /** Total costs for the timeframe, excluding any minimums and discounts. */ - @JsonProperty("subtotal") @ExcludeMissing fun _subtotal(): JsonField = subtotal - - @JsonProperty("timeframe_end") - @ExcludeMissing - fun _timeframeEnd(): JsonField = timeframeEnd - - @JsonProperty("timeframe_start") - @ExcludeMissing - fun _timeframeStart(): JsonField = timeframeStart - - /** Total costs for the timeframe, including any minimums and discounts. */ - @JsonProperty("total") @ExcludeMissing fun _total(): JsonField = total - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - perPriceCosts().forEach { it.validate() } - subtotal() - timeframeEnd() - timeframeStart() - total() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Data]. */ - class Builder internal constructor() { - - private var perPriceCosts: JsonField>? = null - private var subtotal: JsonField? = null - private var timeframeEnd: JsonField? = null - private var timeframeStart: JsonField? = null - private var total: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - perPriceCosts = data.perPriceCosts.map { it.toMutableList() } - subtotal = data.subtotal - timeframeEnd = data.timeframeEnd - timeframeStart = data.timeframeStart - total = data.total - additionalProperties = data.additionalProperties.toMutableMap() - } - - fun perPriceCosts(perPriceCosts: List) = - perPriceCosts(JsonField.of(perPriceCosts)) - - fun perPriceCosts(perPriceCosts: JsonField>) = apply { - this.perPriceCosts = perPriceCosts.map { it.toMutableList() } - } - - fun addPerPriceCost(perPriceCost: PerPriceCost) = apply { - perPriceCosts = - (perPriceCosts ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(perPriceCost) - } - } - - /** Total costs for the timeframe, excluding any minimums and discounts. */ - fun subtotal(subtotal: String) = subtotal(JsonField.of(subtotal)) - - /** Total costs for the timeframe, excluding any minimums and discounts. */ - fun subtotal(subtotal: JsonField) = apply { this.subtotal = subtotal } - - fun timeframeEnd(timeframeEnd: OffsetDateTime) = - timeframeEnd(JsonField.of(timeframeEnd)) - - fun timeframeEnd(timeframeEnd: JsonField) = apply { - this.timeframeEnd = timeframeEnd - } - - fun timeframeStart(timeframeStart: OffsetDateTime) = - timeframeStart(JsonField.of(timeframeStart)) - - fun timeframeStart(timeframeStart: JsonField) = apply { - this.timeframeStart = timeframeStart - } - - /** Total costs for the timeframe, including any minimums and discounts. */ - fun total(total: String) = total(JsonField.of(total)) - - /** Total costs for the timeframe, including any minimums and discounts. */ - fun total(total: JsonField) = apply { this.total = total } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Data = - Data( - checkRequired("perPriceCosts", perPriceCosts).map { it.toImmutable() }, - checkRequired("subtotal", subtotal), - checkRequired("timeframeEnd", timeframeEnd), - checkRequired("timeframeStart", timeframeStart), - checkRequired("total", total), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class PerPriceCost - @JsonCreator - private constructor( - @JsonProperty("price") - @ExcludeMissing - private val price: JsonField = JsonMissing.of(), - @JsonProperty("price_id") - @ExcludeMissing - private val priceId: JsonField = JsonMissing.of(), - @JsonProperty("subtotal") - @ExcludeMissing - private val subtotal: JsonField = JsonMissing.of(), - @JsonProperty("total") - @ExcludeMissing - private val total: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - private val quantity: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price object */ - fun price(): Price = price.getRequired("price") - - /** The price the cost is associated with */ - fun priceId(): String = priceId.getRequired("price_id") - - /** Price's contributions for the timeframe, excluding any minimums and discounts. */ - fun subtotal(): String = subtotal.getRequired("subtotal") - - /** Price's contributions for the timeframe, including minimums and discounts. */ - fun total(): String = total.getRequired("total") - - /** The price's quantity for the timeframe */ - fun quantity(): Optional = Optional.ofNullable(quantity.getNullable("quantity")) - - /** The price object */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - - /** The price the cost is associated with */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - - /** Price's contributions for the timeframe, excluding any minimums and discounts. */ - @JsonProperty("subtotal") @ExcludeMissing fun _subtotal(): JsonField = subtotal - - /** Price's contributions for the timeframe, including minimums and discounts. */ - @JsonProperty("total") @ExcludeMissing fun _total(): JsonField = total - - /** The price's quantity for the timeframe */ - @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PerPriceCost = apply { - if (validated) { - return@apply - } - - price().validate() - priceId() - subtotal() - total() - quantity() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PerPriceCost]. */ - class Builder internal constructor() { - - private var price: JsonField? = null - private var priceId: JsonField? = null - private var subtotal: JsonField? = null - private var total: JsonField? = null - private var quantity: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(perPriceCost: PerPriceCost) = apply { - price = perPriceCost.price - priceId = perPriceCost.priceId - subtotal = perPriceCost.subtotal - total = perPriceCost.total - quantity = perPriceCost.quantity - additionalProperties = perPriceCost.additionalProperties.toMutableMap() - } - - /** The price object */ - fun price(price: Price) = price(JsonField.of(price)) - - /** The price object */ - fun price(price: JsonField) = apply { this.price = price } - - /** The price object */ - fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) - - /** The price object */ - fun price(packagePrice: Price.PackagePrice) = - price(Price.ofPackagePrice(packagePrice)) - - /** The price object */ - fun price(matrix: Price.MatrixPrice) = price(Price.ofMatrix(matrix)) - - /** The price object */ - fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) - - /** The price object */ - fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) - - /** The price object */ - fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) - - /** The price object */ - fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) - - /** The price object */ - fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) - - /** The price object */ - fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - - /** The price object */ - fun price(tieredPackage: Price.TieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) - - /** The price object */ - fun price(groupedTiered: Price.GroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) - - /** The price object */ - fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) - - /** The price object */ - fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - - /** The price object */ - fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) - - /** The price object */ - fun price(unitWithPercent: Price.UnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) - - /** The price object */ - fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - - /** The price object */ - fun price(tieredWithProration: Price.TieredWithProrationPrice) = - price(Price.ofTieredWithProration(tieredWithProration)) - - /** The price object */ - fun price(unitWithProration: Price.UnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) - - /** The price object */ - fun price(groupedAllocation: Price.GroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) - - /** The price object */ - fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - - /** The price object */ - fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - - /** The price object */ - fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - - /** The price object */ - fun price(bulkWithProration: Price.BulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) - - /** The price object */ - fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) - - /** The price object */ - fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - - /** The price object */ - fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = - price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - - /** The price object */ - fun price( - scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - - /** The price object */ - fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - - /** The price the cost is associated with */ - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) - - /** The price the cost is associated with */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - - /** - * Price's contributions for the timeframe, excluding any minimums and discounts. - */ - fun subtotal(subtotal: String) = subtotal(JsonField.of(subtotal)) - - /** - * Price's contributions for the timeframe, excluding any minimums and discounts. - */ - fun subtotal(subtotal: JsonField) = apply { this.subtotal = subtotal } - - /** Price's contributions for the timeframe, including minimums and discounts. */ - fun total(total: String) = total(JsonField.of(total)) - - /** Price's contributions for the timeframe, including minimums and discounts. */ - fun total(total: JsonField) = apply { this.total = total } - - /** The price's quantity for the timeframe */ - fun quantity(quantity: Double?) = quantity(JsonField.ofNullable(quantity)) - - /** The price's quantity for the timeframe */ - fun quantity(quantity: Double) = quantity(quantity as Double?) - - /** The price's quantity for the timeframe */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun quantity(quantity: Optional) = - quantity(quantity.orElse(null) as Double?) - - /** The price's quantity for the timeframe */ - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PerPriceCost = - PerPriceCost( - checkRequired("price", price), - checkRequired("priceId", priceId), - checkRequired("subtotal", subtotal), - checkRequired("total", total), - quantity, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PerPriceCost && price == other.price && priceId == other.priceId && subtotal == other.subtotal && total == other.total && quantity == other.quantity && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(price, priceId, subtotal, total, quantity, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PerPriceCost{price=$price, priceId=$priceId, subtotal=$subtotal, total=$total, quantity=$quantity, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && perPriceCosts == other.perPriceCosts && subtotal == other.subtotal && timeframeEnd == other.timeframeEnd && timeframeStart == other.timeframeStart && total == other.total && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(perPriceCosts, subtotal, timeframeEnd, timeframeStart, total, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Data{perPriceCosts=$perPriceCosts, subtotal=$subtotal, timeframeEnd=$timeframeEnd, timeframeStart=$timeframeStart, total=$total, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CustomerCostListResponse && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(data, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CustomerCostListResponse{data=$data, additionalProperties=$additionalProperties}" -} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostsModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostsModel.kt new file mode 100644 index 000000000..7f5852164 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostsModel.kt @@ -0,0 +1,131 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects + +@NoAutoDetect +class CustomerCostsModel +@JsonCreator +private constructor( + @JsonProperty("data") + @ExcludeMissing + private val data: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun data(): List = data.getRequired("data") + + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): CustomerCostsModel = apply { + if (validated) { + return@apply + } + + data().forEach { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CustomerCostsModel]. + * + * The following fields are required: + * ```java + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomerCostsModel]. */ + class Builder internal constructor() { + + private var data: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(customerCostsModel: CustomerCostsModel) = apply { + data = customerCostsModel.data.map { it.toMutableList() } + additionalProperties = customerCostsModel.additionalProperties.toMutableMap() + } + + fun data(data: List) = data(JsonField.of(data)) + + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + fun addData(data: AggregatedCostModel) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): CustomerCostsModel = + CustomerCostsModel( + checkRequired("data", data).map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CustomerCostsModel && data == other.data && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(data, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomerCostsModel{data=$data, additionalProperties=$additionalProperties}" +} 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 b1c35b84d..26c2c7485 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 @@ -6,15 +6,6 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField @@ -22,8 +13,8 @@ import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.Params +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import com.withorb.api.core.immutableEmptyMap @@ -31,7 +22,6 @@ import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.util.Objects import java.util.Optional -import kotlin.jvm.optionals.getOrNull /** * This operation is used to create an Orb customer, who is party to the core billing relationship. @@ -61,7 +51,7 @@ private constructor( /** The full name of the customer */ fun name(): String = body.name() - fun accountingSyncConfiguration(): Optional = + fun accountingSyncConfiguration(): Optional = body.accountingSyncConfiguration() /** @@ -77,7 +67,7 @@ private constructor( */ fun autoCollection(): Optional = body.autoCollection() - fun billingAddress(): Optional = body.billingAddress() + fun billingAddress(): Optional = body.billingAddress() /** * An ISO 4217 currency string used for the customer's invoices and balance. If not set at @@ -95,7 +85,7 @@ private constructor( fun externalCustomerId(): Optional = body.externalCustomerId() /** The hierarchical relationships for this customer. */ - fun hierarchy(): Optional = body.hierarchy() + fun hierarchy(): Optional = body.hierarchy() /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting @@ -116,11 +106,12 @@ private constructor( */ fun paymentProviderId(): Optional = body.paymentProviderId() - fun reportingConfiguration(): Optional = body.reportingConfiguration() + fun reportingConfiguration(): Optional = + body.reportingConfiguration() - fun shippingAddress(): Optional = body.shippingAddress() + fun shippingAddress(): Optional = body.shippingAddress() - fun taxConfiguration(): Optional = body.taxConfiguration() + fun taxConfiguration(): Optional = body.taxConfiguration() /** * Tax IDs are commonly required to be displayed on customer invoices, which are added to the @@ -228,7 +219,7 @@ private constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - fun taxId(): Optional = body.taxId() + fun taxId(): Optional = body.taxId() /** * A timezone identifier from the IANA timezone database, such as `"America/Los_Angeles"`. This @@ -246,7 +237,7 @@ private constructor( /** The full name of the customer */ fun _name(): JsonField = body._name() - fun _accountingSyncConfiguration(): JsonField = + fun _accountingSyncConfiguration(): JsonField = body._accountingSyncConfiguration() /** @@ -262,7 +253,7 @@ private constructor( */ fun _autoCollection(): JsonField = body._autoCollection() - fun _billingAddress(): JsonField = body._billingAddress() + fun _billingAddress(): JsonField = body._billingAddress() /** * An ISO 4217 currency string used for the customer's invoices and balance. If not set at @@ -280,7 +271,7 @@ private constructor( fun _externalCustomerId(): JsonField = body._externalCustomerId() /** The hierarchical relationships for this customer. */ - fun _hierarchy(): JsonField = body._hierarchy() + fun _hierarchy(): JsonField = body._hierarchy() /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting @@ -301,12 +292,12 @@ private constructor( */ fun _paymentProviderId(): JsonField = body._paymentProviderId() - fun _reportingConfiguration(): JsonField = + fun _reportingConfiguration(): JsonField = body._reportingConfiguration() - fun _shippingAddress(): JsonField = body._shippingAddress() + fun _shippingAddress(): JsonField = body._shippingAddress() - fun _taxConfiguration(): JsonField = body._taxConfiguration() + fun _taxConfiguration(): JsonField = body._taxConfiguration() /** * Tax IDs are commonly required to be displayed on customer invoices, which are added to the @@ -414,7 +405,7 @@ private constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - fun _taxId(): JsonField = body._taxId() + fun _taxId(): JsonField = body._taxId() /** * A timezone identifier from the IANA timezone database, such as `"America/Los_Angeles"`. This @@ -447,7 +438,7 @@ private constructor( private val name: JsonField = JsonMissing.of(), @JsonProperty("accounting_sync_configuration") @ExcludeMissing - private val accountingSyncConfiguration: JsonField = + private val accountingSyncConfiguration: JsonField = JsonMissing.of(), @JsonProperty("additional_emails") @ExcludeMissing @@ -457,7 +448,7 @@ private constructor( private val autoCollection: JsonField = JsonMissing.of(), @JsonProperty("billing_address") @ExcludeMissing - private val billingAddress: JsonField = JsonMissing.of(), + private val billingAddress: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing private val currency: JsonField = JsonMissing.of(), @@ -469,7 +460,7 @@ private constructor( private val externalCustomerId: JsonField = JsonMissing.of(), @JsonProperty("hierarchy") @ExcludeMissing - private val hierarchy: JsonField = JsonMissing.of(), + private val hierarchy: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), @@ -481,16 +472,17 @@ private constructor( private val paymentProviderId: JsonField = JsonMissing.of(), @JsonProperty("reporting_configuration") @ExcludeMissing - private val reportingConfiguration: JsonField = JsonMissing.of(), + private val reportingConfiguration: JsonField = + JsonMissing.of(), @JsonProperty("shipping_address") @ExcludeMissing - private val shippingAddress: JsonField = JsonMissing.of(), + private val shippingAddress: JsonField = JsonMissing.of(), @JsonProperty("tax_configuration") @ExcludeMissing - private val taxConfiguration: JsonField = JsonMissing.of(), + private val taxConfiguration: JsonField = JsonMissing.of(), @JsonProperty("tax_id") @ExcludeMissing - private val taxId: JsonField = JsonMissing.of(), + private val taxId: JsonField = JsonMissing.of(), @JsonProperty("timezone") @ExcludeMissing private val timezone: JsonField = JsonMissing.of(), @@ -507,7 +499,7 @@ private constructor( /** The full name of the customer */ fun name(): String = name.getRequired("name") - fun accountingSyncConfiguration(): Optional = + fun accountingSyncConfiguration(): Optional = Optional.ofNullable( accountingSyncConfiguration.getNullable("accounting_sync_configuration") ) @@ -527,7 +519,7 @@ private constructor( fun autoCollection(): Optional = Optional.ofNullable(autoCollection.getNullable("auto_collection")) - fun billingAddress(): Optional = + fun billingAddress(): Optional = Optional.ofNullable(billingAddress.getNullable("billing_address")) /** @@ -548,7 +540,7 @@ private constructor( Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) /** The hierarchical relationships for this customer. */ - fun hierarchy(): Optional = + fun hierarchy(): Optional = Optional.ofNullable(hierarchy.getNullable("hierarchy")) /** @@ -572,13 +564,13 @@ private constructor( fun paymentProviderId(): Optional = Optional.ofNullable(paymentProviderId.getNullable("payment_provider_id")) - fun reportingConfiguration(): Optional = + fun reportingConfiguration(): Optional = Optional.ofNullable(reportingConfiguration.getNullable("reporting_configuration")) - fun shippingAddress(): Optional = + fun shippingAddress(): Optional = Optional.ofNullable(shippingAddress.getNullable("shipping_address")) - fun taxConfiguration(): Optional = + fun taxConfiguration(): Optional = Optional.ofNullable(taxConfiguration.getNullable("tax_configuration")) /** @@ -687,7 +679,7 @@ private constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - fun taxId(): Optional = Optional.ofNullable(taxId.getNullable("tax_id")) + fun taxId(): Optional = Optional.ofNullable(taxId.getNullable("tax_id")) /** * A timezone identifier from the IANA timezone database, such as `"America/Los_Angeles"`. @@ -707,7 +699,7 @@ private constructor( @JsonProperty("accounting_sync_configuration") @ExcludeMissing - fun _accountingSyncConfiguration(): JsonField = + fun _accountingSyncConfiguration(): JsonField = accountingSyncConfiguration /** @@ -729,7 +721,7 @@ private constructor( @JsonProperty("billing_address") @ExcludeMissing - fun _billingAddress(): JsonField = billingAddress + fun _billingAddress(): JsonField = billingAddress /** * An ISO 4217 currency string used for the customer's invoices and balance. If not set at @@ -753,7 +745,7 @@ private constructor( /** The hierarchical relationships for this customer. */ @JsonProperty("hierarchy") @ExcludeMissing - fun _hierarchy(): JsonField = hierarchy + fun _hierarchy(): JsonField = hierarchy /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -780,15 +772,16 @@ private constructor( @JsonProperty("reporting_configuration") @ExcludeMissing - fun _reportingConfiguration(): JsonField = reportingConfiguration + fun _reportingConfiguration(): JsonField = + reportingConfiguration @JsonProperty("shipping_address") @ExcludeMissing - fun _shippingAddress(): JsonField = shippingAddress + fun _shippingAddress(): JsonField = shippingAddress @JsonProperty("tax_configuration") @ExcludeMissing - fun _taxConfiguration(): JsonField = taxConfiguration + fun _taxConfiguration(): JsonField = taxConfiguration /** * Tax IDs are commonly required to be displayed on customer invoices, which are added to @@ -896,7 +889,7 @@ private constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - @JsonProperty("tax_id") @ExcludeMissing fun _taxId(): JsonField = taxId + @JsonProperty("tax_id") @ExcludeMissing fun _taxId(): JsonField = taxId /** * A timezone identifier from the IANA timezone database, such as `"America/Los_Angeles"`. @@ -941,6 +934,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .email() + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -949,22 +951,24 @@ private constructor( private var email: JsonField? = null private var name: JsonField? = null - private var accountingSyncConfiguration: JsonField = + private var accountingSyncConfiguration: + JsonField = JsonMissing.of() private var additionalEmails: JsonField>? = null private var autoCollection: JsonField = JsonMissing.of() - private var billingAddress: JsonField = JsonMissing.of() + private var billingAddress: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() private var emailDelivery: JsonField = JsonMissing.of() private var externalCustomerId: JsonField = JsonMissing.of() - private var hierarchy: JsonField = JsonMissing.of() + private var hierarchy: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var paymentProvider: JsonField = JsonMissing.of() private var paymentProviderId: JsonField = JsonMissing.of() - private var reportingConfiguration: JsonField = JsonMissing.of() - private var shippingAddress: JsonField = JsonMissing.of() - private var taxConfiguration: JsonField = JsonMissing.of() - private var taxId: JsonField = JsonMissing.of() + private var reportingConfiguration: JsonField = + JsonMissing.of() + private var shippingAddress: JsonField = JsonMissing.of() + private var taxConfiguration: JsonField = JsonMissing.of() + private var taxId: JsonField = JsonMissing.of() private var timezone: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1012,15 +1016,15 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } fun accountingSyncConfiguration( - accountingSyncConfiguration: AccountingSyncConfiguration? + accountingSyncConfiguration: NewAccountingSyncConfigurationModel? ) = accountingSyncConfiguration(JsonField.ofNullable(accountingSyncConfiguration)) fun accountingSyncConfiguration( - accountingSyncConfiguration: Optional + accountingSyncConfiguration: Optional ) = accountingSyncConfiguration(accountingSyncConfiguration.orElse(null)) fun accountingSyncConfiguration( - accountingSyncConfiguration: JsonField + accountingSyncConfiguration: JsonField ) = apply { this.accountingSyncConfiguration = accountingSyncConfiguration } /** @@ -1051,14 +1055,8 @@ private constructor( */ fun addAdditionalEmail(additionalEmail: String) = apply { additionalEmails = - (additionalEmails ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(additionalEmail) + (additionalEmails ?: JsonField.of(mutableListOf())).also { + checkKnown("additionalEmails", it).add(additionalEmail) } } @@ -1095,13 +1093,13 @@ private constructor( this.autoCollection = autoCollection } - fun billingAddress(billingAddress: BillingAddress?) = + fun billingAddress(billingAddress: AddressInputModel?) = billingAddress(JsonField.ofNullable(billingAddress)) - fun billingAddress(billingAddress: Optional) = + fun billingAddress(billingAddress: Optional) = billingAddress(billingAddress.orElse(null)) - fun billingAddress(billingAddress: JsonField) = apply { + fun billingAddress(billingAddress: JsonField) = apply { this.billingAddress = billingAddress } @@ -1162,13 +1160,17 @@ private constructor( } /** The hierarchical relationships for this customer. */ - fun hierarchy(hierarchy: Hierarchy?) = hierarchy(JsonField.ofNullable(hierarchy)) + fun hierarchy(hierarchy: CustomerHierarchyConfigModel?) = + hierarchy(JsonField.ofNullable(hierarchy)) /** The hierarchical relationships for this customer. */ - fun hierarchy(hierarchy: Optional) = hierarchy(hierarchy.orElse(null)) + fun hierarchy(hierarchy: Optional) = + hierarchy(hierarchy.orElse(null)) /** The hierarchical relationships for this customer. */ - fun hierarchy(hierarchy: JsonField) = apply { this.hierarchy = hierarchy } + fun hierarchy(hierarchy: JsonField) = apply { + this.hierarchy = hierarchy + } /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -1235,61 +1237,63 @@ private constructor( this.paymentProviderId = paymentProviderId } - fun reportingConfiguration(reportingConfiguration: ReportingConfiguration?) = + fun reportingConfiguration(reportingConfiguration: NewReportingConfigurationModel?) = reportingConfiguration(JsonField.ofNullable(reportingConfiguration)) - fun reportingConfiguration(reportingConfiguration: Optional) = - reportingConfiguration(reportingConfiguration.orElse(null)) + fun reportingConfiguration( + reportingConfiguration: Optional + ) = reportingConfiguration(reportingConfiguration.orElse(null)) - fun reportingConfiguration(reportingConfiguration: JsonField) = - apply { - this.reportingConfiguration = reportingConfiguration - } + fun reportingConfiguration( + reportingConfiguration: JsonField + ) = apply { this.reportingConfiguration = reportingConfiguration } - fun shippingAddress(shippingAddress: ShippingAddress?) = + fun shippingAddress(shippingAddress: AddressInputModel?) = shippingAddress(JsonField.ofNullable(shippingAddress)) - fun shippingAddress(shippingAddress: Optional) = + fun shippingAddress(shippingAddress: Optional) = shippingAddress(shippingAddress.orElse(null)) - fun shippingAddress(shippingAddress: JsonField) = apply { + fun shippingAddress(shippingAddress: JsonField) = apply { this.shippingAddress = shippingAddress } - fun taxConfiguration(taxConfiguration: TaxConfiguration?) = + fun taxConfiguration(taxConfiguration: NewTaxConfigurationModel?) = taxConfiguration(JsonField.ofNullable(taxConfiguration)) - fun taxConfiguration(taxConfiguration: Optional) = + fun taxConfiguration(taxConfiguration: Optional) = taxConfiguration(taxConfiguration.orElse(null)) - fun taxConfiguration(taxConfiguration: JsonField) = apply { + fun taxConfiguration(taxConfiguration: JsonField) = apply { this.taxConfiguration = taxConfiguration } - fun taxConfiguration(newAvalara: TaxConfiguration.NewAvalaraTaxConfiguration) = - taxConfiguration(TaxConfiguration.ofNewAvalara(newAvalara)) + fun taxConfiguration( + avalaraTaxConfiguration: NewTaxConfigurationModel.NewAvalaraTaxConfiguration + ) = + taxConfiguration( + NewTaxConfigurationModel.ofAvalaraTaxConfiguration(avalaraTaxConfiguration) + ) - fun newAvalaraTaxConfiguration(taxExempt: Boolean) = + fun avalaraTaxConfigurationTaxConfiguration(taxExempt: Boolean) = taxConfiguration( - TaxConfiguration.NewAvalaraTaxConfiguration.builder() + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.builder() .taxProvider( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.TaxProvider.AVALARA ) .taxExempt(taxExempt) .build() ) - fun taxConfiguration(newTaxJar: TaxConfiguration.NewTaxJarConfiguration) = - taxConfiguration(TaxConfiguration.ofNewTaxJar(newTaxJar)) + fun taxConfiguration( + jarConfiguration: NewTaxConfigurationModel.NewTaxJarConfiguration + ) = taxConfiguration(NewTaxConfigurationModel.ofJarConfiguration(jarConfiguration)) - fun newTaxJarTaxConfiguration(taxExempt: Boolean) = + fun jarConfigurationTaxConfiguration(taxExempt: Boolean) = taxConfiguration( - TaxConfiguration.NewTaxJarConfiguration.builder() + NewTaxConfigurationModel.NewTaxJarConfiguration.builder() .taxProvider( - CustomerCreateParams.TaxConfiguration.NewTaxJarConfiguration.TaxProvider - .TAXJAR + NewTaxConfigurationModel.NewTaxJarConfiguration.TaxProvider.TAXJAR ) .taxExempt(taxExempt) .build() @@ -1401,7 +1405,7 @@ private constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - fun taxId(taxId: TaxId?) = taxId(JsonField.ofNullable(taxId)) + fun taxId(taxId: CustomerTaxIdModel?) = taxId(JsonField.ofNullable(taxId)) /** * Tax IDs are commonly required to be displayed on customer invoices, which are added @@ -1509,7 +1513,7 @@ private constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - fun taxId(taxId: Optional) = taxId(taxId.orElse(null)) + fun taxId(taxId: Optional) = taxId(taxId.orElse(null)) /** * Tax IDs are commonly required to be displayed on customer invoices, which are added @@ -1617,7 +1621,7 @@ private constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - fun taxId(taxId: JsonField) = apply { this.taxId = taxId } + fun taxId(taxId: JsonField) = apply { this.taxId = taxId } /** * A timezone identifier from the IANA timezone database, such as @@ -1705,6 +1709,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [CustomerCreateParams]. + * + * The following fields are required: + * ```java + * .email() + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1741,17 +1754,16 @@ private constructor( /** The full name of the customer */ fun name(name: JsonField) = apply { body.name(name) } - fun accountingSyncConfiguration(accountingSyncConfiguration: AccountingSyncConfiguration?) = - apply { - body.accountingSyncConfiguration(accountingSyncConfiguration) - } + fun accountingSyncConfiguration( + accountingSyncConfiguration: NewAccountingSyncConfigurationModel? + ) = apply { body.accountingSyncConfiguration(accountingSyncConfiguration) } fun accountingSyncConfiguration( - accountingSyncConfiguration: Optional + accountingSyncConfiguration: Optional ) = accountingSyncConfiguration(accountingSyncConfiguration.orElse(null)) fun accountingSyncConfiguration( - accountingSyncConfiguration: JsonField + accountingSyncConfiguration: JsonField ) = apply { body.accountingSyncConfiguration(accountingSyncConfiguration) } /** @@ -1817,14 +1829,14 @@ private constructor( body.autoCollection(autoCollection) } - fun billingAddress(billingAddress: BillingAddress?) = apply { + fun billingAddress(billingAddress: AddressInputModel?) = apply { body.billingAddress(billingAddress) } - fun billingAddress(billingAddress: Optional) = + fun billingAddress(billingAddress: Optional) = billingAddress(billingAddress.orElse(null)) - fun billingAddress(billingAddress: JsonField) = apply { + fun billingAddress(billingAddress: JsonField) = apply { body.billingAddress(billingAddress) } @@ -1885,13 +1897,18 @@ private constructor( } /** The hierarchical relationships for this customer. */ - fun hierarchy(hierarchy: Hierarchy?) = apply { body.hierarchy(hierarchy) } + fun hierarchy(hierarchy: CustomerHierarchyConfigModel?) = apply { + body.hierarchy(hierarchy) + } /** The hierarchical relationships for this customer. */ - fun hierarchy(hierarchy: Optional) = hierarchy(hierarchy.orElse(null)) + fun hierarchy(hierarchy: Optional) = + hierarchy(hierarchy.orElse(null)) /** The hierarchical relationships for this customer. */ - fun hierarchy(hierarchy: JsonField) = apply { body.hierarchy(hierarchy) } + fun hierarchy(hierarchy: JsonField) = apply { + body.hierarchy(hierarchy) + } /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -1960,54 +1977,56 @@ private constructor( body.paymentProviderId(paymentProviderId) } - fun reportingConfiguration(reportingConfiguration: ReportingConfiguration?) = apply { - body.reportingConfiguration(reportingConfiguration) - } - - fun reportingConfiguration(reportingConfiguration: Optional) = - reportingConfiguration(reportingConfiguration.orElse(null)) - - fun reportingConfiguration(reportingConfiguration: JsonField) = + fun reportingConfiguration(reportingConfiguration: NewReportingConfigurationModel?) = apply { body.reportingConfiguration(reportingConfiguration) } - fun shippingAddress(shippingAddress: ShippingAddress?) = apply { + fun reportingConfiguration( + reportingConfiguration: Optional + ) = reportingConfiguration(reportingConfiguration.orElse(null)) + + fun reportingConfiguration( + reportingConfiguration: JsonField + ) = apply { body.reportingConfiguration(reportingConfiguration) } + + fun shippingAddress(shippingAddress: AddressInputModel?) = apply { body.shippingAddress(shippingAddress) } - fun shippingAddress(shippingAddress: Optional) = + fun shippingAddress(shippingAddress: Optional) = shippingAddress(shippingAddress.orElse(null)) - fun shippingAddress(shippingAddress: JsonField) = apply { + fun shippingAddress(shippingAddress: JsonField) = apply { body.shippingAddress(shippingAddress) } - fun taxConfiguration(taxConfiguration: TaxConfiguration?) = apply { + fun taxConfiguration(taxConfiguration: NewTaxConfigurationModel?) = apply { body.taxConfiguration(taxConfiguration) } - fun taxConfiguration(taxConfiguration: Optional) = + fun taxConfiguration(taxConfiguration: Optional) = taxConfiguration(taxConfiguration.orElse(null)) - fun taxConfiguration(taxConfiguration: JsonField) = apply { + fun taxConfiguration(taxConfiguration: JsonField) = apply { body.taxConfiguration(taxConfiguration) } - fun taxConfiguration(newAvalara: TaxConfiguration.NewAvalaraTaxConfiguration) = apply { - body.taxConfiguration(newAvalara) - } + fun taxConfiguration( + avalaraTaxConfiguration: NewTaxConfigurationModel.NewAvalaraTaxConfiguration + ) = apply { body.taxConfiguration(avalaraTaxConfiguration) } - fun newAvalaraTaxConfiguration(taxExempt: Boolean) = apply { - body.newAvalaraTaxConfiguration(taxExempt) + fun avalaraTaxConfigurationTaxConfiguration(taxExempt: Boolean) = apply { + body.avalaraTaxConfigurationTaxConfiguration(taxExempt) } - fun taxConfiguration(newTaxJar: TaxConfiguration.NewTaxJarConfiguration) = apply { - body.taxConfiguration(newTaxJar) - } + fun taxConfiguration(jarConfiguration: NewTaxConfigurationModel.NewTaxJarConfiguration) = + apply { + body.taxConfiguration(jarConfiguration) + } - fun newTaxJarTaxConfiguration(taxExempt: Boolean) = apply { - body.newTaxJarTaxConfiguration(taxExempt) + fun jarConfigurationTaxConfiguration(taxExempt: Boolean) = apply { + body.jarConfigurationTaxConfiguration(taxExempt) } /** @@ -2116,7 +2135,7 @@ private constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - fun taxId(taxId: TaxId?) = apply { body.taxId(taxId) } + fun taxId(taxId: CustomerTaxIdModel?) = apply { body.taxId(taxId) } /** * Tax IDs are commonly required to be displayed on customer invoices, which are added to @@ -2224,7 +2243,7 @@ private constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - fun taxId(taxId: Optional) = taxId(taxId.orElse(null)) + fun taxId(taxId: Optional) = taxId(taxId.orElse(null)) /** * Tax IDs are commonly required to be displayed on customer invoices, which are added to @@ -2332,7 +2351,7 @@ private constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - fun taxId(taxId: JsonField) = apply { body.taxId(taxId) } + fun taxId(taxId: JsonField) = apply { body.taxId(taxId) } /** * A timezone identifier from the IANA timezone database, such as `"America/Los_Angeles"`. @@ -2480,44 +2499,30 @@ private 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`. + */ @NoAutoDetect - class AccountingSyncConfiguration + class Metadata @JsonCreator private constructor( - @JsonProperty("accounting_providers") - @ExcludeMissing - private val accountingProviders: JsonField> = JsonMissing.of(), - @JsonProperty("excluded") - @ExcludeMissing - private val excluded: JsonField = JsonMissing.of(), @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { - fun accountingProviders(): Optional> = - Optional.ofNullable(accountingProviders.getNullable("accounting_providers")) - - fun excluded(): Optional = Optional.ofNullable(excluded.getNullable("excluded")) - - @JsonProperty("accounting_providers") - @ExcludeMissing - fun _accountingProviders(): JsonField> = accountingProviders - - @JsonProperty("excluded") @ExcludeMissing fun _excluded(): JsonField = excluded - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties private var validated: Boolean = false - fun validate(): AccountingSyncConfiguration = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } - accountingProviders().ifPresent { it.forEach { it.validate() } } - excluded() validated = true } @@ -2525,58 +2530,20 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [AccountingSyncConfiguration]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { - private var accountingProviders: JsonField>? = null - private var excluded: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(accountingSyncConfiguration: AccountingSyncConfiguration) = apply { - accountingProviders = - accountingSyncConfiguration.accountingProviders.map { it.toMutableList() } - excluded = accountingSyncConfiguration.excluded - additionalProperties = - accountingSyncConfiguration.additionalProperties.toMutableMap() - } - - fun accountingProviders(accountingProviders: List?) = - accountingProviders(JsonField.ofNullable(accountingProviders)) - - fun accountingProviders(accountingProviders: Optional>) = - accountingProviders(accountingProviders.orElse(null)) - - fun accountingProviders(accountingProviders: JsonField>) = - apply { - this.accountingProviders = accountingProviders.map { it.toMutableList() } - } - - fun addAccountingProvider(accountingProvider: AccountingProvider) = apply { - accountingProviders = - (accountingProviders ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(accountingProvider) - } + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - fun excluded(excluded: Boolean?) = excluded(JsonField.ofNullable(excluded)) - - fun excluded(excluded: Boolean) = excluded(excluded as Boolean?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun excluded(excluded: Optional) = excluded(excluded.orElse(null) as Boolean?) - - fun excluded(excluded: JsonField) = apply { this.excluded = excluded } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -2596,137 +2563,7 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): AccountingSyncConfiguration = - AccountingSyncConfiguration( - (accountingProviders ?: JsonMissing.of()).map { it.toImmutable() }, - excluded, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class AccountingProvider - @JsonCreator - private constructor( - @JsonProperty("external_provider_id") - @ExcludeMissing - private val externalProviderId: JsonField = JsonMissing.of(), - @JsonProperty("provider_type") - @ExcludeMissing - private val providerType: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun externalProviderId(): String = - externalProviderId.getRequired("external_provider_id") - - fun providerType(): String = providerType.getRequired("provider_type") - - @JsonProperty("external_provider_id") - @ExcludeMissing - fun _externalProviderId(): JsonField = externalProviderId - - @JsonProperty("provider_type") - @ExcludeMissing - fun _providerType(): JsonField = providerType - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AccountingProvider = apply { - if (validated) { - return@apply - } - - externalProviderId() - providerType() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AccountingProvider]. */ - class Builder internal constructor() { - - private var externalProviderId: JsonField? = null - private var providerType: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(accountingProvider: AccountingProvider) = apply { - externalProviderId = accountingProvider.externalProviderId - providerType = accountingProvider.providerType - additionalProperties = accountingProvider.additionalProperties.toMutableMap() - } - - fun externalProviderId(externalProviderId: String) = - externalProviderId(JsonField.of(externalProviderId)) - - fun externalProviderId(externalProviderId: JsonField) = apply { - this.externalProviderId = externalProviderId - } - - fun providerType(providerType: String) = providerType(JsonField.of(providerType)) - - fun providerType(providerType: JsonField) = apply { - this.providerType = providerType - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): AccountingProvider = - AccountingProvider( - checkRequired("externalProviderId", externalProviderId), - checkRequired("providerType", providerType), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AccountingProvider && externalProviderId == other.externalProviderId && providerType == other.providerType && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(externalProviderId, providerType, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AccountingProvider{externalProviderId=$externalProviderId, providerType=$providerType, additionalProperties=$additionalProperties}" + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -2734,2794 +2571,139 @@ private constructor( return true } - return /* spotless:off */ other is AccountingSyncConfiguration && accountingProviders == other.accountingProviders && excluded == other.excluded && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(accountingProviders, excluded, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode - override fun toString() = - "AccountingSyncConfiguration{accountingProviders=$accountingProviders, excluded=$excluded, additionalProperties=$additionalProperties}" + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - @NoAutoDetect - class BillingAddress - @JsonCreator - private constructor( - @JsonProperty("city") - @ExcludeMissing - private val city: JsonField = JsonMissing.of(), - @JsonProperty("country") - @ExcludeMissing - private val country: JsonField = JsonMissing.of(), - @JsonProperty("line1") - @ExcludeMissing - private val line1: JsonField = JsonMissing.of(), - @JsonProperty("line2") - @ExcludeMissing - private val line2: JsonField = JsonMissing.of(), - @JsonProperty("postal_code") - @ExcludeMissing - private val postalCode: JsonField = JsonMissing.of(), - @JsonProperty("state") - @ExcludeMissing - private val state: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun city(): Optional = Optional.ofNullable(city.getNullable("city")) - - fun country(): Optional = Optional.ofNullable(country.getNullable("country")) - - fun line1(): Optional = Optional.ofNullable(line1.getNullable("line1")) - - fun line2(): Optional = Optional.ofNullable(line2.getNullable("line2")) - - fun postalCode(): Optional = - Optional.ofNullable(postalCode.getNullable("postal_code")) - - fun state(): Optional = Optional.ofNullable(state.getNullable("state")) - - @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city - - @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country + /** + * This is used for creating charges or invoices in an external system via Orb. When not in test + * mode, the connection must first be configured in the Orb webapp. + */ + class PaymentProvider @JsonCreator private constructor(private val value: JsonField) : + Enum { - @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField = line1 + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 + companion object { - @JsonProperty("postal_code") - @ExcludeMissing - fun _postalCode(): JsonField = postalCode + @JvmField val QUICKBOOKS = of("quickbooks") - @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state + @JvmField val BILL_COM = of("bill.com") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + @JvmField val STRIPE_CHARGE = of("stripe_charge") - private var validated: Boolean = false + @JvmField val STRIPE_INVOICE = of("stripe_invoice") - fun validate(): BillingAddress = apply { - if (validated) { - return@apply - } + @JvmField val NETSUITE = of("netsuite") - city() - country() - line1() - line2() - postalCode() - state() - validated = true + @JvmStatic fun of(value: String) = PaymentProvider(JsonField.of(value)) } - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() + /** An enum containing [PaymentProvider]'s known values. */ + enum class Known { + QUICKBOOKS, + BILL_COM, + STRIPE_CHARGE, + STRIPE_INVOICE, + NETSUITE, } - /** A builder for [BillingAddress]. */ - class Builder internal constructor() { - - private var city: JsonField = JsonMissing.of() - private var country: JsonField = JsonMissing.of() - private var line1: JsonField = JsonMissing.of() - private var line2: JsonField = JsonMissing.of() - private var postalCode: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingAddress: BillingAddress) = apply { - city = billingAddress.city - country = billingAddress.country - line1 = billingAddress.line1 - line2 = billingAddress.line2 - postalCode = billingAddress.postalCode - state = billingAddress.state - additionalProperties = billingAddress.additionalProperties.toMutableMap() - } - - fun city(city: String?) = city(JsonField.ofNullable(city)) - - fun city(city: Optional) = city(city.orElse(null)) - - fun city(city: JsonField) = apply { this.city = city } - - fun country(country: String?) = country(JsonField.ofNullable(country)) - - fun country(country: Optional) = country(country.orElse(null)) - - fun country(country: JsonField) = apply { this.country = country } - - fun line1(line1: String?) = line1(JsonField.ofNullable(line1)) - - fun line1(line1: Optional) = line1(line1.orElse(null)) - - fun line1(line1: JsonField) = apply { this.line1 = line1 } - - fun line2(line2: String?) = line2(JsonField.ofNullable(line2)) - - fun line2(line2: Optional) = line2(line2.orElse(null)) - - fun line2(line2: JsonField) = apply { this.line2 = line2 } - - fun postalCode(postalCode: String?) = postalCode(JsonField.ofNullable(postalCode)) - - fun postalCode(postalCode: Optional) = postalCode(postalCode.orElse(null)) - - fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode } - - fun state(state: String?) = state(JsonField.ofNullable(state)) - - fun state(state: Optional) = state(state.orElse(null)) - - fun state(state: JsonField) = apply { this.state = state } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * 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 { + QUICKBOOKS, + BILL_COM, + STRIPE_CHARGE, + STRIPE_INVOICE, + NETSUITE, + /** + * An enum member indicating that [PaymentProvider] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + QUICKBOOKS -> Value.QUICKBOOKS + BILL_COM -> Value.BILL_COM + STRIPE_CHARGE -> Value.STRIPE_CHARGE + STRIPE_INVOICE -> Value.STRIPE_INVOICE + NETSUITE -> Value.NETSUITE + else -> Value._UNKNOWN } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + QUICKBOOKS -> Known.QUICKBOOKS + BILL_COM -> Known.BILL_COM + STRIPE_CHARGE -> Known.STRIPE_CHARGE + STRIPE_INVOICE -> Known.STRIPE_INVOICE + NETSUITE -> Known.NETSUITE + else -> throw OrbInvalidDataException("Unknown PaymentProvider: $value") } - fun build(): BillingAddress = - BillingAddress( - city, - country, - line1, - line2, - postalCode, - state, - additionalProperties.toImmutable(), - ) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is BillingAddress && city == other.city && country == other.country && line1 == other.line1 && line2 == other.line2 && postalCode == other.postalCode && state == other.state && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(city, country, line1, line2, postalCode, state, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingAddress{city=$city, country=$country, line1=$line1, line2=$line2, postalCode=$postalCode, state=$state, additionalProperties=$additionalProperties}" - } - - /** The hierarchical relationships for this customer. */ - @NoAutoDetect - class Hierarchy - @JsonCreator - private constructor( - @JsonProperty("child_customer_ids") - @ExcludeMissing - private val childCustomerIds: JsonField> = JsonMissing.of(), - @JsonProperty("parent_customer_id") - @ExcludeMissing - private val parentCustomerId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * A list of child customer IDs to add to the hierarchy. The desired child customers must - * not already be part of another hierarchy. - */ - fun childCustomerIds(): Optional> = - Optional.ofNullable(childCustomerIds.getNullable("child_customer_ids")) - - /** - * The ID of the parent customer in the hierarchy. The desired parent customer must not be a - * child of another customer. - */ - fun parentCustomerId(): Optional = - Optional.ofNullable(parentCustomerId.getNullable("parent_customer_id")) - - /** - * A list of child customer IDs to add to the hierarchy. The desired child customers must - * not already be part of another hierarchy. - */ - @JsonProperty("child_customer_ids") - @ExcludeMissing - fun _childCustomerIds(): JsonField> = childCustomerIds - - /** - * The ID of the parent customer in the hierarchy. The desired parent customer must not be a - * child of another customer. - */ - @JsonProperty("parent_customer_id") - @ExcludeMissing - fun _parentCustomerId(): JsonField = parentCustomerId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Hierarchy = apply { - if (validated) { - return@apply - } - - childCustomerIds() - parentCustomerId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Hierarchy]. */ - class Builder internal constructor() { - - private var childCustomerIds: JsonField>? = null - private var parentCustomerId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(hierarchy: Hierarchy) = apply { - childCustomerIds = hierarchy.childCustomerIds.map { it.toMutableList() } - parentCustomerId = hierarchy.parentCustomerId - additionalProperties = hierarchy.additionalProperties.toMutableMap() - } - - /** - * A list of child customer IDs to add to the hierarchy. The desired child customers - * must not already be part of another hierarchy. - */ - fun childCustomerIds(childCustomerIds: List) = - childCustomerIds(JsonField.of(childCustomerIds)) - - /** - * A list of child customer IDs to add to the hierarchy. The desired child customers - * must not already be part of another hierarchy. - */ - fun childCustomerIds(childCustomerIds: JsonField>) = apply { - this.childCustomerIds = childCustomerIds.map { it.toMutableList() } - } - - /** - * A list of child customer IDs to add to the hierarchy. The desired child customers - * must not already be part of another hierarchy. - */ - fun addChildCustomerId(childCustomerId: String) = apply { - childCustomerIds = - (childCustomerIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(childCustomerId) - } - } - - /** - * The ID of the parent customer in the hierarchy. The desired parent customer must not - * be a child of another customer. - */ - fun parentCustomerId(parentCustomerId: String?) = - parentCustomerId(JsonField.ofNullable(parentCustomerId)) - - /** - * The ID of the parent customer in the hierarchy. The desired parent customer must not - * be a child of another customer. - */ - fun parentCustomerId(parentCustomerId: Optional) = - parentCustomerId(parentCustomerId.orElse(null)) - - /** - * The ID of the parent customer in the hierarchy. The desired parent customer must not - * be a child of another customer. - */ - fun parentCustomerId(parentCustomerId: JsonField) = apply { - this.parentCustomerId = parentCustomerId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Hierarchy = - Hierarchy( - (childCustomerIds ?: JsonMissing.of()).map { it.toImmutable() }, - parentCustomerId, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Hierarchy && childCustomerIds == other.childCustomerIds && parentCustomerId == other.parentCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(childCustomerIds, parentCustomerId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Hierarchy{childCustomerIds=$childCustomerIds, parentCustomerId=$parentCustomerId, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - /** - * This is used for creating charges or invoices in an external system via Orb. When not in test - * mode, the connection must first be configured in the Orb webapp. - */ - 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 QUICKBOOKS = of("quickbooks") - - @JvmField val BILL_COM = of("bill.com") - - @JvmField val STRIPE_CHARGE = of("stripe_charge") - - @JvmField val STRIPE_INVOICE = of("stripe_invoice") - - @JvmField val NETSUITE = of("netsuite") - - @JvmStatic fun of(value: String) = PaymentProvider(JsonField.of(value)) - } - - /** An enum containing [PaymentProvider]'s known values. */ - enum class Known { - QUICKBOOKS, - BILL_COM, - STRIPE_CHARGE, - STRIPE_INVOICE, - NETSUITE, - } - - /** - * 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 { - QUICKBOOKS, - BILL_COM, - STRIPE_CHARGE, - STRIPE_INVOICE, - NETSUITE, - /** - * 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) { - QUICKBOOKS -> Value.QUICKBOOKS - BILL_COM -> Value.BILL_COM - STRIPE_CHARGE -> Value.STRIPE_CHARGE - STRIPE_INVOICE -> Value.STRIPE_INVOICE - 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 - BILL_COM -> Known.BILL_COM - STRIPE_CHARGE -> Known.STRIPE_CHARGE - STRIPE_INVOICE -> Known.STRIPE_INVOICE - NETSUITE -> Known.NETSUITE - 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PaymentProvider && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class ReportingConfiguration - @JsonCreator - private constructor( - @JsonProperty("exempt") - @ExcludeMissing - private val exempt: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun exempt(): Boolean = exempt.getRequired("exempt") - - @JsonProperty("exempt") @ExcludeMissing fun _exempt(): JsonField = exempt - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): ReportingConfiguration = apply { - if (validated) { - return@apply - } - - exempt() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ReportingConfiguration]. */ - class Builder internal constructor() { - - private var exempt: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(reportingConfiguration: ReportingConfiguration) = apply { - exempt = reportingConfiguration.exempt - additionalProperties = reportingConfiguration.additionalProperties.toMutableMap() - } - - fun exempt(exempt: Boolean) = exempt(JsonField.of(exempt)) - - fun exempt(exempt: JsonField) = apply { this.exempt = exempt } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): ReportingConfiguration = - ReportingConfiguration( - checkRequired("exempt", exempt), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ReportingConfiguration && exempt == other.exempt && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(exempt, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ReportingConfiguration{exempt=$exempt, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class ShippingAddress - @JsonCreator - private constructor( - @JsonProperty("city") - @ExcludeMissing - private val city: JsonField = JsonMissing.of(), - @JsonProperty("country") - @ExcludeMissing - private val country: JsonField = JsonMissing.of(), - @JsonProperty("line1") - @ExcludeMissing - private val line1: JsonField = JsonMissing.of(), - @JsonProperty("line2") - @ExcludeMissing - private val line2: JsonField = JsonMissing.of(), - @JsonProperty("postal_code") - @ExcludeMissing - private val postalCode: JsonField = JsonMissing.of(), - @JsonProperty("state") - @ExcludeMissing - private val state: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun city(): Optional = Optional.ofNullable(city.getNullable("city")) - - fun country(): Optional = Optional.ofNullable(country.getNullable("country")) - - fun line1(): Optional = Optional.ofNullable(line1.getNullable("line1")) - - fun line2(): Optional = Optional.ofNullable(line2.getNullable("line2")) - - fun postalCode(): Optional = - Optional.ofNullable(postalCode.getNullable("postal_code")) - - fun state(): Optional = Optional.ofNullable(state.getNullable("state")) - - @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city - - @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country - - @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField = line1 - - @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 - - @JsonProperty("postal_code") - @ExcludeMissing - fun _postalCode(): JsonField = postalCode - - @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): ShippingAddress = apply { - if (validated) { - return@apply - } - - city() - country() - line1() - line2() - postalCode() - state() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ShippingAddress]. */ - class Builder internal constructor() { - - private var city: JsonField = JsonMissing.of() - private var country: JsonField = JsonMissing.of() - private var line1: JsonField = JsonMissing.of() - private var line2: JsonField = JsonMissing.of() - private var postalCode: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(shippingAddress: ShippingAddress) = apply { - city = shippingAddress.city - country = shippingAddress.country - line1 = shippingAddress.line1 - line2 = shippingAddress.line2 - postalCode = shippingAddress.postalCode - state = shippingAddress.state - additionalProperties = shippingAddress.additionalProperties.toMutableMap() - } - - fun city(city: String?) = city(JsonField.ofNullable(city)) - - fun city(city: Optional) = city(city.orElse(null)) - - fun city(city: JsonField) = apply { this.city = city } - - fun country(country: String?) = country(JsonField.ofNullable(country)) - - fun country(country: Optional) = country(country.orElse(null)) - - fun country(country: JsonField) = apply { this.country = country } - - fun line1(line1: String?) = line1(JsonField.ofNullable(line1)) - - fun line1(line1: Optional) = line1(line1.orElse(null)) - - fun line1(line1: JsonField) = apply { this.line1 = line1 } - - fun line2(line2: String?) = line2(JsonField.ofNullable(line2)) - - fun line2(line2: Optional) = line2(line2.orElse(null)) - - fun line2(line2: JsonField) = apply { this.line2 = line2 } - - fun postalCode(postalCode: String?) = postalCode(JsonField.ofNullable(postalCode)) - - fun postalCode(postalCode: Optional) = postalCode(postalCode.orElse(null)) - - fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode } - - fun state(state: String?) = state(JsonField.ofNullable(state)) - - fun state(state: Optional) = state(state.orElse(null)) - - fun state(state: JsonField) = apply { this.state = state } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): ShippingAddress = - ShippingAddress( - city, - country, - line1, - line2, - postalCode, - state, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ShippingAddress && city == other.city && country == other.country && line1 == other.line1 && line2 == other.line2 && postalCode == other.postalCode && state == other.state && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(city, country, line1, line2, postalCode, state, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ShippingAddress{city=$city, country=$country, line1=$line1, line2=$line2, postalCode=$postalCode, state=$state, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(using = TaxConfiguration.Deserializer::class) - @JsonSerialize(using = TaxConfiguration.Serializer::class) - class TaxConfiguration - private constructor( - private val newAvalara: NewAvalaraTaxConfiguration? = null, - private val newTaxJar: NewTaxJarConfiguration? = null, - private val _json: JsonValue? = null, - ) { - - fun newAvalara(): Optional = Optional.ofNullable(newAvalara) - - fun newTaxJar(): Optional = Optional.ofNullable(newTaxJar) - - fun isNewAvalara(): Boolean = newAvalara != null - - fun isNewTaxJar(): Boolean = newTaxJar != null - - fun asNewAvalara(): NewAvalaraTaxConfiguration = newAvalara.getOrThrow("newAvalara") - - fun asNewTaxJar(): NewTaxJarConfiguration = newTaxJar.getOrThrow("newTaxJar") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - newAvalara != null -> visitor.visitNewAvalara(newAvalara) - newTaxJar != null -> visitor.visitNewTaxJar(newTaxJar) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): TaxConfiguration = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitNewAvalara(newAvalara: NewAvalaraTaxConfiguration) { - newAvalara.validate() - } - - override fun visitNewTaxJar(newTaxJar: NewTaxJarConfiguration) { - newTaxJar.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TaxConfiguration && newAvalara == other.newAvalara && newTaxJar == other.newTaxJar /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(newAvalara, newTaxJar) /* spotless:on */ - - override fun toString(): String = - when { - newAvalara != null -> "TaxConfiguration{newAvalara=$newAvalara}" - newTaxJar != null -> "TaxConfiguration{newTaxJar=$newTaxJar}" - _json != null -> "TaxConfiguration{_unknown=$_json}" - else -> throw IllegalStateException("Invalid TaxConfiguration") - } - - companion object { - - @JvmStatic - fun ofNewAvalara(newAvalara: NewAvalaraTaxConfiguration) = - TaxConfiguration(newAvalara = newAvalara) - - @JvmStatic - fun ofNewTaxJar(newTaxJar: NewTaxJarConfiguration) = - TaxConfiguration(newTaxJar = newTaxJar) - } - - /** - * An interface that defines how to map each variant of [TaxConfiguration] to a value of - * type [T]. - */ - interface Visitor { - - fun visitNewAvalara(newAvalara: NewAvalaraTaxConfiguration): T - - fun visitNewTaxJar(newTaxJar: NewTaxJarConfiguration): T - - /** - * Maps an unknown variant of [TaxConfiguration] to a value of type [T]. - * - * An instance of [TaxConfiguration] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown TaxConfiguration: $json") - } - } - - internal class Deserializer : BaseDeserializer(TaxConfiguration::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): TaxConfiguration { - val json = JsonValue.fromJsonNode(node) - val taxProvider = - json.asObject().getOrNull()?.get("tax_provider")?.asString()?.getOrNull() - - when (taxProvider) { - "avalara" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return TaxConfiguration(newAvalara = it, _json = json) - } - } - "taxjar" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return TaxConfiguration(newTaxJar = it, _json = json) - } - } - } - - return TaxConfiguration(_json = json) - } - } - - internal class Serializer : BaseSerializer(TaxConfiguration::class) { - - override fun serialize( - value: TaxConfiguration, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.newAvalara != null -> generator.writeObject(value.newAvalara) - value.newTaxJar != null -> generator.writeObject(value.newTaxJar) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid TaxConfiguration") - } - } - } - - @NoAutoDetect - class NewAvalaraTaxConfiguration - @JsonCreator - private constructor( - @JsonProperty("tax_exempt") - @ExcludeMissing - private val taxExempt: JsonField = JsonMissing.of(), - @JsonProperty("tax_provider") - @ExcludeMissing - private val taxProvider: JsonField = JsonMissing.of(), - @JsonProperty("tax_exemption_code") - @ExcludeMissing - private val taxExemptionCode: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun taxExempt(): Boolean = taxExempt.getRequired("tax_exempt") - - fun taxProvider(): TaxProvider = taxProvider.getRequired("tax_provider") - - fun taxExemptionCode(): Optional = - Optional.ofNullable(taxExemptionCode.getNullable("tax_exemption_code")) - - @JsonProperty("tax_exempt") - @ExcludeMissing - fun _taxExempt(): JsonField = taxExempt - - @JsonProperty("tax_provider") - @ExcludeMissing - fun _taxProvider(): JsonField = taxProvider - - @JsonProperty("tax_exemption_code") - @ExcludeMissing - fun _taxExemptionCode(): JsonField = taxExemptionCode - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewAvalaraTaxConfiguration = apply { - if (validated) { - return@apply - } - - taxExempt() - taxProvider() - taxExemptionCode() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewAvalaraTaxConfiguration]. */ - class Builder internal constructor() { - - private var taxExempt: JsonField? = null - private var taxProvider: JsonField? = null - private var taxExemptionCode: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newAvalaraTaxConfiguration: NewAvalaraTaxConfiguration) = apply { - taxExempt = newAvalaraTaxConfiguration.taxExempt - taxProvider = newAvalaraTaxConfiguration.taxProvider - taxExemptionCode = newAvalaraTaxConfiguration.taxExemptionCode - additionalProperties = - newAvalaraTaxConfiguration.additionalProperties.toMutableMap() - } - - fun taxExempt(taxExempt: Boolean) = taxExempt(JsonField.of(taxExempt)) - - fun taxExempt(taxExempt: JsonField) = apply { this.taxExempt = taxExempt } - - fun taxProvider(taxProvider: TaxProvider) = taxProvider(JsonField.of(taxProvider)) - - fun taxProvider(taxProvider: JsonField) = apply { - this.taxProvider = taxProvider - } - - fun taxExemptionCode(taxExemptionCode: String?) = - taxExemptionCode(JsonField.ofNullable(taxExemptionCode)) - - fun taxExemptionCode(taxExemptionCode: Optional) = - taxExemptionCode(taxExemptionCode.orElse(null)) - - fun taxExemptionCode(taxExemptionCode: JsonField) = apply { - this.taxExemptionCode = taxExemptionCode - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): NewAvalaraTaxConfiguration = - NewAvalaraTaxConfiguration( - checkRequired("taxExempt", taxExempt), - checkRequired("taxProvider", taxProvider), - taxExemptionCode, - additionalProperties.toImmutable(), - ) - } - - class TaxProvider - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val AVALARA = of("avalara") - - @JvmStatic fun of(value: String) = TaxProvider(JsonField.of(value)) - } - - /** An enum containing [TaxProvider]'s known values. */ - enum class Known { - AVALARA - } - - /** - * An enum containing [TaxProvider]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [TaxProvider] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AVALARA, - /** - * An enum member indicating that [TaxProvider] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AVALARA -> Value.AVALARA - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AVALARA -> Known.AVALARA - else -> throw OrbInvalidDataException("Unknown TaxProvider: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TaxProvider && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewAvalaraTaxConfiguration && taxExempt == other.taxExempt && taxProvider == other.taxProvider && taxExemptionCode == other.taxExemptionCode && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(taxExempt, taxProvider, taxExemptionCode, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewAvalaraTaxConfiguration{taxExempt=$taxExempt, taxProvider=$taxProvider, taxExemptionCode=$taxExemptionCode, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewTaxJarConfiguration - @JsonCreator - private constructor( - @JsonProperty("tax_exempt") - @ExcludeMissing - private val taxExempt: JsonField = JsonMissing.of(), - @JsonProperty("tax_provider") - @ExcludeMissing - private val taxProvider: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun taxExempt(): Boolean = taxExempt.getRequired("tax_exempt") - - fun taxProvider(): TaxProvider = taxProvider.getRequired("tax_provider") - - @JsonProperty("tax_exempt") - @ExcludeMissing - fun _taxExempt(): JsonField = taxExempt - - @JsonProperty("tax_provider") - @ExcludeMissing - fun _taxProvider(): JsonField = taxProvider - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewTaxJarConfiguration = apply { - if (validated) { - return@apply - } - - taxExempt() - taxProvider() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewTaxJarConfiguration]. */ - class Builder internal constructor() { - - private var taxExempt: JsonField? = null - private var taxProvider: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newTaxJarConfiguration: NewTaxJarConfiguration) = apply { - taxExempt = newTaxJarConfiguration.taxExempt - taxProvider = newTaxJarConfiguration.taxProvider - additionalProperties = - newTaxJarConfiguration.additionalProperties.toMutableMap() - } - - fun taxExempt(taxExempt: Boolean) = taxExempt(JsonField.of(taxExempt)) - - fun taxExempt(taxExempt: JsonField) = apply { this.taxExempt = taxExempt } - - fun taxProvider(taxProvider: TaxProvider) = taxProvider(JsonField.of(taxProvider)) - - fun taxProvider(taxProvider: JsonField) = apply { - this.taxProvider = taxProvider - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): NewTaxJarConfiguration = - NewTaxJarConfiguration( - checkRequired("taxExempt", taxExempt), - checkRequired("taxProvider", taxProvider), - additionalProperties.toImmutable(), - ) - } - - class TaxProvider - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val TAXJAR = of("taxjar") - - @JvmStatic fun of(value: String) = TaxProvider(JsonField.of(value)) - } - - /** An enum containing [TaxProvider]'s known values. */ - enum class Known { - TAXJAR - } - - /** - * An enum containing [TaxProvider]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [TaxProvider] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TAXJAR, - /** - * An enum member indicating that [TaxProvider] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TAXJAR -> Value.TAXJAR - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - TAXJAR -> Known.TAXJAR - else -> throw OrbInvalidDataException("Unknown TaxProvider: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TaxProvider && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewTaxJarConfiguration && taxExempt == other.taxExempt && taxProvider == other.taxProvider && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(taxExempt, taxProvider, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewTaxJarConfiguration{taxExempt=$taxExempt, taxProvider=$taxProvider, additionalProperties=$additionalProperties}" - } - } - - /** - * 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 | - * |--------------------|------------|-------------------------------------------------------------------------------------------------------| - * |Andorra |`ad_nrt` |Andorran NRT Number | - * |Argentina |`ar_cuit` |Argentinian Tax ID Number | - * |Australia |`au_abn` |Australian Business Number (AU ABN) | - * |Australia |`au_arn` |Australian Taxation Office Reference Number | - * |Austria |`eu_vat` |European VAT Number | - * |Bahrain |`bh_vat` |Bahraini VAT Number | - * |Belgium |`eu_vat` |European VAT Number | - * |Bolivia |`bo_tin` |Bolivian Tax ID | - * |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 | - * |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) | - * |Chile |`cl_tin` |Chilean TIN | - * |China |`cn_tin` |Chinese Tax ID | - * |Colombia |`co_nit` |Colombian NIT Number | - * |Costa Rica |`cr_tin` |Costa Rican Tax ID | - * |Croatia |`eu_vat` |European VAT Number | - * |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 | - * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | - * |Finland |`eu_vat` |European VAT Number | - * |France |`eu_vat` |European VAT Number | - * |Georgia |`ge_vat` |Georgian VAT | - * |Germany |`eu_vat` |European VAT Number | - * |Greece |`eu_vat` |European VAT Number | - * |Hong Kong |`hk_br` |Hong Kong BR Number | - * |Hungary |`eu_vat` |European VAT Number | - * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | - * |Iceland |`is_vat` |Icelandic VAT | - * |India |`in_gst` |Indian GST Number | - * |Indonesia |`id_npwp` |Indonesian NPWP Number | - * |Ireland |`eu_vat` |European VAT Number | - * |Israel |`il_vat` |Israel VAT | - * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | - * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | - * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | - * |Latvia |`eu_vat` |European VAT Number | - * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | - * |Mexico |`mx_rfc` |Mexican RFC Number | - * |Netherlands |`eu_vat` |European VAT Number | - * |New Zealand |`nz_gst` |New Zealand GST Number | - * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | - * |Norway |`no_vat` |Norwegian VAT Number | - * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | - * |Oman |`om_vat` |Omani VAT Number | - * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | - * |Poland |`eu_vat` |European VAT Number | - * |Portugal |`eu_vat` |European VAT Number | - * |Romania |`eu_vat` |European VAT Number | - * |Romania |`ro_tin` |Romanian Tax ID Number | - * |Russia |`ru_inn` |Russian INN | - * |Russia |`ru_kpp` |Russian KPP | - * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | - * |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 | - * |Sweden |`eu_vat` |European VAT Number | - * |Switzerland |`ch_vat` |Switzerland VAT Number | - * |Taiwan |`tw_vat` |Taiwanese VAT | - * |Thailand |`th_vat` |Thai VAT | - * |Turkey |`tr_tin` |Turkish Tax Identification Number | - * |Ukraine |`ua_vat` |Ukrainian VAT | - * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | - * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | - * |United Kingdom |`gb_vat` |United Kingdom VAT Number | - * |United States |`us_ein` |United States EIN | - * |Uruguay |`uy_ruc` |Uruguayan RUC Number | - * |Venezuela |`ve_rif` |Venezuelan RIF Number | - * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | - */ - @NoAutoDetect - class TaxId - @JsonCreator - private constructor( - @JsonProperty("country") - @ExcludeMissing - private val country: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonProperty("value") - @ExcludeMissing - private val value: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun country(): Country = country.getRequired("country") - - fun type(): Type = type.getRequired("type") - - fun value(): String = value.getRequired("value") - - @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country - - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TaxId = apply { - if (validated) { - return@apply - } - - country() - type() - value() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TaxId]. */ - class Builder internal constructor() { - - private var country: JsonField? = null - private var type: JsonField? = null - private var value: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(taxId: TaxId) = apply { - country = taxId.country - type = taxId.type - value = taxId.value - additionalProperties = taxId.additionalProperties.toMutableMap() - } - - fun country(country: Country) = country(JsonField.of(country)) - - fun country(country: JsonField) = apply { this.country = country } - - fun type(type: Type) = type(JsonField.of(type)) - - fun type(type: JsonField) = apply { this.type = type } - - fun value(value: String) = value(JsonField.of(value)) - - fun value(value: JsonField) = apply { this.value = 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) - } - - fun build(): TaxId = - TaxId( - checkRequired("country", country), - checkRequired("type", type), - checkRequired("value", value), - additionalProperties.toImmutable(), - ) - } - - class Country @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val AD = of("AD") - - @JvmField val AE = of("AE") - - @JvmField val AR = of("AR") - - @JvmField val AT = of("AT") - - @JvmField val AU = of("AU") - - @JvmField val BE = of("BE") - - @JvmField val BG = of("BG") - - @JvmField val BH = of("BH") - - @JvmField val BO = of("BO") - - @JvmField val BR = of("BR") - - @JvmField val CA = of("CA") - - @JvmField val CH = of("CH") - - @JvmField val CL = of("CL") - - @JvmField val CN = of("CN") - - @JvmField val CO = of("CO") - - @JvmField val CR = of("CR") - - @JvmField val CY = of("CY") - - @JvmField val CZ = of("CZ") - - @JvmField val DE = of("DE") - - @JvmField val DK = of("DK") - - @JvmField val EE = of("EE") - - @JvmField val DO = of("DO") - - @JvmField val EC = of("EC") - - @JvmField val EG = of("EG") - - @JvmField val ES = of("ES") - - @JvmField val EU = of("EU") - - @JvmField val FI = of("FI") - - @JvmField val FR = of("FR") - - @JvmField val GB = of("GB") - - @JvmField val GE = of("GE") - - @JvmField val GR = of("GR") - - @JvmField val HK = of("HK") - - @JvmField val HR = of("HR") - - @JvmField val HU = of("HU") - - @JvmField val ID = of("ID") - - @JvmField val IE = of("IE") - - @JvmField val IL = of("IL") - - @JvmField val IN = of("IN") - - @JvmField val IS = of("IS") - - @JvmField val IT = of("IT") - - @JvmField val JP = of("JP") - - @JvmField val KE = of("KE") - - @JvmField val KR = of("KR") - - @JvmField val KZ = of("KZ") - - @JvmField val LI = of("LI") - - @JvmField val LT = of("LT") - - @JvmField val LU = of("LU") - - @JvmField val LV = of("LV") - - @JvmField val MT = of("MT") - - @JvmField val MX = of("MX") - - @JvmField val MY = of("MY") - - @JvmField val NG = of("NG") - - @JvmField val NL = of("NL") - - @JvmField val NO = of("NO") - - @JvmField val NZ = of("NZ") - - @JvmField val OM = of("OM") - - @JvmField val PE = of("PE") - - @JvmField val PH = of("PH") - - @JvmField val PL = of("PL") - - @JvmField val PT = of("PT") - - @JvmField val RO = of("RO") - - @JvmField val RS = of("RS") - - @JvmField val RU = of("RU") - - @JvmField val SA = of("SA") - - @JvmField val SE = of("SE") - - @JvmField val SG = of("SG") - - @JvmField val SI = of("SI") - - @JvmField val SK = of("SK") - - @JvmField val SV = of("SV") - - @JvmField val TH = of("TH") - - @JvmField val TR = of("TR") - - @JvmField val TW = of("TW") - - @JvmField val UA = of("UA") - - @JvmField val US = of("US") - - @JvmField val UY = of("UY") - - @JvmField val VE = of("VE") - - @JvmField val VN = of("VN") - - @JvmField val ZA = of("ZA") - - @JvmStatic fun of(value: String) = Country(JsonField.of(value)) - } - - /** An enum containing [Country]'s known values. */ - enum class Known { - AD, - AE, - AR, - AT, - AU, - BE, - BG, - BH, - BO, - BR, - CA, - CH, - CL, - CN, - CO, - CR, - CY, - CZ, - DE, - DK, - EE, - DO, - EC, - EG, - ES, - EU, - FI, - FR, - GB, - GE, - GR, - HK, - HR, - HU, - ID, - IE, - IL, - IN, - IS, - IT, - JP, - KE, - KR, - KZ, - LI, - LT, - LU, - LV, - MT, - MX, - MY, - NG, - NL, - NO, - NZ, - OM, - PE, - PH, - PL, - PT, - RO, - RS, - RU, - SA, - SE, - SG, - SI, - SK, - SV, - TH, - TR, - TW, - UA, - US, - UY, - VE, - VN, - ZA, - } - - /** - * An enum containing [Country]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Country] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AD, - AE, - AR, - AT, - AU, - BE, - BG, - BH, - BO, - BR, - CA, - CH, - CL, - CN, - CO, - CR, - CY, - CZ, - DE, - DK, - EE, - DO, - EC, - EG, - ES, - EU, - FI, - FR, - GB, - GE, - GR, - HK, - HR, - HU, - ID, - IE, - IL, - IN, - IS, - IT, - JP, - KE, - KR, - KZ, - LI, - LT, - LU, - LV, - MT, - MX, - MY, - NG, - NL, - NO, - NZ, - OM, - PE, - PH, - PL, - PT, - RO, - RS, - RU, - SA, - SE, - SG, - SI, - SK, - SV, - TH, - TR, - TW, - UA, - US, - UY, - VE, - VN, - ZA, - /** - * An enum member indicating that [Country] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AD -> Value.AD - AE -> Value.AE - AR -> Value.AR - AT -> Value.AT - AU -> Value.AU - BE -> Value.BE - BG -> Value.BG - BH -> Value.BH - BO -> Value.BO - BR -> Value.BR - CA -> Value.CA - CH -> Value.CH - CL -> Value.CL - CN -> Value.CN - CO -> Value.CO - CR -> Value.CR - CY -> Value.CY - CZ -> Value.CZ - DE -> Value.DE - DK -> Value.DK - EE -> Value.EE - DO -> Value.DO - EC -> Value.EC - EG -> Value.EG - ES -> Value.ES - EU -> Value.EU - FI -> Value.FI - FR -> Value.FR - GB -> Value.GB - GE -> Value.GE - GR -> Value.GR - HK -> Value.HK - HR -> Value.HR - HU -> Value.HU - ID -> Value.ID - IE -> Value.IE - IL -> Value.IL - IN -> Value.IN - IS -> Value.IS - IT -> Value.IT - JP -> Value.JP - KE -> Value.KE - KR -> Value.KR - KZ -> Value.KZ - LI -> Value.LI - LT -> Value.LT - LU -> Value.LU - LV -> Value.LV - MT -> Value.MT - MX -> Value.MX - MY -> Value.MY - NG -> Value.NG - NL -> Value.NL - NO -> Value.NO - NZ -> Value.NZ - OM -> Value.OM - PE -> Value.PE - PH -> Value.PH - PL -> Value.PL - PT -> Value.PT - RO -> Value.RO - RS -> Value.RS - RU -> Value.RU - SA -> Value.SA - SE -> Value.SE - SG -> Value.SG - SI -> Value.SI - SK -> Value.SK - SV -> Value.SV - TH -> Value.TH - TR -> Value.TR - TW -> Value.TW - UA -> Value.UA - US -> Value.US - UY -> Value.UY - VE -> Value.VE - VN -> Value.VN - ZA -> Value.ZA - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AD -> Known.AD - AE -> Known.AE - AR -> Known.AR - AT -> Known.AT - AU -> Known.AU - BE -> Known.BE - BG -> Known.BG - BH -> Known.BH - BO -> Known.BO - BR -> Known.BR - CA -> Known.CA - CH -> Known.CH - CL -> Known.CL - CN -> Known.CN - CO -> Known.CO - CR -> Known.CR - CY -> Known.CY - CZ -> Known.CZ - DE -> Known.DE - DK -> Known.DK - EE -> Known.EE - DO -> Known.DO - EC -> Known.EC - EG -> Known.EG - ES -> Known.ES - EU -> Known.EU - FI -> Known.FI - FR -> Known.FR - GB -> Known.GB - GE -> Known.GE - GR -> Known.GR - HK -> Known.HK - HR -> Known.HR - HU -> Known.HU - ID -> Known.ID - IE -> Known.IE - IL -> Known.IL - IN -> Known.IN - IS -> Known.IS - IT -> Known.IT - JP -> Known.JP - KE -> Known.KE - KR -> Known.KR - KZ -> Known.KZ - LI -> Known.LI - LT -> Known.LT - LU -> Known.LU - LV -> Known.LV - MT -> Known.MT - MX -> Known.MX - MY -> Known.MY - NG -> Known.NG - NL -> Known.NL - NO -> Known.NO - NZ -> Known.NZ - OM -> Known.OM - PE -> Known.PE - PH -> Known.PH - PL -> Known.PL - PT -> Known.PT - RO -> Known.RO - RS -> Known.RS - RU -> Known.RU - SA -> Known.SA - SE -> Known.SE - SG -> Known.SG - SI -> Known.SI - SK -> Known.SK - SV -> Known.SV - TH -> Known.TH - TR -> Known.TR - TW -> Known.TW - UA -> Known.UA - US -> Known.US - UY -> Known.UY - VE -> Known.VE - VN -> Known.VN - ZA -> Known.ZA - else -> throw OrbInvalidDataException("Unknown Country: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is Country && value == other.value /* spotless:on */ - } - - 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 AD_NRT = of("ad_nrt") - - @JvmField val AE_TRN = of("ae_trn") - - @JvmField val AR_CUIT = of("ar_cuit") - - @JvmField val EU_VAT = of("eu_vat") - - @JvmField val AU_ABN = of("au_abn") - - @JvmField val AU_ARN = of("au_arn") - - @JvmField val BG_UIC = of("bg_uic") - - @JvmField val BH_VAT = of("bh_vat") - - @JvmField val BO_TIN = of("bo_tin") - - @JvmField val BR_CNPJ = of("br_cnpj") - - @JvmField val BR_CPF = of("br_cpf") - - @JvmField val CA_BN = of("ca_bn") - - @JvmField val CA_GST_HST = of("ca_gst_hst") - - @JvmField val CA_PST_BC = of("ca_pst_bc") - - @JvmField val CA_PST_MB = of("ca_pst_mb") - - @JvmField val CA_PST_SK = of("ca_pst_sk") - - @JvmField val CA_QST = of("ca_qst") - - @JvmField val CH_VAT = of("ch_vat") - - @JvmField val CL_TIN = of("cl_tin") - - @JvmField val CN_TIN = of("cn_tin") - - @JvmField val CO_NIT = of("co_nit") - - @JvmField val CR_TIN = of("cr_tin") - - @JvmField val DO_RCN = of("do_rcn") - - @JvmField val EC_RUC = of("ec_ruc") - - @JvmField val EG_TIN = of("eg_tin") - - @JvmField val ES_CIF = of("es_cif") - - @JvmField val EU_OSS_VAT = of("eu_oss_vat") - - @JvmField val GB_VAT = of("gb_vat") - - @JvmField val GE_VAT = of("ge_vat") - - @JvmField val HK_BR = of("hk_br") - - @JvmField val HU_TIN = of("hu_tin") - - @JvmField val ID_NPWP = of("id_npwp") - - @JvmField val IL_VAT = of("il_vat") - - @JvmField val IN_GST = of("in_gst") - - @JvmField val IS_VAT = of("is_vat") - - @JvmField val JP_CN = of("jp_cn") - - @JvmField val JP_RN = of("jp_rn") - - @JvmField val JP_TRN = of("jp_trn") - - @JvmField val KE_PIN = of("ke_pin") - - @JvmField val KR_BRN = of("kr_brn") - - @JvmField val KZ_BIN = of("kz_bin") - - @JvmField val LI_UID = of("li_uid") - - @JvmField val MX_RFC = of("mx_rfc") - - @JvmField val MY_FRP = of("my_frp") - - @JvmField val MY_ITN = of("my_itn") - - @JvmField val MY_SST = of("my_sst") - - @JvmField val NG_TIN = of("ng_tin") - - @JvmField val NO_VAT = of("no_vat") - - @JvmField val NO_VOEC = of("no_voec") - - @JvmField val NZ_GST = of("nz_gst") - - @JvmField val OM_VAT = of("om_vat") - - @JvmField val PE_RUC = of("pe_ruc") - - @JvmField val PH_TIN = of("ph_tin") - - @JvmField val RO_TIN = of("ro_tin") - - @JvmField val RS_PIB = of("rs_pib") - - @JvmField val RU_INN = of("ru_inn") - - @JvmField val RU_KPP = of("ru_kpp") - - @JvmField val SA_VAT = of("sa_vat") - - @JvmField val SG_GST = of("sg_gst") - - @JvmField val SG_UEN = of("sg_uen") - - @JvmField val SI_TIN = of("si_tin") - - @JvmField val SV_NIT = of("sv_nit") - - @JvmField val TH_VAT = of("th_vat") - - @JvmField val TR_TIN = of("tr_tin") - - @JvmField val TW_VAT = of("tw_vat") - - @JvmField val UA_VAT = of("ua_vat") - - @JvmField val US_EIN = of("us_ein") - - @JvmField val UY_RUC = of("uy_ruc") - - @JvmField val VE_RIF = of("ve_rif") - - @JvmField val VN_TIN = of("vn_tin") - - @JvmField val ZA_VAT = of("za_vat") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - AD_NRT, - AE_TRN, - AR_CUIT, - EU_VAT, - AU_ABN, - AU_ARN, - BG_UIC, - BH_VAT, - BO_TIN, - BR_CNPJ, - BR_CPF, - CA_BN, - CA_GST_HST, - CA_PST_BC, - CA_PST_MB, - CA_PST_SK, - CA_QST, - CH_VAT, - CL_TIN, - CN_TIN, - CO_NIT, - CR_TIN, - DO_RCN, - EC_RUC, - EG_TIN, - ES_CIF, - EU_OSS_VAT, - GB_VAT, - GE_VAT, - HK_BR, - HU_TIN, - ID_NPWP, - IL_VAT, - IN_GST, - IS_VAT, - JP_CN, - JP_RN, - JP_TRN, - KE_PIN, - KR_BRN, - KZ_BIN, - LI_UID, - MX_RFC, - MY_FRP, - MY_ITN, - MY_SST, - NG_TIN, - NO_VAT, - NO_VOEC, - NZ_GST, - OM_VAT, - PE_RUC, - PH_TIN, - RO_TIN, - RS_PIB, - RU_INN, - RU_KPP, - SA_VAT, - SG_GST, - SG_UEN, - SI_TIN, - SV_NIT, - TH_VAT, - TR_TIN, - TW_VAT, - UA_VAT, - US_EIN, - UY_RUC, - VE_RIF, - VN_TIN, - ZA_VAT, - } - - /** - * 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 { - AD_NRT, - AE_TRN, - AR_CUIT, - EU_VAT, - AU_ABN, - AU_ARN, - BG_UIC, - BH_VAT, - BO_TIN, - BR_CNPJ, - BR_CPF, - CA_BN, - CA_GST_HST, - CA_PST_BC, - CA_PST_MB, - CA_PST_SK, - CA_QST, - CH_VAT, - CL_TIN, - CN_TIN, - CO_NIT, - CR_TIN, - DO_RCN, - EC_RUC, - EG_TIN, - ES_CIF, - EU_OSS_VAT, - GB_VAT, - GE_VAT, - HK_BR, - HU_TIN, - ID_NPWP, - IL_VAT, - IN_GST, - IS_VAT, - JP_CN, - JP_RN, - JP_TRN, - KE_PIN, - KR_BRN, - KZ_BIN, - LI_UID, - MX_RFC, - MY_FRP, - MY_ITN, - MY_SST, - NG_TIN, - NO_VAT, - NO_VOEC, - NZ_GST, - OM_VAT, - PE_RUC, - PH_TIN, - RO_TIN, - RS_PIB, - RU_INN, - RU_KPP, - SA_VAT, - SG_GST, - SG_UEN, - SI_TIN, - SV_NIT, - TH_VAT, - TR_TIN, - TW_VAT, - UA_VAT, - US_EIN, - UY_RUC, - VE_RIF, - VN_TIN, - ZA_VAT, - /** 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) { - AD_NRT -> Value.AD_NRT - AE_TRN -> Value.AE_TRN - AR_CUIT -> Value.AR_CUIT - EU_VAT -> Value.EU_VAT - AU_ABN -> Value.AU_ABN - AU_ARN -> Value.AU_ARN - BG_UIC -> Value.BG_UIC - BH_VAT -> Value.BH_VAT - BO_TIN -> Value.BO_TIN - BR_CNPJ -> Value.BR_CNPJ - BR_CPF -> Value.BR_CPF - CA_BN -> Value.CA_BN - CA_GST_HST -> Value.CA_GST_HST - CA_PST_BC -> Value.CA_PST_BC - CA_PST_MB -> Value.CA_PST_MB - CA_PST_SK -> Value.CA_PST_SK - CA_QST -> Value.CA_QST - CH_VAT -> Value.CH_VAT - CL_TIN -> Value.CL_TIN - CN_TIN -> Value.CN_TIN - CO_NIT -> Value.CO_NIT - CR_TIN -> Value.CR_TIN - DO_RCN -> Value.DO_RCN - EC_RUC -> Value.EC_RUC - EG_TIN -> Value.EG_TIN - ES_CIF -> Value.ES_CIF - EU_OSS_VAT -> Value.EU_OSS_VAT - GB_VAT -> Value.GB_VAT - GE_VAT -> Value.GE_VAT - HK_BR -> Value.HK_BR - HU_TIN -> Value.HU_TIN - ID_NPWP -> Value.ID_NPWP - IL_VAT -> Value.IL_VAT - IN_GST -> Value.IN_GST - IS_VAT -> Value.IS_VAT - JP_CN -> Value.JP_CN - JP_RN -> Value.JP_RN - JP_TRN -> Value.JP_TRN - KE_PIN -> Value.KE_PIN - KR_BRN -> Value.KR_BRN - KZ_BIN -> Value.KZ_BIN - LI_UID -> Value.LI_UID - MX_RFC -> Value.MX_RFC - MY_FRP -> Value.MY_FRP - MY_ITN -> Value.MY_ITN - MY_SST -> Value.MY_SST - NG_TIN -> Value.NG_TIN - NO_VAT -> Value.NO_VAT - NO_VOEC -> Value.NO_VOEC - NZ_GST -> Value.NZ_GST - OM_VAT -> Value.OM_VAT - PE_RUC -> Value.PE_RUC - PH_TIN -> Value.PH_TIN - RO_TIN -> Value.RO_TIN - RS_PIB -> Value.RS_PIB - RU_INN -> Value.RU_INN - RU_KPP -> Value.RU_KPP - SA_VAT -> Value.SA_VAT - SG_GST -> Value.SG_GST - SG_UEN -> Value.SG_UEN - SI_TIN -> Value.SI_TIN - SV_NIT -> Value.SV_NIT - TH_VAT -> Value.TH_VAT - TR_TIN -> Value.TR_TIN - TW_VAT -> Value.TW_VAT - UA_VAT -> Value.UA_VAT - US_EIN -> Value.US_EIN - UY_RUC -> Value.UY_RUC - VE_RIF -> Value.VE_RIF - VN_TIN -> Value.VN_TIN - ZA_VAT -> Value.ZA_VAT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AD_NRT -> Known.AD_NRT - AE_TRN -> Known.AE_TRN - AR_CUIT -> Known.AR_CUIT - EU_VAT -> Known.EU_VAT - AU_ABN -> Known.AU_ABN - AU_ARN -> Known.AU_ARN - BG_UIC -> Known.BG_UIC - BH_VAT -> Known.BH_VAT - BO_TIN -> Known.BO_TIN - BR_CNPJ -> Known.BR_CNPJ - BR_CPF -> Known.BR_CPF - CA_BN -> Known.CA_BN - CA_GST_HST -> Known.CA_GST_HST - CA_PST_BC -> Known.CA_PST_BC - CA_PST_MB -> Known.CA_PST_MB - CA_PST_SK -> Known.CA_PST_SK - CA_QST -> Known.CA_QST - CH_VAT -> Known.CH_VAT - CL_TIN -> Known.CL_TIN - CN_TIN -> Known.CN_TIN - CO_NIT -> Known.CO_NIT - CR_TIN -> Known.CR_TIN - DO_RCN -> Known.DO_RCN - EC_RUC -> Known.EC_RUC - EG_TIN -> Known.EG_TIN - ES_CIF -> Known.ES_CIF - EU_OSS_VAT -> Known.EU_OSS_VAT - GB_VAT -> Known.GB_VAT - GE_VAT -> Known.GE_VAT - HK_BR -> Known.HK_BR - HU_TIN -> Known.HU_TIN - ID_NPWP -> Known.ID_NPWP - IL_VAT -> Known.IL_VAT - IN_GST -> Known.IN_GST - IS_VAT -> Known.IS_VAT - JP_CN -> Known.JP_CN - JP_RN -> Known.JP_RN - JP_TRN -> Known.JP_TRN - KE_PIN -> Known.KE_PIN - KR_BRN -> Known.KR_BRN - KZ_BIN -> Known.KZ_BIN - LI_UID -> Known.LI_UID - MX_RFC -> Known.MX_RFC - MY_FRP -> Known.MY_FRP - MY_ITN -> Known.MY_ITN - MY_SST -> Known.MY_SST - NG_TIN -> Known.NG_TIN - NO_VAT -> Known.NO_VAT - NO_VOEC -> Known.NO_VOEC - NZ_GST -> Known.NZ_GST - OM_VAT -> Known.OM_VAT - PE_RUC -> Known.PE_RUC - PH_TIN -> Known.PH_TIN - RO_TIN -> Known.RO_TIN - RS_PIB -> Known.RS_PIB - RU_INN -> Known.RU_INN - RU_KPP -> Known.RU_KPP - SA_VAT -> Known.SA_VAT - SG_GST -> Known.SG_GST - SG_UEN -> Known.SG_UEN - SI_TIN -> Known.SI_TIN - SV_NIT -> Known.SV_NIT - TH_VAT -> Known.TH_VAT - TR_TIN -> Known.TR_TIN - TW_VAT -> Known.TW_VAT - UA_VAT -> Known.UA_VAT - US_EIN -> Known.US_EIN - UY_RUC -> Known.UY_RUC - VE_RIF -> Known.VE_RIF - VN_TIN -> Known.VN_TIN - ZA_VAT -> Known.ZA_VAT - 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TaxId && country == other.country && type == other.type && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PaymentProvider && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(country, type, value, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "TaxId{country=$country, type=$type, value=$value, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditBalancesModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditBalancesModel.kt new file mode 100644 index 000000000..f229b6448 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditBalancesModel.kt @@ -0,0 +1,496 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class CustomerCreditBalancesModel +@JsonCreator +private constructor( + @JsonProperty("data") + @ExcludeMissing + private val data: JsonField> = JsonMissing.of(), + @JsonProperty("pagination_metadata") + @ExcludeMissing + private val paginationMetadata: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun data(): List = data.getRequired("data") + + fun paginationMetadata(): PaginationMetadata = + paginationMetadata.getRequired("pagination_metadata") + + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data + + @JsonProperty("pagination_metadata") + @ExcludeMissing + fun _paginationMetadata(): JsonField = paginationMetadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): CustomerCreditBalancesModel = apply { + if (validated) { + return@apply + } + + data().forEach { it.validate() } + paginationMetadata().validate() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CustomerCreditBalancesModel]. + * + * The following fields are required: + * ```java + * .data() + * .paginationMetadata() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomerCreditBalancesModel]. */ + class Builder internal constructor() { + + private var data: JsonField>? = null + private var paginationMetadata: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(customerCreditBalancesModel: CustomerCreditBalancesModel) = apply { + data = customerCreditBalancesModel.data.map { it.toMutableList() } + paginationMetadata = customerCreditBalancesModel.paginationMetadata + additionalProperties = customerCreditBalancesModel.additionalProperties.toMutableMap() + } + + fun data(data: List) = data(JsonField.of(data)) + + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + 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)) + + 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) + } + + fun build(): CustomerCreditBalancesModel = + CustomerCreditBalancesModel( + checkRequired("data", data).map { it.toImmutable() }, + checkRequired("paginationMetadata", paginationMetadata), + additionalProperties.toImmutable(), + ) + } + + @NoAutoDetect + class Data + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("balance") + @ExcludeMissing + private val balance: JsonField = JsonMissing.of(), + @JsonProperty("effective_date") + @ExcludeMissing + private val effectiveDate: JsonField = JsonMissing.of(), + @JsonProperty("expiry_date") + @ExcludeMissing + private val expiryDate: JsonField = JsonMissing.of(), + @JsonProperty("maximum_initial_balance") + @ExcludeMissing + private val maximumInitialBalance: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_cost_basis") + @ExcludeMissing + private val perUnitCostBasis: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + private val status: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + fun balance(): Double = balance.getRequired("balance") + + fun effectiveDate(): Optional = + Optional.ofNullable(effectiveDate.getNullable("effective_date")) + + fun expiryDate(): Optional = + Optional.ofNullable(expiryDate.getNullable("expiry_date")) + + fun maximumInitialBalance(): Optional = + Optional.ofNullable(maximumInitialBalance.getNullable("maximum_initial_balance")) + + fun perUnitCostBasis(): Optional = + Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) + + fun status(): Status = status.getRequired("status") + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("balance") @ExcludeMissing fun _balance(): JsonField = balance + + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate + + @JsonProperty("expiry_date") + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate + + @JsonProperty("maximum_initial_balance") + @ExcludeMissing + fun _maximumInitialBalance(): JsonField = maximumInitialBalance + + @JsonProperty("per_unit_cost_basis") + @ExcludeMissing + fun _perUnitCostBasis(): JsonField = perUnitCostBasis + + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + id() + balance() + effectiveDate() + expiryDate() + maximumInitialBalance() + perUnitCostBasis() + status() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .id() + * .balance() + * .effectiveDate() + * .expiryDate() + * .maximumInitialBalance() + * .perUnitCostBasis() + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + 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 maximumInitialBalance: JsonField? = null + private var perUnitCostBasis: JsonField? = null + private var status: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + id = data.id + balance = data.balance + effectiveDate = data.effectiveDate + expiryDate = data.expiryDate + maximumInitialBalance = data.maximumInitialBalance + perUnitCostBasis = data.perUnitCostBasis + status = data.status + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun balance(balance: Double) = balance(JsonField.of(balance)) + + fun balance(balance: JsonField) = apply { this.balance = balance } + + fun effectiveDate(effectiveDate: OffsetDateTime?) = + effectiveDate(JsonField.ofNullable(effectiveDate)) + + fun effectiveDate(effectiveDate: Optional) = + effectiveDate(effectiveDate.orElse(null)) + + fun effectiveDate(effectiveDate: JsonField) = apply { + this.effectiveDate = effectiveDate + } + + fun expiryDate(expiryDate: OffsetDateTime?) = + expiryDate(JsonField.ofNullable(expiryDate)) + + fun expiryDate(expiryDate: Optional) = + expiryDate(expiryDate.orElse(null)) + + fun expiryDate(expiryDate: JsonField) = apply { + this.expiryDate = expiryDate + } + + fun maximumInitialBalance(maximumInitialBalance: Double?) = + maximumInitialBalance(JsonField.ofNullable(maximumInitialBalance)) + + fun maximumInitialBalance(maximumInitialBalance: Double) = + maximumInitialBalance(maximumInitialBalance as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun maximumInitialBalance(maximumInitialBalance: Optional) = + maximumInitialBalance(maximumInitialBalance.orElse(null) as Double?) + + fun maximumInitialBalance(maximumInitialBalance: JsonField) = apply { + this.maximumInitialBalance = maximumInitialBalance + } + + fun perUnitCostBasis(perUnitCostBasis: String?) = + perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) + + fun perUnitCostBasis(perUnitCostBasis: Optional) = + perUnitCostBasis(perUnitCostBasis.orElse(null)) + + fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { + this.perUnitCostBasis = perUnitCostBasis + } + + fun status(status: Status) = status(JsonField.of(status)) + + 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) + } + + fun build(): Data = + Data( + checkRequired("id", id), + checkRequired("balance", balance), + checkRequired("effectiveDate", effectiveDate), + checkRequired("expiryDate", expiryDate), + checkRequired("maximumInitialBalance", maximumInitialBalance), + checkRequired("perUnitCostBasis", perUnitCostBasis), + checkRequired("status", status), + additionalProperties.toImmutable(), + ) + } + + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Data && id == other.id && balance == other.balance && effectiveDate == other.effectiveDate && expiryDate == other.expiryDate && maximumInitialBalance == other.maximumInitialBalance && perUnitCostBasis == other.perUnitCostBasis && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, balance, effectiveDate, expiryDate, maximumInitialBalance, perUnitCostBasis, status, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{id=$id, balance=$balance, effectiveDate=$effectiveDate, expiryDate=$expiryDate, maximumInitialBalance=$maximumInitialBalance, perUnitCostBasis=$perUnitCostBasis, status=$status, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CustomerCreditBalancesModel && data == other.data && paginationMetadata == other.paginationMetadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(data, paginationMetadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomerCreditBalancesModel{data=$data, paginationMetadata=$paginationMetadata, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt index 372680a61..de23e5e16 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 @@ -2,38 +2,12 @@ package com.withorb.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer -import com.withorb.api.core.Enum -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.Params import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams -import com.withorb.api.core.immutableEmptyMap -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.time.LocalDate -import java.time.OffsetDateTime import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull /** * This endpoint allows you to create a new ledger entry for a specified customer's balance. This @@ -140,20 +114,20 @@ import kotlin.jvm.optionals.getOrNull class CustomerCreditLedgerCreateEntryByExternalIdParams private constructor( private val externalCustomerId: String, - private val body: Body, + private val addCreditLedgerEntryRequest: AddCreditLedgerEntryRequest, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { fun externalCustomerId(): String = externalCustomerId - fun body(): Body = body + fun addCreditLedgerEntryRequest(): AddCreditLedgerEntryRequest = addCreditLedgerEntryRequest fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): AddCreditLedgerEntryRequest = addCreditLedgerEntryRequest override fun _headers(): Headers = additionalHeaders @@ -166,3351 +140,20 @@ private constructor( } } - @JsonDeserialize(using = Body.Deserializer::class) - @JsonSerialize(using = Body.Serializer::class) - class Body - private constructor( - private val addIncrementCreditLedgerEntryRequestParams: - AddIncrementCreditLedgerEntryRequestParams? = - null, - private val addDecrementCreditLedgerEntryRequestParams: - AddDecrementCreditLedgerEntryRequestParams? = - null, - private val addExpirationChangeCreditLedgerEntryRequestParams: - AddExpirationChangeCreditLedgerEntryRequestParams? = - null, - private val addVoidCreditLedgerEntryRequestParams: AddVoidCreditLedgerEntryRequestParams? = - null, - private val addAmendmentCreditLedgerEntryRequestParams: - AddAmendmentCreditLedgerEntryRequestParams? = - null, - private val _json: JsonValue? = null, - ) { - - fun addIncrementCreditLedgerEntryRequestParams(): - Optional = - Optional.ofNullable(addIncrementCreditLedgerEntryRequestParams) - - fun addDecrementCreditLedgerEntryRequestParams(): - Optional = - Optional.ofNullable(addDecrementCreditLedgerEntryRequestParams) - - fun addExpirationChangeCreditLedgerEntryRequestParams(): - Optional = - Optional.ofNullable(addExpirationChangeCreditLedgerEntryRequestParams) - - fun addVoidCreditLedgerEntryRequestParams(): - Optional = - Optional.ofNullable(addVoidCreditLedgerEntryRequestParams) - - fun addAmendmentCreditLedgerEntryRequestParams(): - Optional = - Optional.ofNullable(addAmendmentCreditLedgerEntryRequestParams) - - fun isAddIncrementCreditLedgerEntryRequestParams(): Boolean = - addIncrementCreditLedgerEntryRequestParams != null - - fun isAddDecrementCreditLedgerEntryRequestParams(): Boolean = - addDecrementCreditLedgerEntryRequestParams != null - - fun isAddExpirationChangeCreditLedgerEntryRequestParams(): Boolean = - addExpirationChangeCreditLedgerEntryRequestParams != null - - fun isAddVoidCreditLedgerEntryRequestParams(): Boolean = - addVoidCreditLedgerEntryRequestParams != null - - fun isAddAmendmentCreditLedgerEntryRequestParams(): Boolean = - addAmendmentCreditLedgerEntryRequestParams != null - - fun asAddIncrementCreditLedgerEntryRequestParams(): - AddIncrementCreditLedgerEntryRequestParams = - addIncrementCreditLedgerEntryRequestParams.getOrThrow( - "addIncrementCreditLedgerEntryRequestParams" - ) - - fun asAddDecrementCreditLedgerEntryRequestParams(): - AddDecrementCreditLedgerEntryRequestParams = - addDecrementCreditLedgerEntryRequestParams.getOrThrow( - "addDecrementCreditLedgerEntryRequestParams" - ) - - fun asAddExpirationChangeCreditLedgerEntryRequestParams(): - AddExpirationChangeCreditLedgerEntryRequestParams = - addExpirationChangeCreditLedgerEntryRequestParams.getOrThrow( - "addExpirationChangeCreditLedgerEntryRequestParams" - ) - - fun asAddVoidCreditLedgerEntryRequestParams(): AddVoidCreditLedgerEntryRequestParams = - addVoidCreditLedgerEntryRequestParams.getOrThrow( - "addVoidCreditLedgerEntryRequestParams" - ) - - fun asAddAmendmentCreditLedgerEntryRequestParams(): - AddAmendmentCreditLedgerEntryRequestParams = - addAmendmentCreditLedgerEntryRequestParams.getOrThrow( - "addAmendmentCreditLedgerEntryRequestParams" - ) - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - addIncrementCreditLedgerEntryRequestParams != null -> - visitor.visitAddIncrementCreditLedgerEntryRequestParams( - addIncrementCreditLedgerEntryRequestParams - ) - addDecrementCreditLedgerEntryRequestParams != null -> - visitor.visitAddDecrementCreditLedgerEntryRequestParams( - addDecrementCreditLedgerEntryRequestParams - ) - addExpirationChangeCreditLedgerEntryRequestParams != null -> - visitor.visitAddExpirationChangeCreditLedgerEntryRequestParams( - addExpirationChangeCreditLedgerEntryRequestParams - ) - addVoidCreditLedgerEntryRequestParams != null -> - visitor.visitAddVoidCreditLedgerEntryRequestParams( - addVoidCreditLedgerEntryRequestParams - ) - addAmendmentCreditLedgerEntryRequestParams != null -> - visitor.visitAddAmendmentCreditLedgerEntryRequestParams( - addAmendmentCreditLedgerEntryRequestParams - ) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitAddIncrementCreditLedgerEntryRequestParams( - addIncrementCreditLedgerEntryRequestParams: - AddIncrementCreditLedgerEntryRequestParams - ) { - addIncrementCreditLedgerEntryRequestParams.validate() - } - - override fun visitAddDecrementCreditLedgerEntryRequestParams( - addDecrementCreditLedgerEntryRequestParams: - AddDecrementCreditLedgerEntryRequestParams - ) { - addDecrementCreditLedgerEntryRequestParams.validate() - } - - override fun visitAddExpirationChangeCreditLedgerEntryRequestParams( - addExpirationChangeCreditLedgerEntryRequestParams: - AddExpirationChangeCreditLedgerEntryRequestParams - ) { - addExpirationChangeCreditLedgerEntryRequestParams.validate() - } - - override fun visitAddVoidCreditLedgerEntryRequestParams( - addVoidCreditLedgerEntryRequestParams: AddVoidCreditLedgerEntryRequestParams - ) { - addVoidCreditLedgerEntryRequestParams.validate() - } - - override fun visitAddAmendmentCreditLedgerEntryRequestParams( - addAmendmentCreditLedgerEntryRequestParams: - AddAmendmentCreditLedgerEntryRequestParams - ) { - addAmendmentCreditLedgerEntryRequestParams.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Body && addIncrementCreditLedgerEntryRequestParams == other.addIncrementCreditLedgerEntryRequestParams && addDecrementCreditLedgerEntryRequestParams == other.addDecrementCreditLedgerEntryRequestParams && addExpirationChangeCreditLedgerEntryRequestParams == other.addExpirationChangeCreditLedgerEntryRequestParams && addVoidCreditLedgerEntryRequestParams == other.addVoidCreditLedgerEntryRequestParams && addAmendmentCreditLedgerEntryRequestParams == other.addAmendmentCreditLedgerEntryRequestParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(addIncrementCreditLedgerEntryRequestParams, addDecrementCreditLedgerEntryRequestParams, addExpirationChangeCreditLedgerEntryRequestParams, addVoidCreditLedgerEntryRequestParams, addAmendmentCreditLedgerEntryRequestParams) /* spotless:on */ - - override fun toString(): String = - when { - addIncrementCreditLedgerEntryRequestParams != null -> - "Body{addIncrementCreditLedgerEntryRequestParams=$addIncrementCreditLedgerEntryRequestParams}" - addDecrementCreditLedgerEntryRequestParams != null -> - "Body{addDecrementCreditLedgerEntryRequestParams=$addDecrementCreditLedgerEntryRequestParams}" - addExpirationChangeCreditLedgerEntryRequestParams != null -> - "Body{addExpirationChangeCreditLedgerEntryRequestParams=$addExpirationChangeCreditLedgerEntryRequestParams}" - addVoidCreditLedgerEntryRequestParams != null -> - "Body{addVoidCreditLedgerEntryRequestParams=$addVoidCreditLedgerEntryRequestParams}" - addAmendmentCreditLedgerEntryRequestParams != null -> - "Body{addAmendmentCreditLedgerEntryRequestParams=$addAmendmentCreditLedgerEntryRequestParams}" - _json != null -> "Body{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Body") - } - - companion object { - - @JvmStatic - fun ofAddIncrementCreditLedgerEntryRequestParams( - addIncrementCreditLedgerEntryRequestParams: - AddIncrementCreditLedgerEntryRequestParams - ) = - Body( - addIncrementCreditLedgerEntryRequestParams = - addIncrementCreditLedgerEntryRequestParams - ) - - @JvmStatic - fun ofAddDecrementCreditLedgerEntryRequestParams( - addDecrementCreditLedgerEntryRequestParams: - AddDecrementCreditLedgerEntryRequestParams - ) = - Body( - addDecrementCreditLedgerEntryRequestParams = - addDecrementCreditLedgerEntryRequestParams - ) - - @JvmStatic - fun ofAddExpirationChangeCreditLedgerEntryRequestParams( - addExpirationChangeCreditLedgerEntryRequestParams: - AddExpirationChangeCreditLedgerEntryRequestParams - ) = - Body( - addExpirationChangeCreditLedgerEntryRequestParams = - addExpirationChangeCreditLedgerEntryRequestParams - ) - - @JvmStatic - fun ofAddVoidCreditLedgerEntryRequestParams( - addVoidCreditLedgerEntryRequestParams: AddVoidCreditLedgerEntryRequestParams - ) = Body(addVoidCreditLedgerEntryRequestParams = addVoidCreditLedgerEntryRequestParams) - - @JvmStatic - fun ofAddAmendmentCreditLedgerEntryRequestParams( - addAmendmentCreditLedgerEntryRequestParams: - AddAmendmentCreditLedgerEntryRequestParams - ) = - Body( - addAmendmentCreditLedgerEntryRequestParams = - addAmendmentCreditLedgerEntryRequestParams - ) - } - - /** An interface that defines how to map each variant of [Body] to a value of type [T]. */ - interface Visitor { - - fun visitAddIncrementCreditLedgerEntryRequestParams( - addIncrementCreditLedgerEntryRequestParams: - AddIncrementCreditLedgerEntryRequestParams - ): T - - fun visitAddDecrementCreditLedgerEntryRequestParams( - addDecrementCreditLedgerEntryRequestParams: - AddDecrementCreditLedgerEntryRequestParams - ): T - - fun visitAddExpirationChangeCreditLedgerEntryRequestParams( - addExpirationChangeCreditLedgerEntryRequestParams: - AddExpirationChangeCreditLedgerEntryRequestParams - ): T - - fun visitAddVoidCreditLedgerEntryRequestParams( - addVoidCreditLedgerEntryRequestParams: AddVoidCreditLedgerEntryRequestParams - ): T - - fun visitAddAmendmentCreditLedgerEntryRequestParams( - addAmendmentCreditLedgerEntryRequestParams: - AddAmendmentCreditLedgerEntryRequestParams - ): T - - /** - * Maps an unknown variant of [Body] to a value of type [T]. - * - * An instance of [Body] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Body: $json") - } - } - - internal class Deserializer : BaseDeserializer(Body::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Body { - val json = JsonValue.fromJsonNode(node) - val entryType = - json.asObject().getOrNull()?.get("entry_type")?.asString()?.getOrNull() - - when (entryType) { - "increment" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body( - addIncrementCreditLedgerEntryRequestParams = it, - _json = json, - ) - } - } - "decrement" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body( - addDecrementCreditLedgerEntryRequestParams = it, - _json = json, - ) - } - } - "expiration_change" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body( - addExpirationChangeCreditLedgerEntryRequestParams = it, - _json = json, - ) - } - } - "void" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body( - addVoidCreditLedgerEntryRequestParams = it, - _json = json, - ) - } - } - "amendment" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body( - addAmendmentCreditLedgerEntryRequestParams = it, - _json = json, - ) - } - } - } - - return Body(_json = json) - } - } - - internal class Serializer : BaseSerializer(Body::class) { - - override fun serialize( - value: Body, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.addIncrementCreditLedgerEntryRequestParams != null -> - generator.writeObject(value.addIncrementCreditLedgerEntryRequestParams) - value.addDecrementCreditLedgerEntryRequestParams != null -> - generator.writeObject(value.addDecrementCreditLedgerEntryRequestParams) - value.addExpirationChangeCreditLedgerEntryRequestParams != null -> - generator.writeObject( - value.addExpirationChangeCreditLedgerEntryRequestParams - ) - value.addVoidCreditLedgerEntryRequestParams != null -> - generator.writeObject(value.addVoidCreditLedgerEntryRequestParams) - value.addAmendmentCreditLedgerEntryRequestParams != null -> - generator.writeObject(value.addAmendmentCreditLedgerEntryRequestParams) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Body") - } - } - } - - @NoAutoDetect - class AddIncrementCreditLedgerEntryRequestParams - @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - private val entryType: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("effective_date") - @ExcludeMissing - private val effectiveDate: JsonField = JsonMissing.of(), - @JsonProperty("expiry_date") - @ExcludeMissing - private val expiryDate: JsonField = JsonMissing.of(), - @JsonProperty("invoice_settings") - @ExcludeMissing - private val invoiceSettings: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - private val perUnitCostBasis: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * The number of credits to effect. Note that this is required for increment, decrement, - * void, or undo operations. - */ - fun amount(): Double = amount.getRequired("amount") - - fun entryType(): EntryType = entryType.getRequired("entry_type") - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) - - /** - * Optional metadata that can be specified when adding ledger results via the API. For - * example, this can be used to note an increment refers to trial credits, or for noting - * corrections as a result of an incident, etc. - */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - /** - * An ISO 8601 format date that denotes when this credit balance should become available - * for use. - */ - fun effectiveDate(): Optional = - Optional.ofNullable(effectiveDate.getNullable("effective_date")) - - /** An ISO 8601 format date that denotes when this credit balance should expire. */ - fun expiryDate(): Optional = - Optional.ofNullable(expiryDate.getNullable("expiry_date")) - - /** - * Passing `invoice_settings` automatically generates an invoice for the newly added - * credits. If `invoice_settings` is passed, you must specify per_unit_cost_basis, as - * the calculation of the invoice total is done on that basis. - */ - fun invoiceSettings(): Optional = - Optional.ofNullable(invoiceSettings.getNullable("invoice_settings")) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * Can only be specified when entry_type=increment. How much, in the customer's - * currency, a customer paid for a single credit in this block - */ - fun perUnitCostBasis(): Optional = - Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - - /** - * The number of credits to effect. Note that this is required for increment, decrement, - * void, or undo operations. - */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** - * Optional metadata that can be specified when adding ledger results via the API. For - * example, this can be used to note an increment refers to trial credits, or for noting - * corrections as a result of an incident, etc. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - /** - * An ISO 8601 format date that denotes when this credit balance should become available - * for use. - */ - @JsonProperty("effective_date") - @ExcludeMissing - fun _effectiveDate(): JsonField = effectiveDate - - /** An ISO 8601 format date that denotes when this credit balance should expire. */ - @JsonProperty("expiry_date") - @ExcludeMissing - fun _expiryDate(): JsonField = expiryDate - - /** - * Passing `invoice_settings` automatically generates an invoice for the newly added - * credits. If `invoice_settings` is passed, you must specify per_unit_cost_basis, as - * the calculation of the invoice total is done on that basis. - */ - @JsonProperty("invoice_settings") - @ExcludeMissing - fun _invoiceSettings(): JsonField = invoiceSettings - - /** - * User-specified key/value pairs for the resource. 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("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * Can only be specified when entry_type=increment. How much, in the customer's - * currency, a customer paid for a single credit in this block - */ - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - fun _perUnitCostBasis(): JsonField = perUnitCostBasis - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AddIncrementCreditLedgerEntryRequestParams = apply { - if (validated) { - return@apply - } - - amount() - entryType() - currency() - description() - effectiveDate() - expiryDate() - invoiceSettings().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - perUnitCostBasis() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AddIncrementCreditLedgerEntryRequestParams]. */ - class Builder internal constructor() { - - private var amount: JsonField? = null - private var entryType: JsonField? = null - private var currency: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var effectiveDate: JsonField = JsonMissing.of() - private var expiryDate: JsonField = JsonMissing.of() - private var invoiceSettings: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var perUnitCostBasis: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - addIncrementCreditLedgerEntryRequestParams: - AddIncrementCreditLedgerEntryRequestParams - ) = apply { - amount = addIncrementCreditLedgerEntryRequestParams.amount - entryType = addIncrementCreditLedgerEntryRequestParams.entryType - currency = addIncrementCreditLedgerEntryRequestParams.currency - description = addIncrementCreditLedgerEntryRequestParams.description - effectiveDate = addIncrementCreditLedgerEntryRequestParams.effectiveDate - expiryDate = addIncrementCreditLedgerEntryRequestParams.expiryDate - invoiceSettings = addIncrementCreditLedgerEntryRequestParams.invoiceSettings - metadata = addIncrementCreditLedgerEntryRequestParams.metadata - perUnitCostBasis = addIncrementCreditLedgerEntryRequestParams.perUnitCostBasis - additionalProperties = - addIncrementCreditLedgerEntryRequestParams.additionalProperties - .toMutableMap() - } - - /** - * The number of credits to effect. Note that this is required for increment, - * decrement, void, or undo operations. - */ - fun amount(amount: Double) = amount(JsonField.of(amount)) - - /** - * The number of credits to effect. Note that this is required for increment, - * decrement, void, or undo operations. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - - fun entryType(entryType: JsonField) = apply { - this.entryType = entryType - } - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** - * Optional metadata that can be specified when adding ledger results via the API. - * For example, this can be used to note an increment refers to trial credits, or - * for noting corrections as a result of an incident, etc. - */ - fun description(description: String?) = - description(JsonField.ofNullable(description)) - - /** - * Optional metadata that can be specified when adding ledger results via the API. - * For example, this can be used to note an increment refers to trial credits, or - * for noting corrections as a result of an incident, etc. - */ - fun description(description: Optional) = - description(description.orElse(null)) - - /** - * Optional metadata that can be specified when adding ledger results via the API. - * For example, this can be used to note an increment refers to trial credits, or - * for noting corrections as a result of an incident, etc. - */ - fun description(description: JsonField) = apply { - this.description = description - } - - /** - * An ISO 8601 format date that denotes when this credit balance should become - * available for use. - */ - fun effectiveDate(effectiveDate: OffsetDateTime?) = - effectiveDate(JsonField.ofNullable(effectiveDate)) - - /** - * An ISO 8601 format date that denotes when this credit balance should become - * available for use. - */ - fun effectiveDate(effectiveDate: Optional) = - effectiveDate(effectiveDate.orElse(null)) - - /** - * An ISO 8601 format date that denotes when this credit balance should become - * available for use. - */ - fun effectiveDate(effectiveDate: JsonField) = apply { - this.effectiveDate = effectiveDate - } - - /** An ISO 8601 format date that denotes when this credit balance should expire. */ - fun expiryDate(expiryDate: OffsetDateTime?) = - expiryDate(JsonField.ofNullable(expiryDate)) - - /** An ISO 8601 format date that denotes when this credit balance should expire. */ - fun expiryDate(expiryDate: Optional) = - expiryDate(expiryDate.orElse(null)) - - /** An ISO 8601 format date that denotes when this credit balance should expire. */ - fun expiryDate(expiryDate: JsonField) = apply { - this.expiryDate = expiryDate - } - - /** - * Passing `invoice_settings` automatically generates an invoice for the newly added - * credits. If `invoice_settings` is passed, you must specify per_unit_cost_basis, - * as the calculation of the invoice total is done on that basis. - */ - fun invoiceSettings(invoiceSettings: InvoiceSettings?) = - invoiceSettings(JsonField.ofNullable(invoiceSettings)) - - /** - * Passing `invoice_settings` automatically generates an invoice for the newly added - * credits. If `invoice_settings` is passed, you must specify per_unit_cost_basis, - * as the calculation of the invoice total is done on that basis. - */ - fun invoiceSettings(invoiceSettings: Optional) = - invoiceSettings(invoiceSettings.orElse(null)) - - /** - * Passing `invoice_settings` automatically generates an invoice for the newly added - * credits. If `invoice_settings` is passed, you must specify per_unit_cost_basis, - * as the calculation of the invoice total is done on that basis. - */ - fun invoiceSettings(invoiceSettings: JsonField) = apply { - this.invoiceSettings = invoiceSettings - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: JsonField) = apply { this.metadata = metadata } - - /** - * Can only be specified when entry_type=increment. How much, in the customer's - * currency, a customer paid for a single credit in this block - */ - fun perUnitCostBasis(perUnitCostBasis: String?) = - perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) - - /** - * Can only be specified when entry_type=increment. How much, in the customer's - * currency, a customer paid for a single credit in this block - */ - fun perUnitCostBasis(perUnitCostBasis: Optional) = - perUnitCostBasis(perUnitCostBasis.orElse(null)) - - /** - * Can only be specified when entry_type=increment. How much, in the customer's - * currency, a customer paid for a single credit in this block - */ - fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { - this.perUnitCostBasis = perUnitCostBasis - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): AddIncrementCreditLedgerEntryRequestParams = - AddIncrementCreditLedgerEntryRequestParams( - checkRequired("amount", amount), - checkRequired("entryType", entryType), - currency, - description, - effectiveDate, - expiryDate, - invoiceSettings, - metadata, - perUnitCostBasis, - additionalProperties.toImmutable(), - ) - } - - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val INCREMENT = of("increment") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - INCREMENT - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - INCREMENT, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - INCREMENT -> Value.INCREMENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - INCREMENT -> Known.INCREMENT - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * Passing `invoice_settings` automatically generates an invoice for the newly added - * credits. If `invoice_settings` is passed, you must specify per_unit_cost_basis, as - * the calculation of the invoice total is done on that basis. - */ - @NoAutoDetect - class InvoiceSettings - @JsonCreator - private constructor( - @JsonProperty("auto_collection") - @ExcludeMissing - private val autoCollection: JsonField = JsonMissing.of(), - @JsonProperty("net_terms") - @ExcludeMissing - private val netTerms: JsonField = JsonMissing.of(), - @JsonProperty("memo") - @ExcludeMissing - private val memo: JsonField = JsonMissing.of(), - @JsonProperty("require_successful_payment") - @ExcludeMissing - private val requireSuccessfulPayment: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * Whether the credits purchase invoice should auto collect with the customer's - * saved payment method. - */ - fun autoCollection(): Boolean = autoCollection.getRequired("auto_collection") - - /** - * The net terms determines the difference between the invoice date and the issue - * date for the invoice. If you intend the invoice to be due on issue, set this - * to 0. - */ - fun netTerms(): Long = netTerms.getRequired("net_terms") - - /** An optional memo to display on the invoice. */ - fun memo(): Optional = Optional.ofNullable(memo.getNullable("memo")) - - /** - * If true, the new credit block will require that the corresponding invoice is paid - * before it can be drawn down from. - */ - fun requireSuccessfulPayment(): Optional = - Optional.ofNullable( - requireSuccessfulPayment.getNullable("require_successful_payment") - ) - - /** - * Whether the credits purchase invoice should auto collect with the customer's - * saved payment method. - */ - @JsonProperty("auto_collection") - @ExcludeMissing - fun _autoCollection(): JsonField = autoCollection - - /** - * The net terms determines the difference between the invoice date and the issue - * date for the invoice. If you intend the invoice to be due on issue, set this - * to 0. - */ - @JsonProperty("net_terms") - @ExcludeMissing - fun _netTerms(): JsonField = netTerms - - /** An optional memo to display on the invoice. */ - @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo - - /** - * If true, the new credit block will require that the corresponding invoice is paid - * before it can be drawn down from. - */ - @JsonProperty("require_successful_payment") - @ExcludeMissing - fun _requireSuccessfulPayment(): JsonField = requireSuccessfulPayment - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoiceSettings = apply { - if (validated) { - return@apply - } - - autoCollection() - netTerms() - memo() - requireSuccessfulPayment() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoiceSettings]. */ - class Builder internal constructor() { - - private var autoCollection: JsonField? = null - private var netTerms: JsonField? = null - private var memo: JsonField = JsonMissing.of() - private var requireSuccessfulPayment: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoiceSettings: InvoiceSettings) = apply { - autoCollection = invoiceSettings.autoCollection - netTerms = invoiceSettings.netTerms - memo = invoiceSettings.memo - requireSuccessfulPayment = invoiceSettings.requireSuccessfulPayment - additionalProperties = invoiceSettings.additionalProperties.toMutableMap() - } - - /** - * Whether the credits purchase invoice should auto collect with the customer's - * saved payment method. - */ - fun autoCollection(autoCollection: Boolean) = - autoCollection(JsonField.of(autoCollection)) - - /** - * Whether the credits purchase invoice should auto collect with the customer's - * saved payment method. - */ - fun autoCollection(autoCollection: JsonField) = apply { - this.autoCollection = autoCollection - } - - /** - * The net terms determines the difference between the invoice date and the - * issue date for the invoice. If you intend the invoice to be due on issue, set - * this to 0. - */ - fun netTerms(netTerms: Long) = netTerms(JsonField.of(netTerms)) - - /** - * The net terms determines the difference between the invoice date and the - * issue date for the invoice. If you intend the invoice to be due on issue, set - * this to 0. - */ - fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } - - /** An optional memo to display on the invoice. */ - fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) - - /** An optional memo to display on the invoice. */ - fun memo(memo: Optional) = memo(memo.orElse(null)) - - /** An optional memo to display on the invoice. */ - fun memo(memo: JsonField) = apply { this.memo = memo } - - /** - * If true, the new credit block will require that the corresponding invoice is - * paid before it can be drawn down from. - */ - fun requireSuccessfulPayment(requireSuccessfulPayment: Boolean) = - requireSuccessfulPayment(JsonField.of(requireSuccessfulPayment)) - - /** - * If true, the new credit block will require that the corresponding invoice is - * paid before it can be drawn down from. - */ - fun requireSuccessfulPayment(requireSuccessfulPayment: JsonField) = - apply { - this.requireSuccessfulPayment = requireSuccessfulPayment - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoiceSettings = - InvoiceSettings( - checkRequired("autoCollection", autoCollection), - checkRequired("netTerms", netTerms), - memo, - requireSuccessfulPayment, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoiceSettings && autoCollection == other.autoCollection && netTerms == other.netTerms && memo == other.memo && requireSuccessfulPayment == other.requireSuccessfulPayment && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(autoCollection, netTerms, memo, requireSuccessfulPayment, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoiceSettings{autoCollection=$autoCollection, netTerms=$netTerms, memo=$memo, requireSuccessfulPayment=$requireSuccessfulPayment, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AddIncrementCreditLedgerEntryRequestParams && amount == other.amount && entryType == other.entryType && currency == other.currency && description == other.description && effectiveDate == other.effectiveDate && expiryDate == other.expiryDate && invoiceSettings == other.invoiceSettings && metadata == other.metadata && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, entryType, currency, description, effectiveDate, expiryDate, invoiceSettings, metadata, perUnitCostBasis, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AddIncrementCreditLedgerEntryRequestParams{amount=$amount, entryType=$entryType, currency=$currency, description=$description, effectiveDate=$effectiveDate, expiryDate=$expiryDate, invoiceSettings=$invoiceSettings, metadata=$metadata, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class AddDecrementCreditLedgerEntryRequestParams - @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - private val entryType: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * The number of credits to effect. Note that this is required for increment, decrement, - * void, or undo operations. - */ - fun amount(): Double = amount.getRequired("amount") - - fun entryType(): EntryType = entryType.getRequired("entry_type") - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) - - /** - * Optional metadata that can be specified when adding ledger results via the API. For - * example, this can be used to note an increment refers to trial credits, or for noting - * corrections as a result of an incident, etc. - */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * The number of credits to effect. Note that this is required for increment, decrement, - * void, or undo operations. - */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** - * Optional metadata that can be specified when adding ledger results via the API. For - * example, this can be used to note an increment refers to trial credits, or for noting - * corrections as a result of an incident, etc. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - /** - * User-specified key/value pairs for the resource. 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("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AddDecrementCreditLedgerEntryRequestParams = apply { - if (validated) { - return@apply - } - - amount() - entryType() - currency() - description() - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AddDecrementCreditLedgerEntryRequestParams]. */ - class Builder internal constructor() { - - private var amount: JsonField? = null - private var entryType: JsonField? = null - private var currency: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - addDecrementCreditLedgerEntryRequestParams: - AddDecrementCreditLedgerEntryRequestParams - ) = apply { - amount = addDecrementCreditLedgerEntryRequestParams.amount - entryType = addDecrementCreditLedgerEntryRequestParams.entryType - currency = addDecrementCreditLedgerEntryRequestParams.currency - description = addDecrementCreditLedgerEntryRequestParams.description - metadata = addDecrementCreditLedgerEntryRequestParams.metadata - additionalProperties = - addDecrementCreditLedgerEntryRequestParams.additionalProperties - .toMutableMap() - } - - /** - * The number of credits to effect. Note that this is required for increment, - * decrement, void, or undo operations. - */ - fun amount(amount: Double) = amount(JsonField.of(amount)) - - /** - * The number of credits to effect. Note that this is required for increment, - * decrement, void, or undo operations. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - - fun entryType(entryType: JsonField) = apply { - this.entryType = entryType - } - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** - * Optional metadata that can be specified when adding ledger results via the API. - * For example, this can be used to note an increment refers to trial credits, or - * for noting corrections as a result of an incident, etc. - */ - fun description(description: String?) = - description(JsonField.ofNullable(description)) - - /** - * Optional metadata that can be specified when adding ledger results via the API. - * For example, this can be used to note an increment refers to trial credits, or - * for noting corrections as a result of an incident, etc. - */ - fun description(description: Optional) = - description(description.orElse(null)) - - /** - * Optional metadata that can be specified when adding ledger results via the API. - * For example, this can be used to note an increment refers to trial credits, or - * for noting corrections as a result of an incident, etc. - */ - fun description(description: JsonField) = apply { - this.description = description - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): AddDecrementCreditLedgerEntryRequestParams = - AddDecrementCreditLedgerEntryRequestParams( - checkRequired("amount", amount), - checkRequired("entryType", entryType), - currency, - description, - metadata, - additionalProperties.toImmutable(), - ) - } - - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DECREMENT = of("decrement") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - DECREMENT - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DECREMENT, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DECREMENT -> Value.DECREMENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - DECREMENT -> Known.DECREMENT - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AddDecrementCreditLedgerEntryRequestParams && amount == other.amount && entryType == other.entryType && currency == other.currency && description == other.description && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, entryType, currency, description, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AddDecrementCreditLedgerEntryRequestParams{amount=$amount, entryType=$entryType, currency=$currency, description=$description, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class AddExpirationChangeCreditLedgerEntryRequestParams - @JsonCreator - private constructor( - @JsonProperty("entry_type") - @ExcludeMissing - private val entryType: JsonField = JsonMissing.of(), - @JsonProperty("expiry_date") - @ExcludeMissing - private val expiryDate: JsonField = JsonMissing.of(), - @JsonProperty("target_expiry_date") - @ExcludeMissing - private val targetExpiryDate: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("block_id") - @ExcludeMissing - private val blockId: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun entryType(): EntryType = entryType.getRequired("entry_type") - - /** An ISO 8601 format date that identifies the origination credit block to expire */ - fun expiryDate(): Optional = - Optional.ofNullable(expiryDate.getNullable("expiry_date")) - - /** - * 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. - */ - fun targetExpiryDate(): LocalDate = targetExpiryDate.getRequired("target_expiry_date") - - /** - * The number of credits to effect. Note that this is required for increment, decrement, - * void, or undo operations. - */ - fun amount(): Optional = Optional.ofNullable(amount.getNullable("amount")) - - /** - * The ID of the block affected by an expiration_change, used to differentiate between - * multiple blocks with the same `expiry_date`. - */ - fun blockId(): Optional = Optional.ofNullable(blockId.getNullable("block_id")) - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) - - /** - * Optional metadata that can be specified when adding ledger results via the API. For - * example, this can be used to note an increment refers to trial credits, or for noting - * corrections as a result of an incident, etc. - */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - - /** An ISO 8601 format date that identifies the origination credit block to expire */ - @JsonProperty("expiry_date") - @ExcludeMissing - fun _expiryDate(): JsonField = expiryDate - - /** - * 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. - */ - @JsonProperty("target_expiry_date") - @ExcludeMissing - fun _targetExpiryDate(): JsonField = targetExpiryDate - - /** - * The number of credits to effect. Note that this is required for increment, decrement, - * void, or undo operations. - */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** - * The ID of the block affected by an expiration_change, used to differentiate between - * multiple blocks with the same `expiry_date`. - */ - @JsonProperty("block_id") @ExcludeMissing fun _blockId(): JsonField = blockId - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** - * Optional metadata that can be specified when adding ledger results via the API. For - * example, this can be used to note an increment refers to trial credits, or for noting - * corrections as a result of an incident, etc. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - /** - * User-specified key/value pairs for the resource. 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("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AddExpirationChangeCreditLedgerEntryRequestParams = apply { - if (validated) { - return@apply - } - - entryType() - expiryDate() - targetExpiryDate() - amount() - blockId() - currency() - description() - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AddExpirationChangeCreditLedgerEntryRequestParams]. */ - class Builder internal constructor() { - - private var entryType: JsonField? = null - private var expiryDate: JsonField? = null - private var targetExpiryDate: JsonField? = null - private var amount: JsonField = JsonMissing.of() - private var blockId: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - addExpirationChangeCreditLedgerEntryRequestParams: - AddExpirationChangeCreditLedgerEntryRequestParams - ) = apply { - entryType = addExpirationChangeCreditLedgerEntryRequestParams.entryType - expiryDate = addExpirationChangeCreditLedgerEntryRequestParams.expiryDate - targetExpiryDate = - addExpirationChangeCreditLedgerEntryRequestParams.targetExpiryDate - amount = addExpirationChangeCreditLedgerEntryRequestParams.amount - blockId = addExpirationChangeCreditLedgerEntryRequestParams.blockId - currency = addExpirationChangeCreditLedgerEntryRequestParams.currency - description = addExpirationChangeCreditLedgerEntryRequestParams.description - metadata = addExpirationChangeCreditLedgerEntryRequestParams.metadata - additionalProperties = - addExpirationChangeCreditLedgerEntryRequestParams.additionalProperties - .toMutableMap() - } - - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - - fun entryType(entryType: JsonField) = apply { - this.entryType = entryType - } - - /** - * An ISO 8601 format date that identifies the origination credit block to expire - */ - fun expiryDate(expiryDate: OffsetDateTime?) = - expiryDate(JsonField.ofNullable(expiryDate)) - - /** - * An ISO 8601 format date that identifies the origination credit block to expire - */ - fun expiryDate(expiryDate: Optional) = - expiryDate(expiryDate.orElse(null)) - - /** - * An ISO 8601 format date that identifies the origination credit block to expire - */ - fun expiryDate(expiryDate: JsonField) = apply { - this.expiryDate = expiryDate - } - - /** - * 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. - */ - fun targetExpiryDate(targetExpiryDate: LocalDate) = - targetExpiryDate(JsonField.of(targetExpiryDate)) - - /** - * 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. - */ - fun targetExpiryDate(targetExpiryDate: JsonField) = apply { - this.targetExpiryDate = targetExpiryDate - } - - /** - * The number of credits to effect. Note that this is required for increment, - * decrement, void, or undo operations. - */ - fun amount(amount: Double?) = amount(JsonField.ofNullable(amount)) - - /** - * The number of credits to effect. Note that this is required for increment, - * decrement, void, or undo operations. - */ - fun amount(amount: Double) = amount(amount as Double?) - - /** - * The number of credits to effect. Note that this is required for increment, - * decrement, void, or undo operations. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun amount(amount: Optional) = amount(amount.orElse(null) as Double?) - - /** - * The number of credits to effect. Note that this is required for increment, - * decrement, void, or undo operations. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** - * The ID of the block affected by an expiration_change, used to differentiate - * between multiple blocks with the same `expiry_date`. - */ - fun blockId(blockId: String?) = blockId(JsonField.ofNullable(blockId)) - - /** - * The ID of the block affected by an expiration_change, used to differentiate - * between multiple blocks with the same `expiry_date`. - */ - fun blockId(blockId: Optional) = blockId(blockId.orElse(null)) - - /** - * The ID of the block affected by an expiration_change, used to differentiate - * between multiple blocks with the same `expiry_date`. - */ - fun blockId(blockId: JsonField) = apply { this.blockId = blockId } - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** - * Optional metadata that can be specified when adding ledger results via the API. - * For example, this can be used to note an increment refers to trial credits, or - * for noting corrections as a result of an incident, etc. - */ - fun description(description: String?) = - description(JsonField.ofNullable(description)) - - /** - * Optional metadata that can be specified when adding ledger results via the API. - * For example, this can be used to note an increment refers to trial credits, or - * for noting corrections as a result of an incident, etc. - */ - fun description(description: Optional) = - description(description.orElse(null)) - - /** - * Optional metadata that can be specified when adding ledger results via the API. - * For example, this can be used to note an increment refers to trial credits, or - * for noting corrections as a result of an incident, etc. - */ - fun description(description: JsonField) = apply { - this.description = description - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): AddExpirationChangeCreditLedgerEntryRequestParams = - AddExpirationChangeCreditLedgerEntryRequestParams( - checkRequired("entryType", entryType), - checkRequired("expiryDate", expiryDate), - checkRequired("targetExpiryDate", targetExpiryDate), - amount, - blockId, - currency, - description, - metadata, - additionalProperties.toImmutable(), - ) - } - - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val EXPIRATION_CHANGE = of("expiration_change") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - EXPIRATION_CHANGE - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - EXPIRATION_CHANGE, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - EXPIRATION_CHANGE -> Value.EXPIRATION_CHANGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - EXPIRATION_CHANGE -> Known.EXPIRATION_CHANGE - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AddExpirationChangeCreditLedgerEntryRequestParams && entryType == other.entryType && expiryDate == other.expiryDate && targetExpiryDate == other.targetExpiryDate && amount == other.amount && blockId == other.blockId && currency == other.currency && description == other.description && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(entryType, expiryDate, targetExpiryDate, amount, blockId, currency, description, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AddExpirationChangeCreditLedgerEntryRequestParams{entryType=$entryType, expiryDate=$expiryDate, targetExpiryDate=$targetExpiryDate, amount=$amount, blockId=$blockId, currency=$currency, description=$description, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class AddVoidCreditLedgerEntryRequestParams - @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("block_id") - @ExcludeMissing - private val blockId: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - private val entryType: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("void_reason") - @ExcludeMissing - private val voidReason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * The number of credits to effect. Note that this is required for increment, decrement, - * void, or undo operations. - */ - fun amount(): Double = amount.getRequired("amount") - - /** The ID of the block to void. */ - fun blockId(): String = blockId.getRequired("block_id") - - fun entryType(): EntryType = entryType.getRequired("entry_type") - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) - - /** - * Optional metadata that can be specified when adding ledger results via the API. For - * example, this can be used to note an increment refers to trial credits, or for noting - * corrections as a result of an incident, etc. - */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** Can only be specified when `entry_type=void`. The reason for the void. */ - fun voidReason(): Optional = - Optional.ofNullable(voidReason.getNullable("void_reason")) - - /** - * The number of credits to effect. Note that this is required for increment, decrement, - * void, or undo operations. - */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** The ID of the block to void. */ - @JsonProperty("block_id") @ExcludeMissing fun _blockId(): JsonField = blockId - - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** - * Optional metadata that can be specified when adding ledger results via the API. For - * example, this can be used to note an increment refers to trial credits, or for noting - * corrections as a result of an incident, etc. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - /** - * User-specified key/value pairs for the resource. 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("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** Can only be specified when `entry_type=void`. The reason for the void. */ - @JsonProperty("void_reason") - @ExcludeMissing - fun _voidReason(): JsonField = voidReason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AddVoidCreditLedgerEntryRequestParams = apply { - if (validated) { - return@apply - } - - amount() - blockId() - entryType() - currency() - description() - metadata().ifPresent { it.validate() } - voidReason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AddVoidCreditLedgerEntryRequestParams]. */ - class Builder internal constructor() { - - private var amount: JsonField? = null - private var blockId: JsonField? = null - private var entryType: JsonField? = null - private var currency: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var voidReason: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - addVoidCreditLedgerEntryRequestParams: AddVoidCreditLedgerEntryRequestParams - ) = apply { - amount = addVoidCreditLedgerEntryRequestParams.amount - blockId = addVoidCreditLedgerEntryRequestParams.blockId - entryType = addVoidCreditLedgerEntryRequestParams.entryType - currency = addVoidCreditLedgerEntryRequestParams.currency - description = addVoidCreditLedgerEntryRequestParams.description - metadata = addVoidCreditLedgerEntryRequestParams.metadata - voidReason = addVoidCreditLedgerEntryRequestParams.voidReason - additionalProperties = - addVoidCreditLedgerEntryRequestParams.additionalProperties.toMutableMap() - } - - /** - * The number of credits to effect. Note that this is required for increment, - * decrement, void, or undo operations. - */ - fun amount(amount: Double) = amount(JsonField.of(amount)) - - /** - * The number of credits to effect. Note that this is required for increment, - * decrement, void, or undo operations. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** The ID of the block to void. */ - fun blockId(blockId: String) = blockId(JsonField.of(blockId)) - - /** The ID of the block to void. */ - fun blockId(blockId: JsonField) = apply { this.blockId = blockId } - - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - - fun entryType(entryType: JsonField) = apply { - this.entryType = entryType - } - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** - * Optional metadata that can be specified when adding ledger results via the API. - * For example, this can be used to note an increment refers to trial credits, or - * for noting corrections as a result of an incident, etc. - */ - fun description(description: String?) = - description(JsonField.ofNullable(description)) - - /** - * Optional metadata that can be specified when adding ledger results via the API. - * For example, this can be used to note an increment refers to trial credits, or - * for noting corrections as a result of an incident, etc. - */ - fun description(description: Optional) = - description(description.orElse(null)) - - /** - * Optional metadata that can be specified when adding ledger results via the API. - * For example, this can be used to note an increment refers to trial credits, or - * for noting corrections as a result of an incident, etc. - */ - fun description(description: JsonField) = apply { - this.description = description - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: JsonField) = apply { this.metadata = metadata } - - /** Can only be specified when `entry_type=void`. The reason for the void. */ - fun voidReason(voidReason: VoidReason?) = - voidReason(JsonField.ofNullable(voidReason)) - - /** Can only be specified when `entry_type=void`. The reason for the void. */ - fun voidReason(voidReason: Optional) = - voidReason(voidReason.orElse(null)) - - /** Can only be specified when `entry_type=void`. The reason for the void. */ - fun voidReason(voidReason: JsonField) = apply { - this.voidReason = voidReason - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): AddVoidCreditLedgerEntryRequestParams = - AddVoidCreditLedgerEntryRequestParams( - checkRequired("amount", amount), - checkRequired("blockId", blockId), - checkRequired("entryType", entryType), - currency, - description, - metadata, - voidReason, - additionalProperties.toImmutable(), - ) - } - - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val VOID = of("void") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - VOID - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - VOID, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - VOID -> Value.VOID - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - VOID -> Known.VOID - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - /** Can only be specified when `entry_type=void`. The reason for the void. */ - class VoidReason - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val REFUND = of("refund") - - @JvmStatic fun of(value: String) = VoidReason(JsonField.of(value)) - } - - /** An enum containing [VoidReason]'s known values. */ - enum class Known { - REFUND - } - - /** - * An enum containing [VoidReason]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [VoidReason] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - REFUND, - /** - * An enum member indicating that [VoidReason] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - REFUND -> Value.REFUND - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - REFUND -> Known.REFUND - else -> throw OrbInvalidDataException("Unknown VoidReason: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is VoidReason && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AddVoidCreditLedgerEntryRequestParams && amount == other.amount && blockId == other.blockId && entryType == other.entryType && currency == other.currency && description == other.description && metadata == other.metadata && voidReason == other.voidReason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, blockId, entryType, currency, description, metadata, voidReason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AddVoidCreditLedgerEntryRequestParams{amount=$amount, blockId=$blockId, entryType=$entryType, currency=$currency, description=$description, metadata=$metadata, voidReason=$voidReason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class AddAmendmentCreditLedgerEntryRequestParams - @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("block_id") - @ExcludeMissing - private val blockId: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - private val entryType: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * The number of credits to effect. Note that this is required for increment, decrement - * or void operations. - */ - fun amount(): Double = amount.getRequired("amount") - - /** The ID of the block to reverse a decrement from. */ - fun blockId(): String = blockId.getRequired("block_id") - - fun entryType(): EntryType = entryType.getRequired("entry_type") - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) - - /** - * Optional metadata that can be specified when adding ledger results via the API. For - * example, this can be used to note an increment refers to trial credits, or for noting - * corrections as a result of an incident, etc. - */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * The number of credits to effect. Note that this is required for increment, decrement - * or void operations. - */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** The ID of the block to reverse a decrement from. */ - @JsonProperty("block_id") @ExcludeMissing fun _blockId(): JsonField = blockId - - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** - * Optional metadata that can be specified when adding ledger results via the API. For - * example, this can be used to note an increment refers to trial credits, or for noting - * corrections as a result of an incident, etc. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - /** - * User-specified key/value pairs for the resource. 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("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AddAmendmentCreditLedgerEntryRequestParams = apply { - if (validated) { - return@apply - } - - amount() - blockId() - entryType() - currency() - description() - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AddAmendmentCreditLedgerEntryRequestParams]. */ - class Builder internal constructor() { - - private var amount: JsonField? = null - private var blockId: JsonField? = null - private var entryType: JsonField? = null - private var currency: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - addAmendmentCreditLedgerEntryRequestParams: - AddAmendmentCreditLedgerEntryRequestParams - ) = apply { - amount = addAmendmentCreditLedgerEntryRequestParams.amount - blockId = addAmendmentCreditLedgerEntryRequestParams.blockId - entryType = addAmendmentCreditLedgerEntryRequestParams.entryType - currency = addAmendmentCreditLedgerEntryRequestParams.currency - description = addAmendmentCreditLedgerEntryRequestParams.description - metadata = addAmendmentCreditLedgerEntryRequestParams.metadata - additionalProperties = - addAmendmentCreditLedgerEntryRequestParams.additionalProperties - .toMutableMap() - } - - /** - * The number of credits to effect. Note that this is required for increment, - * decrement or void operations. - */ - fun amount(amount: Double) = amount(JsonField.of(amount)) - - /** - * The number of credits to effect. Note that this is required for increment, - * decrement or void operations. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** The ID of the block to reverse a decrement from. */ - fun blockId(blockId: String) = blockId(JsonField.of(blockId)) - - /** The ID of the block to reverse a decrement from. */ - fun blockId(blockId: JsonField) = apply { this.blockId = blockId } - - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - - fun entryType(entryType: JsonField) = apply { - this.entryType = entryType - } - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** - * Optional metadata that can be specified when adding ledger results via the API. - * For example, this can be used to note an increment refers to trial credits, or - * for noting corrections as a result of an incident, etc. - */ - fun description(description: String?) = - description(JsonField.ofNullable(description)) - - /** - * Optional metadata that can be specified when adding ledger results via the API. - * For example, this can be used to note an increment refers to trial credits, or - * for noting corrections as a result of an incident, etc. - */ - fun description(description: Optional) = - description(description.orElse(null)) - - /** - * Optional metadata that can be specified when adding ledger results via the API. - * For example, this can be used to note an increment refers to trial credits, or - * for noting corrections as a result of an incident, etc. - */ - fun description(description: JsonField) = apply { - this.description = description - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): AddAmendmentCreditLedgerEntryRequestParams = - AddAmendmentCreditLedgerEntryRequestParams( - checkRequired("amount", amount), - checkRequired("blockId", blockId), - checkRequired("entryType", entryType), - currency, - description, - metadata, - additionalProperties.toImmutable(), - ) - } - - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val AMENDMENT = of("amendment") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - AMENDMENT - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMENDMENT, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMENDMENT -> Value.AMENDMENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AMENDMENT -> Known.AMENDMENT - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AddAmendmentCreditLedgerEntryRequestParams && amount == other.amount && blockId == other.blockId && entryType == other.entryType && currency == other.currency && description == other.description && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, blockId, entryType, currency, description, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AddAmendmentCreditLedgerEntryRequestParams{amount=$amount, blockId=$blockId, entryType=$entryType, currency=$currency, description=$description, metadata=$metadata, additionalProperties=$additionalProperties}" - } - } - fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of + * [CustomerCreditLedgerCreateEntryByExternalIdParams]. + * + * The following fields are required: + * ```java + * .externalCustomerId() + * .addCreditLedgerEntryRequest() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -3519,7 +162,7 @@ private constructor( class Builder internal constructor() { private var externalCustomerId: String? = null - private var body: Body? = null + private var addCreditLedgerEntryRequest: AddCreditLedgerEntryRequest? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -3530,7 +173,8 @@ private constructor( ) = apply { externalCustomerId = customerCreditLedgerCreateEntryByExternalIdParams.externalCustomerId - body = customerCreditLedgerCreateEntryByExternalIdParams.body + addCreditLedgerEntryRequest = + customerCreditLedgerCreateEntryByExternalIdParams.addCreditLedgerEntryRequest additionalHeaders = customerCreditLedgerCreateEntryByExternalIdParams.additionalHeaders.toBuilder() additionalQueryParams = @@ -3541,24 +185,26 @@ private constructor( this.externalCustomerId = externalCustomerId } - fun body(body: Body) = apply { this.body = body } + fun addCreditLedgerEntryRequest(addCreditLedgerEntryRequest: AddCreditLedgerEntryRequest) = + apply { + this.addCreditLedgerEntryRequest = addCreditLedgerEntryRequest + } - fun body( - addIncrementCreditLedgerEntryRequestParams: - Body.AddIncrementCreditLedgerEntryRequestParams + fun addCreditLedgerEntryRequest( + incrementCreditLedgerEntryRequestParams: + AddCreditLedgerEntryRequest.AddIncrementCreditLedgerEntryRequestParams ) = - body( - Body.ofAddIncrementCreditLedgerEntryRequestParams( - addIncrementCreditLedgerEntryRequestParams + addCreditLedgerEntryRequest( + AddCreditLedgerEntryRequest.ofIncrementCreditLedgerEntryRequestParams( + incrementCreditLedgerEntryRequestParams ) ) - fun addIncrementCreditLedgerEntryRequestParamsBody(amount: Double) = - body( - Body.AddIncrementCreditLedgerEntryRequestParams.builder() + fun addIncrementCreditLedgerEntryRequestParamsCreditLedgerEntryRequest(amount: Double) = + addCreditLedgerEntryRequest( + AddCreditLedgerEntryRequest.AddIncrementCreditLedgerEntryRequestParams.builder() .entryType( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams + AddCreditLedgerEntryRequest.AddIncrementCreditLedgerEntryRequestParams .EntryType .INCREMENT ) @@ -3566,22 +212,21 @@ private constructor( .build() ) - fun body( - addDecrementCreditLedgerEntryRequestParams: - Body.AddDecrementCreditLedgerEntryRequestParams + fun addCreditLedgerEntryRequest( + decrementCreditLedgerEntryRequestParams: + AddCreditLedgerEntryRequest.AddDecrementCreditLedgerEntryRequestParams ) = - body( - Body.ofAddDecrementCreditLedgerEntryRequestParams( - addDecrementCreditLedgerEntryRequestParams + addCreditLedgerEntryRequest( + AddCreditLedgerEntryRequest.ofDecrementCreditLedgerEntryRequestParams( + decrementCreditLedgerEntryRequestParams ) ) - fun addDecrementCreditLedgerEntryRequestParamsBody(amount: Double) = - body( - Body.AddDecrementCreditLedgerEntryRequestParams.builder() + fun addDecrementCreditLedgerEntryRequestParamsCreditLedgerEntryRequest(amount: Double) = + addCreditLedgerEntryRequest( + AddCreditLedgerEntryRequest.AddDecrementCreditLedgerEntryRequestParams.builder() .entryType( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddDecrementCreditLedgerEntryRequestParams + AddCreditLedgerEntryRequest.AddDecrementCreditLedgerEntryRequestParams .EntryType .DECREMENT ) @@ -3589,30 +234,33 @@ private constructor( .build() ) - fun body( - addExpirationChangeCreditLedgerEntryRequestParams: - Body.AddExpirationChangeCreditLedgerEntryRequestParams + fun addCreditLedgerEntryRequest( + expirationChangeCreditLedgerEntryRequestParams: + AddCreditLedgerEntryRequest.AddExpirationChangeCreditLedgerEntryRequestParams ) = - body( - Body.ofAddExpirationChangeCreditLedgerEntryRequestParams( - addExpirationChangeCreditLedgerEntryRequestParams + addCreditLedgerEntryRequest( + AddCreditLedgerEntryRequest.ofExpirationChangeCreditLedgerEntryRequestParams( + expirationChangeCreditLedgerEntryRequestParams ) ) - fun body( - addVoidCreditLedgerEntryRequestParams: Body.AddVoidCreditLedgerEntryRequestParams + fun addCreditLedgerEntryRequest( + voidCreditLedgerEntryRequestParams: + AddCreditLedgerEntryRequest.AddVoidCreditLedgerEntryRequestParams ) = - body( - Body.ofAddVoidCreditLedgerEntryRequestParams(addVoidCreditLedgerEntryRequestParams) + addCreditLedgerEntryRequest( + AddCreditLedgerEntryRequest.ofVoidCreditLedgerEntryRequestParams( + voidCreditLedgerEntryRequestParams + ) ) - fun body( - addAmendmentCreditLedgerEntryRequestParams: - Body.AddAmendmentCreditLedgerEntryRequestParams + fun addCreditLedgerEntryRequest( + amendmentCreditLedgerEntryRequestParams: + AddCreditLedgerEntryRequest.AddAmendmentCreditLedgerEntryRequestParams ) = - body( - Body.ofAddAmendmentCreditLedgerEntryRequestParams( - addAmendmentCreditLedgerEntryRequestParams + addCreditLedgerEntryRequest( + AddCreditLedgerEntryRequest.ofAmendmentCreditLedgerEntryRequestParams( + amendmentCreditLedgerEntryRequestParams ) ) @@ -3717,7 +365,7 @@ private constructor( fun build(): CustomerCreditLedgerCreateEntryByExternalIdParams = CustomerCreditLedgerCreateEntryByExternalIdParams( checkRequired("externalCustomerId", externalCustomerId), - checkRequired("body", body), + checkRequired("addCreditLedgerEntryRequest", addCreditLedgerEntryRequest), additionalHeaders.build(), additionalQueryParams.build(), ) @@ -3728,11 +376,11 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditLedgerCreateEntryByExternalIdParams && externalCustomerId == other.externalCustomerId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is CustomerCreditLedgerCreateEntryByExternalIdParams && externalCustomerId == other.externalCustomerId && addCreditLedgerEntryRequest == other.addCreditLedgerEntryRequest && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(externalCustomerId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(externalCustomerId, addCreditLedgerEntryRequest, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "CustomerCreditLedgerCreateEntryByExternalIdParams{externalCustomerId=$externalCustomerId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "CustomerCreditLedgerCreateEntryByExternalIdParams{externalCustomerId=$externalCustomerId, addCreditLedgerEntryRequest=$addCreditLedgerEntryRequest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponse.kt deleted file mode 100644 index 07996eff0..000000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponse.kt +++ /dev/null @@ -1,6793 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer -import com.withorb.api.core.Enum -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow -import com.withorb.api.core.immutableEmptyMap -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** - * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within - * Orb. - */ -@JsonDeserialize(using = CustomerCreditLedgerCreateEntryByExternalIdResponse.Deserializer::class) -@JsonSerialize(using = CustomerCreditLedgerCreateEntryByExternalIdResponse.Serializer::class) -class CustomerCreditLedgerCreateEntryByExternalIdResponse -private constructor( - private val incrementLedgerEntry: IncrementLedgerEntry? = null, - private val decrementLedgerEntry: DecrementLedgerEntry? = null, - private val expirationChangeLedgerEntry: ExpirationChangeLedgerEntry? = null, - private val creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry? = null, - private val voidLedgerEntry: VoidLedgerEntry? = null, - private val voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry? = null, - private val amendmentLedgerEntry: AmendmentLedgerEntry? = null, - private val _json: JsonValue? = null, -) { - - fun incrementLedgerEntry(): Optional = - Optional.ofNullable(incrementLedgerEntry) - - fun decrementLedgerEntry(): Optional = - Optional.ofNullable(decrementLedgerEntry) - - fun expirationChangeLedgerEntry(): Optional = - Optional.ofNullable(expirationChangeLedgerEntry) - - fun creditBlockExpiryLedgerEntry(): Optional = - Optional.ofNullable(creditBlockExpiryLedgerEntry) - - fun voidLedgerEntry(): Optional = Optional.ofNullable(voidLedgerEntry) - - fun voidInitiatedLedgerEntry(): Optional = - Optional.ofNullable(voidInitiatedLedgerEntry) - - fun amendmentLedgerEntry(): Optional = - Optional.ofNullable(amendmentLedgerEntry) - - fun isIncrementLedgerEntry(): Boolean = incrementLedgerEntry != null - - fun isDecrementLedgerEntry(): Boolean = decrementLedgerEntry != null - - fun isExpirationChangeLedgerEntry(): Boolean = expirationChangeLedgerEntry != null - - fun isCreditBlockExpiryLedgerEntry(): Boolean = creditBlockExpiryLedgerEntry != null - - fun isVoidLedgerEntry(): Boolean = voidLedgerEntry != null - - fun isVoidInitiatedLedgerEntry(): Boolean = voidInitiatedLedgerEntry != null - - fun isAmendmentLedgerEntry(): Boolean = amendmentLedgerEntry != null - - fun asIncrementLedgerEntry(): IncrementLedgerEntry = - incrementLedgerEntry.getOrThrow("incrementLedgerEntry") - - fun asDecrementLedgerEntry(): DecrementLedgerEntry = - decrementLedgerEntry.getOrThrow("decrementLedgerEntry") - - fun asExpirationChangeLedgerEntry(): ExpirationChangeLedgerEntry = - expirationChangeLedgerEntry.getOrThrow("expirationChangeLedgerEntry") - - fun asCreditBlockExpiryLedgerEntry(): CreditBlockExpiryLedgerEntry = - creditBlockExpiryLedgerEntry.getOrThrow("creditBlockExpiryLedgerEntry") - - fun asVoidLedgerEntry(): VoidLedgerEntry = voidLedgerEntry.getOrThrow("voidLedgerEntry") - - fun asVoidInitiatedLedgerEntry(): VoidInitiatedLedgerEntry = - voidInitiatedLedgerEntry.getOrThrow("voidInitiatedLedgerEntry") - - fun asAmendmentLedgerEntry(): AmendmentLedgerEntry = - amendmentLedgerEntry.getOrThrow("amendmentLedgerEntry") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - incrementLedgerEntry != null -> visitor.visitIncrementLedgerEntry(incrementLedgerEntry) - decrementLedgerEntry != null -> visitor.visitDecrementLedgerEntry(decrementLedgerEntry) - expirationChangeLedgerEntry != null -> - visitor.visitExpirationChangeLedgerEntry(expirationChangeLedgerEntry) - creditBlockExpiryLedgerEntry != null -> - visitor.visitCreditBlockExpiryLedgerEntry(creditBlockExpiryLedgerEntry) - voidLedgerEntry != null -> visitor.visitVoidLedgerEntry(voidLedgerEntry) - voidInitiatedLedgerEntry != null -> - visitor.visitVoidInitiatedLedgerEntry(voidInitiatedLedgerEntry) - amendmentLedgerEntry != null -> visitor.visitAmendmentLedgerEntry(amendmentLedgerEntry) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): CustomerCreditLedgerCreateEntryByExternalIdResponse = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitIncrementLedgerEntry(incrementLedgerEntry: IncrementLedgerEntry) { - incrementLedgerEntry.validate() - } - - override fun visitDecrementLedgerEntry(decrementLedgerEntry: DecrementLedgerEntry) { - decrementLedgerEntry.validate() - } - - override fun visitExpirationChangeLedgerEntry( - expirationChangeLedgerEntry: ExpirationChangeLedgerEntry - ) { - expirationChangeLedgerEntry.validate() - } - - override fun visitCreditBlockExpiryLedgerEntry( - creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry - ) { - creditBlockExpiryLedgerEntry.validate() - } - - override fun visitVoidLedgerEntry(voidLedgerEntry: VoidLedgerEntry) { - voidLedgerEntry.validate() - } - - override fun visitVoidInitiatedLedgerEntry( - voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry - ) { - voidInitiatedLedgerEntry.validate() - } - - override fun visitAmendmentLedgerEntry(amendmentLedgerEntry: AmendmentLedgerEntry) { - amendmentLedgerEntry.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CustomerCreditLedgerCreateEntryByExternalIdResponse && incrementLedgerEntry == other.incrementLedgerEntry && decrementLedgerEntry == other.decrementLedgerEntry && expirationChangeLedgerEntry == other.expirationChangeLedgerEntry && creditBlockExpiryLedgerEntry == other.creditBlockExpiryLedgerEntry && voidLedgerEntry == other.voidLedgerEntry && voidInitiatedLedgerEntry == other.voidInitiatedLedgerEntry && amendmentLedgerEntry == other.amendmentLedgerEntry /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(incrementLedgerEntry, decrementLedgerEntry, expirationChangeLedgerEntry, creditBlockExpiryLedgerEntry, voidLedgerEntry, voidInitiatedLedgerEntry, amendmentLedgerEntry) /* spotless:on */ - - override fun toString(): String = - when { - incrementLedgerEntry != null -> - "CustomerCreditLedgerCreateEntryByExternalIdResponse{incrementLedgerEntry=$incrementLedgerEntry}" - decrementLedgerEntry != null -> - "CustomerCreditLedgerCreateEntryByExternalIdResponse{decrementLedgerEntry=$decrementLedgerEntry}" - expirationChangeLedgerEntry != null -> - "CustomerCreditLedgerCreateEntryByExternalIdResponse{expirationChangeLedgerEntry=$expirationChangeLedgerEntry}" - creditBlockExpiryLedgerEntry != null -> - "CustomerCreditLedgerCreateEntryByExternalIdResponse{creditBlockExpiryLedgerEntry=$creditBlockExpiryLedgerEntry}" - voidLedgerEntry != null -> - "CustomerCreditLedgerCreateEntryByExternalIdResponse{voidLedgerEntry=$voidLedgerEntry}" - voidInitiatedLedgerEntry != null -> - "CustomerCreditLedgerCreateEntryByExternalIdResponse{voidInitiatedLedgerEntry=$voidInitiatedLedgerEntry}" - amendmentLedgerEntry != null -> - "CustomerCreditLedgerCreateEntryByExternalIdResponse{amendmentLedgerEntry=$amendmentLedgerEntry}" - _json != null -> "CustomerCreditLedgerCreateEntryByExternalIdResponse{_unknown=$_json}" - else -> - throw IllegalStateException( - "Invalid CustomerCreditLedgerCreateEntryByExternalIdResponse" - ) - } - - companion object { - - @JvmStatic - fun ofIncrementLedgerEntry(incrementLedgerEntry: IncrementLedgerEntry) = - CustomerCreditLedgerCreateEntryByExternalIdResponse( - incrementLedgerEntry = incrementLedgerEntry - ) - - @JvmStatic - fun ofDecrementLedgerEntry(decrementLedgerEntry: DecrementLedgerEntry) = - CustomerCreditLedgerCreateEntryByExternalIdResponse( - decrementLedgerEntry = decrementLedgerEntry - ) - - @JvmStatic - fun ofExpirationChangeLedgerEntry( - expirationChangeLedgerEntry: ExpirationChangeLedgerEntry - ) = - CustomerCreditLedgerCreateEntryByExternalIdResponse( - expirationChangeLedgerEntry = expirationChangeLedgerEntry - ) - - @JvmStatic - fun ofCreditBlockExpiryLedgerEntry( - creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry - ) = - CustomerCreditLedgerCreateEntryByExternalIdResponse( - creditBlockExpiryLedgerEntry = creditBlockExpiryLedgerEntry - ) - - @JvmStatic - fun ofVoidLedgerEntry(voidLedgerEntry: VoidLedgerEntry) = - CustomerCreditLedgerCreateEntryByExternalIdResponse(voidLedgerEntry = voidLedgerEntry) - - @JvmStatic - fun ofVoidInitiatedLedgerEntry(voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry) = - CustomerCreditLedgerCreateEntryByExternalIdResponse( - voidInitiatedLedgerEntry = voidInitiatedLedgerEntry - ) - - @JvmStatic - fun ofAmendmentLedgerEntry(amendmentLedgerEntry: AmendmentLedgerEntry) = - CustomerCreditLedgerCreateEntryByExternalIdResponse( - amendmentLedgerEntry = amendmentLedgerEntry - ) - } - - /** - * An interface that defines how to map each variant of - * [CustomerCreditLedgerCreateEntryByExternalIdResponse] to a value of type [T]. - */ - interface Visitor { - - fun visitIncrementLedgerEntry(incrementLedgerEntry: IncrementLedgerEntry): T - - fun visitDecrementLedgerEntry(decrementLedgerEntry: DecrementLedgerEntry): T - - fun visitExpirationChangeLedgerEntry( - expirationChangeLedgerEntry: ExpirationChangeLedgerEntry - ): T - - fun visitCreditBlockExpiryLedgerEntry( - creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry - ): T - - fun visitVoidLedgerEntry(voidLedgerEntry: VoidLedgerEntry): T - - fun visitVoidInitiatedLedgerEntry(voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry): T - - fun visitAmendmentLedgerEntry(amendmentLedgerEntry: AmendmentLedgerEntry): T - - /** - * Maps an unknown variant of [CustomerCreditLedgerCreateEntryByExternalIdResponse] to a - * value of type [T]. - * - * An instance of [CustomerCreditLedgerCreateEntryByExternalIdResponse] can contain an - * unknown variant if it was deserialized from data that doesn't match any known variant. - * For example, if the SDK is on an older version than the API, then the API may respond - * with new variants that the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException( - "Unknown CustomerCreditLedgerCreateEntryByExternalIdResponse: $json" - ) - } - } - - internal class Deserializer : - BaseDeserializer( - CustomerCreditLedgerCreateEntryByExternalIdResponse::class - ) { - - override fun ObjectCodec.deserialize( - node: JsonNode - ): CustomerCreditLedgerCreateEntryByExternalIdResponse { - val json = JsonValue.fromJsonNode(node) - val entryType = json.asObject().getOrNull()?.get("entry_type")?.asString()?.getOrNull() - - when (entryType) { - "increment" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return CustomerCreditLedgerCreateEntryByExternalIdResponse( - incrementLedgerEntry = it, - _json = json, - ) - } - } - "decrement" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return CustomerCreditLedgerCreateEntryByExternalIdResponse( - decrementLedgerEntry = it, - _json = json, - ) - } - } - "expiration_change" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return CustomerCreditLedgerCreateEntryByExternalIdResponse( - expirationChangeLedgerEntry = it, - _json = json, - ) - } - } - "credit_block_expiry" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return CustomerCreditLedgerCreateEntryByExternalIdResponse( - creditBlockExpiryLedgerEntry = it, - _json = json, - ) - } - } - "void" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return CustomerCreditLedgerCreateEntryByExternalIdResponse( - voidLedgerEntry = it, - _json = json, - ) - } - } - "void_initiated" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return CustomerCreditLedgerCreateEntryByExternalIdResponse( - voidInitiatedLedgerEntry = it, - _json = json, - ) - } - } - "amendment" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return CustomerCreditLedgerCreateEntryByExternalIdResponse( - amendmentLedgerEntry = it, - _json = json, - ) - } - } - } - - return CustomerCreditLedgerCreateEntryByExternalIdResponse(_json = json) - } - } - - internal class Serializer : - BaseSerializer( - CustomerCreditLedgerCreateEntryByExternalIdResponse::class - ) { - - override fun serialize( - value: CustomerCreditLedgerCreateEntryByExternalIdResponse, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.incrementLedgerEntry != null -> - generator.writeObject(value.incrementLedgerEntry) - value.decrementLedgerEntry != null -> - generator.writeObject(value.decrementLedgerEntry) - value.expirationChangeLedgerEntry != null -> - generator.writeObject(value.expirationChangeLedgerEntry) - value.creditBlockExpiryLedgerEntry != null -> - generator.writeObject(value.creditBlockExpiryLedgerEntry) - value.voidLedgerEntry != null -> generator.writeObject(value.voidLedgerEntry) - value.voidInitiatedLedgerEntry != null -> - generator.writeObject(value.voidInitiatedLedgerEntry) - value.amendmentLedgerEntry != null -> - generator.writeObject(value.amendmentLedgerEntry) - value._json != null -> generator.writeObject(value._json) - else -> - throw IllegalStateException( - "Invalid CustomerCreditLedgerCreateEntryByExternalIdResponse" - ) - } - } - } - - @NoAutoDetect - class IncrementLedgerEntry - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("credit_block") - @ExcludeMissing - private val creditBlock: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("customer") - @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("ending_balance") - @ExcludeMissing - private val endingBalance: JsonField = JsonMissing.of(), - @JsonProperty("entry_status") - @ExcludeMissing - private val entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - private val entryType: JsonField = JsonMissing.of(), - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - private val ledgerSequenceNumber: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("starting_balance") - @ExcludeMissing - private val startingBalance: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun amount(): Double = amount.getRequired("amount") - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - fun creditBlock(): CreditBlock = creditBlock.getRequired("credit_block") - - fun currency(): String = currency.getRequired("currency") - - fun customer(): Customer = customer.getRequired("customer") - - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - fun endingBalance(): Double = endingBalance.getRequired("ending_balance") - - fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") - - fun entryType(): EntryType = entryType.getRequired("entry_type") - - fun ledgerSequenceNumber(): Long = - ledgerSequenceNumber.getRequired("ledger_sequence_number") - - /** - * 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.getRequired("metadata") - - fun startingBalance(): Double = startingBalance.getRequired("starting_balance") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - @JsonProperty("credit_block") - @ExcludeMissing - fun _creditBlock(): JsonField = creditBlock - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - @JsonProperty("ending_balance") - @ExcludeMissing - fun _endingBalance(): JsonField = endingBalance - - @JsonProperty("entry_status") - @ExcludeMissing - fun _entryStatus(): JsonField = entryStatus - - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber - - /** - * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - @JsonProperty("starting_balance") - @ExcludeMissing - fun _startingBalance(): JsonField = startingBalance - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): IncrementLedgerEntry = apply { - if (validated) { - return@apply - } - - id() - amount() - createdAt() - creditBlock().validate() - currency() - customer().validate() - description() - endingBalance() - entryStatus() - entryType() - ledgerSequenceNumber() - metadata().validate() - startingBalance() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [IncrementLedgerEntry]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var amount: JsonField? = null - private var createdAt: JsonField? = null - private var creditBlock: JsonField? = null - private var currency: JsonField? = null - private var customer: JsonField? = null - private var description: JsonField? = null - private var endingBalance: JsonField? = null - private var entryStatus: JsonField? = null - private var entryType: JsonField? = null - private var ledgerSequenceNumber: JsonField? = null - private var metadata: JsonField? = null - private var startingBalance: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(incrementLedgerEntry: IncrementLedgerEntry) = apply { - id = incrementLedgerEntry.id - amount = incrementLedgerEntry.amount - createdAt = incrementLedgerEntry.createdAt - creditBlock = incrementLedgerEntry.creditBlock - currency = incrementLedgerEntry.currency - customer = incrementLedgerEntry.customer - description = incrementLedgerEntry.description - endingBalance = incrementLedgerEntry.endingBalance - entryStatus = incrementLedgerEntry.entryStatus - entryType = incrementLedgerEntry.entryType - ledgerSequenceNumber = incrementLedgerEntry.ledgerSequenceNumber - metadata = incrementLedgerEntry.metadata - startingBalance = incrementLedgerEntry.startingBalance - additionalProperties = incrementLedgerEntry.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun amount(amount: Double) = amount(JsonField.of(amount)) - - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { - this.createdAt = createdAt - } - - fun creditBlock(creditBlock: CreditBlock) = creditBlock(JsonField.of(creditBlock)) - - fun creditBlock(creditBlock: JsonField) = apply { - this.creditBlock = creditBlock - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun customer(customer: Customer) = customer(JsonField.of(customer)) - - fun customer(customer: JsonField) = apply { this.customer = customer } - - fun description(description: String?) = description(JsonField.ofNullable(description)) - - fun description(description: Optional) = description(description.orElse(null)) - - fun description(description: JsonField) = apply { - this.description = description - } - - fun endingBalance(endingBalance: Double) = endingBalance(JsonField.of(endingBalance)) - - fun endingBalance(endingBalance: JsonField) = apply { - this.endingBalance = endingBalance - } - - fun entryStatus(entryStatus: EntryStatus) = entryStatus(JsonField.of(entryStatus)) - - fun entryStatus(entryStatus: JsonField) = apply { - this.entryStatus = entryStatus - } - - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } - - fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = - ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) - - fun ledgerSequenceNumber(ledgerSequenceNumber: JsonField) = apply { - this.ledgerSequenceNumber = ledgerSequenceNumber - } - - /** - * 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - fun startingBalance(startingBalance: Double) = - startingBalance(JsonField.of(startingBalance)) - - fun startingBalance(startingBalance: JsonField) = apply { - this.startingBalance = startingBalance - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): IncrementLedgerEntry = - IncrementLedgerEntry( - checkRequired("id", id), - checkRequired("amount", amount), - checkRequired("createdAt", createdAt), - checkRequired("creditBlock", creditBlock), - checkRequired("currency", currency), - checkRequired("customer", customer), - checkRequired("description", description), - checkRequired("endingBalance", endingBalance), - checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), - checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), - checkRequired("metadata", metadata), - checkRequired("startingBalance", startingBalance), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class CreditBlock - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("expiry_date") - @ExcludeMissing - private val expiryDate: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - private val perUnitCostBasis: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun expiryDate(): Optional = - Optional.ofNullable(expiryDate.getNullable("expiry_date")) - - fun perUnitCostBasis(): Optional = - Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("expiry_date") - @ExcludeMissing - fun _expiryDate(): JsonField = expiryDate - - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - fun _perUnitCostBasis(): JsonField = perUnitCostBasis - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditBlock = apply { - if (validated) { - return@apply - } - - id() - expiryDate() - perUnitCostBasis() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditBlock]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var expiryDate: JsonField? = null - private var perUnitCostBasis: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditBlock: CreditBlock) = apply { - id = creditBlock.id - expiryDate = creditBlock.expiryDate - perUnitCostBasis = creditBlock.perUnitCostBasis - additionalProperties = creditBlock.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun expiryDate(expiryDate: OffsetDateTime?) = - expiryDate(JsonField.ofNullable(expiryDate)) - - fun expiryDate(expiryDate: Optional) = - expiryDate(expiryDate.orElse(null)) - - fun expiryDate(expiryDate: JsonField) = apply { - this.expiryDate = expiryDate - } - - fun perUnitCostBasis(perUnitCostBasis: String?) = - perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) - - fun perUnitCostBasis(perUnitCostBasis: Optional) = - perUnitCostBasis(perUnitCostBasis.orElse(null)) - - fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { - this.perUnitCostBasis = perUnitCostBasis - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditBlock = - CreditBlock( - checkRequired("id", id), - checkRequired("expiryDate", expiryDate), - checkRequired("perUnitCostBasis", perUnitCostBasis), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditBlock && id == other.id && expiryDate == other.expiryDate && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, expiryDate, perUnitCostBasis, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditBlock{id=$id, expiryDate=$expiryDate, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Customer - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("external_customer_id") - @ExcludeMissing - private val externalCustomerId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun externalCustomerId(): Optional = - Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("external_customer_id") - @ExcludeMissing - fun _externalCustomerId(): JsonField = externalCustomerId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Customer = apply { - if (validated) { - return@apply - } - - id() - externalCustomerId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Customer]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var externalCustomerId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customer: Customer) = apply { - id = customer.id - externalCustomerId = customer.externalCustomerId - additionalProperties = customer.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun externalCustomerId(externalCustomerId: String?) = - externalCustomerId(JsonField.ofNullable(externalCustomerId)) - - fun externalCustomerId(externalCustomerId: Optional) = - externalCustomerId(externalCustomerId.orElse(null)) - - fun externalCustomerId(externalCustomerId: JsonField) = apply { - this.externalCustomerId = externalCustomerId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Customer = - Customer( - checkRequired("id", id), - checkRequired("externalCustomerId", externalCustomerId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Customer && id == other.id && externalCustomerId == other.externalCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, externalCustomerId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Customer{id=$id, externalCustomerId=$externalCustomerId, additionalProperties=$additionalProperties}" - } - - class EntryStatus @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val COMMITTED = of("committed") - - @JvmField val PENDING = of("pending") - - @JvmStatic fun of(value: String) = EntryStatus(JsonField.of(value)) - } - - /** An enum containing [EntryStatus]'s known values. */ - enum class Known { - COMMITTED, - PENDING, - } - - /** - * An enum containing [EntryStatus]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryStatus] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - COMMITTED, - PENDING, - /** - * An enum member indicating that [EntryStatus] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - COMMITTED -> Value.COMMITTED - PENDING -> Value.PENDING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - COMMITTED -> Known.COMMITTED - PENDING -> Known.PENDING - else -> throw OrbInvalidDataException("Unknown EntryStatus: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryStatus && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val INCREMENT = of("increment") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - INCREMENT - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - INCREMENT, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - INCREMENT -> Value.INCREMENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - INCREMENT -> Known.INCREMENT - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is IncrementLedgerEntry && id == other.id && amount == other.amount && createdAt == other.createdAt && creditBlock == other.creditBlock && currency == other.currency && customer == other.customer && description == other.description && endingBalance == other.endingBalance && entryStatus == other.entryStatus && entryType == other.entryType && ledgerSequenceNumber == other.ledgerSequenceNumber && metadata == other.metadata && startingBalance == other.startingBalance && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, createdAt, creditBlock, currency, customer, description, endingBalance, entryStatus, entryType, ledgerSequenceNumber, metadata, startingBalance, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "IncrementLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class DecrementLedgerEntry - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("credit_block") - @ExcludeMissing - private val creditBlock: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("customer") - @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("ending_balance") - @ExcludeMissing - private val endingBalance: JsonField = JsonMissing.of(), - @JsonProperty("entry_status") - @ExcludeMissing - private val entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - private val entryType: JsonField = JsonMissing.of(), - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - private val ledgerSequenceNumber: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("starting_balance") - @ExcludeMissing - private val startingBalance: JsonField = JsonMissing.of(), - @JsonProperty("event_id") - @ExcludeMissing - private val eventId: JsonField = JsonMissing.of(), - @JsonProperty("invoice_id") - @ExcludeMissing - private val invoiceId: JsonField = JsonMissing.of(), - @JsonProperty("price_id") - @ExcludeMissing - private val priceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun amount(): Double = amount.getRequired("amount") - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - fun creditBlock(): CreditBlock = creditBlock.getRequired("credit_block") - - fun currency(): String = currency.getRequired("currency") - - fun customer(): Customer = customer.getRequired("customer") - - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - fun endingBalance(): Double = endingBalance.getRequired("ending_balance") - - fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") - - fun entryType(): EntryType = entryType.getRequired("entry_type") - - fun ledgerSequenceNumber(): Long = - ledgerSequenceNumber.getRequired("ledger_sequence_number") - - /** - * 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.getRequired("metadata") - - fun startingBalance(): Double = startingBalance.getRequired("starting_balance") - - fun eventId(): Optional = Optional.ofNullable(eventId.getNullable("event_id")) - - fun invoiceId(): Optional = Optional.ofNullable(invoiceId.getNullable("invoice_id")) - - fun priceId(): Optional = Optional.ofNullable(priceId.getNullable("price_id")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - @JsonProperty("credit_block") - @ExcludeMissing - fun _creditBlock(): JsonField = creditBlock - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - @JsonProperty("ending_balance") - @ExcludeMissing - fun _endingBalance(): JsonField = endingBalance - - @JsonProperty("entry_status") - @ExcludeMissing - fun _entryStatus(): JsonField = entryStatus - - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber - - /** - * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - @JsonProperty("starting_balance") - @ExcludeMissing - fun _startingBalance(): JsonField = startingBalance - - @JsonProperty("event_id") @ExcludeMissing fun _eventId(): JsonField = eventId - - @JsonProperty("invoice_id") @ExcludeMissing fun _invoiceId(): JsonField = invoiceId - - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): DecrementLedgerEntry = apply { - if (validated) { - return@apply - } - - id() - amount() - createdAt() - creditBlock().validate() - currency() - customer().validate() - description() - endingBalance() - entryStatus() - entryType() - ledgerSequenceNumber() - metadata().validate() - startingBalance() - eventId() - invoiceId() - priceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DecrementLedgerEntry]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var amount: JsonField? = null - private var createdAt: JsonField? = null - private var creditBlock: JsonField? = null - private var currency: JsonField? = null - private var customer: JsonField? = null - private var description: JsonField? = null - private var endingBalance: JsonField? = null - private var entryStatus: JsonField? = null - private var entryType: JsonField? = null - private var ledgerSequenceNumber: JsonField? = null - private var metadata: JsonField? = null - private var startingBalance: JsonField? = null - private var eventId: JsonField = JsonMissing.of() - private var invoiceId: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(decrementLedgerEntry: DecrementLedgerEntry) = apply { - id = decrementLedgerEntry.id - amount = decrementLedgerEntry.amount - createdAt = decrementLedgerEntry.createdAt - creditBlock = decrementLedgerEntry.creditBlock - currency = decrementLedgerEntry.currency - customer = decrementLedgerEntry.customer - description = decrementLedgerEntry.description - endingBalance = decrementLedgerEntry.endingBalance - entryStatus = decrementLedgerEntry.entryStatus - entryType = decrementLedgerEntry.entryType - ledgerSequenceNumber = decrementLedgerEntry.ledgerSequenceNumber - metadata = decrementLedgerEntry.metadata - startingBalance = decrementLedgerEntry.startingBalance - eventId = decrementLedgerEntry.eventId - invoiceId = decrementLedgerEntry.invoiceId - priceId = decrementLedgerEntry.priceId - additionalProperties = decrementLedgerEntry.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun amount(amount: Double) = amount(JsonField.of(amount)) - - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { - this.createdAt = createdAt - } - - fun creditBlock(creditBlock: CreditBlock) = creditBlock(JsonField.of(creditBlock)) - - fun creditBlock(creditBlock: JsonField) = apply { - this.creditBlock = creditBlock - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun customer(customer: Customer) = customer(JsonField.of(customer)) - - fun customer(customer: JsonField) = apply { this.customer = customer } - - fun description(description: String?) = description(JsonField.ofNullable(description)) - - fun description(description: Optional) = description(description.orElse(null)) - - fun description(description: JsonField) = apply { - this.description = description - } - - fun endingBalance(endingBalance: Double) = endingBalance(JsonField.of(endingBalance)) - - fun endingBalance(endingBalance: JsonField) = apply { - this.endingBalance = endingBalance - } - - fun entryStatus(entryStatus: EntryStatus) = entryStatus(JsonField.of(entryStatus)) - - fun entryStatus(entryStatus: JsonField) = apply { - this.entryStatus = entryStatus - } - - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } - - fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = - ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) - - fun ledgerSequenceNumber(ledgerSequenceNumber: JsonField) = apply { - this.ledgerSequenceNumber = ledgerSequenceNumber - } - - /** - * 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - fun startingBalance(startingBalance: Double) = - startingBalance(JsonField.of(startingBalance)) - - fun startingBalance(startingBalance: JsonField) = apply { - this.startingBalance = startingBalance - } - - fun eventId(eventId: String?) = eventId(JsonField.ofNullable(eventId)) - - fun eventId(eventId: Optional) = eventId(eventId.orElse(null)) - - fun eventId(eventId: JsonField) = apply { this.eventId = eventId } - - fun invoiceId(invoiceId: String?) = invoiceId(JsonField.ofNullable(invoiceId)) - - fun invoiceId(invoiceId: Optional) = invoiceId(invoiceId.orElse(null)) - - fun invoiceId(invoiceId: JsonField) = apply { this.invoiceId = invoiceId } - - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) - - fun priceId(priceId: Optional) = priceId(priceId.orElse(null)) - - 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) - } - - fun build(): DecrementLedgerEntry = - DecrementLedgerEntry( - checkRequired("id", id), - checkRequired("amount", amount), - checkRequired("createdAt", createdAt), - checkRequired("creditBlock", creditBlock), - checkRequired("currency", currency), - checkRequired("customer", customer), - checkRequired("description", description), - checkRequired("endingBalance", endingBalance), - checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), - checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), - checkRequired("metadata", metadata), - checkRequired("startingBalance", startingBalance), - eventId, - invoiceId, - priceId, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class CreditBlock - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("expiry_date") - @ExcludeMissing - private val expiryDate: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - private val perUnitCostBasis: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun expiryDate(): Optional = - Optional.ofNullable(expiryDate.getNullable("expiry_date")) - - fun perUnitCostBasis(): Optional = - Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("expiry_date") - @ExcludeMissing - fun _expiryDate(): JsonField = expiryDate - - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - fun _perUnitCostBasis(): JsonField = perUnitCostBasis - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditBlock = apply { - if (validated) { - return@apply - } - - id() - expiryDate() - perUnitCostBasis() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditBlock]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var expiryDate: JsonField? = null - private var perUnitCostBasis: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditBlock: CreditBlock) = apply { - id = creditBlock.id - expiryDate = creditBlock.expiryDate - perUnitCostBasis = creditBlock.perUnitCostBasis - additionalProperties = creditBlock.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun expiryDate(expiryDate: OffsetDateTime?) = - expiryDate(JsonField.ofNullable(expiryDate)) - - fun expiryDate(expiryDate: Optional) = - expiryDate(expiryDate.orElse(null)) - - fun expiryDate(expiryDate: JsonField) = apply { - this.expiryDate = expiryDate - } - - fun perUnitCostBasis(perUnitCostBasis: String?) = - perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) - - fun perUnitCostBasis(perUnitCostBasis: Optional) = - perUnitCostBasis(perUnitCostBasis.orElse(null)) - - fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { - this.perUnitCostBasis = perUnitCostBasis - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditBlock = - CreditBlock( - checkRequired("id", id), - checkRequired("expiryDate", expiryDate), - checkRequired("perUnitCostBasis", perUnitCostBasis), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditBlock && id == other.id && expiryDate == other.expiryDate && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, expiryDate, perUnitCostBasis, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditBlock{id=$id, expiryDate=$expiryDate, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Customer - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("external_customer_id") - @ExcludeMissing - private val externalCustomerId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun externalCustomerId(): Optional = - Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("external_customer_id") - @ExcludeMissing - fun _externalCustomerId(): JsonField = externalCustomerId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Customer = apply { - if (validated) { - return@apply - } - - id() - externalCustomerId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Customer]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var externalCustomerId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customer: Customer) = apply { - id = customer.id - externalCustomerId = customer.externalCustomerId - additionalProperties = customer.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun externalCustomerId(externalCustomerId: String?) = - externalCustomerId(JsonField.ofNullable(externalCustomerId)) - - fun externalCustomerId(externalCustomerId: Optional) = - externalCustomerId(externalCustomerId.orElse(null)) - - fun externalCustomerId(externalCustomerId: JsonField) = apply { - this.externalCustomerId = externalCustomerId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Customer = - Customer( - checkRequired("id", id), - checkRequired("externalCustomerId", externalCustomerId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Customer && id == other.id && externalCustomerId == other.externalCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, externalCustomerId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Customer{id=$id, externalCustomerId=$externalCustomerId, additionalProperties=$additionalProperties}" - } - - class EntryStatus @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val COMMITTED = of("committed") - - @JvmField val PENDING = of("pending") - - @JvmStatic fun of(value: String) = EntryStatus(JsonField.of(value)) - } - - /** An enum containing [EntryStatus]'s known values. */ - enum class Known { - COMMITTED, - PENDING, - } - - /** - * An enum containing [EntryStatus]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryStatus] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - COMMITTED, - PENDING, - /** - * An enum member indicating that [EntryStatus] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - COMMITTED -> Value.COMMITTED - PENDING -> Value.PENDING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - COMMITTED -> Known.COMMITTED - PENDING -> Known.PENDING - else -> throw OrbInvalidDataException("Unknown EntryStatus: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryStatus && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DECREMENT = of("decrement") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - DECREMENT - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DECREMENT, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DECREMENT -> Value.DECREMENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - DECREMENT -> Known.DECREMENT - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DecrementLedgerEntry && id == other.id && amount == other.amount && createdAt == other.createdAt && creditBlock == other.creditBlock && currency == other.currency && customer == other.customer && description == other.description && endingBalance == other.endingBalance && entryStatus == other.entryStatus && entryType == other.entryType && ledgerSequenceNumber == other.ledgerSequenceNumber && metadata == other.metadata && startingBalance == other.startingBalance && eventId == other.eventId && invoiceId == other.invoiceId && priceId == other.priceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, createdAt, creditBlock, currency, customer, description, endingBalance, entryStatus, entryType, ledgerSequenceNumber, metadata, startingBalance, eventId, invoiceId, priceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DecrementLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, eventId=$eventId, invoiceId=$invoiceId, priceId=$priceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class ExpirationChangeLedgerEntry - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("credit_block") - @ExcludeMissing - private val creditBlock: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("customer") - @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("ending_balance") - @ExcludeMissing - private val endingBalance: JsonField = JsonMissing.of(), - @JsonProperty("entry_status") - @ExcludeMissing - private val entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - private val entryType: JsonField = JsonMissing.of(), - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - private val ledgerSequenceNumber: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("new_block_expiry_date") - @ExcludeMissing - private val newBlockExpiryDate: JsonField = JsonMissing.of(), - @JsonProperty("starting_balance") - @ExcludeMissing - private val startingBalance: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun amount(): Double = amount.getRequired("amount") - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - fun creditBlock(): CreditBlock = creditBlock.getRequired("credit_block") - - fun currency(): String = currency.getRequired("currency") - - fun customer(): Customer = customer.getRequired("customer") - - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - fun endingBalance(): Double = endingBalance.getRequired("ending_balance") - - fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") - - fun entryType(): EntryType = entryType.getRequired("entry_type") - - fun ledgerSequenceNumber(): Long = - ledgerSequenceNumber.getRequired("ledger_sequence_number") - - /** - * 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.getRequired("metadata") - - fun newBlockExpiryDate(): Optional = - Optional.ofNullable(newBlockExpiryDate.getNullable("new_block_expiry_date")) - - fun startingBalance(): Double = startingBalance.getRequired("starting_balance") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - @JsonProperty("credit_block") - @ExcludeMissing - fun _creditBlock(): JsonField = creditBlock - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - @JsonProperty("ending_balance") - @ExcludeMissing - fun _endingBalance(): JsonField = endingBalance - - @JsonProperty("entry_status") - @ExcludeMissing - fun _entryStatus(): JsonField = entryStatus - - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber - - /** - * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - @JsonProperty("new_block_expiry_date") - @ExcludeMissing - fun _newBlockExpiryDate(): JsonField = newBlockExpiryDate - - @JsonProperty("starting_balance") - @ExcludeMissing - fun _startingBalance(): JsonField = startingBalance - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): ExpirationChangeLedgerEntry = apply { - if (validated) { - return@apply - } - - id() - amount() - createdAt() - creditBlock().validate() - currency() - customer().validate() - description() - endingBalance() - entryStatus() - entryType() - ledgerSequenceNumber() - metadata().validate() - newBlockExpiryDate() - startingBalance() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ExpirationChangeLedgerEntry]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var amount: JsonField? = null - private var createdAt: JsonField? = null - private var creditBlock: JsonField? = null - private var currency: JsonField? = null - private var customer: JsonField? = null - private var description: JsonField? = null - private var endingBalance: JsonField? = null - private var entryStatus: JsonField? = null - private var entryType: JsonField? = null - private var ledgerSequenceNumber: JsonField? = null - private var metadata: JsonField? = null - private var newBlockExpiryDate: JsonField? = null - private var startingBalance: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(expirationChangeLedgerEntry: ExpirationChangeLedgerEntry) = apply { - id = expirationChangeLedgerEntry.id - amount = expirationChangeLedgerEntry.amount - createdAt = expirationChangeLedgerEntry.createdAt - creditBlock = expirationChangeLedgerEntry.creditBlock - currency = expirationChangeLedgerEntry.currency - customer = expirationChangeLedgerEntry.customer - description = expirationChangeLedgerEntry.description - endingBalance = expirationChangeLedgerEntry.endingBalance - entryStatus = expirationChangeLedgerEntry.entryStatus - entryType = expirationChangeLedgerEntry.entryType - ledgerSequenceNumber = expirationChangeLedgerEntry.ledgerSequenceNumber - metadata = expirationChangeLedgerEntry.metadata - newBlockExpiryDate = expirationChangeLedgerEntry.newBlockExpiryDate - startingBalance = expirationChangeLedgerEntry.startingBalance - additionalProperties = - expirationChangeLedgerEntry.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun amount(amount: Double) = amount(JsonField.of(amount)) - - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { - this.createdAt = createdAt - } - - fun creditBlock(creditBlock: CreditBlock) = creditBlock(JsonField.of(creditBlock)) - - fun creditBlock(creditBlock: JsonField) = apply { - this.creditBlock = creditBlock - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun customer(customer: Customer) = customer(JsonField.of(customer)) - - fun customer(customer: JsonField) = apply { this.customer = customer } - - fun description(description: String?) = description(JsonField.ofNullable(description)) - - fun description(description: Optional) = description(description.orElse(null)) - - fun description(description: JsonField) = apply { - this.description = description - } - - fun endingBalance(endingBalance: Double) = endingBalance(JsonField.of(endingBalance)) - - fun endingBalance(endingBalance: JsonField) = apply { - this.endingBalance = endingBalance - } - - fun entryStatus(entryStatus: EntryStatus) = entryStatus(JsonField.of(entryStatus)) - - fun entryStatus(entryStatus: JsonField) = apply { - this.entryStatus = entryStatus - } - - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } - - fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = - ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) - - fun ledgerSequenceNumber(ledgerSequenceNumber: JsonField) = apply { - this.ledgerSequenceNumber = ledgerSequenceNumber - } - - /** - * 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - fun newBlockExpiryDate(newBlockExpiryDate: OffsetDateTime?) = - newBlockExpiryDate(JsonField.ofNullable(newBlockExpiryDate)) - - fun newBlockExpiryDate(newBlockExpiryDate: Optional) = - newBlockExpiryDate(newBlockExpiryDate.orElse(null)) - - fun newBlockExpiryDate(newBlockExpiryDate: JsonField) = apply { - this.newBlockExpiryDate = newBlockExpiryDate - } - - fun startingBalance(startingBalance: Double) = - startingBalance(JsonField.of(startingBalance)) - - fun startingBalance(startingBalance: JsonField) = apply { - this.startingBalance = startingBalance - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): ExpirationChangeLedgerEntry = - ExpirationChangeLedgerEntry( - checkRequired("id", id), - checkRequired("amount", amount), - checkRequired("createdAt", createdAt), - checkRequired("creditBlock", creditBlock), - checkRequired("currency", currency), - checkRequired("customer", customer), - checkRequired("description", description), - checkRequired("endingBalance", endingBalance), - checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), - checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), - checkRequired("metadata", metadata), - checkRequired("newBlockExpiryDate", newBlockExpiryDate), - checkRequired("startingBalance", startingBalance), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class CreditBlock - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("expiry_date") - @ExcludeMissing - private val expiryDate: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - private val perUnitCostBasis: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun expiryDate(): Optional = - Optional.ofNullable(expiryDate.getNullable("expiry_date")) - - fun perUnitCostBasis(): Optional = - Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("expiry_date") - @ExcludeMissing - fun _expiryDate(): JsonField = expiryDate - - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - fun _perUnitCostBasis(): JsonField = perUnitCostBasis - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditBlock = apply { - if (validated) { - return@apply - } - - id() - expiryDate() - perUnitCostBasis() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditBlock]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var expiryDate: JsonField? = null - private var perUnitCostBasis: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditBlock: CreditBlock) = apply { - id = creditBlock.id - expiryDate = creditBlock.expiryDate - perUnitCostBasis = creditBlock.perUnitCostBasis - additionalProperties = creditBlock.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun expiryDate(expiryDate: OffsetDateTime?) = - expiryDate(JsonField.ofNullable(expiryDate)) - - fun expiryDate(expiryDate: Optional) = - expiryDate(expiryDate.orElse(null)) - - fun expiryDate(expiryDate: JsonField) = apply { - this.expiryDate = expiryDate - } - - fun perUnitCostBasis(perUnitCostBasis: String?) = - perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) - - fun perUnitCostBasis(perUnitCostBasis: Optional) = - perUnitCostBasis(perUnitCostBasis.orElse(null)) - - fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { - this.perUnitCostBasis = perUnitCostBasis - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditBlock = - CreditBlock( - checkRequired("id", id), - checkRequired("expiryDate", expiryDate), - checkRequired("perUnitCostBasis", perUnitCostBasis), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditBlock && id == other.id && expiryDate == other.expiryDate && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, expiryDate, perUnitCostBasis, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditBlock{id=$id, expiryDate=$expiryDate, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Customer - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("external_customer_id") - @ExcludeMissing - private val externalCustomerId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun externalCustomerId(): Optional = - Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("external_customer_id") - @ExcludeMissing - fun _externalCustomerId(): JsonField = externalCustomerId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Customer = apply { - if (validated) { - return@apply - } - - id() - externalCustomerId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Customer]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var externalCustomerId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customer: Customer) = apply { - id = customer.id - externalCustomerId = customer.externalCustomerId - additionalProperties = customer.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun externalCustomerId(externalCustomerId: String?) = - externalCustomerId(JsonField.ofNullable(externalCustomerId)) - - fun externalCustomerId(externalCustomerId: Optional) = - externalCustomerId(externalCustomerId.orElse(null)) - - fun externalCustomerId(externalCustomerId: JsonField) = apply { - this.externalCustomerId = externalCustomerId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Customer = - Customer( - checkRequired("id", id), - checkRequired("externalCustomerId", externalCustomerId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Customer && id == other.id && externalCustomerId == other.externalCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, externalCustomerId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Customer{id=$id, externalCustomerId=$externalCustomerId, additionalProperties=$additionalProperties}" - } - - class EntryStatus @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val COMMITTED = of("committed") - - @JvmField val PENDING = of("pending") - - @JvmStatic fun of(value: String) = EntryStatus(JsonField.of(value)) - } - - /** An enum containing [EntryStatus]'s known values. */ - enum class Known { - COMMITTED, - PENDING, - } - - /** - * An enum containing [EntryStatus]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryStatus] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - COMMITTED, - PENDING, - /** - * An enum member indicating that [EntryStatus] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - COMMITTED -> Value.COMMITTED - PENDING -> Value.PENDING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - COMMITTED -> Known.COMMITTED - PENDING -> Known.PENDING - else -> throw OrbInvalidDataException("Unknown EntryStatus: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryStatus && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val EXPIRATION_CHANGE = of("expiration_change") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - EXPIRATION_CHANGE - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - EXPIRATION_CHANGE, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - EXPIRATION_CHANGE -> Value.EXPIRATION_CHANGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - EXPIRATION_CHANGE -> Known.EXPIRATION_CHANGE - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ExpirationChangeLedgerEntry && id == other.id && amount == other.amount && createdAt == other.createdAt && creditBlock == other.creditBlock && currency == other.currency && customer == other.customer && description == other.description && endingBalance == other.endingBalance && entryStatus == other.entryStatus && entryType == other.entryType && ledgerSequenceNumber == other.ledgerSequenceNumber && metadata == other.metadata && newBlockExpiryDate == other.newBlockExpiryDate && startingBalance == other.startingBalance && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, createdAt, creditBlock, currency, customer, description, endingBalance, entryStatus, entryType, ledgerSequenceNumber, metadata, newBlockExpiryDate, startingBalance, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ExpirationChangeLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, newBlockExpiryDate=$newBlockExpiryDate, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class CreditBlockExpiryLedgerEntry - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("credit_block") - @ExcludeMissing - private val creditBlock: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("customer") - @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("ending_balance") - @ExcludeMissing - private val endingBalance: JsonField = JsonMissing.of(), - @JsonProperty("entry_status") - @ExcludeMissing - private val entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - private val entryType: JsonField = JsonMissing.of(), - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - private val ledgerSequenceNumber: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("starting_balance") - @ExcludeMissing - private val startingBalance: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun amount(): Double = amount.getRequired("amount") - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - fun creditBlock(): CreditBlock = creditBlock.getRequired("credit_block") - - fun currency(): String = currency.getRequired("currency") - - fun customer(): Customer = customer.getRequired("customer") - - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - fun endingBalance(): Double = endingBalance.getRequired("ending_balance") - - fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") - - fun entryType(): EntryType = entryType.getRequired("entry_type") - - fun ledgerSequenceNumber(): Long = - ledgerSequenceNumber.getRequired("ledger_sequence_number") - - /** - * 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.getRequired("metadata") - - fun startingBalance(): Double = startingBalance.getRequired("starting_balance") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - @JsonProperty("credit_block") - @ExcludeMissing - fun _creditBlock(): JsonField = creditBlock - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - @JsonProperty("ending_balance") - @ExcludeMissing - fun _endingBalance(): JsonField = endingBalance - - @JsonProperty("entry_status") - @ExcludeMissing - fun _entryStatus(): JsonField = entryStatus - - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber - - /** - * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - @JsonProperty("starting_balance") - @ExcludeMissing - fun _startingBalance(): JsonField = startingBalance - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditBlockExpiryLedgerEntry = apply { - if (validated) { - return@apply - } - - id() - amount() - createdAt() - creditBlock().validate() - currency() - customer().validate() - description() - endingBalance() - entryStatus() - entryType() - ledgerSequenceNumber() - metadata().validate() - startingBalance() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditBlockExpiryLedgerEntry]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var amount: JsonField? = null - private var createdAt: JsonField? = null - private var creditBlock: JsonField? = null - private var currency: JsonField? = null - private var customer: JsonField? = null - private var description: JsonField? = null - private var endingBalance: JsonField? = null - private var entryStatus: JsonField? = null - private var entryType: JsonField? = null - private var ledgerSequenceNumber: JsonField? = null - private var metadata: JsonField? = null - private var startingBalance: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry) = apply { - id = creditBlockExpiryLedgerEntry.id - amount = creditBlockExpiryLedgerEntry.amount - createdAt = creditBlockExpiryLedgerEntry.createdAt - creditBlock = creditBlockExpiryLedgerEntry.creditBlock - currency = creditBlockExpiryLedgerEntry.currency - customer = creditBlockExpiryLedgerEntry.customer - description = creditBlockExpiryLedgerEntry.description - endingBalance = creditBlockExpiryLedgerEntry.endingBalance - entryStatus = creditBlockExpiryLedgerEntry.entryStatus - entryType = creditBlockExpiryLedgerEntry.entryType - ledgerSequenceNumber = creditBlockExpiryLedgerEntry.ledgerSequenceNumber - metadata = creditBlockExpiryLedgerEntry.metadata - startingBalance = creditBlockExpiryLedgerEntry.startingBalance - additionalProperties = - creditBlockExpiryLedgerEntry.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun amount(amount: Double) = amount(JsonField.of(amount)) - - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { - this.createdAt = createdAt - } - - fun creditBlock(creditBlock: CreditBlock) = creditBlock(JsonField.of(creditBlock)) - - fun creditBlock(creditBlock: JsonField) = apply { - this.creditBlock = creditBlock - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun customer(customer: Customer) = customer(JsonField.of(customer)) - - fun customer(customer: JsonField) = apply { this.customer = customer } - - fun description(description: String?) = description(JsonField.ofNullable(description)) - - fun description(description: Optional) = description(description.orElse(null)) - - fun description(description: JsonField) = apply { - this.description = description - } - - fun endingBalance(endingBalance: Double) = endingBalance(JsonField.of(endingBalance)) - - fun endingBalance(endingBalance: JsonField) = apply { - this.endingBalance = endingBalance - } - - fun entryStatus(entryStatus: EntryStatus) = entryStatus(JsonField.of(entryStatus)) - - fun entryStatus(entryStatus: JsonField) = apply { - this.entryStatus = entryStatus - } - - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } - - fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = - ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) - - fun ledgerSequenceNumber(ledgerSequenceNumber: JsonField) = apply { - this.ledgerSequenceNumber = ledgerSequenceNumber - } - - /** - * 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - fun startingBalance(startingBalance: Double) = - startingBalance(JsonField.of(startingBalance)) - - fun startingBalance(startingBalance: JsonField) = apply { - this.startingBalance = startingBalance - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditBlockExpiryLedgerEntry = - CreditBlockExpiryLedgerEntry( - checkRequired("id", id), - checkRequired("amount", amount), - checkRequired("createdAt", createdAt), - checkRequired("creditBlock", creditBlock), - checkRequired("currency", currency), - checkRequired("customer", customer), - checkRequired("description", description), - checkRequired("endingBalance", endingBalance), - checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), - checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), - checkRequired("metadata", metadata), - checkRequired("startingBalance", startingBalance), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class CreditBlock - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("expiry_date") - @ExcludeMissing - private val expiryDate: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - private val perUnitCostBasis: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun expiryDate(): Optional = - Optional.ofNullable(expiryDate.getNullable("expiry_date")) - - fun perUnitCostBasis(): Optional = - Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("expiry_date") - @ExcludeMissing - fun _expiryDate(): JsonField = expiryDate - - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - fun _perUnitCostBasis(): JsonField = perUnitCostBasis - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditBlock = apply { - if (validated) { - return@apply - } - - id() - expiryDate() - perUnitCostBasis() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditBlock]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var expiryDate: JsonField? = null - private var perUnitCostBasis: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditBlock: CreditBlock) = apply { - id = creditBlock.id - expiryDate = creditBlock.expiryDate - perUnitCostBasis = creditBlock.perUnitCostBasis - additionalProperties = creditBlock.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun expiryDate(expiryDate: OffsetDateTime?) = - expiryDate(JsonField.ofNullable(expiryDate)) - - fun expiryDate(expiryDate: Optional) = - expiryDate(expiryDate.orElse(null)) - - fun expiryDate(expiryDate: JsonField) = apply { - this.expiryDate = expiryDate - } - - fun perUnitCostBasis(perUnitCostBasis: String?) = - perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) - - fun perUnitCostBasis(perUnitCostBasis: Optional) = - perUnitCostBasis(perUnitCostBasis.orElse(null)) - - fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { - this.perUnitCostBasis = perUnitCostBasis - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditBlock = - CreditBlock( - checkRequired("id", id), - checkRequired("expiryDate", expiryDate), - checkRequired("perUnitCostBasis", perUnitCostBasis), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditBlock && id == other.id && expiryDate == other.expiryDate && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, expiryDate, perUnitCostBasis, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditBlock{id=$id, expiryDate=$expiryDate, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Customer - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("external_customer_id") - @ExcludeMissing - private val externalCustomerId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun externalCustomerId(): Optional = - Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("external_customer_id") - @ExcludeMissing - fun _externalCustomerId(): JsonField = externalCustomerId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Customer = apply { - if (validated) { - return@apply - } - - id() - externalCustomerId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Customer]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var externalCustomerId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customer: Customer) = apply { - id = customer.id - externalCustomerId = customer.externalCustomerId - additionalProperties = customer.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun externalCustomerId(externalCustomerId: String?) = - externalCustomerId(JsonField.ofNullable(externalCustomerId)) - - fun externalCustomerId(externalCustomerId: Optional) = - externalCustomerId(externalCustomerId.orElse(null)) - - fun externalCustomerId(externalCustomerId: JsonField) = apply { - this.externalCustomerId = externalCustomerId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Customer = - Customer( - checkRequired("id", id), - checkRequired("externalCustomerId", externalCustomerId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Customer && id == other.id && externalCustomerId == other.externalCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, externalCustomerId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Customer{id=$id, externalCustomerId=$externalCustomerId, additionalProperties=$additionalProperties}" - } - - class EntryStatus @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val COMMITTED = of("committed") - - @JvmField val PENDING = of("pending") - - @JvmStatic fun of(value: String) = EntryStatus(JsonField.of(value)) - } - - /** An enum containing [EntryStatus]'s known values. */ - enum class Known { - COMMITTED, - PENDING, - } - - /** - * An enum containing [EntryStatus]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryStatus] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - COMMITTED, - PENDING, - /** - * An enum member indicating that [EntryStatus] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - COMMITTED -> Value.COMMITTED - PENDING -> Value.PENDING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - COMMITTED -> Known.COMMITTED - PENDING -> Known.PENDING - else -> throw OrbInvalidDataException("Unknown EntryStatus: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryStatus && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val CREDIT_BLOCK_EXPIRY = of("credit_block_expiry") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - CREDIT_BLOCK_EXPIRY - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - CREDIT_BLOCK_EXPIRY, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - CREDIT_BLOCK_EXPIRY -> Value.CREDIT_BLOCK_EXPIRY - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - CREDIT_BLOCK_EXPIRY -> Known.CREDIT_BLOCK_EXPIRY - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditBlockExpiryLedgerEntry && id == other.id && amount == other.amount && createdAt == other.createdAt && creditBlock == other.creditBlock && currency == other.currency && customer == other.customer && description == other.description && endingBalance == other.endingBalance && entryStatus == other.entryStatus && entryType == other.entryType && ledgerSequenceNumber == other.ledgerSequenceNumber && metadata == other.metadata && startingBalance == other.startingBalance && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, createdAt, creditBlock, currency, customer, description, endingBalance, entryStatus, entryType, ledgerSequenceNumber, metadata, startingBalance, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditBlockExpiryLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class VoidLedgerEntry - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("credit_block") - @ExcludeMissing - private val creditBlock: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("customer") - @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("ending_balance") - @ExcludeMissing - private val endingBalance: JsonField = JsonMissing.of(), - @JsonProperty("entry_status") - @ExcludeMissing - private val entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - private val entryType: JsonField = JsonMissing.of(), - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - private val ledgerSequenceNumber: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("starting_balance") - @ExcludeMissing - private val startingBalance: JsonField = JsonMissing.of(), - @JsonProperty("void_amount") - @ExcludeMissing - private val voidAmount: JsonField = JsonMissing.of(), - @JsonProperty("void_reason") - @ExcludeMissing - private val voidReason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun amount(): Double = amount.getRequired("amount") - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - fun creditBlock(): CreditBlock = creditBlock.getRequired("credit_block") - - fun currency(): String = currency.getRequired("currency") - - fun customer(): Customer = customer.getRequired("customer") - - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - fun endingBalance(): Double = endingBalance.getRequired("ending_balance") - - fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") - - fun entryType(): EntryType = entryType.getRequired("entry_type") - - fun ledgerSequenceNumber(): Long = - ledgerSequenceNumber.getRequired("ledger_sequence_number") - - /** - * 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.getRequired("metadata") - - fun startingBalance(): Double = startingBalance.getRequired("starting_balance") - - fun voidAmount(): Double = voidAmount.getRequired("void_amount") - - fun voidReason(): Optional = - Optional.ofNullable(voidReason.getNullable("void_reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - @JsonProperty("credit_block") - @ExcludeMissing - fun _creditBlock(): JsonField = creditBlock - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - @JsonProperty("ending_balance") - @ExcludeMissing - fun _endingBalance(): JsonField = endingBalance - - @JsonProperty("entry_status") - @ExcludeMissing - fun _entryStatus(): JsonField = entryStatus - - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber - - /** - * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - @JsonProperty("starting_balance") - @ExcludeMissing - fun _startingBalance(): JsonField = startingBalance - - @JsonProperty("void_amount") - @ExcludeMissing - fun _voidAmount(): JsonField = voidAmount - - @JsonProperty("void_reason") - @ExcludeMissing - fun _voidReason(): JsonField = voidReason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): VoidLedgerEntry = apply { - if (validated) { - return@apply - } - - id() - amount() - createdAt() - creditBlock().validate() - currency() - customer().validate() - description() - endingBalance() - entryStatus() - entryType() - ledgerSequenceNumber() - metadata().validate() - startingBalance() - voidAmount() - voidReason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [VoidLedgerEntry]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var amount: JsonField? = null - private var createdAt: JsonField? = null - private var creditBlock: JsonField? = null - private var currency: JsonField? = null - private var customer: JsonField? = null - private var description: JsonField? = null - private var endingBalance: JsonField? = null - private var entryStatus: JsonField? = null - private var entryType: JsonField? = null - private var ledgerSequenceNumber: JsonField? = null - private var metadata: JsonField? = null - private var startingBalance: JsonField? = null - private var voidAmount: JsonField? = null - private var voidReason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(voidLedgerEntry: VoidLedgerEntry) = apply { - id = voidLedgerEntry.id - amount = voidLedgerEntry.amount - createdAt = voidLedgerEntry.createdAt - creditBlock = voidLedgerEntry.creditBlock - currency = voidLedgerEntry.currency - customer = voidLedgerEntry.customer - description = voidLedgerEntry.description - endingBalance = voidLedgerEntry.endingBalance - entryStatus = voidLedgerEntry.entryStatus - entryType = voidLedgerEntry.entryType - ledgerSequenceNumber = voidLedgerEntry.ledgerSequenceNumber - metadata = voidLedgerEntry.metadata - startingBalance = voidLedgerEntry.startingBalance - voidAmount = voidLedgerEntry.voidAmount - voidReason = voidLedgerEntry.voidReason - additionalProperties = voidLedgerEntry.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun amount(amount: Double) = amount(JsonField.of(amount)) - - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { - this.createdAt = createdAt - } - - fun creditBlock(creditBlock: CreditBlock) = creditBlock(JsonField.of(creditBlock)) - - fun creditBlock(creditBlock: JsonField) = apply { - this.creditBlock = creditBlock - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun customer(customer: Customer) = customer(JsonField.of(customer)) - - fun customer(customer: JsonField) = apply { this.customer = customer } - - fun description(description: String?) = description(JsonField.ofNullable(description)) - - fun description(description: Optional) = description(description.orElse(null)) - - fun description(description: JsonField) = apply { - this.description = description - } - - fun endingBalance(endingBalance: Double) = endingBalance(JsonField.of(endingBalance)) - - fun endingBalance(endingBalance: JsonField) = apply { - this.endingBalance = endingBalance - } - - fun entryStatus(entryStatus: EntryStatus) = entryStatus(JsonField.of(entryStatus)) - - fun entryStatus(entryStatus: JsonField) = apply { - this.entryStatus = entryStatus - } - - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } - - fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = - ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) - - fun ledgerSequenceNumber(ledgerSequenceNumber: JsonField) = apply { - this.ledgerSequenceNumber = ledgerSequenceNumber - } - - /** - * 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - fun startingBalance(startingBalance: Double) = - startingBalance(JsonField.of(startingBalance)) - - fun startingBalance(startingBalance: JsonField) = apply { - this.startingBalance = startingBalance - } - - fun voidAmount(voidAmount: Double) = voidAmount(JsonField.of(voidAmount)) - - fun voidAmount(voidAmount: JsonField) = apply { this.voidAmount = voidAmount } - - fun voidReason(voidReason: String?) = voidReason(JsonField.ofNullable(voidReason)) - - fun voidReason(voidReason: Optional) = voidReason(voidReason.orElse(null)) - - fun voidReason(voidReason: JsonField) = apply { this.voidReason = voidReason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): VoidLedgerEntry = - VoidLedgerEntry( - checkRequired("id", id), - checkRequired("amount", amount), - checkRequired("createdAt", createdAt), - checkRequired("creditBlock", creditBlock), - checkRequired("currency", currency), - checkRequired("customer", customer), - checkRequired("description", description), - checkRequired("endingBalance", endingBalance), - checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), - checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), - checkRequired("metadata", metadata), - checkRequired("startingBalance", startingBalance), - checkRequired("voidAmount", voidAmount), - checkRequired("voidReason", voidReason), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class CreditBlock - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("expiry_date") - @ExcludeMissing - private val expiryDate: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - private val perUnitCostBasis: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun expiryDate(): Optional = - Optional.ofNullable(expiryDate.getNullable("expiry_date")) - - fun perUnitCostBasis(): Optional = - Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("expiry_date") - @ExcludeMissing - fun _expiryDate(): JsonField = expiryDate - - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - fun _perUnitCostBasis(): JsonField = perUnitCostBasis - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditBlock = apply { - if (validated) { - return@apply - } - - id() - expiryDate() - perUnitCostBasis() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditBlock]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var expiryDate: JsonField? = null - private var perUnitCostBasis: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditBlock: CreditBlock) = apply { - id = creditBlock.id - expiryDate = creditBlock.expiryDate - perUnitCostBasis = creditBlock.perUnitCostBasis - additionalProperties = creditBlock.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun expiryDate(expiryDate: OffsetDateTime?) = - expiryDate(JsonField.ofNullable(expiryDate)) - - fun expiryDate(expiryDate: Optional) = - expiryDate(expiryDate.orElse(null)) - - fun expiryDate(expiryDate: JsonField) = apply { - this.expiryDate = expiryDate - } - - fun perUnitCostBasis(perUnitCostBasis: String?) = - perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) - - fun perUnitCostBasis(perUnitCostBasis: Optional) = - perUnitCostBasis(perUnitCostBasis.orElse(null)) - - fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { - this.perUnitCostBasis = perUnitCostBasis - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditBlock = - CreditBlock( - checkRequired("id", id), - checkRequired("expiryDate", expiryDate), - checkRequired("perUnitCostBasis", perUnitCostBasis), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditBlock && id == other.id && expiryDate == other.expiryDate && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, expiryDate, perUnitCostBasis, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditBlock{id=$id, expiryDate=$expiryDate, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Customer - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("external_customer_id") - @ExcludeMissing - private val externalCustomerId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun externalCustomerId(): Optional = - Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("external_customer_id") - @ExcludeMissing - fun _externalCustomerId(): JsonField = externalCustomerId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Customer = apply { - if (validated) { - return@apply - } - - id() - externalCustomerId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Customer]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var externalCustomerId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customer: Customer) = apply { - id = customer.id - externalCustomerId = customer.externalCustomerId - additionalProperties = customer.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun externalCustomerId(externalCustomerId: String?) = - externalCustomerId(JsonField.ofNullable(externalCustomerId)) - - fun externalCustomerId(externalCustomerId: Optional) = - externalCustomerId(externalCustomerId.orElse(null)) - - fun externalCustomerId(externalCustomerId: JsonField) = apply { - this.externalCustomerId = externalCustomerId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Customer = - Customer( - checkRequired("id", id), - checkRequired("externalCustomerId", externalCustomerId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Customer && id == other.id && externalCustomerId == other.externalCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, externalCustomerId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Customer{id=$id, externalCustomerId=$externalCustomerId, additionalProperties=$additionalProperties}" - } - - class EntryStatus @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val COMMITTED = of("committed") - - @JvmField val PENDING = of("pending") - - @JvmStatic fun of(value: String) = EntryStatus(JsonField.of(value)) - } - - /** An enum containing [EntryStatus]'s known values. */ - enum class Known { - COMMITTED, - PENDING, - } - - /** - * An enum containing [EntryStatus]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryStatus] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - COMMITTED, - PENDING, - /** - * An enum member indicating that [EntryStatus] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - COMMITTED -> Value.COMMITTED - PENDING -> Value.PENDING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - COMMITTED -> Known.COMMITTED - PENDING -> Known.PENDING - else -> throw OrbInvalidDataException("Unknown EntryStatus: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryStatus && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val VOID = of("void") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - VOID - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - VOID, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - VOID -> Value.VOID - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - VOID -> Known.VOID - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is VoidLedgerEntry && id == other.id && amount == other.amount && createdAt == other.createdAt && creditBlock == other.creditBlock && currency == other.currency && customer == other.customer && description == other.description && endingBalance == other.endingBalance && entryStatus == other.entryStatus && entryType == other.entryType && ledgerSequenceNumber == other.ledgerSequenceNumber && metadata == other.metadata && startingBalance == other.startingBalance && voidAmount == other.voidAmount && voidReason == other.voidReason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, createdAt, creditBlock, currency, customer, description, endingBalance, entryStatus, entryType, ledgerSequenceNumber, metadata, startingBalance, voidAmount, voidReason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "VoidLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, voidAmount=$voidAmount, voidReason=$voidReason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class VoidInitiatedLedgerEntry - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("credit_block") - @ExcludeMissing - private val creditBlock: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("customer") - @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("ending_balance") - @ExcludeMissing - private val endingBalance: JsonField = JsonMissing.of(), - @JsonProperty("entry_status") - @ExcludeMissing - private val entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - private val entryType: JsonField = JsonMissing.of(), - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - private val ledgerSequenceNumber: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("new_block_expiry_date") - @ExcludeMissing - private val newBlockExpiryDate: JsonField = JsonMissing.of(), - @JsonProperty("starting_balance") - @ExcludeMissing - private val startingBalance: JsonField = JsonMissing.of(), - @JsonProperty("void_amount") - @ExcludeMissing - private val voidAmount: JsonField = JsonMissing.of(), - @JsonProperty("void_reason") - @ExcludeMissing - private val voidReason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun amount(): Double = amount.getRequired("amount") - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - fun creditBlock(): CreditBlock = creditBlock.getRequired("credit_block") - - fun currency(): String = currency.getRequired("currency") - - fun customer(): Customer = customer.getRequired("customer") - - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - fun endingBalance(): Double = endingBalance.getRequired("ending_balance") - - fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") - - fun entryType(): EntryType = entryType.getRequired("entry_type") - - fun ledgerSequenceNumber(): Long = - ledgerSequenceNumber.getRequired("ledger_sequence_number") - - /** - * 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.getRequired("metadata") - - fun newBlockExpiryDate(): OffsetDateTime = - newBlockExpiryDate.getRequired("new_block_expiry_date") - - fun startingBalance(): Double = startingBalance.getRequired("starting_balance") - - fun voidAmount(): Double = voidAmount.getRequired("void_amount") - - fun voidReason(): Optional = - Optional.ofNullable(voidReason.getNullable("void_reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - @JsonProperty("credit_block") - @ExcludeMissing - fun _creditBlock(): JsonField = creditBlock - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - @JsonProperty("ending_balance") - @ExcludeMissing - fun _endingBalance(): JsonField = endingBalance - - @JsonProperty("entry_status") - @ExcludeMissing - fun _entryStatus(): JsonField = entryStatus - - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber - - /** - * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - @JsonProperty("new_block_expiry_date") - @ExcludeMissing - fun _newBlockExpiryDate(): JsonField = newBlockExpiryDate - - @JsonProperty("starting_balance") - @ExcludeMissing - fun _startingBalance(): JsonField = startingBalance - - @JsonProperty("void_amount") - @ExcludeMissing - fun _voidAmount(): JsonField = voidAmount - - @JsonProperty("void_reason") - @ExcludeMissing - fun _voidReason(): JsonField = voidReason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): VoidInitiatedLedgerEntry = apply { - if (validated) { - return@apply - } - - id() - amount() - createdAt() - creditBlock().validate() - currency() - customer().validate() - description() - endingBalance() - entryStatus() - entryType() - ledgerSequenceNumber() - metadata().validate() - newBlockExpiryDate() - startingBalance() - voidAmount() - voidReason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [VoidInitiatedLedgerEntry]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var amount: JsonField? = null - private var createdAt: JsonField? = null - private var creditBlock: JsonField? = null - private var currency: JsonField? = null - private var customer: JsonField? = null - private var description: JsonField? = null - private var endingBalance: JsonField? = null - private var entryStatus: JsonField? = null - private var entryType: JsonField? = null - private var ledgerSequenceNumber: JsonField? = null - private var metadata: JsonField? = null - private var newBlockExpiryDate: JsonField? = null - private var startingBalance: JsonField? = null - private var voidAmount: JsonField? = null - private var voidReason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry) = apply { - id = voidInitiatedLedgerEntry.id - amount = voidInitiatedLedgerEntry.amount - createdAt = voidInitiatedLedgerEntry.createdAt - creditBlock = voidInitiatedLedgerEntry.creditBlock - currency = voidInitiatedLedgerEntry.currency - customer = voidInitiatedLedgerEntry.customer - description = voidInitiatedLedgerEntry.description - endingBalance = voidInitiatedLedgerEntry.endingBalance - entryStatus = voidInitiatedLedgerEntry.entryStatus - entryType = voidInitiatedLedgerEntry.entryType - ledgerSequenceNumber = voidInitiatedLedgerEntry.ledgerSequenceNumber - metadata = voidInitiatedLedgerEntry.metadata - newBlockExpiryDate = voidInitiatedLedgerEntry.newBlockExpiryDate - startingBalance = voidInitiatedLedgerEntry.startingBalance - voidAmount = voidInitiatedLedgerEntry.voidAmount - voidReason = voidInitiatedLedgerEntry.voidReason - additionalProperties = voidInitiatedLedgerEntry.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun amount(amount: Double) = amount(JsonField.of(amount)) - - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { - this.createdAt = createdAt - } - - fun creditBlock(creditBlock: CreditBlock) = creditBlock(JsonField.of(creditBlock)) - - fun creditBlock(creditBlock: JsonField) = apply { - this.creditBlock = creditBlock - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun customer(customer: Customer) = customer(JsonField.of(customer)) - - fun customer(customer: JsonField) = apply { this.customer = customer } - - fun description(description: String?) = description(JsonField.ofNullable(description)) - - fun description(description: Optional) = description(description.orElse(null)) - - fun description(description: JsonField) = apply { - this.description = description - } - - fun endingBalance(endingBalance: Double) = endingBalance(JsonField.of(endingBalance)) - - fun endingBalance(endingBalance: JsonField) = apply { - this.endingBalance = endingBalance - } - - fun entryStatus(entryStatus: EntryStatus) = entryStatus(JsonField.of(entryStatus)) - - fun entryStatus(entryStatus: JsonField) = apply { - this.entryStatus = entryStatus - } - - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } - - fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = - ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) - - fun ledgerSequenceNumber(ledgerSequenceNumber: JsonField) = apply { - this.ledgerSequenceNumber = ledgerSequenceNumber - } - - /** - * 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - fun newBlockExpiryDate(newBlockExpiryDate: OffsetDateTime) = - newBlockExpiryDate(JsonField.of(newBlockExpiryDate)) - - fun newBlockExpiryDate(newBlockExpiryDate: JsonField) = apply { - this.newBlockExpiryDate = newBlockExpiryDate - } - - fun startingBalance(startingBalance: Double) = - startingBalance(JsonField.of(startingBalance)) - - fun startingBalance(startingBalance: JsonField) = apply { - this.startingBalance = startingBalance - } - - fun voidAmount(voidAmount: Double) = voidAmount(JsonField.of(voidAmount)) - - fun voidAmount(voidAmount: JsonField) = apply { this.voidAmount = voidAmount } - - fun voidReason(voidReason: String?) = voidReason(JsonField.ofNullable(voidReason)) - - fun voidReason(voidReason: Optional) = voidReason(voidReason.orElse(null)) - - fun voidReason(voidReason: JsonField) = apply { this.voidReason = voidReason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): VoidInitiatedLedgerEntry = - VoidInitiatedLedgerEntry( - checkRequired("id", id), - checkRequired("amount", amount), - checkRequired("createdAt", createdAt), - checkRequired("creditBlock", creditBlock), - checkRequired("currency", currency), - checkRequired("customer", customer), - checkRequired("description", description), - checkRequired("endingBalance", endingBalance), - checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), - checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), - checkRequired("metadata", metadata), - checkRequired("newBlockExpiryDate", newBlockExpiryDate), - checkRequired("startingBalance", startingBalance), - checkRequired("voidAmount", voidAmount), - checkRequired("voidReason", voidReason), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class CreditBlock - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("expiry_date") - @ExcludeMissing - private val expiryDate: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - private val perUnitCostBasis: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun expiryDate(): Optional = - Optional.ofNullable(expiryDate.getNullable("expiry_date")) - - fun perUnitCostBasis(): Optional = - Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("expiry_date") - @ExcludeMissing - fun _expiryDate(): JsonField = expiryDate - - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - fun _perUnitCostBasis(): JsonField = perUnitCostBasis - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditBlock = apply { - if (validated) { - return@apply - } - - id() - expiryDate() - perUnitCostBasis() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditBlock]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var expiryDate: JsonField? = null - private var perUnitCostBasis: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditBlock: CreditBlock) = apply { - id = creditBlock.id - expiryDate = creditBlock.expiryDate - perUnitCostBasis = creditBlock.perUnitCostBasis - additionalProperties = creditBlock.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun expiryDate(expiryDate: OffsetDateTime?) = - expiryDate(JsonField.ofNullable(expiryDate)) - - fun expiryDate(expiryDate: Optional) = - expiryDate(expiryDate.orElse(null)) - - fun expiryDate(expiryDate: JsonField) = apply { - this.expiryDate = expiryDate - } - - fun perUnitCostBasis(perUnitCostBasis: String?) = - perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) - - fun perUnitCostBasis(perUnitCostBasis: Optional) = - perUnitCostBasis(perUnitCostBasis.orElse(null)) - - fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { - this.perUnitCostBasis = perUnitCostBasis - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditBlock = - CreditBlock( - checkRequired("id", id), - checkRequired("expiryDate", expiryDate), - checkRequired("perUnitCostBasis", perUnitCostBasis), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditBlock && id == other.id && expiryDate == other.expiryDate && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, expiryDate, perUnitCostBasis, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditBlock{id=$id, expiryDate=$expiryDate, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Customer - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("external_customer_id") - @ExcludeMissing - private val externalCustomerId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun externalCustomerId(): Optional = - Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("external_customer_id") - @ExcludeMissing - fun _externalCustomerId(): JsonField = externalCustomerId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Customer = apply { - if (validated) { - return@apply - } - - id() - externalCustomerId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Customer]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var externalCustomerId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customer: Customer) = apply { - id = customer.id - externalCustomerId = customer.externalCustomerId - additionalProperties = customer.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun externalCustomerId(externalCustomerId: String?) = - externalCustomerId(JsonField.ofNullable(externalCustomerId)) - - fun externalCustomerId(externalCustomerId: Optional) = - externalCustomerId(externalCustomerId.orElse(null)) - - fun externalCustomerId(externalCustomerId: JsonField) = apply { - this.externalCustomerId = externalCustomerId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Customer = - Customer( - checkRequired("id", id), - checkRequired("externalCustomerId", externalCustomerId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Customer && id == other.id && externalCustomerId == other.externalCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, externalCustomerId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Customer{id=$id, externalCustomerId=$externalCustomerId, additionalProperties=$additionalProperties}" - } - - class EntryStatus @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val COMMITTED = of("committed") - - @JvmField val PENDING = of("pending") - - @JvmStatic fun of(value: String) = EntryStatus(JsonField.of(value)) - } - - /** An enum containing [EntryStatus]'s known values. */ - enum class Known { - COMMITTED, - PENDING, - } - - /** - * An enum containing [EntryStatus]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryStatus] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - COMMITTED, - PENDING, - /** - * An enum member indicating that [EntryStatus] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - COMMITTED -> Value.COMMITTED - PENDING -> Value.PENDING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - COMMITTED -> Known.COMMITTED - PENDING -> Known.PENDING - else -> throw OrbInvalidDataException("Unknown EntryStatus: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryStatus && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val VOID_INITIATED = of("void_initiated") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - VOID_INITIATED - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - VOID_INITIATED, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - VOID_INITIATED -> Value.VOID_INITIATED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - VOID_INITIATED -> Known.VOID_INITIATED - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is VoidInitiatedLedgerEntry && id == other.id && amount == other.amount && createdAt == other.createdAt && creditBlock == other.creditBlock && currency == other.currency && customer == other.customer && description == other.description && endingBalance == other.endingBalance && entryStatus == other.entryStatus && entryType == other.entryType && ledgerSequenceNumber == other.ledgerSequenceNumber && metadata == other.metadata && newBlockExpiryDate == other.newBlockExpiryDate && startingBalance == other.startingBalance && voidAmount == other.voidAmount && voidReason == other.voidReason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, createdAt, creditBlock, currency, customer, description, endingBalance, entryStatus, entryType, ledgerSequenceNumber, metadata, newBlockExpiryDate, startingBalance, voidAmount, voidReason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "VoidInitiatedLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, newBlockExpiryDate=$newBlockExpiryDate, startingBalance=$startingBalance, voidAmount=$voidAmount, voidReason=$voidReason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class AmendmentLedgerEntry - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("credit_block") - @ExcludeMissing - private val creditBlock: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("customer") - @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("ending_balance") - @ExcludeMissing - private val endingBalance: JsonField = JsonMissing.of(), - @JsonProperty("entry_status") - @ExcludeMissing - private val entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - private val entryType: JsonField = JsonMissing.of(), - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - private val ledgerSequenceNumber: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("starting_balance") - @ExcludeMissing - private val startingBalance: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun amount(): Double = amount.getRequired("amount") - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - fun creditBlock(): CreditBlock = creditBlock.getRequired("credit_block") - - fun currency(): String = currency.getRequired("currency") - - fun customer(): Customer = customer.getRequired("customer") - - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - fun endingBalance(): Double = endingBalance.getRequired("ending_balance") - - fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") - - fun entryType(): EntryType = entryType.getRequired("entry_type") - - fun ledgerSequenceNumber(): Long = - ledgerSequenceNumber.getRequired("ledger_sequence_number") - - /** - * 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.getRequired("metadata") - - fun startingBalance(): Double = startingBalance.getRequired("starting_balance") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - @JsonProperty("credit_block") - @ExcludeMissing - fun _creditBlock(): JsonField = creditBlock - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - @JsonProperty("ending_balance") - @ExcludeMissing - fun _endingBalance(): JsonField = endingBalance - - @JsonProperty("entry_status") - @ExcludeMissing - fun _entryStatus(): JsonField = entryStatus - - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber - - /** - * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - @JsonProperty("starting_balance") - @ExcludeMissing - fun _startingBalance(): JsonField = startingBalance - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AmendmentLedgerEntry = apply { - if (validated) { - return@apply - } - - id() - amount() - createdAt() - creditBlock().validate() - currency() - customer().validate() - description() - endingBalance() - entryStatus() - entryType() - ledgerSequenceNumber() - metadata().validate() - startingBalance() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AmendmentLedgerEntry]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var amount: JsonField? = null - private var createdAt: JsonField? = null - private var creditBlock: JsonField? = null - private var currency: JsonField? = null - private var customer: JsonField? = null - private var description: JsonField? = null - private var endingBalance: JsonField? = null - private var entryStatus: JsonField? = null - private var entryType: JsonField? = null - private var ledgerSequenceNumber: JsonField? = null - private var metadata: JsonField? = null - private var startingBalance: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(amendmentLedgerEntry: AmendmentLedgerEntry) = apply { - id = amendmentLedgerEntry.id - amount = amendmentLedgerEntry.amount - createdAt = amendmentLedgerEntry.createdAt - creditBlock = amendmentLedgerEntry.creditBlock - currency = amendmentLedgerEntry.currency - customer = amendmentLedgerEntry.customer - description = amendmentLedgerEntry.description - endingBalance = amendmentLedgerEntry.endingBalance - entryStatus = amendmentLedgerEntry.entryStatus - entryType = amendmentLedgerEntry.entryType - ledgerSequenceNumber = amendmentLedgerEntry.ledgerSequenceNumber - metadata = amendmentLedgerEntry.metadata - startingBalance = amendmentLedgerEntry.startingBalance - additionalProperties = amendmentLedgerEntry.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun amount(amount: Double) = amount(JsonField.of(amount)) - - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { - this.createdAt = createdAt - } - - fun creditBlock(creditBlock: CreditBlock) = creditBlock(JsonField.of(creditBlock)) - - fun creditBlock(creditBlock: JsonField) = apply { - this.creditBlock = creditBlock - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun customer(customer: Customer) = customer(JsonField.of(customer)) - - fun customer(customer: JsonField) = apply { this.customer = customer } - - fun description(description: String?) = description(JsonField.ofNullable(description)) - - fun description(description: Optional) = description(description.orElse(null)) - - fun description(description: JsonField) = apply { - this.description = description - } - - fun endingBalance(endingBalance: Double) = endingBalance(JsonField.of(endingBalance)) - - fun endingBalance(endingBalance: JsonField) = apply { - this.endingBalance = endingBalance - } - - fun entryStatus(entryStatus: EntryStatus) = entryStatus(JsonField.of(entryStatus)) - - fun entryStatus(entryStatus: JsonField) = apply { - this.entryStatus = entryStatus - } - - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } - - fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = - ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) - - fun ledgerSequenceNumber(ledgerSequenceNumber: JsonField) = apply { - this.ledgerSequenceNumber = ledgerSequenceNumber - } - - /** - * 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - fun startingBalance(startingBalance: Double) = - startingBalance(JsonField.of(startingBalance)) - - fun startingBalance(startingBalance: JsonField) = apply { - this.startingBalance = startingBalance - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): AmendmentLedgerEntry = - AmendmentLedgerEntry( - checkRequired("id", id), - checkRequired("amount", amount), - checkRequired("createdAt", createdAt), - checkRequired("creditBlock", creditBlock), - checkRequired("currency", currency), - checkRequired("customer", customer), - checkRequired("description", description), - checkRequired("endingBalance", endingBalance), - checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), - checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), - checkRequired("metadata", metadata), - checkRequired("startingBalance", startingBalance), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class CreditBlock - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("expiry_date") - @ExcludeMissing - private val expiryDate: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - private val perUnitCostBasis: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun expiryDate(): Optional = - Optional.ofNullable(expiryDate.getNullable("expiry_date")) - - fun perUnitCostBasis(): Optional = - Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("expiry_date") - @ExcludeMissing - fun _expiryDate(): JsonField = expiryDate - - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - fun _perUnitCostBasis(): JsonField = perUnitCostBasis - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditBlock = apply { - if (validated) { - return@apply - } - - id() - expiryDate() - perUnitCostBasis() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditBlock]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var expiryDate: JsonField? = null - private var perUnitCostBasis: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditBlock: CreditBlock) = apply { - id = creditBlock.id - expiryDate = creditBlock.expiryDate - perUnitCostBasis = creditBlock.perUnitCostBasis - additionalProperties = creditBlock.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun expiryDate(expiryDate: OffsetDateTime?) = - expiryDate(JsonField.ofNullable(expiryDate)) - - fun expiryDate(expiryDate: Optional) = - expiryDate(expiryDate.orElse(null)) - - fun expiryDate(expiryDate: JsonField) = apply { - this.expiryDate = expiryDate - } - - fun perUnitCostBasis(perUnitCostBasis: String?) = - perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) - - fun perUnitCostBasis(perUnitCostBasis: Optional) = - perUnitCostBasis(perUnitCostBasis.orElse(null)) - - fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { - this.perUnitCostBasis = perUnitCostBasis - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditBlock = - CreditBlock( - checkRequired("id", id), - checkRequired("expiryDate", expiryDate), - checkRequired("perUnitCostBasis", perUnitCostBasis), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditBlock && id == other.id && expiryDate == other.expiryDate && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, expiryDate, perUnitCostBasis, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditBlock{id=$id, expiryDate=$expiryDate, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Customer - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("external_customer_id") - @ExcludeMissing - private val externalCustomerId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun externalCustomerId(): Optional = - Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("external_customer_id") - @ExcludeMissing - fun _externalCustomerId(): JsonField = externalCustomerId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Customer = apply { - if (validated) { - return@apply - } - - id() - externalCustomerId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Customer]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var externalCustomerId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customer: Customer) = apply { - id = customer.id - externalCustomerId = customer.externalCustomerId - additionalProperties = customer.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun externalCustomerId(externalCustomerId: String?) = - externalCustomerId(JsonField.ofNullable(externalCustomerId)) - - fun externalCustomerId(externalCustomerId: Optional) = - externalCustomerId(externalCustomerId.orElse(null)) - - fun externalCustomerId(externalCustomerId: JsonField) = apply { - this.externalCustomerId = externalCustomerId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Customer = - Customer( - checkRequired("id", id), - checkRequired("externalCustomerId", externalCustomerId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Customer && id == other.id && externalCustomerId == other.externalCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, externalCustomerId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Customer{id=$id, externalCustomerId=$externalCustomerId, additionalProperties=$additionalProperties}" - } - - class EntryStatus @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val COMMITTED = of("committed") - - @JvmField val PENDING = of("pending") - - @JvmStatic fun of(value: String) = EntryStatus(JsonField.of(value)) - } - - /** An enum containing [EntryStatus]'s known values. */ - enum class Known { - COMMITTED, - PENDING, - } - - /** - * An enum containing [EntryStatus]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryStatus] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - COMMITTED, - PENDING, - /** - * An enum member indicating that [EntryStatus] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - COMMITTED -> Value.COMMITTED - PENDING -> Value.PENDING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - COMMITTED -> Known.COMMITTED - PENDING -> Known.PENDING - else -> throw OrbInvalidDataException("Unknown EntryStatus: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryStatus && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val AMENDMENT = of("amendment") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - AMENDMENT - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMENDMENT, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMENDMENT -> Value.AMENDMENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AMENDMENT -> Known.AMENDMENT - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AmendmentLedgerEntry && id == other.id && amount == other.amount && createdAt == other.createdAt && creditBlock == other.creditBlock && currency == other.currency && customer == other.customer && description == other.description && endingBalance == other.endingBalance && entryStatus == other.entryStatus && entryType == other.entryType && ledgerSequenceNumber == other.ledgerSequenceNumber && metadata == other.metadata && startingBalance == other.startingBalance && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, createdAt, creditBlock, currency, customer, description, endingBalance, entryStatus, entryType, ledgerSequenceNumber, metadata, startingBalance, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AmendmentLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" - } -} 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 9c57a9211..5de65960c 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 @@ -2,38 +2,12 @@ package com.withorb.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer -import com.withorb.api.core.Enum -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.Params import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams -import com.withorb.api.core.immutableEmptyMap -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.time.LocalDate -import java.time.OffsetDateTime import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull /** * This endpoint allows you to create a new ledger entry for a specified customer's balance. This @@ -140,20 +114,20 @@ import kotlin.jvm.optionals.getOrNull class CustomerCreditLedgerCreateEntryParams private constructor( private val customerId: String, - private val body: Body, + private val addCreditLedgerEntryRequest: AddCreditLedgerEntryRequest, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { fun customerId(): String = customerId - fun body(): Body = body + fun addCreditLedgerEntryRequest(): AddCreditLedgerEntryRequest = addCreditLedgerEntryRequest fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): AddCreditLedgerEntryRequest = addCreditLedgerEntryRequest override fun _headers(): Headers = additionalHeaders @@ -166,3351 +140,20 @@ private constructor( } } - @JsonDeserialize(using = Body.Deserializer::class) - @JsonSerialize(using = Body.Serializer::class) - class Body - private constructor( - private val addIncrementCreditLedgerEntryRequestParams: - AddIncrementCreditLedgerEntryRequestParams? = - null, - private val addDecrementCreditLedgerEntryRequestParams: - AddDecrementCreditLedgerEntryRequestParams? = - null, - private val addExpirationChangeCreditLedgerEntryRequestParams: - AddExpirationChangeCreditLedgerEntryRequestParams? = - null, - private val addVoidCreditLedgerEntryRequestParams: AddVoidCreditLedgerEntryRequestParams? = - null, - private val addAmendmentCreditLedgerEntryRequestParams: - AddAmendmentCreditLedgerEntryRequestParams? = - null, - private val _json: JsonValue? = null, - ) { - - fun addIncrementCreditLedgerEntryRequestParams(): - Optional = - Optional.ofNullable(addIncrementCreditLedgerEntryRequestParams) - - fun addDecrementCreditLedgerEntryRequestParams(): - Optional = - Optional.ofNullable(addDecrementCreditLedgerEntryRequestParams) - - fun addExpirationChangeCreditLedgerEntryRequestParams(): - Optional = - Optional.ofNullable(addExpirationChangeCreditLedgerEntryRequestParams) - - fun addVoidCreditLedgerEntryRequestParams(): - Optional = - Optional.ofNullable(addVoidCreditLedgerEntryRequestParams) - - fun addAmendmentCreditLedgerEntryRequestParams(): - Optional = - Optional.ofNullable(addAmendmentCreditLedgerEntryRequestParams) - - fun isAddIncrementCreditLedgerEntryRequestParams(): Boolean = - addIncrementCreditLedgerEntryRequestParams != null - - fun isAddDecrementCreditLedgerEntryRequestParams(): Boolean = - addDecrementCreditLedgerEntryRequestParams != null - - fun isAddExpirationChangeCreditLedgerEntryRequestParams(): Boolean = - addExpirationChangeCreditLedgerEntryRequestParams != null - - fun isAddVoidCreditLedgerEntryRequestParams(): Boolean = - addVoidCreditLedgerEntryRequestParams != null - - fun isAddAmendmentCreditLedgerEntryRequestParams(): Boolean = - addAmendmentCreditLedgerEntryRequestParams != null - - fun asAddIncrementCreditLedgerEntryRequestParams(): - AddIncrementCreditLedgerEntryRequestParams = - addIncrementCreditLedgerEntryRequestParams.getOrThrow( - "addIncrementCreditLedgerEntryRequestParams" - ) - - fun asAddDecrementCreditLedgerEntryRequestParams(): - AddDecrementCreditLedgerEntryRequestParams = - addDecrementCreditLedgerEntryRequestParams.getOrThrow( - "addDecrementCreditLedgerEntryRequestParams" - ) - - fun asAddExpirationChangeCreditLedgerEntryRequestParams(): - AddExpirationChangeCreditLedgerEntryRequestParams = - addExpirationChangeCreditLedgerEntryRequestParams.getOrThrow( - "addExpirationChangeCreditLedgerEntryRequestParams" - ) - - fun asAddVoidCreditLedgerEntryRequestParams(): AddVoidCreditLedgerEntryRequestParams = - addVoidCreditLedgerEntryRequestParams.getOrThrow( - "addVoidCreditLedgerEntryRequestParams" - ) - - fun asAddAmendmentCreditLedgerEntryRequestParams(): - AddAmendmentCreditLedgerEntryRequestParams = - addAmendmentCreditLedgerEntryRequestParams.getOrThrow( - "addAmendmentCreditLedgerEntryRequestParams" - ) - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - addIncrementCreditLedgerEntryRequestParams != null -> - visitor.visitAddIncrementCreditLedgerEntryRequestParams( - addIncrementCreditLedgerEntryRequestParams - ) - addDecrementCreditLedgerEntryRequestParams != null -> - visitor.visitAddDecrementCreditLedgerEntryRequestParams( - addDecrementCreditLedgerEntryRequestParams - ) - addExpirationChangeCreditLedgerEntryRequestParams != null -> - visitor.visitAddExpirationChangeCreditLedgerEntryRequestParams( - addExpirationChangeCreditLedgerEntryRequestParams - ) - addVoidCreditLedgerEntryRequestParams != null -> - visitor.visitAddVoidCreditLedgerEntryRequestParams( - addVoidCreditLedgerEntryRequestParams - ) - addAmendmentCreditLedgerEntryRequestParams != null -> - visitor.visitAddAmendmentCreditLedgerEntryRequestParams( - addAmendmentCreditLedgerEntryRequestParams - ) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitAddIncrementCreditLedgerEntryRequestParams( - addIncrementCreditLedgerEntryRequestParams: - AddIncrementCreditLedgerEntryRequestParams - ) { - addIncrementCreditLedgerEntryRequestParams.validate() - } - - override fun visitAddDecrementCreditLedgerEntryRequestParams( - addDecrementCreditLedgerEntryRequestParams: - AddDecrementCreditLedgerEntryRequestParams - ) { - addDecrementCreditLedgerEntryRequestParams.validate() - } - - override fun visitAddExpirationChangeCreditLedgerEntryRequestParams( - addExpirationChangeCreditLedgerEntryRequestParams: - AddExpirationChangeCreditLedgerEntryRequestParams - ) { - addExpirationChangeCreditLedgerEntryRequestParams.validate() - } - - override fun visitAddVoidCreditLedgerEntryRequestParams( - addVoidCreditLedgerEntryRequestParams: AddVoidCreditLedgerEntryRequestParams - ) { - addVoidCreditLedgerEntryRequestParams.validate() - } - - override fun visitAddAmendmentCreditLedgerEntryRequestParams( - addAmendmentCreditLedgerEntryRequestParams: - AddAmendmentCreditLedgerEntryRequestParams - ) { - addAmendmentCreditLedgerEntryRequestParams.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Body && addIncrementCreditLedgerEntryRequestParams == other.addIncrementCreditLedgerEntryRequestParams && addDecrementCreditLedgerEntryRequestParams == other.addDecrementCreditLedgerEntryRequestParams && addExpirationChangeCreditLedgerEntryRequestParams == other.addExpirationChangeCreditLedgerEntryRequestParams && addVoidCreditLedgerEntryRequestParams == other.addVoidCreditLedgerEntryRequestParams && addAmendmentCreditLedgerEntryRequestParams == other.addAmendmentCreditLedgerEntryRequestParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(addIncrementCreditLedgerEntryRequestParams, addDecrementCreditLedgerEntryRequestParams, addExpirationChangeCreditLedgerEntryRequestParams, addVoidCreditLedgerEntryRequestParams, addAmendmentCreditLedgerEntryRequestParams) /* spotless:on */ - - override fun toString(): String = - when { - addIncrementCreditLedgerEntryRequestParams != null -> - "Body{addIncrementCreditLedgerEntryRequestParams=$addIncrementCreditLedgerEntryRequestParams}" - addDecrementCreditLedgerEntryRequestParams != null -> - "Body{addDecrementCreditLedgerEntryRequestParams=$addDecrementCreditLedgerEntryRequestParams}" - addExpirationChangeCreditLedgerEntryRequestParams != null -> - "Body{addExpirationChangeCreditLedgerEntryRequestParams=$addExpirationChangeCreditLedgerEntryRequestParams}" - addVoidCreditLedgerEntryRequestParams != null -> - "Body{addVoidCreditLedgerEntryRequestParams=$addVoidCreditLedgerEntryRequestParams}" - addAmendmentCreditLedgerEntryRequestParams != null -> - "Body{addAmendmentCreditLedgerEntryRequestParams=$addAmendmentCreditLedgerEntryRequestParams}" - _json != null -> "Body{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Body") - } - - companion object { - - @JvmStatic - fun ofAddIncrementCreditLedgerEntryRequestParams( - addIncrementCreditLedgerEntryRequestParams: - AddIncrementCreditLedgerEntryRequestParams - ) = - Body( - addIncrementCreditLedgerEntryRequestParams = - addIncrementCreditLedgerEntryRequestParams - ) - - @JvmStatic - fun ofAddDecrementCreditLedgerEntryRequestParams( - addDecrementCreditLedgerEntryRequestParams: - AddDecrementCreditLedgerEntryRequestParams - ) = - Body( - addDecrementCreditLedgerEntryRequestParams = - addDecrementCreditLedgerEntryRequestParams - ) - - @JvmStatic - fun ofAddExpirationChangeCreditLedgerEntryRequestParams( - addExpirationChangeCreditLedgerEntryRequestParams: - AddExpirationChangeCreditLedgerEntryRequestParams - ) = - Body( - addExpirationChangeCreditLedgerEntryRequestParams = - addExpirationChangeCreditLedgerEntryRequestParams - ) - - @JvmStatic - fun ofAddVoidCreditLedgerEntryRequestParams( - addVoidCreditLedgerEntryRequestParams: AddVoidCreditLedgerEntryRequestParams - ) = Body(addVoidCreditLedgerEntryRequestParams = addVoidCreditLedgerEntryRequestParams) - - @JvmStatic - fun ofAddAmendmentCreditLedgerEntryRequestParams( - addAmendmentCreditLedgerEntryRequestParams: - AddAmendmentCreditLedgerEntryRequestParams - ) = - Body( - addAmendmentCreditLedgerEntryRequestParams = - addAmendmentCreditLedgerEntryRequestParams - ) - } - - /** An interface that defines how to map each variant of [Body] to a value of type [T]. */ - interface Visitor { - - fun visitAddIncrementCreditLedgerEntryRequestParams( - addIncrementCreditLedgerEntryRequestParams: - AddIncrementCreditLedgerEntryRequestParams - ): T - - fun visitAddDecrementCreditLedgerEntryRequestParams( - addDecrementCreditLedgerEntryRequestParams: - AddDecrementCreditLedgerEntryRequestParams - ): T - - fun visitAddExpirationChangeCreditLedgerEntryRequestParams( - addExpirationChangeCreditLedgerEntryRequestParams: - AddExpirationChangeCreditLedgerEntryRequestParams - ): T - - fun visitAddVoidCreditLedgerEntryRequestParams( - addVoidCreditLedgerEntryRequestParams: AddVoidCreditLedgerEntryRequestParams - ): T - - fun visitAddAmendmentCreditLedgerEntryRequestParams( - addAmendmentCreditLedgerEntryRequestParams: - AddAmendmentCreditLedgerEntryRequestParams - ): T - - /** - * Maps an unknown variant of [Body] to a value of type [T]. - * - * An instance of [Body] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Body: $json") - } - } - - internal class Deserializer : BaseDeserializer(Body::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Body { - val json = JsonValue.fromJsonNode(node) - val entryType = - json.asObject().getOrNull()?.get("entry_type")?.asString()?.getOrNull() - - when (entryType) { - "increment" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body( - addIncrementCreditLedgerEntryRequestParams = it, - _json = json, - ) - } - } - "decrement" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body( - addDecrementCreditLedgerEntryRequestParams = it, - _json = json, - ) - } - } - "expiration_change" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body( - addExpirationChangeCreditLedgerEntryRequestParams = it, - _json = json, - ) - } - } - "void" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body( - addVoidCreditLedgerEntryRequestParams = it, - _json = json, - ) - } - } - "amendment" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body( - addAmendmentCreditLedgerEntryRequestParams = it, - _json = json, - ) - } - } - } - - return Body(_json = json) - } - } - - internal class Serializer : BaseSerializer(Body::class) { - - override fun serialize( - value: Body, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.addIncrementCreditLedgerEntryRequestParams != null -> - generator.writeObject(value.addIncrementCreditLedgerEntryRequestParams) - value.addDecrementCreditLedgerEntryRequestParams != null -> - generator.writeObject(value.addDecrementCreditLedgerEntryRequestParams) - value.addExpirationChangeCreditLedgerEntryRequestParams != null -> - generator.writeObject( - value.addExpirationChangeCreditLedgerEntryRequestParams - ) - value.addVoidCreditLedgerEntryRequestParams != null -> - generator.writeObject(value.addVoidCreditLedgerEntryRequestParams) - value.addAmendmentCreditLedgerEntryRequestParams != null -> - generator.writeObject(value.addAmendmentCreditLedgerEntryRequestParams) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Body") - } - } - } - - @NoAutoDetect - class AddIncrementCreditLedgerEntryRequestParams - @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - private val entryType: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("effective_date") - @ExcludeMissing - private val effectiveDate: JsonField = JsonMissing.of(), - @JsonProperty("expiry_date") - @ExcludeMissing - private val expiryDate: JsonField = JsonMissing.of(), - @JsonProperty("invoice_settings") - @ExcludeMissing - private val invoiceSettings: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - private val perUnitCostBasis: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * The number of credits to effect. Note that this is required for increment, decrement, - * void, or undo operations. - */ - fun amount(): Double = amount.getRequired("amount") - - fun entryType(): EntryType = entryType.getRequired("entry_type") - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) - - /** - * Optional metadata that can be specified when adding ledger results via the API. For - * example, this can be used to note an increment refers to trial credits, or for noting - * corrections as a result of an incident, etc. - */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - /** - * An ISO 8601 format date that denotes when this credit balance should become available - * for use. - */ - fun effectiveDate(): Optional = - Optional.ofNullable(effectiveDate.getNullable("effective_date")) - - /** An ISO 8601 format date that denotes when this credit balance should expire. */ - fun expiryDate(): Optional = - Optional.ofNullable(expiryDate.getNullable("expiry_date")) - - /** - * Passing `invoice_settings` automatically generates an invoice for the newly added - * credits. If `invoice_settings` is passed, you must specify per_unit_cost_basis, as - * the calculation of the invoice total is done on that basis. - */ - fun invoiceSettings(): Optional = - Optional.ofNullable(invoiceSettings.getNullable("invoice_settings")) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * Can only be specified when entry_type=increment. How much, in the customer's - * currency, a customer paid for a single credit in this block - */ - fun perUnitCostBasis(): Optional = - Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - - /** - * The number of credits to effect. Note that this is required for increment, decrement, - * void, or undo operations. - */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** - * Optional metadata that can be specified when adding ledger results via the API. For - * example, this can be used to note an increment refers to trial credits, or for noting - * corrections as a result of an incident, etc. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - /** - * An ISO 8601 format date that denotes when this credit balance should become available - * for use. - */ - @JsonProperty("effective_date") - @ExcludeMissing - fun _effectiveDate(): JsonField = effectiveDate - - /** An ISO 8601 format date that denotes when this credit balance should expire. */ - @JsonProperty("expiry_date") - @ExcludeMissing - fun _expiryDate(): JsonField = expiryDate - - /** - * Passing `invoice_settings` automatically generates an invoice for the newly added - * credits. If `invoice_settings` is passed, you must specify per_unit_cost_basis, as - * the calculation of the invoice total is done on that basis. - */ - @JsonProperty("invoice_settings") - @ExcludeMissing - fun _invoiceSettings(): JsonField = invoiceSettings - - /** - * User-specified key/value pairs for the resource. 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("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * Can only be specified when entry_type=increment. How much, in the customer's - * currency, a customer paid for a single credit in this block - */ - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - fun _perUnitCostBasis(): JsonField = perUnitCostBasis - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AddIncrementCreditLedgerEntryRequestParams = apply { - if (validated) { - return@apply - } - - amount() - entryType() - currency() - description() - effectiveDate() - expiryDate() - invoiceSettings().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - perUnitCostBasis() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AddIncrementCreditLedgerEntryRequestParams]. */ - class Builder internal constructor() { - - private var amount: JsonField? = null - private var entryType: JsonField? = null - private var currency: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var effectiveDate: JsonField = JsonMissing.of() - private var expiryDate: JsonField = JsonMissing.of() - private var invoiceSettings: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var perUnitCostBasis: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - addIncrementCreditLedgerEntryRequestParams: - AddIncrementCreditLedgerEntryRequestParams - ) = apply { - amount = addIncrementCreditLedgerEntryRequestParams.amount - entryType = addIncrementCreditLedgerEntryRequestParams.entryType - currency = addIncrementCreditLedgerEntryRequestParams.currency - description = addIncrementCreditLedgerEntryRequestParams.description - effectiveDate = addIncrementCreditLedgerEntryRequestParams.effectiveDate - expiryDate = addIncrementCreditLedgerEntryRequestParams.expiryDate - invoiceSettings = addIncrementCreditLedgerEntryRequestParams.invoiceSettings - metadata = addIncrementCreditLedgerEntryRequestParams.metadata - perUnitCostBasis = addIncrementCreditLedgerEntryRequestParams.perUnitCostBasis - additionalProperties = - addIncrementCreditLedgerEntryRequestParams.additionalProperties - .toMutableMap() - } - - /** - * The number of credits to effect. Note that this is required for increment, - * decrement, void, or undo operations. - */ - fun amount(amount: Double) = amount(JsonField.of(amount)) - - /** - * The number of credits to effect. Note that this is required for increment, - * decrement, void, or undo operations. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - - fun entryType(entryType: JsonField) = apply { - this.entryType = entryType - } - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** - * Optional metadata that can be specified when adding ledger results via the API. - * For example, this can be used to note an increment refers to trial credits, or - * for noting corrections as a result of an incident, etc. - */ - fun description(description: String?) = - description(JsonField.ofNullable(description)) - - /** - * Optional metadata that can be specified when adding ledger results via the API. - * For example, this can be used to note an increment refers to trial credits, or - * for noting corrections as a result of an incident, etc. - */ - fun description(description: Optional) = - description(description.orElse(null)) - - /** - * Optional metadata that can be specified when adding ledger results via the API. - * For example, this can be used to note an increment refers to trial credits, or - * for noting corrections as a result of an incident, etc. - */ - fun description(description: JsonField) = apply { - this.description = description - } - - /** - * An ISO 8601 format date that denotes when this credit balance should become - * available for use. - */ - fun effectiveDate(effectiveDate: OffsetDateTime?) = - effectiveDate(JsonField.ofNullable(effectiveDate)) - - /** - * An ISO 8601 format date that denotes when this credit balance should become - * available for use. - */ - fun effectiveDate(effectiveDate: Optional) = - effectiveDate(effectiveDate.orElse(null)) - - /** - * An ISO 8601 format date that denotes when this credit balance should become - * available for use. - */ - fun effectiveDate(effectiveDate: JsonField) = apply { - this.effectiveDate = effectiveDate - } - - /** An ISO 8601 format date that denotes when this credit balance should expire. */ - fun expiryDate(expiryDate: OffsetDateTime?) = - expiryDate(JsonField.ofNullable(expiryDate)) - - /** An ISO 8601 format date that denotes when this credit balance should expire. */ - fun expiryDate(expiryDate: Optional) = - expiryDate(expiryDate.orElse(null)) - - /** An ISO 8601 format date that denotes when this credit balance should expire. */ - fun expiryDate(expiryDate: JsonField) = apply { - this.expiryDate = expiryDate - } - - /** - * Passing `invoice_settings` automatically generates an invoice for the newly added - * credits. If `invoice_settings` is passed, you must specify per_unit_cost_basis, - * as the calculation of the invoice total is done on that basis. - */ - fun invoiceSettings(invoiceSettings: InvoiceSettings?) = - invoiceSettings(JsonField.ofNullable(invoiceSettings)) - - /** - * Passing `invoice_settings` automatically generates an invoice for the newly added - * credits. If `invoice_settings` is passed, you must specify per_unit_cost_basis, - * as the calculation of the invoice total is done on that basis. - */ - fun invoiceSettings(invoiceSettings: Optional) = - invoiceSettings(invoiceSettings.orElse(null)) - - /** - * Passing `invoice_settings` automatically generates an invoice for the newly added - * credits. If `invoice_settings` is passed, you must specify per_unit_cost_basis, - * as the calculation of the invoice total is done on that basis. - */ - fun invoiceSettings(invoiceSettings: JsonField) = apply { - this.invoiceSettings = invoiceSettings - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: JsonField) = apply { this.metadata = metadata } - - /** - * Can only be specified when entry_type=increment. How much, in the customer's - * currency, a customer paid for a single credit in this block - */ - fun perUnitCostBasis(perUnitCostBasis: String?) = - perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) - - /** - * Can only be specified when entry_type=increment. How much, in the customer's - * currency, a customer paid for a single credit in this block - */ - fun perUnitCostBasis(perUnitCostBasis: Optional) = - perUnitCostBasis(perUnitCostBasis.orElse(null)) - - /** - * Can only be specified when entry_type=increment. How much, in the customer's - * currency, a customer paid for a single credit in this block - */ - fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { - this.perUnitCostBasis = perUnitCostBasis - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): AddIncrementCreditLedgerEntryRequestParams = - AddIncrementCreditLedgerEntryRequestParams( - checkRequired("amount", amount), - checkRequired("entryType", entryType), - currency, - description, - effectiveDate, - expiryDate, - invoiceSettings, - metadata, - perUnitCostBasis, - additionalProperties.toImmutable(), - ) - } - - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val INCREMENT = of("increment") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - INCREMENT - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - INCREMENT, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - INCREMENT -> Value.INCREMENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - INCREMENT -> Known.INCREMENT - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * Passing `invoice_settings` automatically generates an invoice for the newly added - * credits. If `invoice_settings` is passed, you must specify per_unit_cost_basis, as - * the calculation of the invoice total is done on that basis. - */ - @NoAutoDetect - class InvoiceSettings - @JsonCreator - private constructor( - @JsonProperty("auto_collection") - @ExcludeMissing - private val autoCollection: JsonField = JsonMissing.of(), - @JsonProperty("net_terms") - @ExcludeMissing - private val netTerms: JsonField = JsonMissing.of(), - @JsonProperty("memo") - @ExcludeMissing - private val memo: JsonField = JsonMissing.of(), - @JsonProperty("require_successful_payment") - @ExcludeMissing - private val requireSuccessfulPayment: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * Whether the credits purchase invoice should auto collect with the customer's - * saved payment method. - */ - fun autoCollection(): Boolean = autoCollection.getRequired("auto_collection") - - /** - * The net terms determines the difference between the invoice date and the issue - * date for the invoice. If you intend the invoice to be due on issue, set this - * to 0. - */ - fun netTerms(): Long = netTerms.getRequired("net_terms") - - /** An optional memo to display on the invoice. */ - fun memo(): Optional = Optional.ofNullable(memo.getNullable("memo")) - - /** - * If true, the new credit block will require that the corresponding invoice is paid - * before it can be drawn down from. - */ - fun requireSuccessfulPayment(): Optional = - Optional.ofNullable( - requireSuccessfulPayment.getNullable("require_successful_payment") - ) - - /** - * Whether the credits purchase invoice should auto collect with the customer's - * saved payment method. - */ - @JsonProperty("auto_collection") - @ExcludeMissing - fun _autoCollection(): JsonField = autoCollection - - /** - * The net terms determines the difference between the invoice date and the issue - * date for the invoice. If you intend the invoice to be due on issue, set this - * to 0. - */ - @JsonProperty("net_terms") - @ExcludeMissing - fun _netTerms(): JsonField = netTerms - - /** An optional memo to display on the invoice. */ - @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo - - /** - * If true, the new credit block will require that the corresponding invoice is paid - * before it can be drawn down from. - */ - @JsonProperty("require_successful_payment") - @ExcludeMissing - fun _requireSuccessfulPayment(): JsonField = requireSuccessfulPayment - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoiceSettings = apply { - if (validated) { - return@apply - } - - autoCollection() - netTerms() - memo() - requireSuccessfulPayment() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoiceSettings]. */ - class Builder internal constructor() { - - private var autoCollection: JsonField? = null - private var netTerms: JsonField? = null - private var memo: JsonField = JsonMissing.of() - private var requireSuccessfulPayment: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoiceSettings: InvoiceSettings) = apply { - autoCollection = invoiceSettings.autoCollection - netTerms = invoiceSettings.netTerms - memo = invoiceSettings.memo - requireSuccessfulPayment = invoiceSettings.requireSuccessfulPayment - additionalProperties = invoiceSettings.additionalProperties.toMutableMap() - } - - /** - * Whether the credits purchase invoice should auto collect with the customer's - * saved payment method. - */ - fun autoCollection(autoCollection: Boolean) = - autoCollection(JsonField.of(autoCollection)) - - /** - * Whether the credits purchase invoice should auto collect with the customer's - * saved payment method. - */ - fun autoCollection(autoCollection: JsonField) = apply { - this.autoCollection = autoCollection - } - - /** - * The net terms determines the difference between the invoice date and the - * issue date for the invoice. If you intend the invoice to be due on issue, set - * this to 0. - */ - fun netTerms(netTerms: Long) = netTerms(JsonField.of(netTerms)) - - /** - * The net terms determines the difference between the invoice date and the - * issue date for the invoice. If you intend the invoice to be due on issue, set - * this to 0. - */ - fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } - - /** An optional memo to display on the invoice. */ - fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) - - /** An optional memo to display on the invoice. */ - fun memo(memo: Optional) = memo(memo.orElse(null)) - - /** An optional memo to display on the invoice. */ - fun memo(memo: JsonField) = apply { this.memo = memo } - - /** - * If true, the new credit block will require that the corresponding invoice is - * paid before it can be drawn down from. - */ - fun requireSuccessfulPayment(requireSuccessfulPayment: Boolean) = - requireSuccessfulPayment(JsonField.of(requireSuccessfulPayment)) - - /** - * If true, the new credit block will require that the corresponding invoice is - * paid before it can be drawn down from. - */ - fun requireSuccessfulPayment(requireSuccessfulPayment: JsonField) = - apply { - this.requireSuccessfulPayment = requireSuccessfulPayment - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoiceSettings = - InvoiceSettings( - checkRequired("autoCollection", autoCollection), - checkRequired("netTerms", netTerms), - memo, - requireSuccessfulPayment, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoiceSettings && autoCollection == other.autoCollection && netTerms == other.netTerms && memo == other.memo && requireSuccessfulPayment == other.requireSuccessfulPayment && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(autoCollection, netTerms, memo, requireSuccessfulPayment, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoiceSettings{autoCollection=$autoCollection, netTerms=$netTerms, memo=$memo, requireSuccessfulPayment=$requireSuccessfulPayment, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AddIncrementCreditLedgerEntryRequestParams && amount == other.amount && entryType == other.entryType && currency == other.currency && description == other.description && effectiveDate == other.effectiveDate && expiryDate == other.expiryDate && invoiceSettings == other.invoiceSettings && metadata == other.metadata && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, entryType, currency, description, effectiveDate, expiryDate, invoiceSettings, metadata, perUnitCostBasis, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AddIncrementCreditLedgerEntryRequestParams{amount=$amount, entryType=$entryType, currency=$currency, description=$description, effectiveDate=$effectiveDate, expiryDate=$expiryDate, invoiceSettings=$invoiceSettings, metadata=$metadata, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class AddDecrementCreditLedgerEntryRequestParams - @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - private val entryType: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * The number of credits to effect. Note that this is required for increment, decrement, - * void, or undo operations. - */ - fun amount(): Double = amount.getRequired("amount") - - fun entryType(): EntryType = entryType.getRequired("entry_type") - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) - - /** - * Optional metadata that can be specified when adding ledger results via the API. For - * example, this can be used to note an increment refers to trial credits, or for noting - * corrections as a result of an incident, etc. - */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * The number of credits to effect. Note that this is required for increment, decrement, - * void, or undo operations. - */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** - * Optional metadata that can be specified when adding ledger results via the API. For - * example, this can be used to note an increment refers to trial credits, or for noting - * corrections as a result of an incident, etc. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - /** - * User-specified key/value pairs for the resource. 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("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AddDecrementCreditLedgerEntryRequestParams = apply { - if (validated) { - return@apply - } - - amount() - entryType() - currency() - description() - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AddDecrementCreditLedgerEntryRequestParams]. */ - class Builder internal constructor() { - - private var amount: JsonField? = null - private var entryType: JsonField? = null - private var currency: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - addDecrementCreditLedgerEntryRequestParams: - AddDecrementCreditLedgerEntryRequestParams - ) = apply { - amount = addDecrementCreditLedgerEntryRequestParams.amount - entryType = addDecrementCreditLedgerEntryRequestParams.entryType - currency = addDecrementCreditLedgerEntryRequestParams.currency - description = addDecrementCreditLedgerEntryRequestParams.description - metadata = addDecrementCreditLedgerEntryRequestParams.metadata - additionalProperties = - addDecrementCreditLedgerEntryRequestParams.additionalProperties - .toMutableMap() - } - - /** - * The number of credits to effect. Note that this is required for increment, - * decrement, void, or undo operations. - */ - fun amount(amount: Double) = amount(JsonField.of(amount)) - - /** - * The number of credits to effect. Note that this is required for increment, - * decrement, void, or undo operations. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - - fun entryType(entryType: JsonField) = apply { - this.entryType = entryType - } - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** - * Optional metadata that can be specified when adding ledger results via the API. - * For example, this can be used to note an increment refers to trial credits, or - * for noting corrections as a result of an incident, etc. - */ - fun description(description: String?) = - description(JsonField.ofNullable(description)) - - /** - * Optional metadata that can be specified when adding ledger results via the API. - * For example, this can be used to note an increment refers to trial credits, or - * for noting corrections as a result of an incident, etc. - */ - fun description(description: Optional) = - description(description.orElse(null)) - - /** - * Optional metadata that can be specified when adding ledger results via the API. - * For example, this can be used to note an increment refers to trial credits, or - * for noting corrections as a result of an incident, etc. - */ - fun description(description: JsonField) = apply { - this.description = description - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): AddDecrementCreditLedgerEntryRequestParams = - AddDecrementCreditLedgerEntryRequestParams( - checkRequired("amount", amount), - checkRequired("entryType", entryType), - currency, - description, - metadata, - additionalProperties.toImmutable(), - ) - } - - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DECREMENT = of("decrement") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - DECREMENT - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DECREMENT, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DECREMENT -> Value.DECREMENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - DECREMENT -> Known.DECREMENT - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AddDecrementCreditLedgerEntryRequestParams && amount == other.amount && entryType == other.entryType && currency == other.currency && description == other.description && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, entryType, currency, description, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AddDecrementCreditLedgerEntryRequestParams{amount=$amount, entryType=$entryType, currency=$currency, description=$description, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class AddExpirationChangeCreditLedgerEntryRequestParams - @JsonCreator - private constructor( - @JsonProperty("entry_type") - @ExcludeMissing - private val entryType: JsonField = JsonMissing.of(), - @JsonProperty("expiry_date") - @ExcludeMissing - private val expiryDate: JsonField = JsonMissing.of(), - @JsonProperty("target_expiry_date") - @ExcludeMissing - private val targetExpiryDate: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("block_id") - @ExcludeMissing - private val blockId: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun entryType(): EntryType = entryType.getRequired("entry_type") - - /** An ISO 8601 format date that identifies the origination credit block to expire */ - fun expiryDate(): Optional = - Optional.ofNullable(expiryDate.getNullable("expiry_date")) - - /** - * 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. - */ - fun targetExpiryDate(): LocalDate = targetExpiryDate.getRequired("target_expiry_date") - - /** - * The number of credits to effect. Note that this is required for increment, decrement, - * void, or undo operations. - */ - fun amount(): Optional = Optional.ofNullable(amount.getNullable("amount")) - - /** - * The ID of the block affected by an expiration_change, used to differentiate between - * multiple blocks with the same `expiry_date`. - */ - fun blockId(): Optional = Optional.ofNullable(blockId.getNullable("block_id")) - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) - - /** - * Optional metadata that can be specified when adding ledger results via the API. For - * example, this can be used to note an increment refers to trial credits, or for noting - * corrections as a result of an incident, etc. - */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - - /** An ISO 8601 format date that identifies the origination credit block to expire */ - @JsonProperty("expiry_date") - @ExcludeMissing - fun _expiryDate(): JsonField = expiryDate - - /** - * 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. - */ - @JsonProperty("target_expiry_date") - @ExcludeMissing - fun _targetExpiryDate(): JsonField = targetExpiryDate - - /** - * The number of credits to effect. Note that this is required for increment, decrement, - * void, or undo operations. - */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** - * The ID of the block affected by an expiration_change, used to differentiate between - * multiple blocks with the same `expiry_date`. - */ - @JsonProperty("block_id") @ExcludeMissing fun _blockId(): JsonField = blockId - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** - * Optional metadata that can be specified when adding ledger results via the API. For - * example, this can be used to note an increment refers to trial credits, or for noting - * corrections as a result of an incident, etc. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - /** - * User-specified key/value pairs for the resource. 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("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AddExpirationChangeCreditLedgerEntryRequestParams = apply { - if (validated) { - return@apply - } - - entryType() - expiryDate() - targetExpiryDate() - amount() - blockId() - currency() - description() - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AddExpirationChangeCreditLedgerEntryRequestParams]. */ - class Builder internal constructor() { - - private var entryType: JsonField? = null - private var expiryDate: JsonField? = null - private var targetExpiryDate: JsonField? = null - private var amount: JsonField = JsonMissing.of() - private var blockId: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - addExpirationChangeCreditLedgerEntryRequestParams: - AddExpirationChangeCreditLedgerEntryRequestParams - ) = apply { - entryType = addExpirationChangeCreditLedgerEntryRequestParams.entryType - expiryDate = addExpirationChangeCreditLedgerEntryRequestParams.expiryDate - targetExpiryDate = - addExpirationChangeCreditLedgerEntryRequestParams.targetExpiryDate - amount = addExpirationChangeCreditLedgerEntryRequestParams.amount - blockId = addExpirationChangeCreditLedgerEntryRequestParams.blockId - currency = addExpirationChangeCreditLedgerEntryRequestParams.currency - description = addExpirationChangeCreditLedgerEntryRequestParams.description - metadata = addExpirationChangeCreditLedgerEntryRequestParams.metadata - additionalProperties = - addExpirationChangeCreditLedgerEntryRequestParams.additionalProperties - .toMutableMap() - } - - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - - fun entryType(entryType: JsonField) = apply { - this.entryType = entryType - } - - /** - * An ISO 8601 format date that identifies the origination credit block to expire - */ - fun expiryDate(expiryDate: OffsetDateTime?) = - expiryDate(JsonField.ofNullable(expiryDate)) - - /** - * An ISO 8601 format date that identifies the origination credit block to expire - */ - fun expiryDate(expiryDate: Optional) = - expiryDate(expiryDate.orElse(null)) - - /** - * An ISO 8601 format date that identifies the origination credit block to expire - */ - fun expiryDate(expiryDate: JsonField) = apply { - this.expiryDate = expiryDate - } - - /** - * 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. - */ - fun targetExpiryDate(targetExpiryDate: LocalDate) = - targetExpiryDate(JsonField.of(targetExpiryDate)) - - /** - * 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. - */ - fun targetExpiryDate(targetExpiryDate: JsonField) = apply { - this.targetExpiryDate = targetExpiryDate - } - - /** - * The number of credits to effect. Note that this is required for increment, - * decrement, void, or undo operations. - */ - fun amount(amount: Double?) = amount(JsonField.ofNullable(amount)) - - /** - * The number of credits to effect. Note that this is required for increment, - * decrement, void, or undo operations. - */ - fun amount(amount: Double) = amount(amount as Double?) - - /** - * The number of credits to effect. Note that this is required for increment, - * decrement, void, or undo operations. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun amount(amount: Optional) = amount(amount.orElse(null) as Double?) - - /** - * The number of credits to effect. Note that this is required for increment, - * decrement, void, or undo operations. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** - * The ID of the block affected by an expiration_change, used to differentiate - * between multiple blocks with the same `expiry_date`. - */ - fun blockId(blockId: String?) = blockId(JsonField.ofNullable(blockId)) - - /** - * The ID of the block affected by an expiration_change, used to differentiate - * between multiple blocks with the same `expiry_date`. - */ - fun blockId(blockId: Optional) = blockId(blockId.orElse(null)) - - /** - * The ID of the block affected by an expiration_change, used to differentiate - * between multiple blocks with the same `expiry_date`. - */ - fun blockId(blockId: JsonField) = apply { this.blockId = blockId } - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** - * Optional metadata that can be specified when adding ledger results via the API. - * For example, this can be used to note an increment refers to trial credits, or - * for noting corrections as a result of an incident, etc. - */ - fun description(description: String?) = - description(JsonField.ofNullable(description)) - - /** - * Optional metadata that can be specified when adding ledger results via the API. - * For example, this can be used to note an increment refers to trial credits, or - * for noting corrections as a result of an incident, etc. - */ - fun description(description: Optional) = - description(description.orElse(null)) - - /** - * Optional metadata that can be specified when adding ledger results via the API. - * For example, this can be used to note an increment refers to trial credits, or - * for noting corrections as a result of an incident, etc. - */ - fun description(description: JsonField) = apply { - this.description = description - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): AddExpirationChangeCreditLedgerEntryRequestParams = - AddExpirationChangeCreditLedgerEntryRequestParams( - checkRequired("entryType", entryType), - checkRequired("expiryDate", expiryDate), - checkRequired("targetExpiryDate", targetExpiryDate), - amount, - blockId, - currency, - description, - metadata, - additionalProperties.toImmutable(), - ) - } - - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val EXPIRATION_CHANGE = of("expiration_change") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - EXPIRATION_CHANGE - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - EXPIRATION_CHANGE, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - EXPIRATION_CHANGE -> Value.EXPIRATION_CHANGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - EXPIRATION_CHANGE -> Known.EXPIRATION_CHANGE - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AddExpirationChangeCreditLedgerEntryRequestParams && entryType == other.entryType && expiryDate == other.expiryDate && targetExpiryDate == other.targetExpiryDate && amount == other.amount && blockId == other.blockId && currency == other.currency && description == other.description && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(entryType, expiryDate, targetExpiryDate, amount, blockId, currency, description, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AddExpirationChangeCreditLedgerEntryRequestParams{entryType=$entryType, expiryDate=$expiryDate, targetExpiryDate=$targetExpiryDate, amount=$amount, blockId=$blockId, currency=$currency, description=$description, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class AddVoidCreditLedgerEntryRequestParams - @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("block_id") - @ExcludeMissing - private val blockId: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - private val entryType: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("void_reason") - @ExcludeMissing - private val voidReason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * The number of credits to effect. Note that this is required for increment, decrement, - * void, or undo operations. - */ - fun amount(): Double = amount.getRequired("amount") - - /** The ID of the block to void. */ - fun blockId(): String = blockId.getRequired("block_id") - - fun entryType(): EntryType = entryType.getRequired("entry_type") - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) - - /** - * Optional metadata that can be specified when adding ledger results via the API. For - * example, this can be used to note an increment refers to trial credits, or for noting - * corrections as a result of an incident, etc. - */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** Can only be specified when `entry_type=void`. The reason for the void. */ - fun voidReason(): Optional = - Optional.ofNullable(voidReason.getNullable("void_reason")) - - /** - * The number of credits to effect. Note that this is required for increment, decrement, - * void, or undo operations. - */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** The ID of the block to void. */ - @JsonProperty("block_id") @ExcludeMissing fun _blockId(): JsonField = blockId - - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** - * Optional metadata that can be specified when adding ledger results via the API. For - * example, this can be used to note an increment refers to trial credits, or for noting - * corrections as a result of an incident, etc. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - /** - * User-specified key/value pairs for the resource. 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("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** Can only be specified when `entry_type=void`. The reason for the void. */ - @JsonProperty("void_reason") - @ExcludeMissing - fun _voidReason(): JsonField = voidReason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AddVoidCreditLedgerEntryRequestParams = apply { - if (validated) { - return@apply - } - - amount() - blockId() - entryType() - currency() - description() - metadata().ifPresent { it.validate() } - voidReason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AddVoidCreditLedgerEntryRequestParams]. */ - class Builder internal constructor() { - - private var amount: JsonField? = null - private var blockId: JsonField? = null - private var entryType: JsonField? = null - private var currency: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var voidReason: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - addVoidCreditLedgerEntryRequestParams: AddVoidCreditLedgerEntryRequestParams - ) = apply { - amount = addVoidCreditLedgerEntryRequestParams.amount - blockId = addVoidCreditLedgerEntryRequestParams.blockId - entryType = addVoidCreditLedgerEntryRequestParams.entryType - currency = addVoidCreditLedgerEntryRequestParams.currency - description = addVoidCreditLedgerEntryRequestParams.description - metadata = addVoidCreditLedgerEntryRequestParams.metadata - voidReason = addVoidCreditLedgerEntryRequestParams.voidReason - additionalProperties = - addVoidCreditLedgerEntryRequestParams.additionalProperties.toMutableMap() - } - - /** - * The number of credits to effect. Note that this is required for increment, - * decrement, void, or undo operations. - */ - fun amount(amount: Double) = amount(JsonField.of(amount)) - - /** - * The number of credits to effect. Note that this is required for increment, - * decrement, void, or undo operations. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** The ID of the block to void. */ - fun blockId(blockId: String) = blockId(JsonField.of(blockId)) - - /** The ID of the block to void. */ - fun blockId(blockId: JsonField) = apply { this.blockId = blockId } - - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - - fun entryType(entryType: JsonField) = apply { - this.entryType = entryType - } - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** - * Optional metadata that can be specified when adding ledger results via the API. - * For example, this can be used to note an increment refers to trial credits, or - * for noting corrections as a result of an incident, etc. - */ - fun description(description: String?) = - description(JsonField.ofNullable(description)) - - /** - * Optional metadata that can be specified when adding ledger results via the API. - * For example, this can be used to note an increment refers to trial credits, or - * for noting corrections as a result of an incident, etc. - */ - fun description(description: Optional) = - description(description.orElse(null)) - - /** - * Optional metadata that can be specified when adding ledger results via the API. - * For example, this can be used to note an increment refers to trial credits, or - * for noting corrections as a result of an incident, etc. - */ - fun description(description: JsonField) = apply { - this.description = description - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: JsonField) = apply { this.metadata = metadata } - - /** Can only be specified when `entry_type=void`. The reason for the void. */ - fun voidReason(voidReason: VoidReason?) = - voidReason(JsonField.ofNullable(voidReason)) - - /** Can only be specified when `entry_type=void`. The reason for the void. */ - fun voidReason(voidReason: Optional) = - voidReason(voidReason.orElse(null)) - - /** Can only be specified when `entry_type=void`. The reason for the void. */ - fun voidReason(voidReason: JsonField) = apply { - this.voidReason = voidReason - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): AddVoidCreditLedgerEntryRequestParams = - AddVoidCreditLedgerEntryRequestParams( - checkRequired("amount", amount), - checkRequired("blockId", blockId), - checkRequired("entryType", entryType), - currency, - description, - metadata, - voidReason, - additionalProperties.toImmutable(), - ) - } - - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val VOID = of("void") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - VOID - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - VOID, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - VOID -> Value.VOID - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - VOID -> Known.VOID - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - /** Can only be specified when `entry_type=void`. The reason for the void. */ - class VoidReason - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val REFUND = of("refund") - - @JvmStatic fun of(value: String) = VoidReason(JsonField.of(value)) - } - - /** An enum containing [VoidReason]'s known values. */ - enum class Known { - REFUND - } - - /** - * An enum containing [VoidReason]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [VoidReason] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - REFUND, - /** - * An enum member indicating that [VoidReason] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - REFUND -> Value.REFUND - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - REFUND -> Known.REFUND - else -> throw OrbInvalidDataException("Unknown VoidReason: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is VoidReason && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AddVoidCreditLedgerEntryRequestParams && amount == other.amount && blockId == other.blockId && entryType == other.entryType && currency == other.currency && description == other.description && metadata == other.metadata && voidReason == other.voidReason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, blockId, entryType, currency, description, metadata, voidReason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AddVoidCreditLedgerEntryRequestParams{amount=$amount, blockId=$blockId, entryType=$entryType, currency=$currency, description=$description, metadata=$metadata, voidReason=$voidReason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class AddAmendmentCreditLedgerEntryRequestParams - @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("block_id") - @ExcludeMissing - private val blockId: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - private val entryType: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * The number of credits to effect. Note that this is required for increment, decrement - * or void operations. - */ - fun amount(): Double = amount.getRequired("amount") - - /** The ID of the block to reverse a decrement from. */ - fun blockId(): String = blockId.getRequired("block_id") - - fun entryType(): EntryType = entryType.getRequired("entry_type") - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) - - /** - * Optional metadata that can be specified when adding ledger results via the API. For - * example, this can be used to note an increment refers to trial credits, or for noting - * corrections as a result of an incident, etc. - */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * The number of credits to effect. Note that this is required for increment, decrement - * or void operations. - */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** The ID of the block to reverse a decrement from. */ - @JsonProperty("block_id") @ExcludeMissing fun _blockId(): JsonField = blockId - - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** - * Optional metadata that can be specified when adding ledger results via the API. For - * example, this can be used to note an increment refers to trial credits, or for noting - * corrections as a result of an incident, etc. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - /** - * User-specified key/value pairs for the resource. 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("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AddAmendmentCreditLedgerEntryRequestParams = apply { - if (validated) { - return@apply - } - - amount() - blockId() - entryType() - currency() - description() - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AddAmendmentCreditLedgerEntryRequestParams]. */ - class Builder internal constructor() { - - private var amount: JsonField? = null - private var blockId: JsonField? = null - private var entryType: JsonField? = null - private var currency: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - addAmendmentCreditLedgerEntryRequestParams: - AddAmendmentCreditLedgerEntryRequestParams - ) = apply { - amount = addAmendmentCreditLedgerEntryRequestParams.amount - blockId = addAmendmentCreditLedgerEntryRequestParams.blockId - entryType = addAmendmentCreditLedgerEntryRequestParams.entryType - currency = addAmendmentCreditLedgerEntryRequestParams.currency - description = addAmendmentCreditLedgerEntryRequestParams.description - metadata = addAmendmentCreditLedgerEntryRequestParams.metadata - additionalProperties = - addAmendmentCreditLedgerEntryRequestParams.additionalProperties - .toMutableMap() - } - - /** - * The number of credits to effect. Note that this is required for increment, - * decrement or void operations. - */ - fun amount(amount: Double) = amount(JsonField.of(amount)) - - /** - * The number of credits to effect. Note that this is required for increment, - * decrement or void operations. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** The ID of the block to reverse a decrement from. */ - fun blockId(blockId: String) = blockId(JsonField.of(blockId)) - - /** The ID of the block to reverse a decrement from. */ - fun blockId(blockId: JsonField) = apply { this.blockId = blockId } - - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - - fun entryType(entryType: JsonField) = apply { - this.entryType = entryType - } - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * The currency or custom pricing unit to use for this ledger entry. If this is a - * real-world currency, it must match the customer's invoicing currency. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** - * Optional metadata that can be specified when adding ledger results via the API. - * For example, this can be used to note an increment refers to trial credits, or - * for noting corrections as a result of an incident, etc. - */ - fun description(description: String?) = - description(JsonField.ofNullable(description)) - - /** - * Optional metadata that can be specified when adding ledger results via the API. - * For example, this can be used to note an increment refers to trial credits, or - * for noting corrections as a result of an incident, etc. - */ - fun description(description: Optional) = - description(description.orElse(null)) - - /** - * Optional metadata that can be specified when adding ledger results via the API. - * For example, this can be used to note an increment refers to trial credits, or - * for noting corrections as a result of an incident, etc. - */ - fun description(description: JsonField) = apply { - this.description = description - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): AddAmendmentCreditLedgerEntryRequestParams = - AddAmendmentCreditLedgerEntryRequestParams( - checkRequired("amount", amount), - checkRequired("blockId", blockId), - checkRequired("entryType", entryType), - currency, - description, - metadata, - additionalProperties.toImmutable(), - ) - } - - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val AMENDMENT = of("amendment") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - AMENDMENT - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMENDMENT, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMENDMENT -> Value.AMENDMENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AMENDMENT -> Known.AMENDMENT - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AddAmendmentCreditLedgerEntryRequestParams && amount == other.amount && blockId == other.blockId && entryType == other.entryType && currency == other.currency && description == other.description && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, blockId, entryType, currency, description, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AddAmendmentCreditLedgerEntryRequestParams{amount=$amount, blockId=$blockId, entryType=$entryType, currency=$currency, description=$description, metadata=$metadata, additionalProperties=$additionalProperties}" - } - } - fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of + * [CustomerCreditLedgerCreateEntryParams]. + * + * The following fields are required: + * ```java + * .customerId() + * .addCreditLedgerEntryRequest() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -3519,7 +162,7 @@ private constructor( class Builder internal constructor() { private var customerId: String? = null - private var body: Body? = null + private var addCreditLedgerEntryRequest: AddCreditLedgerEntryRequest? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -3528,7 +171,8 @@ private constructor( customerCreditLedgerCreateEntryParams: CustomerCreditLedgerCreateEntryParams ) = apply { customerId = customerCreditLedgerCreateEntryParams.customerId - body = customerCreditLedgerCreateEntryParams.body + addCreditLedgerEntryRequest = + customerCreditLedgerCreateEntryParams.addCreditLedgerEntryRequest additionalHeaders = customerCreditLedgerCreateEntryParams.additionalHeaders.toBuilder() additionalQueryParams = customerCreditLedgerCreateEntryParams.additionalQueryParams.toBuilder() @@ -3536,24 +180,26 @@ private constructor( fun customerId(customerId: String) = apply { this.customerId = customerId } - fun body(body: Body) = apply { this.body = body } + fun addCreditLedgerEntryRequest(addCreditLedgerEntryRequest: AddCreditLedgerEntryRequest) = + apply { + this.addCreditLedgerEntryRequest = addCreditLedgerEntryRequest + } - fun body( - addIncrementCreditLedgerEntryRequestParams: - Body.AddIncrementCreditLedgerEntryRequestParams + fun addCreditLedgerEntryRequest( + incrementCreditLedgerEntryRequestParams: + AddCreditLedgerEntryRequest.AddIncrementCreditLedgerEntryRequestParams ) = - body( - Body.ofAddIncrementCreditLedgerEntryRequestParams( - addIncrementCreditLedgerEntryRequestParams + addCreditLedgerEntryRequest( + AddCreditLedgerEntryRequest.ofIncrementCreditLedgerEntryRequestParams( + incrementCreditLedgerEntryRequestParams ) ) - fun addIncrementCreditLedgerEntryRequestParamsBody(amount: Double) = - body( - Body.AddIncrementCreditLedgerEntryRequestParams.builder() + fun addIncrementCreditLedgerEntryRequestParamsCreditLedgerEntryRequest(amount: Double) = + addCreditLedgerEntryRequest( + AddCreditLedgerEntryRequest.AddIncrementCreditLedgerEntryRequestParams.builder() .entryType( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams + AddCreditLedgerEntryRequest.AddIncrementCreditLedgerEntryRequestParams .EntryType .INCREMENT ) @@ -3561,22 +207,21 @@ private constructor( .build() ) - fun body( - addDecrementCreditLedgerEntryRequestParams: - Body.AddDecrementCreditLedgerEntryRequestParams + fun addCreditLedgerEntryRequest( + decrementCreditLedgerEntryRequestParams: + AddCreditLedgerEntryRequest.AddDecrementCreditLedgerEntryRequestParams ) = - body( - Body.ofAddDecrementCreditLedgerEntryRequestParams( - addDecrementCreditLedgerEntryRequestParams + addCreditLedgerEntryRequest( + AddCreditLedgerEntryRequest.ofDecrementCreditLedgerEntryRequestParams( + decrementCreditLedgerEntryRequestParams ) ) - fun addDecrementCreditLedgerEntryRequestParamsBody(amount: Double) = - body( - Body.AddDecrementCreditLedgerEntryRequestParams.builder() + fun addDecrementCreditLedgerEntryRequestParamsCreditLedgerEntryRequest(amount: Double) = + addCreditLedgerEntryRequest( + AddCreditLedgerEntryRequest.AddDecrementCreditLedgerEntryRequestParams.builder() .entryType( - CustomerCreditLedgerCreateEntryParams.Body - .AddDecrementCreditLedgerEntryRequestParams + AddCreditLedgerEntryRequest.AddDecrementCreditLedgerEntryRequestParams .EntryType .DECREMENT ) @@ -3584,30 +229,33 @@ private constructor( .build() ) - fun body( - addExpirationChangeCreditLedgerEntryRequestParams: - Body.AddExpirationChangeCreditLedgerEntryRequestParams + fun addCreditLedgerEntryRequest( + expirationChangeCreditLedgerEntryRequestParams: + AddCreditLedgerEntryRequest.AddExpirationChangeCreditLedgerEntryRequestParams ) = - body( - Body.ofAddExpirationChangeCreditLedgerEntryRequestParams( - addExpirationChangeCreditLedgerEntryRequestParams + addCreditLedgerEntryRequest( + AddCreditLedgerEntryRequest.ofExpirationChangeCreditLedgerEntryRequestParams( + expirationChangeCreditLedgerEntryRequestParams ) ) - fun body( - addVoidCreditLedgerEntryRequestParams: Body.AddVoidCreditLedgerEntryRequestParams + fun addCreditLedgerEntryRequest( + voidCreditLedgerEntryRequestParams: + AddCreditLedgerEntryRequest.AddVoidCreditLedgerEntryRequestParams ) = - body( - Body.ofAddVoidCreditLedgerEntryRequestParams(addVoidCreditLedgerEntryRequestParams) + addCreditLedgerEntryRequest( + AddCreditLedgerEntryRequest.ofVoidCreditLedgerEntryRequestParams( + voidCreditLedgerEntryRequestParams + ) ) - fun body( - addAmendmentCreditLedgerEntryRequestParams: - Body.AddAmendmentCreditLedgerEntryRequestParams + fun addCreditLedgerEntryRequest( + amendmentCreditLedgerEntryRequestParams: + AddCreditLedgerEntryRequest.AddAmendmentCreditLedgerEntryRequestParams ) = - body( - Body.ofAddAmendmentCreditLedgerEntryRequestParams( - addAmendmentCreditLedgerEntryRequestParams + addCreditLedgerEntryRequest( + AddCreditLedgerEntryRequest.ofAmendmentCreditLedgerEntryRequestParams( + amendmentCreditLedgerEntryRequestParams ) ) @@ -3712,7 +360,7 @@ private constructor( fun build(): CustomerCreditLedgerCreateEntryParams = CustomerCreditLedgerCreateEntryParams( checkRequired("customerId", customerId), - checkRequired("body", body), + checkRequired("addCreditLedgerEntryRequest", addCreditLedgerEntryRequest), additionalHeaders.build(), additionalQueryParams.build(), ) @@ -3723,11 +371,11 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditLedgerCreateEntryParams && customerId == other.customerId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is CustomerCreditLedgerCreateEntryParams && customerId == other.customerId && addCreditLedgerEntryRequest == other.addCreditLedgerEntryRequest && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(customerId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(customerId, addCreditLedgerEntryRequest, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "CustomerCreditLedgerCreateEntryParams{customerId=$customerId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "CustomerCreditLedgerCreateEntryParams{customerId=$customerId, addCreditLedgerEntryRequest=$addCreditLedgerEntryRequest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponse.kt deleted file mode 100644 index 891f99550..000000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponse.kt +++ /dev/null @@ -1,6780 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer -import com.withorb.api.core.Enum -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow -import com.withorb.api.core.immutableEmptyMap -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** - * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within - * Orb. - */ -@JsonDeserialize(using = CustomerCreditLedgerCreateEntryResponse.Deserializer::class) -@JsonSerialize(using = CustomerCreditLedgerCreateEntryResponse.Serializer::class) -class CustomerCreditLedgerCreateEntryResponse -private constructor( - private val incrementLedgerEntry: IncrementLedgerEntry? = null, - private val decrementLedgerEntry: DecrementLedgerEntry? = null, - private val expirationChangeLedgerEntry: ExpirationChangeLedgerEntry? = null, - private val creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry? = null, - private val voidLedgerEntry: VoidLedgerEntry? = null, - private val voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry? = null, - private val amendmentLedgerEntry: AmendmentLedgerEntry? = null, - private val _json: JsonValue? = null, -) { - - fun incrementLedgerEntry(): Optional = - Optional.ofNullable(incrementLedgerEntry) - - fun decrementLedgerEntry(): Optional = - Optional.ofNullable(decrementLedgerEntry) - - fun expirationChangeLedgerEntry(): Optional = - Optional.ofNullable(expirationChangeLedgerEntry) - - fun creditBlockExpiryLedgerEntry(): Optional = - Optional.ofNullable(creditBlockExpiryLedgerEntry) - - fun voidLedgerEntry(): Optional = Optional.ofNullable(voidLedgerEntry) - - fun voidInitiatedLedgerEntry(): Optional = - Optional.ofNullable(voidInitiatedLedgerEntry) - - fun amendmentLedgerEntry(): Optional = - Optional.ofNullable(amendmentLedgerEntry) - - fun isIncrementLedgerEntry(): Boolean = incrementLedgerEntry != null - - fun isDecrementLedgerEntry(): Boolean = decrementLedgerEntry != null - - fun isExpirationChangeLedgerEntry(): Boolean = expirationChangeLedgerEntry != null - - fun isCreditBlockExpiryLedgerEntry(): Boolean = creditBlockExpiryLedgerEntry != null - - fun isVoidLedgerEntry(): Boolean = voidLedgerEntry != null - - fun isVoidInitiatedLedgerEntry(): Boolean = voidInitiatedLedgerEntry != null - - fun isAmendmentLedgerEntry(): Boolean = amendmentLedgerEntry != null - - fun asIncrementLedgerEntry(): IncrementLedgerEntry = - incrementLedgerEntry.getOrThrow("incrementLedgerEntry") - - fun asDecrementLedgerEntry(): DecrementLedgerEntry = - decrementLedgerEntry.getOrThrow("decrementLedgerEntry") - - fun asExpirationChangeLedgerEntry(): ExpirationChangeLedgerEntry = - expirationChangeLedgerEntry.getOrThrow("expirationChangeLedgerEntry") - - fun asCreditBlockExpiryLedgerEntry(): CreditBlockExpiryLedgerEntry = - creditBlockExpiryLedgerEntry.getOrThrow("creditBlockExpiryLedgerEntry") - - fun asVoidLedgerEntry(): VoidLedgerEntry = voidLedgerEntry.getOrThrow("voidLedgerEntry") - - fun asVoidInitiatedLedgerEntry(): VoidInitiatedLedgerEntry = - voidInitiatedLedgerEntry.getOrThrow("voidInitiatedLedgerEntry") - - fun asAmendmentLedgerEntry(): AmendmentLedgerEntry = - amendmentLedgerEntry.getOrThrow("amendmentLedgerEntry") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - incrementLedgerEntry != null -> visitor.visitIncrementLedgerEntry(incrementLedgerEntry) - decrementLedgerEntry != null -> visitor.visitDecrementLedgerEntry(decrementLedgerEntry) - expirationChangeLedgerEntry != null -> - visitor.visitExpirationChangeLedgerEntry(expirationChangeLedgerEntry) - creditBlockExpiryLedgerEntry != null -> - visitor.visitCreditBlockExpiryLedgerEntry(creditBlockExpiryLedgerEntry) - voidLedgerEntry != null -> visitor.visitVoidLedgerEntry(voidLedgerEntry) - voidInitiatedLedgerEntry != null -> - visitor.visitVoidInitiatedLedgerEntry(voidInitiatedLedgerEntry) - amendmentLedgerEntry != null -> visitor.visitAmendmentLedgerEntry(amendmentLedgerEntry) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): CustomerCreditLedgerCreateEntryResponse = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitIncrementLedgerEntry(incrementLedgerEntry: IncrementLedgerEntry) { - incrementLedgerEntry.validate() - } - - override fun visitDecrementLedgerEntry(decrementLedgerEntry: DecrementLedgerEntry) { - decrementLedgerEntry.validate() - } - - override fun visitExpirationChangeLedgerEntry( - expirationChangeLedgerEntry: ExpirationChangeLedgerEntry - ) { - expirationChangeLedgerEntry.validate() - } - - override fun visitCreditBlockExpiryLedgerEntry( - creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry - ) { - creditBlockExpiryLedgerEntry.validate() - } - - override fun visitVoidLedgerEntry(voidLedgerEntry: VoidLedgerEntry) { - voidLedgerEntry.validate() - } - - override fun visitVoidInitiatedLedgerEntry( - voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry - ) { - voidInitiatedLedgerEntry.validate() - } - - override fun visitAmendmentLedgerEntry(amendmentLedgerEntry: AmendmentLedgerEntry) { - amendmentLedgerEntry.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CustomerCreditLedgerCreateEntryResponse && incrementLedgerEntry == other.incrementLedgerEntry && decrementLedgerEntry == other.decrementLedgerEntry && expirationChangeLedgerEntry == other.expirationChangeLedgerEntry && creditBlockExpiryLedgerEntry == other.creditBlockExpiryLedgerEntry && voidLedgerEntry == other.voidLedgerEntry && voidInitiatedLedgerEntry == other.voidInitiatedLedgerEntry && amendmentLedgerEntry == other.amendmentLedgerEntry /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(incrementLedgerEntry, decrementLedgerEntry, expirationChangeLedgerEntry, creditBlockExpiryLedgerEntry, voidLedgerEntry, voidInitiatedLedgerEntry, amendmentLedgerEntry) /* spotless:on */ - - override fun toString(): String = - when { - incrementLedgerEntry != null -> - "CustomerCreditLedgerCreateEntryResponse{incrementLedgerEntry=$incrementLedgerEntry}" - decrementLedgerEntry != null -> - "CustomerCreditLedgerCreateEntryResponse{decrementLedgerEntry=$decrementLedgerEntry}" - expirationChangeLedgerEntry != null -> - "CustomerCreditLedgerCreateEntryResponse{expirationChangeLedgerEntry=$expirationChangeLedgerEntry}" - creditBlockExpiryLedgerEntry != null -> - "CustomerCreditLedgerCreateEntryResponse{creditBlockExpiryLedgerEntry=$creditBlockExpiryLedgerEntry}" - voidLedgerEntry != null -> - "CustomerCreditLedgerCreateEntryResponse{voidLedgerEntry=$voidLedgerEntry}" - voidInitiatedLedgerEntry != null -> - "CustomerCreditLedgerCreateEntryResponse{voidInitiatedLedgerEntry=$voidInitiatedLedgerEntry}" - amendmentLedgerEntry != null -> - "CustomerCreditLedgerCreateEntryResponse{amendmentLedgerEntry=$amendmentLedgerEntry}" - _json != null -> "CustomerCreditLedgerCreateEntryResponse{_unknown=$_json}" - else -> throw IllegalStateException("Invalid CustomerCreditLedgerCreateEntryResponse") - } - - companion object { - - @JvmStatic - fun ofIncrementLedgerEntry(incrementLedgerEntry: IncrementLedgerEntry) = - CustomerCreditLedgerCreateEntryResponse(incrementLedgerEntry = incrementLedgerEntry) - - @JvmStatic - fun ofDecrementLedgerEntry(decrementLedgerEntry: DecrementLedgerEntry) = - CustomerCreditLedgerCreateEntryResponse(decrementLedgerEntry = decrementLedgerEntry) - - @JvmStatic - fun ofExpirationChangeLedgerEntry( - expirationChangeLedgerEntry: ExpirationChangeLedgerEntry - ) = - CustomerCreditLedgerCreateEntryResponse( - expirationChangeLedgerEntry = expirationChangeLedgerEntry - ) - - @JvmStatic - fun ofCreditBlockExpiryLedgerEntry( - creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry - ) = - CustomerCreditLedgerCreateEntryResponse( - creditBlockExpiryLedgerEntry = creditBlockExpiryLedgerEntry - ) - - @JvmStatic - fun ofVoidLedgerEntry(voidLedgerEntry: VoidLedgerEntry) = - CustomerCreditLedgerCreateEntryResponse(voidLedgerEntry = voidLedgerEntry) - - @JvmStatic - fun ofVoidInitiatedLedgerEntry(voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry) = - CustomerCreditLedgerCreateEntryResponse( - voidInitiatedLedgerEntry = voidInitiatedLedgerEntry - ) - - @JvmStatic - fun ofAmendmentLedgerEntry(amendmentLedgerEntry: AmendmentLedgerEntry) = - CustomerCreditLedgerCreateEntryResponse(amendmentLedgerEntry = amendmentLedgerEntry) - } - - /** - * An interface that defines how to map each variant of - * [CustomerCreditLedgerCreateEntryResponse] to a value of type [T]. - */ - interface Visitor { - - fun visitIncrementLedgerEntry(incrementLedgerEntry: IncrementLedgerEntry): T - - fun visitDecrementLedgerEntry(decrementLedgerEntry: DecrementLedgerEntry): T - - fun visitExpirationChangeLedgerEntry( - expirationChangeLedgerEntry: ExpirationChangeLedgerEntry - ): T - - fun visitCreditBlockExpiryLedgerEntry( - creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry - ): T - - fun visitVoidLedgerEntry(voidLedgerEntry: VoidLedgerEntry): T - - fun visitVoidInitiatedLedgerEntry(voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry): T - - fun visitAmendmentLedgerEntry(amendmentLedgerEntry: AmendmentLedgerEntry): T - - /** - * Maps an unknown variant of [CustomerCreditLedgerCreateEntryResponse] to a value of type - * [T]. - * - * An instance of [CustomerCreditLedgerCreateEntryResponse] can contain an unknown variant - * if it was deserialized from data that doesn't match any known variant. For example, if - * the SDK is on an older version than the API, then the API may respond with new variants - * that the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown CustomerCreditLedgerCreateEntryResponse: $json") - } - } - - internal class Deserializer : - BaseDeserializer( - CustomerCreditLedgerCreateEntryResponse::class - ) { - - override fun ObjectCodec.deserialize( - node: JsonNode - ): CustomerCreditLedgerCreateEntryResponse { - val json = JsonValue.fromJsonNode(node) - val entryType = json.asObject().getOrNull()?.get("entry_type")?.asString()?.getOrNull() - - when (entryType) { - "increment" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return CustomerCreditLedgerCreateEntryResponse( - incrementLedgerEntry = it, - _json = json, - ) - } - } - "decrement" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return CustomerCreditLedgerCreateEntryResponse( - decrementLedgerEntry = it, - _json = json, - ) - } - } - "expiration_change" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return CustomerCreditLedgerCreateEntryResponse( - expirationChangeLedgerEntry = it, - _json = json, - ) - } - } - "credit_block_expiry" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return CustomerCreditLedgerCreateEntryResponse( - creditBlockExpiryLedgerEntry = it, - _json = json, - ) - } - } - "void" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return CustomerCreditLedgerCreateEntryResponse( - voidLedgerEntry = it, - _json = json, - ) - } - } - "void_initiated" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return CustomerCreditLedgerCreateEntryResponse( - voidInitiatedLedgerEntry = it, - _json = json, - ) - } - } - "amendment" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return CustomerCreditLedgerCreateEntryResponse( - amendmentLedgerEntry = it, - _json = json, - ) - } - } - } - - return CustomerCreditLedgerCreateEntryResponse(_json = json) - } - } - - internal class Serializer : - BaseSerializer( - CustomerCreditLedgerCreateEntryResponse::class - ) { - - override fun serialize( - value: CustomerCreditLedgerCreateEntryResponse, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.incrementLedgerEntry != null -> - generator.writeObject(value.incrementLedgerEntry) - value.decrementLedgerEntry != null -> - generator.writeObject(value.decrementLedgerEntry) - value.expirationChangeLedgerEntry != null -> - generator.writeObject(value.expirationChangeLedgerEntry) - value.creditBlockExpiryLedgerEntry != null -> - generator.writeObject(value.creditBlockExpiryLedgerEntry) - value.voidLedgerEntry != null -> generator.writeObject(value.voidLedgerEntry) - value.voidInitiatedLedgerEntry != null -> - generator.writeObject(value.voidInitiatedLedgerEntry) - value.amendmentLedgerEntry != null -> - generator.writeObject(value.amendmentLedgerEntry) - value._json != null -> generator.writeObject(value._json) - else -> - throw IllegalStateException("Invalid CustomerCreditLedgerCreateEntryResponse") - } - } - } - - @NoAutoDetect - class IncrementLedgerEntry - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("credit_block") - @ExcludeMissing - private val creditBlock: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("customer") - @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("ending_balance") - @ExcludeMissing - private val endingBalance: JsonField = JsonMissing.of(), - @JsonProperty("entry_status") - @ExcludeMissing - private val entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - private val entryType: JsonField = JsonMissing.of(), - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - private val ledgerSequenceNumber: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("starting_balance") - @ExcludeMissing - private val startingBalance: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun amount(): Double = amount.getRequired("amount") - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - fun creditBlock(): CreditBlock = creditBlock.getRequired("credit_block") - - fun currency(): String = currency.getRequired("currency") - - fun customer(): Customer = customer.getRequired("customer") - - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - fun endingBalance(): Double = endingBalance.getRequired("ending_balance") - - fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") - - fun entryType(): EntryType = entryType.getRequired("entry_type") - - fun ledgerSequenceNumber(): Long = - ledgerSequenceNumber.getRequired("ledger_sequence_number") - - /** - * 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.getRequired("metadata") - - fun startingBalance(): Double = startingBalance.getRequired("starting_balance") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - @JsonProperty("credit_block") - @ExcludeMissing - fun _creditBlock(): JsonField = creditBlock - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - @JsonProperty("ending_balance") - @ExcludeMissing - fun _endingBalance(): JsonField = endingBalance - - @JsonProperty("entry_status") - @ExcludeMissing - fun _entryStatus(): JsonField = entryStatus - - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber - - /** - * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - @JsonProperty("starting_balance") - @ExcludeMissing - fun _startingBalance(): JsonField = startingBalance - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): IncrementLedgerEntry = apply { - if (validated) { - return@apply - } - - id() - amount() - createdAt() - creditBlock().validate() - currency() - customer().validate() - description() - endingBalance() - entryStatus() - entryType() - ledgerSequenceNumber() - metadata().validate() - startingBalance() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [IncrementLedgerEntry]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var amount: JsonField? = null - private var createdAt: JsonField? = null - private var creditBlock: JsonField? = null - private var currency: JsonField? = null - private var customer: JsonField? = null - private var description: JsonField? = null - private var endingBalance: JsonField? = null - private var entryStatus: JsonField? = null - private var entryType: JsonField? = null - private var ledgerSequenceNumber: JsonField? = null - private var metadata: JsonField? = null - private var startingBalance: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(incrementLedgerEntry: IncrementLedgerEntry) = apply { - id = incrementLedgerEntry.id - amount = incrementLedgerEntry.amount - createdAt = incrementLedgerEntry.createdAt - creditBlock = incrementLedgerEntry.creditBlock - currency = incrementLedgerEntry.currency - customer = incrementLedgerEntry.customer - description = incrementLedgerEntry.description - endingBalance = incrementLedgerEntry.endingBalance - entryStatus = incrementLedgerEntry.entryStatus - entryType = incrementLedgerEntry.entryType - ledgerSequenceNumber = incrementLedgerEntry.ledgerSequenceNumber - metadata = incrementLedgerEntry.metadata - startingBalance = incrementLedgerEntry.startingBalance - additionalProperties = incrementLedgerEntry.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun amount(amount: Double) = amount(JsonField.of(amount)) - - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { - this.createdAt = createdAt - } - - fun creditBlock(creditBlock: CreditBlock) = creditBlock(JsonField.of(creditBlock)) - - fun creditBlock(creditBlock: JsonField) = apply { - this.creditBlock = creditBlock - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun customer(customer: Customer) = customer(JsonField.of(customer)) - - fun customer(customer: JsonField) = apply { this.customer = customer } - - fun description(description: String?) = description(JsonField.ofNullable(description)) - - fun description(description: Optional) = description(description.orElse(null)) - - fun description(description: JsonField) = apply { - this.description = description - } - - fun endingBalance(endingBalance: Double) = endingBalance(JsonField.of(endingBalance)) - - fun endingBalance(endingBalance: JsonField) = apply { - this.endingBalance = endingBalance - } - - fun entryStatus(entryStatus: EntryStatus) = entryStatus(JsonField.of(entryStatus)) - - fun entryStatus(entryStatus: JsonField) = apply { - this.entryStatus = entryStatus - } - - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } - - fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = - ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) - - fun ledgerSequenceNumber(ledgerSequenceNumber: JsonField) = apply { - this.ledgerSequenceNumber = ledgerSequenceNumber - } - - /** - * 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - fun startingBalance(startingBalance: Double) = - startingBalance(JsonField.of(startingBalance)) - - fun startingBalance(startingBalance: JsonField) = apply { - this.startingBalance = startingBalance - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): IncrementLedgerEntry = - IncrementLedgerEntry( - checkRequired("id", id), - checkRequired("amount", amount), - checkRequired("createdAt", createdAt), - checkRequired("creditBlock", creditBlock), - checkRequired("currency", currency), - checkRequired("customer", customer), - checkRequired("description", description), - checkRequired("endingBalance", endingBalance), - checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), - checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), - checkRequired("metadata", metadata), - checkRequired("startingBalance", startingBalance), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class CreditBlock - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("expiry_date") - @ExcludeMissing - private val expiryDate: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - private val perUnitCostBasis: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun expiryDate(): Optional = - Optional.ofNullable(expiryDate.getNullable("expiry_date")) - - fun perUnitCostBasis(): Optional = - Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("expiry_date") - @ExcludeMissing - fun _expiryDate(): JsonField = expiryDate - - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - fun _perUnitCostBasis(): JsonField = perUnitCostBasis - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditBlock = apply { - if (validated) { - return@apply - } - - id() - expiryDate() - perUnitCostBasis() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditBlock]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var expiryDate: JsonField? = null - private var perUnitCostBasis: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditBlock: CreditBlock) = apply { - id = creditBlock.id - expiryDate = creditBlock.expiryDate - perUnitCostBasis = creditBlock.perUnitCostBasis - additionalProperties = creditBlock.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun expiryDate(expiryDate: OffsetDateTime?) = - expiryDate(JsonField.ofNullable(expiryDate)) - - fun expiryDate(expiryDate: Optional) = - expiryDate(expiryDate.orElse(null)) - - fun expiryDate(expiryDate: JsonField) = apply { - this.expiryDate = expiryDate - } - - fun perUnitCostBasis(perUnitCostBasis: String?) = - perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) - - fun perUnitCostBasis(perUnitCostBasis: Optional) = - perUnitCostBasis(perUnitCostBasis.orElse(null)) - - fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { - this.perUnitCostBasis = perUnitCostBasis - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditBlock = - CreditBlock( - checkRequired("id", id), - checkRequired("expiryDate", expiryDate), - checkRequired("perUnitCostBasis", perUnitCostBasis), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditBlock && id == other.id && expiryDate == other.expiryDate && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, expiryDate, perUnitCostBasis, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditBlock{id=$id, expiryDate=$expiryDate, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Customer - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("external_customer_id") - @ExcludeMissing - private val externalCustomerId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun externalCustomerId(): Optional = - Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("external_customer_id") - @ExcludeMissing - fun _externalCustomerId(): JsonField = externalCustomerId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Customer = apply { - if (validated) { - return@apply - } - - id() - externalCustomerId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Customer]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var externalCustomerId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customer: Customer) = apply { - id = customer.id - externalCustomerId = customer.externalCustomerId - additionalProperties = customer.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun externalCustomerId(externalCustomerId: String?) = - externalCustomerId(JsonField.ofNullable(externalCustomerId)) - - fun externalCustomerId(externalCustomerId: Optional) = - externalCustomerId(externalCustomerId.orElse(null)) - - fun externalCustomerId(externalCustomerId: JsonField) = apply { - this.externalCustomerId = externalCustomerId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Customer = - Customer( - checkRequired("id", id), - checkRequired("externalCustomerId", externalCustomerId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Customer && id == other.id && externalCustomerId == other.externalCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, externalCustomerId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Customer{id=$id, externalCustomerId=$externalCustomerId, additionalProperties=$additionalProperties}" - } - - class EntryStatus @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val COMMITTED = of("committed") - - @JvmField val PENDING = of("pending") - - @JvmStatic fun of(value: String) = EntryStatus(JsonField.of(value)) - } - - /** An enum containing [EntryStatus]'s known values. */ - enum class Known { - COMMITTED, - PENDING, - } - - /** - * An enum containing [EntryStatus]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryStatus] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - COMMITTED, - PENDING, - /** - * An enum member indicating that [EntryStatus] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - COMMITTED -> Value.COMMITTED - PENDING -> Value.PENDING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - COMMITTED -> Known.COMMITTED - PENDING -> Known.PENDING - else -> throw OrbInvalidDataException("Unknown EntryStatus: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryStatus && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val INCREMENT = of("increment") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - INCREMENT - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - INCREMENT, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - INCREMENT -> Value.INCREMENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - INCREMENT -> Known.INCREMENT - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is IncrementLedgerEntry && id == other.id && amount == other.amount && createdAt == other.createdAt && creditBlock == other.creditBlock && currency == other.currency && customer == other.customer && description == other.description && endingBalance == other.endingBalance && entryStatus == other.entryStatus && entryType == other.entryType && ledgerSequenceNumber == other.ledgerSequenceNumber && metadata == other.metadata && startingBalance == other.startingBalance && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, createdAt, creditBlock, currency, customer, description, endingBalance, entryStatus, entryType, ledgerSequenceNumber, metadata, startingBalance, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "IncrementLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class DecrementLedgerEntry - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("credit_block") - @ExcludeMissing - private val creditBlock: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("customer") - @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("ending_balance") - @ExcludeMissing - private val endingBalance: JsonField = JsonMissing.of(), - @JsonProperty("entry_status") - @ExcludeMissing - private val entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - private val entryType: JsonField = JsonMissing.of(), - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - private val ledgerSequenceNumber: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("starting_balance") - @ExcludeMissing - private val startingBalance: JsonField = JsonMissing.of(), - @JsonProperty("event_id") - @ExcludeMissing - private val eventId: JsonField = JsonMissing.of(), - @JsonProperty("invoice_id") - @ExcludeMissing - private val invoiceId: JsonField = JsonMissing.of(), - @JsonProperty("price_id") - @ExcludeMissing - private val priceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun amount(): Double = amount.getRequired("amount") - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - fun creditBlock(): CreditBlock = creditBlock.getRequired("credit_block") - - fun currency(): String = currency.getRequired("currency") - - fun customer(): Customer = customer.getRequired("customer") - - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - fun endingBalance(): Double = endingBalance.getRequired("ending_balance") - - fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") - - fun entryType(): EntryType = entryType.getRequired("entry_type") - - fun ledgerSequenceNumber(): Long = - ledgerSequenceNumber.getRequired("ledger_sequence_number") - - /** - * 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.getRequired("metadata") - - fun startingBalance(): Double = startingBalance.getRequired("starting_balance") - - fun eventId(): Optional = Optional.ofNullable(eventId.getNullable("event_id")) - - fun invoiceId(): Optional = Optional.ofNullable(invoiceId.getNullable("invoice_id")) - - fun priceId(): Optional = Optional.ofNullable(priceId.getNullable("price_id")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - @JsonProperty("credit_block") - @ExcludeMissing - fun _creditBlock(): JsonField = creditBlock - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - @JsonProperty("ending_balance") - @ExcludeMissing - fun _endingBalance(): JsonField = endingBalance - - @JsonProperty("entry_status") - @ExcludeMissing - fun _entryStatus(): JsonField = entryStatus - - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber - - /** - * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - @JsonProperty("starting_balance") - @ExcludeMissing - fun _startingBalance(): JsonField = startingBalance - - @JsonProperty("event_id") @ExcludeMissing fun _eventId(): JsonField = eventId - - @JsonProperty("invoice_id") @ExcludeMissing fun _invoiceId(): JsonField = invoiceId - - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): DecrementLedgerEntry = apply { - if (validated) { - return@apply - } - - id() - amount() - createdAt() - creditBlock().validate() - currency() - customer().validate() - description() - endingBalance() - entryStatus() - entryType() - ledgerSequenceNumber() - metadata().validate() - startingBalance() - eventId() - invoiceId() - priceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DecrementLedgerEntry]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var amount: JsonField? = null - private var createdAt: JsonField? = null - private var creditBlock: JsonField? = null - private var currency: JsonField? = null - private var customer: JsonField? = null - private var description: JsonField? = null - private var endingBalance: JsonField? = null - private var entryStatus: JsonField? = null - private var entryType: JsonField? = null - private var ledgerSequenceNumber: JsonField? = null - private var metadata: JsonField? = null - private var startingBalance: JsonField? = null - private var eventId: JsonField = JsonMissing.of() - private var invoiceId: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(decrementLedgerEntry: DecrementLedgerEntry) = apply { - id = decrementLedgerEntry.id - amount = decrementLedgerEntry.amount - createdAt = decrementLedgerEntry.createdAt - creditBlock = decrementLedgerEntry.creditBlock - currency = decrementLedgerEntry.currency - customer = decrementLedgerEntry.customer - description = decrementLedgerEntry.description - endingBalance = decrementLedgerEntry.endingBalance - entryStatus = decrementLedgerEntry.entryStatus - entryType = decrementLedgerEntry.entryType - ledgerSequenceNumber = decrementLedgerEntry.ledgerSequenceNumber - metadata = decrementLedgerEntry.metadata - startingBalance = decrementLedgerEntry.startingBalance - eventId = decrementLedgerEntry.eventId - invoiceId = decrementLedgerEntry.invoiceId - priceId = decrementLedgerEntry.priceId - additionalProperties = decrementLedgerEntry.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun amount(amount: Double) = amount(JsonField.of(amount)) - - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { - this.createdAt = createdAt - } - - fun creditBlock(creditBlock: CreditBlock) = creditBlock(JsonField.of(creditBlock)) - - fun creditBlock(creditBlock: JsonField) = apply { - this.creditBlock = creditBlock - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun customer(customer: Customer) = customer(JsonField.of(customer)) - - fun customer(customer: JsonField) = apply { this.customer = customer } - - fun description(description: String?) = description(JsonField.ofNullable(description)) - - fun description(description: Optional) = description(description.orElse(null)) - - fun description(description: JsonField) = apply { - this.description = description - } - - fun endingBalance(endingBalance: Double) = endingBalance(JsonField.of(endingBalance)) - - fun endingBalance(endingBalance: JsonField) = apply { - this.endingBalance = endingBalance - } - - fun entryStatus(entryStatus: EntryStatus) = entryStatus(JsonField.of(entryStatus)) - - fun entryStatus(entryStatus: JsonField) = apply { - this.entryStatus = entryStatus - } - - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } - - fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = - ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) - - fun ledgerSequenceNumber(ledgerSequenceNumber: JsonField) = apply { - this.ledgerSequenceNumber = ledgerSequenceNumber - } - - /** - * 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - fun startingBalance(startingBalance: Double) = - startingBalance(JsonField.of(startingBalance)) - - fun startingBalance(startingBalance: JsonField) = apply { - this.startingBalance = startingBalance - } - - fun eventId(eventId: String?) = eventId(JsonField.ofNullable(eventId)) - - fun eventId(eventId: Optional) = eventId(eventId.orElse(null)) - - fun eventId(eventId: JsonField) = apply { this.eventId = eventId } - - fun invoiceId(invoiceId: String?) = invoiceId(JsonField.ofNullable(invoiceId)) - - fun invoiceId(invoiceId: Optional) = invoiceId(invoiceId.orElse(null)) - - fun invoiceId(invoiceId: JsonField) = apply { this.invoiceId = invoiceId } - - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) - - fun priceId(priceId: Optional) = priceId(priceId.orElse(null)) - - 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) - } - - fun build(): DecrementLedgerEntry = - DecrementLedgerEntry( - checkRequired("id", id), - checkRequired("amount", amount), - checkRequired("createdAt", createdAt), - checkRequired("creditBlock", creditBlock), - checkRequired("currency", currency), - checkRequired("customer", customer), - checkRequired("description", description), - checkRequired("endingBalance", endingBalance), - checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), - checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), - checkRequired("metadata", metadata), - checkRequired("startingBalance", startingBalance), - eventId, - invoiceId, - priceId, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class CreditBlock - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("expiry_date") - @ExcludeMissing - private val expiryDate: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - private val perUnitCostBasis: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun expiryDate(): Optional = - Optional.ofNullable(expiryDate.getNullable("expiry_date")) - - fun perUnitCostBasis(): Optional = - Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("expiry_date") - @ExcludeMissing - fun _expiryDate(): JsonField = expiryDate - - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - fun _perUnitCostBasis(): JsonField = perUnitCostBasis - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditBlock = apply { - if (validated) { - return@apply - } - - id() - expiryDate() - perUnitCostBasis() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditBlock]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var expiryDate: JsonField? = null - private var perUnitCostBasis: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditBlock: CreditBlock) = apply { - id = creditBlock.id - expiryDate = creditBlock.expiryDate - perUnitCostBasis = creditBlock.perUnitCostBasis - additionalProperties = creditBlock.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun expiryDate(expiryDate: OffsetDateTime?) = - expiryDate(JsonField.ofNullable(expiryDate)) - - fun expiryDate(expiryDate: Optional) = - expiryDate(expiryDate.orElse(null)) - - fun expiryDate(expiryDate: JsonField) = apply { - this.expiryDate = expiryDate - } - - fun perUnitCostBasis(perUnitCostBasis: String?) = - perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) - - fun perUnitCostBasis(perUnitCostBasis: Optional) = - perUnitCostBasis(perUnitCostBasis.orElse(null)) - - fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { - this.perUnitCostBasis = perUnitCostBasis - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditBlock = - CreditBlock( - checkRequired("id", id), - checkRequired("expiryDate", expiryDate), - checkRequired("perUnitCostBasis", perUnitCostBasis), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditBlock && id == other.id && expiryDate == other.expiryDate && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, expiryDate, perUnitCostBasis, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditBlock{id=$id, expiryDate=$expiryDate, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Customer - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("external_customer_id") - @ExcludeMissing - private val externalCustomerId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun externalCustomerId(): Optional = - Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("external_customer_id") - @ExcludeMissing - fun _externalCustomerId(): JsonField = externalCustomerId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Customer = apply { - if (validated) { - return@apply - } - - id() - externalCustomerId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Customer]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var externalCustomerId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customer: Customer) = apply { - id = customer.id - externalCustomerId = customer.externalCustomerId - additionalProperties = customer.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun externalCustomerId(externalCustomerId: String?) = - externalCustomerId(JsonField.ofNullable(externalCustomerId)) - - fun externalCustomerId(externalCustomerId: Optional) = - externalCustomerId(externalCustomerId.orElse(null)) - - fun externalCustomerId(externalCustomerId: JsonField) = apply { - this.externalCustomerId = externalCustomerId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Customer = - Customer( - checkRequired("id", id), - checkRequired("externalCustomerId", externalCustomerId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Customer && id == other.id && externalCustomerId == other.externalCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, externalCustomerId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Customer{id=$id, externalCustomerId=$externalCustomerId, additionalProperties=$additionalProperties}" - } - - class EntryStatus @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val COMMITTED = of("committed") - - @JvmField val PENDING = of("pending") - - @JvmStatic fun of(value: String) = EntryStatus(JsonField.of(value)) - } - - /** An enum containing [EntryStatus]'s known values. */ - enum class Known { - COMMITTED, - PENDING, - } - - /** - * An enum containing [EntryStatus]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryStatus] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - COMMITTED, - PENDING, - /** - * An enum member indicating that [EntryStatus] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - COMMITTED -> Value.COMMITTED - PENDING -> Value.PENDING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - COMMITTED -> Known.COMMITTED - PENDING -> Known.PENDING - else -> throw OrbInvalidDataException("Unknown EntryStatus: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryStatus && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DECREMENT = of("decrement") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - DECREMENT - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DECREMENT, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DECREMENT -> Value.DECREMENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - DECREMENT -> Known.DECREMENT - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DecrementLedgerEntry && id == other.id && amount == other.amount && createdAt == other.createdAt && creditBlock == other.creditBlock && currency == other.currency && customer == other.customer && description == other.description && endingBalance == other.endingBalance && entryStatus == other.entryStatus && entryType == other.entryType && ledgerSequenceNumber == other.ledgerSequenceNumber && metadata == other.metadata && startingBalance == other.startingBalance && eventId == other.eventId && invoiceId == other.invoiceId && priceId == other.priceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, createdAt, creditBlock, currency, customer, description, endingBalance, entryStatus, entryType, ledgerSequenceNumber, metadata, startingBalance, eventId, invoiceId, priceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DecrementLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, eventId=$eventId, invoiceId=$invoiceId, priceId=$priceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class ExpirationChangeLedgerEntry - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("credit_block") - @ExcludeMissing - private val creditBlock: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("customer") - @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("ending_balance") - @ExcludeMissing - private val endingBalance: JsonField = JsonMissing.of(), - @JsonProperty("entry_status") - @ExcludeMissing - private val entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - private val entryType: JsonField = JsonMissing.of(), - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - private val ledgerSequenceNumber: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("new_block_expiry_date") - @ExcludeMissing - private val newBlockExpiryDate: JsonField = JsonMissing.of(), - @JsonProperty("starting_balance") - @ExcludeMissing - private val startingBalance: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun amount(): Double = amount.getRequired("amount") - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - fun creditBlock(): CreditBlock = creditBlock.getRequired("credit_block") - - fun currency(): String = currency.getRequired("currency") - - fun customer(): Customer = customer.getRequired("customer") - - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - fun endingBalance(): Double = endingBalance.getRequired("ending_balance") - - fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") - - fun entryType(): EntryType = entryType.getRequired("entry_type") - - fun ledgerSequenceNumber(): Long = - ledgerSequenceNumber.getRequired("ledger_sequence_number") - - /** - * 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.getRequired("metadata") - - fun newBlockExpiryDate(): Optional = - Optional.ofNullable(newBlockExpiryDate.getNullable("new_block_expiry_date")) - - fun startingBalance(): Double = startingBalance.getRequired("starting_balance") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - @JsonProperty("credit_block") - @ExcludeMissing - fun _creditBlock(): JsonField = creditBlock - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - @JsonProperty("ending_balance") - @ExcludeMissing - fun _endingBalance(): JsonField = endingBalance - - @JsonProperty("entry_status") - @ExcludeMissing - fun _entryStatus(): JsonField = entryStatus - - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber - - /** - * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - @JsonProperty("new_block_expiry_date") - @ExcludeMissing - fun _newBlockExpiryDate(): JsonField = newBlockExpiryDate - - @JsonProperty("starting_balance") - @ExcludeMissing - fun _startingBalance(): JsonField = startingBalance - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): ExpirationChangeLedgerEntry = apply { - if (validated) { - return@apply - } - - id() - amount() - createdAt() - creditBlock().validate() - currency() - customer().validate() - description() - endingBalance() - entryStatus() - entryType() - ledgerSequenceNumber() - metadata().validate() - newBlockExpiryDate() - startingBalance() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ExpirationChangeLedgerEntry]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var amount: JsonField? = null - private var createdAt: JsonField? = null - private var creditBlock: JsonField? = null - private var currency: JsonField? = null - private var customer: JsonField? = null - private var description: JsonField? = null - private var endingBalance: JsonField? = null - private var entryStatus: JsonField? = null - private var entryType: JsonField? = null - private var ledgerSequenceNumber: JsonField? = null - private var metadata: JsonField? = null - private var newBlockExpiryDate: JsonField? = null - private var startingBalance: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(expirationChangeLedgerEntry: ExpirationChangeLedgerEntry) = apply { - id = expirationChangeLedgerEntry.id - amount = expirationChangeLedgerEntry.amount - createdAt = expirationChangeLedgerEntry.createdAt - creditBlock = expirationChangeLedgerEntry.creditBlock - currency = expirationChangeLedgerEntry.currency - customer = expirationChangeLedgerEntry.customer - description = expirationChangeLedgerEntry.description - endingBalance = expirationChangeLedgerEntry.endingBalance - entryStatus = expirationChangeLedgerEntry.entryStatus - entryType = expirationChangeLedgerEntry.entryType - ledgerSequenceNumber = expirationChangeLedgerEntry.ledgerSequenceNumber - metadata = expirationChangeLedgerEntry.metadata - newBlockExpiryDate = expirationChangeLedgerEntry.newBlockExpiryDate - startingBalance = expirationChangeLedgerEntry.startingBalance - additionalProperties = - expirationChangeLedgerEntry.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun amount(amount: Double) = amount(JsonField.of(amount)) - - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { - this.createdAt = createdAt - } - - fun creditBlock(creditBlock: CreditBlock) = creditBlock(JsonField.of(creditBlock)) - - fun creditBlock(creditBlock: JsonField) = apply { - this.creditBlock = creditBlock - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun customer(customer: Customer) = customer(JsonField.of(customer)) - - fun customer(customer: JsonField) = apply { this.customer = customer } - - fun description(description: String?) = description(JsonField.ofNullable(description)) - - fun description(description: Optional) = description(description.orElse(null)) - - fun description(description: JsonField) = apply { - this.description = description - } - - fun endingBalance(endingBalance: Double) = endingBalance(JsonField.of(endingBalance)) - - fun endingBalance(endingBalance: JsonField) = apply { - this.endingBalance = endingBalance - } - - fun entryStatus(entryStatus: EntryStatus) = entryStatus(JsonField.of(entryStatus)) - - fun entryStatus(entryStatus: JsonField) = apply { - this.entryStatus = entryStatus - } - - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } - - fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = - ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) - - fun ledgerSequenceNumber(ledgerSequenceNumber: JsonField) = apply { - this.ledgerSequenceNumber = ledgerSequenceNumber - } - - /** - * 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - fun newBlockExpiryDate(newBlockExpiryDate: OffsetDateTime?) = - newBlockExpiryDate(JsonField.ofNullable(newBlockExpiryDate)) - - fun newBlockExpiryDate(newBlockExpiryDate: Optional) = - newBlockExpiryDate(newBlockExpiryDate.orElse(null)) - - fun newBlockExpiryDate(newBlockExpiryDate: JsonField) = apply { - this.newBlockExpiryDate = newBlockExpiryDate - } - - fun startingBalance(startingBalance: Double) = - startingBalance(JsonField.of(startingBalance)) - - fun startingBalance(startingBalance: JsonField) = apply { - this.startingBalance = startingBalance - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): ExpirationChangeLedgerEntry = - ExpirationChangeLedgerEntry( - checkRequired("id", id), - checkRequired("amount", amount), - checkRequired("createdAt", createdAt), - checkRequired("creditBlock", creditBlock), - checkRequired("currency", currency), - checkRequired("customer", customer), - checkRequired("description", description), - checkRequired("endingBalance", endingBalance), - checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), - checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), - checkRequired("metadata", metadata), - checkRequired("newBlockExpiryDate", newBlockExpiryDate), - checkRequired("startingBalance", startingBalance), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class CreditBlock - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("expiry_date") - @ExcludeMissing - private val expiryDate: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - private val perUnitCostBasis: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun expiryDate(): Optional = - Optional.ofNullable(expiryDate.getNullable("expiry_date")) - - fun perUnitCostBasis(): Optional = - Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("expiry_date") - @ExcludeMissing - fun _expiryDate(): JsonField = expiryDate - - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - fun _perUnitCostBasis(): JsonField = perUnitCostBasis - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditBlock = apply { - if (validated) { - return@apply - } - - id() - expiryDate() - perUnitCostBasis() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditBlock]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var expiryDate: JsonField? = null - private var perUnitCostBasis: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditBlock: CreditBlock) = apply { - id = creditBlock.id - expiryDate = creditBlock.expiryDate - perUnitCostBasis = creditBlock.perUnitCostBasis - additionalProperties = creditBlock.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun expiryDate(expiryDate: OffsetDateTime?) = - expiryDate(JsonField.ofNullable(expiryDate)) - - fun expiryDate(expiryDate: Optional) = - expiryDate(expiryDate.orElse(null)) - - fun expiryDate(expiryDate: JsonField) = apply { - this.expiryDate = expiryDate - } - - fun perUnitCostBasis(perUnitCostBasis: String?) = - perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) - - fun perUnitCostBasis(perUnitCostBasis: Optional) = - perUnitCostBasis(perUnitCostBasis.orElse(null)) - - fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { - this.perUnitCostBasis = perUnitCostBasis - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditBlock = - CreditBlock( - checkRequired("id", id), - checkRequired("expiryDate", expiryDate), - checkRequired("perUnitCostBasis", perUnitCostBasis), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditBlock && id == other.id && expiryDate == other.expiryDate && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, expiryDate, perUnitCostBasis, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditBlock{id=$id, expiryDate=$expiryDate, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Customer - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("external_customer_id") - @ExcludeMissing - private val externalCustomerId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun externalCustomerId(): Optional = - Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("external_customer_id") - @ExcludeMissing - fun _externalCustomerId(): JsonField = externalCustomerId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Customer = apply { - if (validated) { - return@apply - } - - id() - externalCustomerId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Customer]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var externalCustomerId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customer: Customer) = apply { - id = customer.id - externalCustomerId = customer.externalCustomerId - additionalProperties = customer.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun externalCustomerId(externalCustomerId: String?) = - externalCustomerId(JsonField.ofNullable(externalCustomerId)) - - fun externalCustomerId(externalCustomerId: Optional) = - externalCustomerId(externalCustomerId.orElse(null)) - - fun externalCustomerId(externalCustomerId: JsonField) = apply { - this.externalCustomerId = externalCustomerId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Customer = - Customer( - checkRequired("id", id), - checkRequired("externalCustomerId", externalCustomerId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Customer && id == other.id && externalCustomerId == other.externalCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, externalCustomerId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Customer{id=$id, externalCustomerId=$externalCustomerId, additionalProperties=$additionalProperties}" - } - - class EntryStatus @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val COMMITTED = of("committed") - - @JvmField val PENDING = of("pending") - - @JvmStatic fun of(value: String) = EntryStatus(JsonField.of(value)) - } - - /** An enum containing [EntryStatus]'s known values. */ - enum class Known { - COMMITTED, - PENDING, - } - - /** - * An enum containing [EntryStatus]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryStatus] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - COMMITTED, - PENDING, - /** - * An enum member indicating that [EntryStatus] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - COMMITTED -> Value.COMMITTED - PENDING -> Value.PENDING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - COMMITTED -> Known.COMMITTED - PENDING -> Known.PENDING - else -> throw OrbInvalidDataException("Unknown EntryStatus: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryStatus && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val EXPIRATION_CHANGE = of("expiration_change") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - EXPIRATION_CHANGE - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - EXPIRATION_CHANGE, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - EXPIRATION_CHANGE -> Value.EXPIRATION_CHANGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - EXPIRATION_CHANGE -> Known.EXPIRATION_CHANGE - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ExpirationChangeLedgerEntry && id == other.id && amount == other.amount && createdAt == other.createdAt && creditBlock == other.creditBlock && currency == other.currency && customer == other.customer && description == other.description && endingBalance == other.endingBalance && entryStatus == other.entryStatus && entryType == other.entryType && ledgerSequenceNumber == other.ledgerSequenceNumber && metadata == other.metadata && newBlockExpiryDate == other.newBlockExpiryDate && startingBalance == other.startingBalance && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, createdAt, creditBlock, currency, customer, description, endingBalance, entryStatus, entryType, ledgerSequenceNumber, metadata, newBlockExpiryDate, startingBalance, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ExpirationChangeLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, newBlockExpiryDate=$newBlockExpiryDate, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class CreditBlockExpiryLedgerEntry - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("credit_block") - @ExcludeMissing - private val creditBlock: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("customer") - @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("ending_balance") - @ExcludeMissing - private val endingBalance: JsonField = JsonMissing.of(), - @JsonProperty("entry_status") - @ExcludeMissing - private val entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - private val entryType: JsonField = JsonMissing.of(), - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - private val ledgerSequenceNumber: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("starting_balance") - @ExcludeMissing - private val startingBalance: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun amount(): Double = amount.getRequired("amount") - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - fun creditBlock(): CreditBlock = creditBlock.getRequired("credit_block") - - fun currency(): String = currency.getRequired("currency") - - fun customer(): Customer = customer.getRequired("customer") - - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - fun endingBalance(): Double = endingBalance.getRequired("ending_balance") - - fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") - - fun entryType(): EntryType = entryType.getRequired("entry_type") - - fun ledgerSequenceNumber(): Long = - ledgerSequenceNumber.getRequired("ledger_sequence_number") - - /** - * 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.getRequired("metadata") - - fun startingBalance(): Double = startingBalance.getRequired("starting_balance") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - @JsonProperty("credit_block") - @ExcludeMissing - fun _creditBlock(): JsonField = creditBlock - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - @JsonProperty("ending_balance") - @ExcludeMissing - fun _endingBalance(): JsonField = endingBalance - - @JsonProperty("entry_status") - @ExcludeMissing - fun _entryStatus(): JsonField = entryStatus - - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber - - /** - * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - @JsonProperty("starting_balance") - @ExcludeMissing - fun _startingBalance(): JsonField = startingBalance - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditBlockExpiryLedgerEntry = apply { - if (validated) { - return@apply - } - - id() - amount() - createdAt() - creditBlock().validate() - currency() - customer().validate() - description() - endingBalance() - entryStatus() - entryType() - ledgerSequenceNumber() - metadata().validate() - startingBalance() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditBlockExpiryLedgerEntry]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var amount: JsonField? = null - private var createdAt: JsonField? = null - private var creditBlock: JsonField? = null - private var currency: JsonField? = null - private var customer: JsonField? = null - private var description: JsonField? = null - private var endingBalance: JsonField? = null - private var entryStatus: JsonField? = null - private var entryType: JsonField? = null - private var ledgerSequenceNumber: JsonField? = null - private var metadata: JsonField? = null - private var startingBalance: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry) = apply { - id = creditBlockExpiryLedgerEntry.id - amount = creditBlockExpiryLedgerEntry.amount - createdAt = creditBlockExpiryLedgerEntry.createdAt - creditBlock = creditBlockExpiryLedgerEntry.creditBlock - currency = creditBlockExpiryLedgerEntry.currency - customer = creditBlockExpiryLedgerEntry.customer - description = creditBlockExpiryLedgerEntry.description - endingBalance = creditBlockExpiryLedgerEntry.endingBalance - entryStatus = creditBlockExpiryLedgerEntry.entryStatus - entryType = creditBlockExpiryLedgerEntry.entryType - ledgerSequenceNumber = creditBlockExpiryLedgerEntry.ledgerSequenceNumber - metadata = creditBlockExpiryLedgerEntry.metadata - startingBalance = creditBlockExpiryLedgerEntry.startingBalance - additionalProperties = - creditBlockExpiryLedgerEntry.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun amount(amount: Double) = amount(JsonField.of(amount)) - - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { - this.createdAt = createdAt - } - - fun creditBlock(creditBlock: CreditBlock) = creditBlock(JsonField.of(creditBlock)) - - fun creditBlock(creditBlock: JsonField) = apply { - this.creditBlock = creditBlock - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun customer(customer: Customer) = customer(JsonField.of(customer)) - - fun customer(customer: JsonField) = apply { this.customer = customer } - - fun description(description: String?) = description(JsonField.ofNullable(description)) - - fun description(description: Optional) = description(description.orElse(null)) - - fun description(description: JsonField) = apply { - this.description = description - } - - fun endingBalance(endingBalance: Double) = endingBalance(JsonField.of(endingBalance)) - - fun endingBalance(endingBalance: JsonField) = apply { - this.endingBalance = endingBalance - } - - fun entryStatus(entryStatus: EntryStatus) = entryStatus(JsonField.of(entryStatus)) - - fun entryStatus(entryStatus: JsonField) = apply { - this.entryStatus = entryStatus - } - - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } - - fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = - ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) - - fun ledgerSequenceNumber(ledgerSequenceNumber: JsonField) = apply { - this.ledgerSequenceNumber = ledgerSequenceNumber - } - - /** - * 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - fun startingBalance(startingBalance: Double) = - startingBalance(JsonField.of(startingBalance)) - - fun startingBalance(startingBalance: JsonField) = apply { - this.startingBalance = startingBalance - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditBlockExpiryLedgerEntry = - CreditBlockExpiryLedgerEntry( - checkRequired("id", id), - checkRequired("amount", amount), - checkRequired("createdAt", createdAt), - checkRequired("creditBlock", creditBlock), - checkRequired("currency", currency), - checkRequired("customer", customer), - checkRequired("description", description), - checkRequired("endingBalance", endingBalance), - checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), - checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), - checkRequired("metadata", metadata), - checkRequired("startingBalance", startingBalance), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class CreditBlock - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("expiry_date") - @ExcludeMissing - private val expiryDate: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - private val perUnitCostBasis: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun expiryDate(): Optional = - Optional.ofNullable(expiryDate.getNullable("expiry_date")) - - fun perUnitCostBasis(): Optional = - Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("expiry_date") - @ExcludeMissing - fun _expiryDate(): JsonField = expiryDate - - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - fun _perUnitCostBasis(): JsonField = perUnitCostBasis - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditBlock = apply { - if (validated) { - return@apply - } - - id() - expiryDate() - perUnitCostBasis() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditBlock]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var expiryDate: JsonField? = null - private var perUnitCostBasis: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditBlock: CreditBlock) = apply { - id = creditBlock.id - expiryDate = creditBlock.expiryDate - perUnitCostBasis = creditBlock.perUnitCostBasis - additionalProperties = creditBlock.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun expiryDate(expiryDate: OffsetDateTime?) = - expiryDate(JsonField.ofNullable(expiryDate)) - - fun expiryDate(expiryDate: Optional) = - expiryDate(expiryDate.orElse(null)) - - fun expiryDate(expiryDate: JsonField) = apply { - this.expiryDate = expiryDate - } - - fun perUnitCostBasis(perUnitCostBasis: String?) = - perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) - - fun perUnitCostBasis(perUnitCostBasis: Optional) = - perUnitCostBasis(perUnitCostBasis.orElse(null)) - - fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { - this.perUnitCostBasis = perUnitCostBasis - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditBlock = - CreditBlock( - checkRequired("id", id), - checkRequired("expiryDate", expiryDate), - checkRequired("perUnitCostBasis", perUnitCostBasis), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditBlock && id == other.id && expiryDate == other.expiryDate && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, expiryDate, perUnitCostBasis, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditBlock{id=$id, expiryDate=$expiryDate, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Customer - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("external_customer_id") - @ExcludeMissing - private val externalCustomerId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun externalCustomerId(): Optional = - Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("external_customer_id") - @ExcludeMissing - fun _externalCustomerId(): JsonField = externalCustomerId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Customer = apply { - if (validated) { - return@apply - } - - id() - externalCustomerId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Customer]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var externalCustomerId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customer: Customer) = apply { - id = customer.id - externalCustomerId = customer.externalCustomerId - additionalProperties = customer.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun externalCustomerId(externalCustomerId: String?) = - externalCustomerId(JsonField.ofNullable(externalCustomerId)) - - fun externalCustomerId(externalCustomerId: Optional) = - externalCustomerId(externalCustomerId.orElse(null)) - - fun externalCustomerId(externalCustomerId: JsonField) = apply { - this.externalCustomerId = externalCustomerId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Customer = - Customer( - checkRequired("id", id), - checkRequired("externalCustomerId", externalCustomerId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Customer && id == other.id && externalCustomerId == other.externalCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, externalCustomerId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Customer{id=$id, externalCustomerId=$externalCustomerId, additionalProperties=$additionalProperties}" - } - - class EntryStatus @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val COMMITTED = of("committed") - - @JvmField val PENDING = of("pending") - - @JvmStatic fun of(value: String) = EntryStatus(JsonField.of(value)) - } - - /** An enum containing [EntryStatus]'s known values. */ - enum class Known { - COMMITTED, - PENDING, - } - - /** - * An enum containing [EntryStatus]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryStatus] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - COMMITTED, - PENDING, - /** - * An enum member indicating that [EntryStatus] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - COMMITTED -> Value.COMMITTED - PENDING -> Value.PENDING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - COMMITTED -> Known.COMMITTED - PENDING -> Known.PENDING - else -> throw OrbInvalidDataException("Unknown EntryStatus: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryStatus && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val CREDIT_BLOCK_EXPIRY = of("credit_block_expiry") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - CREDIT_BLOCK_EXPIRY - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - CREDIT_BLOCK_EXPIRY, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - CREDIT_BLOCK_EXPIRY -> Value.CREDIT_BLOCK_EXPIRY - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - CREDIT_BLOCK_EXPIRY -> Known.CREDIT_BLOCK_EXPIRY - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditBlockExpiryLedgerEntry && id == other.id && amount == other.amount && createdAt == other.createdAt && creditBlock == other.creditBlock && currency == other.currency && customer == other.customer && description == other.description && endingBalance == other.endingBalance && entryStatus == other.entryStatus && entryType == other.entryType && ledgerSequenceNumber == other.ledgerSequenceNumber && metadata == other.metadata && startingBalance == other.startingBalance && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, createdAt, creditBlock, currency, customer, description, endingBalance, entryStatus, entryType, ledgerSequenceNumber, metadata, startingBalance, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditBlockExpiryLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class VoidLedgerEntry - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("credit_block") - @ExcludeMissing - private val creditBlock: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("customer") - @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("ending_balance") - @ExcludeMissing - private val endingBalance: JsonField = JsonMissing.of(), - @JsonProperty("entry_status") - @ExcludeMissing - private val entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - private val entryType: JsonField = JsonMissing.of(), - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - private val ledgerSequenceNumber: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("starting_balance") - @ExcludeMissing - private val startingBalance: JsonField = JsonMissing.of(), - @JsonProperty("void_amount") - @ExcludeMissing - private val voidAmount: JsonField = JsonMissing.of(), - @JsonProperty("void_reason") - @ExcludeMissing - private val voidReason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun amount(): Double = amount.getRequired("amount") - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - fun creditBlock(): CreditBlock = creditBlock.getRequired("credit_block") - - fun currency(): String = currency.getRequired("currency") - - fun customer(): Customer = customer.getRequired("customer") - - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - fun endingBalance(): Double = endingBalance.getRequired("ending_balance") - - fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") - - fun entryType(): EntryType = entryType.getRequired("entry_type") - - fun ledgerSequenceNumber(): Long = - ledgerSequenceNumber.getRequired("ledger_sequence_number") - - /** - * 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.getRequired("metadata") - - fun startingBalance(): Double = startingBalance.getRequired("starting_balance") - - fun voidAmount(): Double = voidAmount.getRequired("void_amount") - - fun voidReason(): Optional = - Optional.ofNullable(voidReason.getNullable("void_reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - @JsonProperty("credit_block") - @ExcludeMissing - fun _creditBlock(): JsonField = creditBlock - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - @JsonProperty("ending_balance") - @ExcludeMissing - fun _endingBalance(): JsonField = endingBalance - - @JsonProperty("entry_status") - @ExcludeMissing - fun _entryStatus(): JsonField = entryStatus - - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber - - /** - * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - @JsonProperty("starting_balance") - @ExcludeMissing - fun _startingBalance(): JsonField = startingBalance - - @JsonProperty("void_amount") - @ExcludeMissing - fun _voidAmount(): JsonField = voidAmount - - @JsonProperty("void_reason") - @ExcludeMissing - fun _voidReason(): JsonField = voidReason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): VoidLedgerEntry = apply { - if (validated) { - return@apply - } - - id() - amount() - createdAt() - creditBlock().validate() - currency() - customer().validate() - description() - endingBalance() - entryStatus() - entryType() - ledgerSequenceNumber() - metadata().validate() - startingBalance() - voidAmount() - voidReason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [VoidLedgerEntry]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var amount: JsonField? = null - private var createdAt: JsonField? = null - private var creditBlock: JsonField? = null - private var currency: JsonField? = null - private var customer: JsonField? = null - private var description: JsonField? = null - private var endingBalance: JsonField? = null - private var entryStatus: JsonField? = null - private var entryType: JsonField? = null - private var ledgerSequenceNumber: JsonField? = null - private var metadata: JsonField? = null - private var startingBalance: JsonField? = null - private var voidAmount: JsonField? = null - private var voidReason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(voidLedgerEntry: VoidLedgerEntry) = apply { - id = voidLedgerEntry.id - amount = voidLedgerEntry.amount - createdAt = voidLedgerEntry.createdAt - creditBlock = voidLedgerEntry.creditBlock - currency = voidLedgerEntry.currency - customer = voidLedgerEntry.customer - description = voidLedgerEntry.description - endingBalance = voidLedgerEntry.endingBalance - entryStatus = voidLedgerEntry.entryStatus - entryType = voidLedgerEntry.entryType - ledgerSequenceNumber = voidLedgerEntry.ledgerSequenceNumber - metadata = voidLedgerEntry.metadata - startingBalance = voidLedgerEntry.startingBalance - voidAmount = voidLedgerEntry.voidAmount - voidReason = voidLedgerEntry.voidReason - additionalProperties = voidLedgerEntry.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun amount(amount: Double) = amount(JsonField.of(amount)) - - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { - this.createdAt = createdAt - } - - fun creditBlock(creditBlock: CreditBlock) = creditBlock(JsonField.of(creditBlock)) - - fun creditBlock(creditBlock: JsonField) = apply { - this.creditBlock = creditBlock - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun customer(customer: Customer) = customer(JsonField.of(customer)) - - fun customer(customer: JsonField) = apply { this.customer = customer } - - fun description(description: String?) = description(JsonField.ofNullable(description)) - - fun description(description: Optional) = description(description.orElse(null)) - - fun description(description: JsonField) = apply { - this.description = description - } - - fun endingBalance(endingBalance: Double) = endingBalance(JsonField.of(endingBalance)) - - fun endingBalance(endingBalance: JsonField) = apply { - this.endingBalance = endingBalance - } - - fun entryStatus(entryStatus: EntryStatus) = entryStatus(JsonField.of(entryStatus)) - - fun entryStatus(entryStatus: JsonField) = apply { - this.entryStatus = entryStatus - } - - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } - - fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = - ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) - - fun ledgerSequenceNumber(ledgerSequenceNumber: JsonField) = apply { - this.ledgerSequenceNumber = ledgerSequenceNumber - } - - /** - * 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - fun startingBalance(startingBalance: Double) = - startingBalance(JsonField.of(startingBalance)) - - fun startingBalance(startingBalance: JsonField) = apply { - this.startingBalance = startingBalance - } - - fun voidAmount(voidAmount: Double) = voidAmount(JsonField.of(voidAmount)) - - fun voidAmount(voidAmount: JsonField) = apply { this.voidAmount = voidAmount } - - fun voidReason(voidReason: String?) = voidReason(JsonField.ofNullable(voidReason)) - - fun voidReason(voidReason: Optional) = voidReason(voidReason.orElse(null)) - - fun voidReason(voidReason: JsonField) = apply { this.voidReason = voidReason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): VoidLedgerEntry = - VoidLedgerEntry( - checkRequired("id", id), - checkRequired("amount", amount), - checkRequired("createdAt", createdAt), - checkRequired("creditBlock", creditBlock), - checkRequired("currency", currency), - checkRequired("customer", customer), - checkRequired("description", description), - checkRequired("endingBalance", endingBalance), - checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), - checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), - checkRequired("metadata", metadata), - checkRequired("startingBalance", startingBalance), - checkRequired("voidAmount", voidAmount), - checkRequired("voidReason", voidReason), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class CreditBlock - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("expiry_date") - @ExcludeMissing - private val expiryDate: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - private val perUnitCostBasis: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun expiryDate(): Optional = - Optional.ofNullable(expiryDate.getNullable("expiry_date")) - - fun perUnitCostBasis(): Optional = - Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("expiry_date") - @ExcludeMissing - fun _expiryDate(): JsonField = expiryDate - - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - fun _perUnitCostBasis(): JsonField = perUnitCostBasis - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditBlock = apply { - if (validated) { - return@apply - } - - id() - expiryDate() - perUnitCostBasis() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditBlock]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var expiryDate: JsonField? = null - private var perUnitCostBasis: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditBlock: CreditBlock) = apply { - id = creditBlock.id - expiryDate = creditBlock.expiryDate - perUnitCostBasis = creditBlock.perUnitCostBasis - additionalProperties = creditBlock.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun expiryDate(expiryDate: OffsetDateTime?) = - expiryDate(JsonField.ofNullable(expiryDate)) - - fun expiryDate(expiryDate: Optional) = - expiryDate(expiryDate.orElse(null)) - - fun expiryDate(expiryDate: JsonField) = apply { - this.expiryDate = expiryDate - } - - fun perUnitCostBasis(perUnitCostBasis: String?) = - perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) - - fun perUnitCostBasis(perUnitCostBasis: Optional) = - perUnitCostBasis(perUnitCostBasis.orElse(null)) - - fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { - this.perUnitCostBasis = perUnitCostBasis - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditBlock = - CreditBlock( - checkRequired("id", id), - checkRequired("expiryDate", expiryDate), - checkRequired("perUnitCostBasis", perUnitCostBasis), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditBlock && id == other.id && expiryDate == other.expiryDate && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, expiryDate, perUnitCostBasis, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditBlock{id=$id, expiryDate=$expiryDate, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Customer - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("external_customer_id") - @ExcludeMissing - private val externalCustomerId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun externalCustomerId(): Optional = - Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("external_customer_id") - @ExcludeMissing - fun _externalCustomerId(): JsonField = externalCustomerId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Customer = apply { - if (validated) { - return@apply - } - - id() - externalCustomerId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Customer]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var externalCustomerId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customer: Customer) = apply { - id = customer.id - externalCustomerId = customer.externalCustomerId - additionalProperties = customer.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun externalCustomerId(externalCustomerId: String?) = - externalCustomerId(JsonField.ofNullable(externalCustomerId)) - - fun externalCustomerId(externalCustomerId: Optional) = - externalCustomerId(externalCustomerId.orElse(null)) - - fun externalCustomerId(externalCustomerId: JsonField) = apply { - this.externalCustomerId = externalCustomerId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Customer = - Customer( - checkRequired("id", id), - checkRequired("externalCustomerId", externalCustomerId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Customer && id == other.id && externalCustomerId == other.externalCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, externalCustomerId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Customer{id=$id, externalCustomerId=$externalCustomerId, additionalProperties=$additionalProperties}" - } - - class EntryStatus @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val COMMITTED = of("committed") - - @JvmField val PENDING = of("pending") - - @JvmStatic fun of(value: String) = EntryStatus(JsonField.of(value)) - } - - /** An enum containing [EntryStatus]'s known values. */ - enum class Known { - COMMITTED, - PENDING, - } - - /** - * An enum containing [EntryStatus]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryStatus] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - COMMITTED, - PENDING, - /** - * An enum member indicating that [EntryStatus] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - COMMITTED -> Value.COMMITTED - PENDING -> Value.PENDING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - COMMITTED -> Known.COMMITTED - PENDING -> Known.PENDING - else -> throw OrbInvalidDataException("Unknown EntryStatus: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryStatus && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val VOID = of("void") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - VOID - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - VOID, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - VOID -> Value.VOID - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - VOID -> Known.VOID - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is VoidLedgerEntry && id == other.id && amount == other.amount && createdAt == other.createdAt && creditBlock == other.creditBlock && currency == other.currency && customer == other.customer && description == other.description && endingBalance == other.endingBalance && entryStatus == other.entryStatus && entryType == other.entryType && ledgerSequenceNumber == other.ledgerSequenceNumber && metadata == other.metadata && startingBalance == other.startingBalance && voidAmount == other.voidAmount && voidReason == other.voidReason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, createdAt, creditBlock, currency, customer, description, endingBalance, entryStatus, entryType, ledgerSequenceNumber, metadata, startingBalance, voidAmount, voidReason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "VoidLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, voidAmount=$voidAmount, voidReason=$voidReason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class VoidInitiatedLedgerEntry - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("credit_block") - @ExcludeMissing - private val creditBlock: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("customer") - @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("ending_balance") - @ExcludeMissing - private val endingBalance: JsonField = JsonMissing.of(), - @JsonProperty("entry_status") - @ExcludeMissing - private val entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - private val entryType: JsonField = JsonMissing.of(), - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - private val ledgerSequenceNumber: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("new_block_expiry_date") - @ExcludeMissing - private val newBlockExpiryDate: JsonField = JsonMissing.of(), - @JsonProperty("starting_balance") - @ExcludeMissing - private val startingBalance: JsonField = JsonMissing.of(), - @JsonProperty("void_amount") - @ExcludeMissing - private val voidAmount: JsonField = JsonMissing.of(), - @JsonProperty("void_reason") - @ExcludeMissing - private val voidReason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun amount(): Double = amount.getRequired("amount") - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - fun creditBlock(): CreditBlock = creditBlock.getRequired("credit_block") - - fun currency(): String = currency.getRequired("currency") - - fun customer(): Customer = customer.getRequired("customer") - - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - fun endingBalance(): Double = endingBalance.getRequired("ending_balance") - - fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") - - fun entryType(): EntryType = entryType.getRequired("entry_type") - - fun ledgerSequenceNumber(): Long = - ledgerSequenceNumber.getRequired("ledger_sequence_number") - - /** - * 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.getRequired("metadata") - - fun newBlockExpiryDate(): OffsetDateTime = - newBlockExpiryDate.getRequired("new_block_expiry_date") - - fun startingBalance(): Double = startingBalance.getRequired("starting_balance") - - fun voidAmount(): Double = voidAmount.getRequired("void_amount") - - fun voidReason(): Optional = - Optional.ofNullable(voidReason.getNullable("void_reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - @JsonProperty("credit_block") - @ExcludeMissing - fun _creditBlock(): JsonField = creditBlock - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - @JsonProperty("ending_balance") - @ExcludeMissing - fun _endingBalance(): JsonField = endingBalance - - @JsonProperty("entry_status") - @ExcludeMissing - fun _entryStatus(): JsonField = entryStatus - - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber - - /** - * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - @JsonProperty("new_block_expiry_date") - @ExcludeMissing - fun _newBlockExpiryDate(): JsonField = newBlockExpiryDate - - @JsonProperty("starting_balance") - @ExcludeMissing - fun _startingBalance(): JsonField = startingBalance - - @JsonProperty("void_amount") - @ExcludeMissing - fun _voidAmount(): JsonField = voidAmount - - @JsonProperty("void_reason") - @ExcludeMissing - fun _voidReason(): JsonField = voidReason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): VoidInitiatedLedgerEntry = apply { - if (validated) { - return@apply - } - - id() - amount() - createdAt() - creditBlock().validate() - currency() - customer().validate() - description() - endingBalance() - entryStatus() - entryType() - ledgerSequenceNumber() - metadata().validate() - newBlockExpiryDate() - startingBalance() - voidAmount() - voidReason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [VoidInitiatedLedgerEntry]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var amount: JsonField? = null - private var createdAt: JsonField? = null - private var creditBlock: JsonField? = null - private var currency: JsonField? = null - private var customer: JsonField? = null - private var description: JsonField? = null - private var endingBalance: JsonField? = null - private var entryStatus: JsonField? = null - private var entryType: JsonField? = null - private var ledgerSequenceNumber: JsonField? = null - private var metadata: JsonField? = null - private var newBlockExpiryDate: JsonField? = null - private var startingBalance: JsonField? = null - private var voidAmount: JsonField? = null - private var voidReason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry) = apply { - id = voidInitiatedLedgerEntry.id - amount = voidInitiatedLedgerEntry.amount - createdAt = voidInitiatedLedgerEntry.createdAt - creditBlock = voidInitiatedLedgerEntry.creditBlock - currency = voidInitiatedLedgerEntry.currency - customer = voidInitiatedLedgerEntry.customer - description = voidInitiatedLedgerEntry.description - endingBalance = voidInitiatedLedgerEntry.endingBalance - entryStatus = voidInitiatedLedgerEntry.entryStatus - entryType = voidInitiatedLedgerEntry.entryType - ledgerSequenceNumber = voidInitiatedLedgerEntry.ledgerSequenceNumber - metadata = voidInitiatedLedgerEntry.metadata - newBlockExpiryDate = voidInitiatedLedgerEntry.newBlockExpiryDate - startingBalance = voidInitiatedLedgerEntry.startingBalance - voidAmount = voidInitiatedLedgerEntry.voidAmount - voidReason = voidInitiatedLedgerEntry.voidReason - additionalProperties = voidInitiatedLedgerEntry.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun amount(amount: Double) = amount(JsonField.of(amount)) - - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { - this.createdAt = createdAt - } - - fun creditBlock(creditBlock: CreditBlock) = creditBlock(JsonField.of(creditBlock)) - - fun creditBlock(creditBlock: JsonField) = apply { - this.creditBlock = creditBlock - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun customer(customer: Customer) = customer(JsonField.of(customer)) - - fun customer(customer: JsonField) = apply { this.customer = customer } - - fun description(description: String?) = description(JsonField.ofNullable(description)) - - fun description(description: Optional) = description(description.orElse(null)) - - fun description(description: JsonField) = apply { - this.description = description - } - - fun endingBalance(endingBalance: Double) = endingBalance(JsonField.of(endingBalance)) - - fun endingBalance(endingBalance: JsonField) = apply { - this.endingBalance = endingBalance - } - - fun entryStatus(entryStatus: EntryStatus) = entryStatus(JsonField.of(entryStatus)) - - fun entryStatus(entryStatus: JsonField) = apply { - this.entryStatus = entryStatus - } - - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } - - fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = - ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) - - fun ledgerSequenceNumber(ledgerSequenceNumber: JsonField) = apply { - this.ledgerSequenceNumber = ledgerSequenceNumber - } - - /** - * 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - fun newBlockExpiryDate(newBlockExpiryDate: OffsetDateTime) = - newBlockExpiryDate(JsonField.of(newBlockExpiryDate)) - - fun newBlockExpiryDate(newBlockExpiryDate: JsonField) = apply { - this.newBlockExpiryDate = newBlockExpiryDate - } - - fun startingBalance(startingBalance: Double) = - startingBalance(JsonField.of(startingBalance)) - - fun startingBalance(startingBalance: JsonField) = apply { - this.startingBalance = startingBalance - } - - fun voidAmount(voidAmount: Double) = voidAmount(JsonField.of(voidAmount)) - - fun voidAmount(voidAmount: JsonField) = apply { this.voidAmount = voidAmount } - - fun voidReason(voidReason: String?) = voidReason(JsonField.ofNullable(voidReason)) - - fun voidReason(voidReason: Optional) = voidReason(voidReason.orElse(null)) - - fun voidReason(voidReason: JsonField) = apply { this.voidReason = voidReason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): VoidInitiatedLedgerEntry = - VoidInitiatedLedgerEntry( - checkRequired("id", id), - checkRequired("amount", amount), - checkRequired("createdAt", createdAt), - checkRequired("creditBlock", creditBlock), - checkRequired("currency", currency), - checkRequired("customer", customer), - checkRequired("description", description), - checkRequired("endingBalance", endingBalance), - checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), - checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), - checkRequired("metadata", metadata), - checkRequired("newBlockExpiryDate", newBlockExpiryDate), - checkRequired("startingBalance", startingBalance), - checkRequired("voidAmount", voidAmount), - checkRequired("voidReason", voidReason), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class CreditBlock - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("expiry_date") - @ExcludeMissing - private val expiryDate: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - private val perUnitCostBasis: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun expiryDate(): Optional = - Optional.ofNullable(expiryDate.getNullable("expiry_date")) - - fun perUnitCostBasis(): Optional = - Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("expiry_date") - @ExcludeMissing - fun _expiryDate(): JsonField = expiryDate - - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - fun _perUnitCostBasis(): JsonField = perUnitCostBasis - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditBlock = apply { - if (validated) { - return@apply - } - - id() - expiryDate() - perUnitCostBasis() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditBlock]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var expiryDate: JsonField? = null - private var perUnitCostBasis: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditBlock: CreditBlock) = apply { - id = creditBlock.id - expiryDate = creditBlock.expiryDate - perUnitCostBasis = creditBlock.perUnitCostBasis - additionalProperties = creditBlock.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun expiryDate(expiryDate: OffsetDateTime?) = - expiryDate(JsonField.ofNullable(expiryDate)) - - fun expiryDate(expiryDate: Optional) = - expiryDate(expiryDate.orElse(null)) - - fun expiryDate(expiryDate: JsonField) = apply { - this.expiryDate = expiryDate - } - - fun perUnitCostBasis(perUnitCostBasis: String?) = - perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) - - fun perUnitCostBasis(perUnitCostBasis: Optional) = - perUnitCostBasis(perUnitCostBasis.orElse(null)) - - fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { - this.perUnitCostBasis = perUnitCostBasis - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditBlock = - CreditBlock( - checkRequired("id", id), - checkRequired("expiryDate", expiryDate), - checkRequired("perUnitCostBasis", perUnitCostBasis), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditBlock && id == other.id && expiryDate == other.expiryDate && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, expiryDate, perUnitCostBasis, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditBlock{id=$id, expiryDate=$expiryDate, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Customer - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("external_customer_id") - @ExcludeMissing - private val externalCustomerId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun externalCustomerId(): Optional = - Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("external_customer_id") - @ExcludeMissing - fun _externalCustomerId(): JsonField = externalCustomerId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Customer = apply { - if (validated) { - return@apply - } - - id() - externalCustomerId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Customer]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var externalCustomerId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customer: Customer) = apply { - id = customer.id - externalCustomerId = customer.externalCustomerId - additionalProperties = customer.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun externalCustomerId(externalCustomerId: String?) = - externalCustomerId(JsonField.ofNullable(externalCustomerId)) - - fun externalCustomerId(externalCustomerId: Optional) = - externalCustomerId(externalCustomerId.orElse(null)) - - fun externalCustomerId(externalCustomerId: JsonField) = apply { - this.externalCustomerId = externalCustomerId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Customer = - Customer( - checkRequired("id", id), - checkRequired("externalCustomerId", externalCustomerId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Customer && id == other.id && externalCustomerId == other.externalCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, externalCustomerId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Customer{id=$id, externalCustomerId=$externalCustomerId, additionalProperties=$additionalProperties}" - } - - class EntryStatus @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val COMMITTED = of("committed") - - @JvmField val PENDING = of("pending") - - @JvmStatic fun of(value: String) = EntryStatus(JsonField.of(value)) - } - - /** An enum containing [EntryStatus]'s known values. */ - enum class Known { - COMMITTED, - PENDING, - } - - /** - * An enum containing [EntryStatus]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryStatus] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - COMMITTED, - PENDING, - /** - * An enum member indicating that [EntryStatus] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - COMMITTED -> Value.COMMITTED - PENDING -> Value.PENDING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - COMMITTED -> Known.COMMITTED - PENDING -> Known.PENDING - else -> throw OrbInvalidDataException("Unknown EntryStatus: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryStatus && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val VOID_INITIATED = of("void_initiated") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - VOID_INITIATED - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - VOID_INITIATED, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - VOID_INITIATED -> Value.VOID_INITIATED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - VOID_INITIATED -> Known.VOID_INITIATED - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is VoidInitiatedLedgerEntry && id == other.id && amount == other.amount && createdAt == other.createdAt && creditBlock == other.creditBlock && currency == other.currency && customer == other.customer && description == other.description && endingBalance == other.endingBalance && entryStatus == other.entryStatus && entryType == other.entryType && ledgerSequenceNumber == other.ledgerSequenceNumber && metadata == other.metadata && newBlockExpiryDate == other.newBlockExpiryDate && startingBalance == other.startingBalance && voidAmount == other.voidAmount && voidReason == other.voidReason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, createdAt, creditBlock, currency, customer, description, endingBalance, entryStatus, entryType, ledgerSequenceNumber, metadata, newBlockExpiryDate, startingBalance, voidAmount, voidReason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "VoidInitiatedLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, newBlockExpiryDate=$newBlockExpiryDate, startingBalance=$startingBalance, voidAmount=$voidAmount, voidReason=$voidReason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class AmendmentLedgerEntry - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("credit_block") - @ExcludeMissing - private val creditBlock: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("customer") - @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("ending_balance") - @ExcludeMissing - private val endingBalance: JsonField = JsonMissing.of(), - @JsonProperty("entry_status") - @ExcludeMissing - private val entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - private val entryType: JsonField = JsonMissing.of(), - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - private val ledgerSequenceNumber: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("starting_balance") - @ExcludeMissing - private val startingBalance: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun amount(): Double = amount.getRequired("amount") - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - fun creditBlock(): CreditBlock = creditBlock.getRequired("credit_block") - - fun currency(): String = currency.getRequired("currency") - - fun customer(): Customer = customer.getRequired("customer") - - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - fun endingBalance(): Double = endingBalance.getRequired("ending_balance") - - fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") - - fun entryType(): EntryType = entryType.getRequired("entry_type") - - fun ledgerSequenceNumber(): Long = - ledgerSequenceNumber.getRequired("ledger_sequence_number") - - /** - * 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.getRequired("metadata") - - fun startingBalance(): Double = startingBalance.getRequired("starting_balance") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - @JsonProperty("credit_block") - @ExcludeMissing - fun _creditBlock(): JsonField = creditBlock - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - @JsonProperty("ending_balance") - @ExcludeMissing - fun _endingBalance(): JsonField = endingBalance - - @JsonProperty("entry_status") - @ExcludeMissing - fun _entryStatus(): JsonField = entryStatus - - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber - - /** - * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - @JsonProperty("starting_balance") - @ExcludeMissing - fun _startingBalance(): JsonField = startingBalance - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AmendmentLedgerEntry = apply { - if (validated) { - return@apply - } - - id() - amount() - createdAt() - creditBlock().validate() - currency() - customer().validate() - description() - endingBalance() - entryStatus() - entryType() - ledgerSequenceNumber() - metadata().validate() - startingBalance() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AmendmentLedgerEntry]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var amount: JsonField? = null - private var createdAt: JsonField? = null - private var creditBlock: JsonField? = null - private var currency: JsonField? = null - private var customer: JsonField? = null - private var description: JsonField? = null - private var endingBalance: JsonField? = null - private var entryStatus: JsonField? = null - private var entryType: JsonField? = null - private var ledgerSequenceNumber: JsonField? = null - private var metadata: JsonField? = null - private var startingBalance: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(amendmentLedgerEntry: AmendmentLedgerEntry) = apply { - id = amendmentLedgerEntry.id - amount = amendmentLedgerEntry.amount - createdAt = amendmentLedgerEntry.createdAt - creditBlock = amendmentLedgerEntry.creditBlock - currency = amendmentLedgerEntry.currency - customer = amendmentLedgerEntry.customer - description = amendmentLedgerEntry.description - endingBalance = amendmentLedgerEntry.endingBalance - entryStatus = amendmentLedgerEntry.entryStatus - entryType = amendmentLedgerEntry.entryType - ledgerSequenceNumber = amendmentLedgerEntry.ledgerSequenceNumber - metadata = amendmentLedgerEntry.metadata - startingBalance = amendmentLedgerEntry.startingBalance - additionalProperties = amendmentLedgerEntry.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun amount(amount: Double) = amount(JsonField.of(amount)) - - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { - this.createdAt = createdAt - } - - fun creditBlock(creditBlock: CreditBlock) = creditBlock(JsonField.of(creditBlock)) - - fun creditBlock(creditBlock: JsonField) = apply { - this.creditBlock = creditBlock - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun customer(customer: Customer) = customer(JsonField.of(customer)) - - fun customer(customer: JsonField) = apply { this.customer = customer } - - fun description(description: String?) = description(JsonField.ofNullable(description)) - - fun description(description: Optional) = description(description.orElse(null)) - - fun description(description: JsonField) = apply { - this.description = description - } - - fun endingBalance(endingBalance: Double) = endingBalance(JsonField.of(endingBalance)) - - fun endingBalance(endingBalance: JsonField) = apply { - this.endingBalance = endingBalance - } - - fun entryStatus(entryStatus: EntryStatus) = entryStatus(JsonField.of(entryStatus)) - - fun entryStatus(entryStatus: JsonField) = apply { - this.entryStatus = entryStatus - } - - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } - - fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = - ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) - - fun ledgerSequenceNumber(ledgerSequenceNumber: JsonField) = apply { - this.ledgerSequenceNumber = ledgerSequenceNumber - } - - /** - * 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - fun startingBalance(startingBalance: Double) = - startingBalance(JsonField.of(startingBalance)) - - fun startingBalance(startingBalance: JsonField) = apply { - this.startingBalance = startingBalance - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): AmendmentLedgerEntry = - AmendmentLedgerEntry( - checkRequired("id", id), - checkRequired("amount", amount), - checkRequired("createdAt", createdAt), - checkRequired("creditBlock", creditBlock), - checkRequired("currency", currency), - checkRequired("customer", customer), - checkRequired("description", description), - checkRequired("endingBalance", endingBalance), - checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), - checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), - checkRequired("metadata", metadata), - checkRequired("startingBalance", startingBalance), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class CreditBlock - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("expiry_date") - @ExcludeMissing - private val expiryDate: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - private val perUnitCostBasis: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun expiryDate(): Optional = - Optional.ofNullable(expiryDate.getNullable("expiry_date")) - - fun perUnitCostBasis(): Optional = - Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("expiry_date") - @ExcludeMissing - fun _expiryDate(): JsonField = expiryDate - - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - fun _perUnitCostBasis(): JsonField = perUnitCostBasis - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditBlock = apply { - if (validated) { - return@apply - } - - id() - expiryDate() - perUnitCostBasis() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditBlock]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var expiryDate: JsonField? = null - private var perUnitCostBasis: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditBlock: CreditBlock) = apply { - id = creditBlock.id - expiryDate = creditBlock.expiryDate - perUnitCostBasis = creditBlock.perUnitCostBasis - additionalProperties = creditBlock.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun expiryDate(expiryDate: OffsetDateTime?) = - expiryDate(JsonField.ofNullable(expiryDate)) - - fun expiryDate(expiryDate: Optional) = - expiryDate(expiryDate.orElse(null)) - - fun expiryDate(expiryDate: JsonField) = apply { - this.expiryDate = expiryDate - } - - fun perUnitCostBasis(perUnitCostBasis: String?) = - perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) - - fun perUnitCostBasis(perUnitCostBasis: Optional) = - perUnitCostBasis(perUnitCostBasis.orElse(null)) - - fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { - this.perUnitCostBasis = perUnitCostBasis - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditBlock = - CreditBlock( - checkRequired("id", id), - checkRequired("expiryDate", expiryDate), - checkRequired("perUnitCostBasis", perUnitCostBasis), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditBlock && id == other.id && expiryDate == other.expiryDate && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, expiryDate, perUnitCostBasis, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditBlock{id=$id, expiryDate=$expiryDate, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Customer - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("external_customer_id") - @ExcludeMissing - private val externalCustomerId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun externalCustomerId(): Optional = - Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("external_customer_id") - @ExcludeMissing - fun _externalCustomerId(): JsonField = externalCustomerId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Customer = apply { - if (validated) { - return@apply - } - - id() - externalCustomerId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Customer]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var externalCustomerId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customer: Customer) = apply { - id = customer.id - externalCustomerId = customer.externalCustomerId - additionalProperties = customer.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun externalCustomerId(externalCustomerId: String?) = - externalCustomerId(JsonField.ofNullable(externalCustomerId)) - - fun externalCustomerId(externalCustomerId: Optional) = - externalCustomerId(externalCustomerId.orElse(null)) - - fun externalCustomerId(externalCustomerId: JsonField) = apply { - this.externalCustomerId = externalCustomerId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Customer = - Customer( - checkRequired("id", id), - checkRequired("externalCustomerId", externalCustomerId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Customer && id == other.id && externalCustomerId == other.externalCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, externalCustomerId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Customer{id=$id, externalCustomerId=$externalCustomerId, additionalProperties=$additionalProperties}" - } - - class EntryStatus @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val COMMITTED = of("committed") - - @JvmField val PENDING = of("pending") - - @JvmStatic fun of(value: String) = EntryStatus(JsonField.of(value)) - } - - /** An enum containing [EntryStatus]'s known values. */ - enum class Known { - COMMITTED, - PENDING, - } - - /** - * An enum containing [EntryStatus]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryStatus] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - COMMITTED, - PENDING, - /** - * An enum member indicating that [EntryStatus] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - COMMITTED -> Value.COMMITTED - PENDING -> Value.PENDING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - COMMITTED -> Known.COMMITTED - PENDING -> Known.PENDING - else -> throw OrbInvalidDataException("Unknown EntryStatus: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryStatus && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val AMENDMENT = of("amendment") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - AMENDMENT - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMENDMENT, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMENDMENT -> Value.AMENDMENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AMENDMENT -> Known.AMENDMENT - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AmendmentLedgerEntry && id == other.id && amount == other.amount && createdAt == other.createdAt && creditBlock == other.creditBlock && currency == other.currency && customer == other.customer && description == other.description && endingBalance == other.endingBalance && entryStatus == other.entryStatus && entryType == other.entryType && ledgerSequenceNumber == other.ledgerSequenceNumber && metadata == other.metadata && startingBalance == other.startingBalance && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, createdAt, creditBlock, currency, customer, description, endingBalance, entryStatus, entryType, ledgerSequenceNumber, metadata, startingBalance, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AmendmentLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" - } -} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPage.kt index 58e689fce..246c85d8b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPage.kt @@ -105,7 +105,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -164,23 +164,20 @@ private constructor( @JsonCreator constructor( @JsonProperty("data") - private val data: JsonField> = - JsonMissing.of(), + private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = - data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = - Optional.ofNullable(data) + fun _data(): Optional>> = Optional.ofNullable(data) @JsonProperty("pagination_metadata") fun _paginationMetadata(): Optional> = @@ -219,13 +216,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [CustomerCreditLedgerListByExternalIdPage]. + */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = - JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -236,12 +236,9 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = - data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { - this.data = data - } + fun data(data: JsonField>) = apply { this.data = data } fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) @@ -259,9 +256,9 @@ private constructor( } class AutoPager(private val firstPage: CustomerCreditLedgerListByExternalIdPage) : - Iterable { + Iterable { - override fun iterator(): Iterator = iterator { + override fun iterator(): Iterator = iterator { var page = firstPage var index = 0 while (true) { @@ -273,7 +270,7 @@ private constructor( } } - fun stream(): Stream { + fun stream(): Stream { return StreamSupport.stream(spliterator(), false) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageAsync.kt index 6951afb95..493720b64 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdPageAsync.kt @@ -106,7 +106,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -167,23 +167,20 @@ private constructor( @JsonCreator constructor( @JsonProperty("data") - private val data: JsonField> = - JsonMissing.of(), + private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = - data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = - Optional.ofNullable(data) + fun _data(): Optional>> = Optional.ofNullable(data) @JsonProperty("pagination_metadata") fun _paginationMetadata(): Optional> = @@ -222,13 +219,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [CustomerCreditLedgerListByExternalIdPageAsync]. + */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = - JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -239,12 +239,9 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = - data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { - this.data = data - } + fun data(data: JsonField>) = apply { this.data = data } fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) @@ -264,11 +261,11 @@ private constructor( class AutoPager(private val firstPage: CustomerCreditLedgerListByExternalIdPageAsync) { fun forEach( - action: Predicate, + action: Predicate, executor: Executor, ): CompletableFuture { fun CompletableFuture>.forEach( - action: (CustomerCreditLedgerListByExternalIdResponse) -> Boolean, + action: (CreditLedgerEntryModel) -> Boolean, executor: Executor, ): CompletableFuture = thenComposeAsync( @@ -284,10 +281,8 @@ private constructor( .forEach(action::test, executor) } - fun toList( - executor: Executor - ): CompletableFuture> { - val values = mutableListOf() + fun toList(executor: Executor): CompletableFuture> { + val values = mutableListOf() return forEach(values::add, executor).thenApply { values } } } 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 36d3ea084..6ac166a13 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 @@ -191,6 +191,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [CustomerCreditLedgerListByExternalIdParams]. + * + * The following fields are required: + * ```java + * .externalCustomerId() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 deleted file mode 100644 index bfb449d60..000000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponse.kt +++ /dev/null @@ -1,6791 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer -import com.withorb.api.core.Enum -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow -import com.withorb.api.core.immutableEmptyMap -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** - * The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid credits within - * Orb. - */ -@JsonDeserialize(using = CustomerCreditLedgerListByExternalIdResponse.Deserializer::class) -@JsonSerialize(using = CustomerCreditLedgerListByExternalIdResponse.Serializer::class) -class CustomerCreditLedgerListByExternalIdResponse -private constructor( - private val incrementLedgerEntry: IncrementLedgerEntry? = null, - private val decrementLedgerEntry: DecrementLedgerEntry? = null, - private val expirationChangeLedgerEntry: ExpirationChangeLedgerEntry? = null, - private val creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry? = null, - private val voidLedgerEntry: VoidLedgerEntry? = null, - private val voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry? = null, - private val amendmentLedgerEntry: AmendmentLedgerEntry? = null, - private val _json: JsonValue? = null, -) { - - fun incrementLedgerEntry(): Optional = - Optional.ofNullable(incrementLedgerEntry) - - fun decrementLedgerEntry(): Optional = - Optional.ofNullable(decrementLedgerEntry) - - fun expirationChangeLedgerEntry(): Optional = - Optional.ofNullable(expirationChangeLedgerEntry) - - fun creditBlockExpiryLedgerEntry(): Optional = - Optional.ofNullable(creditBlockExpiryLedgerEntry) - - fun voidLedgerEntry(): Optional = Optional.ofNullable(voidLedgerEntry) - - fun voidInitiatedLedgerEntry(): Optional = - Optional.ofNullable(voidInitiatedLedgerEntry) - - fun amendmentLedgerEntry(): Optional = - Optional.ofNullable(amendmentLedgerEntry) - - fun isIncrementLedgerEntry(): Boolean = incrementLedgerEntry != null - - fun isDecrementLedgerEntry(): Boolean = decrementLedgerEntry != null - - fun isExpirationChangeLedgerEntry(): Boolean = expirationChangeLedgerEntry != null - - fun isCreditBlockExpiryLedgerEntry(): Boolean = creditBlockExpiryLedgerEntry != null - - fun isVoidLedgerEntry(): Boolean = voidLedgerEntry != null - - fun isVoidInitiatedLedgerEntry(): Boolean = voidInitiatedLedgerEntry != null - - fun isAmendmentLedgerEntry(): Boolean = amendmentLedgerEntry != null - - fun asIncrementLedgerEntry(): IncrementLedgerEntry = - incrementLedgerEntry.getOrThrow("incrementLedgerEntry") - - fun asDecrementLedgerEntry(): DecrementLedgerEntry = - decrementLedgerEntry.getOrThrow("decrementLedgerEntry") - - fun asExpirationChangeLedgerEntry(): ExpirationChangeLedgerEntry = - expirationChangeLedgerEntry.getOrThrow("expirationChangeLedgerEntry") - - fun asCreditBlockExpiryLedgerEntry(): CreditBlockExpiryLedgerEntry = - creditBlockExpiryLedgerEntry.getOrThrow("creditBlockExpiryLedgerEntry") - - fun asVoidLedgerEntry(): VoidLedgerEntry = voidLedgerEntry.getOrThrow("voidLedgerEntry") - - fun asVoidInitiatedLedgerEntry(): VoidInitiatedLedgerEntry = - voidInitiatedLedgerEntry.getOrThrow("voidInitiatedLedgerEntry") - - fun asAmendmentLedgerEntry(): AmendmentLedgerEntry = - amendmentLedgerEntry.getOrThrow("amendmentLedgerEntry") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - incrementLedgerEntry != null -> visitor.visitIncrementLedgerEntry(incrementLedgerEntry) - decrementLedgerEntry != null -> visitor.visitDecrementLedgerEntry(decrementLedgerEntry) - expirationChangeLedgerEntry != null -> - visitor.visitExpirationChangeLedgerEntry(expirationChangeLedgerEntry) - creditBlockExpiryLedgerEntry != null -> - visitor.visitCreditBlockExpiryLedgerEntry(creditBlockExpiryLedgerEntry) - voidLedgerEntry != null -> visitor.visitVoidLedgerEntry(voidLedgerEntry) - voidInitiatedLedgerEntry != null -> - visitor.visitVoidInitiatedLedgerEntry(voidInitiatedLedgerEntry) - amendmentLedgerEntry != null -> visitor.visitAmendmentLedgerEntry(amendmentLedgerEntry) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): CustomerCreditLedgerListByExternalIdResponse = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitIncrementLedgerEntry(incrementLedgerEntry: IncrementLedgerEntry) { - incrementLedgerEntry.validate() - } - - override fun visitDecrementLedgerEntry(decrementLedgerEntry: DecrementLedgerEntry) { - decrementLedgerEntry.validate() - } - - override fun visitExpirationChangeLedgerEntry( - expirationChangeLedgerEntry: ExpirationChangeLedgerEntry - ) { - expirationChangeLedgerEntry.validate() - } - - override fun visitCreditBlockExpiryLedgerEntry( - creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry - ) { - creditBlockExpiryLedgerEntry.validate() - } - - override fun visitVoidLedgerEntry(voidLedgerEntry: VoidLedgerEntry) { - voidLedgerEntry.validate() - } - - override fun visitVoidInitiatedLedgerEntry( - voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry - ) { - voidInitiatedLedgerEntry.validate() - } - - override fun visitAmendmentLedgerEntry(amendmentLedgerEntry: AmendmentLedgerEntry) { - amendmentLedgerEntry.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CustomerCreditLedgerListByExternalIdResponse && incrementLedgerEntry == other.incrementLedgerEntry && decrementLedgerEntry == other.decrementLedgerEntry && expirationChangeLedgerEntry == other.expirationChangeLedgerEntry && creditBlockExpiryLedgerEntry == other.creditBlockExpiryLedgerEntry && voidLedgerEntry == other.voidLedgerEntry && voidInitiatedLedgerEntry == other.voidInitiatedLedgerEntry && amendmentLedgerEntry == other.amendmentLedgerEntry /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(incrementLedgerEntry, decrementLedgerEntry, expirationChangeLedgerEntry, creditBlockExpiryLedgerEntry, voidLedgerEntry, voidInitiatedLedgerEntry, amendmentLedgerEntry) /* spotless:on */ - - override fun toString(): String = - when { - incrementLedgerEntry != null -> - "CustomerCreditLedgerListByExternalIdResponse{incrementLedgerEntry=$incrementLedgerEntry}" - decrementLedgerEntry != null -> - "CustomerCreditLedgerListByExternalIdResponse{decrementLedgerEntry=$decrementLedgerEntry}" - expirationChangeLedgerEntry != null -> - "CustomerCreditLedgerListByExternalIdResponse{expirationChangeLedgerEntry=$expirationChangeLedgerEntry}" - creditBlockExpiryLedgerEntry != null -> - "CustomerCreditLedgerListByExternalIdResponse{creditBlockExpiryLedgerEntry=$creditBlockExpiryLedgerEntry}" - voidLedgerEntry != null -> - "CustomerCreditLedgerListByExternalIdResponse{voidLedgerEntry=$voidLedgerEntry}" - voidInitiatedLedgerEntry != null -> - "CustomerCreditLedgerListByExternalIdResponse{voidInitiatedLedgerEntry=$voidInitiatedLedgerEntry}" - amendmentLedgerEntry != null -> - "CustomerCreditLedgerListByExternalIdResponse{amendmentLedgerEntry=$amendmentLedgerEntry}" - _json != null -> "CustomerCreditLedgerListByExternalIdResponse{_unknown=$_json}" - else -> - throw IllegalStateException("Invalid CustomerCreditLedgerListByExternalIdResponse") - } - - companion object { - - @JvmStatic - fun ofIncrementLedgerEntry(incrementLedgerEntry: IncrementLedgerEntry) = - CustomerCreditLedgerListByExternalIdResponse( - incrementLedgerEntry = incrementLedgerEntry - ) - - @JvmStatic - fun ofDecrementLedgerEntry(decrementLedgerEntry: DecrementLedgerEntry) = - CustomerCreditLedgerListByExternalIdResponse( - decrementLedgerEntry = decrementLedgerEntry - ) - - @JvmStatic - fun ofExpirationChangeLedgerEntry( - expirationChangeLedgerEntry: ExpirationChangeLedgerEntry - ) = - CustomerCreditLedgerListByExternalIdResponse( - expirationChangeLedgerEntry = expirationChangeLedgerEntry - ) - - @JvmStatic - fun ofCreditBlockExpiryLedgerEntry( - creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry - ) = - CustomerCreditLedgerListByExternalIdResponse( - creditBlockExpiryLedgerEntry = creditBlockExpiryLedgerEntry - ) - - @JvmStatic - fun ofVoidLedgerEntry(voidLedgerEntry: VoidLedgerEntry) = - CustomerCreditLedgerListByExternalIdResponse(voidLedgerEntry = voidLedgerEntry) - - @JvmStatic - fun ofVoidInitiatedLedgerEntry(voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry) = - CustomerCreditLedgerListByExternalIdResponse( - voidInitiatedLedgerEntry = voidInitiatedLedgerEntry - ) - - @JvmStatic - fun ofAmendmentLedgerEntry(amendmentLedgerEntry: AmendmentLedgerEntry) = - CustomerCreditLedgerListByExternalIdResponse( - amendmentLedgerEntry = amendmentLedgerEntry - ) - } - - /** - * An interface that defines how to map each variant of - * [CustomerCreditLedgerListByExternalIdResponse] to a value of type [T]. - */ - interface Visitor { - - fun visitIncrementLedgerEntry(incrementLedgerEntry: IncrementLedgerEntry): T - - fun visitDecrementLedgerEntry(decrementLedgerEntry: DecrementLedgerEntry): T - - fun visitExpirationChangeLedgerEntry( - expirationChangeLedgerEntry: ExpirationChangeLedgerEntry - ): T - - fun visitCreditBlockExpiryLedgerEntry( - creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry - ): T - - fun visitVoidLedgerEntry(voidLedgerEntry: VoidLedgerEntry): T - - fun visitVoidInitiatedLedgerEntry(voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry): T - - fun visitAmendmentLedgerEntry(amendmentLedgerEntry: AmendmentLedgerEntry): T - - /** - * Maps an unknown variant of [CustomerCreditLedgerListByExternalIdResponse] to a value of - * type [T]. - * - * An instance of [CustomerCreditLedgerListByExternalIdResponse] can contain an unknown - * variant if it was deserialized from data that doesn't match any known variant. For - * example, if the SDK is on an older version than the API, then the API may respond with - * new variants that the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException( - "Unknown CustomerCreditLedgerListByExternalIdResponse: $json" - ) - } - } - - internal class Deserializer : - BaseDeserializer( - CustomerCreditLedgerListByExternalIdResponse::class - ) { - - override fun ObjectCodec.deserialize( - node: JsonNode - ): CustomerCreditLedgerListByExternalIdResponse { - val json = JsonValue.fromJsonNode(node) - val entryType = json.asObject().getOrNull()?.get("entry_type")?.asString()?.getOrNull() - - when (entryType) { - "increment" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return CustomerCreditLedgerListByExternalIdResponse( - incrementLedgerEntry = it, - _json = json, - ) - } - } - "decrement" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return CustomerCreditLedgerListByExternalIdResponse( - decrementLedgerEntry = it, - _json = json, - ) - } - } - "expiration_change" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return CustomerCreditLedgerListByExternalIdResponse( - expirationChangeLedgerEntry = it, - _json = json, - ) - } - } - "credit_block_expiry" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return CustomerCreditLedgerListByExternalIdResponse( - creditBlockExpiryLedgerEntry = it, - _json = json, - ) - } - } - "void" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return CustomerCreditLedgerListByExternalIdResponse( - voidLedgerEntry = it, - _json = json, - ) - } - } - "void_initiated" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return CustomerCreditLedgerListByExternalIdResponse( - voidInitiatedLedgerEntry = it, - _json = json, - ) - } - } - "amendment" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return CustomerCreditLedgerListByExternalIdResponse( - amendmentLedgerEntry = it, - _json = json, - ) - } - } - } - - return CustomerCreditLedgerListByExternalIdResponse(_json = json) - } - } - - internal class Serializer : - BaseSerializer( - CustomerCreditLedgerListByExternalIdResponse::class - ) { - - override fun serialize( - value: CustomerCreditLedgerListByExternalIdResponse, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.incrementLedgerEntry != null -> - generator.writeObject(value.incrementLedgerEntry) - value.decrementLedgerEntry != null -> - generator.writeObject(value.decrementLedgerEntry) - value.expirationChangeLedgerEntry != null -> - generator.writeObject(value.expirationChangeLedgerEntry) - value.creditBlockExpiryLedgerEntry != null -> - generator.writeObject(value.creditBlockExpiryLedgerEntry) - value.voidLedgerEntry != null -> generator.writeObject(value.voidLedgerEntry) - value.voidInitiatedLedgerEntry != null -> - generator.writeObject(value.voidInitiatedLedgerEntry) - value.amendmentLedgerEntry != null -> - generator.writeObject(value.amendmentLedgerEntry) - value._json != null -> generator.writeObject(value._json) - else -> - throw IllegalStateException( - "Invalid CustomerCreditLedgerListByExternalIdResponse" - ) - } - } - } - - @NoAutoDetect - class IncrementLedgerEntry - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("credit_block") - @ExcludeMissing - private val creditBlock: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("customer") - @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("ending_balance") - @ExcludeMissing - private val endingBalance: JsonField = JsonMissing.of(), - @JsonProperty("entry_status") - @ExcludeMissing - private val entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - private val entryType: JsonField = JsonMissing.of(), - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - private val ledgerSequenceNumber: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("starting_balance") - @ExcludeMissing - private val startingBalance: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun amount(): Double = amount.getRequired("amount") - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - fun creditBlock(): CreditBlock = creditBlock.getRequired("credit_block") - - fun currency(): String = currency.getRequired("currency") - - fun customer(): Customer = customer.getRequired("customer") - - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - fun endingBalance(): Double = endingBalance.getRequired("ending_balance") - - fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") - - fun entryType(): EntryType = entryType.getRequired("entry_type") - - fun ledgerSequenceNumber(): Long = - ledgerSequenceNumber.getRequired("ledger_sequence_number") - - /** - * 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.getRequired("metadata") - - fun startingBalance(): Double = startingBalance.getRequired("starting_balance") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - @JsonProperty("credit_block") - @ExcludeMissing - fun _creditBlock(): JsonField = creditBlock - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - @JsonProperty("ending_balance") - @ExcludeMissing - fun _endingBalance(): JsonField = endingBalance - - @JsonProperty("entry_status") - @ExcludeMissing - fun _entryStatus(): JsonField = entryStatus - - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber - - /** - * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - @JsonProperty("starting_balance") - @ExcludeMissing - fun _startingBalance(): JsonField = startingBalance - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): IncrementLedgerEntry = apply { - if (validated) { - return@apply - } - - id() - amount() - createdAt() - creditBlock().validate() - currency() - customer().validate() - description() - endingBalance() - entryStatus() - entryType() - ledgerSequenceNumber() - metadata().validate() - startingBalance() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [IncrementLedgerEntry]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var amount: JsonField? = null - private var createdAt: JsonField? = null - private var creditBlock: JsonField? = null - private var currency: JsonField? = null - private var customer: JsonField? = null - private var description: JsonField? = null - private var endingBalance: JsonField? = null - private var entryStatus: JsonField? = null - private var entryType: JsonField? = null - private var ledgerSequenceNumber: JsonField? = null - private var metadata: JsonField? = null - private var startingBalance: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(incrementLedgerEntry: IncrementLedgerEntry) = apply { - id = incrementLedgerEntry.id - amount = incrementLedgerEntry.amount - createdAt = incrementLedgerEntry.createdAt - creditBlock = incrementLedgerEntry.creditBlock - currency = incrementLedgerEntry.currency - customer = incrementLedgerEntry.customer - description = incrementLedgerEntry.description - endingBalance = incrementLedgerEntry.endingBalance - entryStatus = incrementLedgerEntry.entryStatus - entryType = incrementLedgerEntry.entryType - ledgerSequenceNumber = incrementLedgerEntry.ledgerSequenceNumber - metadata = incrementLedgerEntry.metadata - startingBalance = incrementLedgerEntry.startingBalance - additionalProperties = incrementLedgerEntry.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun amount(amount: Double) = amount(JsonField.of(amount)) - - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { - this.createdAt = createdAt - } - - fun creditBlock(creditBlock: CreditBlock) = creditBlock(JsonField.of(creditBlock)) - - fun creditBlock(creditBlock: JsonField) = apply { - this.creditBlock = creditBlock - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun customer(customer: Customer) = customer(JsonField.of(customer)) - - fun customer(customer: JsonField) = apply { this.customer = customer } - - fun description(description: String?) = description(JsonField.ofNullable(description)) - - fun description(description: Optional) = description(description.orElse(null)) - - fun description(description: JsonField) = apply { - this.description = description - } - - fun endingBalance(endingBalance: Double) = endingBalance(JsonField.of(endingBalance)) - - fun endingBalance(endingBalance: JsonField) = apply { - this.endingBalance = endingBalance - } - - fun entryStatus(entryStatus: EntryStatus) = entryStatus(JsonField.of(entryStatus)) - - fun entryStatus(entryStatus: JsonField) = apply { - this.entryStatus = entryStatus - } - - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } - - fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = - ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) - - fun ledgerSequenceNumber(ledgerSequenceNumber: JsonField) = apply { - this.ledgerSequenceNumber = ledgerSequenceNumber - } - - /** - * 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - fun startingBalance(startingBalance: Double) = - startingBalance(JsonField.of(startingBalance)) - - fun startingBalance(startingBalance: JsonField) = apply { - this.startingBalance = startingBalance - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): IncrementLedgerEntry = - IncrementLedgerEntry( - checkRequired("id", id), - checkRequired("amount", amount), - checkRequired("createdAt", createdAt), - checkRequired("creditBlock", creditBlock), - checkRequired("currency", currency), - checkRequired("customer", customer), - checkRequired("description", description), - checkRequired("endingBalance", endingBalance), - checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), - checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), - checkRequired("metadata", metadata), - checkRequired("startingBalance", startingBalance), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class CreditBlock - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("expiry_date") - @ExcludeMissing - private val expiryDate: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - private val perUnitCostBasis: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun expiryDate(): Optional = - Optional.ofNullable(expiryDate.getNullable("expiry_date")) - - fun perUnitCostBasis(): Optional = - Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("expiry_date") - @ExcludeMissing - fun _expiryDate(): JsonField = expiryDate - - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - fun _perUnitCostBasis(): JsonField = perUnitCostBasis - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditBlock = apply { - if (validated) { - return@apply - } - - id() - expiryDate() - perUnitCostBasis() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditBlock]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var expiryDate: JsonField? = null - private var perUnitCostBasis: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditBlock: CreditBlock) = apply { - id = creditBlock.id - expiryDate = creditBlock.expiryDate - perUnitCostBasis = creditBlock.perUnitCostBasis - additionalProperties = creditBlock.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun expiryDate(expiryDate: OffsetDateTime?) = - expiryDate(JsonField.ofNullable(expiryDate)) - - fun expiryDate(expiryDate: Optional) = - expiryDate(expiryDate.orElse(null)) - - fun expiryDate(expiryDate: JsonField) = apply { - this.expiryDate = expiryDate - } - - fun perUnitCostBasis(perUnitCostBasis: String?) = - perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) - - fun perUnitCostBasis(perUnitCostBasis: Optional) = - perUnitCostBasis(perUnitCostBasis.orElse(null)) - - fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { - this.perUnitCostBasis = perUnitCostBasis - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditBlock = - CreditBlock( - checkRequired("id", id), - checkRequired("expiryDate", expiryDate), - checkRequired("perUnitCostBasis", perUnitCostBasis), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditBlock && id == other.id && expiryDate == other.expiryDate && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, expiryDate, perUnitCostBasis, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditBlock{id=$id, expiryDate=$expiryDate, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Customer - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("external_customer_id") - @ExcludeMissing - private val externalCustomerId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun externalCustomerId(): Optional = - Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("external_customer_id") - @ExcludeMissing - fun _externalCustomerId(): JsonField = externalCustomerId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Customer = apply { - if (validated) { - return@apply - } - - id() - externalCustomerId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Customer]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var externalCustomerId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customer: Customer) = apply { - id = customer.id - externalCustomerId = customer.externalCustomerId - additionalProperties = customer.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun externalCustomerId(externalCustomerId: String?) = - externalCustomerId(JsonField.ofNullable(externalCustomerId)) - - fun externalCustomerId(externalCustomerId: Optional) = - externalCustomerId(externalCustomerId.orElse(null)) - - fun externalCustomerId(externalCustomerId: JsonField) = apply { - this.externalCustomerId = externalCustomerId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Customer = - Customer( - checkRequired("id", id), - checkRequired("externalCustomerId", externalCustomerId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Customer && id == other.id && externalCustomerId == other.externalCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, externalCustomerId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Customer{id=$id, externalCustomerId=$externalCustomerId, additionalProperties=$additionalProperties}" - } - - class EntryStatus @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val COMMITTED = of("committed") - - @JvmField val PENDING = of("pending") - - @JvmStatic fun of(value: String) = EntryStatus(JsonField.of(value)) - } - - /** An enum containing [EntryStatus]'s known values. */ - enum class Known { - COMMITTED, - PENDING, - } - - /** - * An enum containing [EntryStatus]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryStatus] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - COMMITTED, - PENDING, - /** - * An enum member indicating that [EntryStatus] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - COMMITTED -> Value.COMMITTED - PENDING -> Value.PENDING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - COMMITTED -> Known.COMMITTED - PENDING -> Known.PENDING - else -> throw OrbInvalidDataException("Unknown EntryStatus: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryStatus && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val INCREMENT = of("increment") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - INCREMENT - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - INCREMENT, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - INCREMENT -> Value.INCREMENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - INCREMENT -> Known.INCREMENT - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is IncrementLedgerEntry && id == other.id && amount == other.amount && createdAt == other.createdAt && creditBlock == other.creditBlock && currency == other.currency && customer == other.customer && description == other.description && endingBalance == other.endingBalance && entryStatus == other.entryStatus && entryType == other.entryType && ledgerSequenceNumber == other.ledgerSequenceNumber && metadata == other.metadata && startingBalance == other.startingBalance && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, createdAt, creditBlock, currency, customer, description, endingBalance, entryStatus, entryType, ledgerSequenceNumber, metadata, startingBalance, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "IncrementLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class DecrementLedgerEntry - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("credit_block") - @ExcludeMissing - private val creditBlock: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("customer") - @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("ending_balance") - @ExcludeMissing - private val endingBalance: JsonField = JsonMissing.of(), - @JsonProperty("entry_status") - @ExcludeMissing - private val entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - private val entryType: JsonField = JsonMissing.of(), - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - private val ledgerSequenceNumber: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("starting_balance") - @ExcludeMissing - private val startingBalance: JsonField = JsonMissing.of(), - @JsonProperty("event_id") - @ExcludeMissing - private val eventId: JsonField = JsonMissing.of(), - @JsonProperty("invoice_id") - @ExcludeMissing - private val invoiceId: JsonField = JsonMissing.of(), - @JsonProperty("price_id") - @ExcludeMissing - private val priceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun amount(): Double = amount.getRequired("amount") - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - fun creditBlock(): CreditBlock = creditBlock.getRequired("credit_block") - - fun currency(): String = currency.getRequired("currency") - - fun customer(): Customer = customer.getRequired("customer") - - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - fun endingBalance(): Double = endingBalance.getRequired("ending_balance") - - fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") - - fun entryType(): EntryType = entryType.getRequired("entry_type") - - fun ledgerSequenceNumber(): Long = - ledgerSequenceNumber.getRequired("ledger_sequence_number") - - /** - * 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.getRequired("metadata") - - fun startingBalance(): Double = startingBalance.getRequired("starting_balance") - - fun eventId(): Optional = Optional.ofNullable(eventId.getNullable("event_id")) - - fun invoiceId(): Optional = Optional.ofNullable(invoiceId.getNullable("invoice_id")) - - fun priceId(): Optional = Optional.ofNullable(priceId.getNullable("price_id")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - @JsonProperty("credit_block") - @ExcludeMissing - fun _creditBlock(): JsonField = creditBlock - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - @JsonProperty("ending_balance") - @ExcludeMissing - fun _endingBalance(): JsonField = endingBalance - - @JsonProperty("entry_status") - @ExcludeMissing - fun _entryStatus(): JsonField = entryStatus - - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber - - /** - * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - @JsonProperty("starting_balance") - @ExcludeMissing - fun _startingBalance(): JsonField = startingBalance - - @JsonProperty("event_id") @ExcludeMissing fun _eventId(): JsonField = eventId - - @JsonProperty("invoice_id") @ExcludeMissing fun _invoiceId(): JsonField = invoiceId - - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): DecrementLedgerEntry = apply { - if (validated) { - return@apply - } - - id() - amount() - createdAt() - creditBlock().validate() - currency() - customer().validate() - description() - endingBalance() - entryStatus() - entryType() - ledgerSequenceNumber() - metadata().validate() - startingBalance() - eventId() - invoiceId() - priceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DecrementLedgerEntry]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var amount: JsonField? = null - private var createdAt: JsonField? = null - private var creditBlock: JsonField? = null - private var currency: JsonField? = null - private var customer: JsonField? = null - private var description: JsonField? = null - private var endingBalance: JsonField? = null - private var entryStatus: JsonField? = null - private var entryType: JsonField? = null - private var ledgerSequenceNumber: JsonField? = null - private var metadata: JsonField? = null - private var startingBalance: JsonField? = null - private var eventId: JsonField = JsonMissing.of() - private var invoiceId: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(decrementLedgerEntry: DecrementLedgerEntry) = apply { - id = decrementLedgerEntry.id - amount = decrementLedgerEntry.amount - createdAt = decrementLedgerEntry.createdAt - creditBlock = decrementLedgerEntry.creditBlock - currency = decrementLedgerEntry.currency - customer = decrementLedgerEntry.customer - description = decrementLedgerEntry.description - endingBalance = decrementLedgerEntry.endingBalance - entryStatus = decrementLedgerEntry.entryStatus - entryType = decrementLedgerEntry.entryType - ledgerSequenceNumber = decrementLedgerEntry.ledgerSequenceNumber - metadata = decrementLedgerEntry.metadata - startingBalance = decrementLedgerEntry.startingBalance - eventId = decrementLedgerEntry.eventId - invoiceId = decrementLedgerEntry.invoiceId - priceId = decrementLedgerEntry.priceId - additionalProperties = decrementLedgerEntry.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun amount(amount: Double) = amount(JsonField.of(amount)) - - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { - this.createdAt = createdAt - } - - fun creditBlock(creditBlock: CreditBlock) = creditBlock(JsonField.of(creditBlock)) - - fun creditBlock(creditBlock: JsonField) = apply { - this.creditBlock = creditBlock - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun customer(customer: Customer) = customer(JsonField.of(customer)) - - fun customer(customer: JsonField) = apply { this.customer = customer } - - fun description(description: String?) = description(JsonField.ofNullable(description)) - - fun description(description: Optional) = description(description.orElse(null)) - - fun description(description: JsonField) = apply { - this.description = description - } - - fun endingBalance(endingBalance: Double) = endingBalance(JsonField.of(endingBalance)) - - fun endingBalance(endingBalance: JsonField) = apply { - this.endingBalance = endingBalance - } - - fun entryStatus(entryStatus: EntryStatus) = entryStatus(JsonField.of(entryStatus)) - - fun entryStatus(entryStatus: JsonField) = apply { - this.entryStatus = entryStatus - } - - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } - - fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = - ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) - - fun ledgerSequenceNumber(ledgerSequenceNumber: JsonField) = apply { - this.ledgerSequenceNumber = ledgerSequenceNumber - } - - /** - * 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - fun startingBalance(startingBalance: Double) = - startingBalance(JsonField.of(startingBalance)) - - fun startingBalance(startingBalance: JsonField) = apply { - this.startingBalance = startingBalance - } - - fun eventId(eventId: String?) = eventId(JsonField.ofNullable(eventId)) - - fun eventId(eventId: Optional) = eventId(eventId.orElse(null)) - - fun eventId(eventId: JsonField) = apply { this.eventId = eventId } - - fun invoiceId(invoiceId: String?) = invoiceId(JsonField.ofNullable(invoiceId)) - - fun invoiceId(invoiceId: Optional) = invoiceId(invoiceId.orElse(null)) - - fun invoiceId(invoiceId: JsonField) = apply { this.invoiceId = invoiceId } - - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) - - fun priceId(priceId: Optional) = priceId(priceId.orElse(null)) - - 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) - } - - fun build(): DecrementLedgerEntry = - DecrementLedgerEntry( - checkRequired("id", id), - checkRequired("amount", amount), - checkRequired("createdAt", createdAt), - checkRequired("creditBlock", creditBlock), - checkRequired("currency", currency), - checkRequired("customer", customer), - checkRequired("description", description), - checkRequired("endingBalance", endingBalance), - checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), - checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), - checkRequired("metadata", metadata), - checkRequired("startingBalance", startingBalance), - eventId, - invoiceId, - priceId, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class CreditBlock - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("expiry_date") - @ExcludeMissing - private val expiryDate: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - private val perUnitCostBasis: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun expiryDate(): Optional = - Optional.ofNullable(expiryDate.getNullable("expiry_date")) - - fun perUnitCostBasis(): Optional = - Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("expiry_date") - @ExcludeMissing - fun _expiryDate(): JsonField = expiryDate - - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - fun _perUnitCostBasis(): JsonField = perUnitCostBasis - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditBlock = apply { - if (validated) { - return@apply - } - - id() - expiryDate() - perUnitCostBasis() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditBlock]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var expiryDate: JsonField? = null - private var perUnitCostBasis: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditBlock: CreditBlock) = apply { - id = creditBlock.id - expiryDate = creditBlock.expiryDate - perUnitCostBasis = creditBlock.perUnitCostBasis - additionalProperties = creditBlock.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun expiryDate(expiryDate: OffsetDateTime?) = - expiryDate(JsonField.ofNullable(expiryDate)) - - fun expiryDate(expiryDate: Optional) = - expiryDate(expiryDate.orElse(null)) - - fun expiryDate(expiryDate: JsonField) = apply { - this.expiryDate = expiryDate - } - - fun perUnitCostBasis(perUnitCostBasis: String?) = - perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) - - fun perUnitCostBasis(perUnitCostBasis: Optional) = - perUnitCostBasis(perUnitCostBasis.orElse(null)) - - fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { - this.perUnitCostBasis = perUnitCostBasis - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditBlock = - CreditBlock( - checkRequired("id", id), - checkRequired("expiryDate", expiryDate), - checkRequired("perUnitCostBasis", perUnitCostBasis), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditBlock && id == other.id && expiryDate == other.expiryDate && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, expiryDate, perUnitCostBasis, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditBlock{id=$id, expiryDate=$expiryDate, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Customer - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("external_customer_id") - @ExcludeMissing - private val externalCustomerId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun externalCustomerId(): Optional = - Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("external_customer_id") - @ExcludeMissing - fun _externalCustomerId(): JsonField = externalCustomerId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Customer = apply { - if (validated) { - return@apply - } - - id() - externalCustomerId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Customer]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var externalCustomerId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customer: Customer) = apply { - id = customer.id - externalCustomerId = customer.externalCustomerId - additionalProperties = customer.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun externalCustomerId(externalCustomerId: String?) = - externalCustomerId(JsonField.ofNullable(externalCustomerId)) - - fun externalCustomerId(externalCustomerId: Optional) = - externalCustomerId(externalCustomerId.orElse(null)) - - fun externalCustomerId(externalCustomerId: JsonField) = apply { - this.externalCustomerId = externalCustomerId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Customer = - Customer( - checkRequired("id", id), - checkRequired("externalCustomerId", externalCustomerId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Customer && id == other.id && externalCustomerId == other.externalCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, externalCustomerId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Customer{id=$id, externalCustomerId=$externalCustomerId, additionalProperties=$additionalProperties}" - } - - class EntryStatus @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val COMMITTED = of("committed") - - @JvmField val PENDING = of("pending") - - @JvmStatic fun of(value: String) = EntryStatus(JsonField.of(value)) - } - - /** An enum containing [EntryStatus]'s known values. */ - enum class Known { - COMMITTED, - PENDING, - } - - /** - * An enum containing [EntryStatus]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryStatus] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - COMMITTED, - PENDING, - /** - * An enum member indicating that [EntryStatus] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - COMMITTED -> Value.COMMITTED - PENDING -> Value.PENDING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - COMMITTED -> Known.COMMITTED - PENDING -> Known.PENDING - else -> throw OrbInvalidDataException("Unknown EntryStatus: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryStatus && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DECREMENT = of("decrement") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - DECREMENT - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DECREMENT, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DECREMENT -> Value.DECREMENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - DECREMENT -> Known.DECREMENT - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DecrementLedgerEntry && id == other.id && amount == other.amount && createdAt == other.createdAt && creditBlock == other.creditBlock && currency == other.currency && customer == other.customer && description == other.description && endingBalance == other.endingBalance && entryStatus == other.entryStatus && entryType == other.entryType && ledgerSequenceNumber == other.ledgerSequenceNumber && metadata == other.metadata && startingBalance == other.startingBalance && eventId == other.eventId && invoiceId == other.invoiceId && priceId == other.priceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, createdAt, creditBlock, currency, customer, description, endingBalance, entryStatus, entryType, ledgerSequenceNumber, metadata, startingBalance, eventId, invoiceId, priceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DecrementLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, eventId=$eventId, invoiceId=$invoiceId, priceId=$priceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class ExpirationChangeLedgerEntry - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("credit_block") - @ExcludeMissing - private val creditBlock: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("customer") - @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("ending_balance") - @ExcludeMissing - private val endingBalance: JsonField = JsonMissing.of(), - @JsonProperty("entry_status") - @ExcludeMissing - private val entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - private val entryType: JsonField = JsonMissing.of(), - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - private val ledgerSequenceNumber: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("new_block_expiry_date") - @ExcludeMissing - private val newBlockExpiryDate: JsonField = JsonMissing.of(), - @JsonProperty("starting_balance") - @ExcludeMissing - private val startingBalance: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun amount(): Double = amount.getRequired("amount") - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - fun creditBlock(): CreditBlock = creditBlock.getRequired("credit_block") - - fun currency(): String = currency.getRequired("currency") - - fun customer(): Customer = customer.getRequired("customer") - - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - fun endingBalance(): Double = endingBalance.getRequired("ending_balance") - - fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") - - fun entryType(): EntryType = entryType.getRequired("entry_type") - - fun ledgerSequenceNumber(): Long = - ledgerSequenceNumber.getRequired("ledger_sequence_number") - - /** - * 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.getRequired("metadata") - - fun newBlockExpiryDate(): Optional = - Optional.ofNullable(newBlockExpiryDate.getNullable("new_block_expiry_date")) - - fun startingBalance(): Double = startingBalance.getRequired("starting_balance") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - @JsonProperty("credit_block") - @ExcludeMissing - fun _creditBlock(): JsonField = creditBlock - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - @JsonProperty("ending_balance") - @ExcludeMissing - fun _endingBalance(): JsonField = endingBalance - - @JsonProperty("entry_status") - @ExcludeMissing - fun _entryStatus(): JsonField = entryStatus - - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber - - /** - * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - @JsonProperty("new_block_expiry_date") - @ExcludeMissing - fun _newBlockExpiryDate(): JsonField = newBlockExpiryDate - - @JsonProperty("starting_balance") - @ExcludeMissing - fun _startingBalance(): JsonField = startingBalance - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): ExpirationChangeLedgerEntry = apply { - if (validated) { - return@apply - } - - id() - amount() - createdAt() - creditBlock().validate() - currency() - customer().validate() - description() - endingBalance() - entryStatus() - entryType() - ledgerSequenceNumber() - metadata().validate() - newBlockExpiryDate() - startingBalance() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ExpirationChangeLedgerEntry]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var amount: JsonField? = null - private var createdAt: JsonField? = null - private var creditBlock: JsonField? = null - private var currency: JsonField? = null - private var customer: JsonField? = null - private var description: JsonField? = null - private var endingBalance: JsonField? = null - private var entryStatus: JsonField? = null - private var entryType: JsonField? = null - private var ledgerSequenceNumber: JsonField? = null - private var metadata: JsonField? = null - private var newBlockExpiryDate: JsonField? = null - private var startingBalance: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(expirationChangeLedgerEntry: ExpirationChangeLedgerEntry) = apply { - id = expirationChangeLedgerEntry.id - amount = expirationChangeLedgerEntry.amount - createdAt = expirationChangeLedgerEntry.createdAt - creditBlock = expirationChangeLedgerEntry.creditBlock - currency = expirationChangeLedgerEntry.currency - customer = expirationChangeLedgerEntry.customer - description = expirationChangeLedgerEntry.description - endingBalance = expirationChangeLedgerEntry.endingBalance - entryStatus = expirationChangeLedgerEntry.entryStatus - entryType = expirationChangeLedgerEntry.entryType - ledgerSequenceNumber = expirationChangeLedgerEntry.ledgerSequenceNumber - metadata = expirationChangeLedgerEntry.metadata - newBlockExpiryDate = expirationChangeLedgerEntry.newBlockExpiryDate - startingBalance = expirationChangeLedgerEntry.startingBalance - additionalProperties = - expirationChangeLedgerEntry.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun amount(amount: Double) = amount(JsonField.of(amount)) - - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { - this.createdAt = createdAt - } - - fun creditBlock(creditBlock: CreditBlock) = creditBlock(JsonField.of(creditBlock)) - - fun creditBlock(creditBlock: JsonField) = apply { - this.creditBlock = creditBlock - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun customer(customer: Customer) = customer(JsonField.of(customer)) - - fun customer(customer: JsonField) = apply { this.customer = customer } - - fun description(description: String?) = description(JsonField.ofNullable(description)) - - fun description(description: Optional) = description(description.orElse(null)) - - fun description(description: JsonField) = apply { - this.description = description - } - - fun endingBalance(endingBalance: Double) = endingBalance(JsonField.of(endingBalance)) - - fun endingBalance(endingBalance: JsonField) = apply { - this.endingBalance = endingBalance - } - - fun entryStatus(entryStatus: EntryStatus) = entryStatus(JsonField.of(entryStatus)) - - fun entryStatus(entryStatus: JsonField) = apply { - this.entryStatus = entryStatus - } - - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } - - fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = - ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) - - fun ledgerSequenceNumber(ledgerSequenceNumber: JsonField) = apply { - this.ledgerSequenceNumber = ledgerSequenceNumber - } - - /** - * 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - fun newBlockExpiryDate(newBlockExpiryDate: OffsetDateTime?) = - newBlockExpiryDate(JsonField.ofNullable(newBlockExpiryDate)) - - fun newBlockExpiryDate(newBlockExpiryDate: Optional) = - newBlockExpiryDate(newBlockExpiryDate.orElse(null)) - - fun newBlockExpiryDate(newBlockExpiryDate: JsonField) = apply { - this.newBlockExpiryDate = newBlockExpiryDate - } - - fun startingBalance(startingBalance: Double) = - startingBalance(JsonField.of(startingBalance)) - - fun startingBalance(startingBalance: JsonField) = apply { - this.startingBalance = startingBalance - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): ExpirationChangeLedgerEntry = - ExpirationChangeLedgerEntry( - checkRequired("id", id), - checkRequired("amount", amount), - checkRequired("createdAt", createdAt), - checkRequired("creditBlock", creditBlock), - checkRequired("currency", currency), - checkRequired("customer", customer), - checkRequired("description", description), - checkRequired("endingBalance", endingBalance), - checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), - checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), - checkRequired("metadata", metadata), - checkRequired("newBlockExpiryDate", newBlockExpiryDate), - checkRequired("startingBalance", startingBalance), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class CreditBlock - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("expiry_date") - @ExcludeMissing - private val expiryDate: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - private val perUnitCostBasis: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun expiryDate(): Optional = - Optional.ofNullable(expiryDate.getNullable("expiry_date")) - - fun perUnitCostBasis(): Optional = - Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("expiry_date") - @ExcludeMissing - fun _expiryDate(): JsonField = expiryDate - - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - fun _perUnitCostBasis(): JsonField = perUnitCostBasis - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditBlock = apply { - if (validated) { - return@apply - } - - id() - expiryDate() - perUnitCostBasis() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditBlock]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var expiryDate: JsonField? = null - private var perUnitCostBasis: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditBlock: CreditBlock) = apply { - id = creditBlock.id - expiryDate = creditBlock.expiryDate - perUnitCostBasis = creditBlock.perUnitCostBasis - additionalProperties = creditBlock.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun expiryDate(expiryDate: OffsetDateTime?) = - expiryDate(JsonField.ofNullable(expiryDate)) - - fun expiryDate(expiryDate: Optional) = - expiryDate(expiryDate.orElse(null)) - - fun expiryDate(expiryDate: JsonField) = apply { - this.expiryDate = expiryDate - } - - fun perUnitCostBasis(perUnitCostBasis: String?) = - perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) - - fun perUnitCostBasis(perUnitCostBasis: Optional) = - perUnitCostBasis(perUnitCostBasis.orElse(null)) - - fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { - this.perUnitCostBasis = perUnitCostBasis - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditBlock = - CreditBlock( - checkRequired("id", id), - checkRequired("expiryDate", expiryDate), - checkRequired("perUnitCostBasis", perUnitCostBasis), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditBlock && id == other.id && expiryDate == other.expiryDate && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, expiryDate, perUnitCostBasis, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditBlock{id=$id, expiryDate=$expiryDate, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Customer - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("external_customer_id") - @ExcludeMissing - private val externalCustomerId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun externalCustomerId(): Optional = - Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("external_customer_id") - @ExcludeMissing - fun _externalCustomerId(): JsonField = externalCustomerId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Customer = apply { - if (validated) { - return@apply - } - - id() - externalCustomerId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Customer]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var externalCustomerId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customer: Customer) = apply { - id = customer.id - externalCustomerId = customer.externalCustomerId - additionalProperties = customer.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun externalCustomerId(externalCustomerId: String?) = - externalCustomerId(JsonField.ofNullable(externalCustomerId)) - - fun externalCustomerId(externalCustomerId: Optional) = - externalCustomerId(externalCustomerId.orElse(null)) - - fun externalCustomerId(externalCustomerId: JsonField) = apply { - this.externalCustomerId = externalCustomerId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Customer = - Customer( - checkRequired("id", id), - checkRequired("externalCustomerId", externalCustomerId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Customer && id == other.id && externalCustomerId == other.externalCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, externalCustomerId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Customer{id=$id, externalCustomerId=$externalCustomerId, additionalProperties=$additionalProperties}" - } - - class EntryStatus @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val COMMITTED = of("committed") - - @JvmField val PENDING = of("pending") - - @JvmStatic fun of(value: String) = EntryStatus(JsonField.of(value)) - } - - /** An enum containing [EntryStatus]'s known values. */ - enum class Known { - COMMITTED, - PENDING, - } - - /** - * An enum containing [EntryStatus]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryStatus] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - COMMITTED, - PENDING, - /** - * An enum member indicating that [EntryStatus] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - COMMITTED -> Value.COMMITTED - PENDING -> Value.PENDING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - COMMITTED -> Known.COMMITTED - PENDING -> Known.PENDING - else -> throw OrbInvalidDataException("Unknown EntryStatus: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryStatus && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val EXPIRATION_CHANGE = of("expiration_change") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - EXPIRATION_CHANGE - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - EXPIRATION_CHANGE, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - EXPIRATION_CHANGE -> Value.EXPIRATION_CHANGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - EXPIRATION_CHANGE -> Known.EXPIRATION_CHANGE - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ExpirationChangeLedgerEntry && id == other.id && amount == other.amount && createdAt == other.createdAt && creditBlock == other.creditBlock && currency == other.currency && customer == other.customer && description == other.description && endingBalance == other.endingBalance && entryStatus == other.entryStatus && entryType == other.entryType && ledgerSequenceNumber == other.ledgerSequenceNumber && metadata == other.metadata && newBlockExpiryDate == other.newBlockExpiryDate && startingBalance == other.startingBalance && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, createdAt, creditBlock, currency, customer, description, endingBalance, entryStatus, entryType, ledgerSequenceNumber, metadata, newBlockExpiryDate, startingBalance, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ExpirationChangeLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, newBlockExpiryDate=$newBlockExpiryDate, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class CreditBlockExpiryLedgerEntry - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("credit_block") - @ExcludeMissing - private val creditBlock: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("customer") - @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("ending_balance") - @ExcludeMissing - private val endingBalance: JsonField = JsonMissing.of(), - @JsonProperty("entry_status") - @ExcludeMissing - private val entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - private val entryType: JsonField = JsonMissing.of(), - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - private val ledgerSequenceNumber: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("starting_balance") - @ExcludeMissing - private val startingBalance: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun amount(): Double = amount.getRequired("amount") - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - fun creditBlock(): CreditBlock = creditBlock.getRequired("credit_block") - - fun currency(): String = currency.getRequired("currency") - - fun customer(): Customer = customer.getRequired("customer") - - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - fun endingBalance(): Double = endingBalance.getRequired("ending_balance") - - fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") - - fun entryType(): EntryType = entryType.getRequired("entry_type") - - fun ledgerSequenceNumber(): Long = - ledgerSequenceNumber.getRequired("ledger_sequence_number") - - /** - * 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.getRequired("metadata") - - fun startingBalance(): Double = startingBalance.getRequired("starting_balance") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - @JsonProperty("credit_block") - @ExcludeMissing - fun _creditBlock(): JsonField = creditBlock - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - @JsonProperty("ending_balance") - @ExcludeMissing - fun _endingBalance(): JsonField = endingBalance - - @JsonProperty("entry_status") - @ExcludeMissing - fun _entryStatus(): JsonField = entryStatus - - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber - - /** - * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - @JsonProperty("starting_balance") - @ExcludeMissing - fun _startingBalance(): JsonField = startingBalance - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditBlockExpiryLedgerEntry = apply { - if (validated) { - return@apply - } - - id() - amount() - createdAt() - creditBlock().validate() - currency() - customer().validate() - description() - endingBalance() - entryStatus() - entryType() - ledgerSequenceNumber() - metadata().validate() - startingBalance() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditBlockExpiryLedgerEntry]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var amount: JsonField? = null - private var createdAt: JsonField? = null - private var creditBlock: JsonField? = null - private var currency: JsonField? = null - private var customer: JsonField? = null - private var description: JsonField? = null - private var endingBalance: JsonField? = null - private var entryStatus: JsonField? = null - private var entryType: JsonField? = null - private var ledgerSequenceNumber: JsonField? = null - private var metadata: JsonField? = null - private var startingBalance: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry) = apply { - id = creditBlockExpiryLedgerEntry.id - amount = creditBlockExpiryLedgerEntry.amount - createdAt = creditBlockExpiryLedgerEntry.createdAt - creditBlock = creditBlockExpiryLedgerEntry.creditBlock - currency = creditBlockExpiryLedgerEntry.currency - customer = creditBlockExpiryLedgerEntry.customer - description = creditBlockExpiryLedgerEntry.description - endingBalance = creditBlockExpiryLedgerEntry.endingBalance - entryStatus = creditBlockExpiryLedgerEntry.entryStatus - entryType = creditBlockExpiryLedgerEntry.entryType - ledgerSequenceNumber = creditBlockExpiryLedgerEntry.ledgerSequenceNumber - metadata = creditBlockExpiryLedgerEntry.metadata - startingBalance = creditBlockExpiryLedgerEntry.startingBalance - additionalProperties = - creditBlockExpiryLedgerEntry.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun amount(amount: Double) = amount(JsonField.of(amount)) - - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { - this.createdAt = createdAt - } - - fun creditBlock(creditBlock: CreditBlock) = creditBlock(JsonField.of(creditBlock)) - - fun creditBlock(creditBlock: JsonField) = apply { - this.creditBlock = creditBlock - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun customer(customer: Customer) = customer(JsonField.of(customer)) - - fun customer(customer: JsonField) = apply { this.customer = customer } - - fun description(description: String?) = description(JsonField.ofNullable(description)) - - fun description(description: Optional) = description(description.orElse(null)) - - fun description(description: JsonField) = apply { - this.description = description - } - - fun endingBalance(endingBalance: Double) = endingBalance(JsonField.of(endingBalance)) - - fun endingBalance(endingBalance: JsonField) = apply { - this.endingBalance = endingBalance - } - - fun entryStatus(entryStatus: EntryStatus) = entryStatus(JsonField.of(entryStatus)) - - fun entryStatus(entryStatus: JsonField) = apply { - this.entryStatus = entryStatus - } - - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } - - fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = - ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) - - fun ledgerSequenceNumber(ledgerSequenceNumber: JsonField) = apply { - this.ledgerSequenceNumber = ledgerSequenceNumber - } - - /** - * 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - fun startingBalance(startingBalance: Double) = - startingBalance(JsonField.of(startingBalance)) - - fun startingBalance(startingBalance: JsonField) = apply { - this.startingBalance = startingBalance - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditBlockExpiryLedgerEntry = - CreditBlockExpiryLedgerEntry( - checkRequired("id", id), - checkRequired("amount", amount), - checkRequired("createdAt", createdAt), - checkRequired("creditBlock", creditBlock), - checkRequired("currency", currency), - checkRequired("customer", customer), - checkRequired("description", description), - checkRequired("endingBalance", endingBalance), - checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), - checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), - checkRequired("metadata", metadata), - checkRequired("startingBalance", startingBalance), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class CreditBlock - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("expiry_date") - @ExcludeMissing - private val expiryDate: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - private val perUnitCostBasis: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun expiryDate(): Optional = - Optional.ofNullable(expiryDate.getNullable("expiry_date")) - - fun perUnitCostBasis(): Optional = - Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("expiry_date") - @ExcludeMissing - fun _expiryDate(): JsonField = expiryDate - - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - fun _perUnitCostBasis(): JsonField = perUnitCostBasis - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditBlock = apply { - if (validated) { - return@apply - } - - id() - expiryDate() - perUnitCostBasis() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditBlock]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var expiryDate: JsonField? = null - private var perUnitCostBasis: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditBlock: CreditBlock) = apply { - id = creditBlock.id - expiryDate = creditBlock.expiryDate - perUnitCostBasis = creditBlock.perUnitCostBasis - additionalProperties = creditBlock.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun expiryDate(expiryDate: OffsetDateTime?) = - expiryDate(JsonField.ofNullable(expiryDate)) - - fun expiryDate(expiryDate: Optional) = - expiryDate(expiryDate.orElse(null)) - - fun expiryDate(expiryDate: JsonField) = apply { - this.expiryDate = expiryDate - } - - fun perUnitCostBasis(perUnitCostBasis: String?) = - perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) - - fun perUnitCostBasis(perUnitCostBasis: Optional) = - perUnitCostBasis(perUnitCostBasis.orElse(null)) - - fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { - this.perUnitCostBasis = perUnitCostBasis - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditBlock = - CreditBlock( - checkRequired("id", id), - checkRequired("expiryDate", expiryDate), - checkRequired("perUnitCostBasis", perUnitCostBasis), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditBlock && id == other.id && expiryDate == other.expiryDate && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, expiryDate, perUnitCostBasis, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditBlock{id=$id, expiryDate=$expiryDate, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Customer - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("external_customer_id") - @ExcludeMissing - private val externalCustomerId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun externalCustomerId(): Optional = - Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("external_customer_id") - @ExcludeMissing - fun _externalCustomerId(): JsonField = externalCustomerId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Customer = apply { - if (validated) { - return@apply - } - - id() - externalCustomerId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Customer]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var externalCustomerId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customer: Customer) = apply { - id = customer.id - externalCustomerId = customer.externalCustomerId - additionalProperties = customer.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun externalCustomerId(externalCustomerId: String?) = - externalCustomerId(JsonField.ofNullable(externalCustomerId)) - - fun externalCustomerId(externalCustomerId: Optional) = - externalCustomerId(externalCustomerId.orElse(null)) - - fun externalCustomerId(externalCustomerId: JsonField) = apply { - this.externalCustomerId = externalCustomerId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Customer = - Customer( - checkRequired("id", id), - checkRequired("externalCustomerId", externalCustomerId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Customer && id == other.id && externalCustomerId == other.externalCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, externalCustomerId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Customer{id=$id, externalCustomerId=$externalCustomerId, additionalProperties=$additionalProperties}" - } - - class EntryStatus @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val COMMITTED = of("committed") - - @JvmField val PENDING = of("pending") - - @JvmStatic fun of(value: String) = EntryStatus(JsonField.of(value)) - } - - /** An enum containing [EntryStatus]'s known values. */ - enum class Known { - COMMITTED, - PENDING, - } - - /** - * An enum containing [EntryStatus]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryStatus] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - COMMITTED, - PENDING, - /** - * An enum member indicating that [EntryStatus] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - COMMITTED -> Value.COMMITTED - PENDING -> Value.PENDING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - COMMITTED -> Known.COMMITTED - PENDING -> Known.PENDING - else -> throw OrbInvalidDataException("Unknown EntryStatus: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryStatus && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val CREDIT_BLOCK_EXPIRY = of("credit_block_expiry") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - CREDIT_BLOCK_EXPIRY - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - CREDIT_BLOCK_EXPIRY, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - CREDIT_BLOCK_EXPIRY -> Value.CREDIT_BLOCK_EXPIRY - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - CREDIT_BLOCK_EXPIRY -> Known.CREDIT_BLOCK_EXPIRY - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditBlockExpiryLedgerEntry && id == other.id && amount == other.amount && createdAt == other.createdAt && creditBlock == other.creditBlock && currency == other.currency && customer == other.customer && description == other.description && endingBalance == other.endingBalance && entryStatus == other.entryStatus && entryType == other.entryType && ledgerSequenceNumber == other.ledgerSequenceNumber && metadata == other.metadata && startingBalance == other.startingBalance && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, createdAt, creditBlock, currency, customer, description, endingBalance, entryStatus, entryType, ledgerSequenceNumber, metadata, startingBalance, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditBlockExpiryLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class VoidLedgerEntry - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("credit_block") - @ExcludeMissing - private val creditBlock: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("customer") - @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("ending_balance") - @ExcludeMissing - private val endingBalance: JsonField = JsonMissing.of(), - @JsonProperty("entry_status") - @ExcludeMissing - private val entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - private val entryType: JsonField = JsonMissing.of(), - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - private val ledgerSequenceNumber: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("starting_balance") - @ExcludeMissing - private val startingBalance: JsonField = JsonMissing.of(), - @JsonProperty("void_amount") - @ExcludeMissing - private val voidAmount: JsonField = JsonMissing.of(), - @JsonProperty("void_reason") - @ExcludeMissing - private val voidReason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun amount(): Double = amount.getRequired("amount") - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - fun creditBlock(): CreditBlock = creditBlock.getRequired("credit_block") - - fun currency(): String = currency.getRequired("currency") - - fun customer(): Customer = customer.getRequired("customer") - - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - fun endingBalance(): Double = endingBalance.getRequired("ending_balance") - - fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") - - fun entryType(): EntryType = entryType.getRequired("entry_type") - - fun ledgerSequenceNumber(): Long = - ledgerSequenceNumber.getRequired("ledger_sequence_number") - - /** - * 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.getRequired("metadata") - - fun startingBalance(): Double = startingBalance.getRequired("starting_balance") - - fun voidAmount(): Double = voidAmount.getRequired("void_amount") - - fun voidReason(): Optional = - Optional.ofNullable(voidReason.getNullable("void_reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - @JsonProperty("credit_block") - @ExcludeMissing - fun _creditBlock(): JsonField = creditBlock - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - @JsonProperty("ending_balance") - @ExcludeMissing - fun _endingBalance(): JsonField = endingBalance - - @JsonProperty("entry_status") - @ExcludeMissing - fun _entryStatus(): JsonField = entryStatus - - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber - - /** - * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - @JsonProperty("starting_balance") - @ExcludeMissing - fun _startingBalance(): JsonField = startingBalance - - @JsonProperty("void_amount") - @ExcludeMissing - fun _voidAmount(): JsonField = voidAmount - - @JsonProperty("void_reason") - @ExcludeMissing - fun _voidReason(): JsonField = voidReason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): VoidLedgerEntry = apply { - if (validated) { - return@apply - } - - id() - amount() - createdAt() - creditBlock().validate() - currency() - customer().validate() - description() - endingBalance() - entryStatus() - entryType() - ledgerSequenceNumber() - metadata().validate() - startingBalance() - voidAmount() - voidReason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [VoidLedgerEntry]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var amount: JsonField? = null - private var createdAt: JsonField? = null - private var creditBlock: JsonField? = null - private var currency: JsonField? = null - private var customer: JsonField? = null - private var description: JsonField? = null - private var endingBalance: JsonField? = null - private var entryStatus: JsonField? = null - private var entryType: JsonField? = null - private var ledgerSequenceNumber: JsonField? = null - private var metadata: JsonField? = null - private var startingBalance: JsonField? = null - private var voidAmount: JsonField? = null - private var voidReason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(voidLedgerEntry: VoidLedgerEntry) = apply { - id = voidLedgerEntry.id - amount = voidLedgerEntry.amount - createdAt = voidLedgerEntry.createdAt - creditBlock = voidLedgerEntry.creditBlock - currency = voidLedgerEntry.currency - customer = voidLedgerEntry.customer - description = voidLedgerEntry.description - endingBalance = voidLedgerEntry.endingBalance - entryStatus = voidLedgerEntry.entryStatus - entryType = voidLedgerEntry.entryType - ledgerSequenceNumber = voidLedgerEntry.ledgerSequenceNumber - metadata = voidLedgerEntry.metadata - startingBalance = voidLedgerEntry.startingBalance - voidAmount = voidLedgerEntry.voidAmount - voidReason = voidLedgerEntry.voidReason - additionalProperties = voidLedgerEntry.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun amount(amount: Double) = amount(JsonField.of(amount)) - - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { - this.createdAt = createdAt - } - - fun creditBlock(creditBlock: CreditBlock) = creditBlock(JsonField.of(creditBlock)) - - fun creditBlock(creditBlock: JsonField) = apply { - this.creditBlock = creditBlock - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun customer(customer: Customer) = customer(JsonField.of(customer)) - - fun customer(customer: JsonField) = apply { this.customer = customer } - - fun description(description: String?) = description(JsonField.ofNullable(description)) - - fun description(description: Optional) = description(description.orElse(null)) - - fun description(description: JsonField) = apply { - this.description = description - } - - fun endingBalance(endingBalance: Double) = endingBalance(JsonField.of(endingBalance)) - - fun endingBalance(endingBalance: JsonField) = apply { - this.endingBalance = endingBalance - } - - fun entryStatus(entryStatus: EntryStatus) = entryStatus(JsonField.of(entryStatus)) - - fun entryStatus(entryStatus: JsonField) = apply { - this.entryStatus = entryStatus - } - - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } - - fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = - ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) - - fun ledgerSequenceNumber(ledgerSequenceNumber: JsonField) = apply { - this.ledgerSequenceNumber = ledgerSequenceNumber - } - - /** - * 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - fun startingBalance(startingBalance: Double) = - startingBalance(JsonField.of(startingBalance)) - - fun startingBalance(startingBalance: JsonField) = apply { - this.startingBalance = startingBalance - } - - fun voidAmount(voidAmount: Double) = voidAmount(JsonField.of(voidAmount)) - - fun voidAmount(voidAmount: JsonField) = apply { this.voidAmount = voidAmount } - - fun voidReason(voidReason: String?) = voidReason(JsonField.ofNullable(voidReason)) - - fun voidReason(voidReason: Optional) = voidReason(voidReason.orElse(null)) - - fun voidReason(voidReason: JsonField) = apply { this.voidReason = voidReason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): VoidLedgerEntry = - VoidLedgerEntry( - checkRequired("id", id), - checkRequired("amount", amount), - checkRequired("createdAt", createdAt), - checkRequired("creditBlock", creditBlock), - checkRequired("currency", currency), - checkRequired("customer", customer), - checkRequired("description", description), - checkRequired("endingBalance", endingBalance), - checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), - checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), - checkRequired("metadata", metadata), - checkRequired("startingBalance", startingBalance), - checkRequired("voidAmount", voidAmount), - checkRequired("voidReason", voidReason), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class CreditBlock - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("expiry_date") - @ExcludeMissing - private val expiryDate: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - private val perUnitCostBasis: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun expiryDate(): Optional = - Optional.ofNullable(expiryDate.getNullable("expiry_date")) - - fun perUnitCostBasis(): Optional = - Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("expiry_date") - @ExcludeMissing - fun _expiryDate(): JsonField = expiryDate - - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - fun _perUnitCostBasis(): JsonField = perUnitCostBasis - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditBlock = apply { - if (validated) { - return@apply - } - - id() - expiryDate() - perUnitCostBasis() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditBlock]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var expiryDate: JsonField? = null - private var perUnitCostBasis: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditBlock: CreditBlock) = apply { - id = creditBlock.id - expiryDate = creditBlock.expiryDate - perUnitCostBasis = creditBlock.perUnitCostBasis - additionalProperties = creditBlock.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun expiryDate(expiryDate: OffsetDateTime?) = - expiryDate(JsonField.ofNullable(expiryDate)) - - fun expiryDate(expiryDate: Optional) = - expiryDate(expiryDate.orElse(null)) - - fun expiryDate(expiryDate: JsonField) = apply { - this.expiryDate = expiryDate - } - - fun perUnitCostBasis(perUnitCostBasis: String?) = - perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) - - fun perUnitCostBasis(perUnitCostBasis: Optional) = - perUnitCostBasis(perUnitCostBasis.orElse(null)) - - fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { - this.perUnitCostBasis = perUnitCostBasis - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditBlock = - CreditBlock( - checkRequired("id", id), - checkRequired("expiryDate", expiryDate), - checkRequired("perUnitCostBasis", perUnitCostBasis), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditBlock && id == other.id && expiryDate == other.expiryDate && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, expiryDate, perUnitCostBasis, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditBlock{id=$id, expiryDate=$expiryDate, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Customer - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("external_customer_id") - @ExcludeMissing - private val externalCustomerId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun externalCustomerId(): Optional = - Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("external_customer_id") - @ExcludeMissing - fun _externalCustomerId(): JsonField = externalCustomerId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Customer = apply { - if (validated) { - return@apply - } - - id() - externalCustomerId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Customer]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var externalCustomerId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customer: Customer) = apply { - id = customer.id - externalCustomerId = customer.externalCustomerId - additionalProperties = customer.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun externalCustomerId(externalCustomerId: String?) = - externalCustomerId(JsonField.ofNullable(externalCustomerId)) - - fun externalCustomerId(externalCustomerId: Optional) = - externalCustomerId(externalCustomerId.orElse(null)) - - fun externalCustomerId(externalCustomerId: JsonField) = apply { - this.externalCustomerId = externalCustomerId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Customer = - Customer( - checkRequired("id", id), - checkRequired("externalCustomerId", externalCustomerId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Customer && id == other.id && externalCustomerId == other.externalCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, externalCustomerId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Customer{id=$id, externalCustomerId=$externalCustomerId, additionalProperties=$additionalProperties}" - } - - class EntryStatus @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val COMMITTED = of("committed") - - @JvmField val PENDING = of("pending") - - @JvmStatic fun of(value: String) = EntryStatus(JsonField.of(value)) - } - - /** An enum containing [EntryStatus]'s known values. */ - enum class Known { - COMMITTED, - PENDING, - } - - /** - * An enum containing [EntryStatus]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryStatus] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - COMMITTED, - PENDING, - /** - * An enum member indicating that [EntryStatus] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - COMMITTED -> Value.COMMITTED - PENDING -> Value.PENDING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - COMMITTED -> Known.COMMITTED - PENDING -> Known.PENDING - else -> throw OrbInvalidDataException("Unknown EntryStatus: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryStatus && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val VOID = of("void") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - VOID - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - VOID, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - VOID -> Value.VOID - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - VOID -> Known.VOID - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is VoidLedgerEntry && id == other.id && amount == other.amount && createdAt == other.createdAt && creditBlock == other.creditBlock && currency == other.currency && customer == other.customer && description == other.description && endingBalance == other.endingBalance && entryStatus == other.entryStatus && entryType == other.entryType && ledgerSequenceNumber == other.ledgerSequenceNumber && metadata == other.metadata && startingBalance == other.startingBalance && voidAmount == other.voidAmount && voidReason == other.voidReason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, createdAt, creditBlock, currency, customer, description, endingBalance, entryStatus, entryType, ledgerSequenceNumber, metadata, startingBalance, voidAmount, voidReason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "VoidLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, voidAmount=$voidAmount, voidReason=$voidReason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class VoidInitiatedLedgerEntry - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("credit_block") - @ExcludeMissing - private val creditBlock: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("customer") - @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("ending_balance") - @ExcludeMissing - private val endingBalance: JsonField = JsonMissing.of(), - @JsonProperty("entry_status") - @ExcludeMissing - private val entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - private val entryType: JsonField = JsonMissing.of(), - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - private val ledgerSequenceNumber: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("new_block_expiry_date") - @ExcludeMissing - private val newBlockExpiryDate: JsonField = JsonMissing.of(), - @JsonProperty("starting_balance") - @ExcludeMissing - private val startingBalance: JsonField = JsonMissing.of(), - @JsonProperty("void_amount") - @ExcludeMissing - private val voidAmount: JsonField = JsonMissing.of(), - @JsonProperty("void_reason") - @ExcludeMissing - private val voidReason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun amount(): Double = amount.getRequired("amount") - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - fun creditBlock(): CreditBlock = creditBlock.getRequired("credit_block") - - fun currency(): String = currency.getRequired("currency") - - fun customer(): Customer = customer.getRequired("customer") - - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - fun endingBalance(): Double = endingBalance.getRequired("ending_balance") - - fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") - - fun entryType(): EntryType = entryType.getRequired("entry_type") - - fun ledgerSequenceNumber(): Long = - ledgerSequenceNumber.getRequired("ledger_sequence_number") - - /** - * 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.getRequired("metadata") - - fun newBlockExpiryDate(): OffsetDateTime = - newBlockExpiryDate.getRequired("new_block_expiry_date") - - fun startingBalance(): Double = startingBalance.getRequired("starting_balance") - - fun voidAmount(): Double = voidAmount.getRequired("void_amount") - - fun voidReason(): Optional = - Optional.ofNullable(voidReason.getNullable("void_reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - @JsonProperty("credit_block") - @ExcludeMissing - fun _creditBlock(): JsonField = creditBlock - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - @JsonProperty("ending_balance") - @ExcludeMissing - fun _endingBalance(): JsonField = endingBalance - - @JsonProperty("entry_status") - @ExcludeMissing - fun _entryStatus(): JsonField = entryStatus - - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber - - /** - * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - @JsonProperty("new_block_expiry_date") - @ExcludeMissing - fun _newBlockExpiryDate(): JsonField = newBlockExpiryDate - - @JsonProperty("starting_balance") - @ExcludeMissing - fun _startingBalance(): JsonField = startingBalance - - @JsonProperty("void_amount") - @ExcludeMissing - fun _voidAmount(): JsonField = voidAmount - - @JsonProperty("void_reason") - @ExcludeMissing - fun _voidReason(): JsonField = voidReason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): VoidInitiatedLedgerEntry = apply { - if (validated) { - return@apply - } - - id() - amount() - createdAt() - creditBlock().validate() - currency() - customer().validate() - description() - endingBalance() - entryStatus() - entryType() - ledgerSequenceNumber() - metadata().validate() - newBlockExpiryDate() - startingBalance() - voidAmount() - voidReason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [VoidInitiatedLedgerEntry]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var amount: JsonField? = null - private var createdAt: JsonField? = null - private var creditBlock: JsonField? = null - private var currency: JsonField? = null - private var customer: JsonField? = null - private var description: JsonField? = null - private var endingBalance: JsonField? = null - private var entryStatus: JsonField? = null - private var entryType: JsonField? = null - private var ledgerSequenceNumber: JsonField? = null - private var metadata: JsonField? = null - private var newBlockExpiryDate: JsonField? = null - private var startingBalance: JsonField? = null - private var voidAmount: JsonField? = null - private var voidReason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry) = apply { - id = voidInitiatedLedgerEntry.id - amount = voidInitiatedLedgerEntry.amount - createdAt = voidInitiatedLedgerEntry.createdAt - creditBlock = voidInitiatedLedgerEntry.creditBlock - currency = voidInitiatedLedgerEntry.currency - customer = voidInitiatedLedgerEntry.customer - description = voidInitiatedLedgerEntry.description - endingBalance = voidInitiatedLedgerEntry.endingBalance - entryStatus = voidInitiatedLedgerEntry.entryStatus - entryType = voidInitiatedLedgerEntry.entryType - ledgerSequenceNumber = voidInitiatedLedgerEntry.ledgerSequenceNumber - metadata = voidInitiatedLedgerEntry.metadata - newBlockExpiryDate = voidInitiatedLedgerEntry.newBlockExpiryDate - startingBalance = voidInitiatedLedgerEntry.startingBalance - voidAmount = voidInitiatedLedgerEntry.voidAmount - voidReason = voidInitiatedLedgerEntry.voidReason - additionalProperties = voidInitiatedLedgerEntry.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun amount(amount: Double) = amount(JsonField.of(amount)) - - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { - this.createdAt = createdAt - } - - fun creditBlock(creditBlock: CreditBlock) = creditBlock(JsonField.of(creditBlock)) - - fun creditBlock(creditBlock: JsonField) = apply { - this.creditBlock = creditBlock - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun customer(customer: Customer) = customer(JsonField.of(customer)) - - fun customer(customer: JsonField) = apply { this.customer = customer } - - fun description(description: String?) = description(JsonField.ofNullable(description)) - - fun description(description: Optional) = description(description.orElse(null)) - - fun description(description: JsonField) = apply { - this.description = description - } - - fun endingBalance(endingBalance: Double) = endingBalance(JsonField.of(endingBalance)) - - fun endingBalance(endingBalance: JsonField) = apply { - this.endingBalance = endingBalance - } - - fun entryStatus(entryStatus: EntryStatus) = entryStatus(JsonField.of(entryStatus)) - - fun entryStatus(entryStatus: JsonField) = apply { - this.entryStatus = entryStatus - } - - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } - - fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = - ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) - - fun ledgerSequenceNumber(ledgerSequenceNumber: JsonField) = apply { - this.ledgerSequenceNumber = ledgerSequenceNumber - } - - /** - * 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - fun newBlockExpiryDate(newBlockExpiryDate: OffsetDateTime) = - newBlockExpiryDate(JsonField.of(newBlockExpiryDate)) - - fun newBlockExpiryDate(newBlockExpiryDate: JsonField) = apply { - this.newBlockExpiryDate = newBlockExpiryDate - } - - fun startingBalance(startingBalance: Double) = - startingBalance(JsonField.of(startingBalance)) - - fun startingBalance(startingBalance: JsonField) = apply { - this.startingBalance = startingBalance - } - - fun voidAmount(voidAmount: Double) = voidAmount(JsonField.of(voidAmount)) - - fun voidAmount(voidAmount: JsonField) = apply { this.voidAmount = voidAmount } - - fun voidReason(voidReason: String?) = voidReason(JsonField.ofNullable(voidReason)) - - fun voidReason(voidReason: Optional) = voidReason(voidReason.orElse(null)) - - fun voidReason(voidReason: JsonField) = apply { this.voidReason = voidReason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): VoidInitiatedLedgerEntry = - VoidInitiatedLedgerEntry( - checkRequired("id", id), - checkRequired("amount", amount), - checkRequired("createdAt", createdAt), - checkRequired("creditBlock", creditBlock), - checkRequired("currency", currency), - checkRequired("customer", customer), - checkRequired("description", description), - checkRequired("endingBalance", endingBalance), - checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), - checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), - checkRequired("metadata", metadata), - checkRequired("newBlockExpiryDate", newBlockExpiryDate), - checkRequired("startingBalance", startingBalance), - checkRequired("voidAmount", voidAmount), - checkRequired("voidReason", voidReason), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class CreditBlock - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("expiry_date") - @ExcludeMissing - private val expiryDate: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - private val perUnitCostBasis: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun expiryDate(): Optional = - Optional.ofNullable(expiryDate.getNullable("expiry_date")) - - fun perUnitCostBasis(): Optional = - Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("expiry_date") - @ExcludeMissing - fun _expiryDate(): JsonField = expiryDate - - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - fun _perUnitCostBasis(): JsonField = perUnitCostBasis - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditBlock = apply { - if (validated) { - return@apply - } - - id() - expiryDate() - perUnitCostBasis() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditBlock]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var expiryDate: JsonField? = null - private var perUnitCostBasis: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditBlock: CreditBlock) = apply { - id = creditBlock.id - expiryDate = creditBlock.expiryDate - perUnitCostBasis = creditBlock.perUnitCostBasis - additionalProperties = creditBlock.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun expiryDate(expiryDate: OffsetDateTime?) = - expiryDate(JsonField.ofNullable(expiryDate)) - - fun expiryDate(expiryDate: Optional) = - expiryDate(expiryDate.orElse(null)) - - fun expiryDate(expiryDate: JsonField) = apply { - this.expiryDate = expiryDate - } - - fun perUnitCostBasis(perUnitCostBasis: String?) = - perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) - - fun perUnitCostBasis(perUnitCostBasis: Optional) = - perUnitCostBasis(perUnitCostBasis.orElse(null)) - - fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { - this.perUnitCostBasis = perUnitCostBasis - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditBlock = - CreditBlock( - checkRequired("id", id), - checkRequired("expiryDate", expiryDate), - checkRequired("perUnitCostBasis", perUnitCostBasis), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditBlock && id == other.id && expiryDate == other.expiryDate && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, expiryDate, perUnitCostBasis, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditBlock{id=$id, expiryDate=$expiryDate, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Customer - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("external_customer_id") - @ExcludeMissing - private val externalCustomerId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun externalCustomerId(): Optional = - Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("external_customer_id") - @ExcludeMissing - fun _externalCustomerId(): JsonField = externalCustomerId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Customer = apply { - if (validated) { - return@apply - } - - id() - externalCustomerId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Customer]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var externalCustomerId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customer: Customer) = apply { - id = customer.id - externalCustomerId = customer.externalCustomerId - additionalProperties = customer.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun externalCustomerId(externalCustomerId: String?) = - externalCustomerId(JsonField.ofNullable(externalCustomerId)) - - fun externalCustomerId(externalCustomerId: Optional) = - externalCustomerId(externalCustomerId.orElse(null)) - - fun externalCustomerId(externalCustomerId: JsonField) = apply { - this.externalCustomerId = externalCustomerId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Customer = - Customer( - checkRequired("id", id), - checkRequired("externalCustomerId", externalCustomerId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Customer && id == other.id && externalCustomerId == other.externalCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, externalCustomerId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Customer{id=$id, externalCustomerId=$externalCustomerId, additionalProperties=$additionalProperties}" - } - - class EntryStatus @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val COMMITTED = of("committed") - - @JvmField val PENDING = of("pending") - - @JvmStatic fun of(value: String) = EntryStatus(JsonField.of(value)) - } - - /** An enum containing [EntryStatus]'s known values. */ - enum class Known { - COMMITTED, - PENDING, - } - - /** - * An enum containing [EntryStatus]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryStatus] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - COMMITTED, - PENDING, - /** - * An enum member indicating that [EntryStatus] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - COMMITTED -> Value.COMMITTED - PENDING -> Value.PENDING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - COMMITTED -> Known.COMMITTED - PENDING -> Known.PENDING - else -> throw OrbInvalidDataException("Unknown EntryStatus: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryStatus && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val VOID_INITIATED = of("void_initiated") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - VOID_INITIATED - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - VOID_INITIATED, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - VOID_INITIATED -> Value.VOID_INITIATED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - VOID_INITIATED -> Known.VOID_INITIATED - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is VoidInitiatedLedgerEntry && id == other.id && amount == other.amount && createdAt == other.createdAt && creditBlock == other.creditBlock && currency == other.currency && customer == other.customer && description == other.description && endingBalance == other.endingBalance && entryStatus == other.entryStatus && entryType == other.entryType && ledgerSequenceNumber == other.ledgerSequenceNumber && metadata == other.metadata && newBlockExpiryDate == other.newBlockExpiryDate && startingBalance == other.startingBalance && voidAmount == other.voidAmount && voidReason == other.voidReason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, createdAt, creditBlock, currency, customer, description, endingBalance, entryStatus, entryType, ledgerSequenceNumber, metadata, newBlockExpiryDate, startingBalance, voidAmount, voidReason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "VoidInitiatedLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, newBlockExpiryDate=$newBlockExpiryDate, startingBalance=$startingBalance, voidAmount=$voidAmount, voidReason=$voidReason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class AmendmentLedgerEntry - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("credit_block") - @ExcludeMissing - private val creditBlock: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("customer") - @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("ending_balance") - @ExcludeMissing - private val endingBalance: JsonField = JsonMissing.of(), - @JsonProperty("entry_status") - @ExcludeMissing - private val entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - private val entryType: JsonField = JsonMissing.of(), - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - private val ledgerSequenceNumber: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("starting_balance") - @ExcludeMissing - private val startingBalance: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun amount(): Double = amount.getRequired("amount") - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - fun creditBlock(): CreditBlock = creditBlock.getRequired("credit_block") - - fun currency(): String = currency.getRequired("currency") - - fun customer(): Customer = customer.getRequired("customer") - - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - fun endingBalance(): Double = endingBalance.getRequired("ending_balance") - - fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") - - fun entryType(): EntryType = entryType.getRequired("entry_type") - - fun ledgerSequenceNumber(): Long = - ledgerSequenceNumber.getRequired("ledger_sequence_number") - - /** - * 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.getRequired("metadata") - - fun startingBalance(): Double = startingBalance.getRequired("starting_balance") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - @JsonProperty("credit_block") - @ExcludeMissing - fun _creditBlock(): JsonField = creditBlock - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - @JsonProperty("ending_balance") - @ExcludeMissing - fun _endingBalance(): JsonField = endingBalance - - @JsonProperty("entry_status") - @ExcludeMissing - fun _entryStatus(): JsonField = entryStatus - - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - - @JsonProperty("ledger_sequence_number") - @ExcludeMissing - fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber - - /** - * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - @JsonProperty("starting_balance") - @ExcludeMissing - fun _startingBalance(): JsonField = startingBalance - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AmendmentLedgerEntry = apply { - if (validated) { - return@apply - } - - id() - amount() - createdAt() - creditBlock().validate() - currency() - customer().validate() - description() - endingBalance() - entryStatus() - entryType() - ledgerSequenceNumber() - metadata().validate() - startingBalance() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AmendmentLedgerEntry]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var amount: JsonField? = null - private var createdAt: JsonField? = null - private var creditBlock: JsonField? = null - private var currency: JsonField? = null - private var customer: JsonField? = null - private var description: JsonField? = null - private var endingBalance: JsonField? = null - private var entryStatus: JsonField? = null - private var entryType: JsonField? = null - private var ledgerSequenceNumber: JsonField? = null - private var metadata: JsonField? = null - private var startingBalance: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(amendmentLedgerEntry: AmendmentLedgerEntry) = apply { - id = amendmentLedgerEntry.id - amount = amendmentLedgerEntry.amount - createdAt = amendmentLedgerEntry.createdAt - creditBlock = amendmentLedgerEntry.creditBlock - currency = amendmentLedgerEntry.currency - customer = amendmentLedgerEntry.customer - description = amendmentLedgerEntry.description - endingBalance = amendmentLedgerEntry.endingBalance - entryStatus = amendmentLedgerEntry.entryStatus - entryType = amendmentLedgerEntry.entryType - ledgerSequenceNumber = amendmentLedgerEntry.ledgerSequenceNumber - metadata = amendmentLedgerEntry.metadata - startingBalance = amendmentLedgerEntry.startingBalance - additionalProperties = amendmentLedgerEntry.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun amount(amount: Double) = amount(JsonField.of(amount)) - - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { - this.createdAt = createdAt - } - - fun creditBlock(creditBlock: CreditBlock) = creditBlock(JsonField.of(creditBlock)) - - fun creditBlock(creditBlock: JsonField) = apply { - this.creditBlock = creditBlock - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun customer(customer: Customer) = customer(JsonField.of(customer)) - - fun customer(customer: JsonField) = apply { this.customer = customer } - - fun description(description: String?) = description(JsonField.ofNullable(description)) - - fun description(description: Optional) = description(description.orElse(null)) - - fun description(description: JsonField) = apply { - this.description = description - } - - fun endingBalance(endingBalance: Double) = endingBalance(JsonField.of(endingBalance)) - - fun endingBalance(endingBalance: JsonField) = apply { - this.endingBalance = endingBalance - } - - fun entryStatus(entryStatus: EntryStatus) = entryStatus(JsonField.of(entryStatus)) - - fun entryStatus(entryStatus: JsonField) = apply { - this.entryStatus = entryStatus - } - - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } - - fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = - ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) - - fun ledgerSequenceNumber(ledgerSequenceNumber: JsonField) = apply { - this.ledgerSequenceNumber = ledgerSequenceNumber - } - - /** - * 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - fun startingBalance(startingBalance: Double) = - startingBalance(JsonField.of(startingBalance)) - - fun startingBalance(startingBalance: JsonField) = apply { - this.startingBalance = startingBalance - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): AmendmentLedgerEntry = - AmendmentLedgerEntry( - checkRequired("id", id), - checkRequired("amount", amount), - checkRequired("createdAt", createdAt), - checkRequired("creditBlock", creditBlock), - checkRequired("currency", currency), - checkRequired("customer", customer), - checkRequired("description", description), - checkRequired("endingBalance", endingBalance), - checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), - checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), - checkRequired("metadata", metadata), - checkRequired("startingBalance", startingBalance), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class CreditBlock - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("expiry_date") - @ExcludeMissing - private val expiryDate: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - private val perUnitCostBasis: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun expiryDate(): Optional = - Optional.ofNullable(expiryDate.getNullable("expiry_date")) - - fun perUnitCostBasis(): Optional = - Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("expiry_date") - @ExcludeMissing - fun _expiryDate(): JsonField = expiryDate - - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - fun _perUnitCostBasis(): JsonField = perUnitCostBasis - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditBlock = apply { - if (validated) { - return@apply - } - - id() - expiryDate() - perUnitCostBasis() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditBlock]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var expiryDate: JsonField? = null - private var perUnitCostBasis: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditBlock: CreditBlock) = apply { - id = creditBlock.id - expiryDate = creditBlock.expiryDate - perUnitCostBasis = creditBlock.perUnitCostBasis - additionalProperties = creditBlock.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun expiryDate(expiryDate: OffsetDateTime?) = - expiryDate(JsonField.ofNullable(expiryDate)) - - fun expiryDate(expiryDate: Optional) = - expiryDate(expiryDate.orElse(null)) - - fun expiryDate(expiryDate: JsonField) = apply { - this.expiryDate = expiryDate - } - - fun perUnitCostBasis(perUnitCostBasis: String?) = - perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) - - fun perUnitCostBasis(perUnitCostBasis: Optional) = - perUnitCostBasis(perUnitCostBasis.orElse(null)) - - fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { - this.perUnitCostBasis = perUnitCostBasis - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditBlock = - CreditBlock( - checkRequired("id", id), - checkRequired("expiryDate", expiryDate), - checkRequired("perUnitCostBasis", perUnitCostBasis), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditBlock && id == other.id && expiryDate == other.expiryDate && perUnitCostBasis == other.perUnitCostBasis && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, expiryDate, perUnitCostBasis, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditBlock{id=$id, expiryDate=$expiryDate, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Customer - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("external_customer_id") - @ExcludeMissing - private val externalCustomerId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun externalCustomerId(): Optional = - Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("external_customer_id") - @ExcludeMissing - fun _externalCustomerId(): JsonField = externalCustomerId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Customer = apply { - if (validated) { - return@apply - } - - id() - externalCustomerId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Customer]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var externalCustomerId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customer: Customer) = apply { - id = customer.id - externalCustomerId = customer.externalCustomerId - additionalProperties = customer.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun externalCustomerId(externalCustomerId: String?) = - externalCustomerId(JsonField.ofNullable(externalCustomerId)) - - fun externalCustomerId(externalCustomerId: Optional) = - externalCustomerId(externalCustomerId.orElse(null)) - - fun externalCustomerId(externalCustomerId: JsonField) = apply { - this.externalCustomerId = externalCustomerId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Customer = - Customer( - checkRequired("id", id), - checkRequired("externalCustomerId", externalCustomerId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Customer && id == other.id && externalCustomerId == other.externalCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, externalCustomerId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Customer{id=$id, externalCustomerId=$externalCustomerId, additionalProperties=$additionalProperties}" - } - - class EntryStatus @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val COMMITTED = of("committed") - - @JvmField val PENDING = of("pending") - - @JvmStatic fun of(value: String) = EntryStatus(JsonField.of(value)) - } - - /** An enum containing [EntryStatus]'s known values. */ - enum class Known { - COMMITTED, - PENDING, - } - - /** - * An enum containing [EntryStatus]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryStatus] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - COMMITTED, - PENDING, - /** - * An enum member indicating that [EntryStatus] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - COMMITTED -> Value.COMMITTED - PENDING -> Value.PENDING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - COMMITTED -> Known.COMMITTED - PENDING -> Known.PENDING - else -> throw OrbInvalidDataException("Unknown EntryStatus: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryStatus && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val AMENDMENT = of("amendment") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - AMENDMENT - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMENDMENT, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMENDMENT -> Value.AMENDMENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AMENDMENT -> Known.AMENDMENT - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AmendmentLedgerEntry && id == other.id && amount == other.amount && createdAt == other.createdAt && creditBlock == other.creditBlock && currency == other.currency && customer == other.customer && description == other.description && endingBalance == other.endingBalance && entryStatus == other.entryStatus && entryType == other.entryType && ledgerSequenceNumber == other.ledgerSequenceNumber && metadata == other.metadata && startingBalance == other.startingBalance && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, createdAt, creditBlock, currency, customer, description, endingBalance, entryStatus, entryType, ledgerSequenceNumber, metadata, startingBalance, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AmendmentLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" - } -} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPage.kt index c134f8174..1a0d5a939 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPage.kt @@ -105,7 +105,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -164,21 +164,20 @@ private constructor( @JsonCreator constructor( @JsonProperty("data") - private val data: JsonField> = JsonMissing.of(), + private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = - Optional.ofNullable(data) + fun _data(): Optional>> = Optional.ofNullable(data) @JsonProperty("pagination_metadata") fun _paginationMetadata(): Optional> = @@ -217,12 +216,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [CustomerCreditLedgerListPage]. + */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -233,11 +236,9 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { - this.data = data - } + fun data(data: JsonField>) = apply { this.data = data } fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) @@ -255,9 +256,9 @@ private constructor( } class AutoPager(private val firstPage: CustomerCreditLedgerListPage) : - Iterable { + Iterable { - override fun iterator(): Iterator = iterator { + override fun iterator(): Iterator = iterator { var page = firstPage var index = 0 while (true) { @@ -269,7 +270,7 @@ private constructor( } } - fun stream(): Stream { + fun stream(): Stream { return StreamSupport.stream(spliterator(), false) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageAsync.kt index 07722d0eb..d31ed850e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListPageAsync.kt @@ -106,7 +106,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -167,21 +167,20 @@ private constructor( @JsonCreator constructor( @JsonProperty("data") - private val data: JsonField> = JsonMissing.of(), + private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = - Optional.ofNullable(data) + fun _data(): Optional>> = Optional.ofNullable(data) @JsonProperty("pagination_metadata") fun _paginationMetadata(): Optional> = @@ -220,12 +219,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [CustomerCreditLedgerListPageAsync]. + */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -236,11 +239,9 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { - this.data = data - } + fun data(data: JsonField>) = apply { this.data = data } fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) @@ -260,11 +261,11 @@ private constructor( class AutoPager(private val firstPage: CustomerCreditLedgerListPageAsync) { fun forEach( - action: Predicate, + action: Predicate, executor: Executor, ): CompletableFuture { fun CompletableFuture>.forEach( - action: (CustomerCreditLedgerListResponse) -> Boolean, + action: (CreditLedgerEntryModel) -> Boolean, executor: Executor, ): CompletableFuture = thenComposeAsync( @@ -280,8 +281,8 @@ private constructor( .forEach(action::test, executor) } - fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() + fun toList(executor: Executor): CompletableFuture> { + val values = mutableListOf() return forEach(values::add, executor).thenApply { values } } } 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 876f2fa6c..fcea25555 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 @@ -191,6 +191,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [CustomerCreditLedgerListParams]. + * + * The following fields are required: + * ```java + * .customerId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPage.kt index b3bb50bce..1b7dc5a8b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPage.kt @@ -37,7 +37,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -96,22 +96,20 @@ private constructor( @JsonCreator constructor( @JsonProperty("data") - private val data: JsonField> = - JsonMissing.of(), + private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = - data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = + fun _data(): Optional>> = Optional.ofNullable(data) @JsonProperty("pagination_metadata") @@ -151,13 +149,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [CustomerCreditListByExternalIdPage]. + */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = - JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -168,9 +169,9 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { + fun data(data: JsonField>) = apply { this.data = data } @@ -190,9 +191,9 @@ private constructor( } class AutoPager(private val firstPage: CustomerCreditListByExternalIdPage) : - Iterable { + Iterable { - override fun iterator(): Iterator = iterator { + override fun iterator(): Iterator = iterator { var page = firstPage var index = 0 while (true) { @@ -204,7 +205,7 @@ private constructor( } } - fun stream(): Stream { + fun stream(): Stream { return StreamSupport.stream(spliterator(), false) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageAsync.kt index 0a35cfee0..6bda43527 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdPageAsync.kt @@ -38,7 +38,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -99,22 +99,20 @@ private constructor( @JsonCreator constructor( @JsonProperty("data") - private val data: JsonField> = - JsonMissing.of(), + private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = - data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = + fun _data(): Optional>> = Optional.ofNullable(data) @JsonProperty("pagination_metadata") @@ -154,13 +152,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [CustomerCreditListByExternalIdPageAsync]. + */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = - JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -171,9 +172,9 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { + fun data(data: JsonField>) = apply { this.data = data } @@ -195,11 +196,11 @@ private constructor( class AutoPager(private val firstPage: CustomerCreditListByExternalIdPageAsync) { fun forEach( - action: Predicate, + action: Predicate, executor: Executor, ): CompletableFuture { fun CompletableFuture>.forEach( - action: (CustomerCreditListByExternalIdResponse) -> Boolean, + action: (CustomerCreditBalancesModel.Data) -> Boolean, executor: Executor, ): CompletableFuture = thenComposeAsync( @@ -215,10 +216,8 @@ private constructor( .forEach(action::test, executor) } - fun toList( - executor: Executor - ): CompletableFuture> { - val values = mutableListOf() + fun toList(executor: Executor): CompletableFuture> { + val values = mutableListOf() return forEach(values::add, executor).thenApply { values } } } 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 6242c763b..005d44d4c 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 @@ -76,6 +76,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [CustomerCreditListByExternalIdParams]. + * + * The following fields are required: + * ```java + * .externalCustomerId() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 deleted file mode 100644 index 550b7e47e..000000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt +++ /dev/null @@ -1,343 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.withorb.api.core.Enum -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.checkRequired -import com.withorb.api.core.immutableEmptyMap -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional - -@NoAutoDetect -class CustomerCreditListByExternalIdResponse -@JsonCreator -private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("balance") - @ExcludeMissing - private val balance: JsonField = JsonMissing.of(), - @JsonProperty("effective_date") - @ExcludeMissing - private val effectiveDate: JsonField = JsonMissing.of(), - @JsonProperty("expiry_date") - @ExcludeMissing - private val expiryDate: JsonField = JsonMissing.of(), - @JsonProperty("maximum_initial_balance") - @ExcludeMissing - private val maximumInitialBalance: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - private val perUnitCostBasis: JsonField = JsonMissing.of(), - @JsonProperty("status") - @ExcludeMissing - private val status: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun id(): String = id.getRequired("id") - - fun balance(): Double = balance.getRequired("balance") - - fun effectiveDate(): Optional = - Optional.ofNullable(effectiveDate.getNullable("effective_date")) - - fun expiryDate(): Optional = - Optional.ofNullable(expiryDate.getNullable("expiry_date")) - - fun maximumInitialBalance(): Optional = - Optional.ofNullable(maximumInitialBalance.getNullable("maximum_initial_balance")) - - fun perUnitCostBasis(): Optional = - Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - - fun status(): Status = status.getRequired("status") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("balance") @ExcludeMissing fun _balance(): JsonField = balance - - @JsonProperty("effective_date") - @ExcludeMissing - fun _effectiveDate(): JsonField = effectiveDate - - @JsonProperty("expiry_date") - @ExcludeMissing - fun _expiryDate(): JsonField = expiryDate - - @JsonProperty("maximum_initial_balance") - @ExcludeMissing - fun _maximumInitialBalance(): JsonField = maximumInitialBalance - - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - fun _perUnitCostBasis(): JsonField = perUnitCostBasis - - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CustomerCreditListByExternalIdResponse = apply { - if (validated) { - return@apply - } - - id() - balance() - effectiveDate() - expiryDate() - maximumInitialBalance() - perUnitCostBasis() - status() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CustomerCreditListByExternalIdResponse]. */ - 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 maximumInitialBalance: JsonField? = null - private var perUnitCostBasis: JsonField? = null - private var status: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - customerCreditListByExternalIdResponse: CustomerCreditListByExternalIdResponse - ) = apply { - id = customerCreditListByExternalIdResponse.id - balance = customerCreditListByExternalIdResponse.balance - effectiveDate = customerCreditListByExternalIdResponse.effectiveDate - expiryDate = customerCreditListByExternalIdResponse.expiryDate - maximumInitialBalance = customerCreditListByExternalIdResponse.maximumInitialBalance - perUnitCostBasis = customerCreditListByExternalIdResponse.perUnitCostBasis - status = customerCreditListByExternalIdResponse.status - additionalProperties = - customerCreditListByExternalIdResponse.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun balance(balance: Double) = balance(JsonField.of(balance)) - - fun balance(balance: JsonField) = apply { this.balance = balance } - - fun effectiveDate(effectiveDate: OffsetDateTime?) = - effectiveDate(JsonField.ofNullable(effectiveDate)) - - fun effectiveDate(effectiveDate: Optional) = - effectiveDate(effectiveDate.orElse(null)) - - fun effectiveDate(effectiveDate: JsonField) = apply { - this.effectiveDate = effectiveDate - } - - fun expiryDate(expiryDate: OffsetDateTime?) = expiryDate(JsonField.ofNullable(expiryDate)) - - fun expiryDate(expiryDate: Optional) = expiryDate(expiryDate.orElse(null)) - - fun expiryDate(expiryDate: JsonField) = apply { - this.expiryDate = expiryDate - } - - fun maximumInitialBalance(maximumInitialBalance: Double?) = - maximumInitialBalance(JsonField.ofNullable(maximumInitialBalance)) - - fun maximumInitialBalance(maximumInitialBalance: Double) = - maximumInitialBalance(maximumInitialBalance as Double?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun maximumInitialBalance(maximumInitialBalance: Optional) = - maximumInitialBalance(maximumInitialBalance.orElse(null) as Double?) - - fun maximumInitialBalance(maximumInitialBalance: JsonField) = apply { - this.maximumInitialBalance = maximumInitialBalance - } - - fun perUnitCostBasis(perUnitCostBasis: String?) = - perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) - - fun perUnitCostBasis(perUnitCostBasis: Optional) = - perUnitCostBasis(perUnitCostBasis.orElse(null)) - - fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { - this.perUnitCostBasis = perUnitCostBasis - } - - fun status(status: Status) = status(JsonField.of(status)) - - 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) - } - - fun build(): CustomerCreditListByExternalIdResponse = - CustomerCreditListByExternalIdResponse( - checkRequired("id", id), - checkRequired("balance", balance), - checkRequired("effectiveDate", effectiveDate), - checkRequired("expiryDate", expiryDate), - checkRequired("maximumInitialBalance", maximumInitialBalance), - checkRequired("perUnitCostBasis", perUnitCostBasis), - checkRequired("status", status), - additionalProperties.toImmutable(), - ) - } - - 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CustomerCreditListByExternalIdResponse && id == other.id && balance == other.balance && effectiveDate == other.effectiveDate && expiryDate == other.expiryDate && maximumInitialBalance == other.maximumInitialBalance && perUnitCostBasis == other.perUnitCostBasis && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, balance, effectiveDate, expiryDate, maximumInitialBalance, perUnitCostBasis, status, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CustomerCreditListByExternalIdResponse{id=$id, balance=$balance, effectiveDate=$effectiveDate, expiryDate=$expiryDate, maximumInitialBalance=$maximumInitialBalance, perUnitCostBasis=$perUnitCostBasis, status=$status, additionalProperties=$additionalProperties}" -} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPage.kt index e56ae567e..1c254397d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPage.kt @@ -37,7 +37,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -96,20 +96,20 @@ private constructor( @JsonCreator constructor( @JsonProperty("data") - private val data: JsonField> = JsonMissing.of(), + private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = + fun _data(): Optional>> = Optional.ofNullable(data) @JsonProperty("pagination_metadata") @@ -149,12 +149,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [CustomerCreditListPage]. + */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -165,9 +168,11 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { + this.data = data + } fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) @@ -185,9 +190,9 @@ private constructor( } class AutoPager(private val firstPage: CustomerCreditListPage) : - Iterable { + Iterable { - override fun iterator(): Iterator = iterator { + override fun iterator(): Iterator = iterator { var page = firstPage var index = 0 while (true) { @@ -199,7 +204,7 @@ private constructor( } } - fun stream(): Stream { + fun stream(): Stream { return StreamSupport.stream(spliterator(), false) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPageAsync.kt index fe9a9f299..4f877bf10 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListPageAsync.kt @@ -38,7 +38,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -99,20 +99,20 @@ private constructor( @JsonCreator constructor( @JsonProperty("data") - private val data: JsonField> = JsonMissing.of(), + private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = + fun _data(): Optional>> = Optional.ofNullable(data) @JsonProperty("pagination_metadata") @@ -152,12 +152,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [CustomerCreditListPageAsync]. + */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -168,9 +172,11 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { + this.data = data + } fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) @@ -190,11 +196,11 @@ private constructor( class AutoPager(private val firstPage: CustomerCreditListPageAsync) { fun forEach( - action: Predicate, + action: Predicate, executor: Executor, ): CompletableFuture { fun CompletableFuture>.forEach( - action: (CustomerCreditListResponse) -> Boolean, + action: (CustomerCreditBalancesModel.Data) -> Boolean, executor: Executor, ): CompletableFuture = thenComposeAsync( @@ -210,8 +216,8 @@ private constructor( .forEach(action::test, executor) } - fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() + fun toList(executor: Executor): CompletableFuture> { + val values = mutableListOf() return forEach(values::add, executor).thenApply { values } } } 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 af7102c49..5fdcf4c62 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 @@ -76,6 +76,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [CustomerCreditListParams]. + * + * The following fields are required: + * ```java + * .customerId() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 deleted file mode 100644 index 02743c4ea..000000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt +++ /dev/null @@ -1,340 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.withorb.api.core.Enum -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.checkRequired -import com.withorb.api.core.immutableEmptyMap -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional - -@NoAutoDetect -class CustomerCreditListResponse -@JsonCreator -private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("balance") - @ExcludeMissing - private val balance: JsonField = JsonMissing.of(), - @JsonProperty("effective_date") - @ExcludeMissing - private val effectiveDate: JsonField = JsonMissing.of(), - @JsonProperty("expiry_date") - @ExcludeMissing - private val expiryDate: JsonField = JsonMissing.of(), - @JsonProperty("maximum_initial_balance") - @ExcludeMissing - private val maximumInitialBalance: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - private val perUnitCostBasis: JsonField = JsonMissing.of(), - @JsonProperty("status") - @ExcludeMissing - private val status: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun id(): String = id.getRequired("id") - - fun balance(): Double = balance.getRequired("balance") - - fun effectiveDate(): Optional = - Optional.ofNullable(effectiveDate.getNullable("effective_date")) - - fun expiryDate(): Optional = - Optional.ofNullable(expiryDate.getNullable("expiry_date")) - - fun maximumInitialBalance(): Optional = - Optional.ofNullable(maximumInitialBalance.getNullable("maximum_initial_balance")) - - fun perUnitCostBasis(): Optional = - Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - - fun status(): Status = status.getRequired("status") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("balance") @ExcludeMissing fun _balance(): JsonField = balance - - @JsonProperty("effective_date") - @ExcludeMissing - fun _effectiveDate(): JsonField = effectiveDate - - @JsonProperty("expiry_date") - @ExcludeMissing - fun _expiryDate(): JsonField = expiryDate - - @JsonProperty("maximum_initial_balance") - @ExcludeMissing - fun _maximumInitialBalance(): JsonField = maximumInitialBalance - - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - fun _perUnitCostBasis(): JsonField = perUnitCostBasis - - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CustomerCreditListResponse = apply { - if (validated) { - return@apply - } - - id() - balance() - effectiveDate() - expiryDate() - maximumInitialBalance() - perUnitCostBasis() - status() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CustomerCreditListResponse]. */ - 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 maximumInitialBalance: JsonField? = null - private var perUnitCostBasis: JsonField? = null - private var status: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customerCreditListResponse: CustomerCreditListResponse) = apply { - id = customerCreditListResponse.id - balance = customerCreditListResponse.balance - effectiveDate = customerCreditListResponse.effectiveDate - expiryDate = customerCreditListResponse.expiryDate - maximumInitialBalance = customerCreditListResponse.maximumInitialBalance - perUnitCostBasis = customerCreditListResponse.perUnitCostBasis - status = customerCreditListResponse.status - additionalProperties = customerCreditListResponse.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun balance(balance: Double) = balance(JsonField.of(balance)) - - fun balance(balance: JsonField) = apply { this.balance = balance } - - fun effectiveDate(effectiveDate: OffsetDateTime?) = - effectiveDate(JsonField.ofNullable(effectiveDate)) - - fun effectiveDate(effectiveDate: Optional) = - effectiveDate(effectiveDate.orElse(null)) - - fun effectiveDate(effectiveDate: JsonField) = apply { - this.effectiveDate = effectiveDate - } - - fun expiryDate(expiryDate: OffsetDateTime?) = expiryDate(JsonField.ofNullable(expiryDate)) - - fun expiryDate(expiryDate: Optional) = expiryDate(expiryDate.orElse(null)) - - fun expiryDate(expiryDate: JsonField) = apply { - this.expiryDate = expiryDate - } - - fun maximumInitialBalance(maximumInitialBalance: Double?) = - maximumInitialBalance(JsonField.ofNullable(maximumInitialBalance)) - - fun maximumInitialBalance(maximumInitialBalance: Double) = - maximumInitialBalance(maximumInitialBalance as Double?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun maximumInitialBalance(maximumInitialBalance: Optional) = - maximumInitialBalance(maximumInitialBalance.orElse(null) as Double?) - - fun maximumInitialBalance(maximumInitialBalance: JsonField) = apply { - this.maximumInitialBalance = maximumInitialBalance - } - - fun perUnitCostBasis(perUnitCostBasis: String?) = - perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) - - fun perUnitCostBasis(perUnitCostBasis: Optional) = - perUnitCostBasis(perUnitCostBasis.orElse(null)) - - fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { - this.perUnitCostBasis = perUnitCostBasis - } - - fun status(status: Status) = status(JsonField.of(status)) - - 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) - } - - fun build(): CustomerCreditListResponse = - CustomerCreditListResponse( - checkRequired("id", id), - checkRequired("balance", balance), - checkRequired("effectiveDate", effectiveDate), - checkRequired("expiryDate", expiryDate), - checkRequired("maximumInitialBalance", maximumInitialBalance), - checkRequired("perUnitCostBasis", perUnitCostBasis), - checkRequired("status", status), - additionalProperties.toImmutable(), - ) - } - - 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CustomerCreditListResponse && id == other.id && balance == other.balance && effectiveDate == other.effectiveDate && expiryDate == other.expiryDate && maximumInitialBalance == other.maximumInitialBalance && perUnitCostBasis == other.perUnitCostBasis && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, balance, effectiveDate, expiryDate, maximumInitialBalance, perUnitCostBasis, status, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CustomerCreditListResponse{id=$id, balance=$balance, effectiveDate=$effectiveDate, expiryDate=$expiryDate, maximumInitialBalance=$maximumInitialBalance, perUnitCostBasis=$perUnitCostBasis, status=$status, additionalProperties=$additionalProperties}" -} 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 825d1de61..ffca17156 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 @@ -2,26 +2,13 @@ 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.NoAutoDetect 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.immutableEmptyMap -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.time.OffsetDateTime import java.util.Objects -import java.util.Optional /** * This endpoint allows you to create a new top-up for a specified customer's balance. While this @@ -34,90 +21,23 @@ import java.util.Optional class CustomerCreditTopUpCreateByExternalIdParams private constructor( private val externalCustomerId: String, - private val body: Body, + private val addCreditTopUpRequest: AddCreditTopUpRequest, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { fun externalCustomerId(): String = externalCustomerId - /** The amount to increment when the threshold is reached. */ - fun amount(): String = body.amount() + fun addCreditTopUpRequest(): AddCreditTopUpRequest = addCreditTopUpRequest - /** - * The currency or custom pricing unit to use for this top-up. If this is a real-world currency, - * it must match the customer's invoicing currency. - */ - fun currency(): String = body.currency() - - /** Settings for invoices generated by triggered top-ups. */ - fun invoiceSettings(): InvoiceSettings = body.invoiceSettings() - - /** How much, in the customer's currency, to charge for each unit. */ - fun perUnitCostBasis(): String = body.perUnitCostBasis() - - /** - * The threshold at which to trigger the top-up. If the balance is at or below this threshold, - * the top-up will be triggered. - */ - fun threshold(): String = body.threshold() - - /** - * The date from which the top-up is active. If unspecified, the top-up is active immediately. - */ - fun activeFrom(): Optional = body.activeFrom() - - /** - * The number of days or months after which the top-up expires. If unspecified, it does not - * expire. - */ - fun expiresAfter(): Optional = body.expiresAfter() - - /** The unit of expires_after. */ - fun expiresAfterUnit(): Optional = body.expiresAfterUnit() - - /** The amount to increment when the threshold is reached. */ - fun _amount(): JsonField = body._amount() - - /** - * The currency or custom pricing unit to use for this top-up. If this is a real-world currency, - * it must match the customer's invoicing currency. - */ - fun _currency(): JsonField = body._currency() - - /** Settings for invoices generated by triggered top-ups. */ - fun _invoiceSettings(): JsonField = body._invoiceSettings() - - /** How much, in the customer's currency, to charge for each unit. */ - fun _perUnitCostBasis(): JsonField = body._perUnitCostBasis() - - /** - * The threshold at which to trigger the top-up. If the balance is at or below this threshold, - * the top-up will be triggered. - */ - fun _threshold(): JsonField = body._threshold() - - /** - * The date from which the top-up is active. If unspecified, the top-up is active immediately. - */ - fun _activeFrom(): JsonField = body._activeFrom() - - /** - * The number of days or months after which the top-up expires. If unspecified, it does not - * expire. - */ - fun _expiresAfter(): JsonField = body._expiresAfter() - - /** The unit of expires_after. */ - fun _expiresAfterUnit(): JsonField = body._expiresAfterUnit() - - fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalBodyProperties(): Map = + addCreditTopUpRequest._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): AddCreditTopUpRequest = addCreditTopUpRequest override fun _headers(): Headers = additionalHeaders @@ -130,344 +50,20 @@ private constructor( } } - @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("invoice_settings") - @ExcludeMissing - private val invoiceSettings: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - private val perUnitCostBasis: JsonField = JsonMissing.of(), - @JsonProperty("threshold") - @ExcludeMissing - private val threshold: JsonField = JsonMissing.of(), - @JsonProperty("active_from") - @ExcludeMissing - private val activeFrom: JsonField = JsonMissing.of(), - @JsonProperty("expires_after") - @ExcludeMissing - private val expiresAfter: JsonField = JsonMissing.of(), - @JsonProperty("expires_after_unit") - @ExcludeMissing - private val expiresAfterUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The amount to increment when the threshold is reached. */ - fun amount(): String = amount.getRequired("amount") - - /** - * The currency or custom pricing unit to use for this top-up. If this is a real-world - * currency, it must match the customer's invoicing currency. - */ - fun currency(): String = currency.getRequired("currency") - - /** Settings for invoices generated by triggered top-ups. */ - fun invoiceSettings(): InvoiceSettings = invoiceSettings.getRequired("invoice_settings") - - /** How much, in the customer's currency, to charge for each unit. */ - fun perUnitCostBasis(): String = perUnitCostBasis.getRequired("per_unit_cost_basis") - - /** - * The threshold at which to trigger the top-up. If the balance is at or below this - * threshold, the top-up will be triggered. - */ - fun threshold(): String = threshold.getRequired("threshold") - - /** - * The date from which the top-up is active. If unspecified, the top-up is active - * immediately. - */ - fun activeFrom(): Optional = - Optional.ofNullable(activeFrom.getNullable("active_from")) - - /** - * The number of days or months after which the top-up expires. If unspecified, it does not - * expire. - */ - fun expiresAfter(): Optional = - Optional.ofNullable(expiresAfter.getNullable("expires_after")) - - /** The unit of expires_after. */ - fun expiresAfterUnit(): Optional = - Optional.ofNullable(expiresAfterUnit.getNullable("expires_after_unit")) - - /** The amount to increment when the threshold is reached. */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** - * The currency or custom pricing unit to use for this top-up. If this is a real-world - * currency, it must match the customer's invoicing currency. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** Settings for invoices generated by triggered top-ups. */ - @JsonProperty("invoice_settings") - @ExcludeMissing - fun _invoiceSettings(): JsonField = invoiceSettings - - /** How much, in the customer's currency, to charge for each unit. */ - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - fun _perUnitCostBasis(): JsonField = perUnitCostBasis - - /** - * The threshold at which to trigger the top-up. If the balance is at or below this - * threshold, the top-up will be triggered. - */ - @JsonProperty("threshold") @ExcludeMissing fun _threshold(): JsonField = threshold - - /** - * The date from which the top-up is active. If unspecified, the top-up is active - * immediately. - */ - @JsonProperty("active_from") - @ExcludeMissing - fun _activeFrom(): JsonField = activeFrom - - /** - * The number of days or months after which the top-up expires. If unspecified, it does not - * expire. - */ - @JsonProperty("expires_after") - @ExcludeMissing - fun _expiresAfter(): JsonField = expiresAfter - - /** The unit of expires_after. */ - @JsonProperty("expires_after_unit") - @ExcludeMissing - fun _expiresAfterUnit(): JsonField = expiresAfterUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - amount() - currency() - invoiceSettings().validate() - perUnitCostBasis() - threshold() - activeFrom() - expiresAfter() - expiresAfterUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var amount: JsonField? = null - private var currency: JsonField? = null - private var invoiceSettings: JsonField? = null - private var perUnitCostBasis: JsonField? = null - private var threshold: JsonField? = null - private var activeFrom: JsonField = JsonMissing.of() - private var expiresAfter: JsonField = JsonMissing.of() - private var expiresAfterUnit: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - amount = body.amount - currency = body.currency - invoiceSettings = body.invoiceSettings - perUnitCostBasis = body.perUnitCostBasis - threshold = body.threshold - activeFrom = body.activeFrom - expiresAfter = body.expiresAfter - expiresAfterUnit = body.expiresAfterUnit - additionalProperties = body.additionalProperties.toMutableMap() - } - - /** The amount to increment when the threshold is reached. */ - fun amount(amount: String) = amount(JsonField.of(amount)) - - /** The amount to increment when the threshold is reached. */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** - * The currency or custom pricing unit to use for this top-up. If this is a real-world - * currency, it must match the customer's invoicing currency. - */ - fun currency(currency: String) = currency(JsonField.of(currency)) - - /** - * The currency or custom pricing unit to use for this top-up. If this is a real-world - * currency, it must match the customer's invoicing currency. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** Settings for invoices generated by triggered top-ups. */ - fun invoiceSettings(invoiceSettings: InvoiceSettings) = - invoiceSettings(JsonField.of(invoiceSettings)) - - /** Settings for invoices generated by triggered top-ups. */ - fun invoiceSettings(invoiceSettings: JsonField) = apply { - this.invoiceSettings = invoiceSettings - } - - /** How much, in the customer's currency, to charge for each unit. */ - fun perUnitCostBasis(perUnitCostBasis: String) = - perUnitCostBasis(JsonField.of(perUnitCostBasis)) - - /** How much, in the customer's currency, to charge for each unit. */ - fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { - this.perUnitCostBasis = perUnitCostBasis - } - - /** - * The threshold at which to trigger the top-up. If the balance is at or below this - * threshold, the top-up will be triggered. - */ - fun threshold(threshold: String) = threshold(JsonField.of(threshold)) - - /** - * The threshold at which to trigger the top-up. If the balance is at or below this - * threshold, the top-up will be triggered. - */ - fun threshold(threshold: JsonField) = apply { this.threshold = threshold } - - /** - * The date from which the top-up is active. If unspecified, the top-up is active - * immediately. - */ - fun activeFrom(activeFrom: OffsetDateTime?) = - activeFrom(JsonField.ofNullable(activeFrom)) - - /** - * The date from which the top-up is active. If unspecified, the top-up is active - * immediately. - */ - fun activeFrom(activeFrom: Optional) = - activeFrom(activeFrom.orElse(null)) - - /** - * The date from which the top-up is active. If unspecified, the top-up is active - * immediately. - */ - fun activeFrom(activeFrom: JsonField) = apply { - this.activeFrom = activeFrom - } - - /** - * The number of days or months after which the top-up expires. If unspecified, it does - * not expire. - */ - fun expiresAfter(expiresAfter: Long?) = expiresAfter(JsonField.ofNullable(expiresAfter)) - - /** - * The number of days or months after which the top-up expires. If unspecified, it does - * not expire. - */ - fun expiresAfter(expiresAfter: Long) = expiresAfter(expiresAfter as Long?) - - /** - * The number of days or months after which the top-up expires. If unspecified, it does - * not expire. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun expiresAfter(expiresAfter: Optional) = - expiresAfter(expiresAfter.orElse(null) as Long?) - - /** - * The number of days or months after which the top-up expires. If unspecified, it does - * not expire. - */ - fun expiresAfter(expiresAfter: JsonField) = apply { - this.expiresAfter = expiresAfter - } - - /** The unit of expires_after. */ - fun expiresAfterUnit(expiresAfterUnit: ExpiresAfterUnit?) = - expiresAfterUnit(JsonField.ofNullable(expiresAfterUnit)) - - /** The unit of expires_after. */ - fun expiresAfterUnit(expiresAfterUnit: Optional) = - expiresAfterUnit(expiresAfterUnit.orElse(null)) - - /** The unit of expires_after. */ - fun expiresAfterUnit(expiresAfterUnit: JsonField) = apply { - this.expiresAfterUnit = expiresAfterUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Body = - Body( - checkRequired("amount", amount), - checkRequired("currency", currency), - checkRequired("invoiceSettings", invoiceSettings), - checkRequired("perUnitCostBasis", perUnitCostBasis), - checkRequired("threshold", threshold), - activeFrom, - expiresAfter, - expiresAfterUnit, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Body && amount == other.amount && currency == other.currency && invoiceSettings == other.invoiceSettings && perUnitCostBasis == other.perUnitCostBasis && threshold == other.threshold && activeFrom == other.activeFrom && expiresAfter == other.expiresAfter && expiresAfterUnit == other.expiresAfterUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, currency, invoiceSettings, perUnitCostBasis, threshold, activeFrom, expiresAfter, expiresAfterUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{amount=$amount, currency=$currency, invoiceSettings=$invoiceSettings, perUnitCostBasis=$perUnitCostBasis, threshold=$threshold, activeFrom=$activeFrom, expiresAfter=$expiresAfter, expiresAfterUnit=$expiresAfterUnit, additionalProperties=$additionalProperties}" - } - fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of + * [CustomerCreditTopUpCreateByExternalIdParams]. + * + * The following fields are required: + * ```java + * .externalCustomerId() + * .addCreditTopUpRequest() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -476,7 +72,7 @@ private constructor( class Builder internal constructor() { private var externalCustomerId: String? = null - private var body: Body.Builder = Body.builder() + private var addCreditTopUpRequest: AddCreditTopUpRequest? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -485,7 +81,8 @@ private constructor( customerCreditTopUpCreateByExternalIdParams: CustomerCreditTopUpCreateByExternalIdParams ) = apply { externalCustomerId = customerCreditTopUpCreateByExternalIdParams.externalCustomerId - body = customerCreditTopUpCreateByExternalIdParams.body.toBuilder() + addCreditTopUpRequest = + customerCreditTopUpCreateByExternalIdParams.addCreditTopUpRequest additionalHeaders = customerCreditTopUpCreateByExternalIdParams.additionalHeaders.toBuilder() additionalQueryParams = @@ -496,133 +93,8 @@ private constructor( this.externalCustomerId = externalCustomerId } - /** The amount to increment when the threshold is reached. */ - fun amount(amount: String) = apply { body.amount(amount) } - - /** The amount to increment when the threshold is reached. */ - fun amount(amount: JsonField) = apply { body.amount(amount) } - - /** - * The currency or custom pricing unit to use for this top-up. If this is a real-world - * currency, it must match the customer's invoicing currency. - */ - fun currency(currency: String) = apply { body.currency(currency) } - - /** - * The currency or custom pricing unit to use for this top-up. If this is a real-world - * currency, it must match the customer's invoicing currency. - */ - fun currency(currency: JsonField) = apply { body.currency(currency) } - - /** Settings for invoices generated by triggered top-ups. */ - fun invoiceSettings(invoiceSettings: InvoiceSettings) = apply { - body.invoiceSettings(invoiceSettings) - } - - /** Settings for invoices generated by triggered top-ups. */ - fun invoiceSettings(invoiceSettings: JsonField) = apply { - body.invoiceSettings(invoiceSettings) - } - - /** How much, in the customer's currency, to charge for each unit. */ - fun perUnitCostBasis(perUnitCostBasis: String) = apply { - body.perUnitCostBasis(perUnitCostBasis) - } - - /** How much, in the customer's currency, to charge for each unit. */ - fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { - body.perUnitCostBasis(perUnitCostBasis) - } - - /** - * The threshold at which to trigger the top-up. If the balance is at or below this - * threshold, the top-up will be triggered. - */ - fun threshold(threshold: String) = apply { body.threshold(threshold) } - - /** - * The threshold at which to trigger the top-up. If the balance is at or below this - * threshold, the top-up will be triggered. - */ - fun threshold(threshold: JsonField) = apply { body.threshold(threshold) } - - /** - * The date from which the top-up is active. If unspecified, the top-up is active - * immediately. - */ - fun activeFrom(activeFrom: OffsetDateTime?) = apply { body.activeFrom(activeFrom) } - - /** - * The date from which the top-up is active. If unspecified, the top-up is active - * immediately. - */ - fun activeFrom(activeFrom: Optional) = activeFrom(activeFrom.orElse(null)) - - /** - * The date from which the top-up is active. If unspecified, the top-up is active - * immediately. - */ - fun activeFrom(activeFrom: JsonField) = apply { - body.activeFrom(activeFrom) - } - - /** - * The number of days or months after which the top-up expires. If unspecified, it does not - * expire. - */ - fun expiresAfter(expiresAfter: Long?) = apply { body.expiresAfter(expiresAfter) } - - /** - * The number of days or months after which the top-up expires. If unspecified, it does not - * expire. - */ - fun expiresAfter(expiresAfter: Long) = expiresAfter(expiresAfter as Long?) - - /** - * The number of days or months after which the top-up expires. If unspecified, it does not - * expire. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun expiresAfter(expiresAfter: Optional) = - expiresAfter(expiresAfter.orElse(null) as Long?) - - /** - * The number of days or months after which the top-up expires. If unspecified, it does not - * expire. - */ - fun expiresAfter(expiresAfter: JsonField) = apply { body.expiresAfter(expiresAfter) } - - /** The unit of expires_after. */ - fun expiresAfterUnit(expiresAfterUnit: ExpiresAfterUnit?) = apply { - body.expiresAfterUnit(expiresAfterUnit) - } - - /** The unit of expires_after. */ - fun expiresAfterUnit(expiresAfterUnit: Optional) = - expiresAfterUnit(expiresAfterUnit.orElse(null)) - - /** The unit of expires_after. */ - fun expiresAfterUnit(expiresAfterUnit: JsonField) = apply { - body.expiresAfterUnit(expiresAfterUnit) - } - - 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 addCreditTopUpRequest(addCreditTopUpRequest: AddCreditTopUpRequest) = apply { + this.addCreditTopUpRequest = addCreditTopUpRequest } fun additionalHeaders(additionalHeaders: Headers) = apply { @@ -726,333 +198,22 @@ private constructor( fun build(): CustomerCreditTopUpCreateByExternalIdParams = CustomerCreditTopUpCreateByExternalIdParams( checkRequired("externalCustomerId", externalCustomerId), - body.build(), + checkRequired("addCreditTopUpRequest", addCreditTopUpRequest), additionalHeaders.build(), additionalQueryParams.build(), ) } - /** Settings for invoices generated by triggered top-ups. */ - @NoAutoDetect - class InvoiceSettings - @JsonCreator - private constructor( - @JsonProperty("auto_collection") - @ExcludeMissing - private val autoCollection: JsonField = JsonMissing.of(), - @JsonProperty("net_terms") - @ExcludeMissing - private val netTerms: JsonField = JsonMissing.of(), - @JsonProperty("memo") - @ExcludeMissing - private val memo: JsonField = JsonMissing.of(), - @JsonProperty("require_successful_payment") - @ExcludeMissing - private val requireSuccessfulPayment: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * Whether the credits purchase invoice should auto collect with the customer's saved - * payment method. - */ - fun autoCollection(): Boolean = autoCollection.getRequired("auto_collection") - - /** - * The net terms determines the difference between the invoice date and the issue date for - * the invoice. If you intend the invoice to be due on issue, set this to 0. - */ - fun netTerms(): Long = netTerms.getRequired("net_terms") - - /** An optional memo to display on the invoice. */ - fun memo(): Optional = Optional.ofNullable(memo.getNullable("memo")) - - /** - * If true, new credit blocks created by this top-up will require that the corresponding - * invoice is paid before they can be drawn down from. - */ - fun requireSuccessfulPayment(): Optional = - Optional.ofNullable(requireSuccessfulPayment.getNullable("require_successful_payment")) - - /** - * Whether the credits purchase invoice should auto collect with the customer's saved - * payment method. - */ - @JsonProperty("auto_collection") - @ExcludeMissing - fun _autoCollection(): JsonField = autoCollection - - /** - * The net terms determines the difference between the invoice date and the issue date for - * the invoice. If you intend the invoice to be due on issue, set this to 0. - */ - @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms - - /** An optional memo to display on the invoice. */ - @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo - - /** - * If true, new credit blocks created by this top-up will require that the corresponding - * invoice is paid before they can be drawn down from. - */ - @JsonProperty("require_successful_payment") - @ExcludeMissing - fun _requireSuccessfulPayment(): JsonField = requireSuccessfulPayment - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoiceSettings = apply { - if (validated) { - return@apply - } - - autoCollection() - netTerms() - memo() - requireSuccessfulPayment() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoiceSettings]. */ - class Builder internal constructor() { - - private var autoCollection: JsonField? = null - private var netTerms: JsonField? = null - private var memo: JsonField = JsonMissing.of() - private var requireSuccessfulPayment: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoiceSettings: InvoiceSettings) = apply { - autoCollection = invoiceSettings.autoCollection - netTerms = invoiceSettings.netTerms - memo = invoiceSettings.memo - requireSuccessfulPayment = invoiceSettings.requireSuccessfulPayment - additionalProperties = invoiceSettings.additionalProperties.toMutableMap() - } - - /** - * Whether the credits purchase invoice should auto collect with the customer's saved - * payment method. - */ - fun autoCollection(autoCollection: Boolean) = - autoCollection(JsonField.of(autoCollection)) - - /** - * Whether the credits purchase invoice should auto collect with the customer's saved - * payment method. - */ - fun autoCollection(autoCollection: JsonField) = apply { - this.autoCollection = autoCollection - } - - /** - * The net terms determines the difference between the invoice date and the issue date - * for the invoice. If you intend the invoice to be due on issue, set this to 0. - */ - fun netTerms(netTerms: Long) = netTerms(JsonField.of(netTerms)) - - /** - * The net terms determines the difference between the invoice date and the issue date - * for the invoice. If you intend the invoice to be due on issue, set this to 0. - */ - fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } - - /** An optional memo to display on the invoice. */ - fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) - - /** An optional memo to display on the invoice. */ - fun memo(memo: Optional) = memo(memo.orElse(null)) - - /** An optional memo to display on the invoice. */ - fun memo(memo: JsonField) = apply { this.memo = memo } - - /** - * If true, new credit blocks created by this top-up will require that the corresponding - * invoice is paid before they can be drawn down from. - */ - fun requireSuccessfulPayment(requireSuccessfulPayment: Boolean) = - requireSuccessfulPayment(JsonField.of(requireSuccessfulPayment)) - - /** - * If true, new credit blocks created by this top-up will require that the corresponding - * invoice is paid before they can be drawn down from. - */ - fun requireSuccessfulPayment(requireSuccessfulPayment: JsonField) = apply { - this.requireSuccessfulPayment = requireSuccessfulPayment - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoiceSettings = - InvoiceSettings( - checkRequired("autoCollection", autoCollection), - checkRequired("netTerms", netTerms), - memo, - requireSuccessfulPayment, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoiceSettings && autoCollection == other.autoCollection && netTerms == other.netTerms && memo == other.memo && requireSuccessfulPayment == other.requireSuccessfulPayment && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(autoCollection, netTerms, memo, requireSuccessfulPayment, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoiceSettings{autoCollection=$autoCollection, netTerms=$netTerms, memo=$memo, requireSuccessfulPayment=$requireSuccessfulPayment, additionalProperties=$additionalProperties}" - } - - /** The unit of expires_after. */ - class ExpiresAfterUnit @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = ExpiresAfterUnit(JsonField.of(value)) - } - - /** An enum containing [ExpiresAfterUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [ExpiresAfterUnit]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ExpiresAfterUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [ExpiresAfterUnit] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown ExpiresAfterUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is ExpiresAfterUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is CustomerCreditTopUpCreateByExternalIdParams && externalCustomerId == other.externalCustomerId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is CustomerCreditTopUpCreateByExternalIdParams && externalCustomerId == other.externalCustomerId && addCreditTopUpRequest == other.addCreditTopUpRequest && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(externalCustomerId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(externalCustomerId, addCreditTopUpRequest, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "CustomerCreditTopUpCreateByExternalIdParams{externalCustomerId=$externalCustomerId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "CustomerCreditTopUpCreateByExternalIdParams{externalCustomerId=$externalCustomerId, addCreditTopUpRequest=$addCreditTopUpRequest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } 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 5b5a1ee69..8e06aa6a1 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 @@ -2,26 +2,13 @@ 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.NoAutoDetect 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.immutableEmptyMap -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.time.OffsetDateTime import java.util.Objects -import java.util.Optional /** * This endpoint allows you to create a new top-up for a specified customer's balance. While this @@ -34,90 +21,23 @@ import java.util.Optional class CustomerCreditTopUpCreateParams private constructor( private val customerId: String, - private val body: Body, + private val addCreditTopUpRequest: AddCreditTopUpRequest, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { fun customerId(): String = customerId - /** The amount to increment when the threshold is reached. */ - fun amount(): String = body.amount() + fun addCreditTopUpRequest(): AddCreditTopUpRequest = addCreditTopUpRequest - /** - * The currency or custom pricing unit to use for this top-up. If this is a real-world currency, - * it must match the customer's invoicing currency. - */ - fun currency(): String = body.currency() - - /** Settings for invoices generated by triggered top-ups. */ - fun invoiceSettings(): InvoiceSettings = body.invoiceSettings() - - /** How much, in the customer's currency, to charge for each unit. */ - fun perUnitCostBasis(): String = body.perUnitCostBasis() - - /** - * The threshold at which to trigger the top-up. If the balance is at or below this threshold, - * the top-up will be triggered. - */ - fun threshold(): String = body.threshold() - - /** - * The date from which the top-up is active. If unspecified, the top-up is active immediately. - */ - fun activeFrom(): Optional = body.activeFrom() - - /** - * The number of days or months after which the top-up expires. If unspecified, it does not - * expire. - */ - fun expiresAfter(): Optional = body.expiresAfter() - - /** The unit of expires_after. */ - fun expiresAfterUnit(): Optional = body.expiresAfterUnit() - - /** The amount to increment when the threshold is reached. */ - fun _amount(): JsonField = body._amount() - - /** - * The currency or custom pricing unit to use for this top-up. If this is a real-world currency, - * it must match the customer's invoicing currency. - */ - fun _currency(): JsonField = body._currency() - - /** Settings for invoices generated by triggered top-ups. */ - fun _invoiceSettings(): JsonField = body._invoiceSettings() - - /** How much, in the customer's currency, to charge for each unit. */ - fun _perUnitCostBasis(): JsonField = body._perUnitCostBasis() - - /** - * The threshold at which to trigger the top-up. If the balance is at or below this threshold, - * the top-up will be triggered. - */ - fun _threshold(): JsonField = body._threshold() - - /** - * The date from which the top-up is active. If unspecified, the top-up is active immediately. - */ - fun _activeFrom(): JsonField = body._activeFrom() - - /** - * The number of days or months after which the top-up expires. If unspecified, it does not - * expire. - */ - fun _expiresAfter(): JsonField = body._expiresAfter() - - /** The unit of expires_after. */ - fun _expiresAfterUnit(): JsonField = body._expiresAfterUnit() - - fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalBodyProperties(): Map = + addCreditTopUpRequest._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): AddCreditTopUpRequest = addCreditTopUpRequest override fun _headers(): Headers = additionalHeaders @@ -130,344 +50,20 @@ private constructor( } } - @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("invoice_settings") - @ExcludeMissing - private val invoiceSettings: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - private val perUnitCostBasis: JsonField = JsonMissing.of(), - @JsonProperty("threshold") - @ExcludeMissing - private val threshold: JsonField = JsonMissing.of(), - @JsonProperty("active_from") - @ExcludeMissing - private val activeFrom: JsonField = JsonMissing.of(), - @JsonProperty("expires_after") - @ExcludeMissing - private val expiresAfter: JsonField = JsonMissing.of(), - @JsonProperty("expires_after_unit") - @ExcludeMissing - private val expiresAfterUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The amount to increment when the threshold is reached. */ - fun amount(): String = amount.getRequired("amount") - - /** - * The currency or custom pricing unit to use for this top-up. If this is a real-world - * currency, it must match the customer's invoicing currency. - */ - fun currency(): String = currency.getRequired("currency") - - /** Settings for invoices generated by triggered top-ups. */ - fun invoiceSettings(): InvoiceSettings = invoiceSettings.getRequired("invoice_settings") - - /** How much, in the customer's currency, to charge for each unit. */ - fun perUnitCostBasis(): String = perUnitCostBasis.getRequired("per_unit_cost_basis") - - /** - * The threshold at which to trigger the top-up. If the balance is at or below this - * threshold, the top-up will be triggered. - */ - fun threshold(): String = threshold.getRequired("threshold") - - /** - * The date from which the top-up is active. If unspecified, the top-up is active - * immediately. - */ - fun activeFrom(): Optional = - Optional.ofNullable(activeFrom.getNullable("active_from")) - - /** - * The number of days or months after which the top-up expires. If unspecified, it does not - * expire. - */ - fun expiresAfter(): Optional = - Optional.ofNullable(expiresAfter.getNullable("expires_after")) - - /** The unit of expires_after. */ - fun expiresAfterUnit(): Optional = - Optional.ofNullable(expiresAfterUnit.getNullable("expires_after_unit")) - - /** The amount to increment when the threshold is reached. */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** - * The currency or custom pricing unit to use for this top-up. If this is a real-world - * currency, it must match the customer's invoicing currency. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** Settings for invoices generated by triggered top-ups. */ - @JsonProperty("invoice_settings") - @ExcludeMissing - fun _invoiceSettings(): JsonField = invoiceSettings - - /** How much, in the customer's currency, to charge for each unit. */ - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - fun _perUnitCostBasis(): JsonField = perUnitCostBasis - - /** - * The threshold at which to trigger the top-up. If the balance is at or below this - * threshold, the top-up will be triggered. - */ - @JsonProperty("threshold") @ExcludeMissing fun _threshold(): JsonField = threshold - - /** - * The date from which the top-up is active. If unspecified, the top-up is active - * immediately. - */ - @JsonProperty("active_from") - @ExcludeMissing - fun _activeFrom(): JsonField = activeFrom - - /** - * The number of days or months after which the top-up expires. If unspecified, it does not - * expire. - */ - @JsonProperty("expires_after") - @ExcludeMissing - fun _expiresAfter(): JsonField = expiresAfter - - /** The unit of expires_after. */ - @JsonProperty("expires_after_unit") - @ExcludeMissing - fun _expiresAfterUnit(): JsonField = expiresAfterUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - amount() - currency() - invoiceSettings().validate() - perUnitCostBasis() - threshold() - activeFrom() - expiresAfter() - expiresAfterUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var amount: JsonField? = null - private var currency: JsonField? = null - private var invoiceSettings: JsonField? = null - private var perUnitCostBasis: JsonField? = null - private var threshold: JsonField? = null - private var activeFrom: JsonField = JsonMissing.of() - private var expiresAfter: JsonField = JsonMissing.of() - private var expiresAfterUnit: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - amount = body.amount - currency = body.currency - invoiceSettings = body.invoiceSettings - perUnitCostBasis = body.perUnitCostBasis - threshold = body.threshold - activeFrom = body.activeFrom - expiresAfter = body.expiresAfter - expiresAfterUnit = body.expiresAfterUnit - additionalProperties = body.additionalProperties.toMutableMap() - } - - /** The amount to increment when the threshold is reached. */ - fun amount(amount: String) = amount(JsonField.of(amount)) - - /** The amount to increment when the threshold is reached. */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** - * The currency or custom pricing unit to use for this top-up. If this is a real-world - * currency, it must match the customer's invoicing currency. - */ - fun currency(currency: String) = currency(JsonField.of(currency)) - - /** - * The currency or custom pricing unit to use for this top-up. If this is a real-world - * currency, it must match the customer's invoicing currency. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** Settings for invoices generated by triggered top-ups. */ - fun invoiceSettings(invoiceSettings: InvoiceSettings) = - invoiceSettings(JsonField.of(invoiceSettings)) - - /** Settings for invoices generated by triggered top-ups. */ - fun invoiceSettings(invoiceSettings: JsonField) = apply { - this.invoiceSettings = invoiceSettings - } - - /** How much, in the customer's currency, to charge for each unit. */ - fun perUnitCostBasis(perUnitCostBasis: String) = - perUnitCostBasis(JsonField.of(perUnitCostBasis)) - - /** How much, in the customer's currency, to charge for each unit. */ - fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { - this.perUnitCostBasis = perUnitCostBasis - } - - /** - * The threshold at which to trigger the top-up. If the balance is at or below this - * threshold, the top-up will be triggered. - */ - fun threshold(threshold: String) = threshold(JsonField.of(threshold)) - - /** - * The threshold at which to trigger the top-up. If the balance is at or below this - * threshold, the top-up will be triggered. - */ - fun threshold(threshold: JsonField) = apply { this.threshold = threshold } - - /** - * The date from which the top-up is active. If unspecified, the top-up is active - * immediately. - */ - fun activeFrom(activeFrom: OffsetDateTime?) = - activeFrom(JsonField.ofNullable(activeFrom)) - - /** - * The date from which the top-up is active. If unspecified, the top-up is active - * immediately. - */ - fun activeFrom(activeFrom: Optional) = - activeFrom(activeFrom.orElse(null)) - - /** - * The date from which the top-up is active. If unspecified, the top-up is active - * immediately. - */ - fun activeFrom(activeFrom: JsonField) = apply { - this.activeFrom = activeFrom - } - - /** - * The number of days or months after which the top-up expires. If unspecified, it does - * not expire. - */ - fun expiresAfter(expiresAfter: Long?) = expiresAfter(JsonField.ofNullable(expiresAfter)) - - /** - * The number of days or months after which the top-up expires. If unspecified, it does - * not expire. - */ - fun expiresAfter(expiresAfter: Long) = expiresAfter(expiresAfter as Long?) - - /** - * The number of days or months after which the top-up expires. If unspecified, it does - * not expire. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun expiresAfter(expiresAfter: Optional) = - expiresAfter(expiresAfter.orElse(null) as Long?) - - /** - * The number of days or months after which the top-up expires. If unspecified, it does - * not expire. - */ - fun expiresAfter(expiresAfter: JsonField) = apply { - this.expiresAfter = expiresAfter - } - - /** The unit of expires_after. */ - fun expiresAfterUnit(expiresAfterUnit: ExpiresAfterUnit?) = - expiresAfterUnit(JsonField.ofNullable(expiresAfterUnit)) - - /** The unit of expires_after. */ - fun expiresAfterUnit(expiresAfterUnit: Optional) = - expiresAfterUnit(expiresAfterUnit.orElse(null)) - - /** The unit of expires_after. */ - fun expiresAfterUnit(expiresAfterUnit: JsonField) = apply { - this.expiresAfterUnit = expiresAfterUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Body = - Body( - checkRequired("amount", amount), - checkRequired("currency", currency), - checkRequired("invoiceSettings", invoiceSettings), - checkRequired("perUnitCostBasis", perUnitCostBasis), - checkRequired("threshold", threshold), - activeFrom, - expiresAfter, - expiresAfterUnit, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Body && amount == other.amount && currency == other.currency && invoiceSettings == other.invoiceSettings && perUnitCostBasis == other.perUnitCostBasis && threshold == other.threshold && activeFrom == other.activeFrom && expiresAfter == other.expiresAfter && expiresAfterUnit == other.expiresAfterUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, currency, invoiceSettings, perUnitCostBasis, threshold, activeFrom, expiresAfter, expiresAfterUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{amount=$amount, currency=$currency, invoiceSettings=$invoiceSettings, perUnitCostBasis=$perUnitCostBasis, threshold=$threshold, activeFrom=$activeFrom, expiresAfter=$expiresAfter, expiresAfterUnit=$expiresAfterUnit, additionalProperties=$additionalProperties}" - } - fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of + * [CustomerCreditTopUpCreateParams]. + * + * The following fields are required: + * ```java + * .customerId() + * .addCreditTopUpRequest() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -476,7 +72,7 @@ private constructor( class Builder internal constructor() { private var customerId: String? = null - private var body: Body.Builder = Body.builder() + private var addCreditTopUpRequest: AddCreditTopUpRequest? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -484,7 +80,7 @@ private constructor( internal fun from(customerCreditTopUpCreateParams: CustomerCreditTopUpCreateParams) = apply { customerId = customerCreditTopUpCreateParams.customerId - body = customerCreditTopUpCreateParams.body.toBuilder() + addCreditTopUpRequest = customerCreditTopUpCreateParams.addCreditTopUpRequest additionalHeaders = customerCreditTopUpCreateParams.additionalHeaders.toBuilder() additionalQueryParams = customerCreditTopUpCreateParams.additionalQueryParams.toBuilder() @@ -492,133 +88,8 @@ private constructor( fun customerId(customerId: String) = apply { this.customerId = customerId } - /** The amount to increment when the threshold is reached. */ - fun amount(amount: String) = apply { body.amount(amount) } - - /** The amount to increment when the threshold is reached. */ - fun amount(amount: JsonField) = apply { body.amount(amount) } - - /** - * The currency or custom pricing unit to use for this top-up. If this is a real-world - * currency, it must match the customer's invoicing currency. - */ - fun currency(currency: String) = apply { body.currency(currency) } - - /** - * The currency or custom pricing unit to use for this top-up. If this is a real-world - * currency, it must match the customer's invoicing currency. - */ - fun currency(currency: JsonField) = apply { body.currency(currency) } - - /** Settings for invoices generated by triggered top-ups. */ - fun invoiceSettings(invoiceSettings: InvoiceSettings) = apply { - body.invoiceSettings(invoiceSettings) - } - - /** Settings for invoices generated by triggered top-ups. */ - fun invoiceSettings(invoiceSettings: JsonField) = apply { - body.invoiceSettings(invoiceSettings) - } - - /** How much, in the customer's currency, to charge for each unit. */ - fun perUnitCostBasis(perUnitCostBasis: String) = apply { - body.perUnitCostBasis(perUnitCostBasis) - } - - /** How much, in the customer's currency, to charge for each unit. */ - fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { - body.perUnitCostBasis(perUnitCostBasis) - } - - /** - * The threshold at which to trigger the top-up. If the balance is at or below this - * threshold, the top-up will be triggered. - */ - fun threshold(threshold: String) = apply { body.threshold(threshold) } - - /** - * The threshold at which to trigger the top-up. If the balance is at or below this - * threshold, the top-up will be triggered. - */ - fun threshold(threshold: JsonField) = apply { body.threshold(threshold) } - - /** - * The date from which the top-up is active. If unspecified, the top-up is active - * immediately. - */ - fun activeFrom(activeFrom: OffsetDateTime?) = apply { body.activeFrom(activeFrom) } - - /** - * The date from which the top-up is active. If unspecified, the top-up is active - * immediately. - */ - fun activeFrom(activeFrom: Optional) = activeFrom(activeFrom.orElse(null)) - - /** - * The date from which the top-up is active. If unspecified, the top-up is active - * immediately. - */ - fun activeFrom(activeFrom: JsonField) = apply { - body.activeFrom(activeFrom) - } - - /** - * The number of days or months after which the top-up expires. If unspecified, it does not - * expire. - */ - fun expiresAfter(expiresAfter: Long?) = apply { body.expiresAfter(expiresAfter) } - - /** - * The number of days or months after which the top-up expires. If unspecified, it does not - * expire. - */ - fun expiresAfter(expiresAfter: Long) = expiresAfter(expiresAfter as Long?) - - /** - * The number of days or months after which the top-up expires. If unspecified, it does not - * expire. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun expiresAfter(expiresAfter: Optional) = - expiresAfter(expiresAfter.orElse(null) as Long?) - - /** - * The number of days or months after which the top-up expires. If unspecified, it does not - * expire. - */ - fun expiresAfter(expiresAfter: JsonField) = apply { body.expiresAfter(expiresAfter) } - - /** The unit of expires_after. */ - fun expiresAfterUnit(expiresAfterUnit: ExpiresAfterUnit?) = apply { - body.expiresAfterUnit(expiresAfterUnit) - } - - /** The unit of expires_after. */ - fun expiresAfterUnit(expiresAfterUnit: Optional) = - expiresAfterUnit(expiresAfterUnit.orElse(null)) - - /** The unit of expires_after. */ - fun expiresAfterUnit(expiresAfterUnit: JsonField) = apply { - body.expiresAfterUnit(expiresAfterUnit) - } - - 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 addCreditTopUpRequest(addCreditTopUpRequest: AddCreditTopUpRequest) = apply { + this.addCreditTopUpRequest = addCreditTopUpRequest } fun additionalHeaders(additionalHeaders: Headers) = apply { @@ -722,333 +193,22 @@ private constructor( fun build(): CustomerCreditTopUpCreateParams = CustomerCreditTopUpCreateParams( checkRequired("customerId", customerId), - body.build(), + checkRequired("addCreditTopUpRequest", addCreditTopUpRequest), additionalHeaders.build(), additionalQueryParams.build(), ) } - /** Settings for invoices generated by triggered top-ups. */ - @NoAutoDetect - class InvoiceSettings - @JsonCreator - private constructor( - @JsonProperty("auto_collection") - @ExcludeMissing - private val autoCollection: JsonField = JsonMissing.of(), - @JsonProperty("net_terms") - @ExcludeMissing - private val netTerms: JsonField = JsonMissing.of(), - @JsonProperty("memo") - @ExcludeMissing - private val memo: JsonField = JsonMissing.of(), - @JsonProperty("require_successful_payment") - @ExcludeMissing - private val requireSuccessfulPayment: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * Whether the credits purchase invoice should auto collect with the customer's saved - * payment method. - */ - fun autoCollection(): Boolean = autoCollection.getRequired("auto_collection") - - /** - * The net terms determines the difference between the invoice date and the issue date for - * the invoice. If you intend the invoice to be due on issue, set this to 0. - */ - fun netTerms(): Long = netTerms.getRequired("net_terms") - - /** An optional memo to display on the invoice. */ - fun memo(): Optional = Optional.ofNullable(memo.getNullable("memo")) - - /** - * If true, new credit blocks created by this top-up will require that the corresponding - * invoice is paid before they can be drawn down from. - */ - fun requireSuccessfulPayment(): Optional = - Optional.ofNullable(requireSuccessfulPayment.getNullable("require_successful_payment")) - - /** - * Whether the credits purchase invoice should auto collect with the customer's saved - * payment method. - */ - @JsonProperty("auto_collection") - @ExcludeMissing - fun _autoCollection(): JsonField = autoCollection - - /** - * The net terms determines the difference between the invoice date and the issue date for - * the invoice. If you intend the invoice to be due on issue, set this to 0. - */ - @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms - - /** An optional memo to display on the invoice. */ - @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo - - /** - * If true, new credit blocks created by this top-up will require that the corresponding - * invoice is paid before they can be drawn down from. - */ - @JsonProperty("require_successful_payment") - @ExcludeMissing - fun _requireSuccessfulPayment(): JsonField = requireSuccessfulPayment - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoiceSettings = apply { - if (validated) { - return@apply - } - - autoCollection() - netTerms() - memo() - requireSuccessfulPayment() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoiceSettings]. */ - class Builder internal constructor() { - - private var autoCollection: JsonField? = null - private var netTerms: JsonField? = null - private var memo: JsonField = JsonMissing.of() - private var requireSuccessfulPayment: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoiceSettings: InvoiceSettings) = apply { - autoCollection = invoiceSettings.autoCollection - netTerms = invoiceSettings.netTerms - memo = invoiceSettings.memo - requireSuccessfulPayment = invoiceSettings.requireSuccessfulPayment - additionalProperties = invoiceSettings.additionalProperties.toMutableMap() - } - - /** - * Whether the credits purchase invoice should auto collect with the customer's saved - * payment method. - */ - fun autoCollection(autoCollection: Boolean) = - autoCollection(JsonField.of(autoCollection)) - - /** - * Whether the credits purchase invoice should auto collect with the customer's saved - * payment method. - */ - fun autoCollection(autoCollection: JsonField) = apply { - this.autoCollection = autoCollection - } - - /** - * The net terms determines the difference between the invoice date and the issue date - * for the invoice. If you intend the invoice to be due on issue, set this to 0. - */ - fun netTerms(netTerms: Long) = netTerms(JsonField.of(netTerms)) - - /** - * The net terms determines the difference between the invoice date and the issue date - * for the invoice. If you intend the invoice to be due on issue, set this to 0. - */ - fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } - - /** An optional memo to display on the invoice. */ - fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) - - /** An optional memo to display on the invoice. */ - fun memo(memo: Optional) = memo(memo.orElse(null)) - - /** An optional memo to display on the invoice. */ - fun memo(memo: JsonField) = apply { this.memo = memo } - - /** - * If true, new credit blocks created by this top-up will require that the corresponding - * invoice is paid before they can be drawn down from. - */ - fun requireSuccessfulPayment(requireSuccessfulPayment: Boolean) = - requireSuccessfulPayment(JsonField.of(requireSuccessfulPayment)) - - /** - * If true, new credit blocks created by this top-up will require that the corresponding - * invoice is paid before they can be drawn down from. - */ - fun requireSuccessfulPayment(requireSuccessfulPayment: JsonField) = apply { - this.requireSuccessfulPayment = requireSuccessfulPayment - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoiceSettings = - InvoiceSettings( - checkRequired("autoCollection", autoCollection), - checkRequired("netTerms", netTerms), - memo, - requireSuccessfulPayment, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoiceSettings && autoCollection == other.autoCollection && netTerms == other.netTerms && memo == other.memo && requireSuccessfulPayment == other.requireSuccessfulPayment && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(autoCollection, netTerms, memo, requireSuccessfulPayment, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoiceSettings{autoCollection=$autoCollection, netTerms=$netTerms, memo=$memo, requireSuccessfulPayment=$requireSuccessfulPayment, additionalProperties=$additionalProperties}" - } - - /** The unit of expires_after. */ - class ExpiresAfterUnit @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = ExpiresAfterUnit(JsonField.of(value)) - } - - /** An enum containing [ExpiresAfterUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [ExpiresAfterUnit]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ExpiresAfterUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [ExpiresAfterUnit] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown ExpiresAfterUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is ExpiresAfterUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is CustomerCreditTopUpCreateParams && customerId == other.customerId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is CustomerCreditTopUpCreateParams && customerId == other.customerId && addCreditTopUpRequest == other.addCreditTopUpRequest && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(customerId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(customerId, addCreditTopUpRequest, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "CustomerCreditTopUpCreateParams{customerId=$customerId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "CustomerCreditTopUpCreateParams{customerId=$customerId, addCreditTopUpRequest=$addCreditTopUpRequest, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateResponse.kt deleted file mode 100644 index 7f0d8c52d..000000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateResponse.kt +++ /dev/null @@ -1,633 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.withorb.api.core.Enum -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.checkRequired -import com.withorb.api.core.immutableEmptyMap -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.util.Objects -import java.util.Optional - -@NoAutoDetect -class CustomerCreditTopUpCreateResponse -@JsonCreator -private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("invoice_settings") - @ExcludeMissing - private val invoiceSettings: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - private val perUnitCostBasis: JsonField = JsonMissing.of(), - @JsonProperty("threshold") - @ExcludeMissing - private val threshold: JsonField = JsonMissing.of(), - @JsonProperty("expires_after") - @ExcludeMissing - private val expiresAfter: JsonField = JsonMissing.of(), - @JsonProperty("expires_after_unit") - @ExcludeMissing - private val expiresAfterUnit: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun id(): String = id.getRequired("id") - - /** The amount to increment when the threshold is reached. */ - fun amount(): String = amount.getRequired("amount") - - /** - * The currency or custom pricing unit to use for this top-up. If this is a real-world currency, - * it must match the customer's invoicing currency. - */ - fun currency(): String = currency.getRequired("currency") - - /** Settings for invoices generated by triggered top-ups. */ - fun invoiceSettings(): InvoiceSettings = invoiceSettings.getRequired("invoice_settings") - - /** How much, in the customer's currency, to charge for each unit. */ - fun perUnitCostBasis(): String = perUnitCostBasis.getRequired("per_unit_cost_basis") - - /** - * The threshold at which to trigger the top-up. If the balance is at or below this threshold, - * the top-up will be triggered. - */ - fun threshold(): String = threshold.getRequired("threshold") - - /** - * The number of days or months after which the top-up expires. If unspecified, it does not - * expire. - */ - fun expiresAfter(): Optional = - Optional.ofNullable(expiresAfter.getNullable("expires_after")) - - /** The unit of expires_after. */ - fun expiresAfterUnit(): Optional = - Optional.ofNullable(expiresAfterUnit.getNullable("expires_after_unit")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** The amount to increment when the threshold is reached. */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** - * The currency or custom pricing unit to use for this top-up. If this is a real-world currency, - * it must match the customer's invoicing currency. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** Settings for invoices generated by triggered top-ups. */ - @JsonProperty("invoice_settings") - @ExcludeMissing - fun _invoiceSettings(): JsonField = invoiceSettings - - /** How much, in the customer's currency, to charge for each unit. */ - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - fun _perUnitCostBasis(): JsonField = perUnitCostBasis - - /** - * The threshold at which to trigger the top-up. If the balance is at or below this threshold, - * the top-up will be triggered. - */ - @JsonProperty("threshold") @ExcludeMissing fun _threshold(): JsonField = threshold - - /** - * The number of days or months after which the top-up expires. If unspecified, it does not - * expire. - */ - @JsonProperty("expires_after") - @ExcludeMissing - fun _expiresAfter(): JsonField = expiresAfter - - /** The unit of expires_after. */ - @JsonProperty("expires_after_unit") - @ExcludeMissing - fun _expiresAfterUnit(): JsonField = expiresAfterUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CustomerCreditTopUpCreateResponse = apply { - if (validated) { - return@apply - } - - id() - amount() - currency() - invoiceSettings().validate() - perUnitCostBasis() - threshold() - expiresAfter() - expiresAfterUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CustomerCreditTopUpCreateResponse]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var amount: JsonField? = null - private var currency: JsonField? = null - private var invoiceSettings: JsonField? = null - private var perUnitCostBasis: JsonField? = null - private var threshold: JsonField? = null - private var expiresAfter: JsonField = JsonMissing.of() - private var expiresAfterUnit: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customerCreditTopUpCreateResponse: CustomerCreditTopUpCreateResponse) = - apply { - id = customerCreditTopUpCreateResponse.id - amount = customerCreditTopUpCreateResponse.amount - currency = customerCreditTopUpCreateResponse.currency - invoiceSettings = customerCreditTopUpCreateResponse.invoiceSettings - perUnitCostBasis = customerCreditTopUpCreateResponse.perUnitCostBasis - threshold = customerCreditTopUpCreateResponse.threshold - expiresAfter = customerCreditTopUpCreateResponse.expiresAfter - expiresAfterUnit = customerCreditTopUpCreateResponse.expiresAfterUnit - additionalProperties = - customerCreditTopUpCreateResponse.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - /** The amount to increment when the threshold is reached. */ - fun amount(amount: String) = amount(JsonField.of(amount)) - - /** The amount to increment when the threshold is reached. */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** - * The currency or custom pricing unit to use for this top-up. If this is a real-world - * currency, it must match the customer's invoicing currency. - */ - fun currency(currency: String) = currency(JsonField.of(currency)) - - /** - * The currency or custom pricing unit to use for this top-up. If this is a real-world - * currency, it must match the customer's invoicing currency. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** Settings for invoices generated by triggered top-ups. */ - fun invoiceSettings(invoiceSettings: InvoiceSettings) = - invoiceSettings(JsonField.of(invoiceSettings)) - - /** Settings for invoices generated by triggered top-ups. */ - fun invoiceSettings(invoiceSettings: JsonField) = apply { - this.invoiceSettings = invoiceSettings - } - - /** How much, in the customer's currency, to charge for each unit. */ - fun perUnitCostBasis(perUnitCostBasis: String) = - perUnitCostBasis(JsonField.of(perUnitCostBasis)) - - /** How much, in the customer's currency, to charge for each unit. */ - fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { - this.perUnitCostBasis = perUnitCostBasis - } - - /** - * The threshold at which to trigger the top-up. If the balance is at or below this - * threshold, the top-up will be triggered. - */ - fun threshold(threshold: String) = threshold(JsonField.of(threshold)) - - /** - * The threshold at which to trigger the top-up. If the balance is at or below this - * threshold, the top-up will be triggered. - */ - fun threshold(threshold: JsonField) = apply { this.threshold = threshold } - - /** - * The number of days or months after which the top-up expires. If unspecified, it does not - * expire. - */ - fun expiresAfter(expiresAfter: Long?) = expiresAfter(JsonField.ofNullable(expiresAfter)) - - /** - * The number of days or months after which the top-up expires. If unspecified, it does not - * expire. - */ - fun expiresAfter(expiresAfter: Long) = expiresAfter(expiresAfter as Long?) - - /** - * The number of days or months after which the top-up expires. If unspecified, it does not - * expire. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun expiresAfter(expiresAfter: Optional) = - expiresAfter(expiresAfter.orElse(null) as Long?) - - /** - * The number of days or months after which the top-up expires. If unspecified, it does not - * expire. - */ - fun expiresAfter(expiresAfter: JsonField) = apply { this.expiresAfter = expiresAfter } - - /** The unit of expires_after. */ - fun expiresAfterUnit(expiresAfterUnit: ExpiresAfterUnit?) = - expiresAfterUnit(JsonField.ofNullable(expiresAfterUnit)) - - /** The unit of expires_after. */ - fun expiresAfterUnit(expiresAfterUnit: Optional) = - expiresAfterUnit(expiresAfterUnit.orElse(null)) - - /** The unit of expires_after. */ - fun expiresAfterUnit(expiresAfterUnit: JsonField) = apply { - this.expiresAfterUnit = expiresAfterUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CustomerCreditTopUpCreateResponse = - CustomerCreditTopUpCreateResponse( - checkRequired("id", id), - checkRequired("amount", amount), - checkRequired("currency", currency), - checkRequired("invoiceSettings", invoiceSettings), - checkRequired("perUnitCostBasis", perUnitCostBasis), - checkRequired("threshold", threshold), - expiresAfter, - expiresAfterUnit, - additionalProperties.toImmutable(), - ) - } - - /** Settings for invoices generated by triggered top-ups. */ - @NoAutoDetect - class InvoiceSettings - @JsonCreator - private constructor( - @JsonProperty("auto_collection") - @ExcludeMissing - private val autoCollection: JsonField = JsonMissing.of(), - @JsonProperty("net_terms") - @ExcludeMissing - private val netTerms: JsonField = JsonMissing.of(), - @JsonProperty("memo") - @ExcludeMissing - private val memo: JsonField = JsonMissing.of(), - @JsonProperty("require_successful_payment") - @ExcludeMissing - private val requireSuccessfulPayment: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * Whether the credits purchase invoice should auto collect with the customer's saved - * payment method. - */ - fun autoCollection(): Boolean = autoCollection.getRequired("auto_collection") - - /** - * The net terms determines the difference between the invoice date and the issue date for - * the invoice. If you intend the invoice to be due on issue, set this to 0. - */ - fun netTerms(): Long = netTerms.getRequired("net_terms") - - /** An optional memo to display on the invoice. */ - fun memo(): Optional = Optional.ofNullable(memo.getNullable("memo")) - - /** - * If true, new credit blocks created by this top-up will require that the corresponding - * invoice is paid before they can be drawn down from. - */ - fun requireSuccessfulPayment(): Optional = - Optional.ofNullable(requireSuccessfulPayment.getNullable("require_successful_payment")) - - /** - * Whether the credits purchase invoice should auto collect with the customer's saved - * payment method. - */ - @JsonProperty("auto_collection") - @ExcludeMissing - fun _autoCollection(): JsonField = autoCollection - - /** - * The net terms determines the difference between the invoice date and the issue date for - * the invoice. If you intend the invoice to be due on issue, set this to 0. - */ - @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms - - /** An optional memo to display on the invoice. */ - @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo - - /** - * If true, new credit blocks created by this top-up will require that the corresponding - * invoice is paid before they can be drawn down from. - */ - @JsonProperty("require_successful_payment") - @ExcludeMissing - fun _requireSuccessfulPayment(): JsonField = requireSuccessfulPayment - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoiceSettings = apply { - if (validated) { - return@apply - } - - autoCollection() - netTerms() - memo() - requireSuccessfulPayment() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoiceSettings]. */ - class Builder internal constructor() { - - private var autoCollection: JsonField? = null - private var netTerms: JsonField? = null - private var memo: JsonField = JsonMissing.of() - private var requireSuccessfulPayment: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoiceSettings: InvoiceSettings) = apply { - autoCollection = invoiceSettings.autoCollection - netTerms = invoiceSettings.netTerms - memo = invoiceSettings.memo - requireSuccessfulPayment = invoiceSettings.requireSuccessfulPayment - additionalProperties = invoiceSettings.additionalProperties.toMutableMap() - } - - /** - * Whether the credits purchase invoice should auto collect with the customer's saved - * payment method. - */ - fun autoCollection(autoCollection: Boolean) = - autoCollection(JsonField.of(autoCollection)) - - /** - * Whether the credits purchase invoice should auto collect with the customer's saved - * payment method. - */ - fun autoCollection(autoCollection: JsonField) = apply { - this.autoCollection = autoCollection - } - - /** - * The net terms determines the difference between the invoice date and the issue date - * for the invoice. If you intend the invoice to be due on issue, set this to 0. - */ - fun netTerms(netTerms: Long) = netTerms(JsonField.of(netTerms)) - - /** - * The net terms determines the difference between the invoice date and the issue date - * for the invoice. If you intend the invoice to be due on issue, set this to 0. - */ - fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } - - /** An optional memo to display on the invoice. */ - fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) - - /** An optional memo to display on the invoice. */ - fun memo(memo: Optional) = memo(memo.orElse(null)) - - /** An optional memo to display on the invoice. */ - fun memo(memo: JsonField) = apply { this.memo = memo } - - /** - * If true, new credit blocks created by this top-up will require that the corresponding - * invoice is paid before they can be drawn down from. - */ - fun requireSuccessfulPayment(requireSuccessfulPayment: Boolean) = - requireSuccessfulPayment(JsonField.of(requireSuccessfulPayment)) - - /** - * If true, new credit blocks created by this top-up will require that the corresponding - * invoice is paid before they can be drawn down from. - */ - fun requireSuccessfulPayment(requireSuccessfulPayment: JsonField) = apply { - this.requireSuccessfulPayment = requireSuccessfulPayment - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoiceSettings = - InvoiceSettings( - checkRequired("autoCollection", autoCollection), - checkRequired("netTerms", netTerms), - memo, - requireSuccessfulPayment, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoiceSettings && autoCollection == other.autoCollection && netTerms == other.netTerms && memo == other.memo && requireSuccessfulPayment == other.requireSuccessfulPayment && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(autoCollection, netTerms, memo, requireSuccessfulPayment, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoiceSettings{autoCollection=$autoCollection, netTerms=$netTerms, memo=$memo, requireSuccessfulPayment=$requireSuccessfulPayment, additionalProperties=$additionalProperties}" - } - - /** The unit of expires_after. */ - class ExpiresAfterUnit @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = ExpiresAfterUnit(JsonField.of(value)) - } - - /** An enum containing [ExpiresAfterUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [ExpiresAfterUnit]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ExpiresAfterUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [ExpiresAfterUnit] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown ExpiresAfterUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is ExpiresAfterUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CustomerCreditTopUpCreateResponse && id == other.id && amount == other.amount && currency == other.currency && invoiceSettings == other.invoiceSettings && perUnitCostBasis == other.perUnitCostBasis && threshold == other.threshold && expiresAfter == other.expiresAfter && expiresAfterUnit == other.expiresAfterUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, currency, invoiceSettings, perUnitCostBasis, threshold, expiresAfter, expiresAfterUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CustomerCreditTopUpCreateResponse{id=$id, amount=$amount, currency=$currency, invoiceSettings=$invoiceSettings, perUnitCostBasis=$perUnitCostBasis, threshold=$threshold, expiresAfter=$expiresAfter, expiresAfterUnit=$expiresAfterUnit, additionalProperties=$additionalProperties}" -} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpDeleteByExternalIdParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpDeleteByExternalIdParams.kt index 02638f15e..53708c4df 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpDeleteByExternalIdParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpDeleteByExternalIdParams.kt @@ -55,6 +55,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [CustomerCreditTopUpDeleteByExternalIdParams]. + * + * The following fields are required: + * ```java + * .externalCustomerId() + * .topUpId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpDeleteParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpDeleteParams.kt index bfac40664..0fbb1e641 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpDeleteParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpDeleteParams.kt @@ -55,6 +55,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [CustomerCreditTopUpDeleteParams]. + * + * The following fields are required: + * ```java + * .customerId() + * .topUpId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPage.kt index db1d259ab..9ddf80055 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPage.kt @@ -29,7 +29,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -87,24 +87,20 @@ private constructor( class Response @JsonCreator constructor( - @JsonProperty("data") - private val data: JsonField> = - JsonMissing.of(), + @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = - data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = - Optional.ofNullable(data) + fun _data(): Optional>> = Optional.ofNullable(data) @JsonProperty("pagination_metadata") fun _paginationMetadata(): Optional> = @@ -143,13 +139,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [CustomerCreditTopUpListByExternalIdPage]. + */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = - JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -160,12 +159,9 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = - data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { - this.data = data - } + fun data(data: JsonField>) = apply { this.data = data } fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) @@ -183,9 +179,9 @@ private constructor( } class AutoPager(private val firstPage: CustomerCreditTopUpListByExternalIdPage) : - Iterable { + Iterable { - override fun iterator(): Iterator = iterator { + override fun iterator(): Iterator = iterator { var page = firstPage var index = 0 while (true) { @@ -197,7 +193,7 @@ private constructor( } } - fun stream(): Stream { + fun stream(): Stream { return StreamSupport.stream(spliterator(), false) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPageAsync.kt index cd7942865..fbd002949 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdPageAsync.kt @@ -30,7 +30,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -90,24 +90,20 @@ private constructor( class Response @JsonCreator constructor( - @JsonProperty("data") - private val data: JsonField> = - JsonMissing.of(), + @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = - data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = - Optional.ofNullable(data) + fun _data(): Optional>> = Optional.ofNullable(data) @JsonProperty("pagination_metadata") fun _paginationMetadata(): Optional> = @@ -146,13 +142,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [CustomerCreditTopUpListByExternalIdPageAsync]. + */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = - JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -163,12 +162,9 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = - data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { - this.data = data - } + fun data(data: JsonField>) = apply { this.data = data } fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) @@ -187,12 +183,9 @@ private constructor( class AutoPager(private val firstPage: CustomerCreditTopUpListByExternalIdPageAsync) { - fun forEach( - action: Predicate, - executor: Executor, - ): CompletableFuture { + fun forEach(action: Predicate, executor: Executor): CompletableFuture { fun CompletableFuture>.forEach( - action: (CustomerCreditTopUpListByExternalIdResponse) -> Boolean, + action: (TopUpModel) -> Boolean, executor: Executor, ): CompletableFuture = thenComposeAsync( @@ -208,10 +201,8 @@ private constructor( .forEach(action::test, executor) } - fun toList( - executor: Executor - ): CompletableFuture> { - val values = mutableListOf() + fun toList(executor: Executor): CompletableFuture> { + val values = mutableListOf() return forEach(values::add, executor).thenApply { values } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdParams.kt index d5bc71d3c..0720aa518 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdParams.kt @@ -56,6 +56,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [CustomerCreditTopUpListByExternalIdParams]. + * + * The following fields are required: + * ```java + * .externalCustomerId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPage.kt index 696d7a99d..1210337d1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPage.kt @@ -29,7 +29,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -87,22 +87,20 @@ private constructor( class Response @JsonCreator constructor( - @JsonProperty("data") - private val data: JsonField> = JsonMissing.of(), + @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = - Optional.ofNullable(data) + fun _data(): Optional>> = Optional.ofNullable(data) @JsonProperty("pagination_metadata") fun _paginationMetadata(): Optional> = @@ -141,12 +139,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [CustomerCreditTopUpListPage]. + */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -157,11 +159,9 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { - this.data = data - } + fun data(data: JsonField>) = apply { this.data = data } fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) @@ -178,10 +178,9 @@ private constructor( } } - class AutoPager(private val firstPage: CustomerCreditTopUpListPage) : - Iterable { + class AutoPager(private val firstPage: CustomerCreditTopUpListPage) : Iterable { - override fun iterator(): Iterator = iterator { + override fun iterator(): Iterator = iterator { var page = firstPage var index = 0 while (true) { @@ -193,7 +192,7 @@ private constructor( } } - fun stream(): Stream { + fun stream(): Stream { return StreamSupport.stream(spliterator(), false) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPageAsync.kt index 20b9b1828..2ad4c6e0a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListPageAsync.kt @@ -30,7 +30,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -90,22 +90,20 @@ private constructor( class Response @JsonCreator constructor( - @JsonProperty("data") - private val data: JsonField> = JsonMissing.of(), + @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = - Optional.ofNullable(data) + fun _data(): Optional>> = Optional.ofNullable(data) @JsonProperty("pagination_metadata") fun _paginationMetadata(): Optional> = @@ -144,12 +142,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [CustomerCreditTopUpListPageAsync]. + */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -160,11 +162,9 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { - this.data = data - } + fun data(data: JsonField>) = apply { this.data = data } fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) @@ -183,12 +183,9 @@ private constructor( class AutoPager(private val firstPage: CustomerCreditTopUpListPageAsync) { - fun forEach( - action: Predicate, - executor: Executor, - ): CompletableFuture { + fun forEach(action: Predicate, executor: Executor): CompletableFuture { fun CompletableFuture>.forEach( - action: (CustomerCreditTopUpListResponse) -> Boolean, + action: (TopUpModel) -> Boolean, executor: Executor, ): CompletableFuture = thenComposeAsync( @@ -204,8 +201,8 @@ private constructor( .forEach(action::test, executor) } - fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() + fun toList(executor: Executor): CompletableFuture> { + val values = mutableListOf() return forEach(values::add, executor).thenApply { values } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListParams.kt index 2ae7453a7..a5eeba038 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListParams.kt @@ -56,6 +56,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [CustomerCreditTopUpListParams]. + * + * The following fields are required: + * ```java + * .customerId() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 deleted file mode 100644 index 15b667d56..000000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListResponse.kt +++ /dev/null @@ -1,633 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.withorb.api.core.Enum -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.checkRequired -import com.withorb.api.core.immutableEmptyMap -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.util.Objects -import java.util.Optional - -@NoAutoDetect -class CustomerCreditTopUpListResponse -@JsonCreator -private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("invoice_settings") - @ExcludeMissing - private val invoiceSettings: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - private val perUnitCostBasis: JsonField = JsonMissing.of(), - @JsonProperty("threshold") - @ExcludeMissing - private val threshold: JsonField = JsonMissing.of(), - @JsonProperty("expires_after") - @ExcludeMissing - private val expiresAfter: JsonField = JsonMissing.of(), - @JsonProperty("expires_after_unit") - @ExcludeMissing - private val expiresAfterUnit: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun id(): String = id.getRequired("id") - - /** The amount to increment when the threshold is reached. */ - fun amount(): String = amount.getRequired("amount") - - /** - * The currency or custom pricing unit to use for this top-up. If this is a real-world currency, - * it must match the customer's invoicing currency. - */ - fun currency(): String = currency.getRequired("currency") - - /** Settings for invoices generated by triggered top-ups. */ - fun invoiceSettings(): InvoiceSettings = invoiceSettings.getRequired("invoice_settings") - - /** How much, in the customer's currency, to charge for each unit. */ - fun perUnitCostBasis(): String = perUnitCostBasis.getRequired("per_unit_cost_basis") - - /** - * The threshold at which to trigger the top-up. If the balance is at or below this threshold, - * the top-up will be triggered. - */ - fun threshold(): String = threshold.getRequired("threshold") - - /** - * The number of days or months after which the top-up expires. If unspecified, it does not - * expire. - */ - fun expiresAfter(): Optional = - Optional.ofNullable(expiresAfter.getNullable("expires_after")) - - /** The unit of expires_after. */ - fun expiresAfterUnit(): Optional = - Optional.ofNullable(expiresAfterUnit.getNullable("expires_after_unit")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** The amount to increment when the threshold is reached. */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** - * The currency or custom pricing unit to use for this top-up. If this is a real-world currency, - * it must match the customer's invoicing currency. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** Settings for invoices generated by triggered top-ups. */ - @JsonProperty("invoice_settings") - @ExcludeMissing - fun _invoiceSettings(): JsonField = invoiceSettings - - /** How much, in the customer's currency, to charge for each unit. */ - @JsonProperty("per_unit_cost_basis") - @ExcludeMissing - fun _perUnitCostBasis(): JsonField = perUnitCostBasis - - /** - * The threshold at which to trigger the top-up. If the balance is at or below this threshold, - * the top-up will be triggered. - */ - @JsonProperty("threshold") @ExcludeMissing fun _threshold(): JsonField = threshold - - /** - * The number of days or months after which the top-up expires. If unspecified, it does not - * expire. - */ - @JsonProperty("expires_after") - @ExcludeMissing - fun _expiresAfter(): JsonField = expiresAfter - - /** The unit of expires_after. */ - @JsonProperty("expires_after_unit") - @ExcludeMissing - fun _expiresAfterUnit(): JsonField = expiresAfterUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CustomerCreditTopUpListResponse = apply { - if (validated) { - return@apply - } - - id() - amount() - currency() - invoiceSettings().validate() - perUnitCostBasis() - threshold() - expiresAfter() - expiresAfterUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CustomerCreditTopUpListResponse]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var amount: JsonField? = null - private var currency: JsonField? = null - private var invoiceSettings: JsonField? = null - private var perUnitCostBasis: JsonField? = null - private var threshold: JsonField? = null - private var expiresAfter: JsonField = JsonMissing.of() - private var expiresAfterUnit: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customerCreditTopUpListResponse: CustomerCreditTopUpListResponse) = - apply { - id = customerCreditTopUpListResponse.id - amount = customerCreditTopUpListResponse.amount - currency = customerCreditTopUpListResponse.currency - invoiceSettings = customerCreditTopUpListResponse.invoiceSettings - perUnitCostBasis = customerCreditTopUpListResponse.perUnitCostBasis - threshold = customerCreditTopUpListResponse.threshold - expiresAfter = customerCreditTopUpListResponse.expiresAfter - expiresAfterUnit = customerCreditTopUpListResponse.expiresAfterUnit - additionalProperties = - customerCreditTopUpListResponse.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - /** The amount to increment when the threshold is reached. */ - fun amount(amount: String) = amount(JsonField.of(amount)) - - /** The amount to increment when the threshold is reached. */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** - * The currency or custom pricing unit to use for this top-up. If this is a real-world - * currency, it must match the customer's invoicing currency. - */ - fun currency(currency: String) = currency(JsonField.of(currency)) - - /** - * The currency or custom pricing unit to use for this top-up. If this is a real-world - * currency, it must match the customer's invoicing currency. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** Settings for invoices generated by triggered top-ups. */ - fun invoiceSettings(invoiceSettings: InvoiceSettings) = - invoiceSettings(JsonField.of(invoiceSettings)) - - /** Settings for invoices generated by triggered top-ups. */ - fun invoiceSettings(invoiceSettings: JsonField) = apply { - this.invoiceSettings = invoiceSettings - } - - /** How much, in the customer's currency, to charge for each unit. */ - fun perUnitCostBasis(perUnitCostBasis: String) = - perUnitCostBasis(JsonField.of(perUnitCostBasis)) - - /** How much, in the customer's currency, to charge for each unit. */ - fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { - this.perUnitCostBasis = perUnitCostBasis - } - - /** - * The threshold at which to trigger the top-up. If the balance is at or below this - * threshold, the top-up will be triggered. - */ - fun threshold(threshold: String) = threshold(JsonField.of(threshold)) - - /** - * The threshold at which to trigger the top-up. If the balance is at or below this - * threshold, the top-up will be triggered. - */ - fun threshold(threshold: JsonField) = apply { this.threshold = threshold } - - /** - * The number of days or months after which the top-up expires. If unspecified, it does not - * expire. - */ - fun expiresAfter(expiresAfter: Long?) = expiresAfter(JsonField.ofNullable(expiresAfter)) - - /** - * The number of days or months after which the top-up expires. If unspecified, it does not - * expire. - */ - fun expiresAfter(expiresAfter: Long) = expiresAfter(expiresAfter as Long?) - - /** - * The number of days or months after which the top-up expires. If unspecified, it does not - * expire. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun expiresAfter(expiresAfter: Optional) = - expiresAfter(expiresAfter.orElse(null) as Long?) - - /** - * The number of days or months after which the top-up expires. If unspecified, it does not - * expire. - */ - fun expiresAfter(expiresAfter: JsonField) = apply { this.expiresAfter = expiresAfter } - - /** The unit of expires_after. */ - fun expiresAfterUnit(expiresAfterUnit: ExpiresAfterUnit?) = - expiresAfterUnit(JsonField.ofNullable(expiresAfterUnit)) - - /** The unit of expires_after. */ - fun expiresAfterUnit(expiresAfterUnit: Optional) = - expiresAfterUnit(expiresAfterUnit.orElse(null)) - - /** The unit of expires_after. */ - fun expiresAfterUnit(expiresAfterUnit: JsonField) = apply { - this.expiresAfterUnit = expiresAfterUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CustomerCreditTopUpListResponse = - CustomerCreditTopUpListResponse( - checkRequired("id", id), - checkRequired("amount", amount), - checkRequired("currency", currency), - checkRequired("invoiceSettings", invoiceSettings), - checkRequired("perUnitCostBasis", perUnitCostBasis), - checkRequired("threshold", threshold), - expiresAfter, - expiresAfterUnit, - additionalProperties.toImmutable(), - ) - } - - /** Settings for invoices generated by triggered top-ups. */ - @NoAutoDetect - class InvoiceSettings - @JsonCreator - private constructor( - @JsonProperty("auto_collection") - @ExcludeMissing - private val autoCollection: JsonField = JsonMissing.of(), - @JsonProperty("net_terms") - @ExcludeMissing - private val netTerms: JsonField = JsonMissing.of(), - @JsonProperty("memo") - @ExcludeMissing - private val memo: JsonField = JsonMissing.of(), - @JsonProperty("require_successful_payment") - @ExcludeMissing - private val requireSuccessfulPayment: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * Whether the credits purchase invoice should auto collect with the customer's saved - * payment method. - */ - fun autoCollection(): Boolean = autoCollection.getRequired("auto_collection") - - /** - * The net terms determines the difference between the invoice date and the issue date for - * the invoice. If you intend the invoice to be due on issue, set this to 0. - */ - fun netTerms(): Long = netTerms.getRequired("net_terms") - - /** An optional memo to display on the invoice. */ - fun memo(): Optional = Optional.ofNullable(memo.getNullable("memo")) - - /** - * If true, new credit blocks created by this top-up will require that the corresponding - * invoice is paid before they can be drawn down from. - */ - fun requireSuccessfulPayment(): Optional = - Optional.ofNullable(requireSuccessfulPayment.getNullable("require_successful_payment")) - - /** - * Whether the credits purchase invoice should auto collect with the customer's saved - * payment method. - */ - @JsonProperty("auto_collection") - @ExcludeMissing - fun _autoCollection(): JsonField = autoCollection - - /** - * The net terms determines the difference between the invoice date and the issue date for - * the invoice. If you intend the invoice to be due on issue, set this to 0. - */ - @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms - - /** An optional memo to display on the invoice. */ - @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo - - /** - * If true, new credit blocks created by this top-up will require that the corresponding - * invoice is paid before they can be drawn down from. - */ - @JsonProperty("require_successful_payment") - @ExcludeMissing - fun _requireSuccessfulPayment(): JsonField = requireSuccessfulPayment - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoiceSettings = apply { - if (validated) { - return@apply - } - - autoCollection() - netTerms() - memo() - requireSuccessfulPayment() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoiceSettings]. */ - class Builder internal constructor() { - - private var autoCollection: JsonField? = null - private var netTerms: JsonField? = null - private var memo: JsonField = JsonMissing.of() - private var requireSuccessfulPayment: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoiceSettings: InvoiceSettings) = apply { - autoCollection = invoiceSettings.autoCollection - netTerms = invoiceSettings.netTerms - memo = invoiceSettings.memo - requireSuccessfulPayment = invoiceSettings.requireSuccessfulPayment - additionalProperties = invoiceSettings.additionalProperties.toMutableMap() - } - - /** - * Whether the credits purchase invoice should auto collect with the customer's saved - * payment method. - */ - fun autoCollection(autoCollection: Boolean) = - autoCollection(JsonField.of(autoCollection)) - - /** - * Whether the credits purchase invoice should auto collect with the customer's saved - * payment method. - */ - fun autoCollection(autoCollection: JsonField) = apply { - this.autoCollection = autoCollection - } - - /** - * The net terms determines the difference between the invoice date and the issue date - * for the invoice. If you intend the invoice to be due on issue, set this to 0. - */ - fun netTerms(netTerms: Long) = netTerms(JsonField.of(netTerms)) - - /** - * The net terms determines the difference between the invoice date and the issue date - * for the invoice. If you intend the invoice to be due on issue, set this to 0. - */ - fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } - - /** An optional memo to display on the invoice. */ - fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) - - /** An optional memo to display on the invoice. */ - fun memo(memo: Optional) = memo(memo.orElse(null)) - - /** An optional memo to display on the invoice. */ - fun memo(memo: JsonField) = apply { this.memo = memo } - - /** - * If true, new credit blocks created by this top-up will require that the corresponding - * invoice is paid before they can be drawn down from. - */ - fun requireSuccessfulPayment(requireSuccessfulPayment: Boolean) = - requireSuccessfulPayment(JsonField.of(requireSuccessfulPayment)) - - /** - * If true, new credit blocks created by this top-up will require that the corresponding - * invoice is paid before they can be drawn down from. - */ - fun requireSuccessfulPayment(requireSuccessfulPayment: JsonField) = apply { - this.requireSuccessfulPayment = requireSuccessfulPayment - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoiceSettings = - InvoiceSettings( - checkRequired("autoCollection", autoCollection), - checkRequired("netTerms", netTerms), - memo, - requireSuccessfulPayment, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoiceSettings && autoCollection == other.autoCollection && netTerms == other.netTerms && memo == other.memo && requireSuccessfulPayment == other.requireSuccessfulPayment && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(autoCollection, netTerms, memo, requireSuccessfulPayment, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoiceSettings{autoCollection=$autoCollection, netTerms=$netTerms, memo=$memo, requireSuccessfulPayment=$requireSuccessfulPayment, additionalProperties=$additionalProperties}" - } - - /** The unit of expires_after. */ - class ExpiresAfterUnit @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = ExpiresAfterUnit(JsonField.of(value)) - } - - /** An enum containing [ExpiresAfterUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [ExpiresAfterUnit]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ExpiresAfterUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [ExpiresAfterUnit] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown ExpiresAfterUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is ExpiresAfterUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CustomerCreditTopUpListResponse && id == other.id && amount == other.amount && currency == other.currency && invoiceSettings == other.invoiceSettings && perUnitCostBasis == other.perUnitCostBasis && threshold == other.threshold && expiresAfter == other.expiresAfter && expiresAfterUnit == other.expiresAfterUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, currency, invoiceSettings, perUnitCostBasis, threshold, expiresAfter, expiresAfterUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CustomerCreditTopUpListResponse{id=$id, amount=$amount, currency=$currency, invoiceSettings=$invoiceSettings, perUnitCostBasis=$perUnitCostBasis, threshold=$threshold, expiresAfter=$expiresAfter, expiresAfterUnit=$expiresAfterUnit, additionalProperties=$additionalProperties}" -} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerDeleteParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerDeleteParams.kt index f869a8ee3..76ed7ab2a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerDeleteParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerDeleteParams.kt @@ -62,6 +62,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [CustomerDeleteParams]. + * + * The following fields are required: + * ```java + * .customerId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerFetchByExternalIdParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerFetchByExternalIdParams.kt index 29c13c3a5..2c496d4ef 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerFetchByExternalIdParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerFetchByExternalIdParams.kt @@ -44,6 +44,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [CustomerFetchByExternalIdParams]. + * + * The following fields are required: + * ```java + * .externalCustomerId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerFetchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerFetchParams.kt index 5b14f708f..11128697e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerFetchParams.kt @@ -43,6 +43,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [CustomerFetchParams]. + * + * The following fields are required: + * ```java + * .customerId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerHierarchyConfigModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerHierarchyConfigModel.kt new file mode 100644 index 000000000..917993ba8 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerHierarchyConfigModel.kt @@ -0,0 +1,195 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class CustomerHierarchyConfigModel +@JsonCreator +private constructor( + @JsonProperty("child_customer_ids") + @ExcludeMissing + private val childCustomerIds: JsonField> = JsonMissing.of(), + @JsonProperty("parent_customer_id") + @ExcludeMissing + private val parentCustomerId: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** + * A list of child customer IDs to add to the hierarchy. The desired child customers must not + * already be part of another hierarchy. + */ + fun childCustomerIds(): Optional> = + Optional.ofNullable(childCustomerIds.getNullable("child_customer_ids")) + + /** + * The ID of the parent customer in the hierarchy. The desired parent customer must not be a + * child of another customer. + */ + fun parentCustomerId(): Optional = + Optional.ofNullable(parentCustomerId.getNullable("parent_customer_id")) + + /** + * A list of child customer IDs to add to the hierarchy. The desired child customers must not + * already be part of another hierarchy. + */ + @JsonProperty("child_customer_ids") + @ExcludeMissing + fun _childCustomerIds(): JsonField> = childCustomerIds + + /** + * The ID of the parent customer in the hierarchy. The desired parent customer must not be a + * child of another customer. + */ + @JsonProperty("parent_customer_id") + @ExcludeMissing + fun _parentCustomerId(): JsonField = parentCustomerId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): CustomerHierarchyConfigModel = apply { + if (validated) { + return@apply + } + + childCustomerIds() + parentCustomerId() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CustomerHierarchyConfigModel]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomerHierarchyConfigModel]. */ + class Builder internal constructor() { + + private var childCustomerIds: JsonField>? = null + private var parentCustomerId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(customerHierarchyConfigModel: CustomerHierarchyConfigModel) = apply { + childCustomerIds = + customerHierarchyConfigModel.childCustomerIds.map { it.toMutableList() } + parentCustomerId = customerHierarchyConfigModel.parentCustomerId + additionalProperties = customerHierarchyConfigModel.additionalProperties.toMutableMap() + } + + /** + * A list of child customer IDs to add to the hierarchy. The desired child customers must + * not already be part of another hierarchy. + */ + fun childCustomerIds(childCustomerIds: List) = + childCustomerIds(JsonField.of(childCustomerIds)) + + /** + * A list of child customer IDs to add to the hierarchy. The desired child customers must + * not already be part of another hierarchy. + */ + fun childCustomerIds(childCustomerIds: JsonField>) = apply { + this.childCustomerIds = childCustomerIds.map { it.toMutableList() } + } + + /** + * A list of child customer IDs to add to the hierarchy. The desired child customers must + * not already be part of another hierarchy. + */ + fun addChildCustomerId(childCustomerId: String) = apply { + childCustomerIds = + (childCustomerIds ?: JsonField.of(mutableListOf())).also { + checkKnown("childCustomerIds", it).add(childCustomerId) + } + } + + /** + * The ID of the parent customer in the hierarchy. The desired parent customer must not be a + * child of another customer. + */ + fun parentCustomerId(parentCustomerId: String?) = + parentCustomerId(JsonField.ofNullable(parentCustomerId)) + + /** + * The ID of the parent customer in the hierarchy. The desired parent customer must not be a + * child of another customer. + */ + fun parentCustomerId(parentCustomerId: Optional) = + parentCustomerId(parentCustomerId.orElse(null)) + + /** + * The ID of the parent customer in the hierarchy. The desired parent customer must not be a + * child of another customer. + */ + fun parentCustomerId(parentCustomerId: JsonField) = apply { + this.parentCustomerId = parentCustomerId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): CustomerHierarchyConfigModel = + CustomerHierarchyConfigModel( + (childCustomerIds ?: JsonMissing.of()).map { it.toImmutable() }, + parentCustomerId, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CustomerHierarchyConfigModel && childCustomerIds == other.childCustomerIds && parentCustomerId == other.parentCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(childCustomerIds, parentCustomerId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomerHierarchyConfigModel{childCustomerIds=$childCustomerIds, parentCustomerId=$parentCustomerId, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPage.kt index 84452eb57..38b11d4fb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPage.kt @@ -35,7 +35,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -90,20 +90,20 @@ private constructor( class Response @JsonCreator constructor( - @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), + @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = Optional.ofNullable(data) + fun _data(): Optional>> = Optional.ofNullable(data) @JsonProperty("pagination_metadata") fun _paginationMetadata(): Optional> = @@ -142,12 +142,13 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [CustomerListPage]. */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -158,9 +159,9 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { this.data = data } fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) @@ -177,9 +178,9 @@ private constructor( } } - class AutoPager(private val firstPage: CustomerListPage) : Iterable { + class AutoPager(private val firstPage: CustomerListPage) : Iterable { - override fun iterator(): Iterator = iterator { + override fun iterator(): Iterator = iterator { var page = firstPage var index = 0 while (true) { @@ -191,7 +192,7 @@ private constructor( } } - fun stream(): Stream { + fun stream(): Stream { return StreamSupport.stream(spliterator(), false) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPageAsync.kt index eaac458fa..4c842eff6 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListPageAsync.kt @@ -36,7 +36,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -96,20 +96,20 @@ private constructor( class Response @JsonCreator constructor( - @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), + @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = Optional.ofNullable(data) + fun _data(): Optional>> = Optional.ofNullable(data) @JsonProperty("pagination_metadata") fun _paginationMetadata(): Optional> = @@ -148,12 +148,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [CustomerListPageAsync]. + */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -164,9 +167,9 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { this.data = data } fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) @@ -185,9 +188,9 @@ private constructor( class AutoPager(private val firstPage: CustomerListPageAsync) { - fun forEach(action: Predicate, executor: Executor): CompletableFuture { + fun forEach(action: Predicate, executor: Executor): CompletableFuture { fun CompletableFuture>.forEach( - action: (Customer) -> Boolean, + action: (CustomerModel) -> Boolean, executor: Executor, ): CompletableFuture = thenComposeAsync( @@ -203,8 +206,8 @@ private constructor( .forEach(action::test, executor) } - fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() + fun toList(executor: Executor): CompletableFuture> { + val values = mutableListOf() return forEach(values::add, executor).thenApply { values } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListParams.kt index a8faebb8b..a0982c7b6 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListParams.kt @@ -91,6 +91,7 @@ private constructor( @JvmStatic fun none(): CustomerListParams = builder().build() + /** Returns a mutable builder for constructing an instance of [CustomerListParams]. */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerMinifiedModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerMinifiedModel.kt new file mode 100644 index 000000000..0a7798651 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerMinifiedModel.kt @@ -0,0 +1,145 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class CustomerMinifiedModel +@JsonCreator +private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("external_customer_id") + @ExcludeMissing + private val externalCustomerId: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun id(): String = id.getRequired("id") + + fun externalCustomerId(): Optional = + Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("external_customer_id") + @ExcludeMissing + fun _externalCustomerId(): JsonField = externalCustomerId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): CustomerMinifiedModel = apply { + if (validated) { + return@apply + } + + id() + externalCustomerId() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CustomerMinifiedModel]. + * + * The following fields are required: + * ```java + * .id() + * .externalCustomerId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomerMinifiedModel]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var externalCustomerId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(customerMinifiedModel: CustomerMinifiedModel) = apply { + id = customerMinifiedModel.id + externalCustomerId = customerMinifiedModel.externalCustomerId + additionalProperties = customerMinifiedModel.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) + + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.orElse(null)) + + fun externalCustomerId(externalCustomerId: JsonField) = apply { + this.externalCustomerId = externalCustomerId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): CustomerMinifiedModel = + CustomerMinifiedModel( + checkRequired("id", id), + checkRequired("externalCustomerId", externalCustomerId), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CustomerMinifiedModel && id == other.id && externalCustomerId == other.externalCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, externalCustomerId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomerMinifiedModel{id=$id, externalCustomerId=$externalCustomerId, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerModel.kt new file mode 100644 index 000000000..df943d650 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerModel.kt @@ -0,0 +1,2080 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +/** + * 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. + */ +@NoAutoDetect +class CustomerModel +@JsonCreator +private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("additional_emails") + @ExcludeMissing + private val additionalEmails: JsonField> = JsonMissing.of(), + @JsonProperty("auto_collection") + @ExcludeMissing + private val autoCollection: JsonField = JsonMissing.of(), + @JsonProperty("balance") + @ExcludeMissing + private val balance: JsonField = JsonMissing.of(), + @JsonProperty("billing_address") + @ExcludeMissing + private val billingAddress: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("email") @ExcludeMissing private val email: JsonField = JsonMissing.of(), + @JsonProperty("email_delivery") + @ExcludeMissing + private val emailDelivery: JsonField = JsonMissing.of(), + @JsonProperty("exempt_from_automated_tax") + @ExcludeMissing + private val exemptFromAutomatedTax: JsonField = JsonMissing.of(), + @JsonProperty("external_customer_id") + @ExcludeMissing + private val externalCustomerId: JsonField = JsonMissing.of(), + @JsonProperty("hierarchy") + @ExcludeMissing + private val hierarchy: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("payment_provider") + @ExcludeMissing + private val paymentProvider: JsonField = JsonMissing.of(), + @JsonProperty("payment_provider_id") + @ExcludeMissing + private val paymentProviderId: JsonField = JsonMissing.of(), + @JsonProperty("portal_url") + @ExcludeMissing + private val portalUrl: JsonField = JsonMissing.of(), + @JsonProperty("shipping_address") + @ExcludeMissing + private val shippingAddress: JsonField = JsonMissing.of(), + @JsonProperty("tax_id") + @ExcludeMissing + private val taxId: JsonField = JsonMissing.of(), + @JsonProperty("timezone") + @ExcludeMissing + private val timezone: JsonField = JsonMissing.of(), + @JsonProperty("accounting_sync_configuration") + @ExcludeMissing + private val accountingSyncConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("reporting_configuration") + @ExcludeMissing + private val reportingConfiguration: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun id(): String = id.getRequired("id") + + fun additionalEmails(): List = additionalEmails.getRequired("additional_emails") + + fun autoCollection(): Boolean = autoCollection.getRequired("auto_collection") + + /** The customer's current balance in their currency. */ + fun balance(): String = balance.getRequired("balance") + + fun billingAddress(): Optional = + Optional.ofNullable(billingAddress.getNullable("billing_address")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** + * A valid customer email, to be used for notifications. When Orb triggers payment through a + * payment gateway, this email will be used for any automatically issued receipts. + */ + fun email(): String = email.getRequired("email") + + fun emailDelivery(): Boolean = emailDelivery.getRequired("email_delivery") + + fun exemptFromAutomatedTax(): Optional = + Optional.ofNullable(exemptFromAutomatedTax.getNullable("exempt_from_automated_tax")) + + /** + * An optional user-defined ID for this customer resource, used throughout the system as an + * alias for this Customer. Use this field to identify a customer by an existing identifier in + * your system. + */ + fun externalCustomerId(): Optional = + Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) + + /** The hierarchical relationships for this customer. */ + fun hierarchy(): Hierarchy = hierarchy.getRequired("hierarchy") + + /** + * 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.getRequired("metadata") + + /** The full name of the customer */ + fun name(): String = name.getRequired("name") + + /** + * This is used for creating charges or invoices in an external system via Orb. When not in test + * mode, the connection must first be configured in the Orb webapp. + */ + fun paymentProvider(): Optional = + Optional.ofNullable(paymentProvider.getNullable("payment_provider")) + + /** + * The ID of this customer in an external payments solution, such as Stripe. This is used for + * creating charges or invoices in the external system via Orb. + */ + fun paymentProviderId(): Optional = + Optional.ofNullable(paymentProviderId.getNullable("payment_provider_id")) + + fun portalUrl(): Optional = Optional.ofNullable(portalUrl.getNullable("portal_url")) + + fun shippingAddress(): Optional = + Optional.ofNullable(shippingAddress.getNullable("shipping_address")) + + /** + * 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 | + * |--------------------|------------|-------------------------------------------------------------------------------------------------------| + * |Andorra |`ad_nrt` |Andorran NRT Number | + * |Argentina |`ar_cuit` |Argentinian Tax ID Number | + * |Australia |`au_abn` |Australian Business Number (AU ABN) | + * |Australia |`au_arn` |Australian Taxation Office Reference Number | + * |Austria |`eu_vat` |European VAT Number | + * |Bahrain |`bh_vat` |Bahraini VAT Number | + * |Belgium |`eu_vat` |European VAT Number | + * |Bolivia |`bo_tin` |Bolivian Tax ID | + * |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 | + * |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) | + * |Chile |`cl_tin` |Chilean TIN | + * |China |`cn_tin` |Chinese Tax ID | + * |Colombia |`co_nit` |Colombian NIT Number | + * |Costa Rica |`cr_tin` |Costa Rican Tax ID | + * |Croatia |`eu_vat` |European VAT Number | + * |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 | + * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Finland |`eu_vat` |European VAT Number | + * |France |`eu_vat` |European VAT Number | + * |Georgia |`ge_vat` |Georgian VAT | + * |Germany |`eu_vat` |European VAT Number | + * |Greece |`eu_vat` |European VAT Number | + * |Hong Kong |`hk_br` |Hong Kong BR Number | + * |Hungary |`eu_vat` |European VAT Number | + * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | + * |Iceland |`is_vat` |Icelandic VAT | + * |India |`in_gst` |Indian GST Number | + * |Indonesia |`id_npwp` |Indonesian NPWP Number | + * |Ireland |`eu_vat` |European VAT Number | + * |Israel |`il_vat` |Israel VAT | + * |Italy |`eu_vat` |European VAT Number | + * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | + * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | + * |Latvia |`eu_vat` |European VAT Number | + * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | + * |Mexico |`mx_rfc` |Mexican RFC Number | + * |Netherlands |`eu_vat` |European VAT Number | + * |New Zealand |`nz_gst` |New Zealand GST Number | + * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | + * |Norway |`no_vat` |Norwegian VAT Number | + * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | + * |Oman |`om_vat` |Omani VAT Number | + * |Peru |`pe_ruc` |Peruvian RUC Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Poland |`eu_vat` |European VAT Number | + * |Portugal |`eu_vat` |European VAT Number | + * |Romania |`eu_vat` |European VAT Number | + * |Romania |`ro_tin` |Romanian Tax ID Number | + * |Russia |`ru_inn` |Russian INN | + * |Russia |`ru_kpp` |Russian KPP | + * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | + * |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 | + * |Sweden |`eu_vat` |European VAT Number | + * |Switzerland |`ch_vat` |Switzerland VAT Number | + * |Taiwan |`tw_vat` |Taiwanese VAT | + * |Thailand |`th_vat` |Thai VAT | + * |Turkey |`tr_tin` |Turkish Tax Identification Number | + * |Ukraine |`ua_vat` |Ukrainian VAT | + * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | + * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | + * |United Kingdom |`gb_vat` |United Kingdom VAT Number | + * |United States |`us_ein` |United States EIN | + * |Uruguay |`uy_ruc` |Uruguayan RUC Number | + * |Venezuela |`ve_rif` |Venezuelan RIF Number | + * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + */ + fun taxId(): Optional = Optional.ofNullable(taxId.getNullable("tax_id")) + + /** + * A timezone identifier from the IANA timezone database, such as "America/Los_Angeles". This + * "defaults to your account's timezone if not set. This cannot be changed after customer + * creation. + */ + fun timezone(): String = timezone.getRequired("timezone") + + fun accountingSyncConfiguration(): Optional = + Optional.ofNullable( + accountingSyncConfiguration.getNullable("accounting_sync_configuration") + ) + + fun reportingConfiguration(): Optional = + Optional.ofNullable(reportingConfiguration.getNullable("reporting_configuration")) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("additional_emails") + @ExcludeMissing + fun _additionalEmails(): JsonField> = additionalEmails + + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection + + /** The customer's current balance in their currency. */ + @JsonProperty("balance") @ExcludeMissing fun _balance(): JsonField = balance + + @JsonProperty("billing_address") + @ExcludeMissing + fun _billingAddress(): JsonField = billingAddress + + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * A valid customer email, to be used for notifications. When Orb triggers payment through a + * payment gateway, this email will be used for any automatically issued receipts. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email + + @JsonProperty("email_delivery") + @ExcludeMissing + fun _emailDelivery(): JsonField = emailDelivery + + @JsonProperty("exempt_from_automated_tax") + @ExcludeMissing + fun _exemptFromAutomatedTax(): JsonField = exemptFromAutomatedTax + + /** + * An optional user-defined ID for this customer resource, used throughout the system as an + * alias for this Customer. Use this field to identify a customer by an existing identifier in + * your system. + */ + @JsonProperty("external_customer_id") + @ExcludeMissing + fun _externalCustomerId(): JsonField = externalCustomerId + + /** The hierarchical relationships for this customer. */ + @JsonProperty("hierarchy") @ExcludeMissing fun _hierarchy(): JsonField = hierarchy + + /** + * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** The full name of the customer */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * This is used for creating charges or invoices in an external system via Orb. When not in test + * mode, the connection must first be configured in the Orb webapp. + */ + @JsonProperty("payment_provider") + @ExcludeMissing + fun _paymentProvider(): JsonField = paymentProvider + + /** + * The ID of this customer in an external payments solution, such as Stripe. This is used for + * creating charges or invoices in the external system via Orb. + */ + @JsonProperty("payment_provider_id") + @ExcludeMissing + fun _paymentProviderId(): JsonField = paymentProviderId + + @JsonProperty("portal_url") @ExcludeMissing fun _portalUrl(): JsonField = portalUrl + + @JsonProperty("shipping_address") + @ExcludeMissing + fun _shippingAddress(): JsonField = shippingAddress + + /** + * 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 | + * |--------------------|------------|-------------------------------------------------------------------------------------------------------| + * |Andorra |`ad_nrt` |Andorran NRT Number | + * |Argentina |`ar_cuit` |Argentinian Tax ID Number | + * |Australia |`au_abn` |Australian Business Number (AU ABN) | + * |Australia |`au_arn` |Australian Taxation Office Reference Number | + * |Austria |`eu_vat` |European VAT Number | + * |Bahrain |`bh_vat` |Bahraini VAT Number | + * |Belgium |`eu_vat` |European VAT Number | + * |Bolivia |`bo_tin` |Bolivian Tax ID | + * |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 | + * |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) | + * |Chile |`cl_tin` |Chilean TIN | + * |China |`cn_tin` |Chinese Tax ID | + * |Colombia |`co_nit` |Colombian NIT Number | + * |Costa Rica |`cr_tin` |Costa Rican Tax ID | + * |Croatia |`eu_vat` |European VAT Number | + * |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 | + * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Finland |`eu_vat` |European VAT Number | + * |France |`eu_vat` |European VAT Number | + * |Georgia |`ge_vat` |Georgian VAT | + * |Germany |`eu_vat` |European VAT Number | + * |Greece |`eu_vat` |European VAT Number | + * |Hong Kong |`hk_br` |Hong Kong BR Number | + * |Hungary |`eu_vat` |European VAT Number | + * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | + * |Iceland |`is_vat` |Icelandic VAT | + * |India |`in_gst` |Indian GST Number | + * |Indonesia |`id_npwp` |Indonesian NPWP Number | + * |Ireland |`eu_vat` |European VAT Number | + * |Israel |`il_vat` |Israel VAT | + * |Italy |`eu_vat` |European VAT Number | + * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | + * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | + * |Latvia |`eu_vat` |European VAT Number | + * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | + * |Mexico |`mx_rfc` |Mexican RFC Number | + * |Netherlands |`eu_vat` |European VAT Number | + * |New Zealand |`nz_gst` |New Zealand GST Number | + * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | + * |Norway |`no_vat` |Norwegian VAT Number | + * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | + * |Oman |`om_vat` |Omani VAT Number | + * |Peru |`pe_ruc` |Peruvian RUC Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Poland |`eu_vat` |European VAT Number | + * |Portugal |`eu_vat` |European VAT Number | + * |Romania |`eu_vat` |European VAT Number | + * |Romania |`ro_tin` |Romanian Tax ID Number | + * |Russia |`ru_inn` |Russian INN | + * |Russia |`ru_kpp` |Russian KPP | + * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | + * |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 | + * |Sweden |`eu_vat` |European VAT Number | + * |Switzerland |`ch_vat` |Switzerland VAT Number | + * |Taiwan |`tw_vat` |Taiwanese VAT | + * |Thailand |`th_vat` |Thai VAT | + * |Turkey |`tr_tin` |Turkish Tax Identification Number | + * |Ukraine |`ua_vat` |Ukrainian VAT | + * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | + * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | + * |United Kingdom |`gb_vat` |United Kingdom VAT Number | + * |United States |`us_ein` |United States EIN | + * |Uruguay |`uy_ruc` |Uruguayan RUC Number | + * |Venezuela |`ve_rif` |Venezuelan RIF Number | + * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + */ + @JsonProperty("tax_id") @ExcludeMissing fun _taxId(): JsonField = taxId + + /** + * A timezone identifier from the IANA timezone database, such as "America/Los_Angeles". This + * "defaults to your account's timezone if not set. This cannot be changed after customer + * creation. + */ + @JsonProperty("timezone") @ExcludeMissing fun _timezone(): JsonField = timezone + + @JsonProperty("accounting_sync_configuration") + @ExcludeMissing + fun _accountingSyncConfiguration(): JsonField = + accountingSyncConfiguration + + @JsonProperty("reporting_configuration") + @ExcludeMissing + fun _reportingConfiguration(): JsonField = reportingConfiguration + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): CustomerModel = apply { + if (validated) { + return@apply + } + + id() + additionalEmails() + autoCollection() + balance() + billingAddress().ifPresent { it.validate() } + createdAt() + currency() + email() + emailDelivery() + exemptFromAutomatedTax() + externalCustomerId() + hierarchy().validate() + metadata().validate() + name() + paymentProvider() + paymentProviderId() + portalUrl() + shippingAddress().ifPresent { it.validate() } + taxId().ifPresent { it.validate() } + timezone() + accountingSyncConfiguration().ifPresent { it.validate() } + reportingConfiguration().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CustomerModel]. + * + * The following fields are required: + * ```java + * .id() + * .additionalEmails() + * .autoCollection() + * .balance() + * .billingAddress() + * .createdAt() + * .currency() + * .email() + * .emailDelivery() + * .exemptFromAutomatedTax() + * .externalCustomerId() + * .hierarchy() + * .metadata() + * .name() + * .paymentProvider() + * .paymentProviderId() + * .portalUrl() + * .shippingAddress() + * .taxId() + * .timezone() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomerModel]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var additionalEmails: JsonField>? = null + private var autoCollection: JsonField? = null + private var balance: JsonField? = null + private var billingAddress: JsonField? = null + private var createdAt: JsonField? = null + private var currency: JsonField? = null + private var email: JsonField? = null + private var emailDelivery: JsonField? = null + private var exemptFromAutomatedTax: JsonField? = null + private var externalCustomerId: JsonField? = null + private var hierarchy: JsonField? = null + private var metadata: JsonField? = null + private var name: JsonField? = null + private var paymentProvider: JsonField? = null + private var paymentProviderId: JsonField? = null + private var portalUrl: JsonField? = null + private var shippingAddress: JsonField? = null + private var taxId: JsonField? = null + private var timezone: JsonField? = null + private var accountingSyncConfiguration: JsonField = + JsonMissing.of() + private var reportingConfiguration: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(customerModel: CustomerModel) = apply { + id = customerModel.id + additionalEmails = customerModel.additionalEmails.map { it.toMutableList() } + autoCollection = customerModel.autoCollection + balance = customerModel.balance + billingAddress = customerModel.billingAddress + createdAt = customerModel.createdAt + currency = customerModel.currency + email = customerModel.email + emailDelivery = customerModel.emailDelivery + exemptFromAutomatedTax = customerModel.exemptFromAutomatedTax + externalCustomerId = customerModel.externalCustomerId + hierarchy = customerModel.hierarchy + metadata = customerModel.metadata + name = customerModel.name + paymentProvider = customerModel.paymentProvider + paymentProviderId = customerModel.paymentProviderId + portalUrl = customerModel.portalUrl + shippingAddress = customerModel.shippingAddress + taxId = customerModel.taxId + timezone = customerModel.timezone + accountingSyncConfiguration = customerModel.accountingSyncConfiguration + reportingConfiguration = customerModel.reportingConfiguration + additionalProperties = customerModel.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun additionalEmails(additionalEmails: List) = + additionalEmails(JsonField.of(additionalEmails)) + + fun additionalEmails(additionalEmails: JsonField>) = apply { + this.additionalEmails = additionalEmails.map { it.toMutableList() } + } + + fun addAdditionalEmail(additionalEmail: String) = apply { + additionalEmails = + (additionalEmails ?: JsonField.of(mutableListOf())).also { + checkKnown("additionalEmails", it).add(additionalEmail) + } + } + + fun autoCollection(autoCollection: Boolean) = autoCollection(JsonField.of(autoCollection)) + + fun autoCollection(autoCollection: JsonField) = apply { + this.autoCollection = autoCollection + } + + /** The customer's current balance in their currency. */ + fun balance(balance: String) = balance(JsonField.of(balance)) + + /** The customer's current balance in their currency. */ + fun balance(balance: JsonField) = apply { this.balance = balance } + + fun billingAddress(billingAddress: AddressModel?) = + billingAddress(JsonField.ofNullable(billingAddress)) + + fun billingAddress(billingAddress: Optional) = + billingAddress(billingAddress.orElse(null)) + + fun billingAddress(billingAddress: JsonField) = apply { + this.billingAddress = billingAddress + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + fun currency(currency: Optional) = currency(currency.orElse(null)) + + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** + * A valid customer email, to be used for notifications. When Orb triggers payment through a + * payment gateway, this email will be used for any automatically issued receipts. + */ + fun email(email: String) = email(JsonField.of(email)) + + /** + * A valid customer email, to be used for notifications. When Orb triggers payment through a + * payment gateway, this email will be used for any automatically issued receipts. + */ + fun email(email: JsonField) = apply { this.email = email } + + fun emailDelivery(emailDelivery: Boolean) = emailDelivery(JsonField.of(emailDelivery)) + + fun emailDelivery(emailDelivery: JsonField) = apply { + this.emailDelivery = emailDelivery + } + + fun exemptFromAutomatedTax(exemptFromAutomatedTax: Boolean?) = + exemptFromAutomatedTax(JsonField.ofNullable(exemptFromAutomatedTax)) + + fun exemptFromAutomatedTax(exemptFromAutomatedTax: Boolean) = + exemptFromAutomatedTax(exemptFromAutomatedTax as Boolean?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun exemptFromAutomatedTax(exemptFromAutomatedTax: Optional) = + exemptFromAutomatedTax(exemptFromAutomatedTax.orElse(null) as Boolean?) + + fun exemptFromAutomatedTax(exemptFromAutomatedTax: JsonField) = apply { + this.exemptFromAutomatedTax = exemptFromAutomatedTax + } + + /** + * An optional user-defined ID for this customer resource, used throughout the system as an + * alias for this Customer. Use this field to identify a customer by an existing identifier + * in your system. + */ + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) + + /** + * An optional user-defined ID for this customer resource, used throughout the system as an + * alias for this Customer. Use this field to identify a customer by an existing identifier + * in your system. + */ + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.orElse(null)) + + /** + * An optional user-defined ID for this customer resource, used throughout the system as an + * alias for this Customer. Use this field to identify a customer by an existing identifier + * in your system. + */ + fun externalCustomerId(externalCustomerId: JsonField) = apply { + this.externalCustomerId = externalCustomerId + } + + /** The hierarchical relationships for this customer. */ + fun hierarchy(hierarchy: Hierarchy) = hierarchy(JsonField.of(hierarchy)) + + /** The hierarchical relationships for this customer. */ + fun hierarchy(hierarchy: JsonField) = apply { this.hierarchy = hierarchy } + + /** + * 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)) + + /** + * 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: JsonField) = apply { this.metadata = metadata } + + /** The full name of the customer */ + fun name(name: String) = name(JsonField.of(name)) + + /** The full name of the customer */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * This is used for creating charges or invoices in an external system via Orb. When not in + * test mode, the connection must first be configured in the Orb webapp. + */ + fun paymentProvider(paymentProvider: PaymentProvider?) = + paymentProvider(JsonField.ofNullable(paymentProvider)) + + /** + * This is used for creating charges or invoices in an external system via Orb. When not in + * test mode, the connection must first be configured in the Orb webapp. + */ + fun paymentProvider(paymentProvider: Optional) = + paymentProvider(paymentProvider.orElse(null)) + + /** + * This is used for creating charges or invoices in an external system via Orb. When not in + * test mode, the connection must first be configured in the Orb webapp. + */ + fun paymentProvider(paymentProvider: JsonField) = apply { + this.paymentProvider = paymentProvider + } + + /** + * The ID of this customer in an external payments solution, such as Stripe. This is used + * for creating charges or invoices in the external system via Orb. + */ + fun paymentProviderId(paymentProviderId: String?) = + paymentProviderId(JsonField.ofNullable(paymentProviderId)) + + /** + * The ID of this customer in an external payments solution, such as Stripe. This is used + * for creating charges or invoices in the external system via Orb. + */ + fun paymentProviderId(paymentProviderId: Optional) = + paymentProviderId(paymentProviderId.orElse(null)) + + /** + * The ID of this customer in an external payments solution, such as Stripe. This is used + * for creating charges or invoices in the external system via Orb. + */ + fun paymentProviderId(paymentProviderId: JsonField) = apply { + this.paymentProviderId = paymentProviderId + } + + fun portalUrl(portalUrl: String?) = portalUrl(JsonField.ofNullable(portalUrl)) + + fun portalUrl(portalUrl: Optional) = portalUrl(portalUrl.orElse(null)) + + fun portalUrl(portalUrl: JsonField) = apply { this.portalUrl = portalUrl } + + fun shippingAddress(shippingAddress: AddressModel?) = + shippingAddress(JsonField.ofNullable(shippingAddress)) + + fun shippingAddress(shippingAddress: Optional) = + shippingAddress(shippingAddress.orElse(null)) + + fun shippingAddress(shippingAddress: JsonField) = apply { + this.shippingAddress = shippingAddress + } + + /** + * 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 | + * |--------------------|------------|-------------------------------------------------------------------------------------------------------| + * |Andorra |`ad_nrt` |Andorran NRT Number | + * |Argentina |`ar_cuit` |Argentinian Tax ID Number | + * |Australia |`au_abn` |Australian Business Number (AU ABN) | + * |Australia |`au_arn` |Australian Taxation Office Reference Number | + * |Austria |`eu_vat` |European VAT Number | + * |Bahrain |`bh_vat` |Bahraini VAT Number | + * |Belgium |`eu_vat` |European VAT Number | + * |Bolivia |`bo_tin` |Bolivian Tax ID | + * |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 | + * |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) | + * |Chile |`cl_tin` |Chilean TIN | + * |China |`cn_tin` |Chinese Tax ID | + * |Colombia |`co_nit` |Colombian NIT Number | + * |Costa Rica |`cr_tin` |Costa Rican Tax ID | + * |Croatia |`eu_vat` |European VAT Number | + * |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 | + * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Finland |`eu_vat` |European VAT Number | + * |France |`eu_vat` |European VAT Number | + * |Georgia |`ge_vat` |Georgian VAT | + * |Germany |`eu_vat` |European VAT Number | + * |Greece |`eu_vat` |European VAT Number | + * |Hong Kong |`hk_br` |Hong Kong BR Number | + * |Hungary |`eu_vat` |European VAT Number | + * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | + * |Iceland |`is_vat` |Icelandic VAT | + * |India |`in_gst` |Indian GST Number | + * |Indonesia |`id_npwp` |Indonesian NPWP Number | + * |Ireland |`eu_vat` |European VAT Number | + * |Israel |`il_vat` |Israel VAT | + * |Italy |`eu_vat` |European VAT Number | + * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | + * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | + * |Latvia |`eu_vat` |European VAT Number | + * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | + * |Mexico |`mx_rfc` |Mexican RFC Number | + * |Netherlands |`eu_vat` |European VAT Number | + * |New Zealand |`nz_gst` |New Zealand GST Number | + * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | + * |Norway |`no_vat` |Norwegian VAT Number | + * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | + * |Oman |`om_vat` |Omani VAT Number | + * |Peru |`pe_ruc` |Peruvian RUC Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Poland |`eu_vat` |European VAT Number | + * |Portugal |`eu_vat` |European VAT Number | + * |Romania |`eu_vat` |European VAT Number | + * |Romania |`ro_tin` |Romanian Tax ID Number | + * |Russia |`ru_inn` |Russian INN | + * |Russia |`ru_kpp` |Russian KPP | + * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | + * |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 | + * |Sweden |`eu_vat` |European VAT Number | + * |Switzerland |`ch_vat` |Switzerland VAT Number | + * |Taiwan |`tw_vat` |Taiwanese VAT | + * |Thailand |`th_vat` |Thai VAT | + * |Turkey |`tr_tin` |Turkish Tax Identification Number | + * |Ukraine |`ua_vat` |Ukrainian VAT | + * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | + * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | + * |United Kingdom |`gb_vat` |United Kingdom VAT Number | + * |United States |`us_ein` |United States EIN | + * |Uruguay |`uy_ruc` |Uruguayan RUC Number | + * |Venezuela |`ve_rif` |Venezuelan RIF Number | + * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + */ + fun taxId(taxId: CustomerTaxIdModel?) = taxId(JsonField.ofNullable(taxId)) + + /** + * 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 | + * |--------------------|------------|-------------------------------------------------------------------------------------------------------| + * |Andorra |`ad_nrt` |Andorran NRT Number | + * |Argentina |`ar_cuit` |Argentinian Tax ID Number | + * |Australia |`au_abn` |Australian Business Number (AU ABN) | + * |Australia |`au_arn` |Australian Taxation Office Reference Number | + * |Austria |`eu_vat` |European VAT Number | + * |Bahrain |`bh_vat` |Bahraini VAT Number | + * |Belgium |`eu_vat` |European VAT Number | + * |Bolivia |`bo_tin` |Bolivian Tax ID | + * |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 | + * |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) | + * |Chile |`cl_tin` |Chilean TIN | + * |China |`cn_tin` |Chinese Tax ID | + * |Colombia |`co_nit` |Colombian NIT Number | + * |Costa Rica |`cr_tin` |Costa Rican Tax ID | + * |Croatia |`eu_vat` |European VAT Number | + * |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 | + * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Finland |`eu_vat` |European VAT Number | + * |France |`eu_vat` |European VAT Number | + * |Georgia |`ge_vat` |Georgian VAT | + * |Germany |`eu_vat` |European VAT Number | + * |Greece |`eu_vat` |European VAT Number | + * |Hong Kong |`hk_br` |Hong Kong BR Number | + * |Hungary |`eu_vat` |European VAT Number | + * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | + * |Iceland |`is_vat` |Icelandic VAT | + * |India |`in_gst` |Indian GST Number | + * |Indonesia |`id_npwp` |Indonesian NPWP Number | + * |Ireland |`eu_vat` |European VAT Number | + * |Israel |`il_vat` |Israel VAT | + * |Italy |`eu_vat` |European VAT Number | + * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | + * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | + * |Latvia |`eu_vat` |European VAT Number | + * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | + * |Mexico |`mx_rfc` |Mexican RFC Number | + * |Netherlands |`eu_vat` |European VAT Number | + * |New Zealand |`nz_gst` |New Zealand GST Number | + * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | + * |Norway |`no_vat` |Norwegian VAT Number | + * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | + * |Oman |`om_vat` |Omani VAT Number | + * |Peru |`pe_ruc` |Peruvian RUC Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Poland |`eu_vat` |European VAT Number | + * |Portugal |`eu_vat` |European VAT Number | + * |Romania |`eu_vat` |European VAT Number | + * |Romania |`ro_tin` |Romanian Tax ID Number | + * |Russia |`ru_inn` |Russian INN | + * |Russia |`ru_kpp` |Russian KPP | + * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | + * |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 | + * |Sweden |`eu_vat` |European VAT Number | + * |Switzerland |`ch_vat` |Switzerland VAT Number | + * |Taiwan |`tw_vat` |Taiwanese VAT | + * |Thailand |`th_vat` |Thai VAT | + * |Turkey |`tr_tin` |Turkish Tax Identification Number | + * |Ukraine |`ua_vat` |Ukrainian VAT | + * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | + * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | + * |United Kingdom |`gb_vat` |United Kingdom VAT Number | + * |United States |`us_ein` |United States EIN | + * |Uruguay |`uy_ruc` |Uruguayan RUC Number | + * |Venezuela |`ve_rif` |Venezuelan RIF Number | + * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + */ + fun taxId(taxId: Optional) = taxId(taxId.orElse(null)) + + /** + * 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 | + * |--------------------|------------|-------------------------------------------------------------------------------------------------------| + * |Andorra |`ad_nrt` |Andorran NRT Number | + * |Argentina |`ar_cuit` |Argentinian Tax ID Number | + * |Australia |`au_abn` |Australian Business Number (AU ABN) | + * |Australia |`au_arn` |Australian Taxation Office Reference Number | + * |Austria |`eu_vat` |European VAT Number | + * |Bahrain |`bh_vat` |Bahraini VAT Number | + * |Belgium |`eu_vat` |European VAT Number | + * |Bolivia |`bo_tin` |Bolivian Tax ID | + * |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 | + * |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) | + * |Chile |`cl_tin` |Chilean TIN | + * |China |`cn_tin` |Chinese Tax ID | + * |Colombia |`co_nit` |Colombian NIT Number | + * |Costa Rica |`cr_tin` |Costa Rican Tax ID | + * |Croatia |`eu_vat` |European VAT Number | + * |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 | + * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Finland |`eu_vat` |European VAT Number | + * |France |`eu_vat` |European VAT Number | + * |Georgia |`ge_vat` |Georgian VAT | + * |Germany |`eu_vat` |European VAT Number | + * |Greece |`eu_vat` |European VAT Number | + * |Hong Kong |`hk_br` |Hong Kong BR Number | + * |Hungary |`eu_vat` |European VAT Number | + * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | + * |Iceland |`is_vat` |Icelandic VAT | + * |India |`in_gst` |Indian GST Number | + * |Indonesia |`id_npwp` |Indonesian NPWP Number | + * |Ireland |`eu_vat` |European VAT Number | + * |Israel |`il_vat` |Israel VAT | + * |Italy |`eu_vat` |European VAT Number | + * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | + * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | + * |Latvia |`eu_vat` |European VAT Number | + * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | + * |Mexico |`mx_rfc` |Mexican RFC Number | + * |Netherlands |`eu_vat` |European VAT Number | + * |New Zealand |`nz_gst` |New Zealand GST Number | + * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | + * |Norway |`no_vat` |Norwegian VAT Number | + * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | + * |Oman |`om_vat` |Omani VAT Number | + * |Peru |`pe_ruc` |Peruvian RUC Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Poland |`eu_vat` |European VAT Number | + * |Portugal |`eu_vat` |European VAT Number | + * |Romania |`eu_vat` |European VAT Number | + * |Romania |`ro_tin` |Romanian Tax ID Number | + * |Russia |`ru_inn` |Russian INN | + * |Russia |`ru_kpp` |Russian KPP | + * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | + * |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 | + * |Sweden |`eu_vat` |European VAT Number | + * |Switzerland |`ch_vat` |Switzerland VAT Number | + * |Taiwan |`tw_vat` |Taiwanese VAT | + * |Thailand |`th_vat` |Thai VAT | + * |Turkey |`tr_tin` |Turkish Tax Identification Number | + * |Ukraine |`ua_vat` |Ukrainian VAT | + * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | + * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | + * |United Kingdom |`gb_vat` |United Kingdom VAT Number | + * |United States |`us_ein` |United States EIN | + * |Uruguay |`uy_ruc` |Uruguayan RUC Number | + * |Venezuela |`ve_rif` |Venezuelan RIF Number | + * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + */ + fun taxId(taxId: JsonField) = apply { this.taxId = taxId } + + /** + * A timezone identifier from the IANA timezone database, such as "America/Los_Angeles". + * This "defaults to your account's timezone if not set. This cannot be changed after + * customer creation. + */ + fun timezone(timezone: String) = timezone(JsonField.of(timezone)) + + /** + * A timezone identifier from the IANA timezone database, such as "America/Los_Angeles". + * This "defaults to your account's timezone if not set. This cannot be changed after + * customer creation. + */ + fun timezone(timezone: JsonField) = apply { this.timezone = timezone } + + fun accountingSyncConfiguration(accountingSyncConfiguration: AccountingSyncConfiguration?) = + accountingSyncConfiguration(JsonField.ofNullable(accountingSyncConfiguration)) + + fun accountingSyncConfiguration( + accountingSyncConfiguration: Optional + ) = accountingSyncConfiguration(accountingSyncConfiguration.orElse(null)) + + fun accountingSyncConfiguration( + accountingSyncConfiguration: JsonField + ) = apply { this.accountingSyncConfiguration = accountingSyncConfiguration } + + fun reportingConfiguration(reportingConfiguration: ReportingConfiguration?) = + reportingConfiguration(JsonField.ofNullable(reportingConfiguration)) + + fun reportingConfiguration(reportingConfiguration: Optional) = + reportingConfiguration(reportingConfiguration.orElse(null)) + + fun reportingConfiguration(reportingConfiguration: JsonField) = + apply { + this.reportingConfiguration = reportingConfiguration + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): CustomerModel = + CustomerModel( + checkRequired("id", id), + checkRequired("additionalEmails", additionalEmails).map { it.toImmutable() }, + checkRequired("autoCollection", autoCollection), + checkRequired("balance", balance), + checkRequired("billingAddress", billingAddress), + checkRequired("createdAt", createdAt), + checkRequired("currency", currency), + checkRequired("email", email), + checkRequired("emailDelivery", emailDelivery), + checkRequired("exemptFromAutomatedTax", exemptFromAutomatedTax), + checkRequired("externalCustomerId", externalCustomerId), + checkRequired("hierarchy", hierarchy), + checkRequired("metadata", metadata), + checkRequired("name", name), + checkRequired("paymentProvider", paymentProvider), + checkRequired("paymentProviderId", paymentProviderId), + checkRequired("portalUrl", portalUrl), + checkRequired("shippingAddress", shippingAddress), + checkRequired("taxId", taxId), + checkRequired("timezone", timezone), + accountingSyncConfiguration, + reportingConfiguration, + additionalProperties.toImmutable(), + ) + } + + /** The hierarchical relationships for this customer. */ + @NoAutoDetect + class Hierarchy + @JsonCreator + private constructor( + @JsonProperty("children") + @ExcludeMissing + private val children: JsonField> = JsonMissing.of(), + @JsonProperty("parent") + @ExcludeMissing + private val parent: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun children(): List = children.getRequired("children") + + fun parent(): Optional = + Optional.ofNullable(parent.getNullable("parent")) + + @JsonProperty("children") + @ExcludeMissing + fun _children(): JsonField> = children + + @JsonProperty("parent") + @ExcludeMissing + fun _parent(): JsonField = parent + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Hierarchy = apply { + if (validated) { + return@apply + } + + children().forEach { it.validate() } + parent().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Hierarchy]. + * + * The following fields are required: + * ```java + * .children() + * .parent() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Hierarchy]. */ + class Builder internal constructor() { + + private var children: JsonField>? = null + private var parent: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(hierarchy: Hierarchy) = apply { + children = hierarchy.children.map { it.toMutableList() } + parent = hierarchy.parent + additionalProperties = hierarchy.additionalProperties.toMutableMap() + } + + fun children(children: List) = children(JsonField.of(children)) + + fun children(children: JsonField>) = apply { + this.children = children.map { it.toMutableList() } + } + + fun addChild(child: CustomerMinifiedModel) = apply { + children = + (children ?: JsonField.of(mutableListOf())).also { + checkKnown("children", it).add(child) + } + } + + fun parent(parent: CustomerMinifiedModel?) = parent(JsonField.ofNullable(parent)) + + fun parent(parent: Optional) = parent(parent.orElse(null)) + + fun parent(parent: JsonField) = apply { this.parent = parent } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): Hierarchy = + Hierarchy( + checkRequired("children", children).map { it.toImmutable() }, + checkRequired("parent", parent), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Hierarchy && children == other.children && parent == other.parent && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(children, parent, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Hierarchy{children=$children, parent=$parent, 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`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + /** + * This is used for creating charges or invoices in an external system via Orb. When not in test + * mode, the connection must first be configured in the Orb webapp. + */ + 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 QUICKBOOKS = of("quickbooks") + + @JvmField val BILL_COM = of("bill.com") + + @JvmField val STRIPE_CHARGE = of("stripe_charge") + + @JvmField val STRIPE_INVOICE = of("stripe_invoice") + + @JvmField val NETSUITE = of("netsuite") + + @JvmStatic fun of(value: String) = PaymentProvider(JsonField.of(value)) + } + + /** An enum containing [PaymentProvider]'s known values. */ + enum class Known { + QUICKBOOKS, + BILL_COM, + STRIPE_CHARGE, + STRIPE_INVOICE, + NETSUITE, + } + + /** + * 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 { + QUICKBOOKS, + BILL_COM, + STRIPE_CHARGE, + STRIPE_INVOICE, + NETSUITE, + /** + * 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) { + QUICKBOOKS -> Value.QUICKBOOKS + BILL_COM -> Value.BILL_COM + STRIPE_CHARGE -> Value.STRIPE_CHARGE + STRIPE_INVOICE -> Value.STRIPE_INVOICE + 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 + BILL_COM -> Known.BILL_COM + STRIPE_CHARGE -> Known.STRIPE_CHARGE + STRIPE_INVOICE -> Known.STRIPE_INVOICE + NETSUITE -> Known.NETSUITE + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PaymentProvider && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + @NoAutoDetect + class AccountingSyncConfiguration + @JsonCreator + private constructor( + @JsonProperty("accounting_providers") + @ExcludeMissing + private val accountingProviders: JsonField> = JsonMissing.of(), + @JsonProperty("excluded") + @ExcludeMissing + private val excluded: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun accountingProviders(): List = + accountingProviders.getRequired("accounting_providers") + + fun excluded(): Boolean = excluded.getRequired("excluded") + + @JsonProperty("accounting_providers") + @ExcludeMissing + fun _accountingProviders(): JsonField> = accountingProviders + + @JsonProperty("excluded") @ExcludeMissing fun _excluded(): JsonField = excluded + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): AccountingSyncConfiguration = apply { + if (validated) { + return@apply + } + + accountingProviders().forEach { it.validate() } + excluded() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AccountingSyncConfiguration]. + * + * The following fields are required: + * ```java + * .accountingProviders() + * .excluded() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AccountingSyncConfiguration]. */ + class Builder internal constructor() { + + private var accountingProviders: JsonField>? = null + private var excluded: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(accountingSyncConfiguration: AccountingSyncConfiguration) = apply { + accountingProviders = + accountingSyncConfiguration.accountingProviders.map { it.toMutableList() } + excluded = accountingSyncConfiguration.excluded + additionalProperties = + accountingSyncConfiguration.additionalProperties.toMutableMap() + } + + fun accountingProviders(accountingProviders: List) = + accountingProviders(JsonField.of(accountingProviders)) + + fun accountingProviders(accountingProviders: JsonField>) = + apply { + this.accountingProviders = accountingProviders.map { it.toMutableList() } + } + + fun addAccountingProvider(accountingProvider: AccountingProvider) = apply { + accountingProviders = + (accountingProviders ?: JsonField.of(mutableListOf())).also { + checkKnown("accountingProviders", it).add(accountingProvider) + } + } + + fun excluded(excluded: Boolean) = excluded(JsonField.of(excluded)) + + fun excluded(excluded: JsonField) = apply { this.excluded = excluded } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): AccountingSyncConfiguration = + AccountingSyncConfiguration( + checkRequired("accountingProviders", accountingProviders).map { + it.toImmutable() + }, + checkRequired("excluded", excluded), + additionalProperties.toImmutable(), + ) + } + + @NoAutoDetect + class AccountingProvider + @JsonCreator + private constructor( + @JsonProperty("external_provider_id") + @ExcludeMissing + private val externalProviderId: JsonField = JsonMissing.of(), + @JsonProperty("provider_type") + @ExcludeMissing + private val providerType: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun externalProviderId(): Optional = + Optional.ofNullable(externalProviderId.getNullable("external_provider_id")) + + fun providerType(): ProviderType = providerType.getRequired("provider_type") + + @JsonProperty("external_provider_id") + @ExcludeMissing + fun _externalProviderId(): JsonField = externalProviderId + + @JsonProperty("provider_type") + @ExcludeMissing + fun _providerType(): JsonField = providerType + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): AccountingProvider = apply { + if (validated) { + return@apply + } + + externalProviderId() + providerType() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AccountingProvider]. + * + * The following fields are required: + * ```java + * .externalProviderId() + * .providerType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AccountingProvider]. */ + class Builder internal constructor() { + + private var externalProviderId: JsonField? = null + private var providerType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(accountingProvider: AccountingProvider) = apply { + externalProviderId = accountingProvider.externalProviderId + providerType = accountingProvider.providerType + additionalProperties = accountingProvider.additionalProperties.toMutableMap() + } + + fun externalProviderId(externalProviderId: String?) = + externalProviderId(JsonField.ofNullable(externalProviderId)) + + fun externalProviderId(externalProviderId: Optional) = + externalProviderId(externalProviderId.orElse(null)) + + fun externalProviderId(externalProviderId: JsonField) = apply { + this.externalProviderId = externalProviderId + } + + fun providerType(providerType: ProviderType) = + providerType(JsonField.of(providerType)) + + fun providerType(providerType: JsonField) = apply { + this.providerType = providerType + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): AccountingProvider = + AccountingProvider( + checkRequired("externalProviderId", externalProviderId), + checkRequired("providerType", providerType), + additionalProperties.toImmutable(), + ) + } + + 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") + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProviderType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AccountingProvider && externalProviderId == other.externalProviderId && providerType == other.providerType && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(externalProviderId, providerType, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AccountingProvider{externalProviderId=$externalProviderId, providerType=$providerType, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AccountingSyncConfiguration && accountingProviders == other.accountingProviders && excluded == other.excluded && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(accountingProviders, excluded, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AccountingSyncConfiguration{accountingProviders=$accountingProviders, excluded=$excluded, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class ReportingConfiguration + @JsonCreator + private constructor( + @JsonProperty("exempt") + @ExcludeMissing + private val exempt: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun exempt(): Boolean = exempt.getRequired("exempt") + + @JsonProperty("exempt") @ExcludeMissing fun _exempt(): JsonField = exempt + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): ReportingConfiguration = apply { + if (validated) { + return@apply + } + + exempt() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ReportingConfiguration]. + * + * The following fields are required: + * ```java + * .exempt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ReportingConfiguration]. */ + class Builder internal constructor() { + + private var exempt: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(reportingConfiguration: ReportingConfiguration) = apply { + exempt = reportingConfiguration.exempt + additionalProperties = reportingConfiguration.additionalProperties.toMutableMap() + } + + fun exempt(exempt: Boolean) = exempt(JsonField.of(exempt)) + + fun exempt(exempt: JsonField) = apply { this.exempt = exempt } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): ReportingConfiguration = + ReportingConfiguration( + checkRequired("exempt", exempt), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ReportingConfiguration && exempt == other.exempt && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(exempt, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReportingConfiguration{exempt=$exempt, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CustomerModel && id == other.id && additionalEmails == other.additionalEmails && autoCollection == other.autoCollection && balance == other.balance && billingAddress == other.billingAddress && createdAt == other.createdAt && currency == other.currency && email == other.email && emailDelivery == other.emailDelivery && exemptFromAutomatedTax == other.exemptFromAutomatedTax && externalCustomerId == other.externalCustomerId && hierarchy == other.hierarchy && metadata == other.metadata && name == other.name && paymentProvider == other.paymentProvider && paymentProviderId == other.paymentProviderId && portalUrl == other.portalUrl && shippingAddress == other.shippingAddress && taxId == other.taxId && timezone == other.timezone && accountingSyncConfiguration == other.accountingSyncConfiguration && reportingConfiguration == other.reportingConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, additionalEmails, autoCollection, balance, billingAddress, createdAt, currency, email, emailDelivery, exemptFromAutomatedTax, externalCustomerId, hierarchy, metadata, name, paymentProvider, paymentProviderId, portalUrl, shippingAddress, taxId, timezone, accountingSyncConfiguration, reportingConfiguration, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomerModel{id=$id, additionalEmails=$additionalEmails, autoCollection=$autoCollection, balance=$balance, billingAddress=$billingAddress, createdAt=$createdAt, currency=$currency, email=$email, emailDelivery=$emailDelivery, exemptFromAutomatedTax=$exemptFromAutomatedTax, externalCustomerId=$externalCustomerId, hierarchy=$hierarchy, metadata=$metadata, name=$name, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, portalUrl=$portalUrl, shippingAddress=$shippingAddress, taxId=$taxId, timezone=$timezone, accountingSyncConfiguration=$accountingSyncConfiguration, reportingConfiguration=$reportingConfiguration, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams.kt index 6669ce437..7d7111556 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams.kt @@ -55,6 +55,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams]. + * + * The following fields are required: + * ```java + * .customerId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerSyncPaymentMethodsFromGatewayParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerSyncPaymentMethodsFromGatewayParams.kt index b3941ca2a..01661d6c1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerSyncPaymentMethodsFromGatewayParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerSyncPaymentMethodsFromGatewayParams.kt @@ -55,6 +55,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [CustomerSyncPaymentMethodsFromGatewayParams]. + * + * The following fields are required: + * ```java + * .externalCustomerId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerTaxIdModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerTaxIdModel.kt new file mode 100644 index 000000000..7d299442c --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerTaxIdModel.kt @@ -0,0 +1,1321 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Objects + +/** + * 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 | + * |--------------------|------------|-------------------------------------------------------------------------------------------------------| + * |Andorra |`ad_nrt` |Andorran NRT Number | + * |Argentina |`ar_cuit` |Argentinian Tax ID Number | + * |Australia |`au_abn` |Australian Business Number (AU ABN) | + * |Australia |`au_arn` |Australian Taxation Office Reference Number | + * |Austria |`eu_vat` |European VAT Number | + * |Bahrain |`bh_vat` |Bahraini VAT Number | + * |Belgium |`eu_vat` |European VAT Number | + * |Bolivia |`bo_tin` |Bolivian Tax ID | + * |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 | + * |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) | + * |Chile |`cl_tin` |Chilean TIN | + * |China |`cn_tin` |Chinese Tax ID | + * |Colombia |`co_nit` |Colombian NIT Number | + * |Costa Rica |`cr_tin` |Costa Rican Tax ID | + * |Croatia |`eu_vat` |European VAT Number | + * |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 | + * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Finland |`eu_vat` |European VAT Number | + * |France |`eu_vat` |European VAT Number | + * |Georgia |`ge_vat` |Georgian VAT | + * |Germany |`eu_vat` |European VAT Number | + * |Greece |`eu_vat` |European VAT Number | + * |Hong Kong |`hk_br` |Hong Kong BR Number | + * |Hungary |`eu_vat` |European VAT Number | + * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | + * |Iceland |`is_vat` |Icelandic VAT | + * |India |`in_gst` |Indian GST Number | + * |Indonesia |`id_npwp` |Indonesian NPWP Number | + * |Ireland |`eu_vat` |European VAT Number | + * |Israel |`il_vat` |Israel VAT | + * |Italy |`eu_vat` |European VAT Number | + * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | + * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | + * |Latvia |`eu_vat` |European VAT Number | + * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | + * |Mexico |`mx_rfc` |Mexican RFC Number | + * |Netherlands |`eu_vat` |European VAT Number | + * |New Zealand |`nz_gst` |New Zealand GST Number | + * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | + * |Norway |`no_vat` |Norwegian VAT Number | + * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | + * |Oman |`om_vat` |Omani VAT Number | + * |Peru |`pe_ruc` |Peruvian RUC Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Poland |`eu_vat` |European VAT Number | + * |Portugal |`eu_vat` |European VAT Number | + * |Romania |`eu_vat` |European VAT Number | + * |Romania |`ro_tin` |Romanian Tax ID Number | + * |Russia |`ru_inn` |Russian INN | + * |Russia |`ru_kpp` |Russian KPP | + * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | + * |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 | + * |Sweden |`eu_vat` |European VAT Number | + * |Switzerland |`ch_vat` |Switzerland VAT Number | + * |Taiwan |`tw_vat` |Taiwanese VAT | + * |Thailand |`th_vat` |Thai VAT | + * |Turkey |`tr_tin` |Turkish Tax Identification Number | + * |Ukraine |`ua_vat` |Ukrainian VAT | + * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | + * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | + * |United Kingdom |`gb_vat` |United Kingdom VAT Number | + * |United States |`us_ein` |United States EIN | + * |Uruguay |`uy_ruc` |Uruguayan RUC Number | + * |Venezuela |`ve_rif` |Venezuelan RIF Number | + * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + */ +@NoAutoDetect +class CustomerTaxIdModel +@JsonCreator +private constructor( + @JsonProperty("country") + @ExcludeMissing + private val country: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing private val value: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun country(): Country = country.getRequired("country") + + fun type(): Type = type.getRequired("type") + + fun value(): String = value.getRequired("value") + + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country + + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): CustomerTaxIdModel = apply { + if (validated) { + return@apply + } + + country() + type() + value() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CustomerTaxIdModel]. + * + * The following fields are required: + * ```java + * .country() + * .type() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomerTaxIdModel]. */ + class Builder internal constructor() { + + private var country: JsonField? = null + private var type: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(customerTaxIdModel: CustomerTaxIdModel) = apply { + country = customerTaxIdModel.country + type = customerTaxIdModel.type + value = customerTaxIdModel.value + additionalProperties = customerTaxIdModel.additionalProperties.toMutableMap() + } + + fun country(country: Country) = country(JsonField.of(country)) + + fun country(country: JsonField) = apply { this.country = country } + + fun type(type: Type) = type(JsonField.of(type)) + + fun type(type: JsonField) = apply { this.type = type } + + fun value(value: String) = value(JsonField.of(value)) + + fun value(value: JsonField) = apply { this.value = 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) + } + + fun build(): CustomerTaxIdModel = + CustomerTaxIdModel( + checkRequired("country", country), + checkRequired("type", type), + checkRequired("value", value), + additionalProperties.toImmutable(), + ) + } + + class Country @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val AD = of("AD") + + @JvmField val AE = of("AE") + + @JvmField val AR = of("AR") + + @JvmField val AT = of("AT") + + @JvmField val AU = of("AU") + + @JvmField val BE = of("BE") + + @JvmField val BG = of("BG") + + @JvmField val BH = of("BH") + + @JvmField val BO = of("BO") + + @JvmField val BR = of("BR") + + @JvmField val CA = of("CA") + + @JvmField val CH = of("CH") + + @JvmField val CL = of("CL") + + @JvmField val CN = of("CN") + + @JvmField val CO = of("CO") + + @JvmField val CR = of("CR") + + @JvmField val CY = of("CY") + + @JvmField val CZ = of("CZ") + + @JvmField val DE = of("DE") + + @JvmField val DK = of("DK") + + @JvmField val EE = of("EE") + + @JvmField val DO = of("DO") + + @JvmField val EC = of("EC") + + @JvmField val EG = of("EG") + + @JvmField val ES = of("ES") + + @JvmField val EU = of("EU") + + @JvmField val FI = of("FI") + + @JvmField val FR = of("FR") + + @JvmField val GB = of("GB") + + @JvmField val GE = of("GE") + + @JvmField val GR = of("GR") + + @JvmField val HK = of("HK") + + @JvmField val HR = of("HR") + + @JvmField val HU = of("HU") + + @JvmField val ID = of("ID") + + @JvmField val IE = of("IE") + + @JvmField val IL = of("IL") + + @JvmField val IN = of("IN") + + @JvmField val IS = of("IS") + + @JvmField val IT = of("IT") + + @JvmField val JP = of("JP") + + @JvmField val KE = of("KE") + + @JvmField val KR = of("KR") + + @JvmField val KZ = of("KZ") + + @JvmField val LI = of("LI") + + @JvmField val LT = of("LT") + + @JvmField val LU = of("LU") + + @JvmField val LV = of("LV") + + @JvmField val MT = of("MT") + + @JvmField val MX = of("MX") + + @JvmField val MY = of("MY") + + @JvmField val NG = of("NG") + + @JvmField val NL = of("NL") + + @JvmField val NO = of("NO") + + @JvmField val NZ = of("NZ") + + @JvmField val OM = of("OM") + + @JvmField val PE = of("PE") + + @JvmField val PH = of("PH") + + @JvmField val PL = of("PL") + + @JvmField val PT = of("PT") + + @JvmField val RO = of("RO") + + @JvmField val RS = of("RS") + + @JvmField val RU = of("RU") + + @JvmField val SA = of("SA") + + @JvmField val SE = of("SE") + + @JvmField val SG = of("SG") + + @JvmField val SI = of("SI") + + @JvmField val SK = of("SK") + + @JvmField val SV = of("SV") + + @JvmField val TH = of("TH") + + @JvmField val TR = of("TR") + + @JvmField val TW = of("TW") + + @JvmField val UA = of("UA") + + @JvmField val US = of("US") + + @JvmField val UY = of("UY") + + @JvmField val VE = of("VE") + + @JvmField val VN = of("VN") + + @JvmField val ZA = of("ZA") + + @JvmStatic fun of(value: String) = Country(JsonField.of(value)) + } + + /** An enum containing [Country]'s known values. */ + enum class Known { + AD, + AE, + AR, + AT, + AU, + BE, + BG, + BH, + BO, + BR, + CA, + CH, + CL, + CN, + CO, + CR, + CY, + CZ, + DE, + DK, + EE, + DO, + EC, + EG, + ES, + EU, + FI, + FR, + GB, + GE, + GR, + HK, + HR, + HU, + ID, + IE, + IL, + IN, + IS, + IT, + JP, + KE, + KR, + KZ, + LI, + LT, + LU, + LV, + MT, + MX, + MY, + NG, + NL, + NO, + NZ, + OM, + PE, + PH, + PL, + PT, + RO, + RS, + RU, + SA, + SE, + SG, + SI, + SK, + SV, + TH, + TR, + TW, + UA, + US, + UY, + VE, + VN, + ZA, + } + + /** + * An enum containing [Country]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Country] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AD, + AE, + AR, + AT, + AU, + BE, + BG, + BH, + BO, + BR, + CA, + CH, + CL, + CN, + CO, + CR, + CY, + CZ, + DE, + DK, + EE, + DO, + EC, + EG, + ES, + EU, + FI, + FR, + GB, + GE, + GR, + HK, + HR, + HU, + ID, + IE, + IL, + IN, + IS, + IT, + JP, + KE, + KR, + KZ, + LI, + LT, + LU, + LV, + MT, + MX, + MY, + NG, + NL, + NO, + NZ, + OM, + PE, + PH, + PL, + PT, + RO, + RS, + RU, + SA, + SE, + SG, + SI, + SK, + SV, + TH, + TR, + TW, + UA, + US, + UY, + VE, + VN, + ZA, + /** An enum member indicating that [Country] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AD -> Value.AD + AE -> Value.AE + AR -> Value.AR + AT -> Value.AT + AU -> Value.AU + BE -> Value.BE + BG -> Value.BG + BH -> Value.BH + BO -> Value.BO + BR -> Value.BR + CA -> Value.CA + CH -> Value.CH + CL -> Value.CL + CN -> Value.CN + CO -> Value.CO + CR -> Value.CR + CY -> Value.CY + CZ -> Value.CZ + DE -> Value.DE + DK -> Value.DK + EE -> Value.EE + DO -> Value.DO + EC -> Value.EC + EG -> Value.EG + ES -> Value.ES + EU -> Value.EU + FI -> Value.FI + FR -> Value.FR + GB -> Value.GB + GE -> Value.GE + GR -> Value.GR + HK -> Value.HK + HR -> Value.HR + HU -> Value.HU + ID -> Value.ID + IE -> Value.IE + IL -> Value.IL + IN -> Value.IN + IS -> Value.IS + IT -> Value.IT + JP -> Value.JP + KE -> Value.KE + KR -> Value.KR + KZ -> Value.KZ + LI -> Value.LI + LT -> Value.LT + LU -> Value.LU + LV -> Value.LV + MT -> Value.MT + MX -> Value.MX + MY -> Value.MY + NG -> Value.NG + NL -> Value.NL + NO -> Value.NO + NZ -> Value.NZ + OM -> Value.OM + PE -> Value.PE + PH -> Value.PH + PL -> Value.PL + PT -> Value.PT + RO -> Value.RO + RS -> Value.RS + RU -> Value.RU + SA -> Value.SA + SE -> Value.SE + SG -> Value.SG + SI -> Value.SI + SK -> Value.SK + SV -> Value.SV + TH -> Value.TH + TR -> Value.TR + TW -> Value.TW + UA -> Value.UA + US -> Value.US + UY -> Value.UY + VE -> Value.VE + VN -> Value.VN + ZA -> Value.ZA + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + AD -> Known.AD + AE -> Known.AE + AR -> Known.AR + AT -> Known.AT + AU -> Known.AU + BE -> Known.BE + BG -> Known.BG + BH -> Known.BH + BO -> Known.BO + BR -> Known.BR + CA -> Known.CA + CH -> Known.CH + CL -> Known.CL + CN -> Known.CN + CO -> Known.CO + CR -> Known.CR + CY -> Known.CY + CZ -> Known.CZ + DE -> Known.DE + DK -> Known.DK + EE -> Known.EE + DO -> Known.DO + EC -> Known.EC + EG -> Known.EG + ES -> Known.ES + EU -> Known.EU + FI -> Known.FI + FR -> Known.FR + GB -> Known.GB + GE -> Known.GE + GR -> Known.GR + HK -> Known.HK + HR -> Known.HR + HU -> Known.HU + ID -> Known.ID + IE -> Known.IE + IL -> Known.IL + IN -> Known.IN + IS -> Known.IS + IT -> Known.IT + JP -> Known.JP + KE -> Known.KE + KR -> Known.KR + KZ -> Known.KZ + LI -> Known.LI + LT -> Known.LT + LU -> Known.LU + LV -> Known.LV + MT -> Known.MT + MX -> Known.MX + MY -> Known.MY + NG -> Known.NG + NL -> Known.NL + NO -> Known.NO + NZ -> Known.NZ + OM -> Known.OM + PE -> Known.PE + PH -> Known.PH + PL -> Known.PL + PT -> Known.PT + RO -> Known.RO + RS -> Known.RS + RU -> Known.RU + SA -> Known.SA + SE -> Known.SE + SG -> Known.SG + SI -> Known.SI + SK -> Known.SK + SV -> Known.SV + TH -> Known.TH + TR -> Known.TR + TW -> Known.TW + UA -> Known.UA + US -> Known.US + UY -> Known.UY + VE -> Known.VE + VN -> Known.VN + ZA -> Known.ZA + else -> throw OrbInvalidDataException("Unknown Country: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if 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 + } + + return /* spotless:off */ other is Country && value == other.value /* spotless:on */ + } + + 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 AD_NRT = of("ad_nrt") + + @JvmField val AE_TRN = of("ae_trn") + + @JvmField val AR_CUIT = of("ar_cuit") + + @JvmField val EU_VAT = of("eu_vat") + + @JvmField val AU_ABN = of("au_abn") + + @JvmField val AU_ARN = of("au_arn") + + @JvmField val BG_UIC = of("bg_uic") + + @JvmField val BH_VAT = of("bh_vat") + + @JvmField val BO_TIN = of("bo_tin") + + @JvmField val BR_CNPJ = of("br_cnpj") + + @JvmField val BR_CPF = of("br_cpf") + + @JvmField val CA_BN = of("ca_bn") + + @JvmField val CA_GST_HST = of("ca_gst_hst") + + @JvmField val CA_PST_BC = of("ca_pst_bc") + + @JvmField val CA_PST_MB = of("ca_pst_mb") + + @JvmField val CA_PST_SK = of("ca_pst_sk") + + @JvmField val CA_QST = of("ca_qst") + + @JvmField val CH_VAT = of("ch_vat") + + @JvmField val CL_TIN = of("cl_tin") + + @JvmField val CN_TIN = of("cn_tin") + + @JvmField val CO_NIT = of("co_nit") + + @JvmField val CR_TIN = of("cr_tin") + + @JvmField val DO_RCN = of("do_rcn") + + @JvmField val EC_RUC = of("ec_ruc") + + @JvmField val EG_TIN = of("eg_tin") + + @JvmField val ES_CIF = of("es_cif") + + @JvmField val EU_OSS_VAT = of("eu_oss_vat") + + @JvmField val GB_VAT = of("gb_vat") + + @JvmField val GE_VAT = of("ge_vat") + + @JvmField val HK_BR = of("hk_br") + + @JvmField val HU_TIN = of("hu_tin") + + @JvmField val ID_NPWP = of("id_npwp") + + @JvmField val IL_VAT = of("il_vat") + + @JvmField val IN_GST = of("in_gst") + + @JvmField val IS_VAT = of("is_vat") + + @JvmField val JP_CN = of("jp_cn") + + @JvmField val JP_RN = of("jp_rn") + + @JvmField val JP_TRN = of("jp_trn") + + @JvmField val KE_PIN = of("ke_pin") + + @JvmField val KR_BRN = of("kr_brn") + + @JvmField val KZ_BIN = of("kz_bin") + + @JvmField val LI_UID = of("li_uid") + + @JvmField val MX_RFC = of("mx_rfc") + + @JvmField val MY_FRP = of("my_frp") + + @JvmField val MY_ITN = of("my_itn") + + @JvmField val MY_SST = of("my_sst") + + @JvmField val NG_TIN = of("ng_tin") + + @JvmField val NO_VAT = of("no_vat") + + @JvmField val NO_VOEC = of("no_voec") + + @JvmField val NZ_GST = of("nz_gst") + + @JvmField val OM_VAT = of("om_vat") + + @JvmField val PE_RUC = of("pe_ruc") + + @JvmField val PH_TIN = of("ph_tin") + + @JvmField val RO_TIN = of("ro_tin") + + @JvmField val RS_PIB = of("rs_pib") + + @JvmField val RU_INN = of("ru_inn") + + @JvmField val RU_KPP = of("ru_kpp") + + @JvmField val SA_VAT = of("sa_vat") + + @JvmField val SG_GST = of("sg_gst") + + @JvmField val SG_UEN = of("sg_uen") + + @JvmField val SI_TIN = of("si_tin") + + @JvmField val SV_NIT = of("sv_nit") + + @JvmField val TH_VAT = of("th_vat") + + @JvmField val TR_TIN = of("tr_tin") + + @JvmField val TW_VAT = of("tw_vat") + + @JvmField val UA_VAT = of("ua_vat") + + @JvmField val US_EIN = of("us_ein") + + @JvmField val UY_RUC = of("uy_ruc") + + @JvmField val VE_RIF = of("ve_rif") + + @JvmField val VN_TIN = of("vn_tin") + + @JvmField val ZA_VAT = of("za_vat") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + AD_NRT, + AE_TRN, + AR_CUIT, + EU_VAT, + AU_ABN, + AU_ARN, + BG_UIC, + BH_VAT, + BO_TIN, + BR_CNPJ, + BR_CPF, + CA_BN, + CA_GST_HST, + CA_PST_BC, + CA_PST_MB, + CA_PST_SK, + CA_QST, + CH_VAT, + CL_TIN, + CN_TIN, + CO_NIT, + CR_TIN, + DO_RCN, + EC_RUC, + EG_TIN, + ES_CIF, + EU_OSS_VAT, + GB_VAT, + GE_VAT, + HK_BR, + HU_TIN, + ID_NPWP, + IL_VAT, + IN_GST, + IS_VAT, + JP_CN, + JP_RN, + JP_TRN, + KE_PIN, + KR_BRN, + KZ_BIN, + LI_UID, + MX_RFC, + MY_FRP, + MY_ITN, + MY_SST, + NG_TIN, + NO_VAT, + NO_VOEC, + NZ_GST, + OM_VAT, + PE_RUC, + PH_TIN, + RO_TIN, + RS_PIB, + RU_INN, + RU_KPP, + SA_VAT, + SG_GST, + SG_UEN, + SI_TIN, + SV_NIT, + TH_VAT, + TR_TIN, + TW_VAT, + UA_VAT, + US_EIN, + UY_RUC, + VE_RIF, + VN_TIN, + ZA_VAT, + } + + /** + * 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 { + AD_NRT, + AE_TRN, + AR_CUIT, + EU_VAT, + AU_ABN, + AU_ARN, + BG_UIC, + BH_VAT, + BO_TIN, + BR_CNPJ, + BR_CPF, + CA_BN, + CA_GST_HST, + CA_PST_BC, + CA_PST_MB, + CA_PST_SK, + CA_QST, + CH_VAT, + CL_TIN, + CN_TIN, + CO_NIT, + CR_TIN, + DO_RCN, + EC_RUC, + EG_TIN, + ES_CIF, + EU_OSS_VAT, + GB_VAT, + GE_VAT, + HK_BR, + HU_TIN, + ID_NPWP, + IL_VAT, + IN_GST, + IS_VAT, + JP_CN, + JP_RN, + JP_TRN, + KE_PIN, + KR_BRN, + KZ_BIN, + LI_UID, + MX_RFC, + MY_FRP, + MY_ITN, + MY_SST, + NG_TIN, + NO_VAT, + NO_VOEC, + NZ_GST, + OM_VAT, + PE_RUC, + PH_TIN, + RO_TIN, + RS_PIB, + RU_INN, + RU_KPP, + SA_VAT, + SG_GST, + SG_UEN, + SI_TIN, + SV_NIT, + TH_VAT, + TR_TIN, + TW_VAT, + UA_VAT, + US_EIN, + UY_RUC, + VE_RIF, + VN_TIN, + ZA_VAT, + /** 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) { + AD_NRT -> Value.AD_NRT + AE_TRN -> Value.AE_TRN + AR_CUIT -> Value.AR_CUIT + EU_VAT -> Value.EU_VAT + AU_ABN -> Value.AU_ABN + AU_ARN -> Value.AU_ARN + BG_UIC -> Value.BG_UIC + BH_VAT -> Value.BH_VAT + BO_TIN -> Value.BO_TIN + BR_CNPJ -> Value.BR_CNPJ + BR_CPF -> Value.BR_CPF + CA_BN -> Value.CA_BN + CA_GST_HST -> Value.CA_GST_HST + CA_PST_BC -> Value.CA_PST_BC + CA_PST_MB -> Value.CA_PST_MB + CA_PST_SK -> Value.CA_PST_SK + CA_QST -> Value.CA_QST + CH_VAT -> Value.CH_VAT + CL_TIN -> Value.CL_TIN + CN_TIN -> Value.CN_TIN + CO_NIT -> Value.CO_NIT + CR_TIN -> Value.CR_TIN + DO_RCN -> Value.DO_RCN + EC_RUC -> Value.EC_RUC + EG_TIN -> Value.EG_TIN + ES_CIF -> Value.ES_CIF + EU_OSS_VAT -> Value.EU_OSS_VAT + GB_VAT -> Value.GB_VAT + GE_VAT -> Value.GE_VAT + HK_BR -> Value.HK_BR + HU_TIN -> Value.HU_TIN + ID_NPWP -> Value.ID_NPWP + IL_VAT -> Value.IL_VAT + IN_GST -> Value.IN_GST + IS_VAT -> Value.IS_VAT + JP_CN -> Value.JP_CN + JP_RN -> Value.JP_RN + JP_TRN -> Value.JP_TRN + KE_PIN -> Value.KE_PIN + KR_BRN -> Value.KR_BRN + KZ_BIN -> Value.KZ_BIN + LI_UID -> Value.LI_UID + MX_RFC -> Value.MX_RFC + MY_FRP -> Value.MY_FRP + MY_ITN -> Value.MY_ITN + MY_SST -> Value.MY_SST + NG_TIN -> Value.NG_TIN + NO_VAT -> Value.NO_VAT + NO_VOEC -> Value.NO_VOEC + NZ_GST -> Value.NZ_GST + OM_VAT -> Value.OM_VAT + PE_RUC -> Value.PE_RUC + PH_TIN -> Value.PH_TIN + RO_TIN -> Value.RO_TIN + RS_PIB -> Value.RS_PIB + RU_INN -> Value.RU_INN + RU_KPP -> Value.RU_KPP + SA_VAT -> Value.SA_VAT + SG_GST -> Value.SG_GST + SG_UEN -> Value.SG_UEN + SI_TIN -> Value.SI_TIN + SV_NIT -> Value.SV_NIT + TH_VAT -> Value.TH_VAT + TR_TIN -> Value.TR_TIN + TW_VAT -> Value.TW_VAT + UA_VAT -> Value.UA_VAT + US_EIN -> Value.US_EIN + UY_RUC -> Value.UY_RUC + VE_RIF -> Value.VE_RIF + VN_TIN -> Value.VN_TIN + ZA_VAT -> Value.ZA_VAT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + AD_NRT -> Known.AD_NRT + AE_TRN -> Known.AE_TRN + AR_CUIT -> Known.AR_CUIT + EU_VAT -> Known.EU_VAT + AU_ABN -> Known.AU_ABN + AU_ARN -> Known.AU_ARN + BG_UIC -> Known.BG_UIC + BH_VAT -> Known.BH_VAT + BO_TIN -> Known.BO_TIN + BR_CNPJ -> Known.BR_CNPJ + BR_CPF -> Known.BR_CPF + CA_BN -> Known.CA_BN + CA_GST_HST -> Known.CA_GST_HST + CA_PST_BC -> Known.CA_PST_BC + CA_PST_MB -> Known.CA_PST_MB + CA_PST_SK -> Known.CA_PST_SK + CA_QST -> Known.CA_QST + CH_VAT -> Known.CH_VAT + CL_TIN -> Known.CL_TIN + CN_TIN -> Known.CN_TIN + CO_NIT -> Known.CO_NIT + CR_TIN -> Known.CR_TIN + DO_RCN -> Known.DO_RCN + EC_RUC -> Known.EC_RUC + EG_TIN -> Known.EG_TIN + ES_CIF -> Known.ES_CIF + EU_OSS_VAT -> Known.EU_OSS_VAT + GB_VAT -> Known.GB_VAT + GE_VAT -> Known.GE_VAT + HK_BR -> Known.HK_BR + HU_TIN -> Known.HU_TIN + ID_NPWP -> Known.ID_NPWP + IL_VAT -> Known.IL_VAT + IN_GST -> Known.IN_GST + IS_VAT -> Known.IS_VAT + JP_CN -> Known.JP_CN + JP_RN -> Known.JP_RN + JP_TRN -> Known.JP_TRN + KE_PIN -> Known.KE_PIN + KR_BRN -> Known.KR_BRN + KZ_BIN -> Known.KZ_BIN + LI_UID -> Known.LI_UID + MX_RFC -> Known.MX_RFC + MY_FRP -> Known.MY_FRP + MY_ITN -> Known.MY_ITN + MY_SST -> Known.MY_SST + NG_TIN -> Known.NG_TIN + NO_VAT -> Known.NO_VAT + NO_VOEC -> Known.NO_VOEC + NZ_GST -> Known.NZ_GST + OM_VAT -> Known.OM_VAT + PE_RUC -> Known.PE_RUC + PH_TIN -> Known.PH_TIN + RO_TIN -> Known.RO_TIN + RS_PIB -> Known.RS_PIB + RU_INN -> Known.RU_INN + RU_KPP -> Known.RU_KPP + SA_VAT -> Known.SA_VAT + SG_GST -> Known.SG_GST + SG_UEN -> Known.SG_UEN + SI_TIN -> Known.SI_TIN + SV_NIT -> Known.SV_NIT + TH_VAT -> Known.TH_VAT + TR_TIN -> Known.TR_TIN + TW_VAT -> Known.TW_VAT + UA_VAT -> Known.UA_VAT + US_EIN -> Known.US_EIN + UY_RUC -> Known.UY_RUC + VE_RIF -> Known.VE_RIF + VN_TIN -> Known.VN_TIN + ZA_VAT -> Known.ZA_VAT + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CustomerTaxIdModel && country == other.country && type == other.type && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(country, type, value, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomerTaxIdModel{country=$country, type=$type, value=$value, additionalProperties=$additionalProperties}" +} 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 a4c5441f4..63d289154 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 @@ -2,36 +2,13 @@ package com.withorb.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer -import com.withorb.api.core.Enum -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.Params import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams -import com.withorb.api.core.immutableEmptyMap -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull /** * This endpoint is used to update customer details given an `external_customer_id` (see @@ -41,375 +18,23 @@ import kotlin.jvm.optionals.getOrNull class CustomerUpdateByExternalIdParams private constructor( private val id: String, - private val body: Body, + private val editCustomerModel: EditCustomerModel, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { fun id(): String = id - fun accountingSyncConfiguration(): Optional = - body.accountingSyncConfiguration() + fun editCustomerModel(): EditCustomerModel = editCustomerModel - /** - * Additional email addresses for this customer. If populated, these email addresses will be - * CC'd for customer communications. - */ - fun additionalEmails(): Optional> = body.additionalEmails() - - /** - * Used to determine if invoices for this customer will automatically attempt to charge a saved - * payment method, if available. This parameter defaults to `True` when a payment provider is - * provided on customer creation. - */ - fun autoCollection(): Optional = body.autoCollection() - - 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. - */ - fun currency(): Optional = body.currency() - - /** A valid customer email, to be used for invoicing and notifications. */ - fun email(): Optional = body.email() - - fun emailDelivery(): Optional = body.emailDelivery() - - /** - * The external customer ID. This can only be set if empty and the customer has no past or - * current subscriptions. - */ - fun externalCustomerId(): Optional = body.externalCustomerId() - - /** The hierarchical relationships for this customer. */ - fun hierarchy(): Optional = body.hierarchy() - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - */ - fun metadata(): Optional = body.metadata() - - /** The full name of the customer */ - fun name(): Optional = body.name() - - /** - * This is used for creating charges or invoices in an external system via Orb. When not in test - * mode: - * - the connection must first be configured in the Orb webapp. - * - if the provider is an invoicing provider (`stripe_invoice`, `quickbooks`, `bill.com`, - * `netsuite`), any product mappings must first be configured with the Orb team. - */ - fun paymentProvider(): Optional = body.paymentProvider() - - /** - * The ID of this customer in an external payments solution, such as Stripe. This is used for - * creating charges or invoices in the external system via Orb. - */ - fun paymentProviderId(): Optional = body.paymentProviderId() - - fun reportingConfiguration(): Optional = body.reportingConfiguration() - - fun shippingAddress(): Optional = body.shippingAddress() - - fun taxConfiguration(): Optional = body.taxConfiguration() - - /** - * 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 | - * |--------------------|------------|-------------------------------------------------------------------------------------------------------| - * |Andorra |`ad_nrt` |Andorran NRT Number | - * |Argentina |`ar_cuit` |Argentinian Tax ID Number | - * |Australia |`au_abn` |Australian Business Number (AU ABN) | - * |Australia |`au_arn` |Australian Taxation Office Reference Number | - * |Austria |`eu_vat` |European VAT Number | - * |Bahrain |`bh_vat` |Bahraini VAT Number | - * |Belgium |`eu_vat` |European VAT Number | - * |Bolivia |`bo_tin` |Bolivian Tax ID | - * |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 | - * |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) | - * |Chile |`cl_tin` |Chilean TIN | - * |China |`cn_tin` |Chinese Tax ID | - * |Colombia |`co_nit` |Colombian NIT Number | - * |Costa Rica |`cr_tin` |Costa Rican Tax ID | - * |Croatia |`eu_vat` |European VAT Number | - * |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 | - * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | - * |Finland |`eu_vat` |European VAT Number | - * |France |`eu_vat` |European VAT Number | - * |Georgia |`ge_vat` |Georgian VAT | - * |Germany |`eu_vat` |European VAT Number | - * |Greece |`eu_vat` |European VAT Number | - * |Hong Kong |`hk_br` |Hong Kong BR Number | - * |Hungary |`eu_vat` |European VAT Number | - * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | - * |Iceland |`is_vat` |Icelandic VAT | - * |India |`in_gst` |Indian GST Number | - * |Indonesia |`id_npwp` |Indonesian NPWP Number | - * |Ireland |`eu_vat` |European VAT Number | - * |Israel |`il_vat` |Israel VAT | - * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | - * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | - * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | - * |Latvia |`eu_vat` |European VAT Number | - * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | - * |Mexico |`mx_rfc` |Mexican RFC Number | - * |Netherlands |`eu_vat` |European VAT Number | - * |New Zealand |`nz_gst` |New Zealand GST Number | - * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | - * |Norway |`no_vat` |Norwegian VAT Number | - * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | - * |Oman |`om_vat` |Omani VAT Number | - * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | - * |Poland |`eu_vat` |European VAT Number | - * |Portugal |`eu_vat` |European VAT Number | - * |Romania |`eu_vat` |European VAT Number | - * |Romania |`ro_tin` |Romanian Tax ID Number | - * |Russia |`ru_inn` |Russian INN | - * |Russia |`ru_kpp` |Russian KPP | - * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | - * |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 | - * |Sweden |`eu_vat` |European VAT Number | - * |Switzerland |`ch_vat` |Switzerland VAT Number | - * |Taiwan |`tw_vat` |Taiwanese VAT | - * |Thailand |`th_vat` |Thai VAT | - * |Turkey |`tr_tin` |Turkish Tax Identification Number | - * |Ukraine |`ua_vat` |Ukrainian VAT | - * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | - * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | - * |United Kingdom |`gb_vat` |United Kingdom VAT Number | - * |United States |`us_ein` |United States EIN | - * |Uruguay |`uy_ruc` |Uruguayan RUC Number | - * |Venezuela |`ve_rif` |Venezuelan RIF Number | - * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | - */ - fun taxId(): Optional = body.taxId() - - fun _accountingSyncConfiguration(): JsonField = - body._accountingSyncConfiguration() - - /** - * Additional email addresses for this customer. If populated, these email addresses will be - * CC'd for customer communications. - */ - fun _additionalEmails(): JsonField> = body._additionalEmails() - - /** - * Used to determine if invoices for this customer will automatically attempt to charge a saved - * payment method, if available. This parameter defaults to `True` when a payment provider is - * provided on customer creation. - */ - fun _autoCollection(): JsonField = body._autoCollection() - - fun _billingAddress(): JsonField = 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. - */ - fun _currency(): JsonField = body._currency() - - /** A valid customer email, to be used for invoicing and notifications. */ - fun _email(): JsonField = body._email() - - fun _emailDelivery(): JsonField = body._emailDelivery() - - /** - * The external customer ID. This can only be set if empty and the customer has no past or - * current subscriptions. - */ - fun _externalCustomerId(): JsonField = body._externalCustomerId() - - /** The hierarchical relationships for this customer. */ - fun _hierarchy(): JsonField = body._hierarchy() - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - */ - fun _metadata(): JsonField = body._metadata() - - /** The full name of the customer */ - fun _name(): JsonField = body._name() - - /** - * This is used for creating charges or invoices in an external system via Orb. When not in test - * mode: - * - the connection must first be configured in the Orb webapp. - * - if the provider is an invoicing provider (`stripe_invoice`, `quickbooks`, `bill.com`, - * `netsuite`), any product mappings must first be configured with the Orb team. - */ - fun _paymentProvider(): JsonField = body._paymentProvider() - - /** - * The ID of this customer in an external payments solution, such as Stripe. This is used for - * creating charges or invoices in the external system via Orb. - */ - fun _paymentProviderId(): JsonField = body._paymentProviderId() - - fun _reportingConfiguration(): JsonField = - body._reportingConfiguration() - - fun _shippingAddress(): JsonField = body._shippingAddress() - - fun _taxConfiguration(): JsonField = body._taxConfiguration() - - /** - * 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 | - * |--------------------|------------|-------------------------------------------------------------------------------------------------------| - * |Andorra |`ad_nrt` |Andorran NRT Number | - * |Argentina |`ar_cuit` |Argentinian Tax ID Number | - * |Australia |`au_abn` |Australian Business Number (AU ABN) | - * |Australia |`au_arn` |Australian Taxation Office Reference Number | - * |Austria |`eu_vat` |European VAT Number | - * |Bahrain |`bh_vat` |Bahraini VAT Number | - * |Belgium |`eu_vat` |European VAT Number | - * |Bolivia |`bo_tin` |Bolivian Tax ID | - * |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 | - * |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) | - * |Chile |`cl_tin` |Chilean TIN | - * |China |`cn_tin` |Chinese Tax ID | - * |Colombia |`co_nit` |Colombian NIT Number | - * |Costa Rica |`cr_tin` |Costa Rican Tax ID | - * |Croatia |`eu_vat` |European VAT Number | - * |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 | - * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | - * |Finland |`eu_vat` |European VAT Number | - * |France |`eu_vat` |European VAT Number | - * |Georgia |`ge_vat` |Georgian VAT | - * |Germany |`eu_vat` |European VAT Number | - * |Greece |`eu_vat` |European VAT Number | - * |Hong Kong |`hk_br` |Hong Kong BR Number | - * |Hungary |`eu_vat` |European VAT Number | - * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | - * |Iceland |`is_vat` |Icelandic VAT | - * |India |`in_gst` |Indian GST Number | - * |Indonesia |`id_npwp` |Indonesian NPWP Number | - * |Ireland |`eu_vat` |European VAT Number | - * |Israel |`il_vat` |Israel VAT | - * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | - * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | - * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | - * |Latvia |`eu_vat` |European VAT Number | - * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | - * |Mexico |`mx_rfc` |Mexican RFC Number | - * |Netherlands |`eu_vat` |European VAT Number | - * |New Zealand |`nz_gst` |New Zealand GST Number | - * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | - * |Norway |`no_vat` |Norwegian VAT Number | - * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | - * |Oman |`om_vat` |Omani VAT Number | - * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | - * |Poland |`eu_vat` |European VAT Number | - * |Portugal |`eu_vat` |European VAT Number | - * |Romania |`eu_vat` |European VAT Number | - * |Romania |`ro_tin` |Romanian Tax ID Number | - * |Russia |`ru_inn` |Russian INN | - * |Russia |`ru_kpp` |Russian KPP | - * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | - * |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 | - * |Sweden |`eu_vat` |European VAT Number | - * |Switzerland |`ch_vat` |Switzerland VAT Number | - * |Taiwan |`tw_vat` |Taiwanese VAT | - * |Thailand |`th_vat` |Thai VAT | - * |Turkey |`tr_tin` |Turkish Tax Identification Number | - * |Ukraine |`ua_vat` |Ukrainian VAT | - * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | - * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | - * |United Kingdom |`gb_vat` |United Kingdom VAT Number | - * |United States |`us_ein` |United States EIN | - * |Uruguay |`uy_ruc` |Uruguayan RUC Number | - * |Venezuela |`ve_rif` |Venezuelan RIF Number | - * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | - */ - fun _taxId(): JsonField = body._taxId() - - fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalBodyProperties(): Map = + editCustomerModel._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): EditCustomerModel = editCustomerModel override fun _headers(): Headers = additionalHeaders @@ -422,1241 +47,20 @@ private constructor( } } - @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("accounting_sync_configuration") - @ExcludeMissing - private val accountingSyncConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("additional_emails") - @ExcludeMissing - private val additionalEmails: JsonField> = JsonMissing.of(), - @JsonProperty("auto_collection") - @ExcludeMissing - private val autoCollection: JsonField = JsonMissing.of(), - @JsonProperty("billing_address") - @ExcludeMissing - private val billingAddress: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("email") - @ExcludeMissing - private val email: JsonField = JsonMissing.of(), - @JsonProperty("email_delivery") - @ExcludeMissing - private val emailDelivery: JsonField = JsonMissing.of(), - @JsonProperty("external_customer_id") - @ExcludeMissing - private val externalCustomerId: JsonField = JsonMissing.of(), - @JsonProperty("hierarchy") - @ExcludeMissing - private val hierarchy: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("payment_provider") - @ExcludeMissing - private val paymentProvider: JsonField = JsonMissing.of(), - @JsonProperty("payment_provider_id") - @ExcludeMissing - private val paymentProviderId: JsonField = JsonMissing.of(), - @JsonProperty("reporting_configuration") - @ExcludeMissing - private val reportingConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("shipping_address") - @ExcludeMissing - private val shippingAddress: JsonField = JsonMissing.of(), - @JsonProperty("tax_configuration") - @ExcludeMissing - private val taxConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("tax_id") - @ExcludeMissing - private val taxId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun accountingSyncConfiguration(): Optional = - Optional.ofNullable( - accountingSyncConfiguration.getNullable("accounting_sync_configuration") - ) - - /** - * Additional email addresses for this customer. If populated, these email addresses will be - * CC'd for customer communications. - */ - fun additionalEmails(): Optional> = - Optional.ofNullable(additionalEmails.getNullable("additional_emails")) - - /** - * Used to determine if invoices for this customer will automatically attempt to charge a - * saved payment method, if available. This parameter defaults to `True` when a payment - * provider is provided on customer creation. - */ - fun autoCollection(): Optional = - Optional.ofNullable(autoCollection.getNullable("auto_collection")) - - fun billingAddress(): Optional = - Optional.ofNullable(billingAddress.getNullable("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. - */ - fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) - - /** A valid customer email, to be used for invoicing and notifications. */ - fun email(): Optional = Optional.ofNullable(email.getNullable("email")) - - fun emailDelivery(): Optional = - Optional.ofNullable(emailDelivery.getNullable("email_delivery")) - - /** - * The external customer ID. This can only be set if empty and the customer has no past or - * current subscriptions. - */ - fun externalCustomerId(): Optional = - Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - - /** The hierarchical relationships for this customer. */ - fun hierarchy(): Optional = - Optional.ofNullable(hierarchy.getNullable("hierarchy")) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by setting - * `metadata` to `null`. - */ - fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - - /** The full name of the customer */ - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - /** - * This is used for creating charges or invoices in an external system via Orb. When not in - * test mode: - * - the connection must first be configured in the Orb webapp. - * - if the provider is an invoicing provider (`stripe_invoice`, `quickbooks`, `bill.com`, - * `netsuite`), any product mappings must first be configured with the Orb team. - */ - fun paymentProvider(): Optional = - Optional.ofNullable(paymentProvider.getNullable("payment_provider")) - - /** - * The ID of this customer in an external payments solution, such as Stripe. This is used - * for creating charges or invoices in the external system via Orb. - */ - fun paymentProviderId(): Optional = - Optional.ofNullable(paymentProviderId.getNullable("payment_provider_id")) - - fun reportingConfiguration(): Optional = - Optional.ofNullable(reportingConfiguration.getNullable("reporting_configuration")) - - fun shippingAddress(): Optional = - Optional.ofNullable(shippingAddress.getNullable("shipping_address")) - - fun taxConfiguration(): Optional = - Optional.ofNullable(taxConfiguration.getNullable("tax_configuration")) - - /** - * 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 | - * |--------------------|------------|-------------------------------------------------------------------------------------------------------| - * |Andorra |`ad_nrt` |Andorran NRT Number | - * |Argentina |`ar_cuit` |Argentinian Tax ID Number | - * |Australia |`au_abn` |Australian Business Number (AU ABN) | - * |Australia |`au_arn` |Australian Taxation Office Reference Number | - * |Austria |`eu_vat` |European VAT Number | - * |Bahrain |`bh_vat` |Bahraini VAT Number | - * |Belgium |`eu_vat` |European VAT Number | - * |Bolivia |`bo_tin` |Bolivian Tax ID | - * |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 | - * |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) | - * |Chile |`cl_tin` |Chilean TIN | - * |China |`cn_tin` |Chinese Tax ID | - * |Colombia |`co_nit` |Colombian NIT Number | - * |Costa Rica |`cr_tin` |Costa Rican Tax ID | - * |Croatia |`eu_vat` |European VAT Number | - * |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 | - * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | - * |Finland |`eu_vat` |European VAT Number | - * |France |`eu_vat` |European VAT Number | - * |Georgia |`ge_vat` |Georgian VAT | - * |Germany |`eu_vat` |European VAT Number | - * |Greece |`eu_vat` |European VAT Number | - * |Hong Kong |`hk_br` |Hong Kong BR Number | - * |Hungary |`eu_vat` |European VAT Number | - * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | - * |Iceland |`is_vat` |Icelandic VAT | - * |India |`in_gst` |Indian GST Number | - * |Indonesia |`id_npwp` |Indonesian NPWP Number | - * |Ireland |`eu_vat` |European VAT Number | - * |Israel |`il_vat` |Israel VAT | - * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | - * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | - * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | - * |Latvia |`eu_vat` |European VAT Number | - * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | - * |Mexico |`mx_rfc` |Mexican RFC Number | - * |Netherlands |`eu_vat` |European VAT Number | - * |New Zealand |`nz_gst` |New Zealand GST Number | - * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | - * |Norway |`no_vat` |Norwegian VAT Number | - * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | - * |Oman |`om_vat` |Omani VAT Number | - * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | - * |Poland |`eu_vat` |European VAT Number | - * |Portugal |`eu_vat` |European VAT Number | - * |Romania |`eu_vat` |European VAT Number | - * |Romania |`ro_tin` |Romanian Tax ID Number | - * |Russia |`ru_inn` |Russian INN | - * |Russia |`ru_kpp` |Russian KPP | - * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | - * |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 | - * |Sweden |`eu_vat` |European VAT Number | - * |Switzerland |`ch_vat` |Switzerland VAT Number | - * |Taiwan |`tw_vat` |Taiwanese VAT | - * |Thailand |`th_vat` |Thai VAT | - * |Turkey |`tr_tin` |Turkish Tax Identification Number | - * |Ukraine |`ua_vat` |Ukrainian VAT | - * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | - * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | - * |United Kingdom |`gb_vat` |United Kingdom VAT Number | - * |United States |`us_ein` |United States EIN | - * |Uruguay |`uy_ruc` |Uruguayan RUC Number | - * |Venezuela |`ve_rif` |Venezuelan RIF Number | - * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | - */ - fun taxId(): Optional = Optional.ofNullable(taxId.getNullable("tax_id")) - - @JsonProperty("accounting_sync_configuration") - @ExcludeMissing - fun _accountingSyncConfiguration(): JsonField = - accountingSyncConfiguration - - /** - * Additional email addresses for this customer. If populated, these email addresses will be - * CC'd for customer communications. - */ - @JsonProperty("additional_emails") - @ExcludeMissing - fun _additionalEmails(): JsonField> = additionalEmails - - /** - * Used to determine if invoices for this customer will automatically attempt to charge a - * saved payment method, if available. This parameter defaults to `True` when a payment - * provider is provided on customer creation. - */ - @JsonProperty("auto_collection") - @ExcludeMissing - fun _autoCollection(): JsonField = autoCollection - - @JsonProperty("billing_address") - @ExcludeMissing - fun _billingAddress(): JsonField = 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. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** A valid customer email, to be used for invoicing and notifications. */ - @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email - - @JsonProperty("email_delivery") - @ExcludeMissing - fun _emailDelivery(): JsonField = emailDelivery - - /** - * The external customer ID. This can only be set if empty and the customer has no past or - * current subscriptions. - */ - @JsonProperty("external_customer_id") - @ExcludeMissing - fun _externalCustomerId(): JsonField = externalCustomerId - - /** The hierarchical relationships for this customer. */ - @JsonProperty("hierarchy") - @ExcludeMissing - fun _hierarchy(): JsonField = hierarchy - - /** - * User-specified key/value pairs for the resource. 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - /** The full name of the customer */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * This is used for creating charges or invoices in an external system via Orb. When not in - * test mode: - * - the connection must first be configured in the Orb webapp. - * - if the provider is an invoicing provider (`stripe_invoice`, `quickbooks`, `bill.com`, - * `netsuite`), any product mappings must first be configured with the Orb team. - */ - @JsonProperty("payment_provider") - @ExcludeMissing - fun _paymentProvider(): JsonField = paymentProvider - - /** - * The ID of this customer in an external payments solution, such as Stripe. This is used - * for creating charges or invoices in the external system via Orb. - */ - @JsonProperty("payment_provider_id") - @ExcludeMissing - fun _paymentProviderId(): JsonField = paymentProviderId - - @JsonProperty("reporting_configuration") - @ExcludeMissing - fun _reportingConfiguration(): JsonField = reportingConfiguration - - @JsonProperty("shipping_address") - @ExcludeMissing - fun _shippingAddress(): JsonField = shippingAddress + fun toBuilder() = Builder().from(this) - @JsonProperty("tax_configuration") - @ExcludeMissing - fun _taxConfiguration(): JsonField = taxConfiguration + companion object { /** - * Tax IDs are commonly required to be displayed on customer invoices, which are added to - * the headers of invoices. + * Returns a mutable builder for constructing an instance of + * [CustomerUpdateByExternalIdParams]. * - * ### Supported Tax ID Countries and Types - * |Country |Type |Description | - * |--------------------|------------|-------------------------------------------------------------------------------------------------------| - * |Andorra |`ad_nrt` |Andorran NRT Number | - * |Argentina |`ar_cuit` |Argentinian Tax ID Number | - * |Australia |`au_abn` |Australian Business Number (AU ABN) | - * |Australia |`au_arn` |Australian Taxation Office Reference Number | - * |Austria |`eu_vat` |European VAT Number | - * |Bahrain |`bh_vat` |Bahraini VAT Number | - * |Belgium |`eu_vat` |European VAT Number | - * |Bolivia |`bo_tin` |Bolivian Tax ID | - * |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 | - * |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) | - * |Chile |`cl_tin` |Chilean TIN | - * |China |`cn_tin` |Chinese Tax ID | - * |Colombia |`co_nit` |Colombian NIT Number | - * |Costa Rica |`cr_tin` |Costa Rican Tax ID | - * |Croatia |`eu_vat` |European VAT Number | - * |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 | - * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | - * |Finland |`eu_vat` |European VAT Number | - * |France |`eu_vat` |European VAT Number | - * |Georgia |`ge_vat` |Georgian VAT | - * |Germany |`eu_vat` |European VAT Number | - * |Greece |`eu_vat` |European VAT Number | - * |Hong Kong |`hk_br` |Hong Kong BR Number | - * |Hungary |`eu_vat` |European VAT Number | - * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | - * |Iceland |`is_vat` |Icelandic VAT | - * |India |`in_gst` |Indian GST Number | - * |Indonesia |`id_npwp` |Indonesian NPWP Number | - * |Ireland |`eu_vat` |European VAT Number | - * |Israel |`il_vat` |Israel VAT | - * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | - * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | - * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | - * |Latvia |`eu_vat` |European VAT Number | - * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | - * |Mexico |`mx_rfc` |Mexican RFC Number | - * |Netherlands |`eu_vat` |European VAT Number | - * |New Zealand |`nz_gst` |New Zealand GST Number | - * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | - * |Norway |`no_vat` |Norwegian VAT Number | - * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | - * |Oman |`om_vat` |Omani VAT Number | - * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | - * |Poland |`eu_vat` |European VAT Number | - * |Portugal |`eu_vat` |European VAT Number | - * |Romania |`eu_vat` |European VAT Number | - * |Romania |`ro_tin` |Romanian Tax ID Number | - * |Russia |`ru_inn` |Russian INN | - * |Russia |`ru_kpp` |Russian KPP | - * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | - * |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 | - * |Sweden |`eu_vat` |European VAT Number | - * |Switzerland |`ch_vat` |Switzerland VAT Number | - * |Taiwan |`tw_vat` |Taiwanese VAT | - * |Thailand |`th_vat` |Thai VAT | - * |Turkey |`tr_tin` |Turkish Tax Identification Number | - * |Ukraine |`ua_vat` |Ukrainian VAT | - * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | - * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | - * |United Kingdom |`gb_vat` |United Kingdom VAT Number | - * |United States |`us_ein` |United States EIN | - * |Uruguay |`uy_ruc` |Uruguayan RUC Number | - * |Venezuela |`ve_rif` |Venezuelan RIF Number | - * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + * The following fields are required: + * ```java + * .id() + * .editCustomerModel() + * ``` */ - @JsonProperty("tax_id") @ExcludeMissing fun _taxId(): JsonField = taxId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - accountingSyncConfiguration().ifPresent { it.validate() } - additionalEmails() - autoCollection() - billingAddress().ifPresent { it.validate() } - currency() - email() - emailDelivery() - externalCustomerId() - hierarchy().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - name() - paymentProvider() - paymentProviderId() - reportingConfiguration().ifPresent { it.validate() } - shippingAddress().ifPresent { it.validate() } - taxConfiguration().ifPresent { it.validate() } - taxId().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var accountingSyncConfiguration: JsonField = - JsonMissing.of() - private var additionalEmails: JsonField>? = null - private var autoCollection: JsonField = JsonMissing.of() - private var billingAddress: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var email: JsonField = JsonMissing.of() - private var emailDelivery: JsonField = JsonMissing.of() - private var externalCustomerId: JsonField = JsonMissing.of() - private var hierarchy: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var paymentProvider: JsonField = JsonMissing.of() - private var paymentProviderId: JsonField = JsonMissing.of() - private var reportingConfiguration: JsonField = JsonMissing.of() - private var shippingAddress: JsonField = JsonMissing.of() - private var taxConfiguration: JsonField = JsonMissing.of() - private var taxId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - accountingSyncConfiguration = body.accountingSyncConfiguration - additionalEmails = body.additionalEmails.map { it.toMutableList() } - autoCollection = body.autoCollection - billingAddress = body.billingAddress - currency = body.currency - email = body.email - emailDelivery = body.emailDelivery - externalCustomerId = body.externalCustomerId - hierarchy = body.hierarchy - metadata = body.metadata - name = body.name - paymentProvider = body.paymentProvider - paymentProviderId = body.paymentProviderId - reportingConfiguration = body.reportingConfiguration - shippingAddress = body.shippingAddress - taxConfiguration = body.taxConfiguration - taxId = body.taxId - additionalProperties = body.additionalProperties.toMutableMap() - } - - fun accountingSyncConfiguration( - accountingSyncConfiguration: AccountingSyncConfiguration? - ) = accountingSyncConfiguration(JsonField.ofNullable(accountingSyncConfiguration)) - - fun accountingSyncConfiguration( - accountingSyncConfiguration: Optional - ) = accountingSyncConfiguration(accountingSyncConfiguration.orElse(null)) - - fun accountingSyncConfiguration( - accountingSyncConfiguration: JsonField - ) = apply { this.accountingSyncConfiguration = accountingSyncConfiguration } - - /** - * Additional email addresses for this customer. If populated, these email addresses - * will be CC'd for customer communications. - */ - fun additionalEmails(additionalEmails: List?) = - additionalEmails(JsonField.ofNullable(additionalEmails)) - - /** - * Additional email addresses for this customer. If populated, these email addresses - * will be CC'd for customer communications. - */ - fun additionalEmails(additionalEmails: Optional>) = - additionalEmails(additionalEmails.orElse(null)) - - /** - * Additional email addresses for this customer. If populated, these email addresses - * will be CC'd for customer communications. - */ - fun additionalEmails(additionalEmails: JsonField>) = apply { - this.additionalEmails = additionalEmails.map { it.toMutableList() } - } - - /** - * Additional email addresses for this customer. If populated, these email addresses - * will be CC'd for customer communications. - */ - fun addAdditionalEmail(additionalEmail: String) = apply { - additionalEmails = - (additionalEmails ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(additionalEmail) - } - } - - /** - * Used to determine if invoices for this customer will automatically attempt to charge - * a saved payment method, if available. This parameter defaults to `True` when a - * payment provider is provided on customer creation. - */ - fun autoCollection(autoCollection: Boolean?) = - autoCollection(JsonField.ofNullable(autoCollection)) - - /** - * Used to determine if invoices for this customer will automatically attempt to charge - * a saved payment method, if available. This parameter defaults to `True` when a - * payment provider is provided on customer creation. - */ - fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) - - /** - * Used to determine if invoices for this customer will automatically attempt to charge - * a saved payment method, if available. This parameter defaults to `True` when a - * payment provider is provided on customer creation. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun autoCollection(autoCollection: Optional) = - autoCollection(autoCollection.orElse(null) as Boolean?) - - /** - * Used to determine if invoices for this customer will automatically attempt to charge - * a saved payment method, if available. This parameter defaults to `True` when a - * payment provider is provided on customer creation. - */ - fun autoCollection(autoCollection: JsonField) = apply { - this.autoCollection = autoCollection - } - - fun billingAddress(billingAddress: BillingAddress?) = - billingAddress(JsonField.ofNullable(billingAddress)) - - fun billingAddress(billingAddress: Optional) = - billingAddress(billingAddress.orElse(null)) - - fun billingAddress(billingAddress: JsonField) = apply { - this.billingAddress = 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. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * 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. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** A valid customer email, to be used for invoicing and notifications. */ - fun email(email: String?) = email(JsonField.ofNullable(email)) - - /** A valid customer email, to be used for invoicing and notifications. */ - fun email(email: Optional) = email(email.orElse(null)) - - /** A valid customer email, to be used for invoicing and notifications. */ - fun email(email: JsonField) = apply { this.email = email } - - fun emailDelivery(emailDelivery: Boolean?) = - emailDelivery(JsonField.ofNullable(emailDelivery)) - - fun emailDelivery(emailDelivery: Boolean) = emailDelivery(emailDelivery as Boolean?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun emailDelivery(emailDelivery: Optional) = - emailDelivery(emailDelivery.orElse(null) as Boolean?) - - fun emailDelivery(emailDelivery: JsonField) = apply { - this.emailDelivery = emailDelivery - } - - /** - * The external customer ID. This can only be set if empty and the customer has no past - * or current subscriptions. - */ - fun externalCustomerId(externalCustomerId: String?) = - externalCustomerId(JsonField.ofNullable(externalCustomerId)) - - /** - * The external customer ID. This can only be set if empty and the customer has no past - * or current subscriptions. - */ - fun externalCustomerId(externalCustomerId: Optional) = - externalCustomerId(externalCustomerId.orElse(null)) - - /** - * The external customer ID. This can only be set if empty and the customer has no past - * or current subscriptions. - */ - fun externalCustomerId(externalCustomerId: JsonField) = apply { - this.externalCustomerId = externalCustomerId - } - - /** The hierarchical relationships for this customer. */ - fun hierarchy(hierarchy: Hierarchy?) = hierarchy(JsonField.ofNullable(hierarchy)) - - /** The hierarchical relationships for this customer. */ - fun hierarchy(hierarchy: Optional) = hierarchy(hierarchy.orElse(null)) - - /** The hierarchical relationships for this customer. */ - fun hierarchy(hierarchy: JsonField) = apply { this.hierarchy = hierarchy } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: JsonField) = apply { this.metadata = metadata } - - /** The full name of the customer */ - fun name(name: String?) = name(JsonField.ofNullable(name)) - - /** The full name of the customer */ - fun name(name: Optional) = name(name.orElse(null)) - - /** The full name of the customer */ - fun name(name: JsonField) = apply { this.name = name } - - /** - * This is used for creating charges or invoices in an external system via Orb. When not - * in test mode: - * - the connection must first be configured in the Orb webapp. - * - if the provider is an invoicing provider (`stripe_invoice`, `quickbooks`, - * `bill.com`, `netsuite`), any product mappings must first be configured with the Orb - * team. - */ - fun paymentProvider(paymentProvider: PaymentProvider?) = - paymentProvider(JsonField.ofNullable(paymentProvider)) - - /** - * This is used for creating charges or invoices in an external system via Orb. When not - * in test mode: - * - the connection must first be configured in the Orb webapp. - * - if the provider is an invoicing provider (`stripe_invoice`, `quickbooks`, - * `bill.com`, `netsuite`), any product mappings must first be configured with the Orb - * team. - */ - fun paymentProvider(paymentProvider: Optional) = - paymentProvider(paymentProvider.orElse(null)) - - /** - * This is used for creating charges or invoices in an external system via Orb. When not - * in test mode: - * - the connection must first be configured in the Orb webapp. - * - if the provider is an invoicing provider (`stripe_invoice`, `quickbooks`, - * `bill.com`, `netsuite`), any product mappings must first be configured with the Orb - * team. - */ - fun paymentProvider(paymentProvider: JsonField) = apply { - this.paymentProvider = paymentProvider - } - - /** - * The ID of this customer in an external payments solution, such as Stripe. This is - * used for creating charges or invoices in the external system via Orb. - */ - fun paymentProviderId(paymentProviderId: String?) = - paymentProviderId(JsonField.ofNullable(paymentProviderId)) - - /** - * The ID of this customer in an external payments solution, such as Stripe. This is - * used for creating charges or invoices in the external system via Orb. - */ - fun paymentProviderId(paymentProviderId: Optional) = - paymentProviderId(paymentProviderId.orElse(null)) - - /** - * The ID of this customer in an external payments solution, such as Stripe. This is - * used for creating charges or invoices in the external system via Orb. - */ - fun paymentProviderId(paymentProviderId: JsonField) = apply { - this.paymentProviderId = paymentProviderId - } - - fun reportingConfiguration(reportingConfiguration: ReportingConfiguration?) = - reportingConfiguration(JsonField.ofNullable(reportingConfiguration)) - - fun reportingConfiguration(reportingConfiguration: Optional) = - reportingConfiguration(reportingConfiguration.orElse(null)) - - fun reportingConfiguration(reportingConfiguration: JsonField) = - apply { - this.reportingConfiguration = reportingConfiguration - } - - fun shippingAddress(shippingAddress: ShippingAddress?) = - shippingAddress(JsonField.ofNullable(shippingAddress)) - - fun shippingAddress(shippingAddress: Optional) = - shippingAddress(shippingAddress.orElse(null)) - - fun shippingAddress(shippingAddress: JsonField) = apply { - this.shippingAddress = shippingAddress - } - - fun taxConfiguration(taxConfiguration: TaxConfiguration?) = - taxConfiguration(JsonField.ofNullable(taxConfiguration)) - - fun taxConfiguration(taxConfiguration: Optional) = - taxConfiguration(taxConfiguration.orElse(null)) - - fun taxConfiguration(taxConfiguration: JsonField) = apply { - this.taxConfiguration = taxConfiguration - } - - fun taxConfiguration(newAvalara: TaxConfiguration.NewAvalaraTaxConfiguration) = - taxConfiguration(TaxConfiguration.ofNewAvalara(newAvalara)) - - fun newAvalaraTaxConfiguration(taxExempt: Boolean) = - taxConfiguration( - TaxConfiguration.NewAvalaraTaxConfiguration.builder() - .taxProvider( - CustomerUpdateByExternalIdParams.TaxConfiguration - .NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) - .taxExempt(taxExempt) - .build() - ) - - fun taxConfiguration(newTaxJar: TaxConfiguration.NewTaxJarConfiguration) = - taxConfiguration(TaxConfiguration.ofNewTaxJar(newTaxJar)) - - fun newTaxJarTaxConfiguration(taxExempt: Boolean) = - taxConfiguration( - TaxConfiguration.NewTaxJarConfiguration.builder() - .taxProvider( - CustomerUpdateByExternalIdParams.TaxConfiguration.NewTaxJarConfiguration - .TaxProvider - .TAXJAR - ) - .taxExempt(taxExempt) - .build() - ) - - /** - * 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 | - * |--------------------|------------|-------------------------------------------------------------------------------------------------------| - * |Andorra |`ad_nrt` |Andorran NRT Number | - * |Argentina |`ar_cuit` |Argentinian Tax ID Number | - * |Australia |`au_abn` |Australian Business Number (AU ABN) | - * |Australia |`au_arn` |Australian Taxation Office Reference Number | - * |Austria |`eu_vat` |European VAT Number | - * |Bahrain |`bh_vat` |Bahraini VAT Number | - * |Belgium |`eu_vat` |European VAT Number | - * |Bolivia |`bo_tin` |Bolivian Tax ID | - * |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 | - * |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) | - * |Chile |`cl_tin` |Chilean TIN | - * |China |`cn_tin` |Chinese Tax ID | - * |Colombia |`co_nit` |Colombian NIT Number | - * |Costa Rica |`cr_tin` |Costa Rican Tax ID | - * |Croatia |`eu_vat` |European VAT Number | - * |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 | - * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | - * |Finland |`eu_vat` |European VAT Number | - * |France |`eu_vat` |European VAT Number | - * |Georgia |`ge_vat` |Georgian VAT | - * |Germany |`eu_vat` |European VAT Number | - * |Greece |`eu_vat` |European VAT Number | - * |Hong Kong |`hk_br` |Hong Kong BR Number | - * |Hungary |`eu_vat` |European VAT Number | - * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | - * |Iceland |`is_vat` |Icelandic VAT | - * |India |`in_gst` |Indian GST Number | - * |Indonesia |`id_npwp` |Indonesian NPWP Number | - * |Ireland |`eu_vat` |European VAT Number | - * |Israel |`il_vat` |Israel VAT | - * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | - * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | - * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | - * |Latvia |`eu_vat` |European VAT Number | - * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | - * |Mexico |`mx_rfc` |Mexican RFC Number | - * |Netherlands |`eu_vat` |European VAT Number | - * |New Zealand |`nz_gst` |New Zealand GST Number | - * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | - * |Norway |`no_vat` |Norwegian VAT Number | - * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | - * |Oman |`om_vat` |Omani VAT Number | - * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | - * |Poland |`eu_vat` |European VAT Number | - * |Portugal |`eu_vat` |European VAT Number | - * |Romania |`eu_vat` |European VAT Number | - * |Romania |`ro_tin` |Romanian Tax ID Number | - * |Russia |`ru_inn` |Russian INN | - * |Russia |`ru_kpp` |Russian KPP | - * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | - * |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 | - * |Sweden |`eu_vat` |European VAT Number | - * |Switzerland |`ch_vat` |Switzerland VAT Number | - * |Taiwan |`tw_vat` |Taiwanese VAT | - * |Thailand |`th_vat` |Thai VAT | - * |Turkey |`tr_tin` |Turkish Tax Identification Number | - * |Ukraine |`ua_vat` |Ukrainian VAT | - * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | - * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | - * |United Kingdom |`gb_vat` |United Kingdom VAT Number | - * |United States |`us_ein` |United States EIN | - * |Uruguay |`uy_ruc` |Uruguayan RUC Number | - * |Venezuela |`ve_rif` |Venezuelan RIF Number | - * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | - */ - fun taxId(taxId: TaxId?) = taxId(JsonField.ofNullable(taxId)) - - /** - * 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 | - * |--------------------|------------|-------------------------------------------------------------------------------------------------------| - * |Andorra |`ad_nrt` |Andorran NRT Number | - * |Argentina |`ar_cuit` |Argentinian Tax ID Number | - * |Australia |`au_abn` |Australian Business Number (AU ABN) | - * |Australia |`au_arn` |Australian Taxation Office Reference Number | - * |Austria |`eu_vat` |European VAT Number | - * |Bahrain |`bh_vat` |Bahraini VAT Number | - * |Belgium |`eu_vat` |European VAT Number | - * |Bolivia |`bo_tin` |Bolivian Tax ID | - * |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 | - * |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) | - * |Chile |`cl_tin` |Chilean TIN | - * |China |`cn_tin` |Chinese Tax ID | - * |Colombia |`co_nit` |Colombian NIT Number | - * |Costa Rica |`cr_tin` |Costa Rican Tax ID | - * |Croatia |`eu_vat` |European VAT Number | - * |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 | - * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | - * |Finland |`eu_vat` |European VAT Number | - * |France |`eu_vat` |European VAT Number | - * |Georgia |`ge_vat` |Georgian VAT | - * |Germany |`eu_vat` |European VAT Number | - * |Greece |`eu_vat` |European VAT Number | - * |Hong Kong |`hk_br` |Hong Kong BR Number | - * |Hungary |`eu_vat` |European VAT Number | - * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | - * |Iceland |`is_vat` |Icelandic VAT | - * |India |`in_gst` |Indian GST Number | - * |Indonesia |`id_npwp` |Indonesian NPWP Number | - * |Ireland |`eu_vat` |European VAT Number | - * |Israel |`il_vat` |Israel VAT | - * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | - * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | - * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | - * |Latvia |`eu_vat` |European VAT Number | - * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | - * |Mexico |`mx_rfc` |Mexican RFC Number | - * |Netherlands |`eu_vat` |European VAT Number | - * |New Zealand |`nz_gst` |New Zealand GST Number | - * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | - * |Norway |`no_vat` |Norwegian VAT Number | - * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | - * |Oman |`om_vat` |Omani VAT Number | - * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | - * |Poland |`eu_vat` |European VAT Number | - * |Portugal |`eu_vat` |European VAT Number | - * |Romania |`eu_vat` |European VAT Number | - * |Romania |`ro_tin` |Romanian Tax ID Number | - * |Russia |`ru_inn` |Russian INN | - * |Russia |`ru_kpp` |Russian KPP | - * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | - * |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 | - * |Sweden |`eu_vat` |European VAT Number | - * |Switzerland |`ch_vat` |Switzerland VAT Number | - * |Taiwan |`tw_vat` |Taiwanese VAT | - * |Thailand |`th_vat` |Thai VAT | - * |Turkey |`tr_tin` |Turkish Tax Identification Number | - * |Ukraine |`ua_vat` |Ukrainian VAT | - * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | - * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | - * |United Kingdom |`gb_vat` |United Kingdom VAT Number | - * |United States |`us_ein` |United States EIN | - * |Uruguay |`uy_ruc` |Uruguayan RUC Number | - * |Venezuela |`ve_rif` |Venezuelan RIF Number | - * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | - */ - fun taxId(taxId: Optional) = taxId(taxId.orElse(null)) - - /** - * 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 | - * |--------------------|------------|-------------------------------------------------------------------------------------------------------| - * |Andorra |`ad_nrt` |Andorran NRT Number | - * |Argentina |`ar_cuit` |Argentinian Tax ID Number | - * |Australia |`au_abn` |Australian Business Number (AU ABN) | - * |Australia |`au_arn` |Australian Taxation Office Reference Number | - * |Austria |`eu_vat` |European VAT Number | - * |Bahrain |`bh_vat` |Bahraini VAT Number | - * |Belgium |`eu_vat` |European VAT Number | - * |Bolivia |`bo_tin` |Bolivian Tax ID | - * |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 | - * |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) | - * |Chile |`cl_tin` |Chilean TIN | - * |China |`cn_tin` |Chinese Tax ID | - * |Colombia |`co_nit` |Colombian NIT Number | - * |Costa Rica |`cr_tin` |Costa Rican Tax ID | - * |Croatia |`eu_vat` |European VAT Number | - * |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 | - * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | - * |Finland |`eu_vat` |European VAT Number | - * |France |`eu_vat` |European VAT Number | - * |Georgia |`ge_vat` |Georgian VAT | - * |Germany |`eu_vat` |European VAT Number | - * |Greece |`eu_vat` |European VAT Number | - * |Hong Kong |`hk_br` |Hong Kong BR Number | - * |Hungary |`eu_vat` |European VAT Number | - * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | - * |Iceland |`is_vat` |Icelandic VAT | - * |India |`in_gst` |Indian GST Number | - * |Indonesia |`id_npwp` |Indonesian NPWP Number | - * |Ireland |`eu_vat` |European VAT Number | - * |Israel |`il_vat` |Israel VAT | - * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | - * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | - * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | - * |Latvia |`eu_vat` |European VAT Number | - * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | - * |Mexico |`mx_rfc` |Mexican RFC Number | - * |Netherlands |`eu_vat` |European VAT Number | - * |New Zealand |`nz_gst` |New Zealand GST Number | - * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | - * |Norway |`no_vat` |Norwegian VAT Number | - * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | - * |Oman |`om_vat` |Omani VAT Number | - * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | - * |Poland |`eu_vat` |European VAT Number | - * |Portugal |`eu_vat` |European VAT Number | - * |Romania |`eu_vat` |European VAT Number | - * |Romania |`ro_tin` |Romanian Tax ID Number | - * |Russia |`ru_inn` |Russian INN | - * |Russia |`ru_kpp` |Russian KPP | - * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | - * |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 | - * |Sweden |`eu_vat` |European VAT Number | - * |Switzerland |`ch_vat` |Switzerland VAT Number | - * |Taiwan |`tw_vat` |Taiwanese VAT | - * |Thailand |`th_vat` |Thai VAT | - * |Turkey |`tr_tin` |Turkish Tax Identification Number | - * |Ukraine |`ua_vat` |Ukrainian VAT | - * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | - * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | - * |United Kingdom |`gb_vat` |United Kingdom VAT Number | - * |United States |`us_ein` |United States EIN | - * |Uruguay |`uy_ruc` |Uruguayan RUC Number | - * |Venezuela |`ve_rif` |Venezuelan RIF Number | - * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | - */ - fun taxId(taxId: JsonField) = apply { this.taxId = taxId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Body = - Body( - accountingSyncConfiguration, - (additionalEmails ?: JsonMissing.of()).map { it.toImmutable() }, - autoCollection, - billingAddress, - currency, - email, - emailDelivery, - externalCustomerId, - hierarchy, - metadata, - name, - paymentProvider, - paymentProviderId, - reportingConfiguration, - shippingAddress, - taxConfiguration, - taxId, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Body && accountingSyncConfiguration == other.accountingSyncConfiguration && additionalEmails == other.additionalEmails && autoCollection == other.autoCollection && billingAddress == other.billingAddress && currency == other.currency && email == other.email && emailDelivery == other.emailDelivery && externalCustomerId == other.externalCustomerId && hierarchy == other.hierarchy && metadata == other.metadata && name == other.name && paymentProvider == other.paymentProvider && paymentProviderId == other.paymentProviderId && reportingConfiguration == other.reportingConfiguration && shippingAddress == other.shippingAddress && taxConfiguration == other.taxConfiguration && taxId == other.taxId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(accountingSyncConfiguration, additionalEmails, autoCollection, billingAddress, currency, email, emailDelivery, externalCustomerId, hierarchy, metadata, name, paymentProvider, paymentProviderId, reportingConfiguration, shippingAddress, taxConfiguration, taxId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{accountingSyncConfiguration=$accountingSyncConfiguration, additionalEmails=$additionalEmails, autoCollection=$autoCollection, billingAddress=$billingAddress, currency=$currency, email=$email, emailDelivery=$emailDelivery, externalCustomerId=$externalCustomerId, hierarchy=$hierarchy, metadata=$metadata, name=$name, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, reportingConfiguration=$reportingConfiguration, shippingAddress=$shippingAddress, taxConfiguration=$taxConfiguration, taxId=$taxId, additionalProperties=$additionalProperties}" - } - - fun toBuilder() = Builder().from(this) - - companion object { - @JvmStatic fun builder() = Builder() } @@ -1665,7 +69,7 @@ private constructor( class Builder internal constructor() { private var id: String? = null - private var body: Body.Builder = Body.builder() + private var editCustomerModel: EditCustomerModel? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -1673,7 +77,7 @@ private constructor( internal fun from(customerUpdateByExternalIdParams: CustomerUpdateByExternalIdParams) = apply { id = customerUpdateByExternalIdParams.id - body = customerUpdateByExternalIdParams.body.toBuilder() + editCustomerModel = customerUpdateByExternalIdParams.editCustomerModel additionalHeaders = customerUpdateByExternalIdParams.additionalHeaders.toBuilder() additionalQueryParams = customerUpdateByExternalIdParams.additionalQueryParams.toBuilder() @@ -1681,688 +85,56 @@ private constructor( fun id(id: String) = apply { this.id = id } - fun accountingSyncConfiguration(accountingSyncConfiguration: AccountingSyncConfiguration?) = - apply { - body.accountingSyncConfiguration(accountingSyncConfiguration) - } - - fun accountingSyncConfiguration( - accountingSyncConfiguration: Optional - ) = accountingSyncConfiguration(accountingSyncConfiguration.orElse(null)) + fun editCustomerModel(editCustomerModel: EditCustomerModel) = apply { + this.editCustomerModel = editCustomerModel + } - fun accountingSyncConfiguration( - accountingSyncConfiguration: JsonField - ) = apply { body.accountingSyncConfiguration(accountingSyncConfiguration) } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - /** - * Additional email addresses for this customer. If populated, these email addresses will be - * CC'd for customer communications. - */ - fun additionalEmails(additionalEmails: List?) = apply { - body.additionalEmails(additionalEmails) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - /** - * Additional email addresses for this customer. If populated, these email addresses will be - * CC'd for customer communications. - */ - fun additionalEmails(additionalEmails: Optional>) = - additionalEmails(additionalEmails.orElse(null)) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - /** - * Additional email addresses for this customer. If populated, these email addresses will be - * CC'd for customer communications. - */ - fun additionalEmails(additionalEmails: JsonField>) = apply { - body.additionalEmails(additionalEmails) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) } - /** - * Additional email addresses for this customer. If populated, these email addresses will be - * CC'd for customer communications. - */ - fun addAdditionalEmail(additionalEmail: String) = apply { - body.addAdditionalEmail(additionalEmail) + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } - /** - * Used to determine if invoices for this customer will automatically attempt to charge a - * saved payment method, if available. This parameter defaults to `True` when a payment - * provider is provided on customer creation. - */ - fun autoCollection(autoCollection: Boolean?) = apply { body.autoCollection(autoCollection) } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - /** - * Used to determine if invoices for this customer will automatically attempt to charge a - * saved payment method, if available. This parameter defaults to `True` when a payment - * provider is provided on customer creation. - */ - fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - /** - * Used to determine if invoices for this customer will automatically attempt to charge a - * saved payment method, if available. This parameter defaults to `True` when a payment - * provider is provided on customer creation. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun autoCollection(autoCollection: Optional) = - autoCollection(autoCollection.orElse(null) as Boolean?) + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - /** - * Used to determine if invoices for this customer will automatically attempt to charge a - * saved payment method, if available. This parameter defaults to `True` when a payment - * provider is provided on customer creation. - */ - fun autoCollection(autoCollection: JsonField) = apply { - body.autoCollection(autoCollection) + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } - fun billingAddress(billingAddress: BillingAddress?) = apply { - body.billingAddress(billingAddress) + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } - fun billingAddress(billingAddress: Optional) = - billingAddress(billingAddress.orElse(null)) + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun billingAddress(billingAddress: JsonField) = apply { - body.billingAddress(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. - */ - fun currency(currency: String?) = apply { body.currency(currency) } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * 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. - */ - fun currency(currency: JsonField) = apply { body.currency(currency) } - - /** A valid customer email, to be used for invoicing and notifications. */ - fun email(email: String?) = apply { body.email(email) } - - /** A valid customer email, to be used for invoicing and notifications. */ - fun email(email: Optional) = email(email.orElse(null)) - - /** A valid customer email, to be used for invoicing and notifications. */ - fun email(email: JsonField) = apply { body.email(email) } - - fun emailDelivery(emailDelivery: Boolean?) = apply { body.emailDelivery(emailDelivery) } - - fun emailDelivery(emailDelivery: Boolean) = emailDelivery(emailDelivery as Boolean?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun emailDelivery(emailDelivery: Optional) = - emailDelivery(emailDelivery.orElse(null) as Boolean?) - - fun emailDelivery(emailDelivery: JsonField) = apply { - body.emailDelivery(emailDelivery) - } - - /** - * The external customer ID. This can only be set if empty and the customer has no past or - * current subscriptions. - */ - fun externalCustomerId(externalCustomerId: String?) = apply { - body.externalCustomerId(externalCustomerId) - } - - /** - * The external customer ID. This can only be set if empty and the customer has no past or - * current subscriptions. - */ - fun externalCustomerId(externalCustomerId: Optional) = - externalCustomerId(externalCustomerId.orElse(null)) - - /** - * The external customer ID. This can only be set if empty and the customer has no past or - * current subscriptions. - */ - fun externalCustomerId(externalCustomerId: JsonField) = apply { - body.externalCustomerId(externalCustomerId) - } - - /** The hierarchical relationships for this customer. */ - fun hierarchy(hierarchy: Hierarchy?) = apply { body.hierarchy(hierarchy) } - - /** The hierarchical relationships for this customer. */ - fun hierarchy(hierarchy: Optional) = hierarchy(hierarchy.orElse(null)) - - /** The hierarchical relationships for this customer. */ - fun hierarchy(hierarchy: JsonField) = apply { body.hierarchy(hierarchy) } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by setting - * `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by setting - * `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: JsonField) = apply { body.metadata(metadata) } - - /** The full name of the customer */ - fun name(name: String?) = apply { body.name(name) } - - /** The full name of the customer */ - fun name(name: Optional) = name(name.orElse(null)) - - /** The full name of the customer */ - fun name(name: JsonField) = apply { body.name(name) } - - /** - * This is used for creating charges or invoices in an external system via Orb. When not in - * test mode: - * - the connection must first be configured in the Orb webapp. - * - if the provider is an invoicing provider (`stripe_invoice`, `quickbooks`, `bill.com`, - * `netsuite`), any product mappings must first be configured with the Orb team. - */ - fun paymentProvider(paymentProvider: PaymentProvider?) = apply { - body.paymentProvider(paymentProvider) - } - - /** - * This is used for creating charges or invoices in an external system via Orb. When not in - * test mode: - * - the connection must first be configured in the Orb webapp. - * - if the provider is an invoicing provider (`stripe_invoice`, `quickbooks`, `bill.com`, - * `netsuite`), any product mappings must first be configured with the Orb team. - */ - fun paymentProvider(paymentProvider: Optional) = - paymentProvider(paymentProvider.orElse(null)) - - /** - * This is used for creating charges or invoices in an external system via Orb. When not in - * test mode: - * - the connection must first be configured in the Orb webapp. - * - if the provider is an invoicing provider (`stripe_invoice`, `quickbooks`, `bill.com`, - * `netsuite`), any product mappings must first be configured with the Orb team. - */ - fun paymentProvider(paymentProvider: JsonField) = apply { - body.paymentProvider(paymentProvider) - } - - /** - * The ID of this customer in an external payments solution, such as Stripe. This is used - * for creating charges or invoices in the external system via Orb. - */ - fun paymentProviderId(paymentProviderId: String?) = apply { - body.paymentProviderId(paymentProviderId) - } - - /** - * The ID of this customer in an external payments solution, such as Stripe. This is used - * for creating charges or invoices in the external system via Orb. - */ - fun paymentProviderId(paymentProviderId: Optional) = - paymentProviderId(paymentProviderId.orElse(null)) - - /** - * The ID of this customer in an external payments solution, such as Stripe. This is used - * for creating charges or invoices in the external system via Orb. - */ - fun paymentProviderId(paymentProviderId: JsonField) = apply { - body.paymentProviderId(paymentProviderId) - } - - fun reportingConfiguration(reportingConfiguration: ReportingConfiguration?) = apply { - body.reportingConfiguration(reportingConfiguration) - } - - fun reportingConfiguration(reportingConfiguration: Optional) = - reportingConfiguration(reportingConfiguration.orElse(null)) - - fun reportingConfiguration(reportingConfiguration: JsonField) = - apply { - body.reportingConfiguration(reportingConfiguration) - } - - fun shippingAddress(shippingAddress: ShippingAddress?) = apply { - body.shippingAddress(shippingAddress) - } - - fun shippingAddress(shippingAddress: Optional) = - shippingAddress(shippingAddress.orElse(null)) - - fun shippingAddress(shippingAddress: JsonField) = apply { - body.shippingAddress(shippingAddress) - } - - fun taxConfiguration(taxConfiguration: TaxConfiguration?) = apply { - body.taxConfiguration(taxConfiguration) - } - - fun taxConfiguration(taxConfiguration: Optional) = - taxConfiguration(taxConfiguration.orElse(null)) - - fun taxConfiguration(taxConfiguration: JsonField) = apply { - body.taxConfiguration(taxConfiguration) - } - - fun taxConfiguration(newAvalara: TaxConfiguration.NewAvalaraTaxConfiguration) = apply { - body.taxConfiguration(newAvalara) - } - - fun newAvalaraTaxConfiguration(taxExempt: Boolean) = apply { - body.newAvalaraTaxConfiguration(taxExempt) - } - - fun taxConfiguration(newTaxJar: TaxConfiguration.NewTaxJarConfiguration) = apply { - body.taxConfiguration(newTaxJar) - } - - fun newTaxJarTaxConfiguration(taxExempt: Boolean) = apply { - body.newTaxJarTaxConfiguration(taxExempt) - } - - /** - * 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 | - * |--------------------|------------|-------------------------------------------------------------------------------------------------------| - * |Andorra |`ad_nrt` |Andorran NRT Number | - * |Argentina |`ar_cuit` |Argentinian Tax ID Number | - * |Australia |`au_abn` |Australian Business Number (AU ABN) | - * |Australia |`au_arn` |Australian Taxation Office Reference Number | - * |Austria |`eu_vat` |European VAT Number | - * |Bahrain |`bh_vat` |Bahraini VAT Number | - * |Belgium |`eu_vat` |European VAT Number | - * |Bolivia |`bo_tin` |Bolivian Tax ID | - * |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 | - * |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) | - * |Chile |`cl_tin` |Chilean TIN | - * |China |`cn_tin` |Chinese Tax ID | - * |Colombia |`co_nit` |Colombian NIT Number | - * |Costa Rica |`cr_tin` |Costa Rican Tax ID | - * |Croatia |`eu_vat` |European VAT Number | - * |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 | - * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | - * |Finland |`eu_vat` |European VAT Number | - * |France |`eu_vat` |European VAT Number | - * |Georgia |`ge_vat` |Georgian VAT | - * |Germany |`eu_vat` |European VAT Number | - * |Greece |`eu_vat` |European VAT Number | - * |Hong Kong |`hk_br` |Hong Kong BR Number | - * |Hungary |`eu_vat` |European VAT Number | - * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | - * |Iceland |`is_vat` |Icelandic VAT | - * |India |`in_gst` |Indian GST Number | - * |Indonesia |`id_npwp` |Indonesian NPWP Number | - * |Ireland |`eu_vat` |European VAT Number | - * |Israel |`il_vat` |Israel VAT | - * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | - * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | - * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | - * |Latvia |`eu_vat` |European VAT Number | - * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | - * |Mexico |`mx_rfc` |Mexican RFC Number | - * |Netherlands |`eu_vat` |European VAT Number | - * |New Zealand |`nz_gst` |New Zealand GST Number | - * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | - * |Norway |`no_vat` |Norwegian VAT Number | - * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | - * |Oman |`om_vat` |Omani VAT Number | - * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | - * |Poland |`eu_vat` |European VAT Number | - * |Portugal |`eu_vat` |European VAT Number | - * |Romania |`eu_vat` |European VAT Number | - * |Romania |`ro_tin` |Romanian Tax ID Number | - * |Russia |`ru_inn` |Russian INN | - * |Russia |`ru_kpp` |Russian KPP | - * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | - * |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 | - * |Sweden |`eu_vat` |European VAT Number | - * |Switzerland |`ch_vat` |Switzerland VAT Number | - * |Taiwan |`tw_vat` |Taiwanese VAT | - * |Thailand |`th_vat` |Thai VAT | - * |Turkey |`tr_tin` |Turkish Tax Identification Number | - * |Ukraine |`ua_vat` |Ukrainian VAT | - * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | - * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | - * |United Kingdom |`gb_vat` |United Kingdom VAT Number | - * |United States |`us_ein` |United States EIN | - * |Uruguay |`uy_ruc` |Uruguayan RUC Number | - * |Venezuela |`ve_rif` |Venezuelan RIF Number | - * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | - */ - fun taxId(taxId: TaxId?) = apply { body.taxId(taxId) } - - /** - * 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 | - * |--------------------|------------|-------------------------------------------------------------------------------------------------------| - * |Andorra |`ad_nrt` |Andorran NRT Number | - * |Argentina |`ar_cuit` |Argentinian Tax ID Number | - * |Australia |`au_abn` |Australian Business Number (AU ABN) | - * |Australia |`au_arn` |Australian Taxation Office Reference Number | - * |Austria |`eu_vat` |European VAT Number | - * |Bahrain |`bh_vat` |Bahraini VAT Number | - * |Belgium |`eu_vat` |European VAT Number | - * |Bolivia |`bo_tin` |Bolivian Tax ID | - * |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 | - * |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) | - * |Chile |`cl_tin` |Chilean TIN | - * |China |`cn_tin` |Chinese Tax ID | - * |Colombia |`co_nit` |Colombian NIT Number | - * |Costa Rica |`cr_tin` |Costa Rican Tax ID | - * |Croatia |`eu_vat` |European VAT Number | - * |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 | - * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | - * |Finland |`eu_vat` |European VAT Number | - * |France |`eu_vat` |European VAT Number | - * |Georgia |`ge_vat` |Georgian VAT | - * |Germany |`eu_vat` |European VAT Number | - * |Greece |`eu_vat` |European VAT Number | - * |Hong Kong |`hk_br` |Hong Kong BR Number | - * |Hungary |`eu_vat` |European VAT Number | - * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | - * |Iceland |`is_vat` |Icelandic VAT | - * |India |`in_gst` |Indian GST Number | - * |Indonesia |`id_npwp` |Indonesian NPWP Number | - * |Ireland |`eu_vat` |European VAT Number | - * |Israel |`il_vat` |Israel VAT | - * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | - * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | - * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | - * |Latvia |`eu_vat` |European VAT Number | - * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | - * |Mexico |`mx_rfc` |Mexican RFC Number | - * |Netherlands |`eu_vat` |European VAT Number | - * |New Zealand |`nz_gst` |New Zealand GST Number | - * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | - * |Norway |`no_vat` |Norwegian VAT Number | - * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | - * |Oman |`om_vat` |Omani VAT Number | - * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | - * |Poland |`eu_vat` |European VAT Number | - * |Portugal |`eu_vat` |European VAT Number | - * |Romania |`eu_vat` |European VAT Number | - * |Romania |`ro_tin` |Romanian Tax ID Number | - * |Russia |`ru_inn` |Russian INN | - * |Russia |`ru_kpp` |Russian KPP | - * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | - * |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 | - * |Sweden |`eu_vat` |European VAT Number | - * |Switzerland |`ch_vat` |Switzerland VAT Number | - * |Taiwan |`tw_vat` |Taiwanese VAT | - * |Thailand |`th_vat` |Thai VAT | - * |Turkey |`tr_tin` |Turkish Tax Identification Number | - * |Ukraine |`ua_vat` |Ukrainian VAT | - * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | - * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | - * |United Kingdom |`gb_vat` |United Kingdom VAT Number | - * |United States |`us_ein` |United States EIN | - * |Uruguay |`uy_ruc` |Uruguayan RUC Number | - * |Venezuela |`ve_rif` |Venezuelan RIF Number | - * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | - */ - fun taxId(taxId: Optional) = taxId(taxId.orElse(null)) - - /** - * 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 | - * |--------------------|------------|-------------------------------------------------------------------------------------------------------| - * |Andorra |`ad_nrt` |Andorran NRT Number | - * |Argentina |`ar_cuit` |Argentinian Tax ID Number | - * |Australia |`au_abn` |Australian Business Number (AU ABN) | - * |Australia |`au_arn` |Australian Taxation Office Reference Number | - * |Austria |`eu_vat` |European VAT Number | - * |Bahrain |`bh_vat` |Bahraini VAT Number | - * |Belgium |`eu_vat` |European VAT Number | - * |Bolivia |`bo_tin` |Bolivian Tax ID | - * |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 | - * |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) | - * |Chile |`cl_tin` |Chilean TIN | - * |China |`cn_tin` |Chinese Tax ID | - * |Colombia |`co_nit` |Colombian NIT Number | - * |Costa Rica |`cr_tin` |Costa Rican Tax ID | - * |Croatia |`eu_vat` |European VAT Number | - * |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 | - * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | - * |Finland |`eu_vat` |European VAT Number | - * |France |`eu_vat` |European VAT Number | - * |Georgia |`ge_vat` |Georgian VAT | - * |Germany |`eu_vat` |European VAT Number | - * |Greece |`eu_vat` |European VAT Number | - * |Hong Kong |`hk_br` |Hong Kong BR Number | - * |Hungary |`eu_vat` |European VAT Number | - * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | - * |Iceland |`is_vat` |Icelandic VAT | - * |India |`in_gst` |Indian GST Number | - * |Indonesia |`id_npwp` |Indonesian NPWP Number | - * |Ireland |`eu_vat` |European VAT Number | - * |Israel |`il_vat` |Israel VAT | - * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | - * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | - * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | - * |Latvia |`eu_vat` |European VAT Number | - * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | - * |Mexico |`mx_rfc` |Mexican RFC Number | - * |Netherlands |`eu_vat` |European VAT Number | - * |New Zealand |`nz_gst` |New Zealand GST Number | - * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | - * |Norway |`no_vat` |Norwegian VAT Number | - * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | - * |Oman |`om_vat` |Omani VAT Number | - * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | - * |Poland |`eu_vat` |European VAT Number | - * |Portugal |`eu_vat` |European VAT Number | - * |Romania |`eu_vat` |European VAT Number | - * |Romania |`ro_tin` |Romanian Tax ID Number | - * |Russia |`ru_inn` |Russian INN | - * |Russia |`ru_kpp` |Russian KPP | - * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | - * |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 | - * |Sweden |`eu_vat` |European VAT Number | - * |Switzerland |`ch_vat` |Switzerland VAT Number | - * |Taiwan |`tw_vat` |Taiwanese VAT | - * |Thailand |`th_vat` |Thai VAT | - * |Turkey |`tr_tin` |Turkish Tax Identification Number | - * |Ukraine |`ua_vat` |Ukrainian VAT | - * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | - * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | - * |United Kingdom |`gb_vat` |United Kingdom VAT Number | - * |United States |`us_ein` |United States EIN | - * |Uruguay |`uy_ruc` |Uruguayan RUC Number | - * |Venezuela |`ve_rif` |Venezuelan RIF Number | - * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | - */ - fun taxId(taxId: JsonField) = apply { body.taxId(taxId) } - - 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 removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) } fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { @@ -2418,3069 +190,22 @@ private constructor( fun build(): CustomerUpdateByExternalIdParams = CustomerUpdateByExternalIdParams( checkRequired("id", id), - body.build(), + checkRequired("editCustomerModel", editCustomerModel), additionalHeaders.build(), additionalQueryParams.build(), ) } - @NoAutoDetect - class AccountingSyncConfiguration - @JsonCreator - private constructor( - @JsonProperty("accounting_providers") - @ExcludeMissing - private val accountingProviders: JsonField> = JsonMissing.of(), - @JsonProperty("excluded") - @ExcludeMissing - private val excluded: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun accountingProviders(): Optional> = - Optional.ofNullable(accountingProviders.getNullable("accounting_providers")) - - fun excluded(): Optional = Optional.ofNullable(excluded.getNullable("excluded")) - - @JsonProperty("accounting_providers") - @ExcludeMissing - fun _accountingProviders(): JsonField> = accountingProviders - - @JsonProperty("excluded") @ExcludeMissing fun _excluded(): JsonField = excluded - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AccountingSyncConfiguration = apply { - if (validated) { - return@apply - } - - accountingProviders().ifPresent { it.forEach { it.validate() } } - excluded() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AccountingSyncConfiguration]. */ - class Builder internal constructor() { - - private var accountingProviders: JsonField>? = null - private var excluded: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(accountingSyncConfiguration: AccountingSyncConfiguration) = apply { - accountingProviders = - accountingSyncConfiguration.accountingProviders.map { it.toMutableList() } - excluded = accountingSyncConfiguration.excluded - additionalProperties = - accountingSyncConfiguration.additionalProperties.toMutableMap() - } - - fun accountingProviders(accountingProviders: List?) = - accountingProviders(JsonField.ofNullable(accountingProviders)) - - fun accountingProviders(accountingProviders: Optional>) = - accountingProviders(accountingProviders.orElse(null)) - - fun accountingProviders(accountingProviders: JsonField>) = - apply { - this.accountingProviders = accountingProviders.map { it.toMutableList() } - } - - fun addAccountingProvider(accountingProvider: AccountingProvider) = apply { - accountingProviders = - (accountingProviders ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(accountingProvider) - } - } - - fun excluded(excluded: Boolean?) = excluded(JsonField.ofNullable(excluded)) - - fun excluded(excluded: Boolean) = excluded(excluded as Boolean?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun excluded(excluded: Optional) = excluded(excluded.orElse(null) as Boolean?) - - fun excluded(excluded: JsonField) = apply { this.excluded = excluded } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): AccountingSyncConfiguration = - AccountingSyncConfiguration( - (accountingProviders ?: JsonMissing.of()).map { it.toImmutable() }, - excluded, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class AccountingProvider - @JsonCreator - private constructor( - @JsonProperty("external_provider_id") - @ExcludeMissing - private val externalProviderId: JsonField = JsonMissing.of(), - @JsonProperty("provider_type") - @ExcludeMissing - private val providerType: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun externalProviderId(): String = - externalProviderId.getRequired("external_provider_id") - - fun providerType(): String = providerType.getRequired("provider_type") - - @JsonProperty("external_provider_id") - @ExcludeMissing - fun _externalProviderId(): JsonField = externalProviderId - - @JsonProperty("provider_type") - @ExcludeMissing - fun _providerType(): JsonField = providerType - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AccountingProvider = apply { - if (validated) { - return@apply - } - - externalProviderId() - providerType() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AccountingProvider]. */ - class Builder internal constructor() { - - private var externalProviderId: JsonField? = null - private var providerType: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(accountingProvider: AccountingProvider) = apply { - externalProviderId = accountingProvider.externalProviderId - providerType = accountingProvider.providerType - additionalProperties = accountingProvider.additionalProperties.toMutableMap() - } - - fun externalProviderId(externalProviderId: String) = - externalProviderId(JsonField.of(externalProviderId)) - - fun externalProviderId(externalProviderId: JsonField) = apply { - this.externalProviderId = externalProviderId - } - - fun providerType(providerType: String) = providerType(JsonField.of(providerType)) - - fun providerType(providerType: JsonField) = apply { - this.providerType = providerType - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): AccountingProvider = - AccountingProvider( - checkRequired("externalProviderId", externalProviderId), - checkRequired("providerType", providerType), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AccountingProvider && externalProviderId == other.externalProviderId && providerType == other.providerType && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(externalProviderId, providerType, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AccountingProvider{externalProviderId=$externalProviderId, providerType=$providerType, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AccountingSyncConfiguration && accountingProviders == other.accountingProviders && excluded == other.excluded && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(accountingProviders, excluded, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AccountingSyncConfiguration{accountingProviders=$accountingProviders, excluded=$excluded, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BillingAddress - @JsonCreator - private constructor( - @JsonProperty("city") - @ExcludeMissing - private val city: JsonField = JsonMissing.of(), - @JsonProperty("country") - @ExcludeMissing - private val country: JsonField = JsonMissing.of(), - @JsonProperty("line1") - @ExcludeMissing - private val line1: JsonField = JsonMissing.of(), - @JsonProperty("line2") - @ExcludeMissing - private val line2: JsonField = JsonMissing.of(), - @JsonProperty("postal_code") - @ExcludeMissing - private val postalCode: JsonField = JsonMissing.of(), - @JsonProperty("state") - @ExcludeMissing - private val state: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun city(): Optional = Optional.ofNullable(city.getNullable("city")) - - fun country(): Optional = Optional.ofNullable(country.getNullable("country")) - - fun line1(): Optional = Optional.ofNullable(line1.getNullable("line1")) - - fun line2(): Optional = Optional.ofNullable(line2.getNullable("line2")) - - fun postalCode(): Optional = - Optional.ofNullable(postalCode.getNullable("postal_code")) - - fun state(): Optional = Optional.ofNullable(state.getNullable("state")) - - @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city - - @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country - - @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField = line1 - - @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 - - @JsonProperty("postal_code") - @ExcludeMissing - fun _postalCode(): JsonField = postalCode - - @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingAddress = apply { - if (validated) { - return@apply - } - - city() - country() - line1() - line2() - postalCode() - state() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingAddress]. */ - class Builder internal constructor() { - - private var city: JsonField = JsonMissing.of() - private var country: JsonField = JsonMissing.of() - private var line1: JsonField = JsonMissing.of() - private var line2: JsonField = JsonMissing.of() - private var postalCode: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingAddress: BillingAddress) = apply { - city = billingAddress.city - country = billingAddress.country - line1 = billingAddress.line1 - line2 = billingAddress.line2 - postalCode = billingAddress.postalCode - state = billingAddress.state - additionalProperties = billingAddress.additionalProperties.toMutableMap() - } - - fun city(city: String?) = city(JsonField.ofNullable(city)) - - fun city(city: Optional) = city(city.orElse(null)) - - fun city(city: JsonField) = apply { this.city = city } - - fun country(country: String?) = country(JsonField.ofNullable(country)) - - fun country(country: Optional) = country(country.orElse(null)) - - fun country(country: JsonField) = apply { this.country = country } - - fun line1(line1: String?) = line1(JsonField.ofNullable(line1)) - - fun line1(line1: Optional) = line1(line1.orElse(null)) - - fun line1(line1: JsonField) = apply { this.line1 = line1 } - - fun line2(line2: String?) = line2(JsonField.ofNullable(line2)) - - fun line2(line2: Optional) = line2(line2.orElse(null)) - - fun line2(line2: JsonField) = apply { this.line2 = line2 } - - fun postalCode(postalCode: String?) = postalCode(JsonField.ofNullable(postalCode)) - - fun postalCode(postalCode: Optional) = postalCode(postalCode.orElse(null)) - - fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode } - - fun state(state: String?) = state(JsonField.ofNullable(state)) - - fun state(state: Optional) = state(state.orElse(null)) - - fun state(state: JsonField) = apply { this.state = state } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingAddress = - BillingAddress( - city, - country, - line1, - line2, - postalCode, - state, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingAddress && city == other.city && country == other.country && line1 == other.line1 && line2 == other.line2 && postalCode == other.postalCode && state == other.state && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(city, country, line1, line2, postalCode, state, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingAddress{city=$city, country=$country, line1=$line1, line2=$line2, postalCode=$postalCode, state=$state, additionalProperties=$additionalProperties}" - } - - /** The hierarchical relationships for this customer. */ - @NoAutoDetect - class Hierarchy - @JsonCreator - private constructor( - @JsonProperty("child_customer_ids") - @ExcludeMissing - private val childCustomerIds: JsonField> = JsonMissing.of(), - @JsonProperty("parent_customer_id") - @ExcludeMissing - private val parentCustomerId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * A list of child customer IDs to add to the hierarchy. The desired child customers must - * not already be part of another hierarchy. - */ - fun childCustomerIds(): Optional> = - Optional.ofNullable(childCustomerIds.getNullable("child_customer_ids")) - - /** - * The ID of the parent customer in the hierarchy. The desired parent customer must not be a - * child of another customer. - */ - fun parentCustomerId(): Optional = - Optional.ofNullable(parentCustomerId.getNullable("parent_customer_id")) - - /** - * A list of child customer IDs to add to the hierarchy. The desired child customers must - * not already be part of another hierarchy. - */ - @JsonProperty("child_customer_ids") - @ExcludeMissing - fun _childCustomerIds(): JsonField> = childCustomerIds - - /** - * The ID of the parent customer in the hierarchy. The desired parent customer must not be a - * child of another customer. - */ - @JsonProperty("parent_customer_id") - @ExcludeMissing - fun _parentCustomerId(): JsonField = parentCustomerId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Hierarchy = apply { - if (validated) { - return@apply - } - - childCustomerIds() - parentCustomerId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Hierarchy]. */ - class Builder internal constructor() { - - private var childCustomerIds: JsonField>? = null - private var parentCustomerId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(hierarchy: Hierarchy) = apply { - childCustomerIds = hierarchy.childCustomerIds.map { it.toMutableList() } - parentCustomerId = hierarchy.parentCustomerId - additionalProperties = hierarchy.additionalProperties.toMutableMap() - } - - /** - * A list of child customer IDs to add to the hierarchy. The desired child customers - * must not already be part of another hierarchy. - */ - fun childCustomerIds(childCustomerIds: List) = - childCustomerIds(JsonField.of(childCustomerIds)) - - /** - * A list of child customer IDs to add to the hierarchy. The desired child customers - * must not already be part of another hierarchy. - */ - fun childCustomerIds(childCustomerIds: JsonField>) = apply { - this.childCustomerIds = childCustomerIds.map { it.toMutableList() } - } - - /** - * A list of child customer IDs to add to the hierarchy. The desired child customers - * must not already be part of another hierarchy. - */ - fun addChildCustomerId(childCustomerId: String) = apply { - childCustomerIds = - (childCustomerIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(childCustomerId) - } - } - - /** - * The ID of the parent customer in the hierarchy. The desired parent customer must not - * be a child of another customer. - */ - fun parentCustomerId(parentCustomerId: String?) = - parentCustomerId(JsonField.ofNullable(parentCustomerId)) - - /** - * The ID of the parent customer in the hierarchy. The desired parent customer must not - * be a child of another customer. - */ - fun parentCustomerId(parentCustomerId: Optional) = - parentCustomerId(parentCustomerId.orElse(null)) - - /** - * The ID of the parent customer in the hierarchy. The desired parent customer must not - * be a child of another customer. - */ - fun parentCustomerId(parentCustomerId: JsonField) = apply { - this.parentCustomerId = parentCustomerId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Hierarchy = - Hierarchy( - (childCustomerIds ?: JsonMissing.of()).map { it.toImmutable() }, - parentCustomerId, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Hierarchy && childCustomerIds == other.childCustomerIds && parentCustomerId == other.parentCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(childCustomerIds, parentCustomerId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Hierarchy{childCustomerIds=$childCustomerIds, parentCustomerId=$parentCustomerId, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - /** - * This is used for creating charges or invoices in an external system via Orb. When not in test - * mode: - * - the connection must first be configured in the Orb webapp. - * - if the provider is an invoicing provider (`stripe_invoice`, `quickbooks`, `bill.com`, - * `netsuite`), any product mappings must first be configured with the Orb team. - */ - 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 QUICKBOOKS = of("quickbooks") - - @JvmField val BILL_COM = of("bill.com") - - @JvmField val STRIPE_CHARGE = of("stripe_charge") - - @JvmField val STRIPE_INVOICE = of("stripe_invoice") - - @JvmField val NETSUITE = of("netsuite") - - @JvmStatic fun of(value: String) = PaymentProvider(JsonField.of(value)) - } - - /** An enum containing [PaymentProvider]'s known values. */ - enum class Known { - QUICKBOOKS, - BILL_COM, - STRIPE_CHARGE, - STRIPE_INVOICE, - NETSUITE, - } - - /** - * 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 { - QUICKBOOKS, - BILL_COM, - STRIPE_CHARGE, - STRIPE_INVOICE, - NETSUITE, - /** - * 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) { - QUICKBOOKS -> Value.QUICKBOOKS - BILL_COM -> Value.BILL_COM - STRIPE_CHARGE -> Value.STRIPE_CHARGE - STRIPE_INVOICE -> Value.STRIPE_INVOICE - 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 - BILL_COM -> Known.BILL_COM - STRIPE_CHARGE -> Known.STRIPE_CHARGE - STRIPE_INVOICE -> Known.STRIPE_INVOICE - NETSUITE -> Known.NETSUITE - 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PaymentProvider && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class ReportingConfiguration - @JsonCreator - private constructor( - @JsonProperty("exempt") - @ExcludeMissing - private val exempt: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun exempt(): Boolean = exempt.getRequired("exempt") - - @JsonProperty("exempt") @ExcludeMissing fun _exempt(): JsonField = exempt - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): ReportingConfiguration = apply { - if (validated) { - return@apply - } - - exempt() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ReportingConfiguration]. */ - class Builder internal constructor() { - - private var exempt: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(reportingConfiguration: ReportingConfiguration) = apply { - exempt = reportingConfiguration.exempt - additionalProperties = reportingConfiguration.additionalProperties.toMutableMap() - } - - fun exempt(exempt: Boolean) = exempt(JsonField.of(exempt)) - - fun exempt(exempt: JsonField) = apply { this.exempt = exempt } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): ReportingConfiguration = - ReportingConfiguration( - checkRequired("exempt", exempt), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ReportingConfiguration && exempt == other.exempt && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(exempt, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ReportingConfiguration{exempt=$exempt, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class ShippingAddress - @JsonCreator - private constructor( - @JsonProperty("city") - @ExcludeMissing - private val city: JsonField = JsonMissing.of(), - @JsonProperty("country") - @ExcludeMissing - private val country: JsonField = JsonMissing.of(), - @JsonProperty("line1") - @ExcludeMissing - private val line1: JsonField = JsonMissing.of(), - @JsonProperty("line2") - @ExcludeMissing - private val line2: JsonField = JsonMissing.of(), - @JsonProperty("postal_code") - @ExcludeMissing - private val postalCode: JsonField = JsonMissing.of(), - @JsonProperty("state") - @ExcludeMissing - private val state: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun city(): Optional = Optional.ofNullable(city.getNullable("city")) - - fun country(): Optional = Optional.ofNullable(country.getNullable("country")) - - fun line1(): Optional = Optional.ofNullable(line1.getNullable("line1")) - - fun line2(): Optional = Optional.ofNullable(line2.getNullable("line2")) - - fun postalCode(): Optional = - Optional.ofNullable(postalCode.getNullable("postal_code")) - - fun state(): Optional = Optional.ofNullable(state.getNullable("state")) - - @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city - - @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country - - @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField = line1 - - @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 - - @JsonProperty("postal_code") - @ExcludeMissing - fun _postalCode(): JsonField = postalCode - - @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): ShippingAddress = apply { - if (validated) { - return@apply - } - - city() - country() - line1() - line2() - postalCode() - state() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ShippingAddress]. */ - class Builder internal constructor() { - - private var city: JsonField = JsonMissing.of() - private var country: JsonField = JsonMissing.of() - private var line1: JsonField = JsonMissing.of() - private var line2: JsonField = JsonMissing.of() - private var postalCode: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(shippingAddress: ShippingAddress) = apply { - city = shippingAddress.city - country = shippingAddress.country - line1 = shippingAddress.line1 - line2 = shippingAddress.line2 - postalCode = shippingAddress.postalCode - state = shippingAddress.state - additionalProperties = shippingAddress.additionalProperties.toMutableMap() - } - - fun city(city: String?) = city(JsonField.ofNullable(city)) - - fun city(city: Optional) = city(city.orElse(null)) - - fun city(city: JsonField) = apply { this.city = city } - - fun country(country: String?) = country(JsonField.ofNullable(country)) - - fun country(country: Optional) = country(country.orElse(null)) - - fun country(country: JsonField) = apply { this.country = country } - - fun line1(line1: String?) = line1(JsonField.ofNullable(line1)) - - fun line1(line1: Optional) = line1(line1.orElse(null)) - - fun line1(line1: JsonField) = apply { this.line1 = line1 } - - fun line2(line2: String?) = line2(JsonField.ofNullable(line2)) - - fun line2(line2: Optional) = line2(line2.orElse(null)) - - fun line2(line2: JsonField) = apply { this.line2 = line2 } - - fun postalCode(postalCode: String?) = postalCode(JsonField.ofNullable(postalCode)) - - fun postalCode(postalCode: Optional) = postalCode(postalCode.orElse(null)) - - fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode } - - fun state(state: String?) = state(JsonField.ofNullable(state)) - - fun state(state: Optional) = state(state.orElse(null)) - - fun state(state: JsonField) = apply { this.state = state } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): ShippingAddress = - ShippingAddress( - city, - country, - line1, - line2, - postalCode, - state, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ShippingAddress && city == other.city && country == other.country && line1 == other.line1 && line2 == other.line2 && postalCode == other.postalCode && state == other.state && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(city, country, line1, line2, postalCode, state, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ShippingAddress{city=$city, country=$country, line1=$line1, line2=$line2, postalCode=$postalCode, state=$state, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(using = TaxConfiguration.Deserializer::class) - @JsonSerialize(using = TaxConfiguration.Serializer::class) - class TaxConfiguration - private constructor( - private val newAvalara: NewAvalaraTaxConfiguration? = null, - private val newTaxJar: NewTaxJarConfiguration? = null, - private val _json: JsonValue? = null, - ) { - - fun newAvalara(): Optional = Optional.ofNullable(newAvalara) - - fun newTaxJar(): Optional = Optional.ofNullable(newTaxJar) - - fun isNewAvalara(): Boolean = newAvalara != null - - fun isNewTaxJar(): Boolean = newTaxJar != null - - fun asNewAvalara(): NewAvalaraTaxConfiguration = newAvalara.getOrThrow("newAvalara") - - fun asNewTaxJar(): NewTaxJarConfiguration = newTaxJar.getOrThrow("newTaxJar") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - newAvalara != null -> visitor.visitNewAvalara(newAvalara) - newTaxJar != null -> visitor.visitNewTaxJar(newTaxJar) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): TaxConfiguration = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitNewAvalara(newAvalara: NewAvalaraTaxConfiguration) { - newAvalara.validate() - } - - override fun visitNewTaxJar(newTaxJar: NewTaxJarConfiguration) { - newTaxJar.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TaxConfiguration && newAvalara == other.newAvalara && newTaxJar == other.newTaxJar /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(newAvalara, newTaxJar) /* spotless:on */ - - override fun toString(): String = - when { - newAvalara != null -> "TaxConfiguration{newAvalara=$newAvalara}" - newTaxJar != null -> "TaxConfiguration{newTaxJar=$newTaxJar}" - _json != null -> "TaxConfiguration{_unknown=$_json}" - else -> throw IllegalStateException("Invalid TaxConfiguration") - } - - companion object { - - @JvmStatic - fun ofNewAvalara(newAvalara: NewAvalaraTaxConfiguration) = - TaxConfiguration(newAvalara = newAvalara) - - @JvmStatic - fun ofNewTaxJar(newTaxJar: NewTaxJarConfiguration) = - TaxConfiguration(newTaxJar = newTaxJar) - } - - /** - * An interface that defines how to map each variant of [TaxConfiguration] to a value of - * type [T]. - */ - interface Visitor { - - fun visitNewAvalara(newAvalara: NewAvalaraTaxConfiguration): T - - fun visitNewTaxJar(newTaxJar: NewTaxJarConfiguration): T - - /** - * Maps an unknown variant of [TaxConfiguration] to a value of type [T]. - * - * An instance of [TaxConfiguration] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown TaxConfiguration: $json") - } - } - - internal class Deserializer : BaseDeserializer(TaxConfiguration::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): TaxConfiguration { - val json = JsonValue.fromJsonNode(node) - val taxProvider = - json.asObject().getOrNull()?.get("tax_provider")?.asString()?.getOrNull() - - when (taxProvider) { - "avalara" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return TaxConfiguration(newAvalara = it, _json = json) - } - } - "taxjar" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return TaxConfiguration(newTaxJar = it, _json = json) - } - } - } - - return TaxConfiguration(_json = json) - } - } - - internal class Serializer : BaseSerializer(TaxConfiguration::class) { - - override fun serialize( - value: TaxConfiguration, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.newAvalara != null -> generator.writeObject(value.newAvalara) - value.newTaxJar != null -> generator.writeObject(value.newTaxJar) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid TaxConfiguration") - } - } - } - - @NoAutoDetect - class NewAvalaraTaxConfiguration - @JsonCreator - private constructor( - @JsonProperty("tax_exempt") - @ExcludeMissing - private val taxExempt: JsonField = JsonMissing.of(), - @JsonProperty("tax_provider") - @ExcludeMissing - private val taxProvider: JsonField = JsonMissing.of(), - @JsonProperty("tax_exemption_code") - @ExcludeMissing - private val taxExemptionCode: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun taxExempt(): Boolean = taxExempt.getRequired("tax_exempt") - - fun taxProvider(): TaxProvider = taxProvider.getRequired("tax_provider") - - fun taxExemptionCode(): Optional = - Optional.ofNullable(taxExemptionCode.getNullable("tax_exemption_code")) - - @JsonProperty("tax_exempt") - @ExcludeMissing - fun _taxExempt(): JsonField = taxExempt - - @JsonProperty("tax_provider") - @ExcludeMissing - fun _taxProvider(): JsonField = taxProvider - - @JsonProperty("tax_exemption_code") - @ExcludeMissing - fun _taxExemptionCode(): JsonField = taxExemptionCode - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewAvalaraTaxConfiguration = apply { - if (validated) { - return@apply - } - - taxExempt() - taxProvider() - taxExemptionCode() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewAvalaraTaxConfiguration]. */ - class Builder internal constructor() { - - private var taxExempt: JsonField? = null - private var taxProvider: JsonField? = null - private var taxExemptionCode: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newAvalaraTaxConfiguration: NewAvalaraTaxConfiguration) = apply { - taxExempt = newAvalaraTaxConfiguration.taxExempt - taxProvider = newAvalaraTaxConfiguration.taxProvider - taxExemptionCode = newAvalaraTaxConfiguration.taxExemptionCode - additionalProperties = - newAvalaraTaxConfiguration.additionalProperties.toMutableMap() - } - - fun taxExempt(taxExempt: Boolean) = taxExempt(JsonField.of(taxExempt)) - - fun taxExempt(taxExempt: JsonField) = apply { this.taxExempt = taxExempt } - - fun taxProvider(taxProvider: TaxProvider) = taxProvider(JsonField.of(taxProvider)) - - fun taxProvider(taxProvider: JsonField) = apply { - this.taxProvider = taxProvider - } - - fun taxExemptionCode(taxExemptionCode: String?) = - taxExemptionCode(JsonField.ofNullable(taxExemptionCode)) - - fun taxExemptionCode(taxExemptionCode: Optional) = - taxExemptionCode(taxExemptionCode.orElse(null)) - - fun taxExemptionCode(taxExemptionCode: JsonField) = apply { - this.taxExemptionCode = taxExemptionCode - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): NewAvalaraTaxConfiguration = - NewAvalaraTaxConfiguration( - checkRequired("taxExempt", taxExempt), - checkRequired("taxProvider", taxProvider), - taxExemptionCode, - additionalProperties.toImmutable(), - ) - } - - class TaxProvider - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val AVALARA = of("avalara") - - @JvmStatic fun of(value: String) = TaxProvider(JsonField.of(value)) - } - - /** An enum containing [TaxProvider]'s known values. */ - enum class Known { - AVALARA - } - - /** - * An enum containing [TaxProvider]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [TaxProvider] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AVALARA, - /** - * An enum member indicating that [TaxProvider] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AVALARA -> Value.AVALARA - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AVALARA -> Known.AVALARA - else -> throw OrbInvalidDataException("Unknown TaxProvider: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TaxProvider && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewAvalaraTaxConfiguration && taxExempt == other.taxExempt && taxProvider == other.taxProvider && taxExemptionCode == other.taxExemptionCode && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(taxExempt, taxProvider, taxExemptionCode, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewAvalaraTaxConfiguration{taxExempt=$taxExempt, taxProvider=$taxProvider, taxExemptionCode=$taxExemptionCode, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewTaxJarConfiguration - @JsonCreator - private constructor( - @JsonProperty("tax_exempt") - @ExcludeMissing - private val taxExempt: JsonField = JsonMissing.of(), - @JsonProperty("tax_provider") - @ExcludeMissing - private val taxProvider: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun taxExempt(): Boolean = taxExempt.getRequired("tax_exempt") - - fun taxProvider(): TaxProvider = taxProvider.getRequired("tax_provider") - - @JsonProperty("tax_exempt") - @ExcludeMissing - fun _taxExempt(): JsonField = taxExempt - - @JsonProperty("tax_provider") - @ExcludeMissing - fun _taxProvider(): JsonField = taxProvider - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewTaxJarConfiguration = apply { - if (validated) { - return@apply - } - - taxExempt() - taxProvider() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewTaxJarConfiguration]. */ - class Builder internal constructor() { - - private var taxExempt: JsonField? = null - private var taxProvider: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newTaxJarConfiguration: NewTaxJarConfiguration) = apply { - taxExempt = newTaxJarConfiguration.taxExempt - taxProvider = newTaxJarConfiguration.taxProvider - additionalProperties = - newTaxJarConfiguration.additionalProperties.toMutableMap() - } - - fun taxExempt(taxExempt: Boolean) = taxExempt(JsonField.of(taxExempt)) - - fun taxExempt(taxExempt: JsonField) = apply { this.taxExempt = taxExempt } - - fun taxProvider(taxProvider: TaxProvider) = taxProvider(JsonField.of(taxProvider)) - - fun taxProvider(taxProvider: JsonField) = apply { - this.taxProvider = taxProvider - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): NewTaxJarConfiguration = - NewTaxJarConfiguration( - checkRequired("taxExempt", taxExempt), - checkRequired("taxProvider", taxProvider), - additionalProperties.toImmutable(), - ) - } - - class TaxProvider - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val TAXJAR = of("taxjar") - - @JvmStatic fun of(value: String) = TaxProvider(JsonField.of(value)) - } - - /** An enum containing [TaxProvider]'s known values. */ - enum class Known { - TAXJAR - } - - /** - * An enum containing [TaxProvider]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [TaxProvider] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TAXJAR, - /** - * An enum member indicating that [TaxProvider] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TAXJAR -> Value.TAXJAR - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - TAXJAR -> Known.TAXJAR - else -> throw OrbInvalidDataException("Unknown TaxProvider: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TaxProvider && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewTaxJarConfiguration && taxExempt == other.taxExempt && taxProvider == other.taxProvider && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(taxExempt, taxProvider, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewTaxJarConfiguration{taxExempt=$taxExempt, taxProvider=$taxProvider, additionalProperties=$additionalProperties}" - } - } - - /** - * 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 | - * |--------------------|------------|-------------------------------------------------------------------------------------------------------| - * |Andorra |`ad_nrt` |Andorran NRT Number | - * |Argentina |`ar_cuit` |Argentinian Tax ID Number | - * |Australia |`au_abn` |Australian Business Number (AU ABN) | - * |Australia |`au_arn` |Australian Taxation Office Reference Number | - * |Austria |`eu_vat` |European VAT Number | - * |Bahrain |`bh_vat` |Bahraini VAT Number | - * |Belgium |`eu_vat` |European VAT Number | - * |Bolivia |`bo_tin` |Bolivian Tax ID | - * |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 | - * |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) | - * |Chile |`cl_tin` |Chilean TIN | - * |China |`cn_tin` |Chinese Tax ID | - * |Colombia |`co_nit` |Colombian NIT Number | - * |Costa Rica |`cr_tin` |Costa Rican Tax ID | - * |Croatia |`eu_vat` |European VAT Number | - * |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 | - * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | - * |Finland |`eu_vat` |European VAT Number | - * |France |`eu_vat` |European VAT Number | - * |Georgia |`ge_vat` |Georgian VAT | - * |Germany |`eu_vat` |European VAT Number | - * |Greece |`eu_vat` |European VAT Number | - * |Hong Kong |`hk_br` |Hong Kong BR Number | - * |Hungary |`eu_vat` |European VAT Number | - * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | - * |Iceland |`is_vat` |Icelandic VAT | - * |India |`in_gst` |Indian GST Number | - * |Indonesia |`id_npwp` |Indonesian NPWP Number | - * |Ireland |`eu_vat` |European VAT Number | - * |Israel |`il_vat` |Israel VAT | - * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | - * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | - * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | - * |Latvia |`eu_vat` |European VAT Number | - * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | - * |Mexico |`mx_rfc` |Mexican RFC Number | - * |Netherlands |`eu_vat` |European VAT Number | - * |New Zealand |`nz_gst` |New Zealand GST Number | - * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | - * |Norway |`no_vat` |Norwegian VAT Number | - * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | - * |Oman |`om_vat` |Omani VAT Number | - * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | - * |Poland |`eu_vat` |European VAT Number | - * |Portugal |`eu_vat` |European VAT Number | - * |Romania |`eu_vat` |European VAT Number | - * |Romania |`ro_tin` |Romanian Tax ID Number | - * |Russia |`ru_inn` |Russian INN | - * |Russia |`ru_kpp` |Russian KPP | - * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | - * |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 | - * |Sweden |`eu_vat` |European VAT Number | - * |Switzerland |`ch_vat` |Switzerland VAT Number | - * |Taiwan |`tw_vat` |Taiwanese VAT | - * |Thailand |`th_vat` |Thai VAT | - * |Turkey |`tr_tin` |Turkish Tax Identification Number | - * |Ukraine |`ua_vat` |Ukrainian VAT | - * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | - * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | - * |United Kingdom |`gb_vat` |United Kingdom VAT Number | - * |United States |`us_ein` |United States EIN | - * |Uruguay |`uy_ruc` |Uruguayan RUC Number | - * |Venezuela |`ve_rif` |Venezuelan RIF Number | - * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | - */ - @NoAutoDetect - class TaxId - @JsonCreator - private constructor( - @JsonProperty("country") - @ExcludeMissing - private val country: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonProperty("value") - @ExcludeMissing - private val value: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun country(): Country = country.getRequired("country") - - fun type(): Type = type.getRequired("type") - - fun value(): String = value.getRequired("value") - - @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country - - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TaxId = apply { - if (validated) { - return@apply - } - - country() - type() - value() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TaxId]. */ - class Builder internal constructor() { - - private var country: JsonField? = null - private var type: JsonField? = null - private var value: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(taxId: TaxId) = apply { - country = taxId.country - type = taxId.type - value = taxId.value - additionalProperties = taxId.additionalProperties.toMutableMap() - } - - fun country(country: Country) = country(JsonField.of(country)) - - fun country(country: JsonField) = apply { this.country = country } - - fun type(type: Type) = type(JsonField.of(type)) - - fun type(type: JsonField) = apply { this.type = type } - - fun value(value: String) = value(JsonField.of(value)) - - fun value(value: JsonField) = apply { this.value = 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) - } - - fun build(): TaxId = - TaxId( - checkRequired("country", country), - checkRequired("type", type), - checkRequired("value", value), - additionalProperties.toImmutable(), - ) - } - - class Country @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val AD = of("AD") - - @JvmField val AE = of("AE") - - @JvmField val AR = of("AR") - - @JvmField val AT = of("AT") - - @JvmField val AU = of("AU") - - @JvmField val BE = of("BE") - - @JvmField val BG = of("BG") - - @JvmField val BH = of("BH") - - @JvmField val BO = of("BO") - - @JvmField val BR = of("BR") - - @JvmField val CA = of("CA") - - @JvmField val CH = of("CH") - - @JvmField val CL = of("CL") - - @JvmField val CN = of("CN") - - @JvmField val CO = of("CO") - - @JvmField val CR = of("CR") - - @JvmField val CY = of("CY") - - @JvmField val CZ = of("CZ") - - @JvmField val DE = of("DE") - - @JvmField val DK = of("DK") - - @JvmField val EE = of("EE") - - @JvmField val DO = of("DO") - - @JvmField val EC = of("EC") - - @JvmField val EG = of("EG") - - @JvmField val ES = of("ES") - - @JvmField val EU = of("EU") - - @JvmField val FI = of("FI") - - @JvmField val FR = of("FR") - - @JvmField val GB = of("GB") - - @JvmField val GE = of("GE") - - @JvmField val GR = of("GR") - - @JvmField val HK = of("HK") - - @JvmField val HR = of("HR") - - @JvmField val HU = of("HU") - - @JvmField val ID = of("ID") - - @JvmField val IE = of("IE") - - @JvmField val IL = of("IL") - - @JvmField val IN = of("IN") - - @JvmField val IS = of("IS") - - @JvmField val IT = of("IT") - - @JvmField val JP = of("JP") - - @JvmField val KE = of("KE") - - @JvmField val KR = of("KR") - - @JvmField val KZ = of("KZ") - - @JvmField val LI = of("LI") - - @JvmField val LT = of("LT") - - @JvmField val LU = of("LU") - - @JvmField val LV = of("LV") - - @JvmField val MT = of("MT") - - @JvmField val MX = of("MX") - - @JvmField val MY = of("MY") - - @JvmField val NG = of("NG") - - @JvmField val NL = of("NL") - - @JvmField val NO = of("NO") - - @JvmField val NZ = of("NZ") - - @JvmField val OM = of("OM") - - @JvmField val PE = of("PE") - - @JvmField val PH = of("PH") - - @JvmField val PL = of("PL") - - @JvmField val PT = of("PT") - - @JvmField val RO = of("RO") - - @JvmField val RS = of("RS") - - @JvmField val RU = of("RU") - - @JvmField val SA = of("SA") - - @JvmField val SE = of("SE") - - @JvmField val SG = of("SG") - - @JvmField val SI = of("SI") - - @JvmField val SK = of("SK") - - @JvmField val SV = of("SV") - - @JvmField val TH = of("TH") - - @JvmField val TR = of("TR") - - @JvmField val TW = of("TW") - - @JvmField val UA = of("UA") - - @JvmField val US = of("US") - - @JvmField val UY = of("UY") - - @JvmField val VE = of("VE") - - @JvmField val VN = of("VN") - - @JvmField val ZA = of("ZA") - - @JvmStatic fun of(value: String) = Country(JsonField.of(value)) - } - - /** An enum containing [Country]'s known values. */ - enum class Known { - AD, - AE, - AR, - AT, - AU, - BE, - BG, - BH, - BO, - BR, - CA, - CH, - CL, - CN, - CO, - CR, - CY, - CZ, - DE, - DK, - EE, - DO, - EC, - EG, - ES, - EU, - FI, - FR, - GB, - GE, - GR, - HK, - HR, - HU, - ID, - IE, - IL, - IN, - IS, - IT, - JP, - KE, - KR, - KZ, - LI, - LT, - LU, - LV, - MT, - MX, - MY, - NG, - NL, - NO, - NZ, - OM, - PE, - PH, - PL, - PT, - RO, - RS, - RU, - SA, - SE, - SG, - SI, - SK, - SV, - TH, - TR, - TW, - UA, - US, - UY, - VE, - VN, - ZA, - } - - /** - * An enum containing [Country]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Country] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AD, - AE, - AR, - AT, - AU, - BE, - BG, - BH, - BO, - BR, - CA, - CH, - CL, - CN, - CO, - CR, - CY, - CZ, - DE, - DK, - EE, - DO, - EC, - EG, - ES, - EU, - FI, - FR, - GB, - GE, - GR, - HK, - HR, - HU, - ID, - IE, - IL, - IN, - IS, - IT, - JP, - KE, - KR, - KZ, - LI, - LT, - LU, - LV, - MT, - MX, - MY, - NG, - NL, - NO, - NZ, - OM, - PE, - PH, - PL, - PT, - RO, - RS, - RU, - SA, - SE, - SG, - SI, - SK, - SV, - TH, - TR, - TW, - UA, - US, - UY, - VE, - VN, - ZA, - /** - * An enum member indicating that [Country] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AD -> Value.AD - AE -> Value.AE - AR -> Value.AR - AT -> Value.AT - AU -> Value.AU - BE -> Value.BE - BG -> Value.BG - BH -> Value.BH - BO -> Value.BO - BR -> Value.BR - CA -> Value.CA - CH -> Value.CH - CL -> Value.CL - CN -> Value.CN - CO -> Value.CO - CR -> Value.CR - CY -> Value.CY - CZ -> Value.CZ - DE -> Value.DE - DK -> Value.DK - EE -> Value.EE - DO -> Value.DO - EC -> Value.EC - EG -> Value.EG - ES -> Value.ES - EU -> Value.EU - FI -> Value.FI - FR -> Value.FR - GB -> Value.GB - GE -> Value.GE - GR -> Value.GR - HK -> Value.HK - HR -> Value.HR - HU -> Value.HU - ID -> Value.ID - IE -> Value.IE - IL -> Value.IL - IN -> Value.IN - IS -> Value.IS - IT -> Value.IT - JP -> Value.JP - KE -> Value.KE - KR -> Value.KR - KZ -> Value.KZ - LI -> Value.LI - LT -> Value.LT - LU -> Value.LU - LV -> Value.LV - MT -> Value.MT - MX -> Value.MX - MY -> Value.MY - NG -> Value.NG - NL -> Value.NL - NO -> Value.NO - NZ -> Value.NZ - OM -> Value.OM - PE -> Value.PE - PH -> Value.PH - PL -> Value.PL - PT -> Value.PT - RO -> Value.RO - RS -> Value.RS - RU -> Value.RU - SA -> Value.SA - SE -> Value.SE - SG -> Value.SG - SI -> Value.SI - SK -> Value.SK - SV -> Value.SV - TH -> Value.TH - TR -> Value.TR - TW -> Value.TW - UA -> Value.UA - US -> Value.US - UY -> Value.UY - VE -> Value.VE - VN -> Value.VN - ZA -> Value.ZA - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AD -> Known.AD - AE -> Known.AE - AR -> Known.AR - AT -> Known.AT - AU -> Known.AU - BE -> Known.BE - BG -> Known.BG - BH -> Known.BH - BO -> Known.BO - BR -> Known.BR - CA -> Known.CA - CH -> Known.CH - CL -> Known.CL - CN -> Known.CN - CO -> Known.CO - CR -> Known.CR - CY -> Known.CY - CZ -> Known.CZ - DE -> Known.DE - DK -> Known.DK - EE -> Known.EE - DO -> Known.DO - EC -> Known.EC - EG -> Known.EG - ES -> Known.ES - EU -> Known.EU - FI -> Known.FI - FR -> Known.FR - GB -> Known.GB - GE -> Known.GE - GR -> Known.GR - HK -> Known.HK - HR -> Known.HR - HU -> Known.HU - ID -> Known.ID - IE -> Known.IE - IL -> Known.IL - IN -> Known.IN - IS -> Known.IS - IT -> Known.IT - JP -> Known.JP - KE -> Known.KE - KR -> Known.KR - KZ -> Known.KZ - LI -> Known.LI - LT -> Known.LT - LU -> Known.LU - LV -> Known.LV - MT -> Known.MT - MX -> Known.MX - MY -> Known.MY - NG -> Known.NG - NL -> Known.NL - NO -> Known.NO - NZ -> Known.NZ - OM -> Known.OM - PE -> Known.PE - PH -> Known.PH - PL -> Known.PL - PT -> Known.PT - RO -> Known.RO - RS -> Known.RS - RU -> Known.RU - SA -> Known.SA - SE -> Known.SE - SG -> Known.SG - SI -> Known.SI - SK -> Known.SK - SV -> Known.SV - TH -> Known.TH - TR -> Known.TR - TW -> Known.TW - UA -> Known.UA - US -> Known.US - UY -> Known.UY - VE -> Known.VE - VN -> Known.VN - ZA -> Known.ZA - else -> throw OrbInvalidDataException("Unknown Country: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is Country && value == other.value /* spotless:on */ - } - - 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 AD_NRT = of("ad_nrt") - - @JvmField val AE_TRN = of("ae_trn") - - @JvmField val AR_CUIT = of("ar_cuit") - - @JvmField val EU_VAT = of("eu_vat") - - @JvmField val AU_ABN = of("au_abn") - - @JvmField val AU_ARN = of("au_arn") - - @JvmField val BG_UIC = of("bg_uic") - - @JvmField val BH_VAT = of("bh_vat") - - @JvmField val BO_TIN = of("bo_tin") - - @JvmField val BR_CNPJ = of("br_cnpj") - - @JvmField val BR_CPF = of("br_cpf") - - @JvmField val CA_BN = of("ca_bn") - - @JvmField val CA_GST_HST = of("ca_gst_hst") - - @JvmField val CA_PST_BC = of("ca_pst_bc") - - @JvmField val CA_PST_MB = of("ca_pst_mb") - - @JvmField val CA_PST_SK = of("ca_pst_sk") - - @JvmField val CA_QST = of("ca_qst") - - @JvmField val CH_VAT = of("ch_vat") - - @JvmField val CL_TIN = of("cl_tin") - - @JvmField val CN_TIN = of("cn_tin") - - @JvmField val CO_NIT = of("co_nit") - - @JvmField val CR_TIN = of("cr_tin") - - @JvmField val DO_RCN = of("do_rcn") - - @JvmField val EC_RUC = of("ec_ruc") - - @JvmField val EG_TIN = of("eg_tin") - - @JvmField val ES_CIF = of("es_cif") - - @JvmField val EU_OSS_VAT = of("eu_oss_vat") - - @JvmField val GB_VAT = of("gb_vat") - - @JvmField val GE_VAT = of("ge_vat") - - @JvmField val HK_BR = of("hk_br") - - @JvmField val HU_TIN = of("hu_tin") - - @JvmField val ID_NPWP = of("id_npwp") - - @JvmField val IL_VAT = of("il_vat") - - @JvmField val IN_GST = of("in_gst") - - @JvmField val IS_VAT = of("is_vat") - - @JvmField val JP_CN = of("jp_cn") - - @JvmField val JP_RN = of("jp_rn") - - @JvmField val JP_TRN = of("jp_trn") - - @JvmField val KE_PIN = of("ke_pin") - - @JvmField val KR_BRN = of("kr_brn") - - @JvmField val KZ_BIN = of("kz_bin") - - @JvmField val LI_UID = of("li_uid") - - @JvmField val MX_RFC = of("mx_rfc") - - @JvmField val MY_FRP = of("my_frp") - - @JvmField val MY_ITN = of("my_itn") - - @JvmField val MY_SST = of("my_sst") - - @JvmField val NG_TIN = of("ng_tin") - - @JvmField val NO_VAT = of("no_vat") - - @JvmField val NO_VOEC = of("no_voec") - - @JvmField val NZ_GST = of("nz_gst") - - @JvmField val OM_VAT = of("om_vat") - - @JvmField val PE_RUC = of("pe_ruc") - - @JvmField val PH_TIN = of("ph_tin") - - @JvmField val RO_TIN = of("ro_tin") - - @JvmField val RS_PIB = of("rs_pib") - - @JvmField val RU_INN = of("ru_inn") - - @JvmField val RU_KPP = of("ru_kpp") - - @JvmField val SA_VAT = of("sa_vat") - - @JvmField val SG_GST = of("sg_gst") - - @JvmField val SG_UEN = of("sg_uen") - - @JvmField val SI_TIN = of("si_tin") - - @JvmField val SV_NIT = of("sv_nit") - - @JvmField val TH_VAT = of("th_vat") - - @JvmField val TR_TIN = of("tr_tin") - - @JvmField val TW_VAT = of("tw_vat") - - @JvmField val UA_VAT = of("ua_vat") - - @JvmField val US_EIN = of("us_ein") - - @JvmField val UY_RUC = of("uy_ruc") - - @JvmField val VE_RIF = of("ve_rif") - - @JvmField val VN_TIN = of("vn_tin") - - @JvmField val ZA_VAT = of("za_vat") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - AD_NRT, - AE_TRN, - AR_CUIT, - EU_VAT, - AU_ABN, - AU_ARN, - BG_UIC, - BH_VAT, - BO_TIN, - BR_CNPJ, - BR_CPF, - CA_BN, - CA_GST_HST, - CA_PST_BC, - CA_PST_MB, - CA_PST_SK, - CA_QST, - CH_VAT, - CL_TIN, - CN_TIN, - CO_NIT, - CR_TIN, - DO_RCN, - EC_RUC, - EG_TIN, - ES_CIF, - EU_OSS_VAT, - GB_VAT, - GE_VAT, - HK_BR, - HU_TIN, - ID_NPWP, - IL_VAT, - IN_GST, - IS_VAT, - JP_CN, - JP_RN, - JP_TRN, - KE_PIN, - KR_BRN, - KZ_BIN, - LI_UID, - MX_RFC, - MY_FRP, - MY_ITN, - MY_SST, - NG_TIN, - NO_VAT, - NO_VOEC, - NZ_GST, - OM_VAT, - PE_RUC, - PH_TIN, - RO_TIN, - RS_PIB, - RU_INN, - RU_KPP, - SA_VAT, - SG_GST, - SG_UEN, - SI_TIN, - SV_NIT, - TH_VAT, - TR_TIN, - TW_VAT, - UA_VAT, - US_EIN, - UY_RUC, - VE_RIF, - VN_TIN, - ZA_VAT, - } - - /** - * 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 { - AD_NRT, - AE_TRN, - AR_CUIT, - EU_VAT, - AU_ABN, - AU_ARN, - BG_UIC, - BH_VAT, - BO_TIN, - BR_CNPJ, - BR_CPF, - CA_BN, - CA_GST_HST, - CA_PST_BC, - CA_PST_MB, - CA_PST_SK, - CA_QST, - CH_VAT, - CL_TIN, - CN_TIN, - CO_NIT, - CR_TIN, - DO_RCN, - EC_RUC, - EG_TIN, - ES_CIF, - EU_OSS_VAT, - GB_VAT, - GE_VAT, - HK_BR, - HU_TIN, - ID_NPWP, - IL_VAT, - IN_GST, - IS_VAT, - JP_CN, - JP_RN, - JP_TRN, - KE_PIN, - KR_BRN, - KZ_BIN, - LI_UID, - MX_RFC, - MY_FRP, - MY_ITN, - MY_SST, - NG_TIN, - NO_VAT, - NO_VOEC, - NZ_GST, - OM_VAT, - PE_RUC, - PH_TIN, - RO_TIN, - RS_PIB, - RU_INN, - RU_KPP, - SA_VAT, - SG_GST, - SG_UEN, - SI_TIN, - SV_NIT, - TH_VAT, - TR_TIN, - TW_VAT, - UA_VAT, - US_EIN, - UY_RUC, - VE_RIF, - VN_TIN, - ZA_VAT, - /** 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) { - AD_NRT -> Value.AD_NRT - AE_TRN -> Value.AE_TRN - AR_CUIT -> Value.AR_CUIT - EU_VAT -> Value.EU_VAT - AU_ABN -> Value.AU_ABN - AU_ARN -> Value.AU_ARN - BG_UIC -> Value.BG_UIC - BH_VAT -> Value.BH_VAT - BO_TIN -> Value.BO_TIN - BR_CNPJ -> Value.BR_CNPJ - BR_CPF -> Value.BR_CPF - CA_BN -> Value.CA_BN - CA_GST_HST -> Value.CA_GST_HST - CA_PST_BC -> Value.CA_PST_BC - CA_PST_MB -> Value.CA_PST_MB - CA_PST_SK -> Value.CA_PST_SK - CA_QST -> Value.CA_QST - CH_VAT -> Value.CH_VAT - CL_TIN -> Value.CL_TIN - CN_TIN -> Value.CN_TIN - CO_NIT -> Value.CO_NIT - CR_TIN -> Value.CR_TIN - DO_RCN -> Value.DO_RCN - EC_RUC -> Value.EC_RUC - EG_TIN -> Value.EG_TIN - ES_CIF -> Value.ES_CIF - EU_OSS_VAT -> Value.EU_OSS_VAT - GB_VAT -> Value.GB_VAT - GE_VAT -> Value.GE_VAT - HK_BR -> Value.HK_BR - HU_TIN -> Value.HU_TIN - ID_NPWP -> Value.ID_NPWP - IL_VAT -> Value.IL_VAT - IN_GST -> Value.IN_GST - IS_VAT -> Value.IS_VAT - JP_CN -> Value.JP_CN - JP_RN -> Value.JP_RN - JP_TRN -> Value.JP_TRN - KE_PIN -> Value.KE_PIN - KR_BRN -> Value.KR_BRN - KZ_BIN -> Value.KZ_BIN - LI_UID -> Value.LI_UID - MX_RFC -> Value.MX_RFC - MY_FRP -> Value.MY_FRP - MY_ITN -> Value.MY_ITN - MY_SST -> Value.MY_SST - NG_TIN -> Value.NG_TIN - NO_VAT -> Value.NO_VAT - NO_VOEC -> Value.NO_VOEC - NZ_GST -> Value.NZ_GST - OM_VAT -> Value.OM_VAT - PE_RUC -> Value.PE_RUC - PH_TIN -> Value.PH_TIN - RO_TIN -> Value.RO_TIN - RS_PIB -> Value.RS_PIB - RU_INN -> Value.RU_INN - RU_KPP -> Value.RU_KPP - SA_VAT -> Value.SA_VAT - SG_GST -> Value.SG_GST - SG_UEN -> Value.SG_UEN - SI_TIN -> Value.SI_TIN - SV_NIT -> Value.SV_NIT - TH_VAT -> Value.TH_VAT - TR_TIN -> Value.TR_TIN - TW_VAT -> Value.TW_VAT - UA_VAT -> Value.UA_VAT - US_EIN -> Value.US_EIN - UY_RUC -> Value.UY_RUC - VE_RIF -> Value.VE_RIF - VN_TIN -> Value.VN_TIN - ZA_VAT -> Value.ZA_VAT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AD_NRT -> Known.AD_NRT - AE_TRN -> Known.AE_TRN - AR_CUIT -> Known.AR_CUIT - EU_VAT -> Known.EU_VAT - AU_ABN -> Known.AU_ABN - AU_ARN -> Known.AU_ARN - BG_UIC -> Known.BG_UIC - BH_VAT -> Known.BH_VAT - BO_TIN -> Known.BO_TIN - BR_CNPJ -> Known.BR_CNPJ - BR_CPF -> Known.BR_CPF - CA_BN -> Known.CA_BN - CA_GST_HST -> Known.CA_GST_HST - CA_PST_BC -> Known.CA_PST_BC - CA_PST_MB -> Known.CA_PST_MB - CA_PST_SK -> Known.CA_PST_SK - CA_QST -> Known.CA_QST - CH_VAT -> Known.CH_VAT - CL_TIN -> Known.CL_TIN - CN_TIN -> Known.CN_TIN - CO_NIT -> Known.CO_NIT - CR_TIN -> Known.CR_TIN - DO_RCN -> Known.DO_RCN - EC_RUC -> Known.EC_RUC - EG_TIN -> Known.EG_TIN - ES_CIF -> Known.ES_CIF - EU_OSS_VAT -> Known.EU_OSS_VAT - GB_VAT -> Known.GB_VAT - GE_VAT -> Known.GE_VAT - HK_BR -> Known.HK_BR - HU_TIN -> Known.HU_TIN - ID_NPWP -> Known.ID_NPWP - IL_VAT -> Known.IL_VAT - IN_GST -> Known.IN_GST - IS_VAT -> Known.IS_VAT - JP_CN -> Known.JP_CN - JP_RN -> Known.JP_RN - JP_TRN -> Known.JP_TRN - KE_PIN -> Known.KE_PIN - KR_BRN -> Known.KR_BRN - KZ_BIN -> Known.KZ_BIN - LI_UID -> Known.LI_UID - MX_RFC -> Known.MX_RFC - MY_FRP -> Known.MY_FRP - MY_ITN -> Known.MY_ITN - MY_SST -> Known.MY_SST - NG_TIN -> Known.NG_TIN - NO_VAT -> Known.NO_VAT - NO_VOEC -> Known.NO_VOEC - NZ_GST -> Known.NZ_GST - OM_VAT -> Known.OM_VAT - PE_RUC -> Known.PE_RUC - PH_TIN -> Known.PH_TIN - RO_TIN -> Known.RO_TIN - RS_PIB -> Known.RS_PIB - RU_INN -> Known.RU_INN - RU_KPP -> Known.RU_KPP - SA_VAT -> Known.SA_VAT - SG_GST -> Known.SG_GST - SG_UEN -> Known.SG_UEN - SI_TIN -> Known.SI_TIN - SV_NIT -> Known.SV_NIT - TH_VAT -> Known.TH_VAT - TR_TIN -> Known.TR_TIN - TW_VAT -> Known.TW_VAT - UA_VAT -> Known.UA_VAT - US_EIN -> Known.US_EIN - UY_RUC -> Known.UY_RUC - VE_RIF -> Known.VE_RIF - VN_TIN -> Known.VN_TIN - ZA_VAT -> Known.ZA_VAT - 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TaxId && country == other.country && type == other.type && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(country, type, value, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TaxId{country=$country, type=$type, value=$value, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is CustomerUpdateByExternalIdParams && id == other.id && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is CustomerUpdateByExternalIdParams && id == other.id && editCustomerModel == other.editCustomerModel && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(id, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(id, editCustomerModel, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "CustomerUpdateByExternalIdParams{id=$id, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "CustomerUpdateByExternalIdParams{id=$id, editCustomerModel=$editCustomerModel, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt index da59e1411..8027fef15 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 @@ -2,36 +2,13 @@ package com.withorb.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer -import com.withorb.api.core.Enum -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.Params import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams -import com.withorb.api.core.immutableEmptyMap -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull /** * This endpoint can be used to update the `payment_provider`, `payment_provider_id`, `name`, @@ -42,375 +19,23 @@ import kotlin.jvm.optionals.getOrNull class CustomerUpdateParams private constructor( private val customerId: String, - private val body: Body, + private val editCustomerModel: EditCustomerModel, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { fun customerId(): String = customerId - fun accountingSyncConfiguration(): Optional = - body.accountingSyncConfiguration() + fun editCustomerModel(): EditCustomerModel = editCustomerModel - /** - * Additional email addresses for this customer. If populated, these email addresses will be - * CC'd for customer communications. - */ - fun additionalEmails(): Optional> = body.additionalEmails() - - /** - * Used to determine if invoices for this customer will automatically attempt to charge a saved - * payment method, if available. This parameter defaults to `True` when a payment provider is - * provided on customer creation. - */ - fun autoCollection(): Optional = body.autoCollection() - - 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. - */ - fun currency(): Optional = body.currency() - - /** A valid customer email, to be used for invoicing and notifications. */ - fun email(): Optional = body.email() - - fun emailDelivery(): Optional = body.emailDelivery() - - /** - * The external customer ID. This can only be set if empty and the customer has no past or - * current subscriptions. - */ - fun externalCustomerId(): Optional = body.externalCustomerId() - - /** The hierarchical relationships for this customer. */ - fun hierarchy(): Optional = body.hierarchy() - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - */ - fun metadata(): Optional = body.metadata() - - /** The full name of the customer */ - fun name(): Optional = body.name() - - /** - * This is used for creating charges or invoices in an external system via Orb. When not in test - * mode: - * - the connection must first be configured in the Orb webapp. - * - if the provider is an invoicing provider (`stripe_invoice`, `quickbooks`, `bill.com`, - * `netsuite`), any product mappings must first be configured with the Orb team. - */ - fun paymentProvider(): Optional = body.paymentProvider() - - /** - * The ID of this customer in an external payments solution, such as Stripe. This is used for - * creating charges or invoices in the external system via Orb. - */ - fun paymentProviderId(): Optional = body.paymentProviderId() - - fun reportingConfiguration(): Optional = body.reportingConfiguration() - - fun shippingAddress(): Optional = body.shippingAddress() - - fun taxConfiguration(): Optional = body.taxConfiguration() - - /** - * 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 | - * |--------------------|------------|-------------------------------------------------------------------------------------------------------| - * |Andorra |`ad_nrt` |Andorran NRT Number | - * |Argentina |`ar_cuit` |Argentinian Tax ID Number | - * |Australia |`au_abn` |Australian Business Number (AU ABN) | - * |Australia |`au_arn` |Australian Taxation Office Reference Number | - * |Austria |`eu_vat` |European VAT Number | - * |Bahrain |`bh_vat` |Bahraini VAT Number | - * |Belgium |`eu_vat` |European VAT Number | - * |Bolivia |`bo_tin` |Bolivian Tax ID | - * |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 | - * |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) | - * |Chile |`cl_tin` |Chilean TIN | - * |China |`cn_tin` |Chinese Tax ID | - * |Colombia |`co_nit` |Colombian NIT Number | - * |Costa Rica |`cr_tin` |Costa Rican Tax ID | - * |Croatia |`eu_vat` |European VAT Number | - * |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 | - * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | - * |Finland |`eu_vat` |European VAT Number | - * |France |`eu_vat` |European VAT Number | - * |Georgia |`ge_vat` |Georgian VAT | - * |Germany |`eu_vat` |European VAT Number | - * |Greece |`eu_vat` |European VAT Number | - * |Hong Kong |`hk_br` |Hong Kong BR Number | - * |Hungary |`eu_vat` |European VAT Number | - * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | - * |Iceland |`is_vat` |Icelandic VAT | - * |India |`in_gst` |Indian GST Number | - * |Indonesia |`id_npwp` |Indonesian NPWP Number | - * |Ireland |`eu_vat` |European VAT Number | - * |Israel |`il_vat` |Israel VAT | - * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | - * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | - * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | - * |Latvia |`eu_vat` |European VAT Number | - * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | - * |Mexico |`mx_rfc` |Mexican RFC Number | - * |Netherlands |`eu_vat` |European VAT Number | - * |New Zealand |`nz_gst` |New Zealand GST Number | - * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | - * |Norway |`no_vat` |Norwegian VAT Number | - * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | - * |Oman |`om_vat` |Omani VAT Number | - * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | - * |Poland |`eu_vat` |European VAT Number | - * |Portugal |`eu_vat` |European VAT Number | - * |Romania |`eu_vat` |European VAT Number | - * |Romania |`ro_tin` |Romanian Tax ID Number | - * |Russia |`ru_inn` |Russian INN | - * |Russia |`ru_kpp` |Russian KPP | - * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | - * |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 | - * |Sweden |`eu_vat` |European VAT Number | - * |Switzerland |`ch_vat` |Switzerland VAT Number | - * |Taiwan |`tw_vat` |Taiwanese VAT | - * |Thailand |`th_vat` |Thai VAT | - * |Turkey |`tr_tin` |Turkish Tax Identification Number | - * |Ukraine |`ua_vat` |Ukrainian VAT | - * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | - * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | - * |United Kingdom |`gb_vat` |United Kingdom VAT Number | - * |United States |`us_ein` |United States EIN | - * |Uruguay |`uy_ruc` |Uruguayan RUC Number | - * |Venezuela |`ve_rif` |Venezuelan RIF Number | - * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | - */ - fun taxId(): Optional = body.taxId() - - fun _accountingSyncConfiguration(): JsonField = - body._accountingSyncConfiguration() - - /** - * Additional email addresses for this customer. If populated, these email addresses will be - * CC'd for customer communications. - */ - fun _additionalEmails(): JsonField> = body._additionalEmails() - - /** - * Used to determine if invoices for this customer will automatically attempt to charge a saved - * payment method, if available. This parameter defaults to `True` when a payment provider is - * provided on customer creation. - */ - fun _autoCollection(): JsonField = body._autoCollection() - - fun _billingAddress(): JsonField = 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. - */ - fun _currency(): JsonField = body._currency() - - /** A valid customer email, to be used for invoicing and notifications. */ - fun _email(): JsonField = body._email() - - fun _emailDelivery(): JsonField = body._emailDelivery() - - /** - * The external customer ID. This can only be set if empty and the customer has no past or - * current subscriptions. - */ - fun _externalCustomerId(): JsonField = body._externalCustomerId() - - /** The hierarchical relationships for this customer. */ - fun _hierarchy(): JsonField = body._hierarchy() - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - */ - fun _metadata(): JsonField = body._metadata() - - /** The full name of the customer */ - fun _name(): JsonField = body._name() - - /** - * This is used for creating charges or invoices in an external system via Orb. When not in test - * mode: - * - the connection must first be configured in the Orb webapp. - * - if the provider is an invoicing provider (`stripe_invoice`, `quickbooks`, `bill.com`, - * `netsuite`), any product mappings must first be configured with the Orb team. - */ - fun _paymentProvider(): JsonField = body._paymentProvider() - - /** - * The ID of this customer in an external payments solution, such as Stripe. This is used for - * creating charges or invoices in the external system via Orb. - */ - fun _paymentProviderId(): JsonField = body._paymentProviderId() - - fun _reportingConfiguration(): JsonField = - body._reportingConfiguration() - - fun _shippingAddress(): JsonField = body._shippingAddress() - - fun _taxConfiguration(): JsonField = body._taxConfiguration() - - /** - * 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 | - * |--------------------|------------|-------------------------------------------------------------------------------------------------------| - * |Andorra |`ad_nrt` |Andorran NRT Number | - * |Argentina |`ar_cuit` |Argentinian Tax ID Number | - * |Australia |`au_abn` |Australian Business Number (AU ABN) | - * |Australia |`au_arn` |Australian Taxation Office Reference Number | - * |Austria |`eu_vat` |European VAT Number | - * |Bahrain |`bh_vat` |Bahraini VAT Number | - * |Belgium |`eu_vat` |European VAT Number | - * |Bolivia |`bo_tin` |Bolivian Tax ID | - * |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 | - * |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) | - * |Chile |`cl_tin` |Chilean TIN | - * |China |`cn_tin` |Chinese Tax ID | - * |Colombia |`co_nit` |Colombian NIT Number | - * |Costa Rica |`cr_tin` |Costa Rican Tax ID | - * |Croatia |`eu_vat` |European VAT Number | - * |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 | - * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | - * |Finland |`eu_vat` |European VAT Number | - * |France |`eu_vat` |European VAT Number | - * |Georgia |`ge_vat` |Georgian VAT | - * |Germany |`eu_vat` |European VAT Number | - * |Greece |`eu_vat` |European VAT Number | - * |Hong Kong |`hk_br` |Hong Kong BR Number | - * |Hungary |`eu_vat` |European VAT Number | - * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | - * |Iceland |`is_vat` |Icelandic VAT | - * |India |`in_gst` |Indian GST Number | - * |Indonesia |`id_npwp` |Indonesian NPWP Number | - * |Ireland |`eu_vat` |European VAT Number | - * |Israel |`il_vat` |Israel VAT | - * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | - * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | - * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | - * |Latvia |`eu_vat` |European VAT Number | - * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | - * |Mexico |`mx_rfc` |Mexican RFC Number | - * |Netherlands |`eu_vat` |European VAT Number | - * |New Zealand |`nz_gst` |New Zealand GST Number | - * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | - * |Norway |`no_vat` |Norwegian VAT Number | - * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | - * |Oman |`om_vat` |Omani VAT Number | - * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | - * |Poland |`eu_vat` |European VAT Number | - * |Portugal |`eu_vat` |European VAT Number | - * |Romania |`eu_vat` |European VAT Number | - * |Romania |`ro_tin` |Romanian Tax ID Number | - * |Russia |`ru_inn` |Russian INN | - * |Russia |`ru_kpp` |Russian KPP | - * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | - * |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 | - * |Sweden |`eu_vat` |European VAT Number | - * |Switzerland |`ch_vat` |Switzerland VAT Number | - * |Taiwan |`tw_vat` |Taiwanese VAT | - * |Thailand |`th_vat` |Thai VAT | - * |Turkey |`tr_tin` |Turkish Tax Identification Number | - * |Ukraine |`ua_vat` |Ukrainian VAT | - * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | - * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | - * |United Kingdom |`gb_vat` |United Kingdom VAT Number | - * |United States |`us_ein` |United States EIN | - * |Uruguay |`uy_ruc` |Uruguayan RUC Number | - * |Venezuela |`ve_rif` |Venezuelan RIF Number | - * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | - */ - fun _taxId(): JsonField = body._taxId() - - fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalBodyProperties(): Map = + editCustomerModel._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): EditCustomerModel = editCustomerModel override fun _headers(): Headers = additionalHeaders @@ -423,1239 +48,19 @@ private constructor( } } - @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("accounting_sync_configuration") - @ExcludeMissing - private val accountingSyncConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("additional_emails") - @ExcludeMissing - private val additionalEmails: JsonField> = JsonMissing.of(), - @JsonProperty("auto_collection") - @ExcludeMissing - private val autoCollection: JsonField = JsonMissing.of(), - @JsonProperty("billing_address") - @ExcludeMissing - private val billingAddress: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("email") - @ExcludeMissing - private val email: JsonField = JsonMissing.of(), - @JsonProperty("email_delivery") - @ExcludeMissing - private val emailDelivery: JsonField = JsonMissing.of(), - @JsonProperty("external_customer_id") - @ExcludeMissing - private val externalCustomerId: JsonField = JsonMissing.of(), - @JsonProperty("hierarchy") - @ExcludeMissing - private val hierarchy: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("payment_provider") - @ExcludeMissing - private val paymentProvider: JsonField = JsonMissing.of(), - @JsonProperty("payment_provider_id") - @ExcludeMissing - private val paymentProviderId: JsonField = JsonMissing.of(), - @JsonProperty("reporting_configuration") - @ExcludeMissing - private val reportingConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("shipping_address") - @ExcludeMissing - private val shippingAddress: JsonField = JsonMissing.of(), - @JsonProperty("tax_configuration") - @ExcludeMissing - private val taxConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("tax_id") - @ExcludeMissing - private val taxId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun accountingSyncConfiguration(): Optional = - Optional.ofNullable( - accountingSyncConfiguration.getNullable("accounting_sync_configuration") - ) - - /** - * Additional email addresses for this customer. If populated, these email addresses will be - * CC'd for customer communications. - */ - fun additionalEmails(): Optional> = - Optional.ofNullable(additionalEmails.getNullable("additional_emails")) - - /** - * Used to determine if invoices for this customer will automatically attempt to charge a - * saved payment method, if available. This parameter defaults to `True` when a payment - * provider is provided on customer creation. - */ - fun autoCollection(): Optional = - Optional.ofNullable(autoCollection.getNullable("auto_collection")) - - fun billingAddress(): Optional = - Optional.ofNullable(billingAddress.getNullable("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. - */ - fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) - - /** A valid customer email, to be used for invoicing and notifications. */ - fun email(): Optional = Optional.ofNullable(email.getNullable("email")) - - fun emailDelivery(): Optional = - Optional.ofNullable(emailDelivery.getNullable("email_delivery")) - - /** - * The external customer ID. This can only be set if empty and the customer has no past or - * current subscriptions. - */ - fun externalCustomerId(): Optional = - Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - - /** The hierarchical relationships for this customer. */ - fun hierarchy(): Optional = - Optional.ofNullable(hierarchy.getNullable("hierarchy")) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by setting - * `metadata` to `null`. - */ - fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - - /** The full name of the customer */ - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - /** - * This is used for creating charges or invoices in an external system via Orb. When not in - * test mode: - * - the connection must first be configured in the Orb webapp. - * - if the provider is an invoicing provider (`stripe_invoice`, `quickbooks`, `bill.com`, - * `netsuite`), any product mappings must first be configured with the Orb team. - */ - fun paymentProvider(): Optional = - Optional.ofNullable(paymentProvider.getNullable("payment_provider")) - - /** - * The ID of this customer in an external payments solution, such as Stripe. This is used - * for creating charges or invoices in the external system via Orb. - */ - fun paymentProviderId(): Optional = - Optional.ofNullable(paymentProviderId.getNullable("payment_provider_id")) - - fun reportingConfiguration(): Optional = - Optional.ofNullable(reportingConfiguration.getNullable("reporting_configuration")) - - fun shippingAddress(): Optional = - Optional.ofNullable(shippingAddress.getNullable("shipping_address")) - - fun taxConfiguration(): Optional = - Optional.ofNullable(taxConfiguration.getNullable("tax_configuration")) - - /** - * 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 | - * |--------------------|------------|-------------------------------------------------------------------------------------------------------| - * |Andorra |`ad_nrt` |Andorran NRT Number | - * |Argentina |`ar_cuit` |Argentinian Tax ID Number | - * |Australia |`au_abn` |Australian Business Number (AU ABN) | - * |Australia |`au_arn` |Australian Taxation Office Reference Number | - * |Austria |`eu_vat` |European VAT Number | - * |Bahrain |`bh_vat` |Bahraini VAT Number | - * |Belgium |`eu_vat` |European VAT Number | - * |Bolivia |`bo_tin` |Bolivian Tax ID | - * |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 | - * |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) | - * |Chile |`cl_tin` |Chilean TIN | - * |China |`cn_tin` |Chinese Tax ID | - * |Colombia |`co_nit` |Colombian NIT Number | - * |Costa Rica |`cr_tin` |Costa Rican Tax ID | - * |Croatia |`eu_vat` |European VAT Number | - * |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 | - * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | - * |Finland |`eu_vat` |European VAT Number | - * |France |`eu_vat` |European VAT Number | - * |Georgia |`ge_vat` |Georgian VAT | - * |Germany |`eu_vat` |European VAT Number | - * |Greece |`eu_vat` |European VAT Number | - * |Hong Kong |`hk_br` |Hong Kong BR Number | - * |Hungary |`eu_vat` |European VAT Number | - * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | - * |Iceland |`is_vat` |Icelandic VAT | - * |India |`in_gst` |Indian GST Number | - * |Indonesia |`id_npwp` |Indonesian NPWP Number | - * |Ireland |`eu_vat` |European VAT Number | - * |Israel |`il_vat` |Israel VAT | - * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | - * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | - * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | - * |Latvia |`eu_vat` |European VAT Number | - * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | - * |Mexico |`mx_rfc` |Mexican RFC Number | - * |Netherlands |`eu_vat` |European VAT Number | - * |New Zealand |`nz_gst` |New Zealand GST Number | - * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | - * |Norway |`no_vat` |Norwegian VAT Number | - * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | - * |Oman |`om_vat` |Omani VAT Number | - * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | - * |Poland |`eu_vat` |European VAT Number | - * |Portugal |`eu_vat` |European VAT Number | - * |Romania |`eu_vat` |European VAT Number | - * |Romania |`ro_tin` |Romanian Tax ID Number | - * |Russia |`ru_inn` |Russian INN | - * |Russia |`ru_kpp` |Russian KPP | - * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | - * |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 | - * |Sweden |`eu_vat` |European VAT Number | - * |Switzerland |`ch_vat` |Switzerland VAT Number | - * |Taiwan |`tw_vat` |Taiwanese VAT | - * |Thailand |`th_vat` |Thai VAT | - * |Turkey |`tr_tin` |Turkish Tax Identification Number | - * |Ukraine |`ua_vat` |Ukrainian VAT | - * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | - * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | - * |United Kingdom |`gb_vat` |United Kingdom VAT Number | - * |United States |`us_ein` |United States EIN | - * |Uruguay |`uy_ruc` |Uruguayan RUC Number | - * |Venezuela |`ve_rif` |Venezuelan RIF Number | - * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | - */ - fun taxId(): Optional = Optional.ofNullable(taxId.getNullable("tax_id")) - - @JsonProperty("accounting_sync_configuration") - @ExcludeMissing - fun _accountingSyncConfiguration(): JsonField = - accountingSyncConfiguration - - /** - * Additional email addresses for this customer. If populated, these email addresses will be - * CC'd for customer communications. - */ - @JsonProperty("additional_emails") - @ExcludeMissing - fun _additionalEmails(): JsonField> = additionalEmails - - /** - * Used to determine if invoices for this customer will automatically attempt to charge a - * saved payment method, if available. This parameter defaults to `True` when a payment - * provider is provided on customer creation. - */ - @JsonProperty("auto_collection") - @ExcludeMissing - fun _autoCollection(): JsonField = autoCollection - - @JsonProperty("billing_address") - @ExcludeMissing - fun _billingAddress(): JsonField = 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. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** A valid customer email, to be used for invoicing and notifications. */ - @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email - - @JsonProperty("email_delivery") - @ExcludeMissing - fun _emailDelivery(): JsonField = emailDelivery - - /** - * The external customer ID. This can only be set if empty and the customer has no past or - * current subscriptions. - */ - @JsonProperty("external_customer_id") - @ExcludeMissing - fun _externalCustomerId(): JsonField = externalCustomerId - - /** The hierarchical relationships for this customer. */ - @JsonProperty("hierarchy") - @ExcludeMissing - fun _hierarchy(): JsonField = hierarchy - - /** - * User-specified key/value pairs for the resource. 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - /** The full name of the customer */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * This is used for creating charges or invoices in an external system via Orb. When not in - * test mode: - * - the connection must first be configured in the Orb webapp. - * - if the provider is an invoicing provider (`stripe_invoice`, `quickbooks`, `bill.com`, - * `netsuite`), any product mappings must first be configured with the Orb team. - */ - @JsonProperty("payment_provider") - @ExcludeMissing - fun _paymentProvider(): JsonField = paymentProvider - - /** - * The ID of this customer in an external payments solution, such as Stripe. This is used - * for creating charges or invoices in the external system via Orb. - */ - @JsonProperty("payment_provider_id") - @ExcludeMissing - fun _paymentProviderId(): JsonField = paymentProviderId - - @JsonProperty("reporting_configuration") - @ExcludeMissing - fun _reportingConfiguration(): JsonField = reportingConfiguration - - @JsonProperty("shipping_address") - @ExcludeMissing - fun _shippingAddress(): JsonField = shippingAddress + fun toBuilder() = Builder().from(this) - @JsonProperty("tax_configuration") - @ExcludeMissing - fun _taxConfiguration(): JsonField = taxConfiguration + companion object { /** - * Tax IDs are commonly required to be displayed on customer invoices, which are added to - * the headers of invoices. + * Returns a mutable builder for constructing an instance of [CustomerUpdateParams]. * - * ### Supported Tax ID Countries and Types - * |Country |Type |Description | - * |--------------------|------------|-------------------------------------------------------------------------------------------------------| - * |Andorra |`ad_nrt` |Andorran NRT Number | - * |Argentina |`ar_cuit` |Argentinian Tax ID Number | - * |Australia |`au_abn` |Australian Business Number (AU ABN) | - * |Australia |`au_arn` |Australian Taxation Office Reference Number | - * |Austria |`eu_vat` |European VAT Number | - * |Bahrain |`bh_vat` |Bahraini VAT Number | - * |Belgium |`eu_vat` |European VAT Number | - * |Bolivia |`bo_tin` |Bolivian Tax ID | - * |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 | - * |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) | - * |Chile |`cl_tin` |Chilean TIN | - * |China |`cn_tin` |Chinese Tax ID | - * |Colombia |`co_nit` |Colombian NIT Number | - * |Costa Rica |`cr_tin` |Costa Rican Tax ID | - * |Croatia |`eu_vat` |European VAT Number | - * |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 | - * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | - * |Finland |`eu_vat` |European VAT Number | - * |France |`eu_vat` |European VAT Number | - * |Georgia |`ge_vat` |Georgian VAT | - * |Germany |`eu_vat` |European VAT Number | - * |Greece |`eu_vat` |European VAT Number | - * |Hong Kong |`hk_br` |Hong Kong BR Number | - * |Hungary |`eu_vat` |European VAT Number | - * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | - * |Iceland |`is_vat` |Icelandic VAT | - * |India |`in_gst` |Indian GST Number | - * |Indonesia |`id_npwp` |Indonesian NPWP Number | - * |Ireland |`eu_vat` |European VAT Number | - * |Israel |`il_vat` |Israel VAT | - * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | - * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | - * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | - * |Latvia |`eu_vat` |European VAT Number | - * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | - * |Mexico |`mx_rfc` |Mexican RFC Number | - * |Netherlands |`eu_vat` |European VAT Number | - * |New Zealand |`nz_gst` |New Zealand GST Number | - * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | - * |Norway |`no_vat` |Norwegian VAT Number | - * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | - * |Oman |`om_vat` |Omani VAT Number | - * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | - * |Poland |`eu_vat` |European VAT Number | - * |Portugal |`eu_vat` |European VAT Number | - * |Romania |`eu_vat` |European VAT Number | - * |Romania |`ro_tin` |Romanian Tax ID Number | - * |Russia |`ru_inn` |Russian INN | - * |Russia |`ru_kpp` |Russian KPP | - * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | - * |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 | - * |Sweden |`eu_vat` |European VAT Number | - * |Switzerland |`ch_vat` |Switzerland VAT Number | - * |Taiwan |`tw_vat` |Taiwanese VAT | - * |Thailand |`th_vat` |Thai VAT | - * |Turkey |`tr_tin` |Turkish Tax Identification Number | - * |Ukraine |`ua_vat` |Ukrainian VAT | - * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | - * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | - * |United Kingdom |`gb_vat` |United Kingdom VAT Number | - * |United States |`us_ein` |United States EIN | - * |Uruguay |`uy_ruc` |Uruguayan RUC Number | - * |Venezuela |`ve_rif` |Venezuelan RIF Number | - * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + * The following fields are required: + * ```java + * .customerId() + * .editCustomerModel() + * ``` */ - @JsonProperty("tax_id") @ExcludeMissing fun _taxId(): JsonField = taxId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - accountingSyncConfiguration().ifPresent { it.validate() } - additionalEmails() - autoCollection() - billingAddress().ifPresent { it.validate() } - currency() - email() - emailDelivery() - externalCustomerId() - hierarchy().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - name() - paymentProvider() - paymentProviderId() - reportingConfiguration().ifPresent { it.validate() } - shippingAddress().ifPresent { it.validate() } - taxConfiguration().ifPresent { it.validate() } - taxId().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var accountingSyncConfiguration: JsonField = - JsonMissing.of() - private var additionalEmails: JsonField>? = null - private var autoCollection: JsonField = JsonMissing.of() - private var billingAddress: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var email: JsonField = JsonMissing.of() - private var emailDelivery: JsonField = JsonMissing.of() - private var externalCustomerId: JsonField = JsonMissing.of() - private var hierarchy: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var paymentProvider: JsonField = JsonMissing.of() - private var paymentProviderId: JsonField = JsonMissing.of() - private var reportingConfiguration: JsonField = JsonMissing.of() - private var shippingAddress: JsonField = JsonMissing.of() - private var taxConfiguration: JsonField = JsonMissing.of() - private var taxId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - accountingSyncConfiguration = body.accountingSyncConfiguration - additionalEmails = body.additionalEmails.map { it.toMutableList() } - autoCollection = body.autoCollection - billingAddress = body.billingAddress - currency = body.currency - email = body.email - emailDelivery = body.emailDelivery - externalCustomerId = body.externalCustomerId - hierarchy = body.hierarchy - metadata = body.metadata - name = body.name - paymentProvider = body.paymentProvider - paymentProviderId = body.paymentProviderId - reportingConfiguration = body.reportingConfiguration - shippingAddress = body.shippingAddress - taxConfiguration = body.taxConfiguration - taxId = body.taxId - additionalProperties = body.additionalProperties.toMutableMap() - } - - fun accountingSyncConfiguration( - accountingSyncConfiguration: AccountingSyncConfiguration? - ) = accountingSyncConfiguration(JsonField.ofNullable(accountingSyncConfiguration)) - - fun accountingSyncConfiguration( - accountingSyncConfiguration: Optional - ) = accountingSyncConfiguration(accountingSyncConfiguration.orElse(null)) - - fun accountingSyncConfiguration( - accountingSyncConfiguration: JsonField - ) = apply { this.accountingSyncConfiguration = accountingSyncConfiguration } - - /** - * Additional email addresses for this customer. If populated, these email addresses - * will be CC'd for customer communications. - */ - fun additionalEmails(additionalEmails: List?) = - additionalEmails(JsonField.ofNullable(additionalEmails)) - - /** - * Additional email addresses for this customer. If populated, these email addresses - * will be CC'd for customer communications. - */ - fun additionalEmails(additionalEmails: Optional>) = - additionalEmails(additionalEmails.orElse(null)) - - /** - * Additional email addresses for this customer. If populated, these email addresses - * will be CC'd for customer communications. - */ - fun additionalEmails(additionalEmails: JsonField>) = apply { - this.additionalEmails = additionalEmails.map { it.toMutableList() } - } - - /** - * Additional email addresses for this customer. If populated, these email addresses - * will be CC'd for customer communications. - */ - fun addAdditionalEmail(additionalEmail: String) = apply { - additionalEmails = - (additionalEmails ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(additionalEmail) - } - } - - /** - * Used to determine if invoices for this customer will automatically attempt to charge - * a saved payment method, if available. This parameter defaults to `True` when a - * payment provider is provided on customer creation. - */ - fun autoCollection(autoCollection: Boolean?) = - autoCollection(JsonField.ofNullable(autoCollection)) - - /** - * Used to determine if invoices for this customer will automatically attempt to charge - * a saved payment method, if available. This parameter defaults to `True` when a - * payment provider is provided on customer creation. - */ - fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) - - /** - * Used to determine if invoices for this customer will automatically attempt to charge - * a saved payment method, if available. This parameter defaults to `True` when a - * payment provider is provided on customer creation. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun autoCollection(autoCollection: Optional) = - autoCollection(autoCollection.orElse(null) as Boolean?) - - /** - * Used to determine if invoices for this customer will automatically attempt to charge - * a saved payment method, if available. This parameter defaults to `True` when a - * payment provider is provided on customer creation. - */ - fun autoCollection(autoCollection: JsonField) = apply { - this.autoCollection = autoCollection - } - - fun billingAddress(billingAddress: BillingAddress?) = - billingAddress(JsonField.ofNullable(billingAddress)) - - fun billingAddress(billingAddress: Optional) = - billingAddress(billingAddress.orElse(null)) - - fun billingAddress(billingAddress: JsonField) = apply { - this.billingAddress = 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. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * 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. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** A valid customer email, to be used for invoicing and notifications. */ - fun email(email: String?) = email(JsonField.ofNullable(email)) - - /** A valid customer email, to be used for invoicing and notifications. */ - fun email(email: Optional) = email(email.orElse(null)) - - /** A valid customer email, to be used for invoicing and notifications. */ - fun email(email: JsonField) = apply { this.email = email } - - fun emailDelivery(emailDelivery: Boolean?) = - emailDelivery(JsonField.ofNullable(emailDelivery)) - - fun emailDelivery(emailDelivery: Boolean) = emailDelivery(emailDelivery as Boolean?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun emailDelivery(emailDelivery: Optional) = - emailDelivery(emailDelivery.orElse(null) as Boolean?) - - fun emailDelivery(emailDelivery: JsonField) = apply { - this.emailDelivery = emailDelivery - } - - /** - * The external customer ID. This can only be set if empty and the customer has no past - * or current subscriptions. - */ - fun externalCustomerId(externalCustomerId: String?) = - externalCustomerId(JsonField.ofNullable(externalCustomerId)) - - /** - * The external customer ID. This can only be set if empty and the customer has no past - * or current subscriptions. - */ - fun externalCustomerId(externalCustomerId: Optional) = - externalCustomerId(externalCustomerId.orElse(null)) - - /** - * The external customer ID. This can only be set if empty and the customer has no past - * or current subscriptions. - */ - fun externalCustomerId(externalCustomerId: JsonField) = apply { - this.externalCustomerId = externalCustomerId - } - - /** The hierarchical relationships for this customer. */ - fun hierarchy(hierarchy: Hierarchy?) = hierarchy(JsonField.ofNullable(hierarchy)) - - /** The hierarchical relationships for this customer. */ - fun hierarchy(hierarchy: Optional) = hierarchy(hierarchy.orElse(null)) - - /** The hierarchical relationships for this customer. */ - fun hierarchy(hierarchy: JsonField) = apply { this.hierarchy = hierarchy } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: JsonField) = apply { this.metadata = metadata } - - /** The full name of the customer */ - fun name(name: String?) = name(JsonField.ofNullable(name)) - - /** The full name of the customer */ - fun name(name: Optional) = name(name.orElse(null)) - - /** The full name of the customer */ - fun name(name: JsonField) = apply { this.name = name } - - /** - * This is used for creating charges or invoices in an external system via Orb. When not - * in test mode: - * - the connection must first be configured in the Orb webapp. - * - if the provider is an invoicing provider (`stripe_invoice`, `quickbooks`, - * `bill.com`, `netsuite`), any product mappings must first be configured with the Orb - * team. - */ - fun paymentProvider(paymentProvider: PaymentProvider?) = - paymentProvider(JsonField.ofNullable(paymentProvider)) - - /** - * This is used for creating charges or invoices in an external system via Orb. When not - * in test mode: - * - the connection must first be configured in the Orb webapp. - * - if the provider is an invoicing provider (`stripe_invoice`, `quickbooks`, - * `bill.com`, `netsuite`), any product mappings must first be configured with the Orb - * team. - */ - fun paymentProvider(paymentProvider: Optional) = - paymentProvider(paymentProvider.orElse(null)) - - /** - * This is used for creating charges or invoices in an external system via Orb. When not - * in test mode: - * - the connection must first be configured in the Orb webapp. - * - if the provider is an invoicing provider (`stripe_invoice`, `quickbooks`, - * `bill.com`, `netsuite`), any product mappings must first be configured with the Orb - * team. - */ - fun paymentProvider(paymentProvider: JsonField) = apply { - this.paymentProvider = paymentProvider - } - - /** - * The ID of this customer in an external payments solution, such as Stripe. This is - * used for creating charges or invoices in the external system via Orb. - */ - fun paymentProviderId(paymentProviderId: String?) = - paymentProviderId(JsonField.ofNullable(paymentProviderId)) - - /** - * The ID of this customer in an external payments solution, such as Stripe. This is - * used for creating charges or invoices in the external system via Orb. - */ - fun paymentProviderId(paymentProviderId: Optional) = - paymentProviderId(paymentProviderId.orElse(null)) - - /** - * The ID of this customer in an external payments solution, such as Stripe. This is - * used for creating charges or invoices in the external system via Orb. - */ - fun paymentProviderId(paymentProviderId: JsonField) = apply { - this.paymentProviderId = paymentProviderId - } - - fun reportingConfiguration(reportingConfiguration: ReportingConfiguration?) = - reportingConfiguration(JsonField.ofNullable(reportingConfiguration)) - - fun reportingConfiguration(reportingConfiguration: Optional) = - reportingConfiguration(reportingConfiguration.orElse(null)) - - fun reportingConfiguration(reportingConfiguration: JsonField) = - apply { - this.reportingConfiguration = reportingConfiguration - } - - fun shippingAddress(shippingAddress: ShippingAddress?) = - shippingAddress(JsonField.ofNullable(shippingAddress)) - - fun shippingAddress(shippingAddress: Optional) = - shippingAddress(shippingAddress.orElse(null)) - - fun shippingAddress(shippingAddress: JsonField) = apply { - this.shippingAddress = shippingAddress - } - - fun taxConfiguration(taxConfiguration: TaxConfiguration?) = - taxConfiguration(JsonField.ofNullable(taxConfiguration)) - - fun taxConfiguration(taxConfiguration: Optional) = - taxConfiguration(taxConfiguration.orElse(null)) - - fun taxConfiguration(taxConfiguration: JsonField) = apply { - this.taxConfiguration = taxConfiguration - } - - fun taxConfiguration(newAvalara: TaxConfiguration.NewAvalaraTaxConfiguration) = - taxConfiguration(TaxConfiguration.ofNewAvalara(newAvalara)) - - fun newAvalaraTaxConfiguration(taxExempt: Boolean) = - taxConfiguration( - TaxConfiguration.NewAvalaraTaxConfiguration.builder() - .taxProvider( - CustomerUpdateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) - .taxExempt(taxExempt) - .build() - ) - - fun taxConfiguration(newTaxJar: TaxConfiguration.NewTaxJarConfiguration) = - taxConfiguration(TaxConfiguration.ofNewTaxJar(newTaxJar)) - - fun newTaxJarTaxConfiguration(taxExempt: Boolean) = - taxConfiguration( - TaxConfiguration.NewTaxJarConfiguration.builder() - .taxProvider( - CustomerUpdateParams.TaxConfiguration.NewTaxJarConfiguration.TaxProvider - .TAXJAR - ) - .taxExempt(taxExempt) - .build() - ) - - /** - * 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 | - * |--------------------|------------|-------------------------------------------------------------------------------------------------------| - * |Andorra |`ad_nrt` |Andorran NRT Number | - * |Argentina |`ar_cuit` |Argentinian Tax ID Number | - * |Australia |`au_abn` |Australian Business Number (AU ABN) | - * |Australia |`au_arn` |Australian Taxation Office Reference Number | - * |Austria |`eu_vat` |European VAT Number | - * |Bahrain |`bh_vat` |Bahraini VAT Number | - * |Belgium |`eu_vat` |European VAT Number | - * |Bolivia |`bo_tin` |Bolivian Tax ID | - * |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 | - * |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) | - * |Chile |`cl_tin` |Chilean TIN | - * |China |`cn_tin` |Chinese Tax ID | - * |Colombia |`co_nit` |Colombian NIT Number | - * |Costa Rica |`cr_tin` |Costa Rican Tax ID | - * |Croatia |`eu_vat` |European VAT Number | - * |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 | - * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | - * |Finland |`eu_vat` |European VAT Number | - * |France |`eu_vat` |European VAT Number | - * |Georgia |`ge_vat` |Georgian VAT | - * |Germany |`eu_vat` |European VAT Number | - * |Greece |`eu_vat` |European VAT Number | - * |Hong Kong |`hk_br` |Hong Kong BR Number | - * |Hungary |`eu_vat` |European VAT Number | - * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | - * |Iceland |`is_vat` |Icelandic VAT | - * |India |`in_gst` |Indian GST Number | - * |Indonesia |`id_npwp` |Indonesian NPWP Number | - * |Ireland |`eu_vat` |European VAT Number | - * |Israel |`il_vat` |Israel VAT | - * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | - * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | - * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | - * |Latvia |`eu_vat` |European VAT Number | - * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | - * |Mexico |`mx_rfc` |Mexican RFC Number | - * |Netherlands |`eu_vat` |European VAT Number | - * |New Zealand |`nz_gst` |New Zealand GST Number | - * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | - * |Norway |`no_vat` |Norwegian VAT Number | - * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | - * |Oman |`om_vat` |Omani VAT Number | - * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | - * |Poland |`eu_vat` |European VAT Number | - * |Portugal |`eu_vat` |European VAT Number | - * |Romania |`eu_vat` |European VAT Number | - * |Romania |`ro_tin` |Romanian Tax ID Number | - * |Russia |`ru_inn` |Russian INN | - * |Russia |`ru_kpp` |Russian KPP | - * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | - * |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 | - * |Sweden |`eu_vat` |European VAT Number | - * |Switzerland |`ch_vat` |Switzerland VAT Number | - * |Taiwan |`tw_vat` |Taiwanese VAT | - * |Thailand |`th_vat` |Thai VAT | - * |Turkey |`tr_tin` |Turkish Tax Identification Number | - * |Ukraine |`ua_vat` |Ukrainian VAT | - * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | - * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | - * |United Kingdom |`gb_vat` |United Kingdom VAT Number | - * |United States |`us_ein` |United States EIN | - * |Uruguay |`uy_ruc` |Uruguayan RUC Number | - * |Venezuela |`ve_rif` |Venezuelan RIF Number | - * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | - */ - fun taxId(taxId: TaxId?) = taxId(JsonField.ofNullable(taxId)) - - /** - * 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 | - * |--------------------|------------|-------------------------------------------------------------------------------------------------------| - * |Andorra |`ad_nrt` |Andorran NRT Number | - * |Argentina |`ar_cuit` |Argentinian Tax ID Number | - * |Australia |`au_abn` |Australian Business Number (AU ABN) | - * |Australia |`au_arn` |Australian Taxation Office Reference Number | - * |Austria |`eu_vat` |European VAT Number | - * |Bahrain |`bh_vat` |Bahraini VAT Number | - * |Belgium |`eu_vat` |European VAT Number | - * |Bolivia |`bo_tin` |Bolivian Tax ID | - * |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 | - * |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) | - * |Chile |`cl_tin` |Chilean TIN | - * |China |`cn_tin` |Chinese Tax ID | - * |Colombia |`co_nit` |Colombian NIT Number | - * |Costa Rica |`cr_tin` |Costa Rican Tax ID | - * |Croatia |`eu_vat` |European VAT Number | - * |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 | - * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | - * |Finland |`eu_vat` |European VAT Number | - * |France |`eu_vat` |European VAT Number | - * |Georgia |`ge_vat` |Georgian VAT | - * |Germany |`eu_vat` |European VAT Number | - * |Greece |`eu_vat` |European VAT Number | - * |Hong Kong |`hk_br` |Hong Kong BR Number | - * |Hungary |`eu_vat` |European VAT Number | - * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | - * |Iceland |`is_vat` |Icelandic VAT | - * |India |`in_gst` |Indian GST Number | - * |Indonesia |`id_npwp` |Indonesian NPWP Number | - * |Ireland |`eu_vat` |European VAT Number | - * |Israel |`il_vat` |Israel VAT | - * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | - * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | - * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | - * |Latvia |`eu_vat` |European VAT Number | - * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | - * |Mexico |`mx_rfc` |Mexican RFC Number | - * |Netherlands |`eu_vat` |European VAT Number | - * |New Zealand |`nz_gst` |New Zealand GST Number | - * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | - * |Norway |`no_vat` |Norwegian VAT Number | - * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | - * |Oman |`om_vat` |Omani VAT Number | - * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | - * |Poland |`eu_vat` |European VAT Number | - * |Portugal |`eu_vat` |European VAT Number | - * |Romania |`eu_vat` |European VAT Number | - * |Romania |`ro_tin` |Romanian Tax ID Number | - * |Russia |`ru_inn` |Russian INN | - * |Russia |`ru_kpp` |Russian KPP | - * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | - * |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 | - * |Sweden |`eu_vat` |European VAT Number | - * |Switzerland |`ch_vat` |Switzerland VAT Number | - * |Taiwan |`tw_vat` |Taiwanese VAT | - * |Thailand |`th_vat` |Thai VAT | - * |Turkey |`tr_tin` |Turkish Tax Identification Number | - * |Ukraine |`ua_vat` |Ukrainian VAT | - * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | - * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | - * |United Kingdom |`gb_vat` |United Kingdom VAT Number | - * |United States |`us_ein` |United States EIN | - * |Uruguay |`uy_ruc` |Uruguayan RUC Number | - * |Venezuela |`ve_rif` |Venezuelan RIF Number | - * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | - */ - fun taxId(taxId: Optional) = taxId(taxId.orElse(null)) - - /** - * 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 | - * |--------------------|------------|-------------------------------------------------------------------------------------------------------| - * |Andorra |`ad_nrt` |Andorran NRT Number | - * |Argentina |`ar_cuit` |Argentinian Tax ID Number | - * |Australia |`au_abn` |Australian Business Number (AU ABN) | - * |Australia |`au_arn` |Australian Taxation Office Reference Number | - * |Austria |`eu_vat` |European VAT Number | - * |Bahrain |`bh_vat` |Bahraini VAT Number | - * |Belgium |`eu_vat` |European VAT Number | - * |Bolivia |`bo_tin` |Bolivian Tax ID | - * |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 | - * |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) | - * |Chile |`cl_tin` |Chilean TIN | - * |China |`cn_tin` |Chinese Tax ID | - * |Colombia |`co_nit` |Colombian NIT Number | - * |Costa Rica |`cr_tin` |Costa Rican Tax ID | - * |Croatia |`eu_vat` |European VAT Number | - * |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 | - * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | - * |Finland |`eu_vat` |European VAT Number | - * |France |`eu_vat` |European VAT Number | - * |Georgia |`ge_vat` |Georgian VAT | - * |Germany |`eu_vat` |European VAT Number | - * |Greece |`eu_vat` |European VAT Number | - * |Hong Kong |`hk_br` |Hong Kong BR Number | - * |Hungary |`eu_vat` |European VAT Number | - * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | - * |Iceland |`is_vat` |Icelandic VAT | - * |India |`in_gst` |Indian GST Number | - * |Indonesia |`id_npwp` |Indonesian NPWP Number | - * |Ireland |`eu_vat` |European VAT Number | - * |Israel |`il_vat` |Israel VAT | - * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | - * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | - * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | - * |Latvia |`eu_vat` |European VAT Number | - * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | - * |Mexico |`mx_rfc` |Mexican RFC Number | - * |Netherlands |`eu_vat` |European VAT Number | - * |New Zealand |`nz_gst` |New Zealand GST Number | - * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | - * |Norway |`no_vat` |Norwegian VAT Number | - * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | - * |Oman |`om_vat` |Omani VAT Number | - * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | - * |Poland |`eu_vat` |European VAT Number | - * |Portugal |`eu_vat` |European VAT Number | - * |Romania |`eu_vat` |European VAT Number | - * |Romania |`ro_tin` |Romanian Tax ID Number | - * |Russia |`ru_inn` |Russian INN | - * |Russia |`ru_kpp` |Russian KPP | - * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | - * |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 | - * |Sweden |`eu_vat` |European VAT Number | - * |Switzerland |`ch_vat` |Switzerland VAT Number | - * |Taiwan |`tw_vat` |Taiwanese VAT | - * |Thailand |`th_vat` |Thai VAT | - * |Turkey |`tr_tin` |Turkish Tax Identification Number | - * |Ukraine |`ua_vat` |Ukrainian VAT | - * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | - * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | - * |United Kingdom |`gb_vat` |United Kingdom VAT Number | - * |United States |`us_ein` |United States EIN | - * |Uruguay |`uy_ruc` |Uruguayan RUC Number | - * |Venezuela |`ve_rif` |Venezuelan RIF Number | - * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | - */ - fun taxId(taxId: JsonField) = apply { this.taxId = taxId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Body = - Body( - accountingSyncConfiguration, - (additionalEmails ?: JsonMissing.of()).map { it.toImmutable() }, - autoCollection, - billingAddress, - currency, - email, - emailDelivery, - externalCustomerId, - hierarchy, - metadata, - name, - paymentProvider, - paymentProviderId, - reportingConfiguration, - shippingAddress, - taxConfiguration, - taxId, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Body && accountingSyncConfiguration == other.accountingSyncConfiguration && additionalEmails == other.additionalEmails && autoCollection == other.autoCollection && billingAddress == other.billingAddress && currency == other.currency && email == other.email && emailDelivery == other.emailDelivery && externalCustomerId == other.externalCustomerId && hierarchy == other.hierarchy && metadata == other.metadata && name == other.name && paymentProvider == other.paymentProvider && paymentProviderId == other.paymentProviderId && reportingConfiguration == other.reportingConfiguration && shippingAddress == other.shippingAddress && taxConfiguration == other.taxConfiguration && taxId == other.taxId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(accountingSyncConfiguration, additionalEmails, autoCollection, billingAddress, currency, email, emailDelivery, externalCustomerId, hierarchy, metadata, name, paymentProvider, paymentProviderId, reportingConfiguration, shippingAddress, taxConfiguration, taxId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{accountingSyncConfiguration=$accountingSyncConfiguration, additionalEmails=$additionalEmails, autoCollection=$autoCollection, billingAddress=$billingAddress, currency=$currency, email=$email, emailDelivery=$emailDelivery, externalCustomerId=$externalCustomerId, hierarchy=$hierarchy, metadata=$metadata, name=$name, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, reportingConfiguration=$reportingConfiguration, shippingAddress=$shippingAddress, taxConfiguration=$taxConfiguration, taxId=$taxId, additionalProperties=$additionalProperties}" - } - - fun toBuilder() = Builder().from(this) - - companion object { - @JvmStatic fun builder() = Builder() } @@ -1664,702 +69,70 @@ private constructor( class Builder internal constructor() { private var customerId: String? = null - private var body: Body.Builder = Body.builder() + private var editCustomerModel: EditCustomerModel? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(customerUpdateParams: CustomerUpdateParams) = apply { customerId = customerUpdateParams.customerId - body = customerUpdateParams.body.toBuilder() + editCustomerModel = customerUpdateParams.editCustomerModel additionalHeaders = customerUpdateParams.additionalHeaders.toBuilder() additionalQueryParams = customerUpdateParams.additionalQueryParams.toBuilder() } fun customerId(customerId: String) = apply { this.customerId = customerId } - fun accountingSyncConfiguration(accountingSyncConfiguration: AccountingSyncConfiguration?) = - apply { - body.accountingSyncConfiguration(accountingSyncConfiguration) - } - - fun accountingSyncConfiguration( - accountingSyncConfiguration: Optional - ) = accountingSyncConfiguration(accountingSyncConfiguration.orElse(null)) + fun editCustomerModel(editCustomerModel: EditCustomerModel) = apply { + this.editCustomerModel = editCustomerModel + } - fun accountingSyncConfiguration( - accountingSyncConfiguration: JsonField - ) = apply { body.accountingSyncConfiguration(accountingSyncConfiguration) } + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } - /** - * Additional email addresses for this customer. If populated, these email addresses will be - * CC'd for customer communications. - */ - fun additionalEmails(additionalEmails: List?) = apply { - body.additionalEmails(additionalEmails) + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) } - /** - * Additional email addresses for this customer. If populated, these email addresses will be - * CC'd for customer communications. - */ - fun additionalEmails(additionalEmails: Optional>) = - additionalEmails(additionalEmails.orElse(null)) + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } - /** - * Additional email addresses for this customer. If populated, these email addresses will be - * CC'd for customer communications. - */ - fun additionalEmails(additionalEmails: JsonField>) = apply { - body.additionalEmails(additionalEmails) + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) } - /** - * Additional email addresses for this customer. If populated, these email addresses will be - * CC'd for customer communications. - */ - fun addAdditionalEmail(additionalEmail: String) = apply { - body.addAdditionalEmail(additionalEmail) + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) } - /** - * Used to determine if invoices for this customer will automatically attempt to charge a - * saved payment method, if available. This parameter defaults to `True` when a payment - * provider is provided on customer creation. - */ - fun autoCollection(autoCollection: Boolean?) = apply { body.autoCollection(autoCollection) } + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } - /** - * Used to determine if invoices for this customer will automatically attempt to charge a - * saved payment method, if available. This parameter defaults to `True` when a payment - * provider is provided on customer creation. - */ - fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } - /** - * Used to determine if invoices for this customer will automatically attempt to charge a - * saved payment method, if available. This parameter defaults to `True` when a payment - * provider is provided on customer creation. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun autoCollection(autoCollection: Optional) = - autoCollection(autoCollection.orElse(null) as Boolean?) + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } - /** - * Used to determine if invoices for this customer will automatically attempt to charge a - * saved payment method, if available. This parameter defaults to `True` when a payment - * provider is provided on customer creation. - */ - fun autoCollection(autoCollection: JsonField) = apply { - body.autoCollection(autoCollection) + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } - fun billingAddress(billingAddress: BillingAddress?) = apply { - body.billingAddress(billingAddress) + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) } - fun billingAddress(billingAddress: Optional) = - billingAddress(billingAddress.orElse(null)) + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - fun billingAddress(billingAddress: JsonField) = apply { - body.billingAddress(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. - */ - fun currency(currency: String?) = apply { body.currency(currency) } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * 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. - */ - fun currency(currency: JsonField) = apply { body.currency(currency) } - - /** A valid customer email, to be used for invoicing and notifications. */ - fun email(email: String?) = apply { body.email(email) } - - /** A valid customer email, to be used for invoicing and notifications. */ - fun email(email: Optional) = email(email.orElse(null)) - - /** A valid customer email, to be used for invoicing and notifications. */ - fun email(email: JsonField) = apply { body.email(email) } - - fun emailDelivery(emailDelivery: Boolean?) = apply { body.emailDelivery(emailDelivery) } - - fun emailDelivery(emailDelivery: Boolean) = emailDelivery(emailDelivery as Boolean?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun emailDelivery(emailDelivery: Optional) = - emailDelivery(emailDelivery.orElse(null) as Boolean?) - - fun emailDelivery(emailDelivery: JsonField) = apply { - body.emailDelivery(emailDelivery) - } - - /** - * The external customer ID. This can only be set if empty and the customer has no past or - * current subscriptions. - */ - fun externalCustomerId(externalCustomerId: String?) = apply { - body.externalCustomerId(externalCustomerId) - } - - /** - * The external customer ID. This can only be set if empty and the customer has no past or - * current subscriptions. - */ - fun externalCustomerId(externalCustomerId: Optional) = - externalCustomerId(externalCustomerId.orElse(null)) - - /** - * The external customer ID. This can only be set if empty and the customer has no past or - * current subscriptions. - */ - fun externalCustomerId(externalCustomerId: JsonField) = apply { - body.externalCustomerId(externalCustomerId) - } - - /** The hierarchical relationships for this customer. */ - fun hierarchy(hierarchy: Hierarchy?) = apply { body.hierarchy(hierarchy) } - - /** The hierarchical relationships for this customer. */ - fun hierarchy(hierarchy: Optional) = hierarchy(hierarchy.orElse(null)) - - /** The hierarchical relationships for this customer. */ - fun hierarchy(hierarchy: JsonField) = apply { body.hierarchy(hierarchy) } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by setting - * `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by setting - * `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: JsonField) = apply { body.metadata(metadata) } - - /** The full name of the customer */ - fun name(name: String?) = apply { body.name(name) } - - /** The full name of the customer */ - fun name(name: Optional) = name(name.orElse(null)) - - /** The full name of the customer */ - fun name(name: JsonField) = apply { body.name(name) } - - /** - * This is used for creating charges or invoices in an external system via Orb. When not in - * test mode: - * - the connection must first be configured in the Orb webapp. - * - if the provider is an invoicing provider (`stripe_invoice`, `quickbooks`, `bill.com`, - * `netsuite`), any product mappings must first be configured with the Orb team. - */ - fun paymentProvider(paymentProvider: PaymentProvider?) = apply { - body.paymentProvider(paymentProvider) - } - - /** - * This is used for creating charges or invoices in an external system via Orb. When not in - * test mode: - * - the connection must first be configured in the Orb webapp. - * - if the provider is an invoicing provider (`stripe_invoice`, `quickbooks`, `bill.com`, - * `netsuite`), any product mappings must first be configured with the Orb team. - */ - fun paymentProvider(paymentProvider: Optional) = - paymentProvider(paymentProvider.orElse(null)) - - /** - * This is used for creating charges or invoices in an external system via Orb. When not in - * test mode: - * - the connection must first be configured in the Orb webapp. - * - if the provider is an invoicing provider (`stripe_invoice`, `quickbooks`, `bill.com`, - * `netsuite`), any product mappings must first be configured with the Orb team. - */ - fun paymentProvider(paymentProvider: JsonField) = apply { - body.paymentProvider(paymentProvider) - } - - /** - * The ID of this customer in an external payments solution, such as Stripe. This is used - * for creating charges or invoices in the external system via Orb. - */ - fun paymentProviderId(paymentProviderId: String?) = apply { - body.paymentProviderId(paymentProviderId) - } - - /** - * The ID of this customer in an external payments solution, such as Stripe. This is used - * for creating charges or invoices in the external system via Orb. - */ - fun paymentProviderId(paymentProviderId: Optional) = - paymentProviderId(paymentProviderId.orElse(null)) - - /** - * The ID of this customer in an external payments solution, such as Stripe. This is used - * for creating charges or invoices in the external system via Orb. - */ - fun paymentProviderId(paymentProviderId: JsonField) = apply { - body.paymentProviderId(paymentProviderId) - } - - fun reportingConfiguration(reportingConfiguration: ReportingConfiguration?) = apply { - body.reportingConfiguration(reportingConfiguration) - } - - fun reportingConfiguration(reportingConfiguration: Optional) = - reportingConfiguration(reportingConfiguration.orElse(null)) - - fun reportingConfiguration(reportingConfiguration: JsonField) = - apply { - body.reportingConfiguration(reportingConfiguration) - } - - fun shippingAddress(shippingAddress: ShippingAddress?) = apply { - body.shippingAddress(shippingAddress) - } - - fun shippingAddress(shippingAddress: Optional) = - shippingAddress(shippingAddress.orElse(null)) - - fun shippingAddress(shippingAddress: JsonField) = apply { - body.shippingAddress(shippingAddress) - } - - fun taxConfiguration(taxConfiguration: TaxConfiguration?) = apply { - body.taxConfiguration(taxConfiguration) - } - - fun taxConfiguration(taxConfiguration: Optional) = - taxConfiguration(taxConfiguration.orElse(null)) - - fun taxConfiguration(taxConfiguration: JsonField) = apply { - body.taxConfiguration(taxConfiguration) - } - - fun taxConfiguration(newAvalara: TaxConfiguration.NewAvalaraTaxConfiguration) = apply { - body.taxConfiguration(newAvalara) - } - - fun newAvalaraTaxConfiguration(taxExempt: Boolean) = apply { - body.newAvalaraTaxConfiguration(taxExempt) - } - - fun taxConfiguration(newTaxJar: TaxConfiguration.NewTaxJarConfiguration) = apply { - body.taxConfiguration(newTaxJar) - } - - fun newTaxJarTaxConfiguration(taxExempt: Boolean) = apply { - body.newTaxJarTaxConfiguration(taxExempt) - } - - /** - * 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 | - * |--------------------|------------|-------------------------------------------------------------------------------------------------------| - * |Andorra |`ad_nrt` |Andorran NRT Number | - * |Argentina |`ar_cuit` |Argentinian Tax ID Number | - * |Australia |`au_abn` |Australian Business Number (AU ABN) | - * |Australia |`au_arn` |Australian Taxation Office Reference Number | - * |Austria |`eu_vat` |European VAT Number | - * |Bahrain |`bh_vat` |Bahraini VAT Number | - * |Belgium |`eu_vat` |European VAT Number | - * |Bolivia |`bo_tin` |Bolivian Tax ID | - * |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 | - * |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) | - * |Chile |`cl_tin` |Chilean TIN | - * |China |`cn_tin` |Chinese Tax ID | - * |Colombia |`co_nit` |Colombian NIT Number | - * |Costa Rica |`cr_tin` |Costa Rican Tax ID | - * |Croatia |`eu_vat` |European VAT Number | - * |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 | - * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | - * |Finland |`eu_vat` |European VAT Number | - * |France |`eu_vat` |European VAT Number | - * |Georgia |`ge_vat` |Georgian VAT | - * |Germany |`eu_vat` |European VAT Number | - * |Greece |`eu_vat` |European VAT Number | - * |Hong Kong |`hk_br` |Hong Kong BR Number | - * |Hungary |`eu_vat` |European VAT Number | - * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | - * |Iceland |`is_vat` |Icelandic VAT | - * |India |`in_gst` |Indian GST Number | - * |Indonesia |`id_npwp` |Indonesian NPWP Number | - * |Ireland |`eu_vat` |European VAT Number | - * |Israel |`il_vat` |Israel VAT | - * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | - * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | - * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | - * |Latvia |`eu_vat` |European VAT Number | - * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | - * |Mexico |`mx_rfc` |Mexican RFC Number | - * |Netherlands |`eu_vat` |European VAT Number | - * |New Zealand |`nz_gst` |New Zealand GST Number | - * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | - * |Norway |`no_vat` |Norwegian VAT Number | - * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | - * |Oman |`om_vat` |Omani VAT Number | - * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | - * |Poland |`eu_vat` |European VAT Number | - * |Portugal |`eu_vat` |European VAT Number | - * |Romania |`eu_vat` |European VAT Number | - * |Romania |`ro_tin` |Romanian Tax ID Number | - * |Russia |`ru_inn` |Russian INN | - * |Russia |`ru_kpp` |Russian KPP | - * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | - * |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 | - * |Sweden |`eu_vat` |European VAT Number | - * |Switzerland |`ch_vat` |Switzerland VAT Number | - * |Taiwan |`tw_vat` |Taiwanese VAT | - * |Thailand |`th_vat` |Thai VAT | - * |Turkey |`tr_tin` |Turkish Tax Identification Number | - * |Ukraine |`ua_vat` |Ukrainian VAT | - * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | - * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | - * |United Kingdom |`gb_vat` |United Kingdom VAT Number | - * |United States |`us_ein` |United States EIN | - * |Uruguay |`uy_ruc` |Uruguayan RUC Number | - * |Venezuela |`ve_rif` |Venezuelan RIF Number | - * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | - */ - fun taxId(taxId: TaxId?) = apply { body.taxId(taxId) } - - /** - * 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 | - * |--------------------|------------|-------------------------------------------------------------------------------------------------------| - * |Andorra |`ad_nrt` |Andorran NRT Number | - * |Argentina |`ar_cuit` |Argentinian Tax ID Number | - * |Australia |`au_abn` |Australian Business Number (AU ABN) | - * |Australia |`au_arn` |Australian Taxation Office Reference Number | - * |Austria |`eu_vat` |European VAT Number | - * |Bahrain |`bh_vat` |Bahraini VAT Number | - * |Belgium |`eu_vat` |European VAT Number | - * |Bolivia |`bo_tin` |Bolivian Tax ID | - * |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 | - * |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) | - * |Chile |`cl_tin` |Chilean TIN | - * |China |`cn_tin` |Chinese Tax ID | - * |Colombia |`co_nit` |Colombian NIT Number | - * |Costa Rica |`cr_tin` |Costa Rican Tax ID | - * |Croatia |`eu_vat` |European VAT Number | - * |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 | - * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | - * |Finland |`eu_vat` |European VAT Number | - * |France |`eu_vat` |European VAT Number | - * |Georgia |`ge_vat` |Georgian VAT | - * |Germany |`eu_vat` |European VAT Number | - * |Greece |`eu_vat` |European VAT Number | - * |Hong Kong |`hk_br` |Hong Kong BR Number | - * |Hungary |`eu_vat` |European VAT Number | - * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | - * |Iceland |`is_vat` |Icelandic VAT | - * |India |`in_gst` |Indian GST Number | - * |Indonesia |`id_npwp` |Indonesian NPWP Number | - * |Ireland |`eu_vat` |European VAT Number | - * |Israel |`il_vat` |Israel VAT | - * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | - * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | - * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | - * |Latvia |`eu_vat` |European VAT Number | - * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | - * |Mexico |`mx_rfc` |Mexican RFC Number | - * |Netherlands |`eu_vat` |European VAT Number | - * |New Zealand |`nz_gst` |New Zealand GST Number | - * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | - * |Norway |`no_vat` |Norwegian VAT Number | - * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | - * |Oman |`om_vat` |Omani VAT Number | - * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | - * |Poland |`eu_vat` |European VAT Number | - * |Portugal |`eu_vat` |European VAT Number | - * |Romania |`eu_vat` |European VAT Number | - * |Romania |`ro_tin` |Romanian Tax ID Number | - * |Russia |`ru_inn` |Russian INN | - * |Russia |`ru_kpp` |Russian KPP | - * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | - * |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 | - * |Sweden |`eu_vat` |European VAT Number | - * |Switzerland |`ch_vat` |Switzerland VAT Number | - * |Taiwan |`tw_vat` |Taiwanese VAT | - * |Thailand |`th_vat` |Thai VAT | - * |Turkey |`tr_tin` |Turkish Tax Identification Number | - * |Ukraine |`ua_vat` |Ukrainian VAT | - * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | - * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | - * |United Kingdom |`gb_vat` |United Kingdom VAT Number | - * |United States |`us_ein` |United States EIN | - * |Uruguay |`uy_ruc` |Uruguayan RUC Number | - * |Venezuela |`ve_rif` |Venezuelan RIF Number | - * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | - */ - fun taxId(taxId: Optional) = taxId(taxId.orElse(null)) - - /** - * 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 | - * |--------------------|------------|-------------------------------------------------------------------------------------------------------| - * |Andorra |`ad_nrt` |Andorran NRT Number | - * |Argentina |`ar_cuit` |Argentinian Tax ID Number | - * |Australia |`au_abn` |Australian Business Number (AU ABN) | - * |Australia |`au_arn` |Australian Taxation Office Reference Number | - * |Austria |`eu_vat` |European VAT Number | - * |Bahrain |`bh_vat` |Bahraini VAT Number | - * |Belgium |`eu_vat` |European VAT Number | - * |Bolivia |`bo_tin` |Bolivian Tax ID | - * |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 | - * |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) | - * |Chile |`cl_tin` |Chilean TIN | - * |China |`cn_tin` |Chinese Tax ID | - * |Colombia |`co_nit` |Colombian NIT Number | - * |Costa Rica |`cr_tin` |Costa Rican Tax ID | - * |Croatia |`eu_vat` |European VAT Number | - * |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 | - * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | - * |Finland |`eu_vat` |European VAT Number | - * |France |`eu_vat` |European VAT Number | - * |Georgia |`ge_vat` |Georgian VAT | - * |Germany |`eu_vat` |European VAT Number | - * |Greece |`eu_vat` |European VAT Number | - * |Hong Kong |`hk_br` |Hong Kong BR Number | - * |Hungary |`eu_vat` |European VAT Number | - * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | - * |Iceland |`is_vat` |Icelandic VAT | - * |India |`in_gst` |Indian GST Number | - * |Indonesia |`id_npwp` |Indonesian NPWP Number | - * |Ireland |`eu_vat` |European VAT Number | - * |Israel |`il_vat` |Israel VAT | - * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | - * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | - * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | - * |Latvia |`eu_vat` |European VAT Number | - * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | - * |Mexico |`mx_rfc` |Mexican RFC Number | - * |Netherlands |`eu_vat` |European VAT Number | - * |New Zealand |`nz_gst` |New Zealand GST Number | - * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | - * |Norway |`no_vat` |Norwegian VAT Number | - * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | - * |Oman |`om_vat` |Omani VAT Number | - * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | - * |Poland |`eu_vat` |European VAT Number | - * |Portugal |`eu_vat` |European VAT Number | - * |Romania |`eu_vat` |European VAT Number | - * |Romania |`ro_tin` |Romanian Tax ID Number | - * |Russia |`ru_inn` |Russian INN | - * |Russia |`ru_kpp` |Russian KPP | - * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | - * |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 | - * |Sweden |`eu_vat` |European VAT Number | - * |Switzerland |`ch_vat` |Switzerland VAT Number | - * |Taiwan |`tw_vat` |Taiwanese VAT | - * |Thailand |`th_vat` |Thai VAT | - * |Turkey |`tr_tin` |Turkish Tax Identification Number | - * |Ukraine |`ua_vat` |Ukrainian VAT | - * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | - * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | - * |United Kingdom |`gb_vat` |United Kingdom VAT Number | - * |United States |`us_ein` |United States EIN | - * |Uruguay |`uy_ruc` |Uruguayan RUC Number | - * |Venezuela |`ve_rif` |Venezuelan RIF Number | - * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | - */ - fun taxId(taxId: JsonField) = apply { body.taxId(taxId) } - - 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 removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) } fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { @@ -2415,3069 +188,22 @@ private constructor( fun build(): CustomerUpdateParams = CustomerUpdateParams( checkRequired("customerId", customerId), - body.build(), + checkRequired("editCustomerModel", editCustomerModel), additionalHeaders.build(), additionalQueryParams.build(), ) } - @NoAutoDetect - class AccountingSyncConfiguration - @JsonCreator - private constructor( - @JsonProperty("accounting_providers") - @ExcludeMissing - private val accountingProviders: JsonField> = JsonMissing.of(), - @JsonProperty("excluded") - @ExcludeMissing - private val excluded: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun accountingProviders(): Optional> = - Optional.ofNullable(accountingProviders.getNullable("accounting_providers")) - - fun excluded(): Optional = Optional.ofNullable(excluded.getNullable("excluded")) - - @JsonProperty("accounting_providers") - @ExcludeMissing - fun _accountingProviders(): JsonField> = accountingProviders - - @JsonProperty("excluded") @ExcludeMissing fun _excluded(): JsonField = excluded - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AccountingSyncConfiguration = apply { - if (validated) { - return@apply - } - - accountingProviders().ifPresent { it.forEach { it.validate() } } - excluded() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AccountingSyncConfiguration]. */ - class Builder internal constructor() { - - private var accountingProviders: JsonField>? = null - private var excluded: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(accountingSyncConfiguration: AccountingSyncConfiguration) = apply { - accountingProviders = - accountingSyncConfiguration.accountingProviders.map { it.toMutableList() } - excluded = accountingSyncConfiguration.excluded - additionalProperties = - accountingSyncConfiguration.additionalProperties.toMutableMap() - } - - fun accountingProviders(accountingProviders: List?) = - accountingProviders(JsonField.ofNullable(accountingProviders)) - - fun accountingProviders(accountingProviders: Optional>) = - accountingProviders(accountingProviders.orElse(null)) - - fun accountingProviders(accountingProviders: JsonField>) = - apply { - this.accountingProviders = accountingProviders.map { it.toMutableList() } - } - - fun addAccountingProvider(accountingProvider: AccountingProvider) = apply { - accountingProviders = - (accountingProviders ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(accountingProvider) - } - } - - fun excluded(excluded: Boolean?) = excluded(JsonField.ofNullable(excluded)) - - fun excluded(excluded: Boolean) = excluded(excluded as Boolean?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun excluded(excluded: Optional) = excluded(excluded.orElse(null) as Boolean?) - - fun excluded(excluded: JsonField) = apply { this.excluded = excluded } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): AccountingSyncConfiguration = - AccountingSyncConfiguration( - (accountingProviders ?: JsonMissing.of()).map { it.toImmutable() }, - excluded, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class AccountingProvider - @JsonCreator - private constructor( - @JsonProperty("external_provider_id") - @ExcludeMissing - private val externalProviderId: JsonField = JsonMissing.of(), - @JsonProperty("provider_type") - @ExcludeMissing - private val providerType: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun externalProviderId(): String = - externalProviderId.getRequired("external_provider_id") - - fun providerType(): String = providerType.getRequired("provider_type") - - @JsonProperty("external_provider_id") - @ExcludeMissing - fun _externalProviderId(): JsonField = externalProviderId - - @JsonProperty("provider_type") - @ExcludeMissing - fun _providerType(): JsonField = providerType - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AccountingProvider = apply { - if (validated) { - return@apply - } - - externalProviderId() - providerType() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AccountingProvider]. */ - class Builder internal constructor() { - - private var externalProviderId: JsonField? = null - private var providerType: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(accountingProvider: AccountingProvider) = apply { - externalProviderId = accountingProvider.externalProviderId - providerType = accountingProvider.providerType - additionalProperties = accountingProvider.additionalProperties.toMutableMap() - } - - fun externalProviderId(externalProviderId: String) = - externalProviderId(JsonField.of(externalProviderId)) - - fun externalProviderId(externalProviderId: JsonField) = apply { - this.externalProviderId = externalProviderId - } - - fun providerType(providerType: String) = providerType(JsonField.of(providerType)) - - fun providerType(providerType: JsonField) = apply { - this.providerType = providerType - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): AccountingProvider = - AccountingProvider( - checkRequired("externalProviderId", externalProviderId), - checkRequired("providerType", providerType), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AccountingProvider && externalProviderId == other.externalProviderId && providerType == other.providerType && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(externalProviderId, providerType, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AccountingProvider{externalProviderId=$externalProviderId, providerType=$providerType, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AccountingSyncConfiguration && accountingProviders == other.accountingProviders && excluded == other.excluded && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(accountingProviders, excluded, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AccountingSyncConfiguration{accountingProviders=$accountingProviders, excluded=$excluded, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BillingAddress - @JsonCreator - private constructor( - @JsonProperty("city") - @ExcludeMissing - private val city: JsonField = JsonMissing.of(), - @JsonProperty("country") - @ExcludeMissing - private val country: JsonField = JsonMissing.of(), - @JsonProperty("line1") - @ExcludeMissing - private val line1: JsonField = JsonMissing.of(), - @JsonProperty("line2") - @ExcludeMissing - private val line2: JsonField = JsonMissing.of(), - @JsonProperty("postal_code") - @ExcludeMissing - private val postalCode: JsonField = JsonMissing.of(), - @JsonProperty("state") - @ExcludeMissing - private val state: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun city(): Optional = Optional.ofNullable(city.getNullable("city")) - - fun country(): Optional = Optional.ofNullable(country.getNullable("country")) - - fun line1(): Optional = Optional.ofNullable(line1.getNullable("line1")) - - fun line2(): Optional = Optional.ofNullable(line2.getNullable("line2")) - - fun postalCode(): Optional = - Optional.ofNullable(postalCode.getNullable("postal_code")) - - fun state(): Optional = Optional.ofNullable(state.getNullable("state")) - - @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city - - @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country - - @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField = line1 - - @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 - - @JsonProperty("postal_code") - @ExcludeMissing - fun _postalCode(): JsonField = postalCode - - @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingAddress = apply { - if (validated) { - return@apply - } - - city() - country() - line1() - line2() - postalCode() - state() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingAddress]. */ - class Builder internal constructor() { - - private var city: JsonField = JsonMissing.of() - private var country: JsonField = JsonMissing.of() - private var line1: JsonField = JsonMissing.of() - private var line2: JsonField = JsonMissing.of() - private var postalCode: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingAddress: BillingAddress) = apply { - city = billingAddress.city - country = billingAddress.country - line1 = billingAddress.line1 - line2 = billingAddress.line2 - postalCode = billingAddress.postalCode - state = billingAddress.state - additionalProperties = billingAddress.additionalProperties.toMutableMap() - } - - fun city(city: String?) = city(JsonField.ofNullable(city)) - - fun city(city: Optional) = city(city.orElse(null)) - - fun city(city: JsonField) = apply { this.city = city } - - fun country(country: String?) = country(JsonField.ofNullable(country)) - - fun country(country: Optional) = country(country.orElse(null)) - - fun country(country: JsonField) = apply { this.country = country } - - fun line1(line1: String?) = line1(JsonField.ofNullable(line1)) - - fun line1(line1: Optional) = line1(line1.orElse(null)) - - fun line1(line1: JsonField) = apply { this.line1 = line1 } - - fun line2(line2: String?) = line2(JsonField.ofNullable(line2)) - - fun line2(line2: Optional) = line2(line2.orElse(null)) - - fun line2(line2: JsonField) = apply { this.line2 = line2 } - - fun postalCode(postalCode: String?) = postalCode(JsonField.ofNullable(postalCode)) - - fun postalCode(postalCode: Optional) = postalCode(postalCode.orElse(null)) - - fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode } - - fun state(state: String?) = state(JsonField.ofNullable(state)) - - fun state(state: Optional) = state(state.orElse(null)) - - fun state(state: JsonField) = apply { this.state = state } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingAddress = - BillingAddress( - city, - country, - line1, - line2, - postalCode, - state, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingAddress && city == other.city && country == other.country && line1 == other.line1 && line2 == other.line2 && postalCode == other.postalCode && state == other.state && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(city, country, line1, line2, postalCode, state, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingAddress{city=$city, country=$country, line1=$line1, line2=$line2, postalCode=$postalCode, state=$state, additionalProperties=$additionalProperties}" - } - - /** The hierarchical relationships for this customer. */ - @NoAutoDetect - class Hierarchy - @JsonCreator - private constructor( - @JsonProperty("child_customer_ids") - @ExcludeMissing - private val childCustomerIds: JsonField> = JsonMissing.of(), - @JsonProperty("parent_customer_id") - @ExcludeMissing - private val parentCustomerId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * A list of child customer IDs to add to the hierarchy. The desired child customers must - * not already be part of another hierarchy. - */ - fun childCustomerIds(): Optional> = - Optional.ofNullable(childCustomerIds.getNullable("child_customer_ids")) - - /** - * The ID of the parent customer in the hierarchy. The desired parent customer must not be a - * child of another customer. - */ - fun parentCustomerId(): Optional = - Optional.ofNullable(parentCustomerId.getNullable("parent_customer_id")) - - /** - * A list of child customer IDs to add to the hierarchy. The desired child customers must - * not already be part of another hierarchy. - */ - @JsonProperty("child_customer_ids") - @ExcludeMissing - fun _childCustomerIds(): JsonField> = childCustomerIds - - /** - * The ID of the parent customer in the hierarchy. The desired parent customer must not be a - * child of another customer. - */ - @JsonProperty("parent_customer_id") - @ExcludeMissing - fun _parentCustomerId(): JsonField = parentCustomerId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Hierarchy = apply { - if (validated) { - return@apply - } - - childCustomerIds() - parentCustomerId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Hierarchy]. */ - class Builder internal constructor() { - - private var childCustomerIds: JsonField>? = null - private var parentCustomerId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(hierarchy: Hierarchy) = apply { - childCustomerIds = hierarchy.childCustomerIds.map { it.toMutableList() } - parentCustomerId = hierarchy.parentCustomerId - additionalProperties = hierarchy.additionalProperties.toMutableMap() - } - - /** - * A list of child customer IDs to add to the hierarchy. The desired child customers - * must not already be part of another hierarchy. - */ - fun childCustomerIds(childCustomerIds: List) = - childCustomerIds(JsonField.of(childCustomerIds)) - - /** - * A list of child customer IDs to add to the hierarchy. The desired child customers - * must not already be part of another hierarchy. - */ - fun childCustomerIds(childCustomerIds: JsonField>) = apply { - this.childCustomerIds = childCustomerIds.map { it.toMutableList() } - } - - /** - * A list of child customer IDs to add to the hierarchy. The desired child customers - * must not already be part of another hierarchy. - */ - fun addChildCustomerId(childCustomerId: String) = apply { - childCustomerIds = - (childCustomerIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(childCustomerId) - } - } - - /** - * The ID of the parent customer in the hierarchy. The desired parent customer must not - * be a child of another customer. - */ - fun parentCustomerId(parentCustomerId: String?) = - parentCustomerId(JsonField.ofNullable(parentCustomerId)) - - /** - * The ID of the parent customer in the hierarchy. The desired parent customer must not - * be a child of another customer. - */ - fun parentCustomerId(parentCustomerId: Optional) = - parentCustomerId(parentCustomerId.orElse(null)) - - /** - * The ID of the parent customer in the hierarchy. The desired parent customer must not - * be a child of another customer. - */ - fun parentCustomerId(parentCustomerId: JsonField) = apply { - this.parentCustomerId = parentCustomerId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Hierarchy = - Hierarchy( - (childCustomerIds ?: JsonMissing.of()).map { it.toImmutable() }, - parentCustomerId, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Hierarchy && childCustomerIds == other.childCustomerIds && parentCustomerId == other.parentCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(childCustomerIds, parentCustomerId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Hierarchy{childCustomerIds=$childCustomerIds, parentCustomerId=$parentCustomerId, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - /** - * This is used for creating charges or invoices in an external system via Orb. When not in test - * mode: - * - the connection must first be configured in the Orb webapp. - * - if the provider is an invoicing provider (`stripe_invoice`, `quickbooks`, `bill.com`, - * `netsuite`), any product mappings must first be configured with the Orb team. - */ - 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 QUICKBOOKS = of("quickbooks") - - @JvmField val BILL_COM = of("bill.com") - - @JvmField val STRIPE_CHARGE = of("stripe_charge") - - @JvmField val STRIPE_INVOICE = of("stripe_invoice") - - @JvmField val NETSUITE = of("netsuite") - - @JvmStatic fun of(value: String) = PaymentProvider(JsonField.of(value)) - } - - /** An enum containing [PaymentProvider]'s known values. */ - enum class Known { - QUICKBOOKS, - BILL_COM, - STRIPE_CHARGE, - STRIPE_INVOICE, - NETSUITE, - } - - /** - * 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 { - QUICKBOOKS, - BILL_COM, - STRIPE_CHARGE, - STRIPE_INVOICE, - NETSUITE, - /** - * 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) { - QUICKBOOKS -> Value.QUICKBOOKS - BILL_COM -> Value.BILL_COM - STRIPE_CHARGE -> Value.STRIPE_CHARGE - STRIPE_INVOICE -> Value.STRIPE_INVOICE - 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 - BILL_COM -> Known.BILL_COM - STRIPE_CHARGE -> Known.STRIPE_CHARGE - STRIPE_INVOICE -> Known.STRIPE_INVOICE - NETSUITE -> Known.NETSUITE - 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PaymentProvider && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class ReportingConfiguration - @JsonCreator - private constructor( - @JsonProperty("exempt") - @ExcludeMissing - private val exempt: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun exempt(): Boolean = exempt.getRequired("exempt") - - @JsonProperty("exempt") @ExcludeMissing fun _exempt(): JsonField = exempt - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): ReportingConfiguration = apply { - if (validated) { - return@apply - } - - exempt() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ReportingConfiguration]. */ - class Builder internal constructor() { - - private var exempt: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(reportingConfiguration: ReportingConfiguration) = apply { - exempt = reportingConfiguration.exempt - additionalProperties = reportingConfiguration.additionalProperties.toMutableMap() - } - - fun exempt(exempt: Boolean) = exempt(JsonField.of(exempt)) - - fun exempt(exempt: JsonField) = apply { this.exempt = exempt } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): ReportingConfiguration = - ReportingConfiguration( - checkRequired("exempt", exempt), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ReportingConfiguration && exempt == other.exempt && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(exempt, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ReportingConfiguration{exempt=$exempt, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class ShippingAddress - @JsonCreator - private constructor( - @JsonProperty("city") - @ExcludeMissing - private val city: JsonField = JsonMissing.of(), - @JsonProperty("country") - @ExcludeMissing - private val country: JsonField = JsonMissing.of(), - @JsonProperty("line1") - @ExcludeMissing - private val line1: JsonField = JsonMissing.of(), - @JsonProperty("line2") - @ExcludeMissing - private val line2: JsonField = JsonMissing.of(), - @JsonProperty("postal_code") - @ExcludeMissing - private val postalCode: JsonField = JsonMissing.of(), - @JsonProperty("state") - @ExcludeMissing - private val state: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun city(): Optional = Optional.ofNullable(city.getNullable("city")) - - fun country(): Optional = Optional.ofNullable(country.getNullable("country")) - - fun line1(): Optional = Optional.ofNullable(line1.getNullable("line1")) - - fun line2(): Optional = Optional.ofNullable(line2.getNullable("line2")) - - fun postalCode(): Optional = - Optional.ofNullable(postalCode.getNullable("postal_code")) - - fun state(): Optional = Optional.ofNullable(state.getNullable("state")) - - @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city - - @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country - - @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField = line1 - - @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 - - @JsonProperty("postal_code") - @ExcludeMissing - fun _postalCode(): JsonField = postalCode - - @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): ShippingAddress = apply { - if (validated) { - return@apply - } - - city() - country() - line1() - line2() - postalCode() - state() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ShippingAddress]. */ - class Builder internal constructor() { - - private var city: JsonField = JsonMissing.of() - private var country: JsonField = JsonMissing.of() - private var line1: JsonField = JsonMissing.of() - private var line2: JsonField = JsonMissing.of() - private var postalCode: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(shippingAddress: ShippingAddress) = apply { - city = shippingAddress.city - country = shippingAddress.country - line1 = shippingAddress.line1 - line2 = shippingAddress.line2 - postalCode = shippingAddress.postalCode - state = shippingAddress.state - additionalProperties = shippingAddress.additionalProperties.toMutableMap() - } - - fun city(city: String?) = city(JsonField.ofNullable(city)) - - fun city(city: Optional) = city(city.orElse(null)) - - fun city(city: JsonField) = apply { this.city = city } - - fun country(country: String?) = country(JsonField.ofNullable(country)) - - fun country(country: Optional) = country(country.orElse(null)) - - fun country(country: JsonField) = apply { this.country = country } - - fun line1(line1: String?) = line1(JsonField.ofNullable(line1)) - - fun line1(line1: Optional) = line1(line1.orElse(null)) - - fun line1(line1: JsonField) = apply { this.line1 = line1 } - - fun line2(line2: String?) = line2(JsonField.ofNullable(line2)) - - fun line2(line2: Optional) = line2(line2.orElse(null)) - - fun line2(line2: JsonField) = apply { this.line2 = line2 } - - fun postalCode(postalCode: String?) = postalCode(JsonField.ofNullable(postalCode)) - - fun postalCode(postalCode: Optional) = postalCode(postalCode.orElse(null)) - - fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode } - - fun state(state: String?) = state(JsonField.ofNullable(state)) - - fun state(state: Optional) = state(state.orElse(null)) - - fun state(state: JsonField) = apply { this.state = state } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): ShippingAddress = - ShippingAddress( - city, - country, - line1, - line2, - postalCode, - state, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ShippingAddress && city == other.city && country == other.country && line1 == other.line1 && line2 == other.line2 && postalCode == other.postalCode && state == other.state && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(city, country, line1, line2, postalCode, state, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ShippingAddress{city=$city, country=$country, line1=$line1, line2=$line2, postalCode=$postalCode, state=$state, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(using = TaxConfiguration.Deserializer::class) - @JsonSerialize(using = TaxConfiguration.Serializer::class) - class TaxConfiguration - private constructor( - private val newAvalara: NewAvalaraTaxConfiguration? = null, - private val newTaxJar: NewTaxJarConfiguration? = null, - private val _json: JsonValue? = null, - ) { - - fun newAvalara(): Optional = Optional.ofNullable(newAvalara) - - fun newTaxJar(): Optional = Optional.ofNullable(newTaxJar) - - fun isNewAvalara(): Boolean = newAvalara != null - - fun isNewTaxJar(): Boolean = newTaxJar != null - - fun asNewAvalara(): NewAvalaraTaxConfiguration = newAvalara.getOrThrow("newAvalara") - - fun asNewTaxJar(): NewTaxJarConfiguration = newTaxJar.getOrThrow("newTaxJar") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - newAvalara != null -> visitor.visitNewAvalara(newAvalara) - newTaxJar != null -> visitor.visitNewTaxJar(newTaxJar) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): TaxConfiguration = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitNewAvalara(newAvalara: NewAvalaraTaxConfiguration) { - newAvalara.validate() - } - - override fun visitNewTaxJar(newTaxJar: NewTaxJarConfiguration) { - newTaxJar.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TaxConfiguration && newAvalara == other.newAvalara && newTaxJar == other.newTaxJar /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(newAvalara, newTaxJar) /* spotless:on */ - - override fun toString(): String = - when { - newAvalara != null -> "TaxConfiguration{newAvalara=$newAvalara}" - newTaxJar != null -> "TaxConfiguration{newTaxJar=$newTaxJar}" - _json != null -> "TaxConfiguration{_unknown=$_json}" - else -> throw IllegalStateException("Invalid TaxConfiguration") - } - - companion object { - - @JvmStatic - fun ofNewAvalara(newAvalara: NewAvalaraTaxConfiguration) = - TaxConfiguration(newAvalara = newAvalara) - - @JvmStatic - fun ofNewTaxJar(newTaxJar: NewTaxJarConfiguration) = - TaxConfiguration(newTaxJar = newTaxJar) - } - - /** - * An interface that defines how to map each variant of [TaxConfiguration] to a value of - * type [T]. - */ - interface Visitor { - - fun visitNewAvalara(newAvalara: NewAvalaraTaxConfiguration): T - - fun visitNewTaxJar(newTaxJar: NewTaxJarConfiguration): T - - /** - * Maps an unknown variant of [TaxConfiguration] to a value of type [T]. - * - * An instance of [TaxConfiguration] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown TaxConfiguration: $json") - } - } - - internal class Deserializer : BaseDeserializer(TaxConfiguration::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): TaxConfiguration { - val json = JsonValue.fromJsonNode(node) - val taxProvider = - json.asObject().getOrNull()?.get("tax_provider")?.asString()?.getOrNull() - - when (taxProvider) { - "avalara" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return TaxConfiguration(newAvalara = it, _json = json) - } - } - "taxjar" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return TaxConfiguration(newTaxJar = it, _json = json) - } - } - } - - return TaxConfiguration(_json = json) - } - } - - internal class Serializer : BaseSerializer(TaxConfiguration::class) { - - override fun serialize( - value: TaxConfiguration, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.newAvalara != null -> generator.writeObject(value.newAvalara) - value.newTaxJar != null -> generator.writeObject(value.newTaxJar) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid TaxConfiguration") - } - } - } - - @NoAutoDetect - class NewAvalaraTaxConfiguration - @JsonCreator - private constructor( - @JsonProperty("tax_exempt") - @ExcludeMissing - private val taxExempt: JsonField = JsonMissing.of(), - @JsonProperty("tax_provider") - @ExcludeMissing - private val taxProvider: JsonField = JsonMissing.of(), - @JsonProperty("tax_exemption_code") - @ExcludeMissing - private val taxExemptionCode: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun taxExempt(): Boolean = taxExempt.getRequired("tax_exempt") - - fun taxProvider(): TaxProvider = taxProvider.getRequired("tax_provider") - - fun taxExemptionCode(): Optional = - Optional.ofNullable(taxExemptionCode.getNullable("tax_exemption_code")) - - @JsonProperty("tax_exempt") - @ExcludeMissing - fun _taxExempt(): JsonField = taxExempt - - @JsonProperty("tax_provider") - @ExcludeMissing - fun _taxProvider(): JsonField = taxProvider - - @JsonProperty("tax_exemption_code") - @ExcludeMissing - fun _taxExemptionCode(): JsonField = taxExemptionCode - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewAvalaraTaxConfiguration = apply { - if (validated) { - return@apply - } - - taxExempt() - taxProvider() - taxExemptionCode() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewAvalaraTaxConfiguration]. */ - class Builder internal constructor() { - - private var taxExempt: JsonField? = null - private var taxProvider: JsonField? = null - private var taxExemptionCode: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newAvalaraTaxConfiguration: NewAvalaraTaxConfiguration) = apply { - taxExempt = newAvalaraTaxConfiguration.taxExempt - taxProvider = newAvalaraTaxConfiguration.taxProvider - taxExemptionCode = newAvalaraTaxConfiguration.taxExemptionCode - additionalProperties = - newAvalaraTaxConfiguration.additionalProperties.toMutableMap() - } - - fun taxExempt(taxExempt: Boolean) = taxExempt(JsonField.of(taxExempt)) - - fun taxExempt(taxExempt: JsonField) = apply { this.taxExempt = taxExempt } - - fun taxProvider(taxProvider: TaxProvider) = taxProvider(JsonField.of(taxProvider)) - - fun taxProvider(taxProvider: JsonField) = apply { - this.taxProvider = taxProvider - } - - fun taxExemptionCode(taxExemptionCode: String?) = - taxExemptionCode(JsonField.ofNullable(taxExemptionCode)) - - fun taxExemptionCode(taxExemptionCode: Optional) = - taxExemptionCode(taxExemptionCode.orElse(null)) - - fun taxExemptionCode(taxExemptionCode: JsonField) = apply { - this.taxExemptionCode = taxExemptionCode - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): NewAvalaraTaxConfiguration = - NewAvalaraTaxConfiguration( - checkRequired("taxExempt", taxExempt), - checkRequired("taxProvider", taxProvider), - taxExemptionCode, - additionalProperties.toImmutable(), - ) - } - - class TaxProvider - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val AVALARA = of("avalara") - - @JvmStatic fun of(value: String) = TaxProvider(JsonField.of(value)) - } - - /** An enum containing [TaxProvider]'s known values. */ - enum class Known { - AVALARA - } - - /** - * An enum containing [TaxProvider]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [TaxProvider] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AVALARA, - /** - * An enum member indicating that [TaxProvider] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AVALARA -> Value.AVALARA - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AVALARA -> Known.AVALARA - else -> throw OrbInvalidDataException("Unknown TaxProvider: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TaxProvider && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewAvalaraTaxConfiguration && taxExempt == other.taxExempt && taxProvider == other.taxProvider && taxExemptionCode == other.taxExemptionCode && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(taxExempt, taxProvider, taxExemptionCode, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewAvalaraTaxConfiguration{taxExempt=$taxExempt, taxProvider=$taxProvider, taxExemptionCode=$taxExemptionCode, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewTaxJarConfiguration - @JsonCreator - private constructor( - @JsonProperty("tax_exempt") - @ExcludeMissing - private val taxExempt: JsonField = JsonMissing.of(), - @JsonProperty("tax_provider") - @ExcludeMissing - private val taxProvider: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun taxExempt(): Boolean = taxExempt.getRequired("tax_exempt") - - fun taxProvider(): TaxProvider = taxProvider.getRequired("tax_provider") - - @JsonProperty("tax_exempt") - @ExcludeMissing - fun _taxExempt(): JsonField = taxExempt - - @JsonProperty("tax_provider") - @ExcludeMissing - fun _taxProvider(): JsonField = taxProvider - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewTaxJarConfiguration = apply { - if (validated) { - return@apply - } - - taxExempt() - taxProvider() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewTaxJarConfiguration]. */ - class Builder internal constructor() { - - private var taxExempt: JsonField? = null - private var taxProvider: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newTaxJarConfiguration: NewTaxJarConfiguration) = apply { - taxExempt = newTaxJarConfiguration.taxExempt - taxProvider = newTaxJarConfiguration.taxProvider - additionalProperties = - newTaxJarConfiguration.additionalProperties.toMutableMap() - } - - fun taxExempt(taxExempt: Boolean) = taxExempt(JsonField.of(taxExempt)) - - fun taxExempt(taxExempt: JsonField) = apply { this.taxExempt = taxExempt } - - fun taxProvider(taxProvider: TaxProvider) = taxProvider(JsonField.of(taxProvider)) - - fun taxProvider(taxProvider: JsonField) = apply { - this.taxProvider = taxProvider - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): NewTaxJarConfiguration = - NewTaxJarConfiguration( - checkRequired("taxExempt", taxExempt), - checkRequired("taxProvider", taxProvider), - additionalProperties.toImmutable(), - ) - } - - class TaxProvider - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val TAXJAR = of("taxjar") - - @JvmStatic fun of(value: String) = TaxProvider(JsonField.of(value)) - } - - /** An enum containing [TaxProvider]'s known values. */ - enum class Known { - TAXJAR - } - - /** - * An enum containing [TaxProvider]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [TaxProvider] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TAXJAR, - /** - * An enum member indicating that [TaxProvider] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TAXJAR -> Value.TAXJAR - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - TAXJAR -> Known.TAXJAR - else -> throw OrbInvalidDataException("Unknown TaxProvider: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TaxProvider && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewTaxJarConfiguration && taxExempt == other.taxExempt && taxProvider == other.taxProvider && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(taxExempt, taxProvider, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewTaxJarConfiguration{taxExempt=$taxExempt, taxProvider=$taxProvider, additionalProperties=$additionalProperties}" - } - } - - /** - * 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 | - * |--------------------|------------|-------------------------------------------------------------------------------------------------------| - * |Andorra |`ad_nrt` |Andorran NRT Number | - * |Argentina |`ar_cuit` |Argentinian Tax ID Number | - * |Australia |`au_abn` |Australian Business Number (AU ABN) | - * |Australia |`au_arn` |Australian Taxation Office Reference Number | - * |Austria |`eu_vat` |European VAT Number | - * |Bahrain |`bh_vat` |Bahraini VAT Number | - * |Belgium |`eu_vat` |European VAT Number | - * |Bolivia |`bo_tin` |Bolivian Tax ID | - * |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 | - * |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) | - * |Chile |`cl_tin` |Chilean TIN | - * |China |`cn_tin` |Chinese Tax ID | - * |Colombia |`co_nit` |Colombian NIT Number | - * |Costa Rica |`cr_tin` |Costa Rican Tax ID | - * |Croatia |`eu_vat` |European VAT Number | - * |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 | - * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | - * |Finland |`eu_vat` |European VAT Number | - * |France |`eu_vat` |European VAT Number | - * |Georgia |`ge_vat` |Georgian VAT | - * |Germany |`eu_vat` |European VAT Number | - * |Greece |`eu_vat` |European VAT Number | - * |Hong Kong |`hk_br` |Hong Kong BR Number | - * |Hungary |`eu_vat` |European VAT Number | - * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | - * |Iceland |`is_vat` |Icelandic VAT | - * |India |`in_gst` |Indian GST Number | - * |Indonesia |`id_npwp` |Indonesian NPWP Number | - * |Ireland |`eu_vat` |European VAT Number | - * |Israel |`il_vat` |Israel VAT | - * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | - * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | - * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | - * |Latvia |`eu_vat` |European VAT Number | - * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | - * |Mexico |`mx_rfc` |Mexican RFC Number | - * |Netherlands |`eu_vat` |European VAT Number | - * |New Zealand |`nz_gst` |New Zealand GST Number | - * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | - * |Norway |`no_vat` |Norwegian VAT Number | - * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | - * |Oman |`om_vat` |Omani VAT Number | - * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | - * |Poland |`eu_vat` |European VAT Number | - * |Portugal |`eu_vat` |European VAT Number | - * |Romania |`eu_vat` |European VAT Number | - * |Romania |`ro_tin` |Romanian Tax ID Number | - * |Russia |`ru_inn` |Russian INN | - * |Russia |`ru_kpp` |Russian KPP | - * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | - * |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 | - * |Sweden |`eu_vat` |European VAT Number | - * |Switzerland |`ch_vat` |Switzerland VAT Number | - * |Taiwan |`tw_vat` |Taiwanese VAT | - * |Thailand |`th_vat` |Thai VAT | - * |Turkey |`tr_tin` |Turkish Tax Identification Number | - * |Ukraine |`ua_vat` |Ukrainian VAT | - * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | - * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | - * |United Kingdom |`gb_vat` |United Kingdom VAT Number | - * |United States |`us_ein` |United States EIN | - * |Uruguay |`uy_ruc` |Uruguayan RUC Number | - * |Venezuela |`ve_rif` |Venezuelan RIF Number | - * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | - */ - @NoAutoDetect - class TaxId - @JsonCreator - private constructor( - @JsonProperty("country") - @ExcludeMissing - private val country: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonProperty("value") - @ExcludeMissing - private val value: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun country(): Country = country.getRequired("country") - - fun type(): Type = type.getRequired("type") - - fun value(): String = value.getRequired("value") - - @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country - - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TaxId = apply { - if (validated) { - return@apply - } - - country() - type() - value() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TaxId]. */ - class Builder internal constructor() { - - private var country: JsonField? = null - private var type: JsonField? = null - private var value: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(taxId: TaxId) = apply { - country = taxId.country - type = taxId.type - value = taxId.value - additionalProperties = taxId.additionalProperties.toMutableMap() - } - - fun country(country: Country) = country(JsonField.of(country)) - - fun country(country: JsonField) = apply { this.country = country } - - fun type(type: Type) = type(JsonField.of(type)) - - fun type(type: JsonField) = apply { this.type = type } - - fun value(value: String) = value(JsonField.of(value)) - - fun value(value: JsonField) = apply { this.value = 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) - } - - fun build(): TaxId = - TaxId( - checkRequired("country", country), - checkRequired("type", type), - checkRequired("value", value), - additionalProperties.toImmutable(), - ) - } - - class Country @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val AD = of("AD") - - @JvmField val AE = of("AE") - - @JvmField val AR = of("AR") - - @JvmField val AT = of("AT") - - @JvmField val AU = of("AU") - - @JvmField val BE = of("BE") - - @JvmField val BG = of("BG") - - @JvmField val BH = of("BH") - - @JvmField val BO = of("BO") - - @JvmField val BR = of("BR") - - @JvmField val CA = of("CA") - - @JvmField val CH = of("CH") - - @JvmField val CL = of("CL") - - @JvmField val CN = of("CN") - - @JvmField val CO = of("CO") - - @JvmField val CR = of("CR") - - @JvmField val CY = of("CY") - - @JvmField val CZ = of("CZ") - - @JvmField val DE = of("DE") - - @JvmField val DK = of("DK") - - @JvmField val EE = of("EE") - - @JvmField val DO = of("DO") - - @JvmField val EC = of("EC") - - @JvmField val EG = of("EG") - - @JvmField val ES = of("ES") - - @JvmField val EU = of("EU") - - @JvmField val FI = of("FI") - - @JvmField val FR = of("FR") - - @JvmField val GB = of("GB") - - @JvmField val GE = of("GE") - - @JvmField val GR = of("GR") - - @JvmField val HK = of("HK") - - @JvmField val HR = of("HR") - - @JvmField val HU = of("HU") - - @JvmField val ID = of("ID") - - @JvmField val IE = of("IE") - - @JvmField val IL = of("IL") - - @JvmField val IN = of("IN") - - @JvmField val IS = of("IS") - - @JvmField val IT = of("IT") - - @JvmField val JP = of("JP") - - @JvmField val KE = of("KE") - - @JvmField val KR = of("KR") - - @JvmField val KZ = of("KZ") - - @JvmField val LI = of("LI") - - @JvmField val LT = of("LT") - - @JvmField val LU = of("LU") - - @JvmField val LV = of("LV") - - @JvmField val MT = of("MT") - - @JvmField val MX = of("MX") - - @JvmField val MY = of("MY") - - @JvmField val NG = of("NG") - - @JvmField val NL = of("NL") - - @JvmField val NO = of("NO") - - @JvmField val NZ = of("NZ") - - @JvmField val OM = of("OM") - - @JvmField val PE = of("PE") - - @JvmField val PH = of("PH") - - @JvmField val PL = of("PL") - - @JvmField val PT = of("PT") - - @JvmField val RO = of("RO") - - @JvmField val RS = of("RS") - - @JvmField val RU = of("RU") - - @JvmField val SA = of("SA") - - @JvmField val SE = of("SE") - - @JvmField val SG = of("SG") - - @JvmField val SI = of("SI") - - @JvmField val SK = of("SK") - - @JvmField val SV = of("SV") - - @JvmField val TH = of("TH") - - @JvmField val TR = of("TR") - - @JvmField val TW = of("TW") - - @JvmField val UA = of("UA") - - @JvmField val US = of("US") - - @JvmField val UY = of("UY") - - @JvmField val VE = of("VE") - - @JvmField val VN = of("VN") - - @JvmField val ZA = of("ZA") - - @JvmStatic fun of(value: String) = Country(JsonField.of(value)) - } - - /** An enum containing [Country]'s known values. */ - enum class Known { - AD, - AE, - AR, - AT, - AU, - BE, - BG, - BH, - BO, - BR, - CA, - CH, - CL, - CN, - CO, - CR, - CY, - CZ, - DE, - DK, - EE, - DO, - EC, - EG, - ES, - EU, - FI, - FR, - GB, - GE, - GR, - HK, - HR, - HU, - ID, - IE, - IL, - IN, - IS, - IT, - JP, - KE, - KR, - KZ, - LI, - LT, - LU, - LV, - MT, - MX, - MY, - NG, - NL, - NO, - NZ, - OM, - PE, - PH, - PL, - PT, - RO, - RS, - RU, - SA, - SE, - SG, - SI, - SK, - SV, - TH, - TR, - TW, - UA, - US, - UY, - VE, - VN, - ZA, - } - - /** - * An enum containing [Country]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Country] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AD, - AE, - AR, - AT, - AU, - BE, - BG, - BH, - BO, - BR, - CA, - CH, - CL, - CN, - CO, - CR, - CY, - CZ, - DE, - DK, - EE, - DO, - EC, - EG, - ES, - EU, - FI, - FR, - GB, - GE, - GR, - HK, - HR, - HU, - ID, - IE, - IL, - IN, - IS, - IT, - JP, - KE, - KR, - KZ, - LI, - LT, - LU, - LV, - MT, - MX, - MY, - NG, - NL, - NO, - NZ, - OM, - PE, - PH, - PL, - PT, - RO, - RS, - RU, - SA, - SE, - SG, - SI, - SK, - SV, - TH, - TR, - TW, - UA, - US, - UY, - VE, - VN, - ZA, - /** - * An enum member indicating that [Country] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AD -> Value.AD - AE -> Value.AE - AR -> Value.AR - AT -> Value.AT - AU -> Value.AU - BE -> Value.BE - BG -> Value.BG - BH -> Value.BH - BO -> Value.BO - BR -> Value.BR - CA -> Value.CA - CH -> Value.CH - CL -> Value.CL - CN -> Value.CN - CO -> Value.CO - CR -> Value.CR - CY -> Value.CY - CZ -> Value.CZ - DE -> Value.DE - DK -> Value.DK - EE -> Value.EE - DO -> Value.DO - EC -> Value.EC - EG -> Value.EG - ES -> Value.ES - EU -> Value.EU - FI -> Value.FI - FR -> Value.FR - GB -> Value.GB - GE -> Value.GE - GR -> Value.GR - HK -> Value.HK - HR -> Value.HR - HU -> Value.HU - ID -> Value.ID - IE -> Value.IE - IL -> Value.IL - IN -> Value.IN - IS -> Value.IS - IT -> Value.IT - JP -> Value.JP - KE -> Value.KE - KR -> Value.KR - KZ -> Value.KZ - LI -> Value.LI - LT -> Value.LT - LU -> Value.LU - LV -> Value.LV - MT -> Value.MT - MX -> Value.MX - MY -> Value.MY - NG -> Value.NG - NL -> Value.NL - NO -> Value.NO - NZ -> Value.NZ - OM -> Value.OM - PE -> Value.PE - PH -> Value.PH - PL -> Value.PL - PT -> Value.PT - RO -> Value.RO - RS -> Value.RS - RU -> Value.RU - SA -> Value.SA - SE -> Value.SE - SG -> Value.SG - SI -> Value.SI - SK -> Value.SK - SV -> Value.SV - TH -> Value.TH - TR -> Value.TR - TW -> Value.TW - UA -> Value.UA - US -> Value.US - UY -> Value.UY - VE -> Value.VE - VN -> Value.VN - ZA -> Value.ZA - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AD -> Known.AD - AE -> Known.AE - AR -> Known.AR - AT -> Known.AT - AU -> Known.AU - BE -> Known.BE - BG -> Known.BG - BH -> Known.BH - BO -> Known.BO - BR -> Known.BR - CA -> Known.CA - CH -> Known.CH - CL -> Known.CL - CN -> Known.CN - CO -> Known.CO - CR -> Known.CR - CY -> Known.CY - CZ -> Known.CZ - DE -> Known.DE - DK -> Known.DK - EE -> Known.EE - DO -> Known.DO - EC -> Known.EC - EG -> Known.EG - ES -> Known.ES - EU -> Known.EU - FI -> Known.FI - FR -> Known.FR - GB -> Known.GB - GE -> Known.GE - GR -> Known.GR - HK -> Known.HK - HR -> Known.HR - HU -> Known.HU - ID -> Known.ID - IE -> Known.IE - IL -> Known.IL - IN -> Known.IN - IS -> Known.IS - IT -> Known.IT - JP -> Known.JP - KE -> Known.KE - KR -> Known.KR - KZ -> Known.KZ - LI -> Known.LI - LT -> Known.LT - LU -> Known.LU - LV -> Known.LV - MT -> Known.MT - MX -> Known.MX - MY -> Known.MY - NG -> Known.NG - NL -> Known.NL - NO -> Known.NO - NZ -> Known.NZ - OM -> Known.OM - PE -> Known.PE - PH -> Known.PH - PL -> Known.PL - PT -> Known.PT - RO -> Known.RO - RS -> Known.RS - RU -> Known.RU - SA -> Known.SA - SE -> Known.SE - SG -> Known.SG - SI -> Known.SI - SK -> Known.SK - SV -> Known.SV - TH -> Known.TH - TR -> Known.TR - TW -> Known.TW - UA -> Known.UA - US -> Known.US - UY -> Known.UY - VE -> Known.VE - VN -> Known.VN - ZA -> Known.ZA - else -> throw OrbInvalidDataException("Unknown Country: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is Country && value == other.value /* spotless:on */ - } - - 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 AD_NRT = of("ad_nrt") - - @JvmField val AE_TRN = of("ae_trn") - - @JvmField val AR_CUIT = of("ar_cuit") - - @JvmField val EU_VAT = of("eu_vat") - - @JvmField val AU_ABN = of("au_abn") - - @JvmField val AU_ARN = of("au_arn") - - @JvmField val BG_UIC = of("bg_uic") - - @JvmField val BH_VAT = of("bh_vat") - - @JvmField val BO_TIN = of("bo_tin") - - @JvmField val BR_CNPJ = of("br_cnpj") - - @JvmField val BR_CPF = of("br_cpf") - - @JvmField val CA_BN = of("ca_bn") - - @JvmField val CA_GST_HST = of("ca_gst_hst") - - @JvmField val CA_PST_BC = of("ca_pst_bc") - - @JvmField val CA_PST_MB = of("ca_pst_mb") - - @JvmField val CA_PST_SK = of("ca_pst_sk") - - @JvmField val CA_QST = of("ca_qst") - - @JvmField val CH_VAT = of("ch_vat") - - @JvmField val CL_TIN = of("cl_tin") - - @JvmField val CN_TIN = of("cn_tin") - - @JvmField val CO_NIT = of("co_nit") - - @JvmField val CR_TIN = of("cr_tin") - - @JvmField val DO_RCN = of("do_rcn") - - @JvmField val EC_RUC = of("ec_ruc") - - @JvmField val EG_TIN = of("eg_tin") - - @JvmField val ES_CIF = of("es_cif") - - @JvmField val EU_OSS_VAT = of("eu_oss_vat") - - @JvmField val GB_VAT = of("gb_vat") - - @JvmField val GE_VAT = of("ge_vat") - - @JvmField val HK_BR = of("hk_br") - - @JvmField val HU_TIN = of("hu_tin") - - @JvmField val ID_NPWP = of("id_npwp") - - @JvmField val IL_VAT = of("il_vat") - - @JvmField val IN_GST = of("in_gst") - - @JvmField val IS_VAT = of("is_vat") - - @JvmField val JP_CN = of("jp_cn") - - @JvmField val JP_RN = of("jp_rn") - - @JvmField val JP_TRN = of("jp_trn") - - @JvmField val KE_PIN = of("ke_pin") - - @JvmField val KR_BRN = of("kr_brn") - - @JvmField val KZ_BIN = of("kz_bin") - - @JvmField val LI_UID = of("li_uid") - - @JvmField val MX_RFC = of("mx_rfc") - - @JvmField val MY_FRP = of("my_frp") - - @JvmField val MY_ITN = of("my_itn") - - @JvmField val MY_SST = of("my_sst") - - @JvmField val NG_TIN = of("ng_tin") - - @JvmField val NO_VAT = of("no_vat") - - @JvmField val NO_VOEC = of("no_voec") - - @JvmField val NZ_GST = of("nz_gst") - - @JvmField val OM_VAT = of("om_vat") - - @JvmField val PE_RUC = of("pe_ruc") - - @JvmField val PH_TIN = of("ph_tin") - - @JvmField val RO_TIN = of("ro_tin") - - @JvmField val RS_PIB = of("rs_pib") - - @JvmField val RU_INN = of("ru_inn") - - @JvmField val RU_KPP = of("ru_kpp") - - @JvmField val SA_VAT = of("sa_vat") - - @JvmField val SG_GST = of("sg_gst") - - @JvmField val SG_UEN = of("sg_uen") - - @JvmField val SI_TIN = of("si_tin") - - @JvmField val SV_NIT = of("sv_nit") - - @JvmField val TH_VAT = of("th_vat") - - @JvmField val TR_TIN = of("tr_tin") - - @JvmField val TW_VAT = of("tw_vat") - - @JvmField val UA_VAT = of("ua_vat") - - @JvmField val US_EIN = of("us_ein") - - @JvmField val UY_RUC = of("uy_ruc") - - @JvmField val VE_RIF = of("ve_rif") - - @JvmField val VN_TIN = of("vn_tin") - - @JvmField val ZA_VAT = of("za_vat") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - AD_NRT, - AE_TRN, - AR_CUIT, - EU_VAT, - AU_ABN, - AU_ARN, - BG_UIC, - BH_VAT, - BO_TIN, - BR_CNPJ, - BR_CPF, - CA_BN, - CA_GST_HST, - CA_PST_BC, - CA_PST_MB, - CA_PST_SK, - CA_QST, - CH_VAT, - CL_TIN, - CN_TIN, - CO_NIT, - CR_TIN, - DO_RCN, - EC_RUC, - EG_TIN, - ES_CIF, - EU_OSS_VAT, - GB_VAT, - GE_VAT, - HK_BR, - HU_TIN, - ID_NPWP, - IL_VAT, - IN_GST, - IS_VAT, - JP_CN, - JP_RN, - JP_TRN, - KE_PIN, - KR_BRN, - KZ_BIN, - LI_UID, - MX_RFC, - MY_FRP, - MY_ITN, - MY_SST, - NG_TIN, - NO_VAT, - NO_VOEC, - NZ_GST, - OM_VAT, - PE_RUC, - PH_TIN, - RO_TIN, - RS_PIB, - RU_INN, - RU_KPP, - SA_VAT, - SG_GST, - SG_UEN, - SI_TIN, - SV_NIT, - TH_VAT, - TR_TIN, - TW_VAT, - UA_VAT, - US_EIN, - UY_RUC, - VE_RIF, - VN_TIN, - ZA_VAT, - } - - /** - * 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 { - AD_NRT, - AE_TRN, - AR_CUIT, - EU_VAT, - AU_ABN, - AU_ARN, - BG_UIC, - BH_VAT, - BO_TIN, - BR_CNPJ, - BR_CPF, - CA_BN, - CA_GST_HST, - CA_PST_BC, - CA_PST_MB, - CA_PST_SK, - CA_QST, - CH_VAT, - CL_TIN, - CN_TIN, - CO_NIT, - CR_TIN, - DO_RCN, - EC_RUC, - EG_TIN, - ES_CIF, - EU_OSS_VAT, - GB_VAT, - GE_VAT, - HK_BR, - HU_TIN, - ID_NPWP, - IL_VAT, - IN_GST, - IS_VAT, - JP_CN, - JP_RN, - JP_TRN, - KE_PIN, - KR_BRN, - KZ_BIN, - LI_UID, - MX_RFC, - MY_FRP, - MY_ITN, - MY_SST, - NG_TIN, - NO_VAT, - NO_VOEC, - NZ_GST, - OM_VAT, - PE_RUC, - PH_TIN, - RO_TIN, - RS_PIB, - RU_INN, - RU_KPP, - SA_VAT, - SG_GST, - SG_UEN, - SI_TIN, - SV_NIT, - TH_VAT, - TR_TIN, - TW_VAT, - UA_VAT, - US_EIN, - UY_RUC, - VE_RIF, - VN_TIN, - ZA_VAT, - /** 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) { - AD_NRT -> Value.AD_NRT - AE_TRN -> Value.AE_TRN - AR_CUIT -> Value.AR_CUIT - EU_VAT -> Value.EU_VAT - AU_ABN -> Value.AU_ABN - AU_ARN -> Value.AU_ARN - BG_UIC -> Value.BG_UIC - BH_VAT -> Value.BH_VAT - BO_TIN -> Value.BO_TIN - BR_CNPJ -> Value.BR_CNPJ - BR_CPF -> Value.BR_CPF - CA_BN -> Value.CA_BN - CA_GST_HST -> Value.CA_GST_HST - CA_PST_BC -> Value.CA_PST_BC - CA_PST_MB -> Value.CA_PST_MB - CA_PST_SK -> Value.CA_PST_SK - CA_QST -> Value.CA_QST - CH_VAT -> Value.CH_VAT - CL_TIN -> Value.CL_TIN - CN_TIN -> Value.CN_TIN - CO_NIT -> Value.CO_NIT - CR_TIN -> Value.CR_TIN - DO_RCN -> Value.DO_RCN - EC_RUC -> Value.EC_RUC - EG_TIN -> Value.EG_TIN - ES_CIF -> Value.ES_CIF - EU_OSS_VAT -> Value.EU_OSS_VAT - GB_VAT -> Value.GB_VAT - GE_VAT -> Value.GE_VAT - HK_BR -> Value.HK_BR - HU_TIN -> Value.HU_TIN - ID_NPWP -> Value.ID_NPWP - IL_VAT -> Value.IL_VAT - IN_GST -> Value.IN_GST - IS_VAT -> Value.IS_VAT - JP_CN -> Value.JP_CN - JP_RN -> Value.JP_RN - JP_TRN -> Value.JP_TRN - KE_PIN -> Value.KE_PIN - KR_BRN -> Value.KR_BRN - KZ_BIN -> Value.KZ_BIN - LI_UID -> Value.LI_UID - MX_RFC -> Value.MX_RFC - MY_FRP -> Value.MY_FRP - MY_ITN -> Value.MY_ITN - MY_SST -> Value.MY_SST - NG_TIN -> Value.NG_TIN - NO_VAT -> Value.NO_VAT - NO_VOEC -> Value.NO_VOEC - NZ_GST -> Value.NZ_GST - OM_VAT -> Value.OM_VAT - PE_RUC -> Value.PE_RUC - PH_TIN -> Value.PH_TIN - RO_TIN -> Value.RO_TIN - RS_PIB -> Value.RS_PIB - RU_INN -> Value.RU_INN - RU_KPP -> Value.RU_KPP - SA_VAT -> Value.SA_VAT - SG_GST -> Value.SG_GST - SG_UEN -> Value.SG_UEN - SI_TIN -> Value.SI_TIN - SV_NIT -> Value.SV_NIT - TH_VAT -> Value.TH_VAT - TR_TIN -> Value.TR_TIN - TW_VAT -> Value.TW_VAT - UA_VAT -> Value.UA_VAT - US_EIN -> Value.US_EIN - UY_RUC -> Value.UY_RUC - VE_RIF -> Value.VE_RIF - VN_TIN -> Value.VN_TIN - ZA_VAT -> Value.ZA_VAT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AD_NRT -> Known.AD_NRT - AE_TRN -> Known.AE_TRN - AR_CUIT -> Known.AR_CUIT - EU_VAT -> Known.EU_VAT - AU_ABN -> Known.AU_ABN - AU_ARN -> Known.AU_ARN - BG_UIC -> Known.BG_UIC - BH_VAT -> Known.BH_VAT - BO_TIN -> Known.BO_TIN - BR_CNPJ -> Known.BR_CNPJ - BR_CPF -> Known.BR_CPF - CA_BN -> Known.CA_BN - CA_GST_HST -> Known.CA_GST_HST - CA_PST_BC -> Known.CA_PST_BC - CA_PST_MB -> Known.CA_PST_MB - CA_PST_SK -> Known.CA_PST_SK - CA_QST -> Known.CA_QST - CH_VAT -> Known.CH_VAT - CL_TIN -> Known.CL_TIN - CN_TIN -> Known.CN_TIN - CO_NIT -> Known.CO_NIT - CR_TIN -> Known.CR_TIN - DO_RCN -> Known.DO_RCN - EC_RUC -> Known.EC_RUC - EG_TIN -> Known.EG_TIN - ES_CIF -> Known.ES_CIF - EU_OSS_VAT -> Known.EU_OSS_VAT - GB_VAT -> Known.GB_VAT - GE_VAT -> Known.GE_VAT - HK_BR -> Known.HK_BR - HU_TIN -> Known.HU_TIN - ID_NPWP -> Known.ID_NPWP - IL_VAT -> Known.IL_VAT - IN_GST -> Known.IN_GST - IS_VAT -> Known.IS_VAT - JP_CN -> Known.JP_CN - JP_RN -> Known.JP_RN - JP_TRN -> Known.JP_TRN - KE_PIN -> Known.KE_PIN - KR_BRN -> Known.KR_BRN - KZ_BIN -> Known.KZ_BIN - LI_UID -> Known.LI_UID - MX_RFC -> Known.MX_RFC - MY_FRP -> Known.MY_FRP - MY_ITN -> Known.MY_ITN - MY_SST -> Known.MY_SST - NG_TIN -> Known.NG_TIN - NO_VAT -> Known.NO_VAT - NO_VOEC -> Known.NO_VOEC - NZ_GST -> Known.NZ_GST - OM_VAT -> Known.OM_VAT - PE_RUC -> Known.PE_RUC - PH_TIN -> Known.PH_TIN - RO_TIN -> Known.RO_TIN - RS_PIB -> Known.RS_PIB - RU_INN -> Known.RU_INN - RU_KPP -> Known.RU_KPP - SA_VAT -> Known.SA_VAT - SG_GST -> Known.SG_GST - SG_UEN -> Known.SG_UEN - SI_TIN -> Known.SI_TIN - SV_NIT -> Known.SV_NIT - TH_VAT -> Known.TH_VAT - TR_TIN -> Known.TR_TIN - TW_VAT -> Known.TW_VAT - UA_VAT -> Known.UA_VAT - US_EIN -> Known.US_EIN - UY_RUC -> Known.UY_RUC - VE_RIF -> Known.VE_RIF - VN_TIN -> Known.VN_TIN - ZA_VAT -> Known.ZA_VAT - 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TaxId && country == other.country && type == other.type && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(country, type, value, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TaxId{country=$country, type=$type, value=$value, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is CustomerUpdateParams && customerId == other.customerId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is CustomerUpdateParams && customerId == other.customerId && editCustomerModel == other.editCustomerModel && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(customerId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(customerId, editCustomerModel, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "CustomerUpdateParams{customerId=$customerId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "CustomerUpdateParams{customerId=$customerId, editCustomerModel=$editCustomerModel, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceConfigurationModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceConfigurationModel.kt new file mode 100644 index 000000000..c42167aaa --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceConfigurationModel.kt @@ -0,0 +1,160 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects + +@NoAutoDetect +class DimensionalPriceConfigurationModel +@JsonCreator +private constructor( + @JsonProperty("dimension_values") + @ExcludeMissing + private val dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("dimensional_price_group_id") + @ExcludeMissing + private val dimensionalPriceGroupId: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun dimensionValues(): List = dimensionValues.getRequired("dimension_values") + + fun dimensionalPriceGroupId(): String = + dimensionalPriceGroupId.getRequired("dimensional_price_group_id") + + @JsonProperty("dimension_values") + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues + + @JsonProperty("dimensional_price_group_id") + @ExcludeMissing + fun _dimensionalPriceGroupId(): JsonField = dimensionalPriceGroupId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): DimensionalPriceConfigurationModel = apply { + if (validated) { + return@apply + } + + dimensionValues() + dimensionalPriceGroupId() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [DimensionalPriceConfigurationModel]. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .dimensionalPriceGroupId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DimensionalPriceConfigurationModel]. */ + class Builder internal constructor() { + + private var dimensionValues: JsonField>? = null + private var dimensionalPriceGroupId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(dimensionalPriceConfigurationModel: DimensionalPriceConfigurationModel) = + apply { + dimensionValues = + dimensionalPriceConfigurationModel.dimensionValues.map { it.toMutableList() } + dimensionalPriceGroupId = dimensionalPriceConfigurationModel.dimensionalPriceGroupId + additionalProperties = + dimensionalPriceConfigurationModel.additionalProperties.toMutableMap() + } + + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) + + fun dimensionValues(dimensionValues: JsonField>) = apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } + } + + fun addDimensionValue(dimensionValue: String) = apply { + dimensionValues = + (dimensionValues ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensionValues", it).add(dimensionValue) + } + } + + fun dimensionalPriceGroupId(dimensionalPriceGroupId: String) = + dimensionalPriceGroupId(JsonField.of(dimensionalPriceGroupId)) + + fun dimensionalPriceGroupId(dimensionalPriceGroupId: JsonField) = apply { + this.dimensionalPriceGroupId = dimensionalPriceGroupId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): DimensionalPriceConfigurationModel = + DimensionalPriceConfigurationModel( + checkRequired("dimensionValues", dimensionValues).map { it.toImmutable() }, + checkRequired("dimensionalPriceGroupId", dimensionalPriceGroupId), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DimensionalPriceConfigurationModel && dimensionValues == other.dimensionValues && dimensionalPriceGroupId == other.dimensionalPriceGroupId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(dimensionValues, dimensionalPriceGroupId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DimensionalPriceConfigurationModel{dimensionValues=$dimensionValues, dimensionalPriceGroupId=$dimensionalPriceGroupId, additionalProperties=$additionalProperties}" +} 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 8df86a0f5..c74a2ec6f 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 @@ -11,6 +11,7 @@ import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.immutableEmptyMap import com.withorb.api.core.toImmutable @@ -123,6 +124,19 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [DimensionalPriceGroup]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetricId() + * .dimensions() + * .externalDimensionalPriceGroupId() + * .metadata() + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -178,14 +192,8 @@ private constructor( /** The dimensions that this dimensional price group is defined over */ fun addDimension(dimension: String) = apply { dimensions = - (dimensions ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimension) + (dimensions ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensions", it).add(dimension) } } @@ -285,6 +293,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } 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 7a846de46..d148698dd 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 @@ -12,6 +12,7 @@ import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.Params +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams @@ -168,6 +169,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .billableMetricId() + * .dimensions() + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -209,14 +220,8 @@ private constructor( /** The set of keys (in order) used to disambiguate prices in the group. */ fun addDimension(dimension: String) = apply { dimensions = - (dimensions ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimension) + (dimensions ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensions", it).add(dimension) } } @@ -309,6 +314,17 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [DimensionalPriceGroupCreateParams]. + * + * The following fields are required: + * ```java + * .billableMetricId() + * .dimensions() + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -539,6 +555,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams.kt index 5aba7ffd7..c649d76cc 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams.kt @@ -38,6 +38,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams]. + * + * The following fields are required: + * ```java + * .externalDimensionalPriceGroupId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPage.kt index 027b90773..f5eacb378 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPage.kt @@ -29,7 +29,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -88,20 +88,21 @@ private constructor( @JsonCreator constructor( @JsonProperty("data") - private val data: JsonField> = JsonMissing.of(), + private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = Optional.ofNullable(data) + fun _data(): Optional>> = + Optional.ofNullable(data) @JsonProperty("pagination_metadata") fun _paginationMetadata(): Optional> = @@ -140,12 +141,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [DimensionalPriceGroupListPage]. + */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -156,9 +161,9 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { this.data = data } fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) @@ -176,9 +181,9 @@ private constructor( } class AutoPager(private val firstPage: DimensionalPriceGroupListPage) : - Iterable { + Iterable { - override fun iterator(): Iterator = iterator { + override fun iterator(): Iterator = iterator { var page = firstPage var index = 0 while (true) { @@ -190,7 +195,7 @@ private constructor( } } - fun stream(): Stream { + fun stream(): Stream { return StreamSupport.stream(spliterator(), false) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPageAsync.kt index ff7d0b736..b57c927f5 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListPageAsync.kt @@ -30,7 +30,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -91,20 +91,21 @@ private constructor( @JsonCreator constructor( @JsonProperty("data") - private val data: JsonField> = JsonMissing.of(), + private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = Optional.ofNullable(data) + fun _data(): Optional>> = + Optional.ofNullable(data) @JsonProperty("pagination_metadata") fun _paginationMetadata(): Optional> = @@ -143,12 +144,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [DimensionalPriceGroupListPageAsync]. + */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -159,9 +164,9 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { this.data = data } fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) @@ -181,11 +186,11 @@ private constructor( class AutoPager(private val firstPage: DimensionalPriceGroupListPageAsync) { fun forEach( - action: Predicate, + action: Predicate, executor: Executor, ): CompletableFuture { fun CompletableFuture>.forEach( - action: (DimensionalPriceGroup) -> Boolean, + action: (DimensionalPriceGroupModel) -> Boolean, executor: Executor, ): CompletableFuture = thenComposeAsync( @@ -201,8 +206,8 @@ private constructor( .forEach(action::test, executor) } - fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() + fun toList(executor: Executor): CompletableFuture> { + val values = mutableListOf() return forEach(values::add, executor).thenApply { values } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListParams.kt index 870d6b276..61e92df78 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListParams.kt @@ -47,6 +47,10 @@ private constructor( @JvmStatic fun none(): DimensionalPriceGroupListParams = builder().build() + /** + * Returns a mutable builder for constructing an instance of + * [DimensionalPriceGroupListParams]. + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupModel.kt new file mode 100644 index 000000000..87ae9879b --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupModel.kt @@ -0,0 +1,366 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects +import java.util.Optional + +/** + * 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. + */ +@NoAutoDetect +class DimensionalPriceGroupModel +@JsonCreator +private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("dimensions") + @ExcludeMissing + private val dimensions: JsonField> = JsonMissing.of(), + @JsonProperty("external_dimensional_price_group_id") + @ExcludeMissing + private val externalDimensionalPriceGroupId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun id(): String = id.getRequired("id") + + /** + * The billable metric associated with this dimensional price group. All prices associated with + * this dimensional price group will be computed using this billable metric. + */ + fun billableMetricId(): String = billableMetricId.getRequired("billable_metric_id") + + /** The dimensions that this dimensional price group is defined over */ + fun dimensions(): List = dimensions.getRequired("dimensions") + + /** An alias for the dimensional price group */ + fun externalDimensionalPriceGroupId(): Optional = + Optional.ofNullable( + externalDimensionalPriceGroupId.getNullable("external_dimensional_price_group_id") + ) + + /** + * 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.getRequired("metadata") + + /** The name of the dimensional price group */ + fun name(): String = name.getRequired("name") + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * The billable metric associated with this dimensional price group. All prices associated with + * this dimensional price group will be computed using this billable metric. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** The dimensions that this dimensional price group is defined over */ + @JsonProperty("dimensions") + @ExcludeMissing + fun _dimensions(): JsonField> = dimensions + + /** An alias for the dimensional price group */ + @JsonProperty("external_dimensional_price_group_id") + @ExcludeMissing + fun _externalDimensionalPriceGroupId(): JsonField = externalDimensionalPriceGroupId + + /** + * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** The name of the dimensional price group */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): DimensionalPriceGroupModel = apply { + if (validated) { + return@apply + } + + id() + billableMetricId() + dimensions() + externalDimensionalPriceGroupId() + metadata().validate() + name() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DimensionalPriceGroupModel]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetricId() + * .dimensions() + * .externalDimensionalPriceGroupId() + * .metadata() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DimensionalPriceGroupModel]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetricId: JsonField? = null + private var dimensions: JsonField>? = null + private var externalDimensionalPriceGroupId: JsonField? = null + private var metadata: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(dimensionalPriceGroupModel: DimensionalPriceGroupModel) = apply { + id = dimensionalPriceGroupModel.id + billableMetricId = dimensionalPriceGroupModel.billableMetricId + dimensions = dimensionalPriceGroupModel.dimensions.map { it.toMutableList() } + externalDimensionalPriceGroupId = + dimensionalPriceGroupModel.externalDimensionalPriceGroupId + metadata = dimensionalPriceGroupModel.metadata + name = dimensionalPriceGroupModel.name + additionalProperties = dimensionalPriceGroupModel.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + /** + * The billable metric associated with this dimensional price group. All prices associated + * with this dimensional price group will be computed using this billable metric. + */ + fun billableMetricId(billableMetricId: String) = + billableMetricId(JsonField.of(billableMetricId)) + + /** + * The billable metric associated with this dimensional price group. All prices associated + * with this dimensional price group will be computed using this billable metric. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + + /** The dimensions that this dimensional price group is defined over */ + fun dimensions(dimensions: List) = dimensions(JsonField.of(dimensions)) + + /** The dimensions that this dimensional price group is defined over */ + fun dimensions(dimensions: JsonField>) = apply { + this.dimensions = dimensions.map { it.toMutableList() } + } + + /** The dimensions that this dimensional price group is defined over */ + fun addDimension(dimension: String) = apply { + dimensions = + (dimensions ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensions", it).add(dimension) + } + } + + /** An alias for the dimensional price group */ + fun externalDimensionalPriceGroupId(externalDimensionalPriceGroupId: String?) = + externalDimensionalPriceGroupId(JsonField.ofNullable(externalDimensionalPriceGroupId)) + + /** An alias for the dimensional price group */ + fun externalDimensionalPriceGroupId(externalDimensionalPriceGroupId: Optional) = + externalDimensionalPriceGroupId(externalDimensionalPriceGroupId.orElse(null)) + + /** An alias for the dimensional price group */ + fun externalDimensionalPriceGroupId(externalDimensionalPriceGroupId: JsonField) = + apply { + this.externalDimensionalPriceGroupId = externalDimensionalPriceGroupId + } + + /** + * 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)) + + /** + * 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: JsonField) = apply { this.metadata = metadata } + + /** The name of the dimensional price group */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the dimensional price group */ + 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) + } + + fun build(): DimensionalPriceGroupModel = + DimensionalPriceGroupModel( + checkRequired("id", id), + checkRequired("billableMetricId", billableMetricId), + checkRequired("dimensions", dimensions).map { it.toImmutable() }, + checkRequired("externalDimensionalPriceGroupId", externalDimensionalPriceGroupId), + checkRequired("metadata", metadata), + checkRequired("name", name), + additionalProperties.toImmutable(), + ) + } + + /** + * 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`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DimensionalPriceGroupModel && id == other.id && billableMetricId == other.billableMetricId && dimensions == other.dimensions && externalDimensionalPriceGroupId == other.externalDimensionalPriceGroupId && metadata == other.metadata && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billableMetricId, dimensions, externalDimensionalPriceGroupId, metadata, name, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DimensionalPriceGroupModel{id=$id, billableMetricId=$billableMetricId, dimensions=$dimensions, externalDimensionalPriceGroupId=$externalDimensionalPriceGroupId, metadata=$metadata, name=$name, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupRetrieveParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupRetrieveParams.kt index 89a6445cc..2d48fc301 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupRetrieveParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupRetrieveParams.kt @@ -38,6 +38,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [DimensionalPriceGroupRetrieveParams]. + * + * The following fields are required: + * ```java + * .dimensionalPriceGroupId() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 311c7eb53..cc88b5b3a 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 @@ -11,6 +11,7 @@ import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.immutableEmptyMap import com.withorb.api.core.toImmutable @@ -22,19 +23,21 @@ class DimensionalPriceGroups private constructor( @JsonProperty("data") @ExcludeMissing - private val data: JsonField> = JsonMissing.of(), + private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") @ExcludeMissing private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = data.getRequired("data") + fun data(): List = data.getRequired("data") fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data + @JsonProperty("data") + @ExcludeMissing + fun _data(): JsonField> = data @JsonProperty("pagination_metadata") @ExcludeMissing @@ -60,13 +63,22 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [DimensionalPriceGroups]. + * + * The following fields are required: + * ```java + * .data() + * .paginationMetadata() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [DimensionalPriceGroups]. */ class Builder internal constructor() { - private var data: JsonField>? = null + private var data: JsonField>? = null private var paginationMetadata: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -77,22 +89,16 @@ private constructor( additionalProperties = dimensionalPriceGroups.additionalProperties.toMutableMap() } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { + fun data(data: JsonField>) = apply { this.data = data.map { it.toMutableList() } } - fun addData(data: DimensionalPriceGroup) = apply { + fun addData(data: DimensionalPriceGroupModel) = apply { this.data = - (this.data ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(data) + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) } } 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 0ea093d98..d8a772e29 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 @@ -21,6 +21,7 @@ import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.getOrThrow import com.withorb.api.core.immutableEmptyMap @@ -300,6 +301,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [UsageDiscount]. + * + * The following fields are required: + * ```java + * .appliesToPriceIds() + * .discountType() + * .usageDiscount() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -342,14 +353,8 @@ private constructor( */ fun addAppliesToPriceId(appliesToPriceId: String) = apply { appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/DiscountModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DiscountModel.kt new file mode 100644 index 000000000..b7fd86285 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DiscountModel.kt @@ -0,0 +1,539 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.BaseDeserializer +import com.withorb.api.core.BaseSerializer +import com.withorb.api.core.Enum +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.getOrThrow +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +@JsonDeserialize(using = DiscountModel.Deserializer::class) +@JsonSerialize(using = DiscountModel.Serializer::class) +class DiscountModel +private constructor( + private val percentageDiscount: PercentageDiscount? = null, + private val trialDiscount: TrialDiscount? = null, + private val usageDiscount: UsageDiscount? = null, + private val amountDiscount: AmountDiscount? = null, + private val _json: JsonValue? = null, +) { + + fun percentageDiscount(): Optional = Optional.ofNullable(percentageDiscount) + + fun trialDiscount(): Optional = Optional.ofNullable(trialDiscount) + + fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) + + fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) + + fun isPercentageDiscount(): Boolean = percentageDiscount != null + + fun isTrialDiscount(): Boolean = trialDiscount != null + + fun isUsageDiscount(): Boolean = usageDiscount != null + + fun isAmountDiscount(): Boolean = amountDiscount != null + + fun asPercentageDiscount(): PercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") + + fun asTrialDiscount(): TrialDiscount = trialDiscount.getOrThrow("trialDiscount") + + fun asUsageDiscount(): UsageDiscount = usageDiscount.getOrThrow("usageDiscount") + + fun asAmountDiscount(): AmountDiscount = amountDiscount.getOrThrow("amountDiscount") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + percentageDiscount != null -> visitor.visitPercentageDiscount(percentageDiscount) + trialDiscount != null -> visitor.visitTrialDiscount(trialDiscount) + usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) + else -> visitor.unknown(_json) + } + } + + private var validated: Boolean = false + + fun validate(): DiscountModel = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitPercentageDiscount(percentageDiscount: PercentageDiscount) { + percentageDiscount.validate() + } + + override fun visitTrialDiscount(trialDiscount: TrialDiscount) { + trialDiscount.validate() + } + + override fun visitUsageDiscount(usageDiscount: UsageDiscount) { + usageDiscount.validate() + } + + override fun visitAmountDiscount(amountDiscount: AmountDiscount) { + amountDiscount.validate() + } + } + ) + validated = true + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountModel && percentageDiscount == other.percentageDiscount && trialDiscount == other.trialDiscount && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(percentageDiscount, trialDiscount, usageDiscount, amountDiscount) /* spotless:on */ + + override fun toString(): String = + when { + percentageDiscount != null -> "DiscountModel{percentageDiscount=$percentageDiscount}" + trialDiscount != null -> "DiscountModel{trialDiscount=$trialDiscount}" + usageDiscount != null -> "DiscountModel{usageDiscount=$usageDiscount}" + amountDiscount != null -> "DiscountModel{amountDiscount=$amountDiscount}" + _json != null -> "DiscountModel{_unknown=$_json}" + else -> throw IllegalStateException("Invalid DiscountModel") + } + + companion object { + + @JvmStatic + fun ofPercentageDiscount(percentageDiscount: PercentageDiscount) = + DiscountModel(percentageDiscount = percentageDiscount) + + @JvmStatic + fun ofTrialDiscount(trialDiscount: TrialDiscount) = + DiscountModel(trialDiscount = trialDiscount) + + @JvmStatic + fun ofUsageDiscount(usageDiscount: UsageDiscount) = + DiscountModel(usageDiscount = usageDiscount) + + @JvmStatic + fun ofAmountDiscount(amountDiscount: AmountDiscount) = + DiscountModel(amountDiscount = amountDiscount) + } + + /** + * An interface that defines how to map each variant of [DiscountModel] to a value of type [T]. + */ + interface Visitor { + + fun visitPercentageDiscount(percentageDiscount: PercentageDiscount): T + + fun visitTrialDiscount(trialDiscount: TrialDiscount): T + + fun visitUsageDiscount(usageDiscount: UsageDiscount): T + + fun visitAmountDiscount(amountDiscount: AmountDiscount): T + + /** + * Maps an unknown variant of [DiscountModel] to a value of type [T]. + * + * An instance of [DiscountModel] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown DiscountModel: $json") + } + } + + internal class Deserializer : BaseDeserializer(DiscountModel::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): DiscountModel { + val json = JsonValue.fromJsonNode(node) + val discountType = + json.asObject().getOrNull()?.get("discount_type")?.asString()?.getOrNull() + + when (discountType) { + "percentage" -> { + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return DiscountModel(percentageDiscount = it, _json = json) + } + } + "trial" -> { + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return DiscountModel(trialDiscount = it, _json = json) + } + } + "usage" -> { + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return DiscountModel(usageDiscount = it, _json = json) + } + } + "amount" -> { + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return DiscountModel(amountDiscount = it, _json = json) + } + } + } + + return DiscountModel(_json = json) + } + } + + internal class Serializer : BaseSerializer(DiscountModel::class) { + + override fun serialize( + value: DiscountModel, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.percentageDiscount != null -> generator.writeObject(value.percentageDiscount) + value.trialDiscount != null -> generator.writeObject(value.trialDiscount) + value.usageDiscount != null -> generator.writeObject(value.usageDiscount) + value.amountDiscount != null -> generator.writeObject(value.amountDiscount) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid DiscountModel") + } + } + } + + @NoAutoDetect + class UsageDiscount + @JsonCreator + private constructor( + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("discount_type") + @ExcludeMissing + private val discountType: JsonField = JsonMissing.of(), + @JsonProperty("usage_discount") + @ExcludeMissing + private val usageDiscount: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + private val reason: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** + * List of price_ids that this discount applies to. For plan/plan phase discounts, this can + * be a subset of prices. + */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + fun discountType(): DiscountType = discountType.getRequired("discount_type") + + /** + * Only available if discount_type is `usage`. Number of usage units that this discount is + * for + */ + fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") + + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + /** + * List of price_ids that this discount applies to. For plan/plan phase discounts, this can + * be a subset of prices. + */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType + + /** + * Only available if discount_type is `usage`. Number of usage units that this discount is + * for + */ + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount + + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): UsageDiscount = apply { + if (validated) { + return@apply + } + + appliesToPriceIds() + discountType() + usageDiscount() + reason() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UsageDiscount]. + * + * The following fields are required: + * ```java + * .appliesToPriceIds() + * .discountType() + * .usageDiscount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UsageDiscount]. */ + class Builder internal constructor() { + + private var appliesToPriceIds: JsonField>? = null + private var discountType: JsonField? = null + private var usageDiscount: JsonField? = null + private var reason: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(usageDiscount: UsageDiscount) = apply { + appliesToPriceIds = usageDiscount.appliesToPriceIds.map { it.toMutableList() } + discountType = usageDiscount.discountType + this.usageDiscount = usageDiscount.usageDiscount + reason = usageDiscount.reason + additionalProperties = usageDiscount.additionalProperties.toMutableMap() + } + + /** + * List of price_ids that this discount applies to. For plan/plan phase discounts, this + * can be a subset of prices. + */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** + * List of price_ids that this discount applies to. For plan/plan phase discounts, this + * can be a subset of prices. + */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this discount applies to. For plan/plan phase discounts, this + * can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) + + fun discountType(discountType: JsonField) = apply { + this.discountType = discountType + } + + /** + * Only available if discount_type is `usage`. Number of usage units that this discount + * is for + */ + fun usageDiscount(usageDiscount: Double) = usageDiscount(JsonField.of(usageDiscount)) + + /** + * Only available if discount_type is `usage`. Number of usage units that this discount + * is for + */ + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount + } + + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + fun reason(reason: Optional) = reason(reason.orElse(null)) + + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): UsageDiscount = + UsageDiscount( + checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, + checkRequired("discountType", discountType), + checkRequired("usageDiscount", usageDiscount), + reason, + additionalProperties.toImmutable(), + ) + } + + class DiscountType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE = of("usage") + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + /** An enum containing [DiscountType]'s known values. */ + enum class Known { + USAGE + } + + /** + * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [DiscountType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE, + /** + * An enum member indicating that [DiscountType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE -> Value.USAGE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE -> Known.USAGE + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is UsageDiscount && appliesToPriceIds == other.appliesToPriceIds && discountType == other.discountType && usageDiscount == other.usageDiscount && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, discountType, usageDiscount, reason, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UsageDiscount{appliesToPriceIds=$appliesToPriceIds, discountType=$discountType, usageDiscount=$usageDiscount, reason=$reason, additionalProperties=$additionalProperties}" + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/DiscountOverrideModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DiscountOverrideModel.kt new file mode 100644 index 000000000..3dbedf036 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DiscountOverrideModel.kt @@ -0,0 +1,346 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class DiscountOverrideModel +@JsonCreator +private constructor( + @JsonProperty("discount_type") + @ExcludeMissing + private val discountType: JsonField = JsonMissing.of(), + @JsonProperty("amount_discount") + @ExcludeMissing + private val amountDiscount: JsonField = JsonMissing.of(), + @JsonProperty("percentage_discount") + @ExcludeMissing + private val percentageDiscount: JsonField = JsonMissing.of(), + @JsonProperty("usage_discount") + @ExcludeMissing + private val usageDiscount: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun discountType(): DiscountType = discountType.getRequired("discount_type") + + /** Only available if discount_type is `amount`. */ + fun amountDiscount(): Optional = + Optional.ofNullable(amountDiscount.getNullable("amount_discount")) + + /** Only available if discount_type is `percentage`. This is a number between 0 and 1. */ + fun percentageDiscount(): Optional = + Optional.ofNullable(percentageDiscount.getNullable("percentage_discount")) + + /** + * Only available if discount_type is `usage`. Number of usage units that this discount is for + */ + fun usageDiscount(): Optional = + Optional.ofNullable(usageDiscount.getNullable("usage_discount")) + + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType + + /** Only available if discount_type is `amount`. */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount(): JsonField = amountDiscount + + /** Only available if discount_type is `percentage`. This is a number between 0 and 1. */ + @JsonProperty("percentage_discount") + @ExcludeMissing + fun _percentageDiscount(): JsonField = percentageDiscount + + /** + * Only available if discount_type is `usage`. Number of usage units that this discount is for + */ + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): DiscountOverrideModel = apply { + if (validated) { + return@apply + } + + discountType() + amountDiscount() + percentageDiscount() + usageDiscount() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DiscountOverrideModel]. + * + * The following fields are required: + * ```java + * .discountType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DiscountOverrideModel]. */ + class Builder internal constructor() { + + private var discountType: JsonField? = null + private var amountDiscount: JsonField = JsonMissing.of() + private var percentageDiscount: JsonField = JsonMissing.of() + private var usageDiscount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(discountOverrideModel: DiscountOverrideModel) = apply { + discountType = discountOverrideModel.discountType + amountDiscount = discountOverrideModel.amountDiscount + percentageDiscount = discountOverrideModel.percentageDiscount + usageDiscount = discountOverrideModel.usageDiscount + additionalProperties = discountOverrideModel.additionalProperties.toMutableMap() + } + + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) + + fun discountType(discountType: JsonField) = apply { + this.discountType = discountType + } + + /** Only available if discount_type is `amount`. */ + fun amountDiscount(amountDiscount: String?) = + amountDiscount(JsonField.ofNullable(amountDiscount)) + + /** Only available if discount_type is `amount`. */ + fun amountDiscount(amountDiscount: Optional) = + amountDiscount(amountDiscount.orElse(null)) + + /** Only available if discount_type is `amount`. */ + fun amountDiscount(amountDiscount: JsonField) = apply { + this.amountDiscount = amountDiscount + } + + /** Only available if discount_type is `percentage`. This is a number between 0 and 1. */ + fun percentageDiscount(percentageDiscount: Double?) = + percentageDiscount(JsonField.ofNullable(percentageDiscount)) + + /** Only available if discount_type is `percentage`. This is a number between 0 and 1. */ + fun percentageDiscount(percentageDiscount: Double) = + percentageDiscount(percentageDiscount as Double?) + + /** Only available if discount_type is `percentage`. This is a number between 0 and 1. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun percentageDiscount(percentageDiscount: Optional) = + percentageDiscount(percentageDiscount.orElse(null) as Double?) + + /** Only available if discount_type is `percentage`. This is a number between 0 and 1. */ + fun percentageDiscount(percentageDiscount: JsonField) = apply { + this.percentageDiscount = percentageDiscount + } + + /** + * Only available if discount_type is `usage`. Number of usage units that this discount is + * for + */ + fun usageDiscount(usageDiscount: Double?) = + usageDiscount(JsonField.ofNullable(usageDiscount)) + + /** + * Only available if discount_type is `usage`. Number of usage units that this discount is + * for + */ + fun usageDiscount(usageDiscount: Double) = usageDiscount(usageDiscount as Double?) + + /** + * Only available if discount_type is `usage`. Number of usage units that this discount is + * for + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun usageDiscount(usageDiscount: Optional) = + usageDiscount(usageDiscount.orElse(null) as Double?) + + /** + * Only available if discount_type is `usage`. Number of usage units that this discount is + * for + */ + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): DiscountOverrideModel = + DiscountOverrideModel( + checkRequired("discountType", discountType), + amountDiscount, + percentageDiscount, + usageDiscount, + additionalProperties.toImmutable(), + ) + } + + class DiscountType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PERCENTAGE = of("percentage") + + @JvmField val USAGE = of("usage") + + @JvmField val AMOUNT = of("amount") + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + /** An enum containing [DiscountType]'s known values. */ + enum class Known { + PERCENTAGE, + USAGE, + AMOUNT, + } + + /** + * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [DiscountType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PERCENTAGE, + USAGE, + AMOUNT, + /** + * An enum member indicating that [DiscountType] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PERCENTAGE -> Value.PERCENTAGE + USAGE -> Value.USAGE + AMOUNT -> Value.AMOUNT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + PERCENTAGE -> Known.PERCENTAGE + USAGE -> Known.USAGE + AMOUNT -> Known.AMOUNT + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountOverrideModel && discountType == other.discountType && amountDiscount == other.amountDiscount && percentageDiscount == other.percentageDiscount && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(discountType, amountDiscount, percentageDiscount, usageDiscount, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DiscountOverrideModel{discountType=$discountType, amountDiscount=$amountDiscount, percentageDiscount=$percentageDiscount, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EditCustomerModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EditCustomerModel.kt new file mode 100644 index 000000000..b2862a768 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EditCustomerModel.kt @@ -0,0 +1,1452 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class EditCustomerModel +@JsonCreator +private constructor( + @JsonProperty("accounting_sync_configuration") + @ExcludeMissing + private val accountingSyncConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("additional_emails") + @ExcludeMissing + private val additionalEmails: JsonField> = JsonMissing.of(), + @JsonProperty("auto_collection") + @ExcludeMissing + private val autoCollection: JsonField = JsonMissing.of(), + @JsonProperty("billing_address") + @ExcludeMissing + private val billingAddress: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("email") @ExcludeMissing private val email: JsonField = JsonMissing.of(), + @JsonProperty("email_delivery") + @ExcludeMissing + private val emailDelivery: JsonField = JsonMissing.of(), + @JsonProperty("external_customer_id") + @ExcludeMissing + private val externalCustomerId: JsonField = JsonMissing.of(), + @JsonProperty("hierarchy") + @ExcludeMissing + private val hierarchy: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("payment_provider") + @ExcludeMissing + private val paymentProvider: JsonField = JsonMissing.of(), + @JsonProperty("payment_provider_id") + @ExcludeMissing + private val paymentProviderId: JsonField = JsonMissing.of(), + @JsonProperty("reporting_configuration") + @ExcludeMissing + private val reportingConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("shipping_address") + @ExcludeMissing + private val shippingAddress: JsonField = JsonMissing.of(), + @JsonProperty("tax_configuration") + @ExcludeMissing + private val taxConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("tax_id") + @ExcludeMissing + private val taxId: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun accountingSyncConfiguration(): Optional = + Optional.ofNullable( + accountingSyncConfiguration.getNullable("accounting_sync_configuration") + ) + + /** + * Additional email addresses for this customer. If populated, these email addresses will be + * CC'd for customer communications. + */ + fun additionalEmails(): Optional> = + Optional.ofNullable(additionalEmails.getNullable("additional_emails")) + + /** + * Used to determine if invoices for this customer will automatically attempt to charge a saved + * payment method, if available. This parameter defaults to `True` when a payment provider is + * provided on customer creation. + */ + fun autoCollection(): Optional = + Optional.ofNullable(autoCollection.getNullable("auto_collection")) + + fun billingAddress(): Optional = + Optional.ofNullable(billingAddress.getNullable("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. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** A valid customer email, to be used for invoicing and notifications. */ + fun email(): Optional = Optional.ofNullable(email.getNullable("email")) + + fun emailDelivery(): Optional = + Optional.ofNullable(emailDelivery.getNullable("email_delivery")) + + /** + * The external customer ID. This can only be set if empty and the customer has no past or + * current subscriptions. + */ + fun externalCustomerId(): Optional = + Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) + + /** The hierarchical relationships for this customer. */ + fun hierarchy(): Optional = + Optional.ofNullable(hierarchy.getNullable("hierarchy")) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by setting + * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to + * `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The full name of the customer */ + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + /** + * This is used for creating charges or invoices in an external system via Orb. When not in test + * mode: + * - the connection must first be configured in the Orb webapp. + * - if the provider is an invoicing provider (`stripe_invoice`, `quickbooks`, `bill.com`, + * `netsuite`), any product mappings must first be configured with the Orb team. + */ + fun paymentProvider(): Optional = + Optional.ofNullable(paymentProvider.getNullable("payment_provider")) + + /** + * The ID of this customer in an external payments solution, such as Stripe. This is used for + * creating charges or invoices in the external system via Orb. + */ + fun paymentProviderId(): Optional = + Optional.ofNullable(paymentProviderId.getNullable("payment_provider_id")) + + fun reportingConfiguration(): Optional = + Optional.ofNullable(reportingConfiguration.getNullable("reporting_configuration")) + + fun shippingAddress(): Optional = + Optional.ofNullable(shippingAddress.getNullable("shipping_address")) + + fun taxConfiguration(): Optional = + Optional.ofNullable(taxConfiguration.getNullable("tax_configuration")) + + /** + * 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 | + * |--------------------|------------|-------------------------------------------------------------------------------------------------------| + * |Andorra |`ad_nrt` |Andorran NRT Number | + * |Argentina |`ar_cuit` |Argentinian Tax ID Number | + * |Australia |`au_abn` |Australian Business Number (AU ABN) | + * |Australia |`au_arn` |Australian Taxation Office Reference Number | + * |Austria |`eu_vat` |European VAT Number | + * |Bahrain |`bh_vat` |Bahraini VAT Number | + * |Belgium |`eu_vat` |European VAT Number | + * |Bolivia |`bo_tin` |Bolivian Tax ID | + * |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 | + * |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) | + * |Chile |`cl_tin` |Chilean TIN | + * |China |`cn_tin` |Chinese Tax ID | + * |Colombia |`co_nit` |Colombian NIT Number | + * |Costa Rica |`cr_tin` |Costa Rican Tax ID | + * |Croatia |`eu_vat` |European VAT Number | + * |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 | + * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Finland |`eu_vat` |European VAT Number | + * |France |`eu_vat` |European VAT Number | + * |Georgia |`ge_vat` |Georgian VAT | + * |Germany |`eu_vat` |European VAT Number | + * |Greece |`eu_vat` |European VAT Number | + * |Hong Kong |`hk_br` |Hong Kong BR Number | + * |Hungary |`eu_vat` |European VAT Number | + * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | + * |Iceland |`is_vat` |Icelandic VAT | + * |India |`in_gst` |Indian GST Number | + * |Indonesia |`id_npwp` |Indonesian NPWP Number | + * |Ireland |`eu_vat` |European VAT Number | + * |Israel |`il_vat` |Israel VAT | + * |Italy |`eu_vat` |European VAT Number | + * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | + * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | + * |Latvia |`eu_vat` |European VAT Number | + * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | + * |Mexico |`mx_rfc` |Mexican RFC Number | + * |Netherlands |`eu_vat` |European VAT Number | + * |New Zealand |`nz_gst` |New Zealand GST Number | + * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | + * |Norway |`no_vat` |Norwegian VAT Number | + * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | + * |Oman |`om_vat` |Omani VAT Number | + * |Peru |`pe_ruc` |Peruvian RUC Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Poland |`eu_vat` |European VAT Number | + * |Portugal |`eu_vat` |European VAT Number | + * |Romania |`eu_vat` |European VAT Number | + * |Romania |`ro_tin` |Romanian Tax ID Number | + * |Russia |`ru_inn` |Russian INN | + * |Russia |`ru_kpp` |Russian KPP | + * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | + * |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 | + * |Sweden |`eu_vat` |European VAT Number | + * |Switzerland |`ch_vat` |Switzerland VAT Number | + * |Taiwan |`tw_vat` |Taiwanese VAT | + * |Thailand |`th_vat` |Thai VAT | + * |Turkey |`tr_tin` |Turkish Tax Identification Number | + * |Ukraine |`ua_vat` |Ukrainian VAT | + * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | + * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | + * |United Kingdom |`gb_vat` |United Kingdom VAT Number | + * |United States |`us_ein` |United States EIN | + * |Uruguay |`uy_ruc` |Uruguayan RUC Number | + * |Venezuela |`ve_rif` |Venezuelan RIF Number | + * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + */ + fun taxId(): Optional = Optional.ofNullable(taxId.getNullable("tax_id")) + + @JsonProperty("accounting_sync_configuration") + @ExcludeMissing + fun _accountingSyncConfiguration(): JsonField = + accountingSyncConfiguration + + /** + * Additional email addresses for this customer. If populated, these email addresses will be + * CC'd for customer communications. + */ + @JsonProperty("additional_emails") + @ExcludeMissing + fun _additionalEmails(): JsonField> = additionalEmails + + /** + * Used to determine if invoices for this customer will automatically attempt to charge a saved + * payment method, if available. This parameter defaults to `True` when a payment provider is + * provided on customer creation. + */ + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection + + @JsonProperty("billing_address") + @ExcludeMissing + fun _billingAddress(): JsonField = 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. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** A valid customer email, to be used for invoicing and notifications. */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email + + @JsonProperty("email_delivery") + @ExcludeMissing + fun _emailDelivery(): JsonField = emailDelivery + + /** + * The external customer ID. This can only be set if empty and the customer has no past or + * current subscriptions. + */ + @JsonProperty("external_customer_id") + @ExcludeMissing + fun _externalCustomerId(): JsonField = externalCustomerId + + /** The hierarchical relationships for this customer. */ + @JsonProperty("hierarchy") + @ExcludeMissing + fun _hierarchy(): JsonField = hierarchy + + /** + * User-specified key/value pairs for the resource. 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** The full name of the customer */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * This is used for creating charges or invoices in an external system via Orb. When not in test + * mode: + * - the connection must first be configured in the Orb webapp. + * - if the provider is an invoicing provider (`stripe_invoice`, `quickbooks`, `bill.com`, + * `netsuite`), any product mappings must first be configured with the Orb team. + */ + @JsonProperty("payment_provider") + @ExcludeMissing + fun _paymentProvider(): JsonField = paymentProvider + + /** + * The ID of this customer in an external payments solution, such as Stripe. This is used for + * creating charges or invoices in the external system via Orb. + */ + @JsonProperty("payment_provider_id") + @ExcludeMissing + fun _paymentProviderId(): JsonField = paymentProviderId + + @JsonProperty("reporting_configuration") + @ExcludeMissing + fun _reportingConfiguration(): JsonField = + reportingConfiguration + + @JsonProperty("shipping_address") + @ExcludeMissing + fun _shippingAddress(): JsonField = shippingAddress + + @JsonProperty("tax_configuration") + @ExcludeMissing + fun _taxConfiguration(): JsonField = taxConfiguration + + /** + * 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 | + * |--------------------|------------|-------------------------------------------------------------------------------------------------------| + * |Andorra |`ad_nrt` |Andorran NRT Number | + * |Argentina |`ar_cuit` |Argentinian Tax ID Number | + * |Australia |`au_abn` |Australian Business Number (AU ABN) | + * |Australia |`au_arn` |Australian Taxation Office Reference Number | + * |Austria |`eu_vat` |European VAT Number | + * |Bahrain |`bh_vat` |Bahraini VAT Number | + * |Belgium |`eu_vat` |European VAT Number | + * |Bolivia |`bo_tin` |Bolivian Tax ID | + * |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 | + * |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) | + * |Chile |`cl_tin` |Chilean TIN | + * |China |`cn_tin` |Chinese Tax ID | + * |Colombia |`co_nit` |Colombian NIT Number | + * |Costa Rica |`cr_tin` |Costa Rican Tax ID | + * |Croatia |`eu_vat` |European VAT Number | + * |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 | + * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Finland |`eu_vat` |European VAT Number | + * |France |`eu_vat` |European VAT Number | + * |Georgia |`ge_vat` |Georgian VAT | + * |Germany |`eu_vat` |European VAT Number | + * |Greece |`eu_vat` |European VAT Number | + * |Hong Kong |`hk_br` |Hong Kong BR Number | + * |Hungary |`eu_vat` |European VAT Number | + * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | + * |Iceland |`is_vat` |Icelandic VAT | + * |India |`in_gst` |Indian GST Number | + * |Indonesia |`id_npwp` |Indonesian NPWP Number | + * |Ireland |`eu_vat` |European VAT Number | + * |Israel |`il_vat` |Israel VAT | + * |Italy |`eu_vat` |European VAT Number | + * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | + * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | + * |Latvia |`eu_vat` |European VAT Number | + * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | + * |Mexico |`mx_rfc` |Mexican RFC Number | + * |Netherlands |`eu_vat` |European VAT Number | + * |New Zealand |`nz_gst` |New Zealand GST Number | + * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | + * |Norway |`no_vat` |Norwegian VAT Number | + * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | + * |Oman |`om_vat` |Omani VAT Number | + * |Peru |`pe_ruc` |Peruvian RUC Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Poland |`eu_vat` |European VAT Number | + * |Portugal |`eu_vat` |European VAT Number | + * |Romania |`eu_vat` |European VAT Number | + * |Romania |`ro_tin` |Romanian Tax ID Number | + * |Russia |`ru_inn` |Russian INN | + * |Russia |`ru_kpp` |Russian KPP | + * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | + * |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 | + * |Sweden |`eu_vat` |European VAT Number | + * |Switzerland |`ch_vat` |Switzerland VAT Number | + * |Taiwan |`tw_vat` |Taiwanese VAT | + * |Thailand |`th_vat` |Thai VAT | + * |Turkey |`tr_tin` |Turkish Tax Identification Number | + * |Ukraine |`ua_vat` |Ukrainian VAT | + * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | + * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | + * |United Kingdom |`gb_vat` |United Kingdom VAT Number | + * |United States |`us_ein` |United States EIN | + * |Uruguay |`uy_ruc` |Uruguayan RUC Number | + * |Venezuela |`ve_rif` |Venezuelan RIF Number | + * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + */ + @JsonProperty("tax_id") @ExcludeMissing fun _taxId(): JsonField = taxId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): EditCustomerModel = apply { + if (validated) { + return@apply + } + + accountingSyncConfiguration().ifPresent { it.validate() } + additionalEmails() + autoCollection() + billingAddress().ifPresent { it.validate() } + currency() + email() + emailDelivery() + externalCustomerId() + hierarchy().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + name() + paymentProvider() + paymentProviderId() + reportingConfiguration().ifPresent { it.validate() } + shippingAddress().ifPresent { it.validate() } + taxConfiguration().ifPresent { it.validate() } + taxId().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [EditCustomerModel]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EditCustomerModel]. */ + class Builder internal constructor() { + + private var accountingSyncConfiguration: JsonField = + JsonMissing.of() + private var additionalEmails: JsonField>? = null + private var autoCollection: JsonField = JsonMissing.of() + private var billingAddress: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var email: JsonField = JsonMissing.of() + private var emailDelivery: JsonField = JsonMissing.of() + private var externalCustomerId: JsonField = JsonMissing.of() + private var hierarchy: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var paymentProvider: JsonField = JsonMissing.of() + private var paymentProviderId: JsonField = JsonMissing.of() + private var reportingConfiguration: JsonField = + JsonMissing.of() + private var shippingAddress: JsonField = JsonMissing.of() + private var taxConfiguration: JsonField = JsonMissing.of() + private var taxId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(editCustomerModel: EditCustomerModel) = apply { + accountingSyncConfiguration = editCustomerModel.accountingSyncConfiguration + additionalEmails = editCustomerModel.additionalEmails.map { it.toMutableList() } + autoCollection = editCustomerModel.autoCollection + billingAddress = editCustomerModel.billingAddress + currency = editCustomerModel.currency + email = editCustomerModel.email + emailDelivery = editCustomerModel.emailDelivery + externalCustomerId = editCustomerModel.externalCustomerId + hierarchy = editCustomerModel.hierarchy + metadata = editCustomerModel.metadata + name = editCustomerModel.name + paymentProvider = editCustomerModel.paymentProvider + paymentProviderId = editCustomerModel.paymentProviderId + reportingConfiguration = editCustomerModel.reportingConfiguration + shippingAddress = editCustomerModel.shippingAddress + taxConfiguration = editCustomerModel.taxConfiguration + taxId = editCustomerModel.taxId + additionalProperties = editCustomerModel.additionalProperties.toMutableMap() + } + + fun accountingSyncConfiguration( + accountingSyncConfiguration: NewAccountingSyncConfigurationModel? + ) = accountingSyncConfiguration(JsonField.ofNullable(accountingSyncConfiguration)) + + fun accountingSyncConfiguration( + accountingSyncConfiguration: Optional + ) = accountingSyncConfiguration(accountingSyncConfiguration.orElse(null)) + + fun accountingSyncConfiguration( + accountingSyncConfiguration: JsonField + ) = apply { this.accountingSyncConfiguration = accountingSyncConfiguration } + + /** + * Additional email addresses for this customer. If populated, these email addresses will be + * CC'd for customer communications. + */ + fun additionalEmails(additionalEmails: List?) = + additionalEmails(JsonField.ofNullable(additionalEmails)) + + /** + * Additional email addresses for this customer. If populated, these email addresses will be + * CC'd for customer communications. + */ + fun additionalEmails(additionalEmails: Optional>) = + additionalEmails(additionalEmails.orElse(null)) + + /** + * Additional email addresses for this customer. If populated, these email addresses will be + * CC'd for customer communications. + */ + fun additionalEmails(additionalEmails: JsonField>) = apply { + this.additionalEmails = additionalEmails.map { it.toMutableList() } + } + + /** + * Additional email addresses for this customer. If populated, these email addresses will be + * CC'd for customer communications. + */ + fun addAdditionalEmail(additionalEmail: String) = apply { + additionalEmails = + (additionalEmails ?: JsonField.of(mutableListOf())).also { + checkKnown("additionalEmails", it).add(additionalEmail) + } + } + + /** + * Used to determine if invoices for this customer will automatically attempt to charge a + * saved payment method, if available. This parameter defaults to `True` when a payment + * provider is provided on customer creation. + */ + fun autoCollection(autoCollection: Boolean?) = + autoCollection(JsonField.ofNullable(autoCollection)) + + /** + * Used to determine if invoices for this customer will automatically attempt to charge a + * saved payment method, if available. This parameter defaults to `True` when a payment + * provider is provided on customer creation. + */ + fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) + + /** + * Used to determine if invoices for this customer will automatically attempt to charge a + * saved payment method, if available. This parameter defaults to `True` when a payment + * provider is provided on customer creation. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun autoCollection(autoCollection: Optional) = + autoCollection(autoCollection.orElse(null) as Boolean?) + + /** + * Used to determine if invoices for this customer will automatically attempt to charge a + * saved payment method, if available. This parameter defaults to `True` when a payment + * provider is provided on customer creation. + */ + fun autoCollection(autoCollection: JsonField) = apply { + this.autoCollection = autoCollection + } + + fun billingAddress(billingAddress: AddressInputModel?) = + billingAddress(JsonField.ofNullable(billingAddress)) + + fun billingAddress(billingAddress: Optional) = + billingAddress(billingAddress.orElse(null)) + + fun billingAddress(billingAddress: JsonField) = apply { + this.billingAddress = 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. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** + * 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. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) + + /** + * 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. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** A valid customer email, to be used for invoicing and notifications. */ + fun email(email: String?) = email(JsonField.ofNullable(email)) + + /** A valid customer email, to be used for invoicing and notifications. */ + fun email(email: Optional) = email(email.orElse(null)) + + /** A valid customer email, to be used for invoicing and notifications. */ + fun email(email: JsonField) = apply { this.email = email } + + fun emailDelivery(emailDelivery: Boolean?) = + emailDelivery(JsonField.ofNullable(emailDelivery)) + + fun emailDelivery(emailDelivery: Boolean) = emailDelivery(emailDelivery as Boolean?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun emailDelivery(emailDelivery: Optional) = + emailDelivery(emailDelivery.orElse(null) as Boolean?) + + fun emailDelivery(emailDelivery: JsonField) = apply { + this.emailDelivery = emailDelivery + } + + /** + * The external customer ID. This can only be set if empty and the customer has no past or + * current subscriptions. + */ + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) + + /** + * The external customer ID. This can only be set if empty and the customer has no past or + * current subscriptions. + */ + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.orElse(null)) + + /** + * The external customer ID. This can only be set if empty and the customer has no past or + * current subscriptions. + */ + fun externalCustomerId(externalCustomerId: JsonField) = apply { + this.externalCustomerId = externalCustomerId + } + + /** The hierarchical relationships for this customer. */ + fun hierarchy(hierarchy: CustomerHierarchyConfigModel?) = + hierarchy(JsonField.ofNullable(hierarchy)) + + /** The hierarchical relationships for this customer. */ + fun hierarchy(hierarchy: Optional) = + hierarchy(hierarchy.orElse(null)) + + /** The hierarchical relationships for this customer. */ + fun hierarchy(hierarchy: JsonField) = apply { + this.hierarchy = hierarchy + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: JsonField) = apply { this.metadata = metadata } + + /** The full name of the customer */ + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** The full name of the customer */ + fun name(name: Optional) = name(name.orElse(null)) + + /** The full name of the customer */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * This is used for creating charges or invoices in an external system via Orb. When not in + * test mode: + * - the connection must first be configured in the Orb webapp. + * - if the provider is an invoicing provider (`stripe_invoice`, `quickbooks`, `bill.com`, + * `netsuite`), any product mappings must first be configured with the Orb team. + */ + fun paymentProvider(paymentProvider: PaymentProvider?) = + paymentProvider(JsonField.ofNullable(paymentProvider)) + + /** + * This is used for creating charges or invoices in an external system via Orb. When not in + * test mode: + * - the connection must first be configured in the Orb webapp. + * - if the provider is an invoicing provider (`stripe_invoice`, `quickbooks`, `bill.com`, + * `netsuite`), any product mappings must first be configured with the Orb team. + */ + fun paymentProvider(paymentProvider: Optional) = + paymentProvider(paymentProvider.orElse(null)) + + /** + * This is used for creating charges or invoices in an external system via Orb. When not in + * test mode: + * - the connection must first be configured in the Orb webapp. + * - if the provider is an invoicing provider (`stripe_invoice`, `quickbooks`, `bill.com`, + * `netsuite`), any product mappings must first be configured with the Orb team. + */ + fun paymentProvider(paymentProvider: JsonField) = apply { + this.paymentProvider = paymentProvider + } + + /** + * The ID of this customer in an external payments solution, such as Stripe. This is used + * for creating charges or invoices in the external system via Orb. + */ + fun paymentProviderId(paymentProviderId: String?) = + paymentProviderId(JsonField.ofNullable(paymentProviderId)) + + /** + * The ID of this customer in an external payments solution, such as Stripe. This is used + * for creating charges or invoices in the external system via Orb. + */ + fun paymentProviderId(paymentProviderId: Optional) = + paymentProviderId(paymentProviderId.orElse(null)) + + /** + * The ID of this customer in an external payments solution, such as Stripe. This is used + * for creating charges or invoices in the external system via Orb. + */ + fun paymentProviderId(paymentProviderId: JsonField) = apply { + this.paymentProviderId = paymentProviderId + } + + fun reportingConfiguration(reportingConfiguration: NewReportingConfigurationModel?) = + reportingConfiguration(JsonField.ofNullable(reportingConfiguration)) + + fun reportingConfiguration( + reportingConfiguration: Optional + ) = reportingConfiguration(reportingConfiguration.orElse(null)) + + fun reportingConfiguration( + reportingConfiguration: JsonField + ) = apply { this.reportingConfiguration = reportingConfiguration } + + fun shippingAddress(shippingAddress: AddressInputModel?) = + shippingAddress(JsonField.ofNullable(shippingAddress)) + + fun shippingAddress(shippingAddress: Optional) = + shippingAddress(shippingAddress.orElse(null)) + + fun shippingAddress(shippingAddress: JsonField) = apply { + this.shippingAddress = shippingAddress + } + + fun taxConfiguration(taxConfiguration: NewTaxConfigurationModel?) = + taxConfiguration(JsonField.ofNullable(taxConfiguration)) + + fun taxConfiguration(taxConfiguration: Optional) = + taxConfiguration(taxConfiguration.orElse(null)) + + fun taxConfiguration(taxConfiguration: JsonField) = apply { + this.taxConfiguration = taxConfiguration + } + + fun taxConfiguration( + avalaraTaxConfiguration: NewTaxConfigurationModel.NewAvalaraTaxConfiguration + ) = + taxConfiguration( + NewTaxConfigurationModel.ofAvalaraTaxConfiguration(avalaraTaxConfiguration) + ) + + fun avalaraTaxConfigurationTaxConfiguration(taxExempt: Boolean) = + taxConfiguration( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.builder() + .taxProvider( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.TaxProvider.AVALARA + ) + .taxExempt(taxExempt) + .build() + ) + + fun taxConfiguration(jarConfiguration: NewTaxConfigurationModel.NewTaxJarConfiguration) = + taxConfiguration(NewTaxConfigurationModel.ofJarConfiguration(jarConfiguration)) + + fun jarConfigurationTaxConfiguration(taxExempt: Boolean) = + taxConfiguration( + NewTaxConfigurationModel.NewTaxJarConfiguration.builder() + .taxProvider(NewTaxConfigurationModel.NewTaxJarConfiguration.TaxProvider.TAXJAR) + .taxExempt(taxExempt) + .build() + ) + + /** + * 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 | + * |--------------------|------------|-------------------------------------------------------------------------------------------------------| + * |Andorra |`ad_nrt` |Andorran NRT Number | + * |Argentina |`ar_cuit` |Argentinian Tax ID Number | + * |Australia |`au_abn` |Australian Business Number (AU ABN) | + * |Australia |`au_arn` |Australian Taxation Office Reference Number | + * |Austria |`eu_vat` |European VAT Number | + * |Bahrain |`bh_vat` |Bahraini VAT Number | + * |Belgium |`eu_vat` |European VAT Number | + * |Bolivia |`bo_tin` |Bolivian Tax ID | + * |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 | + * |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) | + * |Chile |`cl_tin` |Chilean TIN | + * |China |`cn_tin` |Chinese Tax ID | + * |Colombia |`co_nit` |Colombian NIT Number | + * |Costa Rica |`cr_tin` |Costa Rican Tax ID | + * |Croatia |`eu_vat` |European VAT Number | + * |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 | + * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Finland |`eu_vat` |European VAT Number | + * |France |`eu_vat` |European VAT Number | + * |Georgia |`ge_vat` |Georgian VAT | + * |Germany |`eu_vat` |European VAT Number | + * |Greece |`eu_vat` |European VAT Number | + * |Hong Kong |`hk_br` |Hong Kong BR Number | + * |Hungary |`eu_vat` |European VAT Number | + * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | + * |Iceland |`is_vat` |Icelandic VAT | + * |India |`in_gst` |Indian GST Number | + * |Indonesia |`id_npwp` |Indonesian NPWP Number | + * |Ireland |`eu_vat` |European VAT Number | + * |Israel |`il_vat` |Israel VAT | + * |Italy |`eu_vat` |European VAT Number | + * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | + * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | + * |Latvia |`eu_vat` |European VAT Number | + * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | + * |Mexico |`mx_rfc` |Mexican RFC Number | + * |Netherlands |`eu_vat` |European VAT Number | + * |New Zealand |`nz_gst` |New Zealand GST Number | + * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | + * |Norway |`no_vat` |Norwegian VAT Number | + * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | + * |Oman |`om_vat` |Omani VAT Number | + * |Peru |`pe_ruc` |Peruvian RUC Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Poland |`eu_vat` |European VAT Number | + * |Portugal |`eu_vat` |European VAT Number | + * |Romania |`eu_vat` |European VAT Number | + * |Romania |`ro_tin` |Romanian Tax ID Number | + * |Russia |`ru_inn` |Russian INN | + * |Russia |`ru_kpp` |Russian KPP | + * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | + * |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 | + * |Sweden |`eu_vat` |European VAT Number | + * |Switzerland |`ch_vat` |Switzerland VAT Number | + * |Taiwan |`tw_vat` |Taiwanese VAT | + * |Thailand |`th_vat` |Thai VAT | + * |Turkey |`tr_tin` |Turkish Tax Identification Number | + * |Ukraine |`ua_vat` |Ukrainian VAT | + * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | + * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | + * |United Kingdom |`gb_vat` |United Kingdom VAT Number | + * |United States |`us_ein` |United States EIN | + * |Uruguay |`uy_ruc` |Uruguayan RUC Number | + * |Venezuela |`ve_rif` |Venezuelan RIF Number | + * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + */ + fun taxId(taxId: CustomerTaxIdModel?) = taxId(JsonField.ofNullable(taxId)) + + /** + * 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 | + * |--------------------|------------|-------------------------------------------------------------------------------------------------------| + * |Andorra |`ad_nrt` |Andorran NRT Number | + * |Argentina |`ar_cuit` |Argentinian Tax ID Number | + * |Australia |`au_abn` |Australian Business Number (AU ABN) | + * |Australia |`au_arn` |Australian Taxation Office Reference Number | + * |Austria |`eu_vat` |European VAT Number | + * |Bahrain |`bh_vat` |Bahraini VAT Number | + * |Belgium |`eu_vat` |European VAT Number | + * |Bolivia |`bo_tin` |Bolivian Tax ID | + * |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 | + * |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) | + * |Chile |`cl_tin` |Chilean TIN | + * |China |`cn_tin` |Chinese Tax ID | + * |Colombia |`co_nit` |Colombian NIT Number | + * |Costa Rica |`cr_tin` |Costa Rican Tax ID | + * |Croatia |`eu_vat` |European VAT Number | + * |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 | + * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Finland |`eu_vat` |European VAT Number | + * |France |`eu_vat` |European VAT Number | + * |Georgia |`ge_vat` |Georgian VAT | + * |Germany |`eu_vat` |European VAT Number | + * |Greece |`eu_vat` |European VAT Number | + * |Hong Kong |`hk_br` |Hong Kong BR Number | + * |Hungary |`eu_vat` |European VAT Number | + * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | + * |Iceland |`is_vat` |Icelandic VAT | + * |India |`in_gst` |Indian GST Number | + * |Indonesia |`id_npwp` |Indonesian NPWP Number | + * |Ireland |`eu_vat` |European VAT Number | + * |Israel |`il_vat` |Israel VAT | + * |Italy |`eu_vat` |European VAT Number | + * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | + * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | + * |Latvia |`eu_vat` |European VAT Number | + * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | + * |Mexico |`mx_rfc` |Mexican RFC Number | + * |Netherlands |`eu_vat` |European VAT Number | + * |New Zealand |`nz_gst` |New Zealand GST Number | + * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | + * |Norway |`no_vat` |Norwegian VAT Number | + * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | + * |Oman |`om_vat` |Omani VAT Number | + * |Peru |`pe_ruc` |Peruvian RUC Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Poland |`eu_vat` |European VAT Number | + * |Portugal |`eu_vat` |European VAT Number | + * |Romania |`eu_vat` |European VAT Number | + * |Romania |`ro_tin` |Romanian Tax ID Number | + * |Russia |`ru_inn` |Russian INN | + * |Russia |`ru_kpp` |Russian KPP | + * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | + * |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 | + * |Sweden |`eu_vat` |European VAT Number | + * |Switzerland |`ch_vat` |Switzerland VAT Number | + * |Taiwan |`tw_vat` |Taiwanese VAT | + * |Thailand |`th_vat` |Thai VAT | + * |Turkey |`tr_tin` |Turkish Tax Identification Number | + * |Ukraine |`ua_vat` |Ukrainian VAT | + * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | + * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | + * |United Kingdom |`gb_vat` |United Kingdom VAT Number | + * |United States |`us_ein` |United States EIN | + * |Uruguay |`uy_ruc` |Uruguayan RUC Number | + * |Venezuela |`ve_rif` |Venezuelan RIF Number | + * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + */ + fun taxId(taxId: Optional) = taxId(taxId.orElse(null)) + + /** + * 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 | + * |--------------------|------------|-------------------------------------------------------------------------------------------------------| + * |Andorra |`ad_nrt` |Andorran NRT Number | + * |Argentina |`ar_cuit` |Argentinian Tax ID Number | + * |Australia |`au_abn` |Australian Business Number (AU ABN) | + * |Australia |`au_arn` |Australian Taxation Office Reference Number | + * |Austria |`eu_vat` |European VAT Number | + * |Bahrain |`bh_vat` |Bahraini VAT Number | + * |Belgium |`eu_vat` |European VAT Number | + * |Bolivia |`bo_tin` |Bolivian Tax ID | + * |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 | + * |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) | + * |Chile |`cl_tin` |Chilean TIN | + * |China |`cn_tin` |Chinese Tax ID | + * |Colombia |`co_nit` |Colombian NIT Number | + * |Costa Rica |`cr_tin` |Costa Rican Tax ID | + * |Croatia |`eu_vat` |European VAT Number | + * |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 | + * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Finland |`eu_vat` |European VAT Number | + * |France |`eu_vat` |European VAT Number | + * |Georgia |`ge_vat` |Georgian VAT | + * |Germany |`eu_vat` |European VAT Number | + * |Greece |`eu_vat` |European VAT Number | + * |Hong Kong |`hk_br` |Hong Kong BR Number | + * |Hungary |`eu_vat` |European VAT Number | + * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | + * |Iceland |`is_vat` |Icelandic VAT | + * |India |`in_gst` |Indian GST Number | + * |Indonesia |`id_npwp` |Indonesian NPWP Number | + * |Ireland |`eu_vat` |European VAT Number | + * |Israel |`il_vat` |Israel VAT | + * |Italy |`eu_vat` |European VAT Number | + * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | + * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | + * |Latvia |`eu_vat` |European VAT Number | + * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | + * |Mexico |`mx_rfc` |Mexican RFC Number | + * |Netherlands |`eu_vat` |European VAT Number | + * |New Zealand |`nz_gst` |New Zealand GST Number | + * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | + * |Norway |`no_vat` |Norwegian VAT Number | + * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | + * |Oman |`om_vat` |Omani VAT Number | + * |Peru |`pe_ruc` |Peruvian RUC Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Poland |`eu_vat` |European VAT Number | + * |Portugal |`eu_vat` |European VAT Number | + * |Romania |`eu_vat` |European VAT Number | + * |Romania |`ro_tin` |Romanian Tax ID Number | + * |Russia |`ru_inn` |Russian INN | + * |Russia |`ru_kpp` |Russian KPP | + * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | + * |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 | + * |Sweden |`eu_vat` |European VAT Number | + * |Switzerland |`ch_vat` |Switzerland VAT Number | + * |Taiwan |`tw_vat` |Taiwanese VAT | + * |Thailand |`th_vat` |Thai VAT | + * |Turkey |`tr_tin` |Turkish Tax Identification Number | + * |Ukraine |`ua_vat` |Ukrainian VAT | + * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | + * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | + * |United Kingdom |`gb_vat` |United Kingdom VAT Number | + * |United States |`us_ein` |United States EIN | + * |Uruguay |`uy_ruc` |Uruguayan RUC Number | + * |Venezuela |`ve_rif` |Venezuelan RIF Number | + * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + */ + fun taxId(taxId: JsonField) = apply { this.taxId = taxId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): EditCustomerModel = + EditCustomerModel( + accountingSyncConfiguration, + (additionalEmails ?: JsonMissing.of()).map { it.toImmutable() }, + autoCollection, + billingAddress, + currency, + email, + emailDelivery, + externalCustomerId, + hierarchy, + metadata, + name, + paymentProvider, + paymentProviderId, + reportingConfiguration, + shippingAddress, + taxConfiguration, + taxId, + additionalProperties.toImmutable(), + ) + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by setting + * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to + * `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + /** + * This is used for creating charges or invoices in an external system via Orb. When not in test + * mode: + * - the connection must first be configured in the Orb webapp. + * - if the provider is an invoicing provider (`stripe_invoice`, `quickbooks`, `bill.com`, + * `netsuite`), any product mappings must first be configured with the Orb team. + */ + 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 QUICKBOOKS = of("quickbooks") + + @JvmField val BILL_COM = of("bill.com") + + @JvmField val STRIPE_CHARGE = of("stripe_charge") + + @JvmField val STRIPE_INVOICE = of("stripe_invoice") + + @JvmField val NETSUITE = of("netsuite") + + @JvmStatic fun of(value: String) = PaymentProvider(JsonField.of(value)) + } + + /** An enum containing [PaymentProvider]'s known values. */ + enum class Known { + QUICKBOOKS, + BILL_COM, + STRIPE_CHARGE, + STRIPE_INVOICE, + NETSUITE, + } + + /** + * 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 { + QUICKBOOKS, + BILL_COM, + STRIPE_CHARGE, + STRIPE_INVOICE, + NETSUITE, + /** + * 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) { + QUICKBOOKS -> Value.QUICKBOOKS + BILL_COM -> Value.BILL_COM + STRIPE_CHARGE -> Value.STRIPE_CHARGE + STRIPE_INVOICE -> Value.STRIPE_INVOICE + 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 + BILL_COM -> Known.BILL_COM + STRIPE_CHARGE -> Known.STRIPE_CHARGE + STRIPE_INVOICE -> Known.STRIPE_INVOICE + NETSUITE -> Known.NETSUITE + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PaymentProvider && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is EditCustomerModel && accountingSyncConfiguration == other.accountingSyncConfiguration && additionalEmails == other.additionalEmails && autoCollection == other.autoCollection && billingAddress == other.billingAddress && currency == other.currency && email == other.email && emailDelivery == other.emailDelivery && externalCustomerId == other.externalCustomerId && hierarchy == other.hierarchy && metadata == other.metadata && name == other.name && paymentProvider == other.paymentProvider && paymentProviderId == other.paymentProviderId && reportingConfiguration == other.reportingConfiguration && shippingAddress == other.shippingAddress && taxConfiguration == other.taxConfiguration && taxId == other.taxId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(accountingSyncConfiguration, additionalEmails, autoCollection, billingAddress, currency, email, emailDelivery, externalCustomerId, hierarchy, metadata, name, paymentProvider, paymentProviderId, reportingConfiguration, shippingAddress, taxConfiguration, taxId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EditCustomerModel{accountingSyncConfiguration=$accountingSyncConfiguration, additionalEmails=$additionalEmails, autoCollection=$autoCollection, billingAddress=$billingAddress, currency=$currency, email=$email, emailDelivery=$emailDelivery, externalCustomerId=$externalCustomerId, hierarchy=$hierarchy, metadata=$metadata, name=$name, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, reportingConfiguration=$reportingConfiguration, shippingAddress=$shippingAddress, taxConfiguration=$taxConfiguration, taxId=$taxId, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EditPlanModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EditPlanModel.kt new file mode 100644 index 000000000..8389fe95e --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EditPlanModel.kt @@ -0,0 +1,268 @@ +// 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.NoAutoDetect +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class EditPlanModel +@JsonCreator +private constructor( + @JsonProperty("external_plan_id") + @ExcludeMissing + private val externalPlanId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** + * An optional user-defined ID for this plan resource, used throughout the system as an alias + * for this Plan. Use this field to identify a plan by an existing identifier in your system. + */ + fun externalPlanId(): Optional = + Optional.ofNullable(externalPlanId.getNullable("external_plan_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`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * 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. + */ + @JsonProperty("external_plan_id") + @ExcludeMissing + fun _externalPlanId(): JsonField = externalPlanId + + /** + * User-specified key/value pairs for the resource. 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): EditPlanModel = apply { + if (validated) { + return@apply + } + + externalPlanId() + metadata().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [EditPlanModel]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EditPlanModel]. */ + class Builder internal constructor() { + + private var externalPlanId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(editPlanModel: EditPlanModel) = apply { + externalPlanId = editPlanModel.externalPlanId + metadata = editPlanModel.metadata + additionalProperties = editPlanModel.additionalProperties.toMutableMap() + } + + /** + * An optional user-defined ID for this plan resource, used throughout the system as an + * alias for this Plan. Use this field to identify a plan by an existing identifier in your + * system. + */ + fun externalPlanId(externalPlanId: String?) = + externalPlanId(JsonField.ofNullable(externalPlanId)) + + /** + * An optional user-defined ID for this plan resource, used throughout the system as an + * alias for this Plan. Use this field to identify a plan by an existing identifier in your + * system. + */ + fun externalPlanId(externalPlanId: Optional) = + externalPlanId(externalPlanId.orElse(null)) + + /** + * An optional user-defined ID for this plan resource, used throughout the system as an + * alias for this Plan. Use this field to identify a plan by an existing identifier in your + * system. + */ + fun externalPlanId(externalPlanId: JsonField) = apply { + this.externalPlanId = externalPlanId + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) + } + + fun build(): EditPlanModel = + EditPlanModel(externalPlanId, metadata, additionalProperties.toImmutable()) + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by setting + * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to + * `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is EditPlanModel && externalPlanId == other.externalPlanId && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(externalPlanId, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EditPlanModel{externalPlanId=$externalPlanId, metadata=$metadata, additionalProperties=$additionalProperties}" +} 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 4324496d3..35be7f421 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 @@ -20,6 +20,7 @@ import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.getOrThrow import com.withorb.api.core.immutableEmptyMap @@ -85,6 +86,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [EvaluatePriceGroup]. + * + * The following fields are required: + * ```java + * .amount() + * .groupingValues() + * .quantity() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -122,14 +133,8 @@ private constructor( /** The values for the group in the order specified by `grouping_keys` */ fun addGroupingValue(groupingValue: GroupingValue) = apply { groupingValues = - (groupingValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(groupingValue) + (groupingValues ?: JsonField.of(mutableListOf())).also { + checkKnown("groupingValues", it).add(groupingValue) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseParams.kt index 76349e82d..2cf6717bb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseParams.kt @@ -52,6 +52,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [EventBackfillCloseParams]. + * + * The following fields are required: + * ```java + * .backfillId() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 deleted file mode 100644 index 8e882212c..000000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseResponse.kt +++ /dev/null @@ -1,516 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.withorb.api.core.Enum -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.checkRequired -import com.withorb.api.core.immutableEmptyMap -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional - -/** - * A backfill represents an update to historical usage data, adding or replacing events in a - * timeframe. - */ -@NoAutoDetect -class EventBackfillCloseResponse -@JsonCreator -private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("close_time") - @ExcludeMissing - private val closeTime: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("customer_id") - @ExcludeMissing - private val customerId: JsonField = JsonMissing.of(), - @JsonProperty("events_ingested") - @ExcludeMissing - private val eventsIngested: JsonField = JsonMissing.of(), - @JsonProperty("replace_existing_events") - @ExcludeMissing - private val replaceExistingEvents: JsonField = JsonMissing.of(), - @JsonProperty("reverted_at") - @ExcludeMissing - private val revertedAt: JsonField = JsonMissing.of(), - @JsonProperty("status") - @ExcludeMissing - private val status: JsonField = JsonMissing.of(), - @JsonProperty("timeframe_end") - @ExcludeMissing - private val timeframeEnd: JsonField = JsonMissing.of(), - @JsonProperty("timeframe_start") - @ExcludeMissing - private val timeframeStart: JsonField = JsonMissing.of(), - @JsonProperty("deprecation_filter") - @ExcludeMissing - private val deprecationFilter: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun id(): String = id.getRequired("id") - - /** - * If in the future, the time at which the backfill will automatically close. If in the past, - * the time at which the backfill was closed. - */ - fun closeTime(): Optional = - Optional.ofNullable(closeTime.getNullable("close_time")) - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - /** - * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this - * backfill is scoped to all customers. - */ - fun customerId(): Optional = Optional.ofNullable(customerId.getNullable("customer_id")) - - /** The number of events ingested in this backfill. */ - fun eventsIngested(): Long = eventsIngested.getRequired("events_ingested") - - /** - * If `true`, existing events in the backfill's timeframe will be replaced with the newly - * ingested events associated with the backfill. If `false`, newly ingested events will be added - * to the existing events. - */ - fun replaceExistingEvents(): Boolean = - replaceExistingEvents.getRequired("replace_existing_events") - - /** The time at which this backfill was reverted. */ - fun revertedAt(): Optional = - Optional.ofNullable(revertedAt.getNullable("reverted_at")) - - /** The status of the backfill. */ - fun status(): Status = status.getRequired("status") - - fun timeframeEnd(): OffsetDateTime = timeframeEnd.getRequired("timeframe_end") - - fun timeframeStart(): OffsetDateTime = timeframeStart.getRequired("timeframe_start") - - /** - * A boolean [computed property](/extensibility/advanced-metrics#computed-properties) used to - * filter the set of events to deprecate - */ - fun deprecationFilter(): Optional = - Optional.ofNullable(deprecationFilter.getNullable("deprecation_filter")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * If in the future, the time at which the backfill will automatically close. If in the past, - * the time at which the backfill was closed. - */ - @JsonProperty("close_time") - @ExcludeMissing - fun _closeTime(): JsonField = closeTime - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - /** - * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this - * backfill is scoped to all customers. - */ - @JsonProperty("customer_id") @ExcludeMissing fun _customerId(): JsonField = customerId - - /** The number of events ingested in this backfill. */ - @JsonProperty("events_ingested") - @ExcludeMissing - fun _eventsIngested(): JsonField = eventsIngested - - /** - * If `true`, existing events in the backfill's timeframe will be replaced with the newly - * ingested events associated with the backfill. If `false`, newly ingested events will be added - * to the existing events. - */ - @JsonProperty("replace_existing_events") - @ExcludeMissing - fun _replaceExistingEvents(): JsonField = replaceExistingEvents - - /** The time at which this backfill was reverted. */ - @JsonProperty("reverted_at") - @ExcludeMissing - fun _revertedAt(): JsonField = revertedAt - - /** The status of the backfill. */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - @JsonProperty("timeframe_end") - @ExcludeMissing - fun _timeframeEnd(): JsonField = timeframeEnd - - @JsonProperty("timeframe_start") - @ExcludeMissing - fun _timeframeStart(): JsonField = timeframeStart - - /** - * A boolean [computed property](/extensibility/advanced-metrics#computed-properties) used to - * filter the set of events to deprecate - */ - @JsonProperty("deprecation_filter") - @ExcludeMissing - fun _deprecationFilter(): JsonField = deprecationFilter - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): EventBackfillCloseResponse = apply { - if (validated) { - return@apply - } - - id() - closeTime() - createdAt() - customerId() - eventsIngested() - replaceExistingEvents() - revertedAt() - status() - timeframeEnd() - timeframeStart() - deprecationFilter() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [EventBackfillCloseResponse]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var closeTime: JsonField? = null - private var createdAt: JsonField? = null - private var customerId: JsonField? = null - private var eventsIngested: JsonField? = null - private var replaceExistingEvents: JsonField? = null - private var revertedAt: JsonField? = null - private var status: JsonField? = null - private var timeframeEnd: JsonField? = null - private var timeframeStart: JsonField? = null - private var deprecationFilter: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(eventBackfillCloseResponse: EventBackfillCloseResponse) = apply { - id = eventBackfillCloseResponse.id - closeTime = eventBackfillCloseResponse.closeTime - createdAt = eventBackfillCloseResponse.createdAt - customerId = eventBackfillCloseResponse.customerId - eventsIngested = eventBackfillCloseResponse.eventsIngested - replaceExistingEvents = eventBackfillCloseResponse.replaceExistingEvents - revertedAt = eventBackfillCloseResponse.revertedAt - status = eventBackfillCloseResponse.status - timeframeEnd = eventBackfillCloseResponse.timeframeEnd - timeframeStart = eventBackfillCloseResponse.timeframeStart - deprecationFilter = eventBackfillCloseResponse.deprecationFilter - additionalProperties = eventBackfillCloseResponse.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - /** - * If in the future, the time at which the backfill will automatically close. If in the - * past, the time at which the backfill was closed. - */ - fun closeTime(closeTime: OffsetDateTime?) = closeTime(JsonField.ofNullable(closeTime)) - - /** - * If in the future, the time at which the backfill will automatically close. If in the - * past, the time at which the backfill was closed. - */ - fun closeTime(closeTime: Optional) = closeTime(closeTime.orElse(null)) - - /** - * If in the future, the time at which the backfill will automatically close. If in the - * past, the time at which the backfill was closed. - */ - fun closeTime(closeTime: JsonField) = apply { this.closeTime = closeTime } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - - /** - * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this - * backfill is scoped to all customers. - */ - fun customerId(customerId: String?) = customerId(JsonField.ofNullable(customerId)) - - /** - * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this - * backfill is scoped to all customers. - */ - fun customerId(customerId: Optional) = customerId(customerId.orElse(null)) - - /** - * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this - * backfill is scoped to all customers. - */ - fun customerId(customerId: JsonField) = apply { this.customerId = customerId } - - /** The number of events ingested in this backfill. */ - fun eventsIngested(eventsIngested: Long) = eventsIngested(JsonField.of(eventsIngested)) - - /** The number of events ingested in this backfill. */ - fun eventsIngested(eventsIngested: JsonField) = apply { - this.eventsIngested = eventsIngested - } - - /** - * If `true`, existing events in the backfill's timeframe will be replaced with the newly - * ingested events associated with the backfill. If `false`, newly ingested events will be - * added to the existing events. - */ - fun replaceExistingEvents(replaceExistingEvents: Boolean) = - replaceExistingEvents(JsonField.of(replaceExistingEvents)) - - /** - * If `true`, existing events in the backfill's timeframe will be replaced with the newly - * ingested events associated with the backfill. If `false`, newly ingested events will be - * added to the existing events. - */ - fun replaceExistingEvents(replaceExistingEvents: JsonField) = apply { - this.replaceExistingEvents = replaceExistingEvents - } - - /** The time at which this backfill was reverted. */ - fun revertedAt(revertedAt: OffsetDateTime?) = revertedAt(JsonField.ofNullable(revertedAt)) - - /** The time at which this backfill was reverted. */ - fun revertedAt(revertedAt: Optional) = revertedAt(revertedAt.orElse(null)) - - /** The time at which this backfill was reverted. */ - fun revertedAt(revertedAt: JsonField) = apply { - this.revertedAt = revertedAt - } - - /** The status of the backfill. */ - fun status(status: Status) = status(JsonField.of(status)) - - /** The status of the backfill. */ - fun status(status: JsonField) = apply { this.status = status } - - fun timeframeEnd(timeframeEnd: OffsetDateTime) = timeframeEnd(JsonField.of(timeframeEnd)) - - fun timeframeEnd(timeframeEnd: JsonField) = apply { - this.timeframeEnd = timeframeEnd - } - - fun timeframeStart(timeframeStart: OffsetDateTime) = - timeframeStart(JsonField.of(timeframeStart)) - - fun timeframeStart(timeframeStart: JsonField) = apply { - this.timeframeStart = timeframeStart - } - - /** - * A boolean [computed property](/extensibility/advanced-metrics#computed-properties) used - * to filter the set of events to deprecate - */ - fun deprecationFilter(deprecationFilter: String?) = - deprecationFilter(JsonField.ofNullable(deprecationFilter)) - - /** - * A boolean [computed property](/extensibility/advanced-metrics#computed-properties) used - * to filter the set of events to deprecate - */ - fun deprecationFilter(deprecationFilter: Optional) = - deprecationFilter(deprecationFilter.orElse(null)) - - /** - * A boolean [computed property](/extensibility/advanced-metrics#computed-properties) used - * to filter the set of events to deprecate - */ - fun deprecationFilter(deprecationFilter: JsonField) = apply { - this.deprecationFilter = deprecationFilter - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): EventBackfillCloseResponse = - EventBackfillCloseResponse( - checkRequired("id", id), - checkRequired("closeTime", closeTime), - checkRequired("createdAt", createdAt), - checkRequired("customerId", customerId), - checkRequired("eventsIngested", eventsIngested), - checkRequired("replaceExistingEvents", replaceExistingEvents), - checkRequired("revertedAt", revertedAt), - checkRequired("status", status), - checkRequired("timeframeEnd", timeframeEnd), - checkRequired("timeframeStart", timeframeStart), - deprecationFilter, - additionalProperties.toImmutable(), - ) - } - - /** The status of the backfill. */ - 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 PENDING = of("pending") - - @JvmField val REFLECTED = of("reflected") - - @JvmField val PENDING_REVERT = of("pending_revert") - - @JvmField val REVERTED = of("reverted") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - PENDING, - REFLECTED, - PENDING_REVERT, - REVERTED, - } - - /** - * 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 { - PENDING, - REFLECTED, - PENDING_REVERT, - REVERTED, - /** 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) { - PENDING -> Value.PENDING - REFLECTED -> Value.REFLECTED - PENDING_REVERT -> Value.PENDING_REVERT - REVERTED -> Value.REVERTED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - PENDING -> Known.PENDING - REFLECTED -> Known.REFLECTED - PENDING_REVERT -> Known.PENDING_REVERT - REVERTED -> Known.REVERTED - 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EventBackfillCloseResponse && id == other.id && closeTime == other.closeTime && createdAt == other.createdAt && customerId == other.customerId && eventsIngested == other.eventsIngested && replaceExistingEvents == other.replaceExistingEvents && revertedAt == other.revertedAt && status == other.status && timeframeEnd == other.timeframeEnd && timeframeStart == other.timeframeStart && deprecationFilter == other.deprecationFilter && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, closeTime, createdAt, customerId, eventsIngested, replaceExistingEvents, revertedAt, status, timeframeEnd, timeframeStart, deprecationFilter, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "EventBackfillCloseResponse{id=$id, closeTime=$closeTime, createdAt=$createdAt, customerId=$customerId, eventsIngested=$eventsIngested, replaceExistingEvents=$replaceExistingEvents, revertedAt=$revertedAt, status=$status, timeframeEnd=$timeframeEnd, timeframeStart=$timeframeStart, deprecationFilter=$deprecationFilter, additionalProperties=$additionalProperties}" -} 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 a4455eac1..d0a7f860b 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 @@ -291,6 +291,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .timeframeEnd() + * .timeframeStart() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -490,6 +499,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [EventBackfillCreateParams]. + * + * The following fields are required: + * ```java + * .timeframeEnd() + * .timeframeStart() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 deleted file mode 100644 index 1f42e7de0..000000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateResponse.kt +++ /dev/null @@ -1,516 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.withorb.api.core.Enum -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.checkRequired -import com.withorb.api.core.immutableEmptyMap -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional - -/** - * A backfill represents an update to historical usage data, adding or replacing events in a - * timeframe. - */ -@NoAutoDetect -class EventBackfillCreateResponse -@JsonCreator -private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("close_time") - @ExcludeMissing - private val closeTime: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("customer_id") - @ExcludeMissing - private val customerId: JsonField = JsonMissing.of(), - @JsonProperty("events_ingested") - @ExcludeMissing - private val eventsIngested: JsonField = JsonMissing.of(), - @JsonProperty("replace_existing_events") - @ExcludeMissing - private val replaceExistingEvents: JsonField = JsonMissing.of(), - @JsonProperty("reverted_at") - @ExcludeMissing - private val revertedAt: JsonField = JsonMissing.of(), - @JsonProperty("status") - @ExcludeMissing - private val status: JsonField = JsonMissing.of(), - @JsonProperty("timeframe_end") - @ExcludeMissing - private val timeframeEnd: JsonField = JsonMissing.of(), - @JsonProperty("timeframe_start") - @ExcludeMissing - private val timeframeStart: JsonField = JsonMissing.of(), - @JsonProperty("deprecation_filter") - @ExcludeMissing - private val deprecationFilter: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun id(): String = id.getRequired("id") - - /** - * If in the future, the time at which the backfill will automatically close. If in the past, - * the time at which the backfill was closed. - */ - fun closeTime(): Optional = - Optional.ofNullable(closeTime.getNullable("close_time")) - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - /** - * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this - * backfill is scoped to all customers. - */ - fun customerId(): Optional = Optional.ofNullable(customerId.getNullable("customer_id")) - - /** The number of events ingested in this backfill. */ - fun eventsIngested(): Long = eventsIngested.getRequired("events_ingested") - - /** - * If `true`, existing events in the backfill's timeframe will be replaced with the newly - * ingested events associated with the backfill. If `false`, newly ingested events will be added - * to the existing events. - */ - fun replaceExistingEvents(): Boolean = - replaceExistingEvents.getRequired("replace_existing_events") - - /** The time at which this backfill was reverted. */ - fun revertedAt(): Optional = - Optional.ofNullable(revertedAt.getNullable("reverted_at")) - - /** The status of the backfill. */ - fun status(): Status = status.getRequired("status") - - fun timeframeEnd(): OffsetDateTime = timeframeEnd.getRequired("timeframe_end") - - fun timeframeStart(): OffsetDateTime = timeframeStart.getRequired("timeframe_start") - - /** - * A boolean [computed property](/extensibility/advanced-metrics#computed-properties) used to - * filter the set of events to deprecate - */ - fun deprecationFilter(): Optional = - Optional.ofNullable(deprecationFilter.getNullable("deprecation_filter")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * If in the future, the time at which the backfill will automatically close. If in the past, - * the time at which the backfill was closed. - */ - @JsonProperty("close_time") - @ExcludeMissing - fun _closeTime(): JsonField = closeTime - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - /** - * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this - * backfill is scoped to all customers. - */ - @JsonProperty("customer_id") @ExcludeMissing fun _customerId(): JsonField = customerId - - /** The number of events ingested in this backfill. */ - @JsonProperty("events_ingested") - @ExcludeMissing - fun _eventsIngested(): JsonField = eventsIngested - - /** - * If `true`, existing events in the backfill's timeframe will be replaced with the newly - * ingested events associated with the backfill. If `false`, newly ingested events will be added - * to the existing events. - */ - @JsonProperty("replace_existing_events") - @ExcludeMissing - fun _replaceExistingEvents(): JsonField = replaceExistingEvents - - /** The time at which this backfill was reverted. */ - @JsonProperty("reverted_at") - @ExcludeMissing - fun _revertedAt(): JsonField = revertedAt - - /** The status of the backfill. */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - @JsonProperty("timeframe_end") - @ExcludeMissing - fun _timeframeEnd(): JsonField = timeframeEnd - - @JsonProperty("timeframe_start") - @ExcludeMissing - fun _timeframeStart(): JsonField = timeframeStart - - /** - * A boolean [computed property](/extensibility/advanced-metrics#computed-properties) used to - * filter the set of events to deprecate - */ - @JsonProperty("deprecation_filter") - @ExcludeMissing - fun _deprecationFilter(): JsonField = deprecationFilter - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): EventBackfillCreateResponse = apply { - if (validated) { - return@apply - } - - id() - closeTime() - createdAt() - customerId() - eventsIngested() - replaceExistingEvents() - revertedAt() - status() - timeframeEnd() - timeframeStart() - deprecationFilter() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [EventBackfillCreateResponse]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var closeTime: JsonField? = null - private var createdAt: JsonField? = null - private var customerId: JsonField? = null - private var eventsIngested: JsonField? = null - private var replaceExistingEvents: JsonField? = null - private var revertedAt: JsonField? = null - private var status: JsonField? = null - private var timeframeEnd: JsonField? = null - private var timeframeStart: JsonField? = null - private var deprecationFilter: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(eventBackfillCreateResponse: EventBackfillCreateResponse) = apply { - id = eventBackfillCreateResponse.id - closeTime = eventBackfillCreateResponse.closeTime - createdAt = eventBackfillCreateResponse.createdAt - customerId = eventBackfillCreateResponse.customerId - eventsIngested = eventBackfillCreateResponse.eventsIngested - replaceExistingEvents = eventBackfillCreateResponse.replaceExistingEvents - revertedAt = eventBackfillCreateResponse.revertedAt - status = eventBackfillCreateResponse.status - timeframeEnd = eventBackfillCreateResponse.timeframeEnd - timeframeStart = eventBackfillCreateResponse.timeframeStart - deprecationFilter = eventBackfillCreateResponse.deprecationFilter - additionalProperties = eventBackfillCreateResponse.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - /** - * If in the future, the time at which the backfill will automatically close. If in the - * past, the time at which the backfill was closed. - */ - fun closeTime(closeTime: OffsetDateTime?) = closeTime(JsonField.ofNullable(closeTime)) - - /** - * If in the future, the time at which the backfill will automatically close. If in the - * past, the time at which the backfill was closed. - */ - fun closeTime(closeTime: Optional) = closeTime(closeTime.orElse(null)) - - /** - * If in the future, the time at which the backfill will automatically close. If in the - * past, the time at which the backfill was closed. - */ - fun closeTime(closeTime: JsonField) = apply { this.closeTime = closeTime } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - - /** - * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this - * backfill is scoped to all customers. - */ - fun customerId(customerId: String?) = customerId(JsonField.ofNullable(customerId)) - - /** - * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this - * backfill is scoped to all customers. - */ - fun customerId(customerId: Optional) = customerId(customerId.orElse(null)) - - /** - * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this - * backfill is scoped to all customers. - */ - fun customerId(customerId: JsonField) = apply { this.customerId = customerId } - - /** The number of events ingested in this backfill. */ - fun eventsIngested(eventsIngested: Long) = eventsIngested(JsonField.of(eventsIngested)) - - /** The number of events ingested in this backfill. */ - fun eventsIngested(eventsIngested: JsonField) = apply { - this.eventsIngested = eventsIngested - } - - /** - * If `true`, existing events in the backfill's timeframe will be replaced with the newly - * ingested events associated with the backfill. If `false`, newly ingested events will be - * added to the existing events. - */ - fun replaceExistingEvents(replaceExistingEvents: Boolean) = - replaceExistingEvents(JsonField.of(replaceExistingEvents)) - - /** - * If `true`, existing events in the backfill's timeframe will be replaced with the newly - * ingested events associated with the backfill. If `false`, newly ingested events will be - * added to the existing events. - */ - fun replaceExistingEvents(replaceExistingEvents: JsonField) = apply { - this.replaceExistingEvents = replaceExistingEvents - } - - /** The time at which this backfill was reverted. */ - fun revertedAt(revertedAt: OffsetDateTime?) = revertedAt(JsonField.ofNullable(revertedAt)) - - /** The time at which this backfill was reverted. */ - fun revertedAt(revertedAt: Optional) = revertedAt(revertedAt.orElse(null)) - - /** The time at which this backfill was reverted. */ - fun revertedAt(revertedAt: JsonField) = apply { - this.revertedAt = revertedAt - } - - /** The status of the backfill. */ - fun status(status: Status) = status(JsonField.of(status)) - - /** The status of the backfill. */ - fun status(status: JsonField) = apply { this.status = status } - - fun timeframeEnd(timeframeEnd: OffsetDateTime) = timeframeEnd(JsonField.of(timeframeEnd)) - - fun timeframeEnd(timeframeEnd: JsonField) = apply { - this.timeframeEnd = timeframeEnd - } - - fun timeframeStart(timeframeStart: OffsetDateTime) = - timeframeStart(JsonField.of(timeframeStart)) - - fun timeframeStart(timeframeStart: JsonField) = apply { - this.timeframeStart = timeframeStart - } - - /** - * A boolean [computed property](/extensibility/advanced-metrics#computed-properties) used - * to filter the set of events to deprecate - */ - fun deprecationFilter(deprecationFilter: String?) = - deprecationFilter(JsonField.ofNullable(deprecationFilter)) - - /** - * A boolean [computed property](/extensibility/advanced-metrics#computed-properties) used - * to filter the set of events to deprecate - */ - fun deprecationFilter(deprecationFilter: Optional) = - deprecationFilter(deprecationFilter.orElse(null)) - - /** - * A boolean [computed property](/extensibility/advanced-metrics#computed-properties) used - * to filter the set of events to deprecate - */ - fun deprecationFilter(deprecationFilter: JsonField) = apply { - this.deprecationFilter = deprecationFilter - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): EventBackfillCreateResponse = - EventBackfillCreateResponse( - checkRequired("id", id), - checkRequired("closeTime", closeTime), - checkRequired("createdAt", createdAt), - checkRequired("customerId", customerId), - checkRequired("eventsIngested", eventsIngested), - checkRequired("replaceExistingEvents", replaceExistingEvents), - checkRequired("revertedAt", revertedAt), - checkRequired("status", status), - checkRequired("timeframeEnd", timeframeEnd), - checkRequired("timeframeStart", timeframeStart), - deprecationFilter, - additionalProperties.toImmutable(), - ) - } - - /** The status of the backfill. */ - 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 PENDING = of("pending") - - @JvmField val REFLECTED = of("reflected") - - @JvmField val PENDING_REVERT = of("pending_revert") - - @JvmField val REVERTED = of("reverted") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - PENDING, - REFLECTED, - PENDING_REVERT, - REVERTED, - } - - /** - * 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 { - PENDING, - REFLECTED, - PENDING_REVERT, - REVERTED, - /** 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) { - PENDING -> Value.PENDING - REFLECTED -> Value.REFLECTED - PENDING_REVERT -> Value.PENDING_REVERT - REVERTED -> Value.REVERTED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - PENDING -> Known.PENDING - REFLECTED -> Known.REFLECTED - PENDING_REVERT -> Known.PENDING_REVERT - REVERTED -> Known.REVERTED - 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EventBackfillCreateResponse && id == other.id && closeTime == other.closeTime && createdAt == other.createdAt && customerId == other.customerId && eventsIngested == other.eventsIngested && replaceExistingEvents == other.replaceExistingEvents && revertedAt == other.revertedAt && status == other.status && timeframeEnd == other.timeframeEnd && timeframeStart == other.timeframeStart && deprecationFilter == other.deprecationFilter && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, closeTime, createdAt, customerId, eventsIngested, replaceExistingEvents, revertedAt, status, timeframeEnd, timeframeStart, deprecationFilter, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "EventBackfillCreateResponse{id=$id, closeTime=$closeTime, createdAt=$createdAt, customerId=$customerId, eventsIngested=$eventsIngested, replaceExistingEvents=$replaceExistingEvents, revertedAt=$revertedAt, status=$status, timeframeEnd=$timeframeEnd, timeframeStart=$timeframeStart, deprecationFilter=$deprecationFilter, additionalProperties=$additionalProperties}" -} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchParams.kt index 01cf9e45d..9973604dd 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchParams.kt @@ -38,6 +38,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [EventBackfillFetchParams]. + * + * The following fields are required: + * ```java + * .backfillId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPage.kt index fa384508b..82667b8d1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPage.kt @@ -36,7 +36,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -94,22 +94,20 @@ private constructor( class Response @JsonCreator constructor( - @JsonProperty("data") - private val data: JsonField> = JsonMissing.of(), + @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = - Optional.ofNullable(data) + fun _data(): Optional>> = Optional.ofNullable(data) @JsonProperty("pagination_metadata") fun _paginationMetadata(): Optional> = @@ -148,12 +146,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [EventBackfillListPage]. + */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -164,9 +165,9 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { this.data = data } fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) @@ -183,10 +184,9 @@ private constructor( } } - class AutoPager(private val firstPage: EventBackfillListPage) : - Iterable { + class AutoPager(private val firstPage: EventBackfillListPage) : Iterable { - override fun iterator(): Iterator = iterator { + override fun iterator(): Iterator = iterator { var page = firstPage var index = 0 while (true) { @@ -198,7 +198,7 @@ private constructor( } } - fun stream(): Stream { + fun stream(): Stream { return StreamSupport.stream(spliterator(), false) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPageAsync.kt index f7cdd8764..4b8364cc4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListPageAsync.kt @@ -37,7 +37,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -97,22 +97,20 @@ private constructor( class Response @JsonCreator constructor( - @JsonProperty("data") - private val data: JsonField> = JsonMissing.of(), + @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = - Optional.ofNullable(data) + fun _data(): Optional>> = Optional.ofNullable(data) @JsonProperty("pagination_metadata") fun _paginationMetadata(): Optional> = @@ -151,12 +149,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [EventBackfillListPageAsync]. + */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -167,9 +169,9 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { this.data = data } fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) @@ -188,12 +190,9 @@ private constructor( class AutoPager(private val firstPage: EventBackfillListPageAsync) { - fun forEach( - action: Predicate, - executor: Executor, - ): CompletableFuture { + fun forEach(action: Predicate, executor: Executor): CompletableFuture { fun CompletableFuture>.forEach( - action: (EventBackfillListResponse) -> Boolean, + action: (BackfillModel) -> Boolean, executor: Executor, ): CompletableFuture = thenComposeAsync( @@ -209,8 +208,8 @@ private constructor( .forEach(action::test, executor) } - fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() + fun toList(executor: Executor): CompletableFuture> { + val values = mutableListOf() return forEach(values::add, executor).thenApply { values } } } 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 ef5fbf066..9f0476cdb 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 @@ -54,6 +54,7 @@ private constructor( @JvmStatic fun none(): EventBackfillListParams = builder().build() + /** Returns a mutable builder for constructing an instance of [EventBackfillListParams]. */ @JvmStatic fun builder() = Builder() } 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 deleted file mode 100644 index e798438d8..000000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListResponse.kt +++ /dev/null @@ -1,516 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.withorb.api.core.Enum -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.checkRequired -import com.withorb.api.core.immutableEmptyMap -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional - -/** - * A backfill represents an update to historical usage data, adding or replacing events in a - * timeframe. - */ -@NoAutoDetect -class EventBackfillListResponse -@JsonCreator -private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("close_time") - @ExcludeMissing - private val closeTime: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("customer_id") - @ExcludeMissing - private val customerId: JsonField = JsonMissing.of(), - @JsonProperty("events_ingested") - @ExcludeMissing - private val eventsIngested: JsonField = JsonMissing.of(), - @JsonProperty("replace_existing_events") - @ExcludeMissing - private val replaceExistingEvents: JsonField = JsonMissing.of(), - @JsonProperty("reverted_at") - @ExcludeMissing - private val revertedAt: JsonField = JsonMissing.of(), - @JsonProperty("status") - @ExcludeMissing - private val status: JsonField = JsonMissing.of(), - @JsonProperty("timeframe_end") - @ExcludeMissing - private val timeframeEnd: JsonField = JsonMissing.of(), - @JsonProperty("timeframe_start") - @ExcludeMissing - private val timeframeStart: JsonField = JsonMissing.of(), - @JsonProperty("deprecation_filter") - @ExcludeMissing - private val deprecationFilter: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun id(): String = id.getRequired("id") - - /** - * If in the future, the time at which the backfill will automatically close. If in the past, - * the time at which the backfill was closed. - */ - fun closeTime(): Optional = - Optional.ofNullable(closeTime.getNullable("close_time")) - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - /** - * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this - * backfill is scoped to all customers. - */ - fun customerId(): Optional = Optional.ofNullable(customerId.getNullable("customer_id")) - - /** The number of events ingested in this backfill. */ - fun eventsIngested(): Long = eventsIngested.getRequired("events_ingested") - - /** - * If `true`, existing events in the backfill's timeframe will be replaced with the newly - * ingested events associated with the backfill. If `false`, newly ingested events will be added - * to the existing events. - */ - fun replaceExistingEvents(): Boolean = - replaceExistingEvents.getRequired("replace_existing_events") - - /** The time at which this backfill was reverted. */ - fun revertedAt(): Optional = - Optional.ofNullable(revertedAt.getNullable("reverted_at")) - - /** The status of the backfill. */ - fun status(): Status = status.getRequired("status") - - fun timeframeEnd(): OffsetDateTime = timeframeEnd.getRequired("timeframe_end") - - fun timeframeStart(): OffsetDateTime = timeframeStart.getRequired("timeframe_start") - - /** - * A boolean [computed property](/extensibility/advanced-metrics#computed-properties) used to - * filter the set of events to deprecate - */ - fun deprecationFilter(): Optional = - Optional.ofNullable(deprecationFilter.getNullable("deprecation_filter")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * If in the future, the time at which the backfill will automatically close. If in the past, - * the time at which the backfill was closed. - */ - @JsonProperty("close_time") - @ExcludeMissing - fun _closeTime(): JsonField = closeTime - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - /** - * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this - * backfill is scoped to all customers. - */ - @JsonProperty("customer_id") @ExcludeMissing fun _customerId(): JsonField = customerId - - /** The number of events ingested in this backfill. */ - @JsonProperty("events_ingested") - @ExcludeMissing - fun _eventsIngested(): JsonField = eventsIngested - - /** - * If `true`, existing events in the backfill's timeframe will be replaced with the newly - * ingested events associated with the backfill. If `false`, newly ingested events will be added - * to the existing events. - */ - @JsonProperty("replace_existing_events") - @ExcludeMissing - fun _replaceExistingEvents(): JsonField = replaceExistingEvents - - /** The time at which this backfill was reverted. */ - @JsonProperty("reverted_at") - @ExcludeMissing - fun _revertedAt(): JsonField = revertedAt - - /** The status of the backfill. */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - @JsonProperty("timeframe_end") - @ExcludeMissing - fun _timeframeEnd(): JsonField = timeframeEnd - - @JsonProperty("timeframe_start") - @ExcludeMissing - fun _timeframeStart(): JsonField = timeframeStart - - /** - * A boolean [computed property](/extensibility/advanced-metrics#computed-properties) used to - * filter the set of events to deprecate - */ - @JsonProperty("deprecation_filter") - @ExcludeMissing - fun _deprecationFilter(): JsonField = deprecationFilter - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): EventBackfillListResponse = apply { - if (validated) { - return@apply - } - - id() - closeTime() - createdAt() - customerId() - eventsIngested() - replaceExistingEvents() - revertedAt() - status() - timeframeEnd() - timeframeStart() - deprecationFilter() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [EventBackfillListResponse]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var closeTime: JsonField? = null - private var createdAt: JsonField? = null - private var customerId: JsonField? = null - private var eventsIngested: JsonField? = null - private var replaceExistingEvents: JsonField? = null - private var revertedAt: JsonField? = null - private var status: JsonField? = null - private var timeframeEnd: JsonField? = null - private var timeframeStart: JsonField? = null - private var deprecationFilter: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(eventBackfillListResponse: EventBackfillListResponse) = apply { - id = eventBackfillListResponse.id - closeTime = eventBackfillListResponse.closeTime - createdAt = eventBackfillListResponse.createdAt - customerId = eventBackfillListResponse.customerId - eventsIngested = eventBackfillListResponse.eventsIngested - replaceExistingEvents = eventBackfillListResponse.replaceExistingEvents - revertedAt = eventBackfillListResponse.revertedAt - status = eventBackfillListResponse.status - timeframeEnd = eventBackfillListResponse.timeframeEnd - timeframeStart = eventBackfillListResponse.timeframeStart - deprecationFilter = eventBackfillListResponse.deprecationFilter - additionalProperties = eventBackfillListResponse.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - /** - * If in the future, the time at which the backfill will automatically close. If in the - * past, the time at which the backfill was closed. - */ - fun closeTime(closeTime: OffsetDateTime?) = closeTime(JsonField.ofNullable(closeTime)) - - /** - * If in the future, the time at which the backfill will automatically close. If in the - * past, the time at which the backfill was closed. - */ - fun closeTime(closeTime: Optional) = closeTime(closeTime.orElse(null)) - - /** - * If in the future, the time at which the backfill will automatically close. If in the - * past, the time at which the backfill was closed. - */ - fun closeTime(closeTime: JsonField) = apply { this.closeTime = closeTime } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - - /** - * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this - * backfill is scoped to all customers. - */ - fun customerId(customerId: String?) = customerId(JsonField.ofNullable(customerId)) - - /** - * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this - * backfill is scoped to all customers. - */ - fun customerId(customerId: Optional) = customerId(customerId.orElse(null)) - - /** - * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this - * backfill is scoped to all customers. - */ - fun customerId(customerId: JsonField) = apply { this.customerId = customerId } - - /** The number of events ingested in this backfill. */ - fun eventsIngested(eventsIngested: Long) = eventsIngested(JsonField.of(eventsIngested)) - - /** The number of events ingested in this backfill. */ - fun eventsIngested(eventsIngested: JsonField) = apply { - this.eventsIngested = eventsIngested - } - - /** - * If `true`, existing events in the backfill's timeframe will be replaced with the newly - * ingested events associated with the backfill. If `false`, newly ingested events will be - * added to the existing events. - */ - fun replaceExistingEvents(replaceExistingEvents: Boolean) = - replaceExistingEvents(JsonField.of(replaceExistingEvents)) - - /** - * If `true`, existing events in the backfill's timeframe will be replaced with the newly - * ingested events associated with the backfill. If `false`, newly ingested events will be - * added to the existing events. - */ - fun replaceExistingEvents(replaceExistingEvents: JsonField) = apply { - this.replaceExistingEvents = replaceExistingEvents - } - - /** The time at which this backfill was reverted. */ - fun revertedAt(revertedAt: OffsetDateTime?) = revertedAt(JsonField.ofNullable(revertedAt)) - - /** The time at which this backfill was reverted. */ - fun revertedAt(revertedAt: Optional) = revertedAt(revertedAt.orElse(null)) - - /** The time at which this backfill was reverted. */ - fun revertedAt(revertedAt: JsonField) = apply { - this.revertedAt = revertedAt - } - - /** The status of the backfill. */ - fun status(status: Status) = status(JsonField.of(status)) - - /** The status of the backfill. */ - fun status(status: JsonField) = apply { this.status = status } - - fun timeframeEnd(timeframeEnd: OffsetDateTime) = timeframeEnd(JsonField.of(timeframeEnd)) - - fun timeframeEnd(timeframeEnd: JsonField) = apply { - this.timeframeEnd = timeframeEnd - } - - fun timeframeStart(timeframeStart: OffsetDateTime) = - timeframeStart(JsonField.of(timeframeStart)) - - fun timeframeStart(timeframeStart: JsonField) = apply { - this.timeframeStart = timeframeStart - } - - /** - * A boolean [computed property](/extensibility/advanced-metrics#computed-properties) used - * to filter the set of events to deprecate - */ - fun deprecationFilter(deprecationFilter: String?) = - deprecationFilter(JsonField.ofNullable(deprecationFilter)) - - /** - * A boolean [computed property](/extensibility/advanced-metrics#computed-properties) used - * to filter the set of events to deprecate - */ - fun deprecationFilter(deprecationFilter: Optional) = - deprecationFilter(deprecationFilter.orElse(null)) - - /** - * A boolean [computed property](/extensibility/advanced-metrics#computed-properties) used - * to filter the set of events to deprecate - */ - fun deprecationFilter(deprecationFilter: JsonField) = apply { - this.deprecationFilter = deprecationFilter - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): EventBackfillListResponse = - EventBackfillListResponse( - checkRequired("id", id), - checkRequired("closeTime", closeTime), - checkRequired("createdAt", createdAt), - checkRequired("customerId", customerId), - checkRequired("eventsIngested", eventsIngested), - checkRequired("replaceExistingEvents", replaceExistingEvents), - checkRequired("revertedAt", revertedAt), - checkRequired("status", status), - checkRequired("timeframeEnd", timeframeEnd), - checkRequired("timeframeStart", timeframeStart), - deprecationFilter, - additionalProperties.toImmutable(), - ) - } - - /** The status of the backfill. */ - 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 PENDING = of("pending") - - @JvmField val REFLECTED = of("reflected") - - @JvmField val PENDING_REVERT = of("pending_revert") - - @JvmField val REVERTED = of("reverted") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - PENDING, - REFLECTED, - PENDING_REVERT, - REVERTED, - } - - /** - * 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 { - PENDING, - REFLECTED, - PENDING_REVERT, - REVERTED, - /** 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) { - PENDING -> Value.PENDING - REFLECTED -> Value.REFLECTED - PENDING_REVERT -> Value.PENDING_REVERT - REVERTED -> Value.REVERTED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - PENDING -> Known.PENDING - REFLECTED -> Known.REFLECTED - PENDING_REVERT -> Known.PENDING_REVERT - REVERTED -> Known.REVERTED - 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EventBackfillListResponse && id == other.id && closeTime == other.closeTime && createdAt == other.createdAt && customerId == other.customerId && eventsIngested == other.eventsIngested && replaceExistingEvents == other.replaceExistingEvents && revertedAt == other.revertedAt && status == other.status && timeframeEnd == other.timeframeEnd && timeframeStart == other.timeframeStart && deprecationFilter == other.deprecationFilter && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, closeTime, createdAt, customerId, eventsIngested, replaceExistingEvents, revertedAt, status, timeframeEnd, timeframeStart, deprecationFilter, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "EventBackfillListResponse{id=$id, closeTime=$closeTime, createdAt=$createdAt, customerId=$customerId, eventsIngested=$eventsIngested, replaceExistingEvents=$replaceExistingEvents, revertedAt=$revertedAt, status=$status, timeframeEnd=$timeframeEnd, timeframeStart=$timeframeStart, deprecationFilter=$deprecationFilter, additionalProperties=$additionalProperties}" -} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertParams.kt index 78b01bb19..f4ac20d8f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertParams.kt @@ -55,6 +55,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [EventBackfillRevertParams]. + * + * The following fields are required: + * ```java + * .backfillId() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 deleted file mode 100644 index f32046058..000000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertResponse.kt +++ /dev/null @@ -1,516 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.withorb.api.core.Enum -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.checkRequired -import com.withorb.api.core.immutableEmptyMap -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional - -/** - * A backfill represents an update to historical usage data, adding or replacing events in a - * timeframe. - */ -@NoAutoDetect -class EventBackfillRevertResponse -@JsonCreator -private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("close_time") - @ExcludeMissing - private val closeTime: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("customer_id") - @ExcludeMissing - private val customerId: JsonField = JsonMissing.of(), - @JsonProperty("events_ingested") - @ExcludeMissing - private val eventsIngested: JsonField = JsonMissing.of(), - @JsonProperty("replace_existing_events") - @ExcludeMissing - private val replaceExistingEvents: JsonField = JsonMissing.of(), - @JsonProperty("reverted_at") - @ExcludeMissing - private val revertedAt: JsonField = JsonMissing.of(), - @JsonProperty("status") - @ExcludeMissing - private val status: JsonField = JsonMissing.of(), - @JsonProperty("timeframe_end") - @ExcludeMissing - private val timeframeEnd: JsonField = JsonMissing.of(), - @JsonProperty("timeframe_start") - @ExcludeMissing - private val timeframeStart: JsonField = JsonMissing.of(), - @JsonProperty("deprecation_filter") - @ExcludeMissing - private val deprecationFilter: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun id(): String = id.getRequired("id") - - /** - * If in the future, the time at which the backfill will automatically close. If in the past, - * the time at which the backfill was closed. - */ - fun closeTime(): Optional = - Optional.ofNullable(closeTime.getNullable("close_time")) - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - /** - * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this - * backfill is scoped to all customers. - */ - fun customerId(): Optional = Optional.ofNullable(customerId.getNullable("customer_id")) - - /** The number of events ingested in this backfill. */ - fun eventsIngested(): Long = eventsIngested.getRequired("events_ingested") - - /** - * If `true`, existing events in the backfill's timeframe will be replaced with the newly - * ingested events associated with the backfill. If `false`, newly ingested events will be added - * to the existing events. - */ - fun replaceExistingEvents(): Boolean = - replaceExistingEvents.getRequired("replace_existing_events") - - /** The time at which this backfill was reverted. */ - fun revertedAt(): Optional = - Optional.ofNullable(revertedAt.getNullable("reverted_at")) - - /** The status of the backfill. */ - fun status(): Status = status.getRequired("status") - - fun timeframeEnd(): OffsetDateTime = timeframeEnd.getRequired("timeframe_end") - - fun timeframeStart(): OffsetDateTime = timeframeStart.getRequired("timeframe_start") - - /** - * A boolean [computed property](/extensibility/advanced-metrics#computed-properties) used to - * filter the set of events to deprecate - */ - fun deprecationFilter(): Optional = - Optional.ofNullable(deprecationFilter.getNullable("deprecation_filter")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * If in the future, the time at which the backfill will automatically close. If in the past, - * the time at which the backfill was closed. - */ - @JsonProperty("close_time") - @ExcludeMissing - fun _closeTime(): JsonField = closeTime - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - /** - * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this - * backfill is scoped to all customers. - */ - @JsonProperty("customer_id") @ExcludeMissing fun _customerId(): JsonField = customerId - - /** The number of events ingested in this backfill. */ - @JsonProperty("events_ingested") - @ExcludeMissing - fun _eventsIngested(): JsonField = eventsIngested - - /** - * If `true`, existing events in the backfill's timeframe will be replaced with the newly - * ingested events associated with the backfill. If `false`, newly ingested events will be added - * to the existing events. - */ - @JsonProperty("replace_existing_events") - @ExcludeMissing - fun _replaceExistingEvents(): JsonField = replaceExistingEvents - - /** The time at which this backfill was reverted. */ - @JsonProperty("reverted_at") - @ExcludeMissing - fun _revertedAt(): JsonField = revertedAt - - /** The status of the backfill. */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - @JsonProperty("timeframe_end") - @ExcludeMissing - fun _timeframeEnd(): JsonField = timeframeEnd - - @JsonProperty("timeframe_start") - @ExcludeMissing - fun _timeframeStart(): JsonField = timeframeStart - - /** - * A boolean [computed property](/extensibility/advanced-metrics#computed-properties) used to - * filter the set of events to deprecate - */ - @JsonProperty("deprecation_filter") - @ExcludeMissing - fun _deprecationFilter(): JsonField = deprecationFilter - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): EventBackfillRevertResponse = apply { - if (validated) { - return@apply - } - - id() - closeTime() - createdAt() - customerId() - eventsIngested() - replaceExistingEvents() - revertedAt() - status() - timeframeEnd() - timeframeStart() - deprecationFilter() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [EventBackfillRevertResponse]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var closeTime: JsonField? = null - private var createdAt: JsonField? = null - private var customerId: JsonField? = null - private var eventsIngested: JsonField? = null - private var replaceExistingEvents: JsonField? = null - private var revertedAt: JsonField? = null - private var status: JsonField? = null - private var timeframeEnd: JsonField? = null - private var timeframeStart: JsonField? = null - private var deprecationFilter: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(eventBackfillRevertResponse: EventBackfillRevertResponse) = apply { - id = eventBackfillRevertResponse.id - closeTime = eventBackfillRevertResponse.closeTime - createdAt = eventBackfillRevertResponse.createdAt - customerId = eventBackfillRevertResponse.customerId - eventsIngested = eventBackfillRevertResponse.eventsIngested - replaceExistingEvents = eventBackfillRevertResponse.replaceExistingEvents - revertedAt = eventBackfillRevertResponse.revertedAt - status = eventBackfillRevertResponse.status - timeframeEnd = eventBackfillRevertResponse.timeframeEnd - timeframeStart = eventBackfillRevertResponse.timeframeStart - deprecationFilter = eventBackfillRevertResponse.deprecationFilter - additionalProperties = eventBackfillRevertResponse.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - /** - * If in the future, the time at which the backfill will automatically close. If in the - * past, the time at which the backfill was closed. - */ - fun closeTime(closeTime: OffsetDateTime?) = closeTime(JsonField.ofNullable(closeTime)) - - /** - * If in the future, the time at which the backfill will automatically close. If in the - * past, the time at which the backfill was closed. - */ - fun closeTime(closeTime: Optional) = closeTime(closeTime.orElse(null)) - - /** - * If in the future, the time at which the backfill will automatically close. If in the - * past, the time at which the backfill was closed. - */ - fun closeTime(closeTime: JsonField) = apply { this.closeTime = closeTime } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - - /** - * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this - * backfill is scoped to all customers. - */ - fun customerId(customerId: String?) = customerId(JsonField.ofNullable(customerId)) - - /** - * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this - * backfill is scoped to all customers. - */ - fun customerId(customerId: Optional) = customerId(customerId.orElse(null)) - - /** - * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this - * backfill is scoped to all customers. - */ - fun customerId(customerId: JsonField) = apply { this.customerId = customerId } - - /** The number of events ingested in this backfill. */ - fun eventsIngested(eventsIngested: Long) = eventsIngested(JsonField.of(eventsIngested)) - - /** The number of events ingested in this backfill. */ - fun eventsIngested(eventsIngested: JsonField) = apply { - this.eventsIngested = eventsIngested - } - - /** - * If `true`, existing events in the backfill's timeframe will be replaced with the newly - * ingested events associated with the backfill. If `false`, newly ingested events will be - * added to the existing events. - */ - fun replaceExistingEvents(replaceExistingEvents: Boolean) = - replaceExistingEvents(JsonField.of(replaceExistingEvents)) - - /** - * If `true`, existing events in the backfill's timeframe will be replaced with the newly - * ingested events associated with the backfill. If `false`, newly ingested events will be - * added to the existing events. - */ - fun replaceExistingEvents(replaceExistingEvents: JsonField) = apply { - this.replaceExistingEvents = replaceExistingEvents - } - - /** The time at which this backfill was reverted. */ - fun revertedAt(revertedAt: OffsetDateTime?) = revertedAt(JsonField.ofNullable(revertedAt)) - - /** The time at which this backfill was reverted. */ - fun revertedAt(revertedAt: Optional) = revertedAt(revertedAt.orElse(null)) - - /** The time at which this backfill was reverted. */ - fun revertedAt(revertedAt: JsonField) = apply { - this.revertedAt = revertedAt - } - - /** The status of the backfill. */ - fun status(status: Status) = status(JsonField.of(status)) - - /** The status of the backfill. */ - fun status(status: JsonField) = apply { this.status = status } - - fun timeframeEnd(timeframeEnd: OffsetDateTime) = timeframeEnd(JsonField.of(timeframeEnd)) - - fun timeframeEnd(timeframeEnd: JsonField) = apply { - this.timeframeEnd = timeframeEnd - } - - fun timeframeStart(timeframeStart: OffsetDateTime) = - timeframeStart(JsonField.of(timeframeStart)) - - fun timeframeStart(timeframeStart: JsonField) = apply { - this.timeframeStart = timeframeStart - } - - /** - * A boolean [computed property](/extensibility/advanced-metrics#computed-properties) used - * to filter the set of events to deprecate - */ - fun deprecationFilter(deprecationFilter: String?) = - deprecationFilter(JsonField.ofNullable(deprecationFilter)) - - /** - * A boolean [computed property](/extensibility/advanced-metrics#computed-properties) used - * to filter the set of events to deprecate - */ - fun deprecationFilter(deprecationFilter: Optional) = - deprecationFilter(deprecationFilter.orElse(null)) - - /** - * A boolean [computed property](/extensibility/advanced-metrics#computed-properties) used - * to filter the set of events to deprecate - */ - fun deprecationFilter(deprecationFilter: JsonField) = apply { - this.deprecationFilter = deprecationFilter - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): EventBackfillRevertResponse = - EventBackfillRevertResponse( - checkRequired("id", id), - checkRequired("closeTime", closeTime), - checkRequired("createdAt", createdAt), - checkRequired("customerId", customerId), - checkRequired("eventsIngested", eventsIngested), - checkRequired("replaceExistingEvents", replaceExistingEvents), - checkRequired("revertedAt", revertedAt), - checkRequired("status", status), - checkRequired("timeframeEnd", timeframeEnd), - checkRequired("timeframeStart", timeframeStart), - deprecationFilter, - additionalProperties.toImmutable(), - ) - } - - /** The status of the backfill. */ - 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 PENDING = of("pending") - - @JvmField val REFLECTED = of("reflected") - - @JvmField val PENDING_REVERT = of("pending_revert") - - @JvmField val REVERTED = of("reverted") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - PENDING, - REFLECTED, - PENDING_REVERT, - REVERTED, - } - - /** - * 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 { - PENDING, - REFLECTED, - PENDING_REVERT, - REVERTED, - /** 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) { - PENDING -> Value.PENDING - REFLECTED -> Value.REFLECTED - PENDING_REVERT -> Value.PENDING_REVERT - REVERTED -> Value.REVERTED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - PENDING -> Known.PENDING - REFLECTED -> Known.REFLECTED - PENDING_REVERT -> Known.PENDING_REVERT - REVERTED -> Known.REVERTED - 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EventBackfillRevertResponse && id == other.id && closeTime == other.closeTime && createdAt == other.createdAt && customerId == other.customerId && eventsIngested == other.eventsIngested && replaceExistingEvents == other.replaceExistingEvents && revertedAt == other.revertedAt && status == other.status && timeframeEnd == other.timeframeEnd && timeframeStart == other.timeframeStart && deprecationFilter == other.deprecationFilter && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, closeTime, createdAt, customerId, eventsIngested, replaceExistingEvents, revertedAt, status, timeframeEnd, timeframeStart, deprecationFilter, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "EventBackfillRevertResponse{id=$id, closeTime=$closeTime, createdAt=$createdAt, customerId=$customerId, eventsIngested=$eventsIngested, replaceExistingEvents=$replaceExistingEvents, revertedAt=$revertedAt, status=$status, timeframeEnd=$timeframeEnd, timeframeStart=$timeframeStart, deprecationFilter=$deprecationFilter, additionalProperties=$additionalProperties}" -} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventDeprecateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventDeprecateParams.kt index ec34b5814..129650d93 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventDeprecateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventDeprecateParams.kt @@ -81,6 +81,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [EventDeprecateParams]. + * + * The following fields are required: + * ```java + * .eventId() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 e90fb17ab..0ee6b2491 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 @@ -51,6 +51,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [EventDeprecateResponse]. + * + * The following fields are required: + * ```java + * .deprecated() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 a8be51d17..f6761b9f2 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 @@ -12,6 +12,7 @@ import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.Params +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams @@ -283,6 +284,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .events() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -306,14 +315,8 @@ private constructor( fun addEvent(event: Event) = apply { events = - (events ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(event) + (events ?: JsonField.of(mutableListOf())).also { + checkKnown("events", it).add(event) } } @@ -364,6 +367,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [EventIngestParams]. + * + * The following fields are required: + * ```java + * .events() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -652,6 +663,17 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Event]. + * + * The following fields are required: + * ```java + * .eventName() + * .idempotencyKey() + * .properties() + * .timestamp() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 268822f5f..5e0a0288c 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 @@ -11,6 +11,7 @@ import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.immutableEmptyMap import com.withorb.api.core.toImmutable @@ -75,6 +76,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [EventIngestResponse]. + * + * The following fields are required: + * ```java + * .validationFailed() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -113,14 +122,8 @@ private constructor( */ fun addValidationFailed(validationFailed: ValidationFailed) = apply { this.validationFailed = - (this.validationFailed ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(validationFailed) + (this.validationFailed ?: JsonField.of(mutableListOf())).also { + checkKnown("validationFailed", it).add(validationFailed) } } @@ -219,6 +222,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ValidationFailed]. + * + * The following fields are required: + * ```java + * .idempotencyKey() + * .validationErrors() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -263,14 +275,8 @@ private constructor( */ fun addValidationError(validationError: String) = apply { validationErrors = - (validationErrors ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(validationError) + (validationErrors ?: JsonField.of(mutableListOf())).also { + checkKnown("validationErrors", it).add(validationError) } } @@ -369,6 +375,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Debug]. + * + * The following fields are required: + * ```java + * .duplicate() + * .ingested() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -394,14 +409,8 @@ private constructor( fun addDuplicate(duplicate: String) = apply { this.duplicate = - (this.duplicate ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(duplicate) + (this.duplicate ?: JsonField.of(mutableListOf())).also { + checkKnown("duplicate", it).add(duplicate) } } @@ -413,14 +422,8 @@ private constructor( fun addIngested(ingested: String) = apply { this.ingested = - (this.ingested ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(ingested) + (this.ingested ?: JsonField.of(mutableListOf())).also { + checkKnown("ingested", it).add(ingested) } } 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 9cc3f0227..561d8acbb 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 @@ -12,6 +12,7 @@ import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.Params +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams @@ -176,6 +177,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .eventIds() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -218,14 +227,8 @@ private constructor( */ fun addEventId(eventId: String) = apply { eventIds = - (eventIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(eventId) + (eventIds ?: JsonField.of(mutableListOf())).also { + checkKnown("eventIds", it).add(eventId) } } @@ -323,6 +326,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [EventSearchParams]. + * + * The following fields are required: + * ```java + * .eventIds() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 130082ffb..7fa8aa810 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 @@ -11,6 +11,7 @@ import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.immutableEmptyMap import com.withorb.api.core.toImmutable @@ -51,6 +52,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [EventSearchResponse]. + * + * The following fields are required: + * ```java + * .data() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -74,14 +83,8 @@ private constructor( fun addData(data: Data) = apply { this.data = - (this.data ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(data) + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) } } @@ -235,6 +238,20 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .id() + * .customerId() + * .deprecated() + * .eventName() + * .externalCustomerId() + * .properties() + * .timestamp() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 b731a8a35..549a2fccb 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 @@ -218,6 +218,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .eventName() + * .properties() + * .timestamp() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -349,6 +359,17 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [EventUpdateParams]. + * + * The following fields are required: + * ```java + * .eventId() + * .eventName() + * .properties() + * .timestamp() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 59fea7c77..9039a88ce 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 @@ -51,6 +51,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [EventUpdateResponse]. + * + * The following fields are required: + * ```java + * .amended() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventVolumeListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventVolumeListParams.kt index 13b869b1c..7197ada77 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventVolumeListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventVolumeListParams.kt @@ -89,6 +89,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [EventVolumeListParams]. + * + * The following fields are required: + * ```java + * .timeframeStart() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 80ead4708..d8cd8aa8e 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 @@ -11,6 +11,7 @@ import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.immutableEmptyMap import com.withorb.api.core.toImmutable @@ -50,6 +51,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [EventVolumes]. + * + * The following fields are required: + * ```java + * .data() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -73,14 +82,8 @@ private constructor( fun addData(data: Data) = apply { this.data = - (this.data ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(data) + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) } } @@ -170,6 +173,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .count() + * .timeframeEnd() + * .timeframeStart() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/FixedFeeQuantityScheduleEntryModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/FixedFeeQuantityScheduleEntryModel.kt new file mode 100644 index 000000000..c374b377a --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/FixedFeeQuantityScheduleEntryModel.kt @@ -0,0 +1,178 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class FixedFeeQuantityScheduleEntryModel +@JsonCreator +private constructor( + @JsonProperty("end_date") + @ExcludeMissing + private val endDate: JsonField = JsonMissing.of(), + @JsonProperty("price_id") + @ExcludeMissing + private val priceId: JsonField = JsonMissing.of(), + @JsonProperty("quantity") + @ExcludeMissing + private val quantity: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + private val startDate: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) + + fun priceId(): String = priceId.getRequired("price_id") + + fun quantity(): Double = quantity.getRequired("quantity") + + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity + + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): FixedFeeQuantityScheduleEntryModel = apply { + if (validated) { + return@apply + } + + endDate() + priceId() + quantity() + startDate() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [FixedFeeQuantityScheduleEntryModel]. + * + * The following fields are required: + * ```java + * .endDate() + * .priceId() + * .quantity() + * .startDate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FixedFeeQuantityScheduleEntryModel]. */ + class Builder internal constructor() { + + private var endDate: JsonField? = null + private var priceId: JsonField? = null + private var quantity: JsonField? = null + private var startDate: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fixedFeeQuantityScheduleEntryModel: FixedFeeQuantityScheduleEntryModel) = + apply { + endDate = fixedFeeQuantityScheduleEntryModel.endDate + priceId = fixedFeeQuantityScheduleEntryModel.priceId + quantity = fixedFeeQuantityScheduleEntryModel.quantity + startDate = fixedFeeQuantityScheduleEntryModel.startDate + additionalProperties = + fixedFeeQuantityScheduleEntryModel.additionalProperties.toMutableMap() + } + + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) + + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + 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) + } + + fun build(): FixedFeeQuantityScheduleEntryModel = + FixedFeeQuantityScheduleEntryModel( + checkRequired("endDate", endDate), + checkRequired("priceId", priceId), + checkRequired("quantity", quantity), + checkRequired("startDate", startDate), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FixedFeeQuantityScheduleEntryModel && endDate == other.endDate && priceId == other.priceId && quantity == other.quantity && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(endDate, priceId, quantity, startDate, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FixedFeeQuantityScheduleEntryModel{endDate=$endDate, priceId=$priceId, quantity=$quantity, startDate=$startDate, additionalProperties=$additionalProperties}" +} 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 37afae5ce..d21106c2c 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 @@ -6,30 +6,20 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.immutableEmptyMap import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import java.util.Objects import java.util.Optional -import kotlin.jvm.optionals.getOrNull /** * An [`Invoice`](/core-concepts#invoice) is a fundamental billing entity, representing the request @@ -48,29 +38,29 @@ private constructor( private val amountDue: JsonField = JsonMissing.of(), @JsonProperty("auto_collection") @ExcludeMissing - private val autoCollection: JsonField = JsonMissing.of(), + private val autoCollection: JsonField = JsonMissing.of(), @JsonProperty("billing_address") @ExcludeMissing - private val billingAddress: JsonField = JsonMissing.of(), + private val billingAddress: JsonField = JsonMissing.of(), @JsonProperty("created_at") @ExcludeMissing private val createdAt: JsonField = JsonMissing.of(), @JsonProperty("credit_notes") @ExcludeMissing - private val creditNotes: JsonField> = JsonMissing.of(), + private val creditNotes: JsonField> = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing private val currency: JsonField = JsonMissing.of(), @JsonProperty("customer") @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), + private val customer: JsonField = JsonMissing.of(), @JsonProperty("customer_balance_transactions") @ExcludeMissing - private val customerBalanceTransactions: JsonField> = + private val customerBalanceTransactions: JsonField> = JsonMissing.of(), @JsonProperty("customer_tax_id") @ExcludeMissing - private val customerTaxId: JsonField = JsonMissing.of(), + private val customerTaxId: JsonField = JsonMissing.of(), @JsonProperty("discount") @ExcludeMissing private val discount: JsonValue = JsonMissing.of(), @JsonProperty("discounts") @ExcludeMissing @@ -104,10 +94,10 @@ private constructor( private val issuedAt: JsonField = JsonMissing.of(), @JsonProperty("line_items") @ExcludeMissing - private val lineItems: JsonField> = JsonMissing.of(), + private val lineItems: JsonField> = JsonMissing.of(), @JsonProperty("maximum") @ExcludeMissing - private val maximum: JsonField = JsonMissing.of(), + private val maximum: JsonField = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing private val maximumAmount: JsonField = JsonMissing.of(), @@ -117,7 +107,7 @@ private constructor( private val metadata: JsonField = JsonMissing.of(), @JsonProperty("minimum") @ExcludeMissing - private val minimum: JsonField = JsonMissing.of(), + private val minimum: JsonField = JsonMissing.of(), @JsonProperty("minimum_amount") @ExcludeMissing private val minimumAmount: JsonField = JsonMissing.of(), @@ -126,7 +116,7 @@ private constructor( private val paidAt: JsonField = JsonMissing.of(), @JsonProperty("payment_attempts") @ExcludeMissing - private val paymentAttempts: JsonField> = JsonMissing.of(), + private val paymentAttempts: JsonField> = JsonMissing.of(), @JsonProperty("payment_failed_at") @ExcludeMissing private val paymentFailedAt: JsonField = JsonMissing.of(), @@ -138,13 +128,13 @@ private constructor( private val scheduledIssueAt: JsonField = JsonMissing.of(), @JsonProperty("shipping_address") @ExcludeMissing - private val shippingAddress: JsonField = JsonMissing.of(), + private val shippingAddress: JsonField = JsonMissing.of(), @JsonProperty("status") @ExcludeMissing private val status: JsonField = JsonMissing.of(), @JsonProperty("subscription") @ExcludeMissing - private val subscription: JsonField = JsonMissing.of(), + private val subscription: JsonField = JsonMissing.of(), @JsonProperty("subtotal") @ExcludeMissing private val subtotal: JsonField = JsonMissing.of(), @@ -169,23 +159,23 @@ private constructor( */ fun amountDue(): String = amountDue.getRequired("amount_due") - fun autoCollection(): AutoCollection = autoCollection.getRequired("auto_collection") + fun autoCollection(): AutoCollectionModel = autoCollection.getRequired("auto_collection") - fun billingAddress(): Optional = + fun billingAddress(): Optional = Optional.ofNullable(billingAddress.getNullable("billing_address")) /** The creation time of the resource in Orb. */ fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") /** A list of credit notes associated with the invoice */ - fun creditNotes(): List = creditNotes.getRequired("credit_notes") + fun creditNotes(): List = creditNotes.getRequired("credit_notes") /** An ISO 4217 currency string or `credits` */ fun currency(): String = currency.getRequired("currency") - fun customer(): Customer = customer.getRequired("customer") + fun customer(): CustomerMinifiedModel = customer.getRequired("customer") - fun customerBalanceTransactions(): List = + fun customerBalanceTransactions(): List = customerBalanceTransactions.getRequired("customer_balance_transactions") /** @@ -294,7 +284,7 @@ private constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - fun customerTaxId(): Optional = + fun customerTaxId(): Optional = Optional.ofNullable(customerTaxId.getNullable("customer_tax_id")) /** @@ -357,9 +347,9 @@ private constructor( Optional.ofNullable(issuedAt.getNullable("issued_at")) /** The breakdown of prices in this invoice. */ - fun lineItems(): List = lineItems.getRequired("line_items") + fun lineItems(): List = lineItems.getRequired("line_items") - fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) @@ -374,7 +364,7 @@ private constructor( */ fun metadata(): Metadata = metadata.getRequired("metadata") - fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) fun minimumAmount(): Optional = Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) @@ -383,7 +373,8 @@ private constructor( fun paidAt(): Optional = Optional.ofNullable(paidAt.getNullable("paid_at")) /** A list of payment attempts associated with the invoice */ - fun paymentAttempts(): List = paymentAttempts.getRequired("payment_attempts") + 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 @@ -407,12 +398,12 @@ private constructor( fun scheduledIssueAt(): Optional = Optional.ofNullable(scheduledIssueAt.getNullable("scheduled_issue_at")) - fun shippingAddress(): Optional = + fun shippingAddress(): Optional = Optional.ofNullable(shippingAddress.getNullable("shipping_address")) fun status(): Status = status.getRequired("status") - fun subscription(): Optional = + fun subscription(): Optional = Optional.ofNullable(subscription.getNullable("subscription")) /** The total before any discounts and minimums are applied. */ @@ -449,11 +440,11 @@ private constructor( @JsonProperty("auto_collection") @ExcludeMissing - fun _autoCollection(): JsonField = autoCollection + fun _autoCollection(): JsonField = autoCollection @JsonProperty("billing_address") @ExcludeMissing - fun _billingAddress(): JsonField = billingAddress + fun _billingAddress(): JsonField = billingAddress /** The creation time of the resource in Orb. */ @JsonProperty("created_at") @@ -463,16 +454,18 @@ private constructor( /** A list of credit notes associated with the invoice */ @JsonProperty("credit_notes") @ExcludeMissing - fun _creditNotes(): JsonField> = creditNotes + fun _creditNotes(): JsonField> = creditNotes /** An ISO 4217 currency string or `credits` */ @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer + @JsonProperty("customer") + @ExcludeMissing + fun _customer(): JsonField = customer @JsonProperty("customer_balance_transactions") @ExcludeMissing - fun _customerBalanceTransactions(): JsonField> = + fun _customerBalanceTransactions(): JsonField> = customerBalanceTransactions /** @@ -583,7 +576,7 @@ private constructor( */ @JsonProperty("customer_tax_id") @ExcludeMissing - fun _customerTaxId(): JsonField = customerTaxId + fun _customerTaxId(): JsonField = customerTaxId @JsonProperty("discounts") @ExcludeMissing @@ -648,9 +641,9 @@ private constructor( /** The breakdown of prices in this invoice. */ @JsonProperty("line_items") @ExcludeMissing - fun _lineItems(): JsonField> = lineItems + fun _lineItems(): JsonField> = lineItems - @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum @JsonProperty("maximum_amount") @ExcludeMissing @@ -666,7 +659,7 @@ private constructor( */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum @JsonProperty("minimum_amount") @ExcludeMissing @@ -678,7 +671,7 @@ private constructor( /** A list of payment attempts associated with the invoice */ @JsonProperty("payment_attempts") @ExcludeMissing - fun _paymentAttempts(): JsonField> = paymentAttempts + fun _paymentAttempts(): JsonField> = paymentAttempts /** * If payment was attempted on this invoice but failed, this will be the time of the most recent @@ -707,13 +700,13 @@ private constructor( @JsonProperty("shipping_address") @ExcludeMissing - fun _shippingAddress(): JsonField = shippingAddress + fun _shippingAddress(): JsonField = shippingAddress @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status @JsonProperty("subscription") @ExcludeMissing - fun _subscription(): JsonField = subscription + fun _subscription(): JsonField = subscription /** The total before any discounts and minimums are applied. */ @JsonProperty("subtotal") @ExcludeMissing fun _subtotal(): JsonField = subtotal @@ -799,6 +792,54 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Invoice]. + * + * The following fields are required: + * ```java + * .id() + * .amountDue() + * .autoCollection() + * .billingAddress() + * .createdAt() + * .creditNotes() + * .currency() + * .customer() + * .customerBalanceTransactions() + * .customerTaxId() + * .discount() + * .discounts() + * .dueDate() + * .eligibleToIssueAt() + * .hostedInvoiceUrl() + * .invoiceDate() + * .invoiceNumber() + * .invoicePdf() + * .invoiceSource() + * .issueFailedAt() + * .issuedAt() + * .lineItems() + * .maximum() + * .maximumAmount() + * .memo() + * .metadata() + * .minimum() + * .minimumAmount() + * .paidAt() + * .paymentAttempts() + * .paymentFailedAt() + * .paymentStartedAt() + * .scheduledIssueAt() + * .shippingAddress() + * .status() + * .subscription() + * .subtotal() + * .syncFailedAt() + * .total() + * .voidedAt() + * .willAutoIssue() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -807,16 +848,16 @@ private constructor( private var id: JsonField? = null private var amountDue: JsonField? = null - private var autoCollection: JsonField? = null - private var billingAddress: JsonField? = null + private var autoCollection: JsonField? = null + private var billingAddress: JsonField? = null private var createdAt: JsonField? = null - private var creditNotes: JsonField>? = null + private var creditNotes: JsonField>? = null private var currency: JsonField? = null - private var customer: JsonField? = null + private var customer: JsonField? = null private var customerBalanceTransactions: - JsonField>? = + JsonField>? = null - private var customerTaxId: JsonField? = null + private var customerTaxId: JsonField? = null private var discount: JsonValue? = null private var discounts: JsonField>? = null private var dueDate: JsonField? = null @@ -828,21 +869,21 @@ private constructor( private var invoiceSource: JsonField? = null private var issueFailedAt: JsonField? = null private var issuedAt: JsonField? = null - private var lineItems: JsonField>? = null - private var maximum: JsonField? = null + private var lineItems: JsonField>? = null + private var maximum: JsonField? = null private var maximumAmount: JsonField? = null private var memo: JsonField? = null private var metadata: JsonField? = null - private var minimum: JsonField? = null + private var minimum: JsonField? = null private var minimumAmount: JsonField? = null private var paidAt: JsonField? = null - private var paymentAttempts: 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 shippingAddress: JsonField? = null private var status: JsonField? = null - private var subscription: JsonField? = null + private var subscription: JsonField? = null private var subtotal: JsonField? = null private var syncFailedAt: JsonField? = null private var total: JsonField? = null @@ -913,20 +954,20 @@ private constructor( */ fun amountDue(amountDue: JsonField) = apply { this.amountDue = amountDue } - fun autoCollection(autoCollection: AutoCollection) = + fun autoCollection(autoCollection: AutoCollectionModel) = autoCollection(JsonField.of(autoCollection)) - fun autoCollection(autoCollection: JsonField) = apply { + fun autoCollection(autoCollection: JsonField) = apply { this.autoCollection = autoCollection } - fun billingAddress(billingAddress: BillingAddress?) = + fun billingAddress(billingAddress: AddressModel?) = billingAddress(JsonField.ofNullable(billingAddress)) - fun billingAddress(billingAddress: Optional) = + fun billingAddress(billingAddress: Optional) = billingAddress(billingAddress.orElse(null)) - fun billingAddress(billingAddress: JsonField) = apply { + fun billingAddress(billingAddress: JsonField) = apply { this.billingAddress = billingAddress } @@ -937,24 +978,19 @@ private constructor( 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)) + fun creditNotes(creditNotes: List) = + creditNotes(JsonField.of(creditNotes)) /** A list of credit notes associated with the invoice */ - fun creditNotes(creditNotes: JsonField>) = apply { + fun creditNotes(creditNotes: JsonField>) = apply { this.creditNotes = creditNotes.map { it.toMutableList() } } /** A list of credit notes associated with the invoice */ - fun addCreditNote(creditNote: CreditNote) = apply { + fun addCreditNote(creditNote: CreditNoteSummaryModel) = apply { creditNotes = - (creditNotes ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(creditNote) + (creditNotes ?: JsonField.of(mutableListOf())).also { + checkKnown("creditNotes", it).add(creditNote) } } @@ -964,34 +1000,31 @@ private constructor( /** An ISO 4217 currency string or `credits` */ fun currency(currency: JsonField) = apply { this.currency = currency } - fun customer(customer: Customer) = customer(JsonField.of(customer)) + fun customer(customer: CustomerMinifiedModel) = customer(JsonField.of(customer)) - fun customer(customer: JsonField) = apply { this.customer = customer } + fun customer(customer: JsonField) = apply { + this.customer = customer + } fun customerBalanceTransactions( - customerBalanceTransactions: List + customerBalanceTransactions: List ) = customerBalanceTransactions(JsonField.of(customerBalanceTransactions)) fun customerBalanceTransactions( - customerBalanceTransactions: JsonField> + customerBalanceTransactions: JsonField> ) = apply { this.customerBalanceTransactions = customerBalanceTransactions.map { it.toMutableList() } } - fun addCustomerBalanceTransaction(customerBalanceTransaction: CustomerBalanceTransaction) = - apply { - customerBalanceTransactions = - (customerBalanceTransactions ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(customerBalanceTransaction) - } - } + fun addCustomerBalanceTransaction( + customerBalanceTransaction: CustomerBalanceTransactionModel + ) = 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 @@ -1099,7 +1132,7 @@ private constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - fun customerTaxId(customerTaxId: CustomerTaxId?) = + fun customerTaxId(customerTaxId: CustomerTaxIdModel?) = customerTaxId(JsonField.ofNullable(customerTaxId)) /** @@ -1208,7 +1241,7 @@ private constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - fun customerTaxId(customerTaxId: Optional) = + fun customerTaxId(customerTaxId: Optional) = customerTaxId(customerTaxId.orElse(null)) /** @@ -1317,7 +1350,7 @@ private constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - fun customerTaxId(customerTaxId: JsonField) = apply { + fun customerTaxId(customerTaxId: JsonField) = apply { this.customerTaxId = customerTaxId } @@ -1337,14 +1370,8 @@ private constructor( fun addDiscount(discount: InvoiceLevelDiscount) = apply { discounts = - (discounts ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(discount) + (discounts ?: JsonField.of(mutableListOf())).also { + checkKnown("discounts", it).add(discount) } } @@ -1506,32 +1533,26 @@ private constructor( fun issuedAt(issuedAt: JsonField) = apply { this.issuedAt = issuedAt } /** The breakdown of prices in this invoice. */ - fun lineItems(lineItems: List) = lineItems(JsonField.of(lineItems)) + fun lineItems(lineItems: List) = lineItems(JsonField.of(lineItems)) /** The breakdown of prices in this invoice. */ - fun lineItems(lineItems: JsonField>) = apply { + fun lineItems(lineItems: JsonField>) = apply { this.lineItems = lineItems.map { it.toMutableList() } } /** The breakdown of prices in this invoice. */ - fun addLineItem(lineItem: LineItem) = apply { + fun addLineItem(lineItem: InvoiceLineItemModel) = apply { lineItems = - (lineItems ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(lineItem) + (lineItems ?: JsonField.of(mutableListOf())).also { + checkKnown("lineItems", it).add(lineItem) } } - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) - fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } fun maximumAmount(maximumAmount: String?) = maximumAmount(JsonField.ofNullable(maximumAmount)) @@ -1566,11 +1587,11 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) - fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } fun minimumAmount(minimumAmount: String?) = minimumAmount(JsonField.ofNullable(minimumAmount)) @@ -1598,25 +1619,19 @@ private constructor( fun paidAt(paidAt: JsonField) = apply { this.paidAt = paidAt } /** A list of payment attempts associated with the invoice */ - fun paymentAttempts(paymentAttempts: List) = + fun paymentAttempts(paymentAttempts: List) = paymentAttempts(JsonField.of(paymentAttempts)) /** A list of payment attempts associated with the invoice */ - fun paymentAttempts(paymentAttempts: JsonField>) = apply { + fun paymentAttempts(paymentAttempts: JsonField>) = apply { this.paymentAttempts = paymentAttempts.map { it.toMutableList() } } /** A list of payment attempts associated with the invoice */ - fun addPaymentAttempt(paymentAttempt: PaymentAttempt) = apply { + fun addPaymentAttempt(paymentAttempt: PaymentAttemptModel) = apply { paymentAttempts = - (paymentAttempts ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(paymentAttempt) + (paymentAttempts ?: JsonField.of(mutableListOf())).also { + checkKnown("paymentAttempts", it).add(paymentAttempt) } } @@ -1689,13 +1704,13 @@ private constructor( this.scheduledIssueAt = scheduledIssueAt } - fun shippingAddress(shippingAddress: ShippingAddress?) = + fun shippingAddress(shippingAddress: AddressModel?) = shippingAddress(JsonField.ofNullable(shippingAddress)) - fun shippingAddress(shippingAddress: Optional) = + fun shippingAddress(shippingAddress: Optional) = shippingAddress(shippingAddress.orElse(null)) - fun shippingAddress(shippingAddress: JsonField) = apply { + fun shippingAddress(shippingAddress: JsonField) = apply { this.shippingAddress = shippingAddress } @@ -1703,13 +1718,13 @@ private constructor( fun status(status: JsonField) = apply { this.status = status } - fun subscription(subscription: Subscription?) = + fun subscription(subscription: SubscriptionMinifiedModel?) = subscription(JsonField.ofNullable(subscription)) - fun subscription(subscription: Optional) = + fun subscription(subscription: Optional) = subscription(subscription.orElse(null)) - fun subscription(subscription: JsonField) = apply { + fun subscription(subscription: JsonField) = apply { this.subscription = subscription } @@ -1847,327 +1862,137 @@ private constructor( ) } - @NoAutoDetect - class AutoCollection - @JsonCreator - private constructor( - @JsonProperty("enabled") - @ExcludeMissing - private val enabled: JsonField = JsonMissing.of(), - @JsonProperty("next_attempt_at") - @ExcludeMissing - private val nextAttemptAt: JsonField = JsonMissing.of(), - @JsonProperty("num_attempts") - @ExcludeMissing - private val numAttempts: JsonField = JsonMissing.of(), - @JsonProperty("previously_attempted_at") - @ExcludeMissing - private val previouslyAttemptedAt: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** True only if auto-collection is enabled for this invoice. */ - fun enabled(): Optional = Optional.ofNullable(enabled.getNullable("enabled")) - - /** - * If the invoice is scheduled for auto-collection, this field will reflect when the next - * attempt will occur. If dunning has been exhausted, or auto-collection is not enabled for - * this invoice, this field will be `null`. - */ - fun nextAttemptAt(): Optional = - Optional.ofNullable(nextAttemptAt.getNullable("next_attempt_at")) - - /** Number of auto-collection payment attempts. */ - fun numAttempts(): Optional = - Optional.ofNullable(numAttempts.getNullable("num_attempts")) - - /** - * If Orb has ever attempted payment auto-collection for this invoice, this field will - * reflect when that attempt occurred. In conjunction with `next_attempt_at`, this can be - * used to tell whether the invoice is currently in dunning (that is, - * `previously_attempted_at` is non-null, and `next_attempt_time` is non-null), or if - * dunning has been exhausted (`previously_attempted_at` is non-null, but - * `next_attempt_time` is null). - */ - fun previouslyAttemptedAt(): Optional = - Optional.ofNullable(previouslyAttemptedAt.getNullable("previously_attempted_at")) - - /** True only if auto-collection is enabled for this invoice. */ - @JsonProperty("enabled") @ExcludeMissing fun _enabled(): JsonField = enabled + class InvoiceSource @JsonCreator private constructor(private val value: JsonField) : + Enum { /** - * 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`. + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. */ - @JsonProperty("next_attempt_at") - @ExcludeMissing - fun _nextAttemptAt(): JsonField = nextAttemptAt - - /** Number of auto-collection payment attempts. */ - @JsonProperty("num_attempts") - @ExcludeMissing - fun _numAttempts(): JsonField = numAttempts + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** - * 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). - */ - @JsonProperty("previously_attempted_at") - @ExcludeMissing - fun _previouslyAttemptedAt(): JsonField = previouslyAttemptedAt + companion object { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + @JvmField val SUBSCRIPTION = of("subscription") - private var validated: Boolean = false + @JvmField val PARTIAL = of("partial") - fun validate(): AutoCollection = apply { - if (validated) { - return@apply - } + @JvmField val ONE_OFF = of("one_off") - enabled() - nextAttemptAt() - numAttempts() - previouslyAttemptedAt() - validated = true + @JvmStatic fun of(value: String) = InvoiceSource(JsonField.of(value)) } - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() + /** An enum containing [InvoiceSource]'s known values. */ + enum class Known { + SUBSCRIPTION, + PARTIAL, + ONE_OFF, } - /** 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)) - - /** True only if auto-collection is enabled for this invoice. */ - fun enabled(enabled: Boolean) = enabled(enabled as Boolean?) - - /** True only if auto-collection is enabled for this invoice. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun enabled(enabled: Optional) = enabled(enabled.orElse(null) as Boolean?) - - /** True only if auto-collection is enabled for this invoice. */ - 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)) - - /** - * 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: Optional) = - nextAttemptAt(nextAttemptAt.orElse(null)) - - /** - * 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: JsonField) = apply { - this.nextAttemptAt = nextAttemptAt - } - - /** Number of auto-collection payment attempts. */ - fun numAttempts(numAttempts: Long?) = numAttempts(JsonField.ofNullable(numAttempts)) - - /** Number of auto-collection payment attempts. */ - fun numAttempts(numAttempts: Long) = numAttempts(numAttempts as Long?) - - /** Number of auto-collection payment attempts. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun numAttempts(numAttempts: Optional) = - numAttempts(numAttempts.orElse(null) as Long?) - - /** Number of auto-collection payment attempts. */ - 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)) - - /** - * 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: Optional) = - previouslyAttemptedAt(previouslyAttemptedAt.orElse(null)) - + /** + * 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, /** - * 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). + * An enum member indicating that [InvoiceSource] was instantiated with an unknown + * 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) - } + _UNKNOWN, + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SUBSCRIPTION -> Value.SUBSCRIPTION + PARTIAL -> Value.PARTIAL + ONE_OFF -> Value.ONE_OFF + else -> Value._UNKNOWN } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + SUBSCRIPTION -> Known.SUBSCRIPTION + PARTIAL -> Known.PARTIAL + ONE_OFF -> Known.ONE_OFF + else -> throw OrbInvalidDataException("Unknown InvoiceSource: $value") } - fun build(): AutoCollection = - AutoCollection( - checkRequired("enabled", enabled), - checkRequired("nextAttemptAt", nextAttemptAt), - checkRequired("numAttempts", numAttempts), - checkRequired("previouslyAttemptedAt", previouslyAttemptedAt), - additionalProperties.toImmutable(), - ) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is AutoCollection && enabled == other.enabled && nextAttemptAt == other.nextAttemptAt && numAttempts == other.numAttempts && previouslyAttemptedAt == other.previouslyAttemptedAt && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InvoiceSource && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(enabled, nextAttemptAt, numAttempts, previouslyAttemptedAt, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "AutoCollection{enabled=$enabled, nextAttemptAt=$nextAttemptAt, numAttempts=$numAttempts, previouslyAttemptedAt=$previouslyAttemptedAt, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } + /** + * User specified key-value pairs for the resource. If not present, this defaults to an empty + * dictionary. Individual keys can be removed by setting the value to `null`, and the entire + * metadata mapping can be cleared by setting `metadata` to `null`. + */ @NoAutoDetect - class BillingAddress + class Metadata @JsonCreator private constructor( - @JsonProperty("city") - @ExcludeMissing - private val city: JsonField = JsonMissing.of(), - @JsonProperty("country") - @ExcludeMissing - private val country: JsonField = JsonMissing.of(), - @JsonProperty("line1") - @ExcludeMissing - private val line1: JsonField = JsonMissing.of(), - @JsonProperty("line2") - @ExcludeMissing - private val line2: JsonField = JsonMissing.of(), - @JsonProperty("postal_code") - @ExcludeMissing - private val postalCode: JsonField = JsonMissing.of(), - @JsonProperty("state") - @ExcludeMissing - private val state: JsonField = JsonMissing.of(), @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { - fun city(): Optional = Optional.ofNullable(city.getNullable("city")) - - fun country(): Optional = Optional.ofNullable(country.getNullable("country")) - - fun line1(): Optional = Optional.ofNullable(line1.getNullable("line1")) - - fun line2(): Optional = Optional.ofNullable(line2.getNullable("line2")) - - fun postalCode(): Optional = - Optional.ofNullable(postalCode.getNullable("postal_code")) - - fun state(): Optional = Optional.ofNullable(state.getNullable("state")) - - @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city - - @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country - - @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField = line1 - - @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 - - @JsonProperty("postal_code") - @ExcludeMissing - fun _postalCode(): JsonField = postalCode - - @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties private var validated: Boolean = false - fun validate(): BillingAddress = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } - city() - country() - line1() - line2() - postalCode() - state() validated = true } @@ -2175,67 +2000,20 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [BillingAddress]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { - private var city: JsonField? = null - private var country: JsonField? = null - private var line1: JsonField? = null - private var line2: JsonField? = null - private var postalCode: JsonField? = null - private var state: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(billingAddress: BillingAddress) = apply { - city = billingAddress.city - country = billingAddress.country - line1 = billingAddress.line1 - line2 = billingAddress.line2 - postalCode = billingAddress.postalCode - state = billingAddress.state - additionalProperties = billingAddress.additionalProperties.toMutableMap() + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - fun city(city: String?) = city(JsonField.ofNullable(city)) - - fun city(city: Optional) = city(city.orElse(null)) - - fun city(city: JsonField) = apply { this.city = city } - - fun country(country: String?) = country(JsonField.ofNullable(country)) - - fun country(country: Optional) = country(country.orElse(null)) - - fun country(country: JsonField) = apply { this.country = country } - - fun line1(line1: String?) = line1(JsonField.ofNullable(line1)) - - fun line1(line1: Optional) = line1(line1.orElse(null)) - - fun line1(line1: JsonField) = apply { this.line1 = line1 } - - fun line2(line2: String?) = line2(JsonField.ofNullable(line2)) - - fun line2(line2: Optional) = line2(line2.orElse(null)) - - fun line2(line2: JsonField) = apply { this.line2 = line2 } - - fun postalCode(postalCode: String?) = postalCode(JsonField.ofNullable(postalCode)) - - fun postalCode(postalCode: Optional) = postalCode(postalCode.orElse(null)) - - fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode } - - fun state(state: String?) = state(JsonField.ofNullable(state)) - - fun state(state: Optional) = state(state.orElse(null)) - - fun state(state: JsonField) = apply { this.state = state } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -2255,16 +2033,7 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): BillingAddress = - BillingAddress( - checkRequired("city", city), - checkRequired("country", country), - checkRequired("line1", line1), - checkRequired("line2", line2), - checkRequired("postalCode", postalCode), - checkRequired("state", state), - additionalProperties.toImmutable(), - ) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -2272,9075 +2041,39 @@ private constructor( return true } - return /* spotless:off */ other is BillingAddress && city == other.city && country == other.country && line1 == other.line1 && line2 == other.line2 && postalCode == other.postalCode && state == other.state && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(city, country, line1, line2, postalCode, state, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode - override fun toString() = - "BillingAddress{city=$city, country=$country, line1=$line1, line2=$line2, postalCode=$postalCode, state=$state, additionalProperties=$additionalProperties}" + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - @NoAutoDetect - class CreditNote - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("credit_note_number") - @ExcludeMissing - private val creditNoteNumber: JsonField = JsonMissing.of(), - @JsonProperty("memo") - @ExcludeMissing - private val memo: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonProperty("total") - @ExcludeMissing - private val total: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonProperty("voided_at") - @ExcludeMissing - private val voidedAt: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { - fun id(): String = id.getRequired("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 - fun creditNoteNumber(): String = creditNoteNumber.getRequired("credit_note_number") + companion object { - /** An optional memo supplied on the credit note. */ - fun memo(): Optional = Optional.ofNullable(memo.getNullable("memo")) + @JvmField val ISSUED = of("issued") - fun reason(): String = reason.getRequired("reason") + @JvmField val PAID = of("paid") - fun total(): String = total.getRequired("total") + @JvmField val SYNCED = of("synced") - 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. - */ - fun voidedAt(): Optional = - Optional.ofNullable(voidedAt.getNullable("voided_at")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("credit_note_number") - @ExcludeMissing - fun _creditNoteNumber(): JsonField = creditNoteNumber - - /** An optional memo supplied on the credit note. */ - @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo - - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonProperty("total") @ExcludeMissing fun _total(): JsonField = total - - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - /** - * If the credit note has a status of `void`, this gives a timestamp when the credit note - * was voided. - */ - @JsonProperty("voided_at") - @ExcludeMissing - fun _voidedAt(): JsonField = voidedAt - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditNote = apply { - if (validated) { - return@apply - } - - id() - creditNoteNumber() - memo() - reason() - total() - type() - voidedAt() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - fun id(id: JsonField) = apply { this.id = id } - - fun creditNoteNumber(creditNoteNumber: String) = - creditNoteNumber(JsonField.of(creditNoteNumber)) - - fun creditNoteNumber(creditNoteNumber: JsonField) = apply { - this.creditNoteNumber = creditNoteNumber - } - - /** An optional memo supplied on the credit note. */ - fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) - - /** An optional memo supplied on the credit note. */ - fun memo(memo: Optional) = memo(memo.orElse(null)) - - /** An optional memo supplied on the credit note. */ - fun memo(memo: JsonField) = apply { this.memo = memo } - - fun reason(reason: String) = reason(JsonField.of(reason)) - - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun total(total: String) = total(JsonField.of(total)) - - fun total(total: JsonField) = apply { this.total = total } - - fun type(type: String) = type(JsonField.of(type)) - - 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)) - - /** - * If the credit note has a status of `void`, this gives a timestamp when the credit - * note was voided. - */ - fun voidedAt(voidedAt: Optional) = voidedAt(voidedAt.orElse(null)) - - /** - * If the credit note has a status of `void`, this gives a timestamp when the credit - * note was voided. - */ - 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) - } - - 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.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditNote && id == other.id && creditNoteNumber == other.creditNoteNumber && memo == other.memo && reason == other.reason && total == other.total && type == other.type && voidedAt == other.voidedAt && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, creditNoteNumber, memo, reason, total, type, voidedAt, additionalProperties) } - /* spotless:on */ - - 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}" - } - - @NoAutoDetect - class Customer - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("external_customer_id") - @ExcludeMissing - private val externalCustomerId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun externalCustomerId(): Optional = - Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("external_customer_id") - @ExcludeMissing - fun _externalCustomerId(): JsonField = externalCustomerId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Customer = apply { - if (validated) { - return@apply - } - - id() - externalCustomerId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Customer]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var externalCustomerId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customer: Customer) = apply { - id = customer.id - externalCustomerId = customer.externalCustomerId - additionalProperties = customer.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun externalCustomerId(externalCustomerId: String?) = - externalCustomerId(JsonField.ofNullable(externalCustomerId)) - - fun externalCustomerId(externalCustomerId: Optional) = - externalCustomerId(externalCustomerId.orElse(null)) - - fun externalCustomerId(externalCustomerId: JsonField) = apply { - this.externalCustomerId = externalCustomerId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Customer = - Customer( - checkRequired("id", id), - checkRequired("externalCustomerId", externalCustomerId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Customer && id == other.id && externalCustomerId == other.externalCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, externalCustomerId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Customer{id=$id, externalCustomerId=$externalCustomerId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class CustomerBalanceTransaction - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("action") - @ExcludeMissing - private val action: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("credit_note") - @ExcludeMissing - private val creditNote: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("ending_balance") - @ExcludeMissing - private val endingBalance: JsonField = JsonMissing.of(), - @JsonProperty("invoice") - @ExcludeMissing - private val invoice: JsonField = JsonMissing.of(), - @JsonProperty("starting_balance") - @ExcludeMissing - private val startingBalance: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** A unique id for this transaction. */ - fun id(): String = id.getRequired("id") - - fun action(): Action = action.getRequired("action") - - /** The value of the amount changed in the transaction. */ - fun amount(): String = amount.getRequired("amount") - - /** The creation time of this transaction. */ - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - fun creditNote(): Optional = - Optional.ofNullable(creditNote.getNullable("credit_note")) - - /** An optional description provided for manual customer balance adjustments. */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - /** - * The new value of the customer's balance prior to the transaction, in the customer's - * currency. - */ - fun endingBalance(): String = endingBalance.getRequired("ending_balance") - - fun invoice(): Optional = Optional.ofNullable(invoice.getNullable("invoice")) - - /** - * The original value of the customer's balance prior to the transaction, in the customer's - * currency. - */ - fun startingBalance(): String = startingBalance.getRequired("starting_balance") - - fun type(): Type = type.getRequired("type") - - /** A unique id for this transaction. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("action") @ExcludeMissing fun _action(): JsonField = action - - /** The value of the amount changed in the transaction. */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** The creation time of this transaction. */ - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - @JsonProperty("credit_note") - @ExcludeMissing - fun _creditNote(): JsonField = creditNote - - /** An optional description provided for manual customer balance adjustments. */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - /** - * The new value of the customer's balance prior to the transaction, in the customer's - * currency. - */ - @JsonProperty("ending_balance") - @ExcludeMissing - fun _endingBalance(): JsonField = endingBalance - - @JsonProperty("invoice") @ExcludeMissing fun _invoice(): JsonField = invoice - - /** - * The original value of the customer's balance prior to the transaction, in the customer's - * currency. - */ - @JsonProperty("starting_balance") - @ExcludeMissing - fun _startingBalance(): JsonField = startingBalance - - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CustomerBalanceTransaction = apply { - if (validated) { - return@apply - } - - id() - action() - amount() - createdAt() - creditNote().ifPresent { it.validate() } - description() - endingBalance() - invoice().ifPresent { it.validate() } - startingBalance() - type() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - /** A unique id for this transaction. */ - fun id(id: JsonField) = apply { this.id = id } - - fun action(action: Action) = action(JsonField.of(action)) - - 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)) - - /** The value of the amount changed in the transaction. */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** The creation time of this transaction. */ - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - /** The creation time of this transaction. */ - fun createdAt(createdAt: JsonField) = apply { - this.createdAt = createdAt - } - - fun creditNote(creditNote: CreditNote?) = creditNote(JsonField.ofNullable(creditNote)) - - fun creditNote(creditNote: Optional) = creditNote(creditNote.orElse(null)) - - 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)) - - /** An optional description provided for manual customer balance adjustments. */ - fun description(description: Optional) = description(description.orElse(null)) - - /** An optional description provided for manual customer balance adjustments. */ - 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)) - - /** - * The new value of the customer's balance prior to the transaction, in the customer's - * currency. - */ - fun endingBalance(endingBalance: JsonField) = apply { - this.endingBalance = endingBalance - } - - fun invoice(invoice: InnerInvoice?) = invoice(JsonField.ofNullable(invoice)) - - fun invoice(invoice: Optional) = invoice(invoice.orElse(null)) - - 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)) - - /** - * The original value of the customer's balance prior to the transaction, in the - * customer's currency. - */ - fun startingBalance(startingBalance: JsonField) = apply { - this.startingBalance = startingBalance - } - - fun type(type: Type) = type(JsonField.of(type)) - - 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) - } - - 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.toImmutable(), - ) - } - - 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") - - @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, - } - - /** - * 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, - /** - * 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 - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to 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 - 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Action && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class CreditNote - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The id of the Credit note */ - fun id(): String = id.getRequired("id") - - /** The id of the Credit note */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditNote = apply { - if (validated) { - return@apply - } - - id() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditNote]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditNote: CreditNote) = apply { - id = creditNote.id - additionalProperties = creditNote.additionalProperties.toMutableMap() - } - - /** The id of the Credit note */ - fun id(id: String) = id(JsonField.of(id)) - - /** The id of the Credit note */ - 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) - } - - fun build(): CreditNote = - CreditNote(checkRequired("id", id), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditNote && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditNote{id=$id, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class InnerInvoice - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The Invoice id */ - fun id(): String = id.getRequired("id") - - /** The Invoice id */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InnerInvoice = apply { - if (validated) { - return@apply - } - - id() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InnerInvoice]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(innerInvoice: InnerInvoice) = apply { - id = innerInvoice.id - additionalProperties = innerInvoice.additionalProperties.toMutableMap() - } - - /** The Invoice id */ - fun id(id: String) = id(JsonField.of(id)) - - /** The Invoice id */ - 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) - } - - fun build(): InnerInvoice = - InnerInvoice(checkRequired("id", id), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InnerInvoice && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InnerInvoice{id=$id, additionalProperties=$additionalProperties}" - } - - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CustomerBalanceTransaction && id == other.id && action == other.action && amount == other.amount && createdAt == other.createdAt && creditNote == other.creditNote && description == other.description && endingBalance == other.endingBalance && invoice == other.invoice && startingBalance == other.startingBalance && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, action, amount, createdAt, creditNote, description, endingBalance, invoice, startingBalance, type, additionalProperties) } - /* spotless:on */ - - 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}" - } - - /** - * 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 | - * |--------------------|------------|-------------------------------------------------------------------------------------------------------| - * |Andorra |`ad_nrt` |Andorran NRT Number | - * |Argentina |`ar_cuit` |Argentinian Tax ID Number | - * |Australia |`au_abn` |Australian Business Number (AU ABN) | - * |Australia |`au_arn` |Australian Taxation Office Reference Number | - * |Austria |`eu_vat` |European VAT Number | - * |Bahrain |`bh_vat` |Bahraini VAT Number | - * |Belgium |`eu_vat` |European VAT Number | - * |Bolivia |`bo_tin` |Bolivian Tax ID | - * |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 | - * |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) | - * |Chile |`cl_tin` |Chilean TIN | - * |China |`cn_tin` |Chinese Tax ID | - * |Colombia |`co_nit` |Colombian NIT Number | - * |Costa Rica |`cr_tin` |Costa Rican Tax ID | - * |Croatia |`eu_vat` |European VAT Number | - * |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 | - * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | - * |Finland |`eu_vat` |European VAT Number | - * |France |`eu_vat` |European VAT Number | - * |Georgia |`ge_vat` |Georgian VAT | - * |Germany |`eu_vat` |European VAT Number | - * |Greece |`eu_vat` |European VAT Number | - * |Hong Kong |`hk_br` |Hong Kong BR Number | - * |Hungary |`eu_vat` |European VAT Number | - * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | - * |Iceland |`is_vat` |Icelandic VAT | - * |India |`in_gst` |Indian GST Number | - * |Indonesia |`id_npwp` |Indonesian NPWP Number | - * |Ireland |`eu_vat` |European VAT Number | - * |Israel |`il_vat` |Israel VAT | - * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | - * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | - * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | - * |Latvia |`eu_vat` |European VAT Number | - * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | - * |Mexico |`mx_rfc` |Mexican RFC Number | - * |Netherlands |`eu_vat` |European VAT Number | - * |New Zealand |`nz_gst` |New Zealand GST Number | - * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | - * |Norway |`no_vat` |Norwegian VAT Number | - * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | - * |Oman |`om_vat` |Omani VAT Number | - * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | - * |Poland |`eu_vat` |European VAT Number | - * |Portugal |`eu_vat` |European VAT Number | - * |Romania |`eu_vat` |European VAT Number | - * |Romania |`ro_tin` |Romanian Tax ID Number | - * |Russia |`ru_inn` |Russian INN | - * |Russia |`ru_kpp` |Russian KPP | - * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | - * |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 | - * |Sweden |`eu_vat` |European VAT Number | - * |Switzerland |`ch_vat` |Switzerland VAT Number | - * |Taiwan |`tw_vat` |Taiwanese VAT | - * |Thailand |`th_vat` |Thai VAT | - * |Turkey |`tr_tin` |Turkish Tax Identification Number | - * |Ukraine |`ua_vat` |Ukrainian VAT | - * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | - * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | - * |United Kingdom |`gb_vat` |United Kingdom VAT Number | - * |United States |`us_ein` |United States EIN | - * |Uruguay |`uy_ruc` |Uruguayan RUC Number | - * |Venezuela |`ve_rif` |Venezuelan RIF Number | - * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | - */ - @NoAutoDetect - class CustomerTaxId - @JsonCreator - private constructor( - @JsonProperty("country") - @ExcludeMissing - private val country: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonProperty("value") - @ExcludeMissing - private val value: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun country(): Country = country.getRequired("country") - - fun type(): Type = type.getRequired("type") - - fun value(): String = value.getRequired("value") - - @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country - - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CustomerTaxId = apply { - if (validated) { - return@apply - } - - country() - type() - value() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CustomerTaxId]. */ - class Builder internal constructor() { - - private var country: JsonField? = null - private var type: JsonField? = null - private var value: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customerTaxId: CustomerTaxId) = apply { - country = customerTaxId.country - type = customerTaxId.type - value = customerTaxId.value - additionalProperties = customerTaxId.additionalProperties.toMutableMap() - } - - fun country(country: Country) = country(JsonField.of(country)) - - fun country(country: JsonField) = apply { this.country = country } - - fun type(type: Type) = type(JsonField.of(type)) - - fun type(type: JsonField) = apply { this.type = type } - - fun value(value: String) = value(JsonField.of(value)) - - fun value(value: JsonField) = apply { this.value = 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) - } - - fun build(): CustomerTaxId = - CustomerTaxId( - checkRequired("country", country), - checkRequired("type", type), - checkRequired("value", value), - additionalProperties.toImmutable(), - ) - } - - class Country @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val AD = of("AD") - - @JvmField val AE = of("AE") - - @JvmField val AR = of("AR") - - @JvmField val AT = of("AT") - - @JvmField val AU = of("AU") - - @JvmField val BE = of("BE") - - @JvmField val BG = of("BG") - - @JvmField val BH = of("BH") - - @JvmField val BO = of("BO") - - @JvmField val BR = of("BR") - - @JvmField val CA = of("CA") - - @JvmField val CH = of("CH") - - @JvmField val CL = of("CL") - - @JvmField val CN = of("CN") - - @JvmField val CO = of("CO") - - @JvmField val CR = of("CR") - - @JvmField val CY = of("CY") - - @JvmField val CZ = of("CZ") - - @JvmField val DE = of("DE") - - @JvmField val DK = of("DK") - - @JvmField val EE = of("EE") - - @JvmField val DO = of("DO") - - @JvmField val EC = of("EC") - - @JvmField val EG = of("EG") - - @JvmField val ES = of("ES") - - @JvmField val EU = of("EU") - - @JvmField val FI = of("FI") - - @JvmField val FR = of("FR") - - @JvmField val GB = of("GB") - - @JvmField val GE = of("GE") - - @JvmField val GR = of("GR") - - @JvmField val HK = of("HK") - - @JvmField val HR = of("HR") - - @JvmField val HU = of("HU") - - @JvmField val ID = of("ID") - - @JvmField val IE = of("IE") - - @JvmField val IL = of("IL") - - @JvmField val IN = of("IN") - - @JvmField val IS = of("IS") - - @JvmField val IT = of("IT") - - @JvmField val JP = of("JP") - - @JvmField val KE = of("KE") - - @JvmField val KR = of("KR") - - @JvmField val KZ = of("KZ") - - @JvmField val LI = of("LI") - - @JvmField val LT = of("LT") - - @JvmField val LU = of("LU") - - @JvmField val LV = of("LV") - - @JvmField val MT = of("MT") - - @JvmField val MX = of("MX") - - @JvmField val MY = of("MY") - - @JvmField val NG = of("NG") - - @JvmField val NL = of("NL") - - @JvmField val NO = of("NO") - - @JvmField val NZ = of("NZ") - - @JvmField val OM = of("OM") - - @JvmField val PE = of("PE") - - @JvmField val PH = of("PH") - - @JvmField val PL = of("PL") - - @JvmField val PT = of("PT") - - @JvmField val RO = of("RO") - - @JvmField val RS = of("RS") - - @JvmField val RU = of("RU") - - @JvmField val SA = of("SA") - - @JvmField val SE = of("SE") - - @JvmField val SG = of("SG") - - @JvmField val SI = of("SI") - - @JvmField val SK = of("SK") - - @JvmField val SV = of("SV") - - @JvmField val TH = of("TH") - - @JvmField val TR = of("TR") - - @JvmField val TW = of("TW") - - @JvmField val UA = of("UA") - - @JvmField val US = of("US") - - @JvmField val UY = of("UY") - - @JvmField val VE = of("VE") - - @JvmField val VN = of("VN") - - @JvmField val ZA = of("ZA") - - @JvmStatic fun of(value: String) = Country(JsonField.of(value)) - } - - /** An enum containing [Country]'s known values. */ - enum class Known { - AD, - AE, - AR, - AT, - AU, - BE, - BG, - BH, - BO, - BR, - CA, - CH, - CL, - CN, - CO, - CR, - CY, - CZ, - DE, - DK, - EE, - DO, - EC, - EG, - ES, - EU, - FI, - FR, - GB, - GE, - GR, - HK, - HR, - HU, - ID, - IE, - IL, - IN, - IS, - IT, - JP, - KE, - KR, - KZ, - LI, - LT, - LU, - LV, - MT, - MX, - MY, - NG, - NL, - NO, - NZ, - OM, - PE, - PH, - PL, - PT, - RO, - RS, - RU, - SA, - SE, - SG, - SI, - SK, - SV, - TH, - TR, - TW, - UA, - US, - UY, - VE, - VN, - ZA, - } - - /** - * An enum containing [Country]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Country] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AD, - AE, - AR, - AT, - AU, - BE, - BG, - BH, - BO, - BR, - CA, - CH, - CL, - CN, - CO, - CR, - CY, - CZ, - DE, - DK, - EE, - DO, - EC, - EG, - ES, - EU, - FI, - FR, - GB, - GE, - GR, - HK, - HR, - HU, - ID, - IE, - IL, - IN, - IS, - IT, - JP, - KE, - KR, - KZ, - LI, - LT, - LU, - LV, - MT, - MX, - MY, - NG, - NL, - NO, - NZ, - OM, - PE, - PH, - PL, - PT, - RO, - RS, - RU, - SA, - SE, - SG, - SI, - SK, - SV, - TH, - TR, - TW, - UA, - US, - UY, - VE, - VN, - ZA, - /** - * An enum member indicating that [Country] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AD -> Value.AD - AE -> Value.AE - AR -> Value.AR - AT -> Value.AT - AU -> Value.AU - BE -> Value.BE - BG -> Value.BG - BH -> Value.BH - BO -> Value.BO - BR -> Value.BR - CA -> Value.CA - CH -> Value.CH - CL -> Value.CL - CN -> Value.CN - CO -> Value.CO - CR -> Value.CR - CY -> Value.CY - CZ -> Value.CZ - DE -> Value.DE - DK -> Value.DK - EE -> Value.EE - DO -> Value.DO - EC -> Value.EC - EG -> Value.EG - ES -> Value.ES - EU -> Value.EU - FI -> Value.FI - FR -> Value.FR - GB -> Value.GB - GE -> Value.GE - GR -> Value.GR - HK -> Value.HK - HR -> Value.HR - HU -> Value.HU - ID -> Value.ID - IE -> Value.IE - IL -> Value.IL - IN -> Value.IN - IS -> Value.IS - IT -> Value.IT - JP -> Value.JP - KE -> Value.KE - KR -> Value.KR - KZ -> Value.KZ - LI -> Value.LI - LT -> Value.LT - LU -> Value.LU - LV -> Value.LV - MT -> Value.MT - MX -> Value.MX - MY -> Value.MY - NG -> Value.NG - NL -> Value.NL - NO -> Value.NO - NZ -> Value.NZ - OM -> Value.OM - PE -> Value.PE - PH -> Value.PH - PL -> Value.PL - PT -> Value.PT - RO -> Value.RO - RS -> Value.RS - RU -> Value.RU - SA -> Value.SA - SE -> Value.SE - SG -> Value.SG - SI -> Value.SI - SK -> Value.SK - SV -> Value.SV - TH -> Value.TH - TR -> Value.TR - TW -> Value.TW - UA -> Value.UA - US -> Value.US - UY -> Value.UY - VE -> Value.VE - VN -> Value.VN - ZA -> Value.ZA - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AD -> Known.AD - AE -> Known.AE - AR -> Known.AR - AT -> Known.AT - AU -> Known.AU - BE -> Known.BE - BG -> Known.BG - BH -> Known.BH - BO -> Known.BO - BR -> Known.BR - CA -> Known.CA - CH -> Known.CH - CL -> Known.CL - CN -> Known.CN - CO -> Known.CO - CR -> Known.CR - CY -> Known.CY - CZ -> Known.CZ - DE -> Known.DE - DK -> Known.DK - EE -> Known.EE - DO -> Known.DO - EC -> Known.EC - EG -> Known.EG - ES -> Known.ES - EU -> Known.EU - FI -> Known.FI - FR -> Known.FR - GB -> Known.GB - GE -> Known.GE - GR -> Known.GR - HK -> Known.HK - HR -> Known.HR - HU -> Known.HU - ID -> Known.ID - IE -> Known.IE - IL -> Known.IL - IN -> Known.IN - IS -> Known.IS - IT -> Known.IT - JP -> Known.JP - KE -> Known.KE - KR -> Known.KR - KZ -> Known.KZ - LI -> Known.LI - LT -> Known.LT - LU -> Known.LU - LV -> Known.LV - MT -> Known.MT - MX -> Known.MX - MY -> Known.MY - NG -> Known.NG - NL -> Known.NL - NO -> Known.NO - NZ -> Known.NZ - OM -> Known.OM - PE -> Known.PE - PH -> Known.PH - PL -> Known.PL - PT -> Known.PT - RO -> Known.RO - RS -> Known.RS - RU -> Known.RU - SA -> Known.SA - SE -> Known.SE - SG -> Known.SG - SI -> Known.SI - SK -> Known.SK - SV -> Known.SV - TH -> Known.TH - TR -> Known.TR - TW -> Known.TW - UA -> Known.UA - US -> Known.US - UY -> Known.UY - VE -> Known.VE - VN -> Known.VN - ZA -> Known.ZA - else -> throw OrbInvalidDataException("Unknown Country: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is Country && value == other.value /* spotless:on */ - } - - 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 AD_NRT = of("ad_nrt") - - @JvmField val AE_TRN = of("ae_trn") - - @JvmField val AR_CUIT = of("ar_cuit") - - @JvmField val EU_VAT = of("eu_vat") - - @JvmField val AU_ABN = of("au_abn") - - @JvmField val AU_ARN = of("au_arn") - - @JvmField val BG_UIC = of("bg_uic") - - @JvmField val BH_VAT = of("bh_vat") - - @JvmField val BO_TIN = of("bo_tin") - - @JvmField val BR_CNPJ = of("br_cnpj") - - @JvmField val BR_CPF = of("br_cpf") - - @JvmField val CA_BN = of("ca_bn") - - @JvmField val CA_GST_HST = of("ca_gst_hst") - - @JvmField val CA_PST_BC = of("ca_pst_bc") - - @JvmField val CA_PST_MB = of("ca_pst_mb") - - @JvmField val CA_PST_SK = of("ca_pst_sk") - - @JvmField val CA_QST = of("ca_qst") - - @JvmField val CH_VAT = of("ch_vat") - - @JvmField val CL_TIN = of("cl_tin") - - @JvmField val CN_TIN = of("cn_tin") - - @JvmField val CO_NIT = of("co_nit") - - @JvmField val CR_TIN = of("cr_tin") - - @JvmField val DO_RCN = of("do_rcn") - - @JvmField val EC_RUC = of("ec_ruc") - - @JvmField val EG_TIN = of("eg_tin") - - @JvmField val ES_CIF = of("es_cif") - - @JvmField val EU_OSS_VAT = of("eu_oss_vat") - - @JvmField val GB_VAT = of("gb_vat") - - @JvmField val GE_VAT = of("ge_vat") - - @JvmField val HK_BR = of("hk_br") - - @JvmField val HU_TIN = of("hu_tin") - - @JvmField val ID_NPWP = of("id_npwp") - - @JvmField val IL_VAT = of("il_vat") - - @JvmField val IN_GST = of("in_gst") - - @JvmField val IS_VAT = of("is_vat") - - @JvmField val JP_CN = of("jp_cn") - - @JvmField val JP_RN = of("jp_rn") - - @JvmField val JP_TRN = of("jp_trn") - - @JvmField val KE_PIN = of("ke_pin") - - @JvmField val KR_BRN = of("kr_brn") - - @JvmField val KZ_BIN = of("kz_bin") - - @JvmField val LI_UID = of("li_uid") - - @JvmField val MX_RFC = of("mx_rfc") - - @JvmField val MY_FRP = of("my_frp") - - @JvmField val MY_ITN = of("my_itn") - - @JvmField val MY_SST = of("my_sst") - - @JvmField val NG_TIN = of("ng_tin") - - @JvmField val NO_VAT = of("no_vat") - - @JvmField val NO_VOEC = of("no_voec") - - @JvmField val NZ_GST = of("nz_gst") - - @JvmField val OM_VAT = of("om_vat") - - @JvmField val PE_RUC = of("pe_ruc") - - @JvmField val PH_TIN = of("ph_tin") - - @JvmField val RO_TIN = of("ro_tin") - - @JvmField val RS_PIB = of("rs_pib") - - @JvmField val RU_INN = of("ru_inn") - - @JvmField val RU_KPP = of("ru_kpp") - - @JvmField val SA_VAT = of("sa_vat") - - @JvmField val SG_GST = of("sg_gst") - - @JvmField val SG_UEN = of("sg_uen") - - @JvmField val SI_TIN = of("si_tin") - - @JvmField val SV_NIT = of("sv_nit") - - @JvmField val TH_VAT = of("th_vat") - - @JvmField val TR_TIN = of("tr_tin") - - @JvmField val TW_VAT = of("tw_vat") - - @JvmField val UA_VAT = of("ua_vat") - - @JvmField val US_EIN = of("us_ein") - - @JvmField val UY_RUC = of("uy_ruc") - - @JvmField val VE_RIF = of("ve_rif") - - @JvmField val VN_TIN = of("vn_tin") - - @JvmField val ZA_VAT = of("za_vat") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - AD_NRT, - AE_TRN, - AR_CUIT, - EU_VAT, - AU_ABN, - AU_ARN, - BG_UIC, - BH_VAT, - BO_TIN, - BR_CNPJ, - BR_CPF, - CA_BN, - CA_GST_HST, - CA_PST_BC, - CA_PST_MB, - CA_PST_SK, - CA_QST, - CH_VAT, - CL_TIN, - CN_TIN, - CO_NIT, - CR_TIN, - DO_RCN, - EC_RUC, - EG_TIN, - ES_CIF, - EU_OSS_VAT, - GB_VAT, - GE_VAT, - HK_BR, - HU_TIN, - ID_NPWP, - IL_VAT, - IN_GST, - IS_VAT, - JP_CN, - JP_RN, - JP_TRN, - KE_PIN, - KR_BRN, - KZ_BIN, - LI_UID, - MX_RFC, - MY_FRP, - MY_ITN, - MY_SST, - NG_TIN, - NO_VAT, - NO_VOEC, - NZ_GST, - OM_VAT, - PE_RUC, - PH_TIN, - RO_TIN, - RS_PIB, - RU_INN, - RU_KPP, - SA_VAT, - SG_GST, - SG_UEN, - SI_TIN, - SV_NIT, - TH_VAT, - TR_TIN, - TW_VAT, - UA_VAT, - US_EIN, - UY_RUC, - VE_RIF, - VN_TIN, - ZA_VAT, - } - - /** - * 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 { - AD_NRT, - AE_TRN, - AR_CUIT, - EU_VAT, - AU_ABN, - AU_ARN, - BG_UIC, - BH_VAT, - BO_TIN, - BR_CNPJ, - BR_CPF, - CA_BN, - CA_GST_HST, - CA_PST_BC, - CA_PST_MB, - CA_PST_SK, - CA_QST, - CH_VAT, - CL_TIN, - CN_TIN, - CO_NIT, - CR_TIN, - DO_RCN, - EC_RUC, - EG_TIN, - ES_CIF, - EU_OSS_VAT, - GB_VAT, - GE_VAT, - HK_BR, - HU_TIN, - ID_NPWP, - IL_VAT, - IN_GST, - IS_VAT, - JP_CN, - JP_RN, - JP_TRN, - KE_PIN, - KR_BRN, - KZ_BIN, - LI_UID, - MX_RFC, - MY_FRP, - MY_ITN, - MY_SST, - NG_TIN, - NO_VAT, - NO_VOEC, - NZ_GST, - OM_VAT, - PE_RUC, - PH_TIN, - RO_TIN, - RS_PIB, - RU_INN, - RU_KPP, - SA_VAT, - SG_GST, - SG_UEN, - SI_TIN, - SV_NIT, - TH_VAT, - TR_TIN, - TW_VAT, - UA_VAT, - US_EIN, - UY_RUC, - VE_RIF, - VN_TIN, - ZA_VAT, - /** 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) { - AD_NRT -> Value.AD_NRT - AE_TRN -> Value.AE_TRN - AR_CUIT -> Value.AR_CUIT - EU_VAT -> Value.EU_VAT - AU_ABN -> Value.AU_ABN - AU_ARN -> Value.AU_ARN - BG_UIC -> Value.BG_UIC - BH_VAT -> Value.BH_VAT - BO_TIN -> Value.BO_TIN - BR_CNPJ -> Value.BR_CNPJ - BR_CPF -> Value.BR_CPF - CA_BN -> Value.CA_BN - CA_GST_HST -> Value.CA_GST_HST - CA_PST_BC -> Value.CA_PST_BC - CA_PST_MB -> Value.CA_PST_MB - CA_PST_SK -> Value.CA_PST_SK - CA_QST -> Value.CA_QST - CH_VAT -> Value.CH_VAT - CL_TIN -> Value.CL_TIN - CN_TIN -> Value.CN_TIN - CO_NIT -> Value.CO_NIT - CR_TIN -> Value.CR_TIN - DO_RCN -> Value.DO_RCN - EC_RUC -> Value.EC_RUC - EG_TIN -> Value.EG_TIN - ES_CIF -> Value.ES_CIF - EU_OSS_VAT -> Value.EU_OSS_VAT - GB_VAT -> Value.GB_VAT - GE_VAT -> Value.GE_VAT - HK_BR -> Value.HK_BR - HU_TIN -> Value.HU_TIN - ID_NPWP -> Value.ID_NPWP - IL_VAT -> Value.IL_VAT - IN_GST -> Value.IN_GST - IS_VAT -> Value.IS_VAT - JP_CN -> Value.JP_CN - JP_RN -> Value.JP_RN - JP_TRN -> Value.JP_TRN - KE_PIN -> Value.KE_PIN - KR_BRN -> Value.KR_BRN - KZ_BIN -> Value.KZ_BIN - LI_UID -> Value.LI_UID - MX_RFC -> Value.MX_RFC - MY_FRP -> Value.MY_FRP - MY_ITN -> Value.MY_ITN - MY_SST -> Value.MY_SST - NG_TIN -> Value.NG_TIN - NO_VAT -> Value.NO_VAT - NO_VOEC -> Value.NO_VOEC - NZ_GST -> Value.NZ_GST - OM_VAT -> Value.OM_VAT - PE_RUC -> Value.PE_RUC - PH_TIN -> Value.PH_TIN - RO_TIN -> Value.RO_TIN - RS_PIB -> Value.RS_PIB - RU_INN -> Value.RU_INN - RU_KPP -> Value.RU_KPP - SA_VAT -> Value.SA_VAT - SG_GST -> Value.SG_GST - SG_UEN -> Value.SG_UEN - SI_TIN -> Value.SI_TIN - SV_NIT -> Value.SV_NIT - TH_VAT -> Value.TH_VAT - TR_TIN -> Value.TR_TIN - TW_VAT -> Value.TW_VAT - UA_VAT -> Value.UA_VAT - US_EIN -> Value.US_EIN - UY_RUC -> Value.UY_RUC - VE_RIF -> Value.VE_RIF - VN_TIN -> Value.VN_TIN - ZA_VAT -> Value.ZA_VAT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AD_NRT -> Known.AD_NRT - AE_TRN -> Known.AE_TRN - AR_CUIT -> Known.AR_CUIT - EU_VAT -> Known.EU_VAT - AU_ABN -> Known.AU_ABN - AU_ARN -> Known.AU_ARN - BG_UIC -> Known.BG_UIC - BH_VAT -> Known.BH_VAT - BO_TIN -> Known.BO_TIN - BR_CNPJ -> Known.BR_CNPJ - BR_CPF -> Known.BR_CPF - CA_BN -> Known.CA_BN - CA_GST_HST -> Known.CA_GST_HST - CA_PST_BC -> Known.CA_PST_BC - CA_PST_MB -> Known.CA_PST_MB - CA_PST_SK -> Known.CA_PST_SK - CA_QST -> Known.CA_QST - CH_VAT -> Known.CH_VAT - CL_TIN -> Known.CL_TIN - CN_TIN -> Known.CN_TIN - CO_NIT -> Known.CO_NIT - CR_TIN -> Known.CR_TIN - DO_RCN -> Known.DO_RCN - EC_RUC -> Known.EC_RUC - EG_TIN -> Known.EG_TIN - ES_CIF -> Known.ES_CIF - EU_OSS_VAT -> Known.EU_OSS_VAT - GB_VAT -> Known.GB_VAT - GE_VAT -> Known.GE_VAT - HK_BR -> Known.HK_BR - HU_TIN -> Known.HU_TIN - ID_NPWP -> Known.ID_NPWP - IL_VAT -> Known.IL_VAT - IN_GST -> Known.IN_GST - IS_VAT -> Known.IS_VAT - JP_CN -> Known.JP_CN - JP_RN -> Known.JP_RN - JP_TRN -> Known.JP_TRN - KE_PIN -> Known.KE_PIN - KR_BRN -> Known.KR_BRN - KZ_BIN -> Known.KZ_BIN - LI_UID -> Known.LI_UID - MX_RFC -> Known.MX_RFC - MY_FRP -> Known.MY_FRP - MY_ITN -> Known.MY_ITN - MY_SST -> Known.MY_SST - NG_TIN -> Known.NG_TIN - NO_VAT -> Known.NO_VAT - NO_VOEC -> Known.NO_VOEC - NZ_GST -> Known.NZ_GST - OM_VAT -> Known.OM_VAT - PE_RUC -> Known.PE_RUC - PH_TIN -> Known.PH_TIN - RO_TIN -> Known.RO_TIN - RS_PIB -> Known.RS_PIB - RU_INN -> Known.RU_INN - RU_KPP -> Known.RU_KPP - SA_VAT -> Known.SA_VAT - SG_GST -> Known.SG_GST - SG_UEN -> Known.SG_UEN - SI_TIN -> Known.SI_TIN - SV_NIT -> Known.SV_NIT - TH_VAT -> Known.TH_VAT - TR_TIN -> Known.TR_TIN - TW_VAT -> Known.TW_VAT - UA_VAT -> Known.UA_VAT - US_EIN -> Known.US_EIN - UY_RUC -> Known.UY_RUC - VE_RIF -> Known.VE_RIF - VN_TIN -> Known.VN_TIN - ZA_VAT -> Known.ZA_VAT - 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CustomerTaxId && country == other.country && type == other.type && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(country, type, value, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CustomerTaxId{country=$country, type=$type, value=$value, 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoiceSource && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class LineItem - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjusted_subtotal") - @ExcludeMissing - private val adjustedSubtotal: JsonField = JsonMissing.of(), - @JsonProperty("adjustments") - @ExcludeMissing - private val adjustments: JsonField> = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("credits_applied") - @ExcludeMissing - private val creditsApplied: JsonField = JsonMissing.of(), - @JsonProperty("discount") - @ExcludeMissing - private val discount: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("filter") - @ExcludeMissing - private val filter: JsonField = JsonMissing.of(), - @JsonProperty("grouping") - @ExcludeMissing - private val grouping: JsonField = JsonMissing.of(), - @JsonProperty("maximum") - @ExcludeMissing - private val maximum: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("minimum") - @ExcludeMissing - private val minimum: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("partially_invoiced_amount") - @ExcludeMissing - private val partiallyInvoicedAmount: JsonField = JsonMissing.of(), - @JsonProperty("price") - @ExcludeMissing - private val price: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - private val quantity: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonProperty("sub_line_items") - @ExcludeMissing - private val subLineItems: JsonField> = JsonMissing.of(), - @JsonProperty("subtotal") - @ExcludeMissing - private val subtotal: JsonField = JsonMissing.of(), - @JsonProperty("tax_amounts") - @ExcludeMissing - private val taxAmounts: JsonField> = JsonMissing.of(), - @JsonProperty("usage_customer_ids") - @ExcludeMissing - private val usageCustomerIds: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** A unique ID for this line item. */ - fun id(): String = id.getRequired("id") - - /** - * The line amount after any adjustments and before overage conversion, credits and partial - * invoicing. - */ - fun adjustedSubtotal(): String = adjustedSubtotal.getRequired("adjusted_subtotal") - - /** All adjustments (ie. maximums, minimums, discounts) applied to the line item. */ - fun adjustments(): List = adjustments.getRequired("adjustments") - - /** - * The final amount for a line item after all adjustments and pre paid credits have been - * applied. - */ - fun amount(): String = amount.getRequired("amount") - - /** The number of prepaid credits applied. */ - fun creditsApplied(): String = creditsApplied.getRequired("credits_applied") - - fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) - - /** The end date of the range of time applied for this line item's price. */ - fun endDate(): OffsetDateTime = endDate.getRequired("end_date") - - /** An additional filter that was used to calculate the usage for this line item. */ - fun filter(): Optional = Optional.ofNullable(filter.getNullable("filter")) - - /** - * [DEPRECATED] For configured prices that are split by a grouping key, this will be - * populated with the key and a value. The `amount` and `subtotal` will be the values for - * this particular grouping. - */ - fun grouping(): Optional = Optional.ofNullable(grouping.getNullable("grouping")) - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun maximumAmount(): Optional = - Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun minimumAmount(): Optional = - Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) - - /** The name of the price associated with this line item. */ - fun name(): String = name.getRequired("name") - - /** Any amount applied from a partial invoice */ - fun partiallyInvoicedAmount(): String = - partiallyInvoicedAmount.getRequired("partially_invoiced_amount") - - /** - * The Price resource represents a price that can be billed on a subscription, resulting in - * a charge on an invoice in the form of an invoice line item. Prices take a quantity and - * determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the key - * for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(): Optional = Optional.ofNullable(price.getNullable("price")) - - /** Either the fixed fee quantity or the usage during the service period. */ - fun quantity(): Double = quantity.getRequired("quantity") - - /** The start date of the range of time applied for this line item's price. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** - * For complex pricing structures, the line item can be broken down further in - * `sub_line_items`. - */ - fun subLineItems(): List = subLineItems.getRequired("sub_line_items") - - /** The line amount before before any adjustments. */ - fun subtotal(): String = subtotal.getRequired("subtotal") - - /** - * An array of tax rates and their incurred tax amounts. Empty if no tax integration is - * configured. - */ - fun taxAmounts(): List = taxAmounts.getRequired("tax_amounts") - - /** A list of customer ids that were used to calculate the usage for this line item. */ - fun usageCustomerIds(): Optional> = - Optional.ofNullable(usageCustomerIds.getNullable("usage_customer_ids")) - - /** A unique ID for this line item. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * The line amount after any adjustments and before overage conversion, credits and partial - * invoicing. - */ - @JsonProperty("adjusted_subtotal") - @ExcludeMissing - fun _adjustedSubtotal(): JsonField = adjustedSubtotal - - /** All adjustments (ie. maximums, minimums, discounts) applied to the line item. */ - @JsonProperty("adjustments") - @ExcludeMissing - fun _adjustments(): JsonField> = adjustments - - /** - * The final amount for a line item after all adjustments and pre paid credits have been - * applied. - */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** The number of prepaid credits applied. */ - @JsonProperty("credits_applied") - @ExcludeMissing - fun _creditsApplied(): JsonField = creditsApplied - - @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - - /** The end date of the range of time applied for this line item's price. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** An additional filter that was used to calculate the usage for this line item. */ - @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField = filter - - /** - * [DEPRECATED] For configured prices that are split by a grouping key, this will be - * populated with the key and a value. The `amount` and `subtotal` will be the values for - * this particular grouping. - */ - @JsonProperty("grouping") @ExcludeMissing fun _grouping(): JsonField = grouping - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - @JsonProperty("maximum") - @ExcludeMissing - fun _maximum(): JsonField = maximum - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - @JsonProperty("minimum") - @ExcludeMissing - fun _minimum(): JsonField = minimum - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** The name of the price associated with this line item. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** Any amount applied from a partial invoice */ - @JsonProperty("partially_invoiced_amount") - @ExcludeMissing - fun _partiallyInvoicedAmount(): JsonField = partiallyInvoicedAmount - - /** - * The Price resource represents a price that can be billed on a subscription, resulting in - * a charge on an invoice in the form of an invoice line item. Prices take a quantity and - * determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the key - * for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - - /** Either the fixed fee quantity or the usage during the service period. */ - @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - - /** The start date of the range of time applied for this line item's price. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - /** - * For complex pricing structures, the line item can be broken down further in - * `sub_line_items`. - */ - @JsonProperty("sub_line_items") - @ExcludeMissing - fun _subLineItems(): JsonField> = subLineItems - - /** The line amount before before any adjustments. */ - @JsonProperty("subtotal") @ExcludeMissing fun _subtotal(): JsonField = subtotal - - /** - * An array of tax rates and their incurred tax amounts. Empty if no tax integration is - * configured. - */ - @JsonProperty("tax_amounts") - @ExcludeMissing - fun _taxAmounts(): JsonField> = taxAmounts - - /** A list of customer ids that were used to calculate the usage for this line item. */ - @JsonProperty("usage_customer_ids") - @ExcludeMissing - fun _usageCustomerIds(): JsonField> = usageCustomerIds - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): LineItem = apply { - if (validated) { - return@apply - } - - id() - adjustedSubtotal() - adjustments().forEach { it.validate() } - amount() - creditsApplied() - discount().ifPresent { it.validate() } - endDate() - filter() - grouping() - maximum().ifPresent { it.validate() } - maximumAmount() - minimum().ifPresent { it.validate() } - minimumAmount() - name() - partiallyInvoicedAmount() - price().ifPresent { it.validate() } - quantity() - startDate() - subLineItems().forEach { it.validate() } - subtotal() - taxAmounts().forEach { it.validate() } - usageCustomerIds() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [LineItem]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustedSubtotal: JsonField? = null - private var adjustments: JsonField>? = null - private var amount: JsonField? = null - private var creditsApplied: JsonField? = null - private var discount: JsonField? = null - private var endDate: JsonField? = null - private var filter: JsonField? = null - private var grouping: JsonField? = null - private var maximum: JsonField? = null - private var maximumAmount: JsonField? = null - private var minimum: JsonField? = null - private var minimumAmount: JsonField? = null - private var name: JsonField? = null - private var partiallyInvoicedAmount: JsonField? = null - private var price: JsonField? = null - private var quantity: JsonField? = null - private var startDate: JsonField? = null - private var subLineItems: JsonField>? = null - private var subtotal: JsonField? = null - private var taxAmounts: JsonField>? = null - private var usageCustomerIds: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(lineItem: LineItem) = apply { - id = lineItem.id - adjustedSubtotal = lineItem.adjustedSubtotal - adjustments = lineItem.adjustments.map { it.toMutableList() } - amount = lineItem.amount - creditsApplied = lineItem.creditsApplied - discount = lineItem.discount - endDate = lineItem.endDate - filter = lineItem.filter - grouping = lineItem.grouping - maximum = lineItem.maximum - maximumAmount = lineItem.maximumAmount - minimum = lineItem.minimum - minimumAmount = lineItem.minimumAmount - name = lineItem.name - partiallyInvoicedAmount = lineItem.partiallyInvoicedAmount - price = lineItem.price - quantity = lineItem.quantity - startDate = lineItem.startDate - subLineItems = lineItem.subLineItems.map { it.toMutableList() } - subtotal = lineItem.subtotal - taxAmounts = lineItem.taxAmounts.map { it.toMutableList() } - usageCustomerIds = lineItem.usageCustomerIds.map { it.toMutableList() } - additionalProperties = lineItem.additionalProperties.toMutableMap() - } - - /** A unique ID for this line item. */ - fun id(id: String) = id(JsonField.of(id)) - - /** A unique ID for this line item. */ - fun id(id: JsonField) = apply { this.id = id } - - /** - * The line amount after any adjustments and before overage conversion, credits and - * partial invoicing. - */ - fun adjustedSubtotal(adjustedSubtotal: String) = - adjustedSubtotal(JsonField.of(adjustedSubtotal)) - - /** - * The line amount after any adjustments and before overage conversion, credits and - * partial invoicing. - */ - fun adjustedSubtotal(adjustedSubtotal: JsonField) = apply { - this.adjustedSubtotal = adjustedSubtotal - } - - /** All adjustments (ie. maximums, minimums, discounts) applied to the line item. */ - fun adjustments(adjustments: List) = adjustments(JsonField.of(adjustments)) - - /** All adjustments (ie. maximums, minimums, discounts) applied to the line item. */ - fun adjustments(adjustments: JsonField>) = apply { - this.adjustments = adjustments.map { it.toMutableList() } - } - - /** All adjustments (ie. maximums, minimums, discounts) applied to the line item. */ - fun addAdjustment(adjustment: Adjustment) = apply { - adjustments = - (adjustments ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(adjustment) - } - } - - /** All adjustments (ie. maximums, minimums, discounts) applied to the line item. */ - fun addAdjustment(monetaryUsageDiscount: Adjustment.MonetaryUsageDiscountAdjustment) = - addAdjustment(Adjustment.ofMonetaryUsageDiscount(monetaryUsageDiscount)) - - /** All adjustments (ie. maximums, minimums, discounts) applied to the line item. */ - fun addAdjustment(monetaryAmountDiscount: Adjustment.MonetaryAmountDiscountAdjustment) = - addAdjustment(Adjustment.ofMonetaryAmountDiscount(monetaryAmountDiscount)) - - /** All adjustments (ie. maximums, minimums, discounts) applied to the line item. */ - fun addAdjustment( - monetaryPercentageDiscount: Adjustment.MonetaryPercentageDiscountAdjustment - ) = addAdjustment(Adjustment.ofMonetaryPercentageDiscount(monetaryPercentageDiscount)) - - /** All adjustments (ie. maximums, minimums, discounts) applied to the line item. */ - fun addAdjustment(monetaryMinimum: Adjustment.MonetaryMinimumAdjustment) = - addAdjustment(Adjustment.ofMonetaryMinimum(monetaryMinimum)) - - /** All adjustments (ie. maximums, minimums, discounts) applied to the line item. */ - fun addAdjustment(monetaryMaximum: Adjustment.MonetaryMaximumAdjustment) = - addAdjustment(Adjustment.ofMonetaryMaximum(monetaryMaximum)) - - /** - * The final amount for a line item after all adjustments and pre paid credits have been - * applied. - */ - fun amount(amount: String) = amount(JsonField.of(amount)) - - /** - * The final amount for a line item after all adjustments and pre paid credits have been - * applied. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** The number of prepaid credits applied. */ - fun creditsApplied(creditsApplied: String) = - creditsApplied(JsonField.of(creditsApplied)) - - /** The number of prepaid credits applied. */ - fun creditsApplied(creditsApplied: JsonField) = apply { - this.creditsApplied = creditsApplied - } - - fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) - - fun discount(discount: Optional) = discount(discount.orElse(null)) - - fun discount(discount: JsonField) = apply { this.discount = discount } - - fun discount(percentage: PercentageDiscount) = - discount(Discount.ofPercentage(percentage)) - - fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) - - fun trialDiscount(appliesToPriceIds: List) = - discount( - TrialDiscount.builder() - .discountType(TrialDiscount.DiscountType.TRIAL) - .appliesToPriceIds(appliesToPriceIds) - .build() - ) - - fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) - - fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) - - /** The end date of the range of time applied for this line item's price. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) - - /** The end date of the range of time applied for this line item's price. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** An additional filter that was used to calculate the usage for this line item. */ - fun filter(filter: String?) = filter(JsonField.ofNullable(filter)) - - /** An additional filter that was used to calculate the usage for this line item. */ - fun filter(filter: Optional) = filter(filter.orElse(null)) - - /** An additional filter that was used to calculate the usage for this line item. */ - fun filter(filter: JsonField) = apply { this.filter = filter } - - /** - * [DEPRECATED] For configured prices that are split by a grouping key, this will be - * populated with the key and a value. The `amount` and `subtotal` will be the values - * for this particular grouping. - */ - fun grouping(grouping: String?) = grouping(JsonField.ofNullable(grouping)) - - /** - * [DEPRECATED] For configured prices that are split by a grouping key, this will be - * populated with the key and a value. The `amount` and `subtotal` will be the values - * for this particular grouping. - */ - fun grouping(grouping: Optional) = grouping(grouping.orElse(null)) - - /** - * [DEPRECATED] For configured prices that are split by a grouping key, this will be - * populated with the key and a value. The `amount` and `subtotal` will be the values - * for this particular grouping. - */ - fun grouping(grouping: JsonField) = apply { this.grouping = grouping } - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.orElse(null)) - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: Optional) = - minimumAmount(minimumAmount.orElse(null)) - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** The name of the price associated with this line item. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price associated with this line item. */ - fun name(name: JsonField) = apply { this.name = name } - - /** Any amount applied from a partial invoice */ - fun partiallyInvoicedAmount(partiallyInvoicedAmount: String) = - partiallyInvoicedAmount(JsonField.of(partiallyInvoicedAmount)) - - /** Any amount applied from a partial invoice */ - fun partiallyInvoicedAmount(partiallyInvoicedAmount: JsonField) = apply { - this.partiallyInvoicedAmount = partiallyInvoicedAmount - } - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(price: Optional) = price(price.orElse(null)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(price: JsonField) = apply { this.price = price } - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(matrix: Price.MatrixPrice) = price(Price.ofMatrix(matrix)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredPackage: Price.TieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedTiered: Price.GroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(unitWithPercent: Price.UnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredWithProration: Price.TieredWithProrationPrice) = - price(Price.ofTieredWithProration(tieredWithProration)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(unitWithProration: Price.UnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedAllocation: Price.GroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bulkWithProration: Price.BulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = - price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice) = - price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - - /** Either the fixed fee quantity or the usage during the service period. */ - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - - /** Either the fixed fee quantity or the usage during the service period. */ - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - /** The start date of the range of time applied for this line item's price. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the range of time applied for this line item's price. */ - fun startDate(startDate: JsonField) = apply { - this.startDate = startDate - } - - /** - * For complex pricing structures, the line item can be broken down further in - * `sub_line_items`. - */ - fun subLineItems(subLineItems: List) = - subLineItems(JsonField.of(subLineItems)) - - /** - * For complex pricing structures, the line item can be broken down further in - * `sub_line_items`. - */ - fun subLineItems(subLineItems: JsonField>) = apply { - this.subLineItems = subLineItems.map { it.toMutableList() } - } - - /** - * For complex pricing structures, the line item can be broken down further in - * `sub_line_items`. - */ - fun addSubLineItem(subLineItem: SubLineItem) = apply { - subLineItems = - (subLineItems ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(subLineItem) - } - } - - /** - * For complex pricing structures, the line item can be broken down further in - * `sub_line_items`. - */ - fun addSubLineItem(matrix: SubLineItem.MatrixSubLineItem) = - addSubLineItem(SubLineItem.ofMatrix(matrix)) - - /** - * For complex pricing structures, the line item can be broken down further in - * `sub_line_items`. - */ - fun addSubLineItem(tier: SubLineItem.TierSubLineItem) = - addSubLineItem(SubLineItem.ofTier(tier)) - - /** - * For complex pricing structures, the line item can be broken down further in - * `sub_line_items`. - */ - fun addSubLineItem(other: SubLineItem.OtherSubLineItem) = - addSubLineItem(SubLineItem.ofOther(other)) - - /** The line amount before before any adjustments. */ - fun subtotal(subtotal: String) = subtotal(JsonField.of(subtotal)) - - /** The line amount before before any adjustments. */ - fun subtotal(subtotal: JsonField) = apply { this.subtotal = subtotal } - - /** - * An array of tax rates and their incurred tax amounts. Empty if no tax integration is - * configured. - */ - fun taxAmounts(taxAmounts: List) = taxAmounts(JsonField.of(taxAmounts)) - - /** - * An array of tax rates and their incurred tax amounts. Empty if no tax integration is - * configured. - */ - fun taxAmounts(taxAmounts: JsonField>) = apply { - this.taxAmounts = taxAmounts.map { it.toMutableList() } - } - - /** - * An array of tax rates and their incurred tax amounts. Empty if no tax integration is - * configured. - */ - fun addTaxAmount(taxAmount: TaxAmount) = apply { - taxAmounts = - (taxAmounts ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(taxAmount) - } - } - - /** A list of customer ids that were used to calculate the usage for this line item. */ - fun usageCustomerIds(usageCustomerIds: List?) = - usageCustomerIds(JsonField.ofNullable(usageCustomerIds)) - - /** A list of customer ids that were used to calculate the usage for this line item. */ - fun usageCustomerIds(usageCustomerIds: Optional>) = - usageCustomerIds(usageCustomerIds.orElse(null)) - - /** A list of customer ids that were used to calculate the usage for this line item. */ - fun usageCustomerIds(usageCustomerIds: JsonField>) = apply { - this.usageCustomerIds = usageCustomerIds.map { it.toMutableList() } - } - - /** A list of customer ids that were used to calculate the usage for this line item. */ - fun addUsageCustomerId(usageCustomerId: String) = apply { - usageCustomerIds = - (usageCustomerIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(usageCustomerId) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): LineItem = - LineItem( - checkRequired("id", id), - checkRequired("adjustedSubtotal", adjustedSubtotal), - checkRequired("adjustments", adjustments).map { it.toImmutable() }, - checkRequired("amount", amount), - checkRequired("creditsApplied", creditsApplied), - checkRequired("discount", discount), - checkRequired("endDate", endDate), - checkRequired("filter", filter), - checkRequired("grouping", grouping), - checkRequired("maximum", maximum), - checkRequired("maximumAmount", maximumAmount), - checkRequired("minimum", minimum), - checkRequired("minimumAmount", minimumAmount), - checkRequired("name", name), - checkRequired("partiallyInvoicedAmount", partiallyInvoicedAmount), - checkRequired("price", price), - checkRequired("quantity", quantity), - checkRequired("startDate", startDate), - checkRequired("subLineItems", subLineItems).map { it.toImmutable() }, - checkRequired("subtotal", subtotal), - checkRequired("taxAmounts", taxAmounts).map { it.toImmutable() }, - checkRequired("usageCustomerIds", usageCustomerIds).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val monetaryUsageDiscount: MonetaryUsageDiscountAdjustment? = null, - private val monetaryAmountDiscount: MonetaryAmountDiscountAdjustment? = null, - private val monetaryPercentageDiscount: MonetaryPercentageDiscountAdjustment? = null, - private val monetaryMinimum: MonetaryMinimumAdjustment? = null, - private val monetaryMaximum: MonetaryMaximumAdjustment? = null, - private val _json: JsonValue? = null, - ) { - - fun monetaryUsageDiscount(): Optional = - Optional.ofNullable(monetaryUsageDiscount) - - fun monetaryAmountDiscount(): Optional = - Optional.ofNullable(monetaryAmountDiscount) - - fun monetaryPercentageDiscount(): Optional = - Optional.ofNullable(monetaryPercentageDiscount) - - fun monetaryMinimum(): Optional = - Optional.ofNullable(monetaryMinimum) - - fun monetaryMaximum(): Optional = - Optional.ofNullable(monetaryMaximum) - - fun isMonetaryUsageDiscount(): Boolean = monetaryUsageDiscount != null - - fun isMonetaryAmountDiscount(): Boolean = monetaryAmountDiscount != null - - fun isMonetaryPercentageDiscount(): Boolean = monetaryPercentageDiscount != null - - fun isMonetaryMinimum(): Boolean = monetaryMinimum != null - - fun isMonetaryMaximum(): Boolean = monetaryMaximum != null - - fun asMonetaryUsageDiscount(): MonetaryUsageDiscountAdjustment = - monetaryUsageDiscount.getOrThrow("monetaryUsageDiscount") - - fun asMonetaryAmountDiscount(): MonetaryAmountDiscountAdjustment = - monetaryAmountDiscount.getOrThrow("monetaryAmountDiscount") - - fun asMonetaryPercentageDiscount(): MonetaryPercentageDiscountAdjustment = - monetaryPercentageDiscount.getOrThrow("monetaryPercentageDiscount") - - fun asMonetaryMinimum(): MonetaryMinimumAdjustment = - monetaryMinimum.getOrThrow("monetaryMinimum") - - fun asMonetaryMaximum(): MonetaryMaximumAdjustment = - monetaryMaximum.getOrThrow("monetaryMaximum") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - monetaryUsageDiscount != null -> - visitor.visitMonetaryUsageDiscount(monetaryUsageDiscount) - monetaryAmountDiscount != null -> - visitor.visitMonetaryAmountDiscount(monetaryAmountDiscount) - monetaryPercentageDiscount != null -> - visitor.visitMonetaryPercentageDiscount(monetaryPercentageDiscount) - monetaryMinimum != null -> visitor.visitMonetaryMinimum(monetaryMinimum) - monetaryMaximum != null -> visitor.visitMonetaryMaximum(monetaryMaximum) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitMonetaryUsageDiscount( - monetaryUsageDiscount: MonetaryUsageDiscountAdjustment - ) { - monetaryUsageDiscount.validate() - } - - override fun visitMonetaryAmountDiscount( - monetaryAmountDiscount: MonetaryAmountDiscountAdjustment - ) { - monetaryAmountDiscount.validate() - } - - override fun visitMonetaryPercentageDiscount( - monetaryPercentageDiscount: MonetaryPercentageDiscountAdjustment - ) { - monetaryPercentageDiscount.validate() - } - - override fun visitMonetaryMinimum( - monetaryMinimum: MonetaryMinimumAdjustment - ) { - monetaryMinimum.validate() - } - - override fun visitMonetaryMaximum( - monetaryMaximum: MonetaryMaximumAdjustment - ) { - monetaryMaximum.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Adjustment && monetaryUsageDiscount == other.monetaryUsageDiscount && monetaryAmountDiscount == other.monetaryAmountDiscount && monetaryPercentageDiscount == other.monetaryPercentageDiscount && monetaryMinimum == other.monetaryMinimum && monetaryMaximum == other.monetaryMaximum /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(monetaryUsageDiscount, monetaryAmountDiscount, monetaryPercentageDiscount, monetaryMinimum, monetaryMaximum) /* spotless:on */ - - override fun toString(): String = - when { - monetaryUsageDiscount != null -> - "Adjustment{monetaryUsageDiscount=$monetaryUsageDiscount}" - monetaryAmountDiscount != null -> - "Adjustment{monetaryAmountDiscount=$monetaryAmountDiscount}" - monetaryPercentageDiscount != null -> - "Adjustment{monetaryPercentageDiscount=$monetaryPercentageDiscount}" - monetaryMinimum != null -> "Adjustment{monetaryMinimum=$monetaryMinimum}" - monetaryMaximum != null -> "Adjustment{monetaryMaximum=$monetaryMaximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } - - companion object { - - @JvmStatic - fun ofMonetaryUsageDiscount( - monetaryUsageDiscount: MonetaryUsageDiscountAdjustment - ) = Adjustment(monetaryUsageDiscount = monetaryUsageDiscount) - - @JvmStatic - fun ofMonetaryAmountDiscount( - monetaryAmountDiscount: MonetaryAmountDiscountAdjustment - ) = Adjustment(monetaryAmountDiscount = monetaryAmountDiscount) - - @JvmStatic - fun ofMonetaryPercentageDiscount( - monetaryPercentageDiscount: MonetaryPercentageDiscountAdjustment - ) = Adjustment(monetaryPercentageDiscount = monetaryPercentageDiscount) - - @JvmStatic - fun ofMonetaryMinimum(monetaryMinimum: MonetaryMinimumAdjustment) = - Adjustment(monetaryMinimum = monetaryMinimum) - - @JvmStatic - fun ofMonetaryMaximum(monetaryMaximum: MonetaryMaximumAdjustment) = - Adjustment(monetaryMaximum = monetaryMaximum) - } - - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { - - fun visitMonetaryUsageDiscount( - monetaryUsageDiscount: MonetaryUsageDiscountAdjustment - ): T - - fun visitMonetaryAmountDiscount( - monetaryAmountDiscount: MonetaryAmountDiscountAdjustment - ): T - - fun visitMonetaryPercentageDiscount( - monetaryPercentageDiscount: MonetaryPercentageDiscountAdjustment - ): T - - fun visitMonetaryMinimum(monetaryMinimum: MonetaryMinimumAdjustment): T - - fun visitMonetaryMaximum(monetaryMaximum: MonetaryMaximumAdjustment): T - - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } - - internal class Deserializer : BaseDeserializer(Adjustment::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = - json.asObject().getOrNull()?.get("adjustment_type")?.asString()?.getOrNull() - - when (adjustmentType) { - "usage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(monetaryUsageDiscount = it, _json = json) - } - } - "amount_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(monetaryAmountDiscount = it, _json = json) - } - } - "percentage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(monetaryPercentageDiscount = it, _json = json) - } - } - "minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(monetaryMinimum = it, _json = json) - } - } - "maximum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(monetaryMaximum = it, _json = json) - } - } - } - - return Adjustment(_json = json) - } - } - - internal class Serializer : BaseSerializer(Adjustment::class) { - - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.monetaryUsageDiscount != null -> - generator.writeObject(value.monetaryUsageDiscount) - value.monetaryAmountDiscount != null -> - generator.writeObject(value.monetaryAmountDiscount) - value.monetaryPercentageDiscount != null -> - generator.writeObject(value.monetaryPercentageDiscount) - value.monetaryMinimum != null -> - generator.writeObject(value.monetaryMinimum) - value.monetaryMaximum != null -> - generator.writeObject(value.monetaryMaximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") - } - } - } - - @NoAutoDetect - class MonetaryUsageDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonProperty("usage_discount") - @ExcludeMissing - private val usageDiscount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The value applied by an adjustment. */ - fun amount(): String = amount.getRequired("amount") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - /** - * The number of usage units by which to discount the price this adjustment applies - * to in a given billing period. - */ - fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The value applied by an adjustment. */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - /** - * The number of usage units by which to discount the price this adjustment applies - * to in a given billing period. - */ - @JsonProperty("usage_discount") - @ExcludeMissing - fun _usageDiscount(): JsonField = usageDiscount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MonetaryUsageDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - amount() - appliesToPriceIds() - isInvoiceLevel() - reason() - usageDiscount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MonetaryUsageDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var amount: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var reason: JsonField? = null - private var usageDiscount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - monetaryUsageDiscountAdjustment: MonetaryUsageDiscountAdjustment - ) = apply { - id = monetaryUsageDiscountAdjustment.id - adjustmentType = monetaryUsageDiscountAdjustment.adjustmentType - amount = monetaryUsageDiscountAdjustment.amount - appliesToPriceIds = - monetaryUsageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = monetaryUsageDiscountAdjustment.isInvoiceLevel - reason = monetaryUsageDiscountAdjustment.reason - usageDiscount = monetaryUsageDiscountAdjustment.usageDiscount - additionalProperties = - monetaryUsageDiscountAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The value applied by an adjustment. */ - fun amount(amount: String) = amount(JsonField.of(amount)) - - /** The value applied by an adjustment. */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - /** - * The number of usage units by which to discount the price this adjustment - * applies to in a given billing period. - */ - fun usageDiscount(usageDiscount: Double) = - usageDiscount(JsonField.of(usageDiscount)) - - /** - * The number of usage units by which to discount the price this adjustment - * applies to in a given billing period. - */ - fun usageDiscount(usageDiscount: JsonField) = apply { - this.usageDiscount = usageDiscount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): MonetaryUsageDiscountAdjustment = - MonetaryUsageDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("amount", amount), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("reason", reason), - checkRequired("usageDiscount", usageDiscount), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - USAGE_DISCOUNT -> Known.USAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MonetaryUsageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, amount, appliesToPriceIds, isInvoiceLevel, reason, usageDiscount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MonetaryUsageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amount=$amount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class MonetaryAmountDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("amount_discount") - @ExcludeMissing - private val amountDiscount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The value applied by an adjustment. */ - fun amount(): String = amount.getRequired("amount") - - /** - * The amount by which to discount the prices this adjustment applies to in a given - * billing period. - */ - fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The value applied by an adjustment. */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** - * The amount by which to discount the prices this adjustment applies to in a given - * billing period. - */ - @JsonProperty("amount_discount") - @ExcludeMissing - fun _amountDiscount(): JsonField = amountDiscount - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MonetaryAmountDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - amount() - amountDiscount() - appliesToPriceIds() - isInvoiceLevel() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MonetaryAmountDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var amount: JsonField? = null - private var amountDiscount: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - monetaryAmountDiscountAdjustment: MonetaryAmountDiscountAdjustment - ) = apply { - id = monetaryAmountDiscountAdjustment.id - adjustmentType = monetaryAmountDiscountAdjustment.adjustmentType - amount = monetaryAmountDiscountAdjustment.amount - amountDiscount = monetaryAmountDiscountAdjustment.amountDiscount - appliesToPriceIds = - monetaryAmountDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = monetaryAmountDiscountAdjustment.isInvoiceLevel - reason = monetaryAmountDiscountAdjustment.reason - additionalProperties = - monetaryAmountDiscountAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The value applied by an adjustment. */ - fun amount(amount: String) = amount(JsonField.of(amount)) - - /** The value applied by an adjustment. */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** - * The amount by which to discount the prices this adjustment applies to in a - * given billing period. - */ - fun amountDiscount(amountDiscount: String) = - amountDiscount(JsonField.of(amountDiscount)) - - /** - * The amount by which to discount the prices this adjustment applies to in a - * given billing period. - */ - fun amountDiscount(amountDiscount: JsonField) = apply { - this.amountDiscount = amountDiscount - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): MonetaryAmountDiscountAdjustment = - MonetaryAmountDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("amount", amount), - checkRequired("amountDiscount", amountDiscount), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MonetaryAmountDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, amount, amountDiscount, appliesToPriceIds, isInvoiceLevel, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MonetaryAmountDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amount=$amount, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class MonetaryPercentageDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("percentage_discount") - @ExcludeMissing - private val percentageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The value applied by an adjustment. */ - fun amount(): String = amount.getRequired("amount") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(): Double = - percentageDiscount.getRequired("percentage_discount") - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The value applied by an adjustment. */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - @JsonProperty("percentage_discount") - @ExcludeMissing - fun _percentageDiscount(): JsonField = percentageDiscount - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MonetaryPercentageDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - amount() - appliesToPriceIds() - isInvoiceLevel() - percentageDiscount() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MonetaryPercentageDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var amount: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var percentageDiscount: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - monetaryPercentageDiscountAdjustment: MonetaryPercentageDiscountAdjustment - ) = apply { - id = monetaryPercentageDiscountAdjustment.id - adjustmentType = monetaryPercentageDiscountAdjustment.adjustmentType - amount = monetaryPercentageDiscountAdjustment.amount - appliesToPriceIds = - monetaryPercentageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = monetaryPercentageDiscountAdjustment.isInvoiceLevel - percentageDiscount = monetaryPercentageDiscountAdjustment.percentageDiscount - reason = monetaryPercentageDiscountAdjustment.reason - additionalProperties = - monetaryPercentageDiscountAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The value applied by an adjustment. */ - fun amount(amount: String) = amount(JsonField.of(amount)) - - /** The value applied by an adjustment. */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(percentageDiscount: Double) = - percentageDiscount(JsonField.of(percentageDiscount)) - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(percentageDiscount: JsonField) = apply { - this.percentageDiscount = percentageDiscount - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): MonetaryPercentageDiscountAdjustment = - MonetaryPercentageDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("amount", amount), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("percentageDiscount", percentageDiscount), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val PERCENTAGE_DISCOUNT = of("percentage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MonetaryPercentageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, amount, appliesToPriceIds, isInvoiceLevel, percentageDiscount, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MonetaryPercentageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amount=$amount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class MonetaryMinimumAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The value applied by an adjustment. */ - fun amount(): String = amount.getRequired("amount") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(): String = itemId.getRequired("item_id") - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The value applied by an adjustment. */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The item ID that revenue from this minimum will be attributed to. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MonetaryMinimumAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - amount() - appliesToPriceIds() - isInvoiceLevel() - itemId() - minimumAmount() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MonetaryMinimumAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var amount: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var itemId: JsonField? = null - private var minimumAmount: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(monetaryMinimumAdjustment: MonetaryMinimumAdjustment) = - apply { - id = monetaryMinimumAdjustment.id - adjustmentType = monetaryMinimumAdjustment.adjustmentType - amount = monetaryMinimumAdjustment.amount - appliesToPriceIds = - monetaryMinimumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = monetaryMinimumAdjustment.isInvoiceLevel - itemId = monetaryMinimumAdjustment.itemId - minimumAmount = monetaryMinimumAdjustment.minimumAmount - reason = monetaryMinimumAdjustment.reason - additionalProperties = - monetaryMinimumAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The value applied by an adjustment. */ - fun amount(amount: String) = amount(JsonField.of(amount)) - - /** The value applied by an adjustment. */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): MonetaryMinimumAdjustment = - MonetaryMinimumAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("amount", amount), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("itemId", itemId), - checkRequired("minimumAmount", minimumAmount), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MonetaryMinimumAdjustment && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, amount, appliesToPriceIds, isInvoiceLevel, itemId, minimumAmount, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MonetaryMinimumAdjustment{id=$id, adjustmentType=$adjustmentType, amount=$amount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class MonetaryMaximumAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The value applied by an adjustment. */ - fun amount(): String = amount.getRequired("amount") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The value applied by an adjustment. */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MonetaryMaximumAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - amount() - appliesToPriceIds() - isInvoiceLevel() - maximumAmount() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MonetaryMaximumAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var amount: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var maximumAmount: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(monetaryMaximumAdjustment: MonetaryMaximumAdjustment) = - apply { - id = monetaryMaximumAdjustment.id - adjustmentType = monetaryMaximumAdjustment.adjustmentType - amount = monetaryMaximumAdjustment.amount - appliesToPriceIds = - monetaryMaximumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = monetaryMaximumAdjustment.isInvoiceLevel - maximumAmount = monetaryMaximumAdjustment.maximumAmount - reason = monetaryMaximumAdjustment.reason - additionalProperties = - monetaryMaximumAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The value applied by an adjustment. */ - fun amount(amount: String) = amount(JsonField.of(amount)) - - /** The value applied by an adjustment. */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): MonetaryMaximumAdjustment = - MonetaryMaximumAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("amount", amount), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("maximumAmount", maximumAmount), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MonetaryMaximumAdjustment && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, amount, appliesToPriceIds, isInvoiceLevel, maximumAmount, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MonetaryMaximumAdjustment{id=$id, adjustmentType=$adjustmentType, amount=$amount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, reason=$reason, additionalProperties=$additionalProperties}" - } - } - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - @NoAutoDetect - class Maximum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Maximum amount applied */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Maximum amount applied */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Maximum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - maximumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Maximum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = maximum.maximumAmount - additionalProperties = maximum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Maximum = - Maximum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("maximumAmount", maximumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Maximum && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, maximumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Maximum{appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, additionalProperties=$additionalProperties}" - } - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - @NoAutoDetect - class Minimum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Minimum amount applied */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Minimum amount applied */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Minimum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - minimumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Minimum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var minimumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } - minimumAmount = minimum.minimumAmount - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Minimum = - Minimum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("minimumAmount", minimumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Minimum && appliesToPriceIds == other.appliesToPriceIds && minimumAmount == other.minimumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, minimumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(using = SubLineItem.Deserializer::class) - @JsonSerialize(using = SubLineItem.Serializer::class) - class SubLineItem - private constructor( - private val matrix: MatrixSubLineItem? = null, - private val tier: TierSubLineItem? = null, - private val other: OtherSubLineItem? = null, - private val _json: JsonValue? = null, - ) { - - fun matrix(): Optional = Optional.ofNullable(matrix) - - fun tier(): Optional = Optional.ofNullable(tier) - - fun other(): Optional = Optional.ofNullable(other) - - fun isMatrix(): Boolean = matrix != null - - fun isTier(): Boolean = tier != null - - fun isOther(): Boolean = other != null - - fun asMatrix(): MatrixSubLineItem = matrix.getOrThrow("matrix") - - fun asTier(): TierSubLineItem = tier.getOrThrow("tier") - - fun asOther(): OtherSubLineItem = other.getOrThrow("other") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - matrix != null -> visitor.visitMatrix(matrix) - tier != null -> visitor.visitTier(tier) - other != null -> visitor.visitOther(other) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): SubLineItem = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitMatrix(matrix: MatrixSubLineItem) { - matrix.validate() - } - - override fun visitTier(tier: TierSubLineItem) { - tier.validate() - } - - override fun visitOther(other: OtherSubLineItem) { - other.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is SubLineItem && matrix == other.matrix && tier == other.tier && this.other == other.other /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(matrix, tier, other) /* spotless:on */ - - override fun toString(): String = - when { - matrix != null -> "SubLineItem{matrix=$matrix}" - tier != null -> "SubLineItem{tier=$tier}" - other != null -> "SubLineItem{other=$other}" - _json != null -> "SubLineItem{_unknown=$_json}" - else -> throw IllegalStateException("Invalid SubLineItem") - } - - companion object { - - @JvmStatic fun ofMatrix(matrix: MatrixSubLineItem) = SubLineItem(matrix = matrix) - - @JvmStatic fun ofTier(tier: TierSubLineItem) = SubLineItem(tier = tier) - - @JvmStatic fun ofOther(other: OtherSubLineItem) = SubLineItem(other = other) - } - - /** - * An interface that defines how to map each variant of [SubLineItem] to a value of type - * [T]. - */ - interface Visitor { - - fun visitMatrix(matrix: MatrixSubLineItem): T - - fun visitTier(tier: TierSubLineItem): T - - fun visitOther(other: OtherSubLineItem): T - - /** - * Maps an unknown variant of [SubLineItem] to a value of type [T]. - * - * An instance of [SubLineItem] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown SubLineItem: $json") - } - } - - internal class Deserializer : BaseDeserializer(SubLineItem::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): SubLineItem { - val json = JsonValue.fromJsonNode(node) - val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - - when (type) { - "matrix" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return SubLineItem(matrix = it, _json = json) - } - } - "tier" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return SubLineItem(tier = it, _json = json) - } - } - "'null'" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return SubLineItem(other = it, _json = json) - } - } - } - - return SubLineItem(_json = json) - } - } - - internal class Serializer : BaseSerializer(SubLineItem::class) { - - override fun serialize( - value: SubLineItem, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.matrix != null -> generator.writeObject(value.matrix) - value.tier != null -> generator.writeObject(value.tier) - value.other != null -> generator.writeObject(value.other) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid SubLineItem") - } - } - } - - @NoAutoDetect - class MatrixSubLineItem - @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("grouping") - @ExcludeMissing - private val grouping: JsonField = JsonMissing.of(), - @JsonProperty("matrix_config") - @ExcludeMissing - private val matrixConfig: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - private val quantity: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The total amount for this sub line item. */ - fun amount(): String = amount.getRequired("amount") - - fun grouping(): Optional = - Optional.ofNullable(grouping.getNullable("grouping")) - - fun matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_config") - - fun name(): String = name.getRequired("name") - - fun quantity(): Double = quantity.getRequired("quantity") - - fun type(): Type = type.getRequired("type") - - /** The total amount for this sub line item. */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - @JsonProperty("grouping") - @ExcludeMissing - fun _grouping(): JsonField = grouping - - @JsonProperty("matrix_config") - @ExcludeMissing - fun _matrixConfig(): JsonField = matrixConfig - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("quantity") - @ExcludeMissing - fun _quantity(): JsonField = quantity - - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MatrixSubLineItem = apply { - if (validated) { - return@apply - } - - amount() - grouping().ifPresent { it.validate() } - matrixConfig().validate() - name() - quantity() - type() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MatrixSubLineItem]. */ - class Builder internal constructor() { - - private var amount: JsonField? = null - private var grouping: JsonField? = null - private var matrixConfig: JsonField? = null - private var name: JsonField? = null - private var quantity: JsonField? = null - private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(matrixSubLineItem: MatrixSubLineItem) = apply { - amount = matrixSubLineItem.amount - grouping = matrixSubLineItem.grouping - matrixConfig = matrixSubLineItem.matrixConfig - name = matrixSubLineItem.name - quantity = matrixSubLineItem.quantity - type = matrixSubLineItem.type - additionalProperties = matrixSubLineItem.additionalProperties.toMutableMap() - } - - /** The total amount for this sub line item. */ - fun amount(amount: String) = amount(JsonField.of(amount)) - - /** The total amount for this sub line item. */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun grouping(grouping: Grouping?) = grouping(JsonField.ofNullable(grouping)) - - fun grouping(grouping: Optional) = grouping(grouping.orElse(null)) - - fun grouping(grouping: JsonField) = apply { this.grouping = grouping } - - fun matrixConfig(matrixConfig: MatrixConfig) = - matrixConfig(JsonField.of(matrixConfig)) - - fun matrixConfig(matrixConfig: JsonField) = apply { - this.matrixConfig = matrixConfig - } - - fun name(name: String) = name(JsonField.of(name)) - - fun name(name: JsonField) = apply { this.name = name } - - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun type(type: Type) = type(JsonField.of(type)) - - 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) - } - - fun build(): MatrixSubLineItem = - MatrixSubLineItem( - checkRequired("amount", amount), - checkRequired("grouping", grouping), - checkRequired("matrixConfig", matrixConfig), - checkRequired("name", name), - checkRequired("quantity", quantity), - checkRequired("type", type), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Grouping - @JsonCreator - private constructor( - @JsonProperty("key") - @ExcludeMissing - private val key: JsonField = JsonMissing.of(), - @JsonProperty("value") - @ExcludeMissing - private val value: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun key(): String = key.getRequired("key") - - /** No value indicates the default group */ - fun value(): Optional = Optional.ofNullable(value.getNullable("value")) - - @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key - - /** No value indicates the default group */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Grouping = apply { - if (validated) { - return@apply - } - - key() - value() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Grouping]. */ - class Builder internal constructor() { - - private var key: JsonField? = null - private var value: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(grouping: Grouping) = apply { - key = grouping.key - value = grouping.value - additionalProperties = grouping.additionalProperties.toMutableMap() - } - - fun key(key: String) = key(JsonField.of(key)) - - fun key(key: JsonField) = apply { this.key = key } - - /** No value indicates the default group */ - fun value(value: String?) = value(JsonField.ofNullable(value)) - - /** No value indicates the default group */ - fun value(value: Optional) = value(value.orElse(null)) - - /** No value indicates the default group */ - fun value(value: JsonField) = apply { this.value = 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) - } - - fun build(): Grouping = - Grouping( - checkRequired("key", key), - checkRequired("value", value), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Grouping && key == other.key && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(key, value, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Grouping{key=$key, value=$value, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class MatrixConfig - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The ordered dimension values for this line item. */ - fun dimensionValues(): List = - dimensionValues.getRequired("dimension_values") - - /** The ordered dimension values for this line item. */ - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MatrixConfig = apply { - if (validated) { - return@apply - } - - dimensionValues() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MatrixConfig]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(matrixConfig: MatrixConfig) = apply { - dimensionValues = - matrixConfig.dimensionValues.map { it.toMutableList() } - additionalProperties = matrixConfig.additionalProperties.toMutableMap() - } - - /** The ordered dimension values for this line item. */ - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - /** The ordered dimension values for this line item. */ - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - /** The ordered dimension values for this line item. */ - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): MatrixConfig = - MatrixConfig( - checkRequired("dimensionValues", dimensionValues).map { - it.toImmutable() - }, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MatrixConfig && dimensionValues == other.dimensionValues && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MatrixConfig{dimensionValues=$dimensionValues, additionalProperties=$additionalProperties}" - } - - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MATRIX = of("matrix") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - MATRIX - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MATRIX, - /** - * An enum member indicating that [Type] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MATRIX -> Value.MATRIX - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MATRIX -> Known.MATRIX - else -> throw OrbInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MatrixSubLineItem && amount == other.amount && grouping == other.grouping && matrixConfig == other.matrixConfig && name == other.name && quantity == other.quantity && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, grouping, matrixConfig, name, quantity, type, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MatrixSubLineItem{amount=$amount, grouping=$grouping, matrixConfig=$matrixConfig, name=$name, quantity=$quantity, type=$type, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class TierSubLineItem - @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("grouping") - @ExcludeMissing - private val grouping: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - private val quantity: JsonField = JsonMissing.of(), - @JsonProperty("tier_config") - @ExcludeMissing - private val tierConfig: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The total amount for this sub line item. */ - fun amount(): String = amount.getRequired("amount") - - fun grouping(): Optional = - Optional.ofNullable(grouping.getNullable("grouping")) - - fun name(): String = name.getRequired("name") - - fun quantity(): Double = quantity.getRequired("quantity") - - fun tierConfig(): TierConfig = tierConfig.getRequired("tier_config") - - fun type(): Type = type.getRequired("type") - - /** The total amount for this sub line item. */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - @JsonProperty("grouping") - @ExcludeMissing - fun _grouping(): JsonField = grouping - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("quantity") - @ExcludeMissing - fun _quantity(): JsonField = quantity - - @JsonProperty("tier_config") - @ExcludeMissing - fun _tierConfig(): JsonField = tierConfig - - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TierSubLineItem = apply { - if (validated) { - return@apply - } - - amount() - grouping().ifPresent { it.validate() } - name() - quantity() - tierConfig().validate() - type() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TierSubLineItem]. */ - class Builder internal constructor() { - - private var amount: JsonField? = null - private var grouping: JsonField? = null - private var name: JsonField? = null - private var quantity: JsonField? = null - private var tierConfig: JsonField? = null - private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tierSubLineItem: TierSubLineItem) = apply { - amount = tierSubLineItem.amount - grouping = tierSubLineItem.grouping - name = tierSubLineItem.name - quantity = tierSubLineItem.quantity - tierConfig = tierSubLineItem.tierConfig - type = tierSubLineItem.type - additionalProperties = tierSubLineItem.additionalProperties.toMutableMap() - } - - /** The total amount for this sub line item. */ - fun amount(amount: String) = amount(JsonField.of(amount)) - - /** The total amount for this sub line item. */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun grouping(grouping: Grouping?) = grouping(JsonField.ofNullable(grouping)) - - fun grouping(grouping: Optional) = grouping(grouping.orElse(null)) - - fun grouping(grouping: JsonField) = apply { this.grouping = grouping } - - fun name(name: String) = name(JsonField.of(name)) - - fun name(name: JsonField) = apply { this.name = name } - - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun tierConfig(tierConfig: TierConfig) = tierConfig(JsonField.of(tierConfig)) - - fun tierConfig(tierConfig: JsonField) = apply { - this.tierConfig = tierConfig - } - - fun type(type: Type) = type(JsonField.of(type)) - - 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) - } - - fun build(): TierSubLineItem = - TierSubLineItem( - checkRequired("amount", amount), - checkRequired("grouping", grouping), - checkRequired("name", name), - checkRequired("quantity", quantity), - checkRequired("tierConfig", tierConfig), - checkRequired("type", type), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Grouping - @JsonCreator - private constructor( - @JsonProperty("key") - @ExcludeMissing - private val key: JsonField = JsonMissing.of(), - @JsonProperty("value") - @ExcludeMissing - private val value: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun key(): String = key.getRequired("key") - - /** No value indicates the default group */ - fun value(): Optional = Optional.ofNullable(value.getNullable("value")) - - @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key - - /** No value indicates the default group */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Grouping = apply { - if (validated) { - return@apply - } - - key() - value() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Grouping]. */ - class Builder internal constructor() { - - private var key: JsonField? = null - private var value: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(grouping: Grouping) = apply { - key = grouping.key - value = grouping.value - additionalProperties = grouping.additionalProperties.toMutableMap() - } - - fun key(key: String) = key(JsonField.of(key)) - - fun key(key: JsonField) = apply { this.key = key } - - /** No value indicates the default group */ - fun value(value: String?) = value(JsonField.ofNullable(value)) - - /** No value indicates the default group */ - fun value(value: Optional) = value(value.orElse(null)) - - /** No value indicates the default group */ - fun value(value: JsonField) = apply { this.value = 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) - } - - fun build(): Grouping = - Grouping( - checkRequired("key", key), - checkRequired("value", value), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Grouping && key == other.key && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(key, value, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Grouping{key=$key, value=$value, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class TierConfig - @JsonCreator - private constructor( - @JsonProperty("first_unit") - @ExcludeMissing - private val firstUnit: JsonField = JsonMissing.of(), - @JsonProperty("last_unit") - @ExcludeMissing - private val lastUnit: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - private val unitAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun firstUnit(): Double = firstUnit.getRequired("first_unit") - - fun lastUnit(): Optional = - Optional.ofNullable(lastUnit.getNullable("last_unit")) - - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - @JsonProperty("first_unit") - @ExcludeMissing - fun _firstUnit(): JsonField = firstUnit - - @JsonProperty("last_unit") - @ExcludeMissing - fun _lastUnit(): JsonField = lastUnit - - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TierConfig = apply { - if (validated) { - return@apply - } - - firstUnit() - lastUnit() - unitAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TierConfig]. */ - class Builder internal constructor() { - - private var firstUnit: JsonField? = null - private var lastUnit: JsonField? = null - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tierConfig: TierConfig) = apply { - firstUnit = tierConfig.firstUnit - lastUnit = tierConfig.lastUnit - unitAmount = tierConfig.unitAmount - additionalProperties = tierConfig.additionalProperties.toMutableMap() - } - - fun firstUnit(firstUnit: Double) = firstUnit(JsonField.of(firstUnit)) - - fun firstUnit(firstUnit: JsonField) = apply { - this.firstUnit = firstUnit - } - - fun lastUnit(lastUnit: Double?) = lastUnit(JsonField.ofNullable(lastUnit)) - - fun lastUnit(lastUnit: Double) = lastUnit(lastUnit as Double?) - - @Suppress( - "USELESS_CAST" - ) // See https://youtrack.jetbrains.com/issue/KT-74228 - fun lastUnit(lastUnit: Optional) = - lastUnit(lastUnit.orElse(null) as Double?) - - fun lastUnit(lastUnit: JsonField) = apply { - this.lastUnit = lastUnit - } - - fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - - 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 build(): TierConfig = - TierConfig( - checkRequired("firstUnit", firstUnit), - checkRequired("lastUnit", lastUnit), - checkRequired("unitAmount", unitAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TierConfig && firstUnit == other.firstUnit && lastUnit == other.lastUnit && unitAmount == other.unitAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(firstUnit, lastUnit, unitAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TierConfig{firstUnit=$firstUnit, lastUnit=$lastUnit, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } - - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val TIER = of("tier") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - TIER - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIER, - /** - * An enum member indicating that [Type] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIER -> Value.TIER - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TIER -> Known.TIER - else -> throw OrbInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TierSubLineItem && amount == other.amount && grouping == other.grouping && name == other.name && quantity == other.quantity && tierConfig == other.tierConfig && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, grouping, name, quantity, tierConfig, type, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TierSubLineItem{amount=$amount, grouping=$grouping, name=$name, quantity=$quantity, tierConfig=$tierConfig, type=$type, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class OtherSubLineItem - @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("grouping") - @ExcludeMissing - private val grouping: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - private val quantity: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The total amount for this sub line item. */ - fun amount(): String = amount.getRequired("amount") - - fun grouping(): Optional = - Optional.ofNullable(grouping.getNullable("grouping")) - - fun name(): String = name.getRequired("name") - - fun quantity(): Double = quantity.getRequired("quantity") - - fun type(): Type = type.getRequired("type") - - /** The total amount for this sub line item. */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - @JsonProperty("grouping") - @ExcludeMissing - fun _grouping(): JsonField = grouping - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("quantity") - @ExcludeMissing - fun _quantity(): JsonField = quantity - - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): OtherSubLineItem = apply { - if (validated) { - return@apply - } - - amount() - grouping().ifPresent { it.validate() } - name() - quantity() - type() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [OtherSubLineItem]. */ - class Builder internal constructor() { - - private var amount: JsonField? = null - private var grouping: JsonField? = null - private var name: JsonField? = null - private var quantity: JsonField? = null - private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(otherSubLineItem: OtherSubLineItem) = apply { - amount = otherSubLineItem.amount - grouping = otherSubLineItem.grouping - name = otherSubLineItem.name - quantity = otherSubLineItem.quantity - type = otherSubLineItem.type - additionalProperties = otherSubLineItem.additionalProperties.toMutableMap() - } - - /** The total amount for this sub line item. */ - fun amount(amount: String) = amount(JsonField.of(amount)) - - /** The total amount for this sub line item. */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun grouping(grouping: Grouping?) = grouping(JsonField.ofNullable(grouping)) - - fun grouping(grouping: Optional) = grouping(grouping.orElse(null)) - - fun grouping(grouping: JsonField) = apply { this.grouping = grouping } - - fun name(name: String) = name(JsonField.of(name)) - - fun name(name: JsonField) = apply { this.name = name } - - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun type(type: Type) = type(JsonField.of(type)) - - 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) - } - - fun build(): OtherSubLineItem = - OtherSubLineItem( - checkRequired("amount", amount), - checkRequired("grouping", grouping), - checkRequired("name", name), - checkRequired("quantity", quantity), - checkRequired("type", type), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Grouping - @JsonCreator - private constructor( - @JsonProperty("key") - @ExcludeMissing - private val key: JsonField = JsonMissing.of(), - @JsonProperty("value") - @ExcludeMissing - private val value: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun key(): String = key.getRequired("key") - - /** No value indicates the default group */ - fun value(): Optional = Optional.ofNullable(value.getNullable("value")) - - @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key - - /** No value indicates the default group */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Grouping = apply { - if (validated) { - return@apply - } - - key() - value() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Grouping]. */ - class Builder internal constructor() { - - private var key: JsonField? = null - private var value: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(grouping: Grouping) = apply { - key = grouping.key - value = grouping.value - additionalProperties = grouping.additionalProperties.toMutableMap() - } - - fun key(key: String) = key(JsonField.of(key)) - - fun key(key: JsonField) = apply { this.key = key } - - /** No value indicates the default group */ - fun value(value: String?) = value(JsonField.ofNullable(value)) - - /** No value indicates the default group */ - fun value(value: Optional) = value(value.orElse(null)) - - /** No value indicates the default group */ - fun value(value: JsonField) = apply { this.value = 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) - } - - fun build(): Grouping = - Grouping( - checkRequired("key", key), - checkRequired("value", value), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Grouping && key == other.key && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(key, value, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Grouping{key=$key, value=$value, additionalProperties=$additionalProperties}" - } - - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val NULL = of("'null'") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - NULL - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - NULL, - /** - * An enum member indicating that [Type] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - NULL -> Value.NULL - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - NULL -> Known.NULL - else -> throw OrbInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is OtherSubLineItem && amount == other.amount && grouping == other.grouping && name == other.name && quantity == other.quantity && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, grouping, name, quantity, type, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "OtherSubLineItem{amount=$amount, grouping=$grouping, name=$name, quantity=$quantity, type=$type, additionalProperties=$additionalProperties}" - } - } - - @NoAutoDetect - class TaxAmount - @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("tax_rate_description") - @ExcludeMissing - private val taxRateDescription: JsonField = JsonMissing.of(), - @JsonProperty("tax_rate_percentage") - @ExcludeMissing - private val taxRatePercentage: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The amount of additional tax incurred by this tax rate. */ - fun amount(): String = amount.getRequired("amount") - - /** The human-readable description of the applied tax rate. */ - fun taxRateDescription(): String = - taxRateDescription.getRequired("tax_rate_description") - - /** The tax rate percentage, out of 100. */ - fun taxRatePercentage(): Optional = - Optional.ofNullable(taxRatePercentage.getNullable("tax_rate_percentage")) - - /** The amount of additional tax incurred by this tax rate. */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** The human-readable description of the applied tax rate. */ - @JsonProperty("tax_rate_description") - @ExcludeMissing - fun _taxRateDescription(): JsonField = taxRateDescription - - /** The tax rate percentage, out of 100. */ - @JsonProperty("tax_rate_percentage") - @ExcludeMissing - fun _taxRatePercentage(): JsonField = taxRatePercentage - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TaxAmount = apply { - if (validated) { - return@apply - } - - amount() - taxRateDescription() - taxRatePercentage() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TaxAmount]. */ - class Builder internal constructor() { - - private var amount: JsonField? = null - private var taxRateDescription: JsonField? = null - private var taxRatePercentage: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(taxAmount: TaxAmount) = apply { - amount = taxAmount.amount - taxRateDescription = taxAmount.taxRateDescription - taxRatePercentage = taxAmount.taxRatePercentage - additionalProperties = taxAmount.additionalProperties.toMutableMap() - } - - /** The amount of additional tax incurred by this tax rate. */ - fun amount(amount: String) = amount(JsonField.of(amount)) - - /** The amount of additional tax incurred by this tax rate. */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** The human-readable description of the applied tax rate. */ - fun taxRateDescription(taxRateDescription: String) = - taxRateDescription(JsonField.of(taxRateDescription)) - - /** The human-readable description of the applied tax rate. */ - fun taxRateDescription(taxRateDescription: JsonField) = apply { - this.taxRateDescription = taxRateDescription - } - - /** The tax rate percentage, out of 100. */ - fun taxRatePercentage(taxRatePercentage: String?) = - taxRatePercentage(JsonField.ofNullable(taxRatePercentage)) - - /** The tax rate percentage, out of 100. */ - fun taxRatePercentage(taxRatePercentage: Optional) = - taxRatePercentage(taxRatePercentage.orElse(null)) - - /** The tax rate percentage, out of 100. */ - fun taxRatePercentage(taxRatePercentage: JsonField) = apply { - this.taxRatePercentage = taxRatePercentage - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): TaxAmount = - TaxAmount( - checkRequired("amount", amount), - checkRequired("taxRateDescription", taxRateDescription), - checkRequired("taxRatePercentage", taxRatePercentage), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TaxAmount && amount == other.amount && taxRateDescription == other.taxRateDescription && taxRatePercentage == other.taxRatePercentage && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, taxRateDescription, taxRatePercentage, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TaxAmount{amount=$amount, taxRateDescription=$taxRateDescription, taxRatePercentage=$taxRatePercentage, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is LineItem && id == other.id && adjustedSubtotal == other.adjustedSubtotal && adjustments == other.adjustments && amount == other.amount && creditsApplied == other.creditsApplied && discount == other.discount && endDate == other.endDate && filter == other.filter && grouping == other.grouping && maximum == other.maximum && maximumAmount == other.maximumAmount && minimum == other.minimum && minimumAmount == other.minimumAmount && name == other.name && partiallyInvoicedAmount == other.partiallyInvoicedAmount && price == other.price && quantity == other.quantity && startDate == other.startDate && subLineItems == other.subLineItems && subtotal == other.subtotal && taxAmounts == other.taxAmounts && usageCustomerIds == other.usageCustomerIds && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustedSubtotal, adjustments, amount, creditsApplied, discount, endDate, filter, grouping, maximum, maximumAmount, minimum, minimumAmount, name, partiallyInvoicedAmount, price, quantity, startDate, subLineItems, subtotal, taxAmounts, usageCustomerIds, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "LineItem{id=$id, adjustedSubtotal=$adjustedSubtotal, adjustments=$adjustments, amount=$amount, creditsApplied=$creditsApplied, discount=$discount, endDate=$endDate, filter=$filter, grouping=$grouping, maximum=$maximum, maximumAmount=$maximumAmount, minimum=$minimum, minimumAmount=$minimumAmount, name=$name, partiallyInvoicedAmount=$partiallyInvoicedAmount, price=$price, quantity=$quantity, startDate=$startDate, subLineItems=$subLineItems, subtotal=$subtotal, taxAmounts=$taxAmounts, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Maximum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, this - * can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Maximum amount applied */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, this - * can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Maximum amount applied */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Maximum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - maximumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Maximum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = maximum.maximumAmount - additionalProperties = maximum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Maximum = - Maximum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, - checkRequired("maximumAmount", maximumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Maximum && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, maximumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Maximum{appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Minimum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, this - * can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Minimum amount applied */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, this - * can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Minimum amount applied */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Minimum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - minimumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Minimum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var minimumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } - minimumAmount = minimum.minimumAmount - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Minimum = - Minimum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, - checkRequired("minimumAmount", minimumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Minimum && appliesToPriceIds == other.appliesToPriceIds && minimumAmount == other.minimumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, minimumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PaymentAttempt - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("payment_provider") - @ExcludeMissing - private val paymentProvider: JsonField = JsonMissing.of(), - @JsonProperty("payment_provider_id") - @ExcludeMissing - private val paymentProviderId: JsonField = JsonMissing.of(), - @JsonProperty("succeeded") - @ExcludeMissing - private val succeeded: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The ID of the payment attempt. */ - fun id(): String = id.getRequired("id") - - /** The amount of the payment attempt. */ - fun amount(): String = amount.getRequired("amount") - - /** The time at which the payment attempt was created. */ - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - /** The payment provider that attempted to collect the payment. */ - fun paymentProvider(): Optional = - Optional.ofNullable(paymentProvider.getNullable("payment_provider")) - - /** The ID of the payment attempt in the payment provider. */ - fun paymentProviderId(): Optional = - Optional.ofNullable(paymentProviderId.getNullable("payment_provider_id")) - - /** Whether the payment attempt succeeded. */ - fun succeeded(): Boolean = succeeded.getRequired("succeeded") - - /** The ID of the payment attempt. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** The amount of the payment attempt. */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** The time at which the payment attempt was created. */ - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - /** The payment provider that attempted to collect the payment. */ - @JsonProperty("payment_provider") - @ExcludeMissing - fun _paymentProvider(): JsonField = paymentProvider - - /** The ID of the payment attempt in the payment provider. */ - @JsonProperty("payment_provider_id") - @ExcludeMissing - fun _paymentProviderId(): JsonField = paymentProviderId - - /** Whether the payment attempt succeeded. */ - @JsonProperty("succeeded") @ExcludeMissing fun _succeeded(): JsonField = succeeded - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PaymentAttempt = apply { - if (validated) { - return@apply - } - - id() - amount() - createdAt() - paymentProvider() - paymentProviderId() - succeeded() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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 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 - succeeded = paymentAttempt.succeeded - additionalProperties = paymentAttempt.additionalProperties.toMutableMap() - } - - /** The ID of the payment attempt. */ - fun id(id: String) = id(JsonField.of(id)) - - /** The ID of the payment attempt. */ - fun id(id: JsonField) = apply { this.id = id } - - /** The amount of the payment attempt. */ - fun amount(amount: String) = amount(JsonField.of(amount)) - - /** The amount of the payment attempt. */ - 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)) - - /** The time at which the payment attempt was created. */ - 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)) - - /** The payment provider that attempted to collect the payment. */ - fun paymentProvider(paymentProvider: Optional) = - paymentProvider(paymentProvider.orElse(null)) - - /** The payment provider that attempted to collect the payment. */ - 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)) - - /** The ID of the payment attempt in the payment provider. */ - fun paymentProviderId(paymentProviderId: Optional) = - paymentProviderId(paymentProviderId.orElse(null)) - - /** The ID of the payment attempt in the payment provider. */ - fun paymentProviderId(paymentProviderId: JsonField) = apply { - this.paymentProviderId = paymentProviderId - } - - /** Whether the payment attempt succeeded. */ - fun succeeded(succeeded: Boolean) = succeeded(JsonField.of(succeeded)) - - /** Whether the payment attempt succeeded. */ - 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) - } - - fun build(): PaymentAttempt = - PaymentAttempt( - checkRequired("id", id), - checkRequired("amount", amount), - checkRequired("createdAt", createdAt), - checkRequired("paymentProvider", paymentProvider), - checkRequired("paymentProviderId", paymentProviderId), - checkRequired("succeeded", succeeded), - additionalProperties.toImmutable(), - ) - } - - /** 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PaymentProvider && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PaymentAttempt && id == other.id && amount == other.amount && createdAt == other.createdAt && paymentProvider == other.paymentProvider && paymentProviderId == other.paymentProviderId && succeeded == other.succeeded && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, createdAt, paymentProvider, paymentProviderId, succeeded, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PaymentAttempt{id=$id, amount=$amount, createdAt=$createdAt, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, succeeded=$succeeded, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class ShippingAddress - @JsonCreator - private constructor( - @JsonProperty("city") - @ExcludeMissing - private val city: JsonField = JsonMissing.of(), - @JsonProperty("country") - @ExcludeMissing - private val country: JsonField = JsonMissing.of(), - @JsonProperty("line1") - @ExcludeMissing - private val line1: JsonField = JsonMissing.of(), - @JsonProperty("line2") - @ExcludeMissing - private val line2: JsonField = JsonMissing.of(), - @JsonProperty("postal_code") - @ExcludeMissing - private val postalCode: JsonField = JsonMissing.of(), - @JsonProperty("state") - @ExcludeMissing - private val state: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun city(): Optional = Optional.ofNullable(city.getNullable("city")) - - fun country(): Optional = Optional.ofNullable(country.getNullable("country")) - - fun line1(): Optional = Optional.ofNullable(line1.getNullable("line1")) - - fun line2(): Optional = Optional.ofNullable(line2.getNullable("line2")) - - fun postalCode(): Optional = - Optional.ofNullable(postalCode.getNullable("postal_code")) - - fun state(): Optional = Optional.ofNullable(state.getNullable("state")) - - @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city - - @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country - - @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField = line1 - - @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 - - @JsonProperty("postal_code") - @ExcludeMissing - fun _postalCode(): JsonField = postalCode - - @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): ShippingAddress = apply { - if (validated) { - return@apply - } - - city() - country() - line1() - line2() - postalCode() - state() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ShippingAddress]. */ - class Builder internal constructor() { - - private var city: JsonField? = null - private var country: JsonField? = null - private var line1: JsonField? = null - private var line2: JsonField? = null - private var postalCode: JsonField? = null - private var state: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(shippingAddress: ShippingAddress) = apply { - city = shippingAddress.city - country = shippingAddress.country - line1 = shippingAddress.line1 - line2 = shippingAddress.line2 - postalCode = shippingAddress.postalCode - state = shippingAddress.state - additionalProperties = shippingAddress.additionalProperties.toMutableMap() - } - - fun city(city: String?) = city(JsonField.ofNullable(city)) - - fun city(city: Optional) = city(city.orElse(null)) - - fun city(city: JsonField) = apply { this.city = city } - - fun country(country: String?) = country(JsonField.ofNullable(country)) - - fun country(country: Optional) = country(country.orElse(null)) - - fun country(country: JsonField) = apply { this.country = country } - - fun line1(line1: String?) = line1(JsonField.ofNullable(line1)) - - fun line1(line1: Optional) = line1(line1.orElse(null)) - - fun line1(line1: JsonField) = apply { this.line1 = line1 } - - fun line2(line2: String?) = line2(JsonField.ofNullable(line2)) - - fun line2(line2: Optional) = line2(line2.orElse(null)) - - fun line2(line2: JsonField) = apply { this.line2 = line2 } - - fun postalCode(postalCode: String?) = postalCode(JsonField.ofNullable(postalCode)) - - fun postalCode(postalCode: Optional) = postalCode(postalCode.orElse(null)) - - fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode } - - fun state(state: String?) = state(JsonField.ofNullable(state)) - - fun state(state: Optional) = state(state.orElse(null)) - - fun state(state: JsonField) = apply { this.state = state } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): ShippingAddress = - ShippingAddress( - checkRequired("city", city), - checkRequired("country", country), - checkRequired("line1", line1), - checkRequired("line2", line2), - checkRequired("postalCode", postalCode), - checkRequired("state", state), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ShippingAddress && city == other.city && country == other.country && line1 == other.line1 && line2 == other.line2 && postalCode == other.postalCode && state == other.state && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(city, country, line1, line2, postalCode, state, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ShippingAddress{city=$city, country=$country, line1=$line1, line2=$line2, postalCode=$postalCode, state=$state, 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 VOID = of("void") @JvmField val DRAFT = of("draft") @@ -11435,97 +2168,6 @@ private constructor( override fun toString() = value.toString() } - @NoAutoDetect - class Subscription - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Subscription = apply { - if (validated) { - return@apply - } - - id() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Subscription]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(subscription: Subscription) = apply { - id = subscription.id - additionalProperties = subscription.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - 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) - } - - fun build(): Subscription = - Subscription(checkRequired("id", id), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Subscription && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Subscription{id=$id, 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/InvoiceCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt index fb7678c4d..207b48635 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 @@ -13,6 +13,7 @@ import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.Params +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams @@ -323,6 +324,17 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .currency() + * .invoiceDate() + * .lineItems() + * .netTerms() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -390,14 +402,8 @@ private constructor( fun addLineItem(lineItem: LineItem) = apply { lineItems = - (lineItems ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(lineItem) + (lineItems ?: JsonField.of(mutableListOf())).also { + checkKnown("lineItems", it).add(lineItem) } } @@ -589,6 +595,17 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [InvoiceCreateParams]. + * + * The following fields are required: + * ```java + * .currency() + * .invoiceDate() + * .lineItems() + * .netTerms() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -911,7 +928,7 @@ private constructor( private val startDate: JsonField = JsonMissing.of(), @JsonProperty("unit_config") @ExcludeMissing - private val unitConfig: JsonField = JsonMissing.of(), + private val unitConfig: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -932,7 +949,7 @@ private constructor( /** A date string to specify the line item's start date in the customer's timezone. */ fun startDate(): LocalDate = startDate.getRequired("start_date") - fun unitConfig(): UnitConfig = unitConfig.getRequired("unit_config") + fun unitConfig(): UnitConfigModel = unitConfig.getRequired("unit_config") /** A date string to specify the line item's end date in the customer's timezone. */ @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate @@ -956,7 +973,7 @@ private constructor( @JsonProperty("unit_config") @ExcludeMissing - fun _unitConfig(): JsonField = unitConfig + fun _unitConfig(): JsonField = unitConfig @JsonAnyGetter @ExcludeMissing @@ -983,6 +1000,20 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [LineItem]. + * + * The following fields are required: + * ```java + * .endDate() + * .itemId() + * .modelType() + * .name() + * .quantity() + * .startDate() + * .unitConfig() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -995,7 +1026,7 @@ private constructor( private var name: JsonField? = null private var quantity: JsonField? = null private var startDate: JsonField? = null - private var unitConfig: JsonField? = null + private var unitConfig: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1042,9 +1073,9 @@ private constructor( /** A date string to specify the line item's start date in the customer's timezone. */ fun startDate(startDate: JsonField) = apply { this.startDate = startDate } - fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) + fun unitConfig(unitConfig: UnitConfigModel) = unitConfig(JsonField.of(unitConfig)) - fun unitConfig(unitConfig: JsonField) = apply { + fun unitConfig(unitConfig: JsonField) = apply { this.unitConfig = unitConfig } @@ -1176,114 +1207,6 @@ private constructor( override fun toString() = value.toString() } - @NoAutoDetect - class UnitConfig - @JsonCreator - private constructor( - @JsonProperty("unit_amount") - @ExcludeMissing - private val unitAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Rate per unit of usage */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** Rate per unit of usage */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): UnitConfig = apply { - if (validated) { - return@apply - } - - unitAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnitConfig]. */ - class Builder internal constructor() { - - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unitConfig: UnitConfig) = apply { - unitAmount = unitConfig.unitAmount - additionalProperties = unitConfig.additionalProperties.toMutableMap() - } - - /** Rate per unit of usage */ - fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - - /** Rate per unit of usage */ - 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 build(): UnitConfig = - UnitConfig( - checkRequired("unitAmount", unitAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UnitConfig && unitAmount == other.unitAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(unitAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnitConfig{unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1333,6 +1256,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchParams.kt index c2b4b28e6..9412d65ee 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchParams.kt @@ -38,6 +38,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [InvoiceFetchParams]. + * + * The following fields are required: + * ```java + * .invoiceId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingParams.kt index 68b8d2a67..cbeacaa1a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingParams.kt @@ -39,6 +39,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [InvoiceFetchUpcomingParams]. + * + * The following fields are required: + * ```java + * .subscriptionId() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 9145ab807..95035fc3f 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 @@ -6,30 +6,20 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.immutableEmptyMap import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import java.util.Objects import java.util.Optional -import kotlin.jvm.optionals.getOrNull @NoAutoDetect class InvoiceFetchUpcomingResponse @@ -41,29 +31,29 @@ private constructor( private val amountDue: JsonField = JsonMissing.of(), @JsonProperty("auto_collection") @ExcludeMissing - private val autoCollection: JsonField = JsonMissing.of(), + private val autoCollection: JsonField = JsonMissing.of(), @JsonProperty("billing_address") @ExcludeMissing - private val billingAddress: JsonField = JsonMissing.of(), + private val billingAddress: JsonField = JsonMissing.of(), @JsonProperty("created_at") @ExcludeMissing private val createdAt: JsonField = JsonMissing.of(), @JsonProperty("credit_notes") @ExcludeMissing - private val creditNotes: JsonField> = JsonMissing.of(), + private val creditNotes: JsonField> = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing private val currency: JsonField = JsonMissing.of(), @JsonProperty("customer") @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), + private val customer: JsonField = JsonMissing.of(), @JsonProperty("customer_balance_transactions") @ExcludeMissing - private val customerBalanceTransactions: JsonField> = + private val customerBalanceTransactions: JsonField> = JsonMissing.of(), @JsonProperty("customer_tax_id") @ExcludeMissing - private val customerTaxId: JsonField = JsonMissing.of(), + private val customerTaxId: JsonField = JsonMissing.of(), @JsonProperty("discount") @ExcludeMissing private val discount: JsonValue = JsonMissing.of(), @JsonProperty("discounts") @ExcludeMissing @@ -94,10 +84,10 @@ private constructor( private val issuedAt: JsonField = JsonMissing.of(), @JsonProperty("line_items") @ExcludeMissing - private val lineItems: JsonField> = JsonMissing.of(), + private val lineItems: JsonField> = JsonMissing.of(), @JsonProperty("maximum") @ExcludeMissing - private val maximum: JsonField = JsonMissing.of(), + private val maximum: JsonField = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing private val maximumAmount: JsonField = JsonMissing.of(), @@ -107,7 +97,7 @@ private constructor( private val metadata: JsonField = JsonMissing.of(), @JsonProperty("minimum") @ExcludeMissing - private val minimum: JsonField = JsonMissing.of(), + private val minimum: JsonField = JsonMissing.of(), @JsonProperty("minimum_amount") @ExcludeMissing private val minimumAmount: JsonField = JsonMissing.of(), @@ -116,7 +106,7 @@ private constructor( private val paidAt: JsonField = JsonMissing.of(), @JsonProperty("payment_attempts") @ExcludeMissing - private val paymentAttempts: JsonField> = JsonMissing.of(), + private val paymentAttempts: JsonField> = JsonMissing.of(), @JsonProperty("payment_failed_at") @ExcludeMissing private val paymentFailedAt: JsonField = JsonMissing.of(), @@ -128,13 +118,13 @@ private constructor( private val scheduledIssueAt: JsonField = JsonMissing.of(), @JsonProperty("shipping_address") @ExcludeMissing - private val shippingAddress: JsonField = JsonMissing.of(), + private val shippingAddress: JsonField = JsonMissing.of(), @JsonProperty("status") @ExcludeMissing private val status: JsonField = JsonMissing.of(), @JsonProperty("subscription") @ExcludeMissing - private val subscription: JsonField = JsonMissing.of(), + private val subscription: JsonField = JsonMissing.of(), @JsonProperty("subtotal") @ExcludeMissing private val subtotal: JsonField = JsonMissing.of(), @@ -162,23 +152,23 @@ private constructor( */ fun amountDue(): String = amountDue.getRequired("amount_due") - fun autoCollection(): AutoCollection = autoCollection.getRequired("auto_collection") + fun autoCollection(): AutoCollectionModel = autoCollection.getRequired("auto_collection") - fun billingAddress(): Optional = + fun billingAddress(): Optional = Optional.ofNullable(billingAddress.getNullable("billing_address")) /** The creation time of the resource in Orb. */ fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") /** A list of credit notes associated with the invoice */ - fun creditNotes(): List = creditNotes.getRequired("credit_notes") + fun creditNotes(): List = creditNotes.getRequired("credit_notes") /** An ISO 4217 currency string or `credits` */ fun currency(): String = currency.getRequired("currency") - fun customer(): Customer = customer.getRequired("customer") + fun customer(): CustomerMinifiedModel = customer.getRequired("customer") - fun customerBalanceTransactions(): List = + fun customerBalanceTransactions(): List = customerBalanceTransactions.getRequired("customer_balance_transactions") /** @@ -287,7 +277,7 @@ private constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - fun customerTaxId(): Optional = + fun customerTaxId(): Optional = Optional.ofNullable(customerTaxId.getNullable("customer_tax_id")) /** @@ -347,9 +337,9 @@ private constructor( Optional.ofNullable(issuedAt.getNullable("issued_at")) /** The breakdown of prices in this invoice. */ - fun lineItems(): List = lineItems.getRequired("line_items") + fun lineItems(): List = lineItems.getRequired("line_items") - fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) @@ -364,7 +354,7 @@ private constructor( */ fun metadata(): Metadata = metadata.getRequired("metadata") - fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) fun minimumAmount(): Optional = Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) @@ -373,7 +363,8 @@ private constructor( fun paidAt(): Optional = Optional.ofNullable(paidAt.getNullable("paid_at")) /** A list of payment attempts associated with the invoice */ - fun paymentAttempts(): List = paymentAttempts.getRequired("payment_attempts") + 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 @@ -397,12 +388,12 @@ private constructor( fun scheduledIssueAt(): Optional = Optional.ofNullable(scheduledIssueAt.getNullable("scheduled_issue_at")) - fun shippingAddress(): Optional = + fun shippingAddress(): Optional = Optional.ofNullable(shippingAddress.getNullable("shipping_address")) fun status(): Status = status.getRequired("status") - fun subscription(): Optional = + fun subscription(): Optional = Optional.ofNullable(subscription.getNullable("subscription")) /** The total before any discounts and minimums are applied. */ @@ -442,11 +433,11 @@ private constructor( @JsonProperty("auto_collection") @ExcludeMissing - fun _autoCollection(): JsonField = autoCollection + fun _autoCollection(): JsonField = autoCollection @JsonProperty("billing_address") @ExcludeMissing - fun _billingAddress(): JsonField = billingAddress + fun _billingAddress(): JsonField = billingAddress /** The creation time of the resource in Orb. */ @JsonProperty("created_at") @@ -456,16 +447,18 @@ private constructor( /** A list of credit notes associated with the invoice */ @JsonProperty("credit_notes") @ExcludeMissing - fun _creditNotes(): JsonField> = creditNotes + fun _creditNotes(): JsonField> = creditNotes /** An ISO 4217 currency string or `credits` */ @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer + @JsonProperty("customer") + @ExcludeMissing + fun _customer(): JsonField = customer @JsonProperty("customer_balance_transactions") @ExcludeMissing - fun _customerBalanceTransactions(): JsonField> = + fun _customerBalanceTransactions(): JsonField> = customerBalanceTransactions /** @@ -576,7 +569,7 @@ private constructor( */ @JsonProperty("customer_tax_id") @ExcludeMissing - fun _customerTaxId(): JsonField = customerTaxId + fun _customerTaxId(): JsonField = customerTaxId @JsonProperty("discounts") @ExcludeMissing @@ -636,9 +629,9 @@ private constructor( /** The breakdown of prices in this invoice. */ @JsonProperty("line_items") @ExcludeMissing - fun _lineItems(): JsonField> = lineItems + fun _lineItems(): JsonField> = lineItems - @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum @JsonProperty("maximum_amount") @ExcludeMissing @@ -654,7 +647,7 @@ private constructor( */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum @JsonProperty("minimum_amount") @ExcludeMissing @@ -666,7 +659,7 @@ private constructor( /** A list of payment attempts associated with the invoice */ @JsonProperty("payment_attempts") @ExcludeMissing - fun _paymentAttempts(): JsonField> = paymentAttempts + fun _paymentAttempts(): JsonField> = paymentAttempts /** * If payment was attempted on this invoice but failed, this will be the time of the most recent @@ -695,13 +688,13 @@ private constructor( @JsonProperty("shipping_address") @ExcludeMissing - fun _shippingAddress(): JsonField = shippingAddress + fun _shippingAddress(): JsonField = shippingAddress @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status @JsonProperty("subscription") @ExcludeMissing - fun _subscription(): JsonField = subscription + fun _subscription(): JsonField = subscription /** The total before any discounts and minimums are applied. */ @JsonProperty("subtotal") @ExcludeMissing fun _subtotal(): JsonField = subtotal @@ -792,6 +785,54 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [InvoiceFetchUpcomingResponse]. + * + * The following fields are required: + * ```java + * .id() + * .amountDue() + * .autoCollection() + * .billingAddress() + * .createdAt() + * .creditNotes() + * .currency() + * .customer() + * .customerBalanceTransactions() + * .customerTaxId() + * .discount() + * .discounts() + * .dueDate() + * .eligibleToIssueAt() + * .hostedInvoiceUrl() + * .invoiceNumber() + * .invoicePdf() + * .invoiceSource() + * .issueFailedAt() + * .issuedAt() + * .lineItems() + * .maximum() + * .maximumAmount() + * .memo() + * .metadata() + * .minimum() + * .minimumAmount() + * .paidAt() + * .paymentAttempts() + * .paymentFailedAt() + * .paymentStartedAt() + * .scheduledIssueAt() + * .shippingAddress() + * .status() + * .subscription() + * .subtotal() + * .syncFailedAt() + * .targetDate() + * .total() + * .voidedAt() + * .willAutoIssue() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -800,16 +841,16 @@ private constructor( private var id: JsonField? = null private var amountDue: JsonField? = null - private var autoCollection: JsonField? = null - private var billingAddress: JsonField? = null + private var autoCollection: JsonField? = null + private var billingAddress: JsonField? = null private var createdAt: JsonField? = null - private var creditNotes: JsonField>? = null + private var creditNotes: JsonField>? = null private var currency: JsonField? = null - private var customer: JsonField? = null + private var customer: JsonField? = null private var customerBalanceTransactions: - JsonField>? = + JsonField>? = null - private var customerTaxId: JsonField? = null + private var customerTaxId: JsonField? = null private var discount: JsonValue? = null private var discounts: JsonField>? = null private var dueDate: JsonField? = null @@ -820,21 +861,21 @@ private constructor( private var invoiceSource: JsonField? = null private var issueFailedAt: JsonField? = null private var issuedAt: JsonField? = null - private var lineItems: JsonField>? = null - private var maximum: JsonField? = null + private var lineItems: JsonField>? = null + private var maximum: JsonField? = null private var maximumAmount: JsonField? = null private var memo: JsonField? = null private var metadata: JsonField? = null - private var minimum: JsonField? = null + private var minimum: JsonField? = null private var minimumAmount: JsonField? = null private var paidAt: JsonField? = null - private var paymentAttempts: 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 shippingAddress: JsonField? = null private var status: JsonField? = null - private var subscription: JsonField? = null + private var subscription: JsonField? = null private var subtotal: JsonField? = null private var syncFailedAt: JsonField? = null private var targetDate: JsonField? = null @@ -907,20 +948,20 @@ private constructor( */ fun amountDue(amountDue: JsonField) = apply { this.amountDue = amountDue } - fun autoCollection(autoCollection: AutoCollection) = + fun autoCollection(autoCollection: AutoCollectionModel) = autoCollection(JsonField.of(autoCollection)) - fun autoCollection(autoCollection: JsonField) = apply { + fun autoCollection(autoCollection: JsonField) = apply { this.autoCollection = autoCollection } - fun billingAddress(billingAddress: BillingAddress?) = + fun billingAddress(billingAddress: AddressModel?) = billingAddress(JsonField.ofNullable(billingAddress)) - fun billingAddress(billingAddress: Optional) = + fun billingAddress(billingAddress: Optional) = billingAddress(billingAddress.orElse(null)) - fun billingAddress(billingAddress: JsonField) = apply { + fun billingAddress(billingAddress: JsonField) = apply { this.billingAddress = billingAddress } @@ -931,24 +972,19 @@ private constructor( 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)) + fun creditNotes(creditNotes: List) = + creditNotes(JsonField.of(creditNotes)) /** A list of credit notes associated with the invoice */ - fun creditNotes(creditNotes: JsonField>) = apply { + fun creditNotes(creditNotes: JsonField>) = apply { this.creditNotes = creditNotes.map { it.toMutableList() } } /** A list of credit notes associated with the invoice */ - fun addCreditNote(creditNote: CreditNote) = apply { + fun addCreditNote(creditNote: CreditNoteSummaryModel) = apply { creditNotes = - (creditNotes ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(creditNote) + (creditNotes ?: JsonField.of(mutableListOf())).also { + checkKnown("creditNotes", it).add(creditNote) } } @@ -958,34 +994,31 @@ private constructor( /** An ISO 4217 currency string or `credits` */ fun currency(currency: JsonField) = apply { this.currency = currency } - fun customer(customer: Customer) = customer(JsonField.of(customer)) + fun customer(customer: CustomerMinifiedModel) = customer(JsonField.of(customer)) - fun customer(customer: JsonField) = apply { this.customer = customer } + fun customer(customer: JsonField) = apply { + this.customer = customer + } fun customerBalanceTransactions( - customerBalanceTransactions: List + customerBalanceTransactions: List ) = customerBalanceTransactions(JsonField.of(customerBalanceTransactions)) fun customerBalanceTransactions( - customerBalanceTransactions: JsonField> + customerBalanceTransactions: JsonField> ) = apply { this.customerBalanceTransactions = customerBalanceTransactions.map { it.toMutableList() } } - fun addCustomerBalanceTransaction(customerBalanceTransaction: CustomerBalanceTransaction) = - apply { - customerBalanceTransactions = - (customerBalanceTransactions ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(customerBalanceTransaction) - } - } + fun addCustomerBalanceTransaction( + customerBalanceTransaction: CustomerBalanceTransactionModel + ) = 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 @@ -1093,7 +1126,7 @@ private constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - fun customerTaxId(customerTaxId: CustomerTaxId?) = + fun customerTaxId(customerTaxId: CustomerTaxIdModel?) = customerTaxId(JsonField.ofNullable(customerTaxId)) /** @@ -1202,7 +1235,7 @@ private constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - fun customerTaxId(customerTaxId: Optional) = + fun customerTaxId(customerTaxId: Optional) = customerTaxId(customerTaxId.orElse(null)) /** @@ -1311,7 +1344,7 @@ private constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - fun customerTaxId(customerTaxId: JsonField) = apply { + fun customerTaxId(customerTaxId: JsonField) = apply { this.customerTaxId = customerTaxId } @@ -1331,14 +1364,8 @@ private constructor( fun addDiscount(discount: InvoiceLevelDiscount) = apply { discounts = - (discounts ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(discount) + (discounts ?: JsonField.of(mutableListOf())).also { + checkKnown("discounts", it).add(discount) } } @@ -1492,32 +1519,26 @@ private constructor( fun issuedAt(issuedAt: JsonField) = apply { this.issuedAt = issuedAt } /** The breakdown of prices in this invoice. */ - fun lineItems(lineItems: List) = lineItems(JsonField.of(lineItems)) + fun lineItems(lineItems: List) = lineItems(JsonField.of(lineItems)) /** The breakdown of prices in this invoice. */ - fun lineItems(lineItems: JsonField>) = apply { + fun lineItems(lineItems: JsonField>) = apply { this.lineItems = lineItems.map { it.toMutableList() } } /** The breakdown of prices in this invoice. */ - fun addLineItem(lineItem: LineItem) = apply { + fun addLineItem(lineItem: InvoiceLineItemModel) = apply { lineItems = - (lineItems ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(lineItem) + (lineItems ?: JsonField.of(mutableListOf())).also { + checkKnown("lineItems", it).add(lineItem) } } - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) - fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } fun maximumAmount(maximumAmount: String?) = maximumAmount(JsonField.ofNullable(maximumAmount)) @@ -1552,11 +1573,11 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) - fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } fun minimumAmount(minimumAmount: String?) = minimumAmount(JsonField.ofNullable(minimumAmount)) @@ -1584,25 +1605,19 @@ private constructor( fun paidAt(paidAt: JsonField) = apply { this.paidAt = paidAt } /** A list of payment attempts associated with the invoice */ - fun paymentAttempts(paymentAttempts: List) = + fun paymentAttempts(paymentAttempts: List) = paymentAttempts(JsonField.of(paymentAttempts)) /** A list of payment attempts associated with the invoice */ - fun paymentAttempts(paymentAttempts: JsonField>) = apply { + fun paymentAttempts(paymentAttempts: JsonField>) = apply { this.paymentAttempts = paymentAttempts.map { it.toMutableList() } } /** A list of payment attempts associated with the invoice */ - fun addPaymentAttempt(paymentAttempt: PaymentAttempt) = apply { + fun addPaymentAttempt(paymentAttempt: PaymentAttemptModel) = apply { paymentAttempts = - (paymentAttempts ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(paymentAttempt) + (paymentAttempts ?: JsonField.of(mutableListOf())).also { + checkKnown("paymentAttempts", it).add(paymentAttempt) } } @@ -1675,13 +1690,13 @@ private constructor( this.scheduledIssueAt = scheduledIssueAt } - fun shippingAddress(shippingAddress: ShippingAddress?) = + fun shippingAddress(shippingAddress: AddressModel?) = shippingAddress(JsonField.ofNullable(shippingAddress)) - fun shippingAddress(shippingAddress: Optional) = + fun shippingAddress(shippingAddress: Optional) = shippingAddress(shippingAddress.orElse(null)) - fun shippingAddress(shippingAddress: JsonField) = apply { + fun shippingAddress(shippingAddress: JsonField) = apply { this.shippingAddress = shippingAddress } @@ -1689,13 +1704,13 @@ private constructor( fun status(status: JsonField) = apply { this.status = status } - fun subscription(subscription: Subscription?) = + fun subscription(subscription: SubscriptionMinifiedModel?) = subscription(JsonField.ofNullable(subscription)) - fun subscription(subscription: Optional) = + fun subscription(subscription: Optional) = subscription(subscription.orElse(null)) - fun subscription(subscription: JsonField) = apply { + fun subscription(subscription: JsonField) = apply { this.subscription = subscription } @@ -1841,327 +1856,137 @@ private constructor( ) } - @NoAutoDetect - class AutoCollection - @JsonCreator - private constructor( - @JsonProperty("enabled") - @ExcludeMissing - private val enabled: JsonField = JsonMissing.of(), - @JsonProperty("next_attempt_at") - @ExcludeMissing - private val nextAttemptAt: JsonField = JsonMissing.of(), - @JsonProperty("num_attempts") - @ExcludeMissing - private val numAttempts: JsonField = JsonMissing.of(), - @JsonProperty("previously_attempted_at") - @ExcludeMissing - private val previouslyAttemptedAt: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** True only if auto-collection is enabled for this invoice. */ - fun enabled(): Optional = Optional.ofNullable(enabled.getNullable("enabled")) - - /** - * If the invoice is scheduled for auto-collection, this field will reflect when the next - * attempt will occur. If dunning has been exhausted, or auto-collection is not enabled for - * this invoice, this field will be `null`. - */ - fun nextAttemptAt(): Optional = - Optional.ofNullable(nextAttemptAt.getNullable("next_attempt_at")) - - /** Number of auto-collection payment attempts. */ - fun numAttempts(): Optional = - Optional.ofNullable(numAttempts.getNullable("num_attempts")) - - /** - * If Orb has ever attempted payment auto-collection for this invoice, this field will - * reflect when that attempt occurred. In conjunction with `next_attempt_at`, this can be - * used to tell whether the invoice is currently in dunning (that is, - * `previously_attempted_at` is non-null, and `next_attempt_time` is non-null), or if - * dunning has been exhausted (`previously_attempted_at` is non-null, but - * `next_attempt_time` is null). - */ - fun previouslyAttemptedAt(): Optional = - Optional.ofNullable(previouslyAttemptedAt.getNullable("previously_attempted_at")) - - /** True only if auto-collection is enabled for this invoice. */ - @JsonProperty("enabled") @ExcludeMissing fun _enabled(): JsonField = enabled + class InvoiceSource @JsonCreator private constructor(private val value: JsonField) : + Enum { /** - * 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`. + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. */ - @JsonProperty("next_attempt_at") - @ExcludeMissing - fun _nextAttemptAt(): JsonField = nextAttemptAt - - /** Number of auto-collection payment attempts. */ - @JsonProperty("num_attempts") - @ExcludeMissing - fun _numAttempts(): JsonField = numAttempts + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** - * 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). - */ - @JsonProperty("previously_attempted_at") - @ExcludeMissing - fun _previouslyAttemptedAt(): JsonField = previouslyAttemptedAt + companion object { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + @JvmField val SUBSCRIPTION = of("subscription") - private var validated: Boolean = false + @JvmField val PARTIAL = of("partial") - fun validate(): AutoCollection = apply { - if (validated) { - return@apply - } + @JvmField val ONE_OFF = of("one_off") - enabled() - nextAttemptAt() - numAttempts() - previouslyAttemptedAt() - validated = true + @JvmStatic fun of(value: String) = InvoiceSource(JsonField.of(value)) } - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() + /** An enum containing [InvoiceSource]'s known values. */ + enum class Known { + SUBSCRIPTION, + PARTIAL, + ONE_OFF, } - /** 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)) - - /** True only if auto-collection is enabled for this invoice. */ - fun enabled(enabled: Boolean) = enabled(enabled as Boolean?) - - /** True only if auto-collection is enabled for this invoice. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun enabled(enabled: Optional) = enabled(enabled.orElse(null) as Boolean?) - - /** True only if auto-collection is enabled for this invoice. */ - 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)) - - /** - * 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: Optional) = - nextAttemptAt(nextAttemptAt.orElse(null)) - - /** - * 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: JsonField) = apply { - this.nextAttemptAt = nextAttemptAt - } - - /** Number of auto-collection payment attempts. */ - fun numAttempts(numAttempts: Long?) = numAttempts(JsonField.ofNullable(numAttempts)) - - /** Number of auto-collection payment attempts. */ - fun numAttempts(numAttempts: Long) = numAttempts(numAttempts as Long?) - - /** Number of auto-collection payment attempts. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun numAttempts(numAttempts: Optional) = - numAttempts(numAttempts.orElse(null) as Long?) - - /** Number of auto-collection payment attempts. */ - 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)) - - /** - * 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: Optional) = - previouslyAttemptedAt(previouslyAttemptedAt.orElse(null)) - + /** + * 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, /** - * 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). + * An enum member indicating that [InvoiceSource] was instantiated with an unknown + * 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) - } + _UNKNOWN, + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SUBSCRIPTION -> Value.SUBSCRIPTION + PARTIAL -> Value.PARTIAL + ONE_OFF -> Value.ONE_OFF + else -> Value._UNKNOWN } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + SUBSCRIPTION -> Known.SUBSCRIPTION + PARTIAL -> Known.PARTIAL + ONE_OFF -> Known.ONE_OFF + else -> throw OrbInvalidDataException("Unknown InvoiceSource: $value") } - fun build(): AutoCollection = - AutoCollection( - checkRequired("enabled", enabled), - checkRequired("nextAttemptAt", nextAttemptAt), - checkRequired("numAttempts", numAttempts), - checkRequired("previouslyAttemptedAt", previouslyAttemptedAt), - additionalProperties.toImmutable(), - ) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is AutoCollection && enabled == other.enabled && nextAttemptAt == other.nextAttemptAt && numAttempts == other.numAttempts && previouslyAttemptedAt == other.previouslyAttemptedAt && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InvoiceSource && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(enabled, nextAttemptAt, numAttempts, previouslyAttemptedAt, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "AutoCollection{enabled=$enabled, nextAttemptAt=$nextAttemptAt, numAttempts=$numAttempts, previouslyAttemptedAt=$previouslyAttemptedAt, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } + /** + * User specified key-value pairs for the resource. If not present, this defaults to an empty + * dictionary. Individual keys can be removed by setting the value to `null`, and the entire + * metadata mapping can be cleared by setting `metadata` to `null`. + */ @NoAutoDetect - class BillingAddress + class Metadata @JsonCreator private constructor( - @JsonProperty("city") - @ExcludeMissing - private val city: JsonField = JsonMissing.of(), - @JsonProperty("country") - @ExcludeMissing - private val country: JsonField = JsonMissing.of(), - @JsonProperty("line1") - @ExcludeMissing - private val line1: JsonField = JsonMissing.of(), - @JsonProperty("line2") - @ExcludeMissing - private val line2: JsonField = JsonMissing.of(), - @JsonProperty("postal_code") - @ExcludeMissing - private val postalCode: JsonField = JsonMissing.of(), - @JsonProperty("state") - @ExcludeMissing - private val state: JsonField = JsonMissing.of(), @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { - fun city(): Optional = Optional.ofNullable(city.getNullable("city")) - - fun country(): Optional = Optional.ofNullable(country.getNullable("country")) - - fun line1(): Optional = Optional.ofNullable(line1.getNullable("line1")) - - fun line2(): Optional = Optional.ofNullable(line2.getNullable("line2")) - - fun postalCode(): Optional = - Optional.ofNullable(postalCode.getNullable("postal_code")) - - fun state(): Optional = Optional.ofNullable(state.getNullable("state")) - - @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city - - @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country - - @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField = line1 - - @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 - - @JsonProperty("postal_code") - @ExcludeMissing - fun _postalCode(): JsonField = postalCode - - @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties private var validated: Boolean = false - fun validate(): BillingAddress = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } - city() - country() - line1() - line2() - postalCode() - state() validated = true } @@ -2169,67 +1994,20 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [BillingAddress]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { - private var city: JsonField? = null - private var country: JsonField? = null - private var line1: JsonField? = null - private var line2: JsonField? = null - private var postalCode: JsonField? = null - private var state: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(billingAddress: BillingAddress) = apply { - city = billingAddress.city - country = billingAddress.country - line1 = billingAddress.line1 - line2 = billingAddress.line2 - postalCode = billingAddress.postalCode - state = billingAddress.state - additionalProperties = billingAddress.additionalProperties.toMutableMap() + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - fun city(city: String?) = city(JsonField.ofNullable(city)) - - fun city(city: Optional) = city(city.orElse(null)) - - fun city(city: JsonField) = apply { this.city = city } - - fun country(country: String?) = country(JsonField.ofNullable(country)) - - fun country(country: Optional) = country(country.orElse(null)) - - fun country(country: JsonField) = apply { this.country = country } - - fun line1(line1: String?) = line1(JsonField.ofNullable(line1)) - - fun line1(line1: Optional) = line1(line1.orElse(null)) - - fun line1(line1: JsonField) = apply { this.line1 = line1 } - - fun line2(line2: String?) = line2(JsonField.ofNullable(line2)) - - fun line2(line2: Optional) = line2(line2.orElse(null)) - - fun line2(line2: JsonField) = apply { this.line2 = line2 } - - fun postalCode(postalCode: String?) = postalCode(JsonField.ofNullable(postalCode)) - - fun postalCode(postalCode: Optional) = postalCode(postalCode.orElse(null)) - - fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode } - - fun state(state: String?) = state(JsonField.ofNullable(state)) - - fun state(state: Optional) = state(state.orElse(null)) - - fun state(state: JsonField) = apply { this.state = state } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -2249,16 +2027,7 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): BillingAddress = - BillingAddress( - checkRequired("city", city), - checkRequired("country", country), - checkRequired("line1", line1), - checkRequired("line2", line2), - checkRequired("postalCode", postalCode), - checkRequired("state", state), - additionalProperties.toImmutable(), - ) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -2266,9074 +2035,39 @@ private constructor( return true } - return /* spotless:off */ other is BillingAddress && city == other.city && country == other.country && line1 == other.line1 && line2 == other.line2 && postalCode == other.postalCode && state == other.state && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(city, country, line1, line2, postalCode, state, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode - override fun toString() = - "BillingAddress{city=$city, country=$country, line1=$line1, line2=$line2, postalCode=$postalCode, state=$state, additionalProperties=$additionalProperties}" + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - @NoAutoDetect - class CreditNote - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("credit_note_number") - @ExcludeMissing - private val creditNoteNumber: JsonField = JsonMissing.of(), - @JsonProperty("memo") - @ExcludeMissing - private val memo: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonProperty("total") - @ExcludeMissing - private val total: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonProperty("voided_at") - @ExcludeMissing - private val voidedAt: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { - fun id(): String = id.getRequired("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 - fun creditNoteNumber(): String = creditNoteNumber.getRequired("credit_note_number") + companion object { - /** An optional memo supplied on the credit note. */ - fun memo(): Optional = Optional.ofNullable(memo.getNullable("memo")) + @JvmField val ISSUED = of("issued") - fun reason(): String = reason.getRequired("reason") + @JvmField val PAID = of("paid") - fun total(): String = total.getRequired("total") + @JvmField val SYNCED = of("synced") - 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. - */ - fun voidedAt(): Optional = - Optional.ofNullable(voidedAt.getNullable("voided_at")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("credit_note_number") - @ExcludeMissing - fun _creditNoteNumber(): JsonField = creditNoteNumber - - /** An optional memo supplied on the credit note. */ - @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo - - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonProperty("total") @ExcludeMissing fun _total(): JsonField = total - - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - /** - * If the credit note has a status of `void`, this gives a timestamp when the credit note - * was voided. - */ - @JsonProperty("voided_at") - @ExcludeMissing - fun _voidedAt(): JsonField = voidedAt - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditNote = apply { - if (validated) { - return@apply - } - - id() - creditNoteNumber() - memo() - reason() - total() - type() - voidedAt() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - fun id(id: JsonField) = apply { this.id = id } - - fun creditNoteNumber(creditNoteNumber: String) = - creditNoteNumber(JsonField.of(creditNoteNumber)) - - fun creditNoteNumber(creditNoteNumber: JsonField) = apply { - this.creditNoteNumber = creditNoteNumber - } - - /** An optional memo supplied on the credit note. */ - fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) - - /** An optional memo supplied on the credit note. */ - fun memo(memo: Optional) = memo(memo.orElse(null)) - - /** An optional memo supplied on the credit note. */ - fun memo(memo: JsonField) = apply { this.memo = memo } - - fun reason(reason: String) = reason(JsonField.of(reason)) - - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun total(total: String) = total(JsonField.of(total)) - - fun total(total: JsonField) = apply { this.total = total } - - fun type(type: String) = type(JsonField.of(type)) - - 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)) - - /** - * If the credit note has a status of `void`, this gives a timestamp when the credit - * note was voided. - */ - fun voidedAt(voidedAt: Optional) = voidedAt(voidedAt.orElse(null)) - - /** - * If the credit note has a status of `void`, this gives a timestamp when the credit - * note was voided. - */ - 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) - } - - 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.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditNote && id == other.id && creditNoteNumber == other.creditNoteNumber && memo == other.memo && reason == other.reason && total == other.total && type == other.type && voidedAt == other.voidedAt && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, creditNoteNumber, memo, reason, total, type, voidedAt, additionalProperties) } - /* spotless:on */ - - 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}" - } - - @NoAutoDetect - class Customer - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("external_customer_id") - @ExcludeMissing - private val externalCustomerId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun externalCustomerId(): Optional = - Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("external_customer_id") - @ExcludeMissing - fun _externalCustomerId(): JsonField = externalCustomerId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Customer = apply { - if (validated) { - return@apply - } - - id() - externalCustomerId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Customer]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var externalCustomerId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customer: Customer) = apply { - id = customer.id - externalCustomerId = customer.externalCustomerId - additionalProperties = customer.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun externalCustomerId(externalCustomerId: String?) = - externalCustomerId(JsonField.ofNullable(externalCustomerId)) - - fun externalCustomerId(externalCustomerId: Optional) = - externalCustomerId(externalCustomerId.orElse(null)) - - fun externalCustomerId(externalCustomerId: JsonField) = apply { - this.externalCustomerId = externalCustomerId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Customer = - Customer( - checkRequired("id", id), - checkRequired("externalCustomerId", externalCustomerId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Customer && id == other.id && externalCustomerId == other.externalCustomerId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, externalCustomerId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Customer{id=$id, externalCustomerId=$externalCustomerId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class CustomerBalanceTransaction - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("action") - @ExcludeMissing - private val action: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("credit_note") - @ExcludeMissing - private val creditNote: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - private val description: JsonField = JsonMissing.of(), - @JsonProperty("ending_balance") - @ExcludeMissing - private val endingBalance: JsonField = JsonMissing.of(), - @JsonProperty("invoice") - @ExcludeMissing - private val invoice: JsonField = JsonMissing.of(), - @JsonProperty("starting_balance") - @ExcludeMissing - private val startingBalance: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** A unique id for this transaction. */ - fun id(): String = id.getRequired("id") - - fun action(): Action = action.getRequired("action") - - /** The value of the amount changed in the transaction. */ - fun amount(): String = amount.getRequired("amount") - - /** The creation time of this transaction. */ - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - fun creditNote(): Optional = - Optional.ofNullable(creditNote.getNullable("credit_note")) - - /** An optional description provided for manual customer balance adjustments. */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - /** - * The new value of the customer's balance prior to the transaction, in the customer's - * currency. - */ - fun endingBalance(): String = endingBalance.getRequired("ending_balance") - - fun invoice(): Optional = Optional.ofNullable(invoice.getNullable("invoice")) - - /** - * The original value of the customer's balance prior to the transaction, in the customer's - * currency. - */ - fun startingBalance(): String = startingBalance.getRequired("starting_balance") - - fun type(): Type = type.getRequired("type") - - /** A unique id for this transaction. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("action") @ExcludeMissing fun _action(): JsonField = action - - /** The value of the amount changed in the transaction. */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** The creation time of this transaction. */ - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - @JsonProperty("credit_note") - @ExcludeMissing - fun _creditNote(): JsonField = creditNote - - /** An optional description provided for manual customer balance adjustments. */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - /** - * The new value of the customer's balance prior to the transaction, in the customer's - * currency. - */ - @JsonProperty("ending_balance") - @ExcludeMissing - fun _endingBalance(): JsonField = endingBalance - - @JsonProperty("invoice") @ExcludeMissing fun _invoice(): JsonField = invoice - - /** - * The original value of the customer's balance prior to the transaction, in the customer's - * currency. - */ - @JsonProperty("starting_balance") - @ExcludeMissing - fun _startingBalance(): JsonField = startingBalance - - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CustomerBalanceTransaction = apply { - if (validated) { - return@apply - } - - id() - action() - amount() - createdAt() - creditNote().ifPresent { it.validate() } - description() - endingBalance() - invoice().ifPresent { it.validate() } - startingBalance() - type() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - /** A unique id for this transaction. */ - fun id(id: JsonField) = apply { this.id = id } - - fun action(action: Action) = action(JsonField.of(action)) - - 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)) - - /** The value of the amount changed in the transaction. */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** The creation time of this transaction. */ - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - /** The creation time of this transaction. */ - fun createdAt(createdAt: JsonField) = apply { - this.createdAt = createdAt - } - - fun creditNote(creditNote: CreditNote?) = creditNote(JsonField.ofNullable(creditNote)) - - fun creditNote(creditNote: Optional) = creditNote(creditNote.orElse(null)) - - 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)) - - /** An optional description provided for manual customer balance adjustments. */ - fun description(description: Optional) = description(description.orElse(null)) - - /** An optional description provided for manual customer balance adjustments. */ - 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)) - - /** - * The new value of the customer's balance prior to the transaction, in the customer's - * currency. - */ - fun endingBalance(endingBalance: JsonField) = apply { - this.endingBalance = endingBalance - } - - fun invoice(invoice: Invoice?) = invoice(JsonField.ofNullable(invoice)) - - fun invoice(invoice: Optional) = invoice(invoice.orElse(null)) - - 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)) - - /** - * The original value of the customer's balance prior to the transaction, in the - * customer's currency. - */ - fun startingBalance(startingBalance: JsonField) = apply { - this.startingBalance = startingBalance - } - - fun type(type: Type) = type(JsonField.of(type)) - - 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) - } - - 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.toImmutable(), - ) - } - - 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") - - @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, - } - - /** - * 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, - /** - * 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 - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to 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 - 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Action && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class CreditNote - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The id of the Credit note */ - fun id(): String = id.getRequired("id") - - /** The id of the Credit note */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditNote = apply { - if (validated) { - return@apply - } - - id() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditNote]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditNote: CreditNote) = apply { - id = creditNote.id - additionalProperties = creditNote.additionalProperties.toMutableMap() - } - - /** The id of the Credit note */ - fun id(id: String) = id(JsonField.of(id)) - - /** The id of the Credit note */ - 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) - } - - fun build(): CreditNote = - CreditNote(checkRequired("id", id), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditNote && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditNote{id=$id, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Invoice - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The Invoice id */ - fun id(): String = id.getRequired("id") - - /** The Invoice id */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Invoice = apply { - if (validated) { - return@apply - } - - id() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Invoice]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoice: Invoice) = apply { - id = invoice.id - additionalProperties = invoice.additionalProperties.toMutableMap() - } - - /** The Invoice id */ - fun id(id: String) = id(JsonField.of(id)) - - /** The Invoice id */ - 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) - } - - fun build(): Invoice = - Invoice(checkRequired("id", id), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Invoice && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Invoice{id=$id, additionalProperties=$additionalProperties}" - } - - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CustomerBalanceTransaction && id == other.id && action == other.action && amount == other.amount && createdAt == other.createdAt && creditNote == other.creditNote && description == other.description && endingBalance == other.endingBalance && invoice == other.invoice && startingBalance == other.startingBalance && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, action, amount, createdAt, creditNote, description, endingBalance, invoice, startingBalance, type, additionalProperties) } - /* spotless:on */ - - 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}" - } - - /** - * 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 | - * |--------------------|------------|-------------------------------------------------------------------------------------------------------| - * |Andorra |`ad_nrt` |Andorran NRT Number | - * |Argentina |`ar_cuit` |Argentinian Tax ID Number | - * |Australia |`au_abn` |Australian Business Number (AU ABN) | - * |Australia |`au_arn` |Australian Taxation Office Reference Number | - * |Austria |`eu_vat` |European VAT Number | - * |Bahrain |`bh_vat` |Bahraini VAT Number | - * |Belgium |`eu_vat` |European VAT Number | - * |Bolivia |`bo_tin` |Bolivian Tax ID | - * |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 | - * |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) | - * |Chile |`cl_tin` |Chilean TIN | - * |China |`cn_tin` |Chinese Tax ID | - * |Colombia |`co_nit` |Colombian NIT Number | - * |Costa Rica |`cr_tin` |Costa Rican Tax ID | - * |Croatia |`eu_vat` |European VAT Number | - * |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 | - * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | - * |Finland |`eu_vat` |European VAT Number | - * |France |`eu_vat` |European VAT Number | - * |Georgia |`ge_vat` |Georgian VAT | - * |Germany |`eu_vat` |European VAT Number | - * |Greece |`eu_vat` |European VAT Number | - * |Hong Kong |`hk_br` |Hong Kong BR Number | - * |Hungary |`eu_vat` |European VAT Number | - * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | - * |Iceland |`is_vat` |Icelandic VAT | - * |India |`in_gst` |Indian GST Number | - * |Indonesia |`id_npwp` |Indonesian NPWP Number | - * |Ireland |`eu_vat` |European VAT Number | - * |Israel |`il_vat` |Israel VAT | - * |Italy |`eu_vat` |European VAT Number | - * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | - * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| - * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | - * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | - * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | - * |Latvia |`eu_vat` |European VAT Number | - * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | - * |Mexico |`mx_rfc` |Mexican RFC Number | - * |Netherlands |`eu_vat` |European VAT Number | - * |New Zealand |`nz_gst` |New Zealand GST Number | - * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | - * |Norway |`no_vat` |Norwegian VAT Number | - * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | - * |Oman |`om_vat` |Omani VAT Number | - * |Peru |`pe_ruc` |Peruvian RUC Number | - * |Philippines |`ph_tin ` |Philippines Tax Identification Number | - * |Poland |`eu_vat` |European VAT Number | - * |Portugal |`eu_vat` |European VAT Number | - * |Romania |`eu_vat` |European VAT Number | - * |Romania |`ro_tin` |Romanian Tax ID Number | - * |Russia |`ru_inn` |Russian INN | - * |Russia |`ru_kpp` |Russian KPP | - * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | - * |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 | - * |Sweden |`eu_vat` |European VAT Number | - * |Switzerland |`ch_vat` |Switzerland VAT Number | - * |Taiwan |`tw_vat` |Taiwanese VAT | - * |Thailand |`th_vat` |Thai VAT | - * |Turkey |`tr_tin` |Turkish Tax Identification Number | - * |Ukraine |`ua_vat` |Ukrainian VAT | - * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | - * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | - * |United Kingdom |`gb_vat` |United Kingdom VAT Number | - * |United States |`us_ein` |United States EIN | - * |Uruguay |`uy_ruc` |Uruguayan RUC Number | - * |Venezuela |`ve_rif` |Venezuelan RIF Number | - * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | - */ - @NoAutoDetect - class CustomerTaxId - @JsonCreator - private constructor( - @JsonProperty("country") - @ExcludeMissing - private val country: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), - @JsonProperty("value") - @ExcludeMissing - private val value: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun country(): Country = country.getRequired("country") - - fun type(): Type = type.getRequired("type") - - fun value(): String = value.getRequired("value") - - @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country - - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CustomerTaxId = apply { - if (validated) { - return@apply - } - - country() - type() - value() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CustomerTaxId]. */ - class Builder internal constructor() { - - private var country: JsonField? = null - private var type: JsonField? = null - private var value: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(customerTaxId: CustomerTaxId) = apply { - country = customerTaxId.country - type = customerTaxId.type - value = customerTaxId.value - additionalProperties = customerTaxId.additionalProperties.toMutableMap() - } - - fun country(country: Country) = country(JsonField.of(country)) - - fun country(country: JsonField) = apply { this.country = country } - - fun type(type: Type) = type(JsonField.of(type)) - - fun type(type: JsonField) = apply { this.type = type } - - fun value(value: String) = value(JsonField.of(value)) - - fun value(value: JsonField) = apply { this.value = 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) - } - - fun build(): CustomerTaxId = - CustomerTaxId( - checkRequired("country", country), - checkRequired("type", type), - checkRequired("value", value), - additionalProperties.toImmutable(), - ) - } - - class Country @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val AD = of("AD") - - @JvmField val AE = of("AE") - - @JvmField val AR = of("AR") - - @JvmField val AT = of("AT") - - @JvmField val AU = of("AU") - - @JvmField val BE = of("BE") - - @JvmField val BG = of("BG") - - @JvmField val BH = of("BH") - - @JvmField val BO = of("BO") - - @JvmField val BR = of("BR") - - @JvmField val CA = of("CA") - - @JvmField val CH = of("CH") - - @JvmField val CL = of("CL") - - @JvmField val CN = of("CN") - - @JvmField val CO = of("CO") - - @JvmField val CR = of("CR") - - @JvmField val CY = of("CY") - - @JvmField val CZ = of("CZ") - - @JvmField val DE = of("DE") - - @JvmField val DK = of("DK") - - @JvmField val EE = of("EE") - - @JvmField val DO = of("DO") - - @JvmField val EC = of("EC") - - @JvmField val EG = of("EG") - - @JvmField val ES = of("ES") - - @JvmField val EU = of("EU") - - @JvmField val FI = of("FI") - - @JvmField val FR = of("FR") - - @JvmField val GB = of("GB") - - @JvmField val GE = of("GE") - - @JvmField val GR = of("GR") - - @JvmField val HK = of("HK") - - @JvmField val HR = of("HR") - - @JvmField val HU = of("HU") - - @JvmField val ID = of("ID") - - @JvmField val IE = of("IE") - - @JvmField val IL = of("IL") - - @JvmField val IN = of("IN") - - @JvmField val IS = of("IS") - - @JvmField val IT = of("IT") - - @JvmField val JP = of("JP") - - @JvmField val KE = of("KE") - - @JvmField val KR = of("KR") - - @JvmField val KZ = of("KZ") - - @JvmField val LI = of("LI") - - @JvmField val LT = of("LT") - - @JvmField val LU = of("LU") - - @JvmField val LV = of("LV") - - @JvmField val MT = of("MT") - - @JvmField val MX = of("MX") - - @JvmField val MY = of("MY") - - @JvmField val NG = of("NG") - - @JvmField val NL = of("NL") - - @JvmField val NO = of("NO") - - @JvmField val NZ = of("NZ") - - @JvmField val OM = of("OM") - - @JvmField val PE = of("PE") - - @JvmField val PH = of("PH") - - @JvmField val PL = of("PL") - - @JvmField val PT = of("PT") - - @JvmField val RO = of("RO") - - @JvmField val RS = of("RS") - - @JvmField val RU = of("RU") - - @JvmField val SA = of("SA") - - @JvmField val SE = of("SE") - - @JvmField val SG = of("SG") - - @JvmField val SI = of("SI") - - @JvmField val SK = of("SK") - - @JvmField val SV = of("SV") - - @JvmField val TH = of("TH") - - @JvmField val TR = of("TR") - - @JvmField val TW = of("TW") - - @JvmField val UA = of("UA") - - @JvmField val US = of("US") - - @JvmField val UY = of("UY") - - @JvmField val VE = of("VE") - - @JvmField val VN = of("VN") - - @JvmField val ZA = of("ZA") - - @JvmStatic fun of(value: String) = Country(JsonField.of(value)) - } - - /** An enum containing [Country]'s known values. */ - enum class Known { - AD, - AE, - AR, - AT, - AU, - BE, - BG, - BH, - BO, - BR, - CA, - CH, - CL, - CN, - CO, - CR, - CY, - CZ, - DE, - DK, - EE, - DO, - EC, - EG, - ES, - EU, - FI, - FR, - GB, - GE, - GR, - HK, - HR, - HU, - ID, - IE, - IL, - IN, - IS, - IT, - JP, - KE, - KR, - KZ, - LI, - LT, - LU, - LV, - MT, - MX, - MY, - NG, - NL, - NO, - NZ, - OM, - PE, - PH, - PL, - PT, - RO, - RS, - RU, - SA, - SE, - SG, - SI, - SK, - SV, - TH, - TR, - TW, - UA, - US, - UY, - VE, - VN, - ZA, - } - - /** - * An enum containing [Country]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Country] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AD, - AE, - AR, - AT, - AU, - BE, - BG, - BH, - BO, - BR, - CA, - CH, - CL, - CN, - CO, - CR, - CY, - CZ, - DE, - DK, - EE, - DO, - EC, - EG, - ES, - EU, - FI, - FR, - GB, - GE, - GR, - HK, - HR, - HU, - ID, - IE, - IL, - IN, - IS, - IT, - JP, - KE, - KR, - KZ, - LI, - LT, - LU, - LV, - MT, - MX, - MY, - NG, - NL, - NO, - NZ, - OM, - PE, - PH, - PL, - PT, - RO, - RS, - RU, - SA, - SE, - SG, - SI, - SK, - SV, - TH, - TR, - TW, - UA, - US, - UY, - VE, - VN, - ZA, - /** - * An enum member indicating that [Country] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AD -> Value.AD - AE -> Value.AE - AR -> Value.AR - AT -> Value.AT - AU -> Value.AU - BE -> Value.BE - BG -> Value.BG - BH -> Value.BH - BO -> Value.BO - BR -> Value.BR - CA -> Value.CA - CH -> Value.CH - CL -> Value.CL - CN -> Value.CN - CO -> Value.CO - CR -> Value.CR - CY -> Value.CY - CZ -> Value.CZ - DE -> Value.DE - DK -> Value.DK - EE -> Value.EE - DO -> Value.DO - EC -> Value.EC - EG -> Value.EG - ES -> Value.ES - EU -> Value.EU - FI -> Value.FI - FR -> Value.FR - GB -> Value.GB - GE -> Value.GE - GR -> Value.GR - HK -> Value.HK - HR -> Value.HR - HU -> Value.HU - ID -> Value.ID - IE -> Value.IE - IL -> Value.IL - IN -> Value.IN - IS -> Value.IS - IT -> Value.IT - JP -> Value.JP - KE -> Value.KE - KR -> Value.KR - KZ -> Value.KZ - LI -> Value.LI - LT -> Value.LT - LU -> Value.LU - LV -> Value.LV - MT -> Value.MT - MX -> Value.MX - MY -> Value.MY - NG -> Value.NG - NL -> Value.NL - NO -> Value.NO - NZ -> Value.NZ - OM -> Value.OM - PE -> Value.PE - PH -> Value.PH - PL -> Value.PL - PT -> Value.PT - RO -> Value.RO - RS -> Value.RS - RU -> Value.RU - SA -> Value.SA - SE -> Value.SE - SG -> Value.SG - SI -> Value.SI - SK -> Value.SK - SV -> Value.SV - TH -> Value.TH - TR -> Value.TR - TW -> Value.TW - UA -> Value.UA - US -> Value.US - UY -> Value.UY - VE -> Value.VE - VN -> Value.VN - ZA -> Value.ZA - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AD -> Known.AD - AE -> Known.AE - AR -> Known.AR - AT -> Known.AT - AU -> Known.AU - BE -> Known.BE - BG -> Known.BG - BH -> Known.BH - BO -> Known.BO - BR -> Known.BR - CA -> Known.CA - CH -> Known.CH - CL -> Known.CL - CN -> Known.CN - CO -> Known.CO - CR -> Known.CR - CY -> Known.CY - CZ -> Known.CZ - DE -> Known.DE - DK -> Known.DK - EE -> Known.EE - DO -> Known.DO - EC -> Known.EC - EG -> Known.EG - ES -> Known.ES - EU -> Known.EU - FI -> Known.FI - FR -> Known.FR - GB -> Known.GB - GE -> Known.GE - GR -> Known.GR - HK -> Known.HK - HR -> Known.HR - HU -> Known.HU - ID -> Known.ID - IE -> Known.IE - IL -> Known.IL - IN -> Known.IN - IS -> Known.IS - IT -> Known.IT - JP -> Known.JP - KE -> Known.KE - KR -> Known.KR - KZ -> Known.KZ - LI -> Known.LI - LT -> Known.LT - LU -> Known.LU - LV -> Known.LV - MT -> Known.MT - MX -> Known.MX - MY -> Known.MY - NG -> Known.NG - NL -> Known.NL - NO -> Known.NO - NZ -> Known.NZ - OM -> Known.OM - PE -> Known.PE - PH -> Known.PH - PL -> Known.PL - PT -> Known.PT - RO -> Known.RO - RS -> Known.RS - RU -> Known.RU - SA -> Known.SA - SE -> Known.SE - SG -> Known.SG - SI -> Known.SI - SK -> Known.SK - SV -> Known.SV - TH -> Known.TH - TR -> Known.TR - TW -> Known.TW - UA -> Known.UA - US -> Known.US - UY -> Known.UY - VE -> Known.VE - VN -> Known.VN - ZA -> Known.ZA - else -> throw OrbInvalidDataException("Unknown Country: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is Country && value == other.value /* spotless:on */ - } - - 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 AD_NRT = of("ad_nrt") - - @JvmField val AE_TRN = of("ae_trn") - - @JvmField val AR_CUIT = of("ar_cuit") - - @JvmField val EU_VAT = of("eu_vat") - - @JvmField val AU_ABN = of("au_abn") - - @JvmField val AU_ARN = of("au_arn") - - @JvmField val BG_UIC = of("bg_uic") - - @JvmField val BH_VAT = of("bh_vat") - - @JvmField val BO_TIN = of("bo_tin") - - @JvmField val BR_CNPJ = of("br_cnpj") - - @JvmField val BR_CPF = of("br_cpf") - - @JvmField val CA_BN = of("ca_bn") - - @JvmField val CA_GST_HST = of("ca_gst_hst") - - @JvmField val CA_PST_BC = of("ca_pst_bc") - - @JvmField val CA_PST_MB = of("ca_pst_mb") - - @JvmField val CA_PST_SK = of("ca_pst_sk") - - @JvmField val CA_QST = of("ca_qst") - - @JvmField val CH_VAT = of("ch_vat") - - @JvmField val CL_TIN = of("cl_tin") - - @JvmField val CN_TIN = of("cn_tin") - - @JvmField val CO_NIT = of("co_nit") - - @JvmField val CR_TIN = of("cr_tin") - - @JvmField val DO_RCN = of("do_rcn") - - @JvmField val EC_RUC = of("ec_ruc") - - @JvmField val EG_TIN = of("eg_tin") - - @JvmField val ES_CIF = of("es_cif") - - @JvmField val EU_OSS_VAT = of("eu_oss_vat") - - @JvmField val GB_VAT = of("gb_vat") - - @JvmField val GE_VAT = of("ge_vat") - - @JvmField val HK_BR = of("hk_br") - - @JvmField val HU_TIN = of("hu_tin") - - @JvmField val ID_NPWP = of("id_npwp") - - @JvmField val IL_VAT = of("il_vat") - - @JvmField val IN_GST = of("in_gst") - - @JvmField val IS_VAT = of("is_vat") - - @JvmField val JP_CN = of("jp_cn") - - @JvmField val JP_RN = of("jp_rn") - - @JvmField val JP_TRN = of("jp_trn") - - @JvmField val KE_PIN = of("ke_pin") - - @JvmField val KR_BRN = of("kr_brn") - - @JvmField val KZ_BIN = of("kz_bin") - - @JvmField val LI_UID = of("li_uid") - - @JvmField val MX_RFC = of("mx_rfc") - - @JvmField val MY_FRP = of("my_frp") - - @JvmField val MY_ITN = of("my_itn") - - @JvmField val MY_SST = of("my_sst") - - @JvmField val NG_TIN = of("ng_tin") - - @JvmField val NO_VAT = of("no_vat") - - @JvmField val NO_VOEC = of("no_voec") - - @JvmField val NZ_GST = of("nz_gst") - - @JvmField val OM_VAT = of("om_vat") - - @JvmField val PE_RUC = of("pe_ruc") - - @JvmField val PH_TIN = of("ph_tin") - - @JvmField val RO_TIN = of("ro_tin") - - @JvmField val RS_PIB = of("rs_pib") - - @JvmField val RU_INN = of("ru_inn") - - @JvmField val RU_KPP = of("ru_kpp") - - @JvmField val SA_VAT = of("sa_vat") - - @JvmField val SG_GST = of("sg_gst") - - @JvmField val SG_UEN = of("sg_uen") - - @JvmField val SI_TIN = of("si_tin") - - @JvmField val SV_NIT = of("sv_nit") - - @JvmField val TH_VAT = of("th_vat") - - @JvmField val TR_TIN = of("tr_tin") - - @JvmField val TW_VAT = of("tw_vat") - - @JvmField val UA_VAT = of("ua_vat") - - @JvmField val US_EIN = of("us_ein") - - @JvmField val UY_RUC = of("uy_ruc") - - @JvmField val VE_RIF = of("ve_rif") - - @JvmField val VN_TIN = of("vn_tin") - - @JvmField val ZA_VAT = of("za_vat") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - AD_NRT, - AE_TRN, - AR_CUIT, - EU_VAT, - AU_ABN, - AU_ARN, - BG_UIC, - BH_VAT, - BO_TIN, - BR_CNPJ, - BR_CPF, - CA_BN, - CA_GST_HST, - CA_PST_BC, - CA_PST_MB, - CA_PST_SK, - CA_QST, - CH_VAT, - CL_TIN, - CN_TIN, - CO_NIT, - CR_TIN, - DO_RCN, - EC_RUC, - EG_TIN, - ES_CIF, - EU_OSS_VAT, - GB_VAT, - GE_VAT, - HK_BR, - HU_TIN, - ID_NPWP, - IL_VAT, - IN_GST, - IS_VAT, - JP_CN, - JP_RN, - JP_TRN, - KE_PIN, - KR_BRN, - KZ_BIN, - LI_UID, - MX_RFC, - MY_FRP, - MY_ITN, - MY_SST, - NG_TIN, - NO_VAT, - NO_VOEC, - NZ_GST, - OM_VAT, - PE_RUC, - PH_TIN, - RO_TIN, - RS_PIB, - RU_INN, - RU_KPP, - SA_VAT, - SG_GST, - SG_UEN, - SI_TIN, - SV_NIT, - TH_VAT, - TR_TIN, - TW_VAT, - UA_VAT, - US_EIN, - UY_RUC, - VE_RIF, - VN_TIN, - ZA_VAT, - } - - /** - * 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 { - AD_NRT, - AE_TRN, - AR_CUIT, - EU_VAT, - AU_ABN, - AU_ARN, - BG_UIC, - BH_VAT, - BO_TIN, - BR_CNPJ, - BR_CPF, - CA_BN, - CA_GST_HST, - CA_PST_BC, - CA_PST_MB, - CA_PST_SK, - CA_QST, - CH_VAT, - CL_TIN, - CN_TIN, - CO_NIT, - CR_TIN, - DO_RCN, - EC_RUC, - EG_TIN, - ES_CIF, - EU_OSS_VAT, - GB_VAT, - GE_VAT, - HK_BR, - HU_TIN, - ID_NPWP, - IL_VAT, - IN_GST, - IS_VAT, - JP_CN, - JP_RN, - JP_TRN, - KE_PIN, - KR_BRN, - KZ_BIN, - LI_UID, - MX_RFC, - MY_FRP, - MY_ITN, - MY_SST, - NG_TIN, - NO_VAT, - NO_VOEC, - NZ_GST, - OM_VAT, - PE_RUC, - PH_TIN, - RO_TIN, - RS_PIB, - RU_INN, - RU_KPP, - SA_VAT, - SG_GST, - SG_UEN, - SI_TIN, - SV_NIT, - TH_VAT, - TR_TIN, - TW_VAT, - UA_VAT, - US_EIN, - UY_RUC, - VE_RIF, - VN_TIN, - ZA_VAT, - /** 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) { - AD_NRT -> Value.AD_NRT - AE_TRN -> Value.AE_TRN - AR_CUIT -> Value.AR_CUIT - EU_VAT -> Value.EU_VAT - AU_ABN -> Value.AU_ABN - AU_ARN -> Value.AU_ARN - BG_UIC -> Value.BG_UIC - BH_VAT -> Value.BH_VAT - BO_TIN -> Value.BO_TIN - BR_CNPJ -> Value.BR_CNPJ - BR_CPF -> Value.BR_CPF - CA_BN -> Value.CA_BN - CA_GST_HST -> Value.CA_GST_HST - CA_PST_BC -> Value.CA_PST_BC - CA_PST_MB -> Value.CA_PST_MB - CA_PST_SK -> Value.CA_PST_SK - CA_QST -> Value.CA_QST - CH_VAT -> Value.CH_VAT - CL_TIN -> Value.CL_TIN - CN_TIN -> Value.CN_TIN - CO_NIT -> Value.CO_NIT - CR_TIN -> Value.CR_TIN - DO_RCN -> Value.DO_RCN - EC_RUC -> Value.EC_RUC - EG_TIN -> Value.EG_TIN - ES_CIF -> Value.ES_CIF - EU_OSS_VAT -> Value.EU_OSS_VAT - GB_VAT -> Value.GB_VAT - GE_VAT -> Value.GE_VAT - HK_BR -> Value.HK_BR - HU_TIN -> Value.HU_TIN - ID_NPWP -> Value.ID_NPWP - IL_VAT -> Value.IL_VAT - IN_GST -> Value.IN_GST - IS_VAT -> Value.IS_VAT - JP_CN -> Value.JP_CN - JP_RN -> Value.JP_RN - JP_TRN -> Value.JP_TRN - KE_PIN -> Value.KE_PIN - KR_BRN -> Value.KR_BRN - KZ_BIN -> Value.KZ_BIN - LI_UID -> Value.LI_UID - MX_RFC -> Value.MX_RFC - MY_FRP -> Value.MY_FRP - MY_ITN -> Value.MY_ITN - MY_SST -> Value.MY_SST - NG_TIN -> Value.NG_TIN - NO_VAT -> Value.NO_VAT - NO_VOEC -> Value.NO_VOEC - NZ_GST -> Value.NZ_GST - OM_VAT -> Value.OM_VAT - PE_RUC -> Value.PE_RUC - PH_TIN -> Value.PH_TIN - RO_TIN -> Value.RO_TIN - RS_PIB -> Value.RS_PIB - RU_INN -> Value.RU_INN - RU_KPP -> Value.RU_KPP - SA_VAT -> Value.SA_VAT - SG_GST -> Value.SG_GST - SG_UEN -> Value.SG_UEN - SI_TIN -> Value.SI_TIN - SV_NIT -> Value.SV_NIT - TH_VAT -> Value.TH_VAT - TR_TIN -> Value.TR_TIN - TW_VAT -> Value.TW_VAT - UA_VAT -> Value.UA_VAT - US_EIN -> Value.US_EIN - UY_RUC -> Value.UY_RUC - VE_RIF -> Value.VE_RIF - VN_TIN -> Value.VN_TIN - ZA_VAT -> Value.ZA_VAT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AD_NRT -> Known.AD_NRT - AE_TRN -> Known.AE_TRN - AR_CUIT -> Known.AR_CUIT - EU_VAT -> Known.EU_VAT - AU_ABN -> Known.AU_ABN - AU_ARN -> Known.AU_ARN - BG_UIC -> Known.BG_UIC - BH_VAT -> Known.BH_VAT - BO_TIN -> Known.BO_TIN - BR_CNPJ -> Known.BR_CNPJ - BR_CPF -> Known.BR_CPF - CA_BN -> Known.CA_BN - CA_GST_HST -> Known.CA_GST_HST - CA_PST_BC -> Known.CA_PST_BC - CA_PST_MB -> Known.CA_PST_MB - CA_PST_SK -> Known.CA_PST_SK - CA_QST -> Known.CA_QST - CH_VAT -> Known.CH_VAT - CL_TIN -> Known.CL_TIN - CN_TIN -> Known.CN_TIN - CO_NIT -> Known.CO_NIT - CR_TIN -> Known.CR_TIN - DO_RCN -> Known.DO_RCN - EC_RUC -> Known.EC_RUC - EG_TIN -> Known.EG_TIN - ES_CIF -> Known.ES_CIF - EU_OSS_VAT -> Known.EU_OSS_VAT - GB_VAT -> Known.GB_VAT - GE_VAT -> Known.GE_VAT - HK_BR -> Known.HK_BR - HU_TIN -> Known.HU_TIN - ID_NPWP -> Known.ID_NPWP - IL_VAT -> Known.IL_VAT - IN_GST -> Known.IN_GST - IS_VAT -> Known.IS_VAT - JP_CN -> Known.JP_CN - JP_RN -> Known.JP_RN - JP_TRN -> Known.JP_TRN - KE_PIN -> Known.KE_PIN - KR_BRN -> Known.KR_BRN - KZ_BIN -> Known.KZ_BIN - LI_UID -> Known.LI_UID - MX_RFC -> Known.MX_RFC - MY_FRP -> Known.MY_FRP - MY_ITN -> Known.MY_ITN - MY_SST -> Known.MY_SST - NG_TIN -> Known.NG_TIN - NO_VAT -> Known.NO_VAT - NO_VOEC -> Known.NO_VOEC - NZ_GST -> Known.NZ_GST - OM_VAT -> Known.OM_VAT - PE_RUC -> Known.PE_RUC - PH_TIN -> Known.PH_TIN - RO_TIN -> Known.RO_TIN - RS_PIB -> Known.RS_PIB - RU_INN -> Known.RU_INN - RU_KPP -> Known.RU_KPP - SA_VAT -> Known.SA_VAT - SG_GST -> Known.SG_GST - SG_UEN -> Known.SG_UEN - SI_TIN -> Known.SI_TIN - SV_NIT -> Known.SV_NIT - TH_VAT -> Known.TH_VAT - TR_TIN -> Known.TR_TIN - TW_VAT -> Known.TW_VAT - UA_VAT -> Known.UA_VAT - US_EIN -> Known.US_EIN - UY_RUC -> Known.UY_RUC - VE_RIF -> Known.VE_RIF - VN_TIN -> Known.VN_TIN - ZA_VAT -> Known.ZA_VAT - 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CustomerTaxId && country == other.country && type == other.type && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(country, type, value, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CustomerTaxId{country=$country, type=$type, value=$value, 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoiceSource && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class LineItem - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjusted_subtotal") - @ExcludeMissing - private val adjustedSubtotal: JsonField = JsonMissing.of(), - @JsonProperty("adjustments") - @ExcludeMissing - private val adjustments: JsonField> = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("credits_applied") - @ExcludeMissing - private val creditsApplied: JsonField = JsonMissing.of(), - @JsonProperty("discount") - @ExcludeMissing - private val discount: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("filter") - @ExcludeMissing - private val filter: JsonField = JsonMissing.of(), - @JsonProperty("grouping") - @ExcludeMissing - private val grouping: JsonField = JsonMissing.of(), - @JsonProperty("maximum") - @ExcludeMissing - private val maximum: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("minimum") - @ExcludeMissing - private val minimum: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("partially_invoiced_amount") - @ExcludeMissing - private val partiallyInvoicedAmount: JsonField = JsonMissing.of(), - @JsonProperty("price") - @ExcludeMissing - private val price: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - private val quantity: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonProperty("sub_line_items") - @ExcludeMissing - private val subLineItems: JsonField> = JsonMissing.of(), - @JsonProperty("subtotal") - @ExcludeMissing - private val subtotal: JsonField = JsonMissing.of(), - @JsonProperty("tax_amounts") - @ExcludeMissing - private val taxAmounts: JsonField> = JsonMissing.of(), - @JsonProperty("usage_customer_ids") - @ExcludeMissing - private val usageCustomerIds: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** A unique ID for this line item. */ - fun id(): String = id.getRequired("id") - - /** - * The line amount after any adjustments and before overage conversion, credits and partial - * invoicing. - */ - fun adjustedSubtotal(): String = adjustedSubtotal.getRequired("adjusted_subtotal") - - /** All adjustments (ie. maximums, minimums, discounts) applied to the line item. */ - fun adjustments(): List = adjustments.getRequired("adjustments") - - /** - * The final amount for a line item after all adjustments and pre paid credits have been - * applied. - */ - fun amount(): String = amount.getRequired("amount") - - /** The number of prepaid credits applied. */ - fun creditsApplied(): String = creditsApplied.getRequired("credits_applied") - - fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) - - /** The end date of the range of time applied for this line item's price. */ - fun endDate(): OffsetDateTime = endDate.getRequired("end_date") - - /** An additional filter that was used to calculate the usage for this line item. */ - fun filter(): Optional = Optional.ofNullable(filter.getNullable("filter")) - - /** - * [DEPRECATED] For configured prices that are split by a grouping key, this will be - * populated with the key and a value. The `amount` and `subtotal` will be the values for - * this particular grouping. - */ - fun grouping(): Optional = Optional.ofNullable(grouping.getNullable("grouping")) - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun maximumAmount(): Optional = - Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun minimumAmount(): Optional = - Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) - - /** The name of the price associated with this line item. */ - fun name(): String = name.getRequired("name") - - /** Any amount applied from a partial invoice */ - fun partiallyInvoicedAmount(): String = - partiallyInvoicedAmount.getRequired("partially_invoiced_amount") - - /** - * The Price resource represents a price that can be billed on a subscription, resulting in - * a charge on an invoice in the form of an invoice line item. Prices take a quantity and - * determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the key - * for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(): Optional = Optional.ofNullable(price.getNullable("price")) - - /** Either the fixed fee quantity or the usage during the service period. */ - fun quantity(): Double = quantity.getRequired("quantity") - - /** The start date of the range of time applied for this line item's price. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** - * For complex pricing structures, the line item can be broken down further in - * `sub_line_items`. - */ - fun subLineItems(): List = subLineItems.getRequired("sub_line_items") - - /** The line amount before before any adjustments. */ - fun subtotal(): String = subtotal.getRequired("subtotal") - - /** - * An array of tax rates and their incurred tax amounts. Empty if no tax integration is - * configured. - */ - fun taxAmounts(): List = taxAmounts.getRequired("tax_amounts") - - /** A list of customer ids that were used to calculate the usage for this line item. */ - fun usageCustomerIds(): Optional> = - Optional.ofNullable(usageCustomerIds.getNullable("usage_customer_ids")) - - /** A unique ID for this line item. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * The line amount after any adjustments and before overage conversion, credits and partial - * invoicing. - */ - @JsonProperty("adjusted_subtotal") - @ExcludeMissing - fun _adjustedSubtotal(): JsonField = adjustedSubtotal - - /** All adjustments (ie. maximums, minimums, discounts) applied to the line item. */ - @JsonProperty("adjustments") - @ExcludeMissing - fun _adjustments(): JsonField> = adjustments - - /** - * The final amount for a line item after all adjustments and pre paid credits have been - * applied. - */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** The number of prepaid credits applied. */ - @JsonProperty("credits_applied") - @ExcludeMissing - fun _creditsApplied(): JsonField = creditsApplied - - @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - - /** The end date of the range of time applied for this line item's price. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** An additional filter that was used to calculate the usage for this line item. */ - @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField = filter - - /** - * [DEPRECATED] For configured prices that are split by a grouping key, this will be - * populated with the key and a value. The `amount` and `subtotal` will be the values for - * this particular grouping. - */ - @JsonProperty("grouping") @ExcludeMissing fun _grouping(): JsonField = grouping - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - @JsonProperty("maximum") - @ExcludeMissing - fun _maximum(): JsonField = maximum - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - @JsonProperty("minimum") - @ExcludeMissing - fun _minimum(): JsonField = minimum - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** The name of the price associated with this line item. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** Any amount applied from a partial invoice */ - @JsonProperty("partially_invoiced_amount") - @ExcludeMissing - fun _partiallyInvoicedAmount(): JsonField = partiallyInvoicedAmount - - /** - * The Price resource represents a price that can be billed on a subscription, resulting in - * a charge on an invoice in the form of an invoice line item. Prices take a quantity and - * determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the key - * for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - - /** Either the fixed fee quantity or the usage during the service period. */ - @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - - /** The start date of the range of time applied for this line item's price. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - /** - * For complex pricing structures, the line item can be broken down further in - * `sub_line_items`. - */ - @JsonProperty("sub_line_items") - @ExcludeMissing - fun _subLineItems(): JsonField> = subLineItems - - /** The line amount before before any adjustments. */ - @JsonProperty("subtotal") @ExcludeMissing fun _subtotal(): JsonField = subtotal - - /** - * An array of tax rates and their incurred tax amounts. Empty if no tax integration is - * configured. - */ - @JsonProperty("tax_amounts") - @ExcludeMissing - fun _taxAmounts(): JsonField> = taxAmounts - - /** A list of customer ids that were used to calculate the usage for this line item. */ - @JsonProperty("usage_customer_ids") - @ExcludeMissing - fun _usageCustomerIds(): JsonField> = usageCustomerIds - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): LineItem = apply { - if (validated) { - return@apply - } - - id() - adjustedSubtotal() - adjustments().forEach { it.validate() } - amount() - creditsApplied() - discount().ifPresent { it.validate() } - endDate() - filter() - grouping() - maximum().ifPresent { it.validate() } - maximumAmount() - minimum().ifPresent { it.validate() } - minimumAmount() - name() - partiallyInvoicedAmount() - price().ifPresent { it.validate() } - quantity() - startDate() - subLineItems().forEach { it.validate() } - subtotal() - taxAmounts().forEach { it.validate() } - usageCustomerIds() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [LineItem]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustedSubtotal: JsonField? = null - private var adjustments: JsonField>? = null - private var amount: JsonField? = null - private var creditsApplied: JsonField? = null - private var discount: JsonField? = null - private var endDate: JsonField? = null - private var filter: JsonField? = null - private var grouping: JsonField? = null - private var maximum: JsonField? = null - private var maximumAmount: JsonField? = null - private var minimum: JsonField? = null - private var minimumAmount: JsonField? = null - private var name: JsonField? = null - private var partiallyInvoicedAmount: JsonField? = null - private var price: JsonField? = null - private var quantity: JsonField? = null - private var startDate: JsonField? = null - private var subLineItems: JsonField>? = null - private var subtotal: JsonField? = null - private var taxAmounts: JsonField>? = null - private var usageCustomerIds: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(lineItem: LineItem) = apply { - id = lineItem.id - adjustedSubtotal = lineItem.adjustedSubtotal - adjustments = lineItem.adjustments.map { it.toMutableList() } - amount = lineItem.amount - creditsApplied = lineItem.creditsApplied - discount = lineItem.discount - endDate = lineItem.endDate - filter = lineItem.filter - grouping = lineItem.grouping - maximum = lineItem.maximum - maximumAmount = lineItem.maximumAmount - minimum = lineItem.minimum - minimumAmount = lineItem.minimumAmount - name = lineItem.name - partiallyInvoicedAmount = lineItem.partiallyInvoicedAmount - price = lineItem.price - quantity = lineItem.quantity - startDate = lineItem.startDate - subLineItems = lineItem.subLineItems.map { it.toMutableList() } - subtotal = lineItem.subtotal - taxAmounts = lineItem.taxAmounts.map { it.toMutableList() } - usageCustomerIds = lineItem.usageCustomerIds.map { it.toMutableList() } - additionalProperties = lineItem.additionalProperties.toMutableMap() - } - - /** A unique ID for this line item. */ - fun id(id: String) = id(JsonField.of(id)) - - /** A unique ID for this line item. */ - fun id(id: JsonField) = apply { this.id = id } - - /** - * The line amount after any adjustments and before overage conversion, credits and - * partial invoicing. - */ - fun adjustedSubtotal(adjustedSubtotal: String) = - adjustedSubtotal(JsonField.of(adjustedSubtotal)) - - /** - * The line amount after any adjustments and before overage conversion, credits and - * partial invoicing. - */ - fun adjustedSubtotal(adjustedSubtotal: JsonField) = apply { - this.adjustedSubtotal = adjustedSubtotal - } - - /** All adjustments (ie. maximums, minimums, discounts) applied to the line item. */ - fun adjustments(adjustments: List) = adjustments(JsonField.of(adjustments)) - - /** All adjustments (ie. maximums, minimums, discounts) applied to the line item. */ - fun adjustments(adjustments: JsonField>) = apply { - this.adjustments = adjustments.map { it.toMutableList() } - } - - /** All adjustments (ie. maximums, minimums, discounts) applied to the line item. */ - fun addAdjustment(adjustment: Adjustment) = apply { - adjustments = - (adjustments ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(adjustment) - } - } - - /** All adjustments (ie. maximums, minimums, discounts) applied to the line item. */ - fun addAdjustment(monetaryUsageDiscount: Adjustment.MonetaryUsageDiscountAdjustment) = - addAdjustment(Adjustment.ofMonetaryUsageDiscount(monetaryUsageDiscount)) - - /** All adjustments (ie. maximums, minimums, discounts) applied to the line item. */ - fun addAdjustment(monetaryAmountDiscount: Adjustment.MonetaryAmountDiscountAdjustment) = - addAdjustment(Adjustment.ofMonetaryAmountDiscount(monetaryAmountDiscount)) - - /** All adjustments (ie. maximums, minimums, discounts) applied to the line item. */ - fun addAdjustment( - monetaryPercentageDiscount: Adjustment.MonetaryPercentageDiscountAdjustment - ) = addAdjustment(Adjustment.ofMonetaryPercentageDiscount(monetaryPercentageDiscount)) - - /** All adjustments (ie. maximums, minimums, discounts) applied to the line item. */ - fun addAdjustment(monetaryMinimum: Adjustment.MonetaryMinimumAdjustment) = - addAdjustment(Adjustment.ofMonetaryMinimum(monetaryMinimum)) - - /** All adjustments (ie. maximums, minimums, discounts) applied to the line item. */ - fun addAdjustment(monetaryMaximum: Adjustment.MonetaryMaximumAdjustment) = - addAdjustment(Adjustment.ofMonetaryMaximum(monetaryMaximum)) - - /** - * The final amount for a line item after all adjustments and pre paid credits have been - * applied. - */ - fun amount(amount: String) = amount(JsonField.of(amount)) - - /** - * The final amount for a line item after all adjustments and pre paid credits have been - * applied. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** The number of prepaid credits applied. */ - fun creditsApplied(creditsApplied: String) = - creditsApplied(JsonField.of(creditsApplied)) - - /** The number of prepaid credits applied. */ - fun creditsApplied(creditsApplied: JsonField) = apply { - this.creditsApplied = creditsApplied - } - - fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) - - fun discount(discount: Optional) = discount(discount.orElse(null)) - - fun discount(discount: JsonField) = apply { this.discount = discount } - - fun discount(percentage: PercentageDiscount) = - discount(Discount.ofPercentage(percentage)) - - fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) - - fun trialDiscount(appliesToPriceIds: List) = - discount( - TrialDiscount.builder() - .discountType(TrialDiscount.DiscountType.TRIAL) - .appliesToPriceIds(appliesToPriceIds) - .build() - ) - - fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) - - fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) - - /** The end date of the range of time applied for this line item's price. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) - - /** The end date of the range of time applied for this line item's price. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** An additional filter that was used to calculate the usage for this line item. */ - fun filter(filter: String?) = filter(JsonField.ofNullable(filter)) - - /** An additional filter that was used to calculate the usage for this line item. */ - fun filter(filter: Optional) = filter(filter.orElse(null)) - - /** An additional filter that was used to calculate the usage for this line item. */ - fun filter(filter: JsonField) = apply { this.filter = filter } - - /** - * [DEPRECATED] For configured prices that are split by a grouping key, this will be - * populated with the key and a value. The `amount` and `subtotal` will be the values - * for this particular grouping. - */ - fun grouping(grouping: String?) = grouping(JsonField.ofNullable(grouping)) - - /** - * [DEPRECATED] For configured prices that are split by a grouping key, this will be - * populated with the key and a value. The `amount` and `subtotal` will be the values - * for this particular grouping. - */ - fun grouping(grouping: Optional) = grouping(grouping.orElse(null)) - - /** - * [DEPRECATED] For configured prices that are split by a grouping key, this will be - * populated with the key and a value. The `amount` and `subtotal` will be the values - * for this particular grouping. - */ - fun grouping(grouping: JsonField) = apply { this.grouping = grouping } - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.orElse(null)) - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: Optional) = - minimumAmount(minimumAmount.orElse(null)) - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** The name of the price associated with this line item. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price associated with this line item. */ - fun name(name: JsonField) = apply { this.name = name } - - /** Any amount applied from a partial invoice */ - fun partiallyInvoicedAmount(partiallyInvoicedAmount: String) = - partiallyInvoicedAmount(JsonField.of(partiallyInvoicedAmount)) - - /** Any amount applied from a partial invoice */ - fun partiallyInvoicedAmount(partiallyInvoicedAmount: JsonField) = apply { - this.partiallyInvoicedAmount = partiallyInvoicedAmount - } - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(price: Optional) = price(price.orElse(null)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(price: JsonField) = apply { this.price = price } - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(matrix: Price.MatrixPrice) = price(Price.ofMatrix(matrix)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredPackage: Price.TieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedTiered: Price.GroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(unitWithPercent: Price.UnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredWithProration: Price.TieredWithProrationPrice) = - price(Price.ofTieredWithProration(tieredWithProration)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(unitWithProration: Price.UnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedAllocation: Price.GroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bulkWithProration: Price.BulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = - price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice) = - price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - - /** Either the fixed fee quantity or the usage during the service period. */ - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - - /** Either the fixed fee quantity or the usage during the service period. */ - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - /** The start date of the range of time applied for this line item's price. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the range of time applied for this line item's price. */ - fun startDate(startDate: JsonField) = apply { - this.startDate = startDate - } - - /** - * For complex pricing structures, the line item can be broken down further in - * `sub_line_items`. - */ - fun subLineItems(subLineItems: List) = - subLineItems(JsonField.of(subLineItems)) - - /** - * For complex pricing structures, the line item can be broken down further in - * `sub_line_items`. - */ - fun subLineItems(subLineItems: JsonField>) = apply { - this.subLineItems = subLineItems.map { it.toMutableList() } - } - - /** - * For complex pricing structures, the line item can be broken down further in - * `sub_line_items`. - */ - fun addSubLineItem(subLineItem: SubLineItem) = apply { - subLineItems = - (subLineItems ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(subLineItem) - } - } - - /** - * For complex pricing structures, the line item can be broken down further in - * `sub_line_items`. - */ - fun addSubLineItem(matrix: SubLineItem.MatrixSubLineItem) = - addSubLineItem(SubLineItem.ofMatrix(matrix)) - - /** - * For complex pricing structures, the line item can be broken down further in - * `sub_line_items`. - */ - fun addSubLineItem(tier: SubLineItem.TierSubLineItem) = - addSubLineItem(SubLineItem.ofTier(tier)) - - /** - * For complex pricing structures, the line item can be broken down further in - * `sub_line_items`. - */ - fun addSubLineItem(other: SubLineItem.OtherSubLineItem) = - addSubLineItem(SubLineItem.ofOther(other)) - - /** The line amount before before any adjustments. */ - fun subtotal(subtotal: String) = subtotal(JsonField.of(subtotal)) - - /** The line amount before before any adjustments. */ - fun subtotal(subtotal: JsonField) = apply { this.subtotal = subtotal } - - /** - * An array of tax rates and their incurred tax amounts. Empty if no tax integration is - * configured. - */ - fun taxAmounts(taxAmounts: List) = taxAmounts(JsonField.of(taxAmounts)) - - /** - * An array of tax rates and their incurred tax amounts. Empty if no tax integration is - * configured. - */ - fun taxAmounts(taxAmounts: JsonField>) = apply { - this.taxAmounts = taxAmounts.map { it.toMutableList() } - } - - /** - * An array of tax rates and their incurred tax amounts. Empty if no tax integration is - * configured. - */ - fun addTaxAmount(taxAmount: TaxAmount) = apply { - taxAmounts = - (taxAmounts ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(taxAmount) - } - } - - /** A list of customer ids that were used to calculate the usage for this line item. */ - fun usageCustomerIds(usageCustomerIds: List?) = - usageCustomerIds(JsonField.ofNullable(usageCustomerIds)) - - /** A list of customer ids that were used to calculate the usage for this line item. */ - fun usageCustomerIds(usageCustomerIds: Optional>) = - usageCustomerIds(usageCustomerIds.orElse(null)) - - /** A list of customer ids that were used to calculate the usage for this line item. */ - fun usageCustomerIds(usageCustomerIds: JsonField>) = apply { - this.usageCustomerIds = usageCustomerIds.map { it.toMutableList() } - } - - /** A list of customer ids that were used to calculate the usage for this line item. */ - fun addUsageCustomerId(usageCustomerId: String) = apply { - usageCustomerIds = - (usageCustomerIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(usageCustomerId) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): LineItem = - LineItem( - checkRequired("id", id), - checkRequired("adjustedSubtotal", adjustedSubtotal), - checkRequired("adjustments", adjustments).map { it.toImmutable() }, - checkRequired("amount", amount), - checkRequired("creditsApplied", creditsApplied), - checkRequired("discount", discount), - checkRequired("endDate", endDate), - checkRequired("filter", filter), - checkRequired("grouping", grouping), - checkRequired("maximum", maximum), - checkRequired("maximumAmount", maximumAmount), - checkRequired("minimum", minimum), - checkRequired("minimumAmount", minimumAmount), - checkRequired("name", name), - checkRequired("partiallyInvoicedAmount", partiallyInvoicedAmount), - checkRequired("price", price), - checkRequired("quantity", quantity), - checkRequired("startDate", startDate), - checkRequired("subLineItems", subLineItems).map { it.toImmutable() }, - checkRequired("subtotal", subtotal), - checkRequired("taxAmounts", taxAmounts).map { it.toImmutable() }, - checkRequired("usageCustomerIds", usageCustomerIds).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val monetaryUsageDiscount: MonetaryUsageDiscountAdjustment? = null, - private val monetaryAmountDiscount: MonetaryAmountDiscountAdjustment? = null, - private val monetaryPercentageDiscount: MonetaryPercentageDiscountAdjustment? = null, - private val monetaryMinimum: MonetaryMinimumAdjustment? = null, - private val monetaryMaximum: MonetaryMaximumAdjustment? = null, - private val _json: JsonValue? = null, - ) { - - fun monetaryUsageDiscount(): Optional = - Optional.ofNullable(monetaryUsageDiscount) - - fun monetaryAmountDiscount(): Optional = - Optional.ofNullable(monetaryAmountDiscount) - - fun monetaryPercentageDiscount(): Optional = - Optional.ofNullable(monetaryPercentageDiscount) - - fun monetaryMinimum(): Optional = - Optional.ofNullable(monetaryMinimum) - - fun monetaryMaximum(): Optional = - Optional.ofNullable(monetaryMaximum) - - fun isMonetaryUsageDiscount(): Boolean = monetaryUsageDiscount != null - - fun isMonetaryAmountDiscount(): Boolean = monetaryAmountDiscount != null - - fun isMonetaryPercentageDiscount(): Boolean = monetaryPercentageDiscount != null - - fun isMonetaryMinimum(): Boolean = monetaryMinimum != null - - fun isMonetaryMaximum(): Boolean = monetaryMaximum != null - - fun asMonetaryUsageDiscount(): MonetaryUsageDiscountAdjustment = - monetaryUsageDiscount.getOrThrow("monetaryUsageDiscount") - - fun asMonetaryAmountDiscount(): MonetaryAmountDiscountAdjustment = - monetaryAmountDiscount.getOrThrow("monetaryAmountDiscount") - - fun asMonetaryPercentageDiscount(): MonetaryPercentageDiscountAdjustment = - monetaryPercentageDiscount.getOrThrow("monetaryPercentageDiscount") - - fun asMonetaryMinimum(): MonetaryMinimumAdjustment = - monetaryMinimum.getOrThrow("monetaryMinimum") - - fun asMonetaryMaximum(): MonetaryMaximumAdjustment = - monetaryMaximum.getOrThrow("monetaryMaximum") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - monetaryUsageDiscount != null -> - visitor.visitMonetaryUsageDiscount(monetaryUsageDiscount) - monetaryAmountDiscount != null -> - visitor.visitMonetaryAmountDiscount(monetaryAmountDiscount) - monetaryPercentageDiscount != null -> - visitor.visitMonetaryPercentageDiscount(monetaryPercentageDiscount) - monetaryMinimum != null -> visitor.visitMonetaryMinimum(monetaryMinimum) - monetaryMaximum != null -> visitor.visitMonetaryMaximum(monetaryMaximum) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitMonetaryUsageDiscount( - monetaryUsageDiscount: MonetaryUsageDiscountAdjustment - ) { - monetaryUsageDiscount.validate() - } - - override fun visitMonetaryAmountDiscount( - monetaryAmountDiscount: MonetaryAmountDiscountAdjustment - ) { - monetaryAmountDiscount.validate() - } - - override fun visitMonetaryPercentageDiscount( - monetaryPercentageDiscount: MonetaryPercentageDiscountAdjustment - ) { - monetaryPercentageDiscount.validate() - } - - override fun visitMonetaryMinimum( - monetaryMinimum: MonetaryMinimumAdjustment - ) { - monetaryMinimum.validate() - } - - override fun visitMonetaryMaximum( - monetaryMaximum: MonetaryMaximumAdjustment - ) { - monetaryMaximum.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Adjustment && monetaryUsageDiscount == other.monetaryUsageDiscount && monetaryAmountDiscount == other.monetaryAmountDiscount && monetaryPercentageDiscount == other.monetaryPercentageDiscount && monetaryMinimum == other.monetaryMinimum && monetaryMaximum == other.monetaryMaximum /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(monetaryUsageDiscount, monetaryAmountDiscount, monetaryPercentageDiscount, monetaryMinimum, monetaryMaximum) /* spotless:on */ - - override fun toString(): String = - when { - monetaryUsageDiscount != null -> - "Adjustment{monetaryUsageDiscount=$monetaryUsageDiscount}" - monetaryAmountDiscount != null -> - "Adjustment{monetaryAmountDiscount=$monetaryAmountDiscount}" - monetaryPercentageDiscount != null -> - "Adjustment{monetaryPercentageDiscount=$monetaryPercentageDiscount}" - monetaryMinimum != null -> "Adjustment{monetaryMinimum=$monetaryMinimum}" - monetaryMaximum != null -> "Adjustment{monetaryMaximum=$monetaryMaximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } - - companion object { - - @JvmStatic - fun ofMonetaryUsageDiscount( - monetaryUsageDiscount: MonetaryUsageDiscountAdjustment - ) = Adjustment(monetaryUsageDiscount = monetaryUsageDiscount) - - @JvmStatic - fun ofMonetaryAmountDiscount( - monetaryAmountDiscount: MonetaryAmountDiscountAdjustment - ) = Adjustment(monetaryAmountDiscount = monetaryAmountDiscount) - - @JvmStatic - fun ofMonetaryPercentageDiscount( - monetaryPercentageDiscount: MonetaryPercentageDiscountAdjustment - ) = Adjustment(monetaryPercentageDiscount = monetaryPercentageDiscount) - - @JvmStatic - fun ofMonetaryMinimum(monetaryMinimum: MonetaryMinimumAdjustment) = - Adjustment(monetaryMinimum = monetaryMinimum) - - @JvmStatic - fun ofMonetaryMaximum(monetaryMaximum: MonetaryMaximumAdjustment) = - Adjustment(monetaryMaximum = monetaryMaximum) - } - - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { - - fun visitMonetaryUsageDiscount( - monetaryUsageDiscount: MonetaryUsageDiscountAdjustment - ): T - - fun visitMonetaryAmountDiscount( - monetaryAmountDiscount: MonetaryAmountDiscountAdjustment - ): T - - fun visitMonetaryPercentageDiscount( - monetaryPercentageDiscount: MonetaryPercentageDiscountAdjustment - ): T - - fun visitMonetaryMinimum(monetaryMinimum: MonetaryMinimumAdjustment): T - - fun visitMonetaryMaximum(monetaryMaximum: MonetaryMaximumAdjustment): T - - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } - - internal class Deserializer : BaseDeserializer(Adjustment::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = - json.asObject().getOrNull()?.get("adjustment_type")?.asString()?.getOrNull() - - when (adjustmentType) { - "usage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(monetaryUsageDiscount = it, _json = json) - } - } - "amount_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(monetaryAmountDiscount = it, _json = json) - } - } - "percentage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(monetaryPercentageDiscount = it, _json = json) - } - } - "minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(monetaryMinimum = it, _json = json) - } - } - "maximum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(monetaryMaximum = it, _json = json) - } - } - } - - return Adjustment(_json = json) - } - } - - internal class Serializer : BaseSerializer(Adjustment::class) { - - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.monetaryUsageDiscount != null -> - generator.writeObject(value.monetaryUsageDiscount) - value.monetaryAmountDiscount != null -> - generator.writeObject(value.monetaryAmountDiscount) - value.monetaryPercentageDiscount != null -> - generator.writeObject(value.monetaryPercentageDiscount) - value.monetaryMinimum != null -> - generator.writeObject(value.monetaryMinimum) - value.monetaryMaximum != null -> - generator.writeObject(value.monetaryMaximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") - } - } - } - - @NoAutoDetect - class MonetaryUsageDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonProperty("usage_discount") - @ExcludeMissing - private val usageDiscount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The value applied by an adjustment. */ - fun amount(): String = amount.getRequired("amount") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - /** - * The number of usage units by which to discount the price this adjustment applies - * to in a given billing period. - */ - fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The value applied by an adjustment. */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - /** - * The number of usage units by which to discount the price this adjustment applies - * to in a given billing period. - */ - @JsonProperty("usage_discount") - @ExcludeMissing - fun _usageDiscount(): JsonField = usageDiscount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MonetaryUsageDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - amount() - appliesToPriceIds() - isInvoiceLevel() - reason() - usageDiscount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MonetaryUsageDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var amount: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var reason: JsonField? = null - private var usageDiscount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - monetaryUsageDiscountAdjustment: MonetaryUsageDiscountAdjustment - ) = apply { - id = monetaryUsageDiscountAdjustment.id - adjustmentType = monetaryUsageDiscountAdjustment.adjustmentType - amount = monetaryUsageDiscountAdjustment.amount - appliesToPriceIds = - monetaryUsageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = monetaryUsageDiscountAdjustment.isInvoiceLevel - reason = monetaryUsageDiscountAdjustment.reason - usageDiscount = monetaryUsageDiscountAdjustment.usageDiscount - additionalProperties = - monetaryUsageDiscountAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The value applied by an adjustment. */ - fun amount(amount: String) = amount(JsonField.of(amount)) - - /** The value applied by an adjustment. */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - /** - * The number of usage units by which to discount the price this adjustment - * applies to in a given billing period. - */ - fun usageDiscount(usageDiscount: Double) = - usageDiscount(JsonField.of(usageDiscount)) - - /** - * The number of usage units by which to discount the price this adjustment - * applies to in a given billing period. - */ - fun usageDiscount(usageDiscount: JsonField) = apply { - this.usageDiscount = usageDiscount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): MonetaryUsageDiscountAdjustment = - MonetaryUsageDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("amount", amount), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("reason", reason), - checkRequired("usageDiscount", usageDiscount), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - USAGE_DISCOUNT -> Known.USAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MonetaryUsageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, amount, appliesToPriceIds, isInvoiceLevel, reason, usageDiscount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MonetaryUsageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amount=$amount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class MonetaryAmountDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("amount_discount") - @ExcludeMissing - private val amountDiscount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The value applied by an adjustment. */ - fun amount(): String = amount.getRequired("amount") - - /** - * The amount by which to discount the prices this adjustment applies to in a given - * billing period. - */ - fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The value applied by an adjustment. */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** - * The amount by which to discount the prices this adjustment applies to in a given - * billing period. - */ - @JsonProperty("amount_discount") - @ExcludeMissing - fun _amountDiscount(): JsonField = amountDiscount - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MonetaryAmountDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - amount() - amountDiscount() - appliesToPriceIds() - isInvoiceLevel() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MonetaryAmountDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var amount: JsonField? = null - private var amountDiscount: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - monetaryAmountDiscountAdjustment: MonetaryAmountDiscountAdjustment - ) = apply { - id = monetaryAmountDiscountAdjustment.id - adjustmentType = monetaryAmountDiscountAdjustment.adjustmentType - amount = monetaryAmountDiscountAdjustment.amount - amountDiscount = monetaryAmountDiscountAdjustment.amountDiscount - appliesToPriceIds = - monetaryAmountDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = monetaryAmountDiscountAdjustment.isInvoiceLevel - reason = monetaryAmountDiscountAdjustment.reason - additionalProperties = - monetaryAmountDiscountAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The value applied by an adjustment. */ - fun amount(amount: String) = amount(JsonField.of(amount)) - - /** The value applied by an adjustment. */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** - * The amount by which to discount the prices this adjustment applies to in a - * given billing period. - */ - fun amountDiscount(amountDiscount: String) = - amountDiscount(JsonField.of(amountDiscount)) - - /** - * The amount by which to discount the prices this adjustment applies to in a - * given billing period. - */ - fun amountDiscount(amountDiscount: JsonField) = apply { - this.amountDiscount = amountDiscount - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): MonetaryAmountDiscountAdjustment = - MonetaryAmountDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("amount", amount), - checkRequired("amountDiscount", amountDiscount), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MonetaryAmountDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, amount, amountDiscount, appliesToPriceIds, isInvoiceLevel, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MonetaryAmountDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amount=$amount, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class MonetaryPercentageDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("percentage_discount") - @ExcludeMissing - private val percentageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The value applied by an adjustment. */ - fun amount(): String = amount.getRequired("amount") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(): Double = - percentageDiscount.getRequired("percentage_discount") - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The value applied by an adjustment. */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - @JsonProperty("percentage_discount") - @ExcludeMissing - fun _percentageDiscount(): JsonField = percentageDiscount - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MonetaryPercentageDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - amount() - appliesToPriceIds() - isInvoiceLevel() - percentageDiscount() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MonetaryPercentageDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var amount: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var percentageDiscount: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - monetaryPercentageDiscountAdjustment: MonetaryPercentageDiscountAdjustment - ) = apply { - id = monetaryPercentageDiscountAdjustment.id - adjustmentType = monetaryPercentageDiscountAdjustment.adjustmentType - amount = monetaryPercentageDiscountAdjustment.amount - appliesToPriceIds = - monetaryPercentageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = monetaryPercentageDiscountAdjustment.isInvoiceLevel - percentageDiscount = monetaryPercentageDiscountAdjustment.percentageDiscount - reason = monetaryPercentageDiscountAdjustment.reason - additionalProperties = - monetaryPercentageDiscountAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The value applied by an adjustment. */ - fun amount(amount: String) = amount(JsonField.of(amount)) - - /** The value applied by an adjustment. */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(percentageDiscount: Double) = - percentageDiscount(JsonField.of(percentageDiscount)) - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(percentageDiscount: JsonField) = apply { - this.percentageDiscount = percentageDiscount - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): MonetaryPercentageDiscountAdjustment = - MonetaryPercentageDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("amount", amount), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("percentageDiscount", percentageDiscount), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val PERCENTAGE_DISCOUNT = of("percentage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MonetaryPercentageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, amount, appliesToPriceIds, isInvoiceLevel, percentageDiscount, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MonetaryPercentageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amount=$amount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class MonetaryMinimumAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The value applied by an adjustment. */ - fun amount(): String = amount.getRequired("amount") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(): String = itemId.getRequired("item_id") - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The value applied by an adjustment. */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The item ID that revenue from this minimum will be attributed to. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MonetaryMinimumAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - amount() - appliesToPriceIds() - isInvoiceLevel() - itemId() - minimumAmount() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MonetaryMinimumAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var amount: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var itemId: JsonField? = null - private var minimumAmount: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(monetaryMinimumAdjustment: MonetaryMinimumAdjustment) = - apply { - id = monetaryMinimumAdjustment.id - adjustmentType = monetaryMinimumAdjustment.adjustmentType - amount = monetaryMinimumAdjustment.amount - appliesToPriceIds = - monetaryMinimumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = monetaryMinimumAdjustment.isInvoiceLevel - itemId = monetaryMinimumAdjustment.itemId - minimumAmount = monetaryMinimumAdjustment.minimumAmount - reason = monetaryMinimumAdjustment.reason - additionalProperties = - monetaryMinimumAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The value applied by an adjustment. */ - fun amount(amount: String) = amount(JsonField.of(amount)) - - /** The value applied by an adjustment. */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): MonetaryMinimumAdjustment = - MonetaryMinimumAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("amount", amount), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("itemId", itemId), - checkRequired("minimumAmount", minimumAmount), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MonetaryMinimumAdjustment && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, amount, appliesToPriceIds, isInvoiceLevel, itemId, minimumAmount, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MonetaryMinimumAdjustment{id=$id, adjustmentType=$adjustmentType, amount=$amount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class MonetaryMaximumAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The value applied by an adjustment. */ - fun amount(): String = amount.getRequired("amount") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The value applied by an adjustment. */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MonetaryMaximumAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - amount() - appliesToPriceIds() - isInvoiceLevel() - maximumAmount() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MonetaryMaximumAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var amount: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var maximumAmount: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(monetaryMaximumAdjustment: MonetaryMaximumAdjustment) = - apply { - id = monetaryMaximumAdjustment.id - adjustmentType = monetaryMaximumAdjustment.adjustmentType - amount = monetaryMaximumAdjustment.amount - appliesToPriceIds = - monetaryMaximumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = monetaryMaximumAdjustment.isInvoiceLevel - maximumAmount = monetaryMaximumAdjustment.maximumAmount - reason = monetaryMaximumAdjustment.reason - additionalProperties = - monetaryMaximumAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The value applied by an adjustment. */ - fun amount(amount: String) = amount(JsonField.of(amount)) - - /** The value applied by an adjustment. */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): MonetaryMaximumAdjustment = - MonetaryMaximumAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("amount", amount), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("maximumAmount", maximumAmount), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MonetaryMaximumAdjustment && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, amount, appliesToPriceIds, isInvoiceLevel, maximumAmount, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MonetaryMaximumAdjustment{id=$id, adjustmentType=$adjustmentType, amount=$amount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, reason=$reason, additionalProperties=$additionalProperties}" - } - } - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - @NoAutoDetect - class Maximum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Maximum amount applied */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Maximum amount applied */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Maximum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - maximumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Maximum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = maximum.maximumAmount - additionalProperties = maximum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Maximum = - Maximum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("maximumAmount", maximumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Maximum && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, maximumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Maximum{appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, additionalProperties=$additionalProperties}" - } - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - @NoAutoDetect - class Minimum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Minimum amount applied */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Minimum amount applied */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Minimum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - minimumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Minimum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var minimumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } - minimumAmount = minimum.minimumAmount - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Minimum = - Minimum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("minimumAmount", minimumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Minimum && appliesToPriceIds == other.appliesToPriceIds && minimumAmount == other.minimumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, minimumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(using = SubLineItem.Deserializer::class) - @JsonSerialize(using = SubLineItem.Serializer::class) - class SubLineItem - private constructor( - private val matrix: MatrixSubLineItem? = null, - private val tier: TierSubLineItem? = null, - private val other: OtherSubLineItem? = null, - private val _json: JsonValue? = null, - ) { - - fun matrix(): Optional = Optional.ofNullable(matrix) - - fun tier(): Optional = Optional.ofNullable(tier) - - fun other(): Optional = Optional.ofNullable(other) - - fun isMatrix(): Boolean = matrix != null - - fun isTier(): Boolean = tier != null - - fun isOther(): Boolean = other != null - - fun asMatrix(): MatrixSubLineItem = matrix.getOrThrow("matrix") - - fun asTier(): TierSubLineItem = tier.getOrThrow("tier") - - fun asOther(): OtherSubLineItem = other.getOrThrow("other") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - matrix != null -> visitor.visitMatrix(matrix) - tier != null -> visitor.visitTier(tier) - other != null -> visitor.visitOther(other) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): SubLineItem = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitMatrix(matrix: MatrixSubLineItem) { - matrix.validate() - } - - override fun visitTier(tier: TierSubLineItem) { - tier.validate() - } - - override fun visitOther(other: OtherSubLineItem) { - other.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is SubLineItem && matrix == other.matrix && tier == other.tier && this.other == other.other /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(matrix, tier, other) /* spotless:on */ - - override fun toString(): String = - when { - matrix != null -> "SubLineItem{matrix=$matrix}" - tier != null -> "SubLineItem{tier=$tier}" - other != null -> "SubLineItem{other=$other}" - _json != null -> "SubLineItem{_unknown=$_json}" - else -> throw IllegalStateException("Invalid SubLineItem") - } - - companion object { - - @JvmStatic fun ofMatrix(matrix: MatrixSubLineItem) = SubLineItem(matrix = matrix) - - @JvmStatic fun ofTier(tier: TierSubLineItem) = SubLineItem(tier = tier) - - @JvmStatic fun ofOther(other: OtherSubLineItem) = SubLineItem(other = other) - } - - /** - * An interface that defines how to map each variant of [SubLineItem] to a value of type - * [T]. - */ - interface Visitor { - - fun visitMatrix(matrix: MatrixSubLineItem): T - - fun visitTier(tier: TierSubLineItem): T - - fun visitOther(other: OtherSubLineItem): T - - /** - * Maps an unknown variant of [SubLineItem] to a value of type [T]. - * - * An instance of [SubLineItem] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown SubLineItem: $json") - } - } - - internal class Deserializer : BaseDeserializer(SubLineItem::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): SubLineItem { - val json = JsonValue.fromJsonNode(node) - val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() - - when (type) { - "matrix" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return SubLineItem(matrix = it, _json = json) - } - } - "tier" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return SubLineItem(tier = it, _json = json) - } - } - "'null'" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return SubLineItem(other = it, _json = json) - } - } - } - - return SubLineItem(_json = json) - } - } - - internal class Serializer : BaseSerializer(SubLineItem::class) { - - override fun serialize( - value: SubLineItem, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.matrix != null -> generator.writeObject(value.matrix) - value.tier != null -> generator.writeObject(value.tier) - value.other != null -> generator.writeObject(value.other) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid SubLineItem") - } - } - } - - @NoAutoDetect - class MatrixSubLineItem - @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("grouping") - @ExcludeMissing - private val grouping: JsonField = JsonMissing.of(), - @JsonProperty("matrix_config") - @ExcludeMissing - private val matrixConfig: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - private val quantity: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The total amount for this sub line item. */ - fun amount(): String = amount.getRequired("amount") - - fun grouping(): Optional = - Optional.ofNullable(grouping.getNullable("grouping")) - - fun matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_config") - - fun name(): String = name.getRequired("name") - - fun quantity(): Double = quantity.getRequired("quantity") - - fun type(): Type = type.getRequired("type") - - /** The total amount for this sub line item. */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - @JsonProperty("grouping") - @ExcludeMissing - fun _grouping(): JsonField = grouping - - @JsonProperty("matrix_config") - @ExcludeMissing - fun _matrixConfig(): JsonField = matrixConfig - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("quantity") - @ExcludeMissing - fun _quantity(): JsonField = quantity - - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MatrixSubLineItem = apply { - if (validated) { - return@apply - } - - amount() - grouping().ifPresent { it.validate() } - matrixConfig().validate() - name() - quantity() - type() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MatrixSubLineItem]. */ - class Builder internal constructor() { - - private var amount: JsonField? = null - private var grouping: JsonField? = null - private var matrixConfig: JsonField? = null - private var name: JsonField? = null - private var quantity: JsonField? = null - private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(matrixSubLineItem: MatrixSubLineItem) = apply { - amount = matrixSubLineItem.amount - grouping = matrixSubLineItem.grouping - matrixConfig = matrixSubLineItem.matrixConfig - name = matrixSubLineItem.name - quantity = matrixSubLineItem.quantity - type = matrixSubLineItem.type - additionalProperties = matrixSubLineItem.additionalProperties.toMutableMap() - } - - /** The total amount for this sub line item. */ - fun amount(amount: String) = amount(JsonField.of(amount)) - - /** The total amount for this sub line item. */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun grouping(grouping: Grouping?) = grouping(JsonField.ofNullable(grouping)) - - fun grouping(grouping: Optional) = grouping(grouping.orElse(null)) - - fun grouping(grouping: JsonField) = apply { this.grouping = grouping } - - fun matrixConfig(matrixConfig: MatrixConfig) = - matrixConfig(JsonField.of(matrixConfig)) - - fun matrixConfig(matrixConfig: JsonField) = apply { - this.matrixConfig = matrixConfig - } - - fun name(name: String) = name(JsonField.of(name)) - - fun name(name: JsonField) = apply { this.name = name } - - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun type(type: Type) = type(JsonField.of(type)) - - 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) - } - - fun build(): MatrixSubLineItem = - MatrixSubLineItem( - checkRequired("amount", amount), - checkRequired("grouping", grouping), - checkRequired("matrixConfig", matrixConfig), - checkRequired("name", name), - checkRequired("quantity", quantity), - checkRequired("type", type), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Grouping - @JsonCreator - private constructor( - @JsonProperty("key") - @ExcludeMissing - private val key: JsonField = JsonMissing.of(), - @JsonProperty("value") - @ExcludeMissing - private val value: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun key(): String = key.getRequired("key") - - /** No value indicates the default group */ - fun value(): Optional = Optional.ofNullable(value.getNullable("value")) - - @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key - - /** No value indicates the default group */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Grouping = apply { - if (validated) { - return@apply - } - - key() - value() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Grouping]. */ - class Builder internal constructor() { - - private var key: JsonField? = null - private var value: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(grouping: Grouping) = apply { - key = grouping.key - value = grouping.value - additionalProperties = grouping.additionalProperties.toMutableMap() - } - - fun key(key: String) = key(JsonField.of(key)) - - fun key(key: JsonField) = apply { this.key = key } - - /** No value indicates the default group */ - fun value(value: String?) = value(JsonField.ofNullable(value)) - - /** No value indicates the default group */ - fun value(value: Optional) = value(value.orElse(null)) - - /** No value indicates the default group */ - fun value(value: JsonField) = apply { this.value = 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) - } - - fun build(): Grouping = - Grouping( - checkRequired("key", key), - checkRequired("value", value), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Grouping && key == other.key && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(key, value, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Grouping{key=$key, value=$value, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class MatrixConfig - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The ordered dimension values for this line item. */ - fun dimensionValues(): List = - dimensionValues.getRequired("dimension_values") - - /** The ordered dimension values for this line item. */ - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MatrixConfig = apply { - if (validated) { - return@apply - } - - dimensionValues() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MatrixConfig]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(matrixConfig: MatrixConfig) = apply { - dimensionValues = - matrixConfig.dimensionValues.map { it.toMutableList() } - additionalProperties = matrixConfig.additionalProperties.toMutableMap() - } - - /** The ordered dimension values for this line item. */ - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - /** The ordered dimension values for this line item. */ - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - /** The ordered dimension values for this line item. */ - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): MatrixConfig = - MatrixConfig( - checkRequired("dimensionValues", dimensionValues).map { - it.toImmutable() - }, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MatrixConfig && dimensionValues == other.dimensionValues && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MatrixConfig{dimensionValues=$dimensionValues, additionalProperties=$additionalProperties}" - } - - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MATRIX = of("matrix") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - MATRIX - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MATRIX, - /** - * An enum member indicating that [Type] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MATRIX -> Value.MATRIX - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MATRIX -> Known.MATRIX - else -> throw OrbInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MatrixSubLineItem && amount == other.amount && grouping == other.grouping && matrixConfig == other.matrixConfig && name == other.name && quantity == other.quantity && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, grouping, matrixConfig, name, quantity, type, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MatrixSubLineItem{amount=$amount, grouping=$grouping, matrixConfig=$matrixConfig, name=$name, quantity=$quantity, type=$type, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class TierSubLineItem - @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("grouping") - @ExcludeMissing - private val grouping: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - private val quantity: JsonField = JsonMissing.of(), - @JsonProperty("tier_config") - @ExcludeMissing - private val tierConfig: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The total amount for this sub line item. */ - fun amount(): String = amount.getRequired("amount") - - fun grouping(): Optional = - Optional.ofNullable(grouping.getNullable("grouping")) - - fun name(): String = name.getRequired("name") - - fun quantity(): Double = quantity.getRequired("quantity") - - fun tierConfig(): TierConfig = tierConfig.getRequired("tier_config") - - fun type(): Type = type.getRequired("type") - - /** The total amount for this sub line item. */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - @JsonProperty("grouping") - @ExcludeMissing - fun _grouping(): JsonField = grouping - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("quantity") - @ExcludeMissing - fun _quantity(): JsonField = quantity - - @JsonProperty("tier_config") - @ExcludeMissing - fun _tierConfig(): JsonField = tierConfig - - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TierSubLineItem = apply { - if (validated) { - return@apply - } - - amount() - grouping().ifPresent { it.validate() } - name() - quantity() - tierConfig().validate() - type() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TierSubLineItem]. */ - class Builder internal constructor() { - - private var amount: JsonField? = null - private var grouping: JsonField? = null - private var name: JsonField? = null - private var quantity: JsonField? = null - private var tierConfig: JsonField? = null - private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tierSubLineItem: TierSubLineItem) = apply { - amount = tierSubLineItem.amount - grouping = tierSubLineItem.grouping - name = tierSubLineItem.name - quantity = tierSubLineItem.quantity - tierConfig = tierSubLineItem.tierConfig - type = tierSubLineItem.type - additionalProperties = tierSubLineItem.additionalProperties.toMutableMap() - } - - /** The total amount for this sub line item. */ - fun amount(amount: String) = amount(JsonField.of(amount)) - - /** The total amount for this sub line item. */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun grouping(grouping: Grouping?) = grouping(JsonField.ofNullable(grouping)) - - fun grouping(grouping: Optional) = grouping(grouping.orElse(null)) - - fun grouping(grouping: JsonField) = apply { this.grouping = grouping } - - fun name(name: String) = name(JsonField.of(name)) - - fun name(name: JsonField) = apply { this.name = name } - - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun tierConfig(tierConfig: TierConfig) = tierConfig(JsonField.of(tierConfig)) - - fun tierConfig(tierConfig: JsonField) = apply { - this.tierConfig = tierConfig - } - - fun type(type: Type) = type(JsonField.of(type)) - - 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) - } - - fun build(): TierSubLineItem = - TierSubLineItem( - checkRequired("amount", amount), - checkRequired("grouping", grouping), - checkRequired("name", name), - checkRequired("quantity", quantity), - checkRequired("tierConfig", tierConfig), - checkRequired("type", type), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Grouping - @JsonCreator - private constructor( - @JsonProperty("key") - @ExcludeMissing - private val key: JsonField = JsonMissing.of(), - @JsonProperty("value") - @ExcludeMissing - private val value: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun key(): String = key.getRequired("key") - - /** No value indicates the default group */ - fun value(): Optional = Optional.ofNullable(value.getNullable("value")) - - @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key - - /** No value indicates the default group */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Grouping = apply { - if (validated) { - return@apply - } - - key() - value() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Grouping]. */ - class Builder internal constructor() { - - private var key: JsonField? = null - private var value: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(grouping: Grouping) = apply { - key = grouping.key - value = grouping.value - additionalProperties = grouping.additionalProperties.toMutableMap() - } - - fun key(key: String) = key(JsonField.of(key)) - - fun key(key: JsonField) = apply { this.key = key } - - /** No value indicates the default group */ - fun value(value: String?) = value(JsonField.ofNullable(value)) - - /** No value indicates the default group */ - fun value(value: Optional) = value(value.orElse(null)) - - /** No value indicates the default group */ - fun value(value: JsonField) = apply { this.value = 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) - } - - fun build(): Grouping = - Grouping( - checkRequired("key", key), - checkRequired("value", value), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Grouping && key == other.key && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(key, value, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Grouping{key=$key, value=$value, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class TierConfig - @JsonCreator - private constructor( - @JsonProperty("first_unit") - @ExcludeMissing - private val firstUnit: JsonField = JsonMissing.of(), - @JsonProperty("last_unit") - @ExcludeMissing - private val lastUnit: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - private val unitAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun firstUnit(): Double = firstUnit.getRequired("first_unit") - - fun lastUnit(): Optional = - Optional.ofNullable(lastUnit.getNullable("last_unit")) - - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - @JsonProperty("first_unit") - @ExcludeMissing - fun _firstUnit(): JsonField = firstUnit - - @JsonProperty("last_unit") - @ExcludeMissing - fun _lastUnit(): JsonField = lastUnit - - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TierConfig = apply { - if (validated) { - return@apply - } - - firstUnit() - lastUnit() - unitAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TierConfig]. */ - class Builder internal constructor() { - - private var firstUnit: JsonField? = null - private var lastUnit: JsonField? = null - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tierConfig: TierConfig) = apply { - firstUnit = tierConfig.firstUnit - lastUnit = tierConfig.lastUnit - unitAmount = tierConfig.unitAmount - additionalProperties = tierConfig.additionalProperties.toMutableMap() - } - - fun firstUnit(firstUnit: Double) = firstUnit(JsonField.of(firstUnit)) - - fun firstUnit(firstUnit: JsonField) = apply { - this.firstUnit = firstUnit - } - - fun lastUnit(lastUnit: Double?) = lastUnit(JsonField.ofNullable(lastUnit)) - - fun lastUnit(lastUnit: Double) = lastUnit(lastUnit as Double?) - - @Suppress( - "USELESS_CAST" - ) // See https://youtrack.jetbrains.com/issue/KT-74228 - fun lastUnit(lastUnit: Optional) = - lastUnit(lastUnit.orElse(null) as Double?) - - fun lastUnit(lastUnit: JsonField) = apply { - this.lastUnit = lastUnit - } - - fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - - 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 build(): TierConfig = - TierConfig( - checkRequired("firstUnit", firstUnit), - checkRequired("lastUnit", lastUnit), - checkRequired("unitAmount", unitAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TierConfig && firstUnit == other.firstUnit && lastUnit == other.lastUnit && unitAmount == other.unitAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(firstUnit, lastUnit, unitAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TierConfig{firstUnit=$firstUnit, lastUnit=$lastUnit, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } - - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val TIER = of("tier") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - TIER - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIER, - /** - * An enum member indicating that [Type] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIER -> Value.TIER - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TIER -> Known.TIER - else -> throw OrbInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TierSubLineItem && amount == other.amount && grouping == other.grouping && name == other.name && quantity == other.quantity && tierConfig == other.tierConfig && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, grouping, name, quantity, tierConfig, type, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TierSubLineItem{amount=$amount, grouping=$grouping, name=$name, quantity=$quantity, tierConfig=$tierConfig, type=$type, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class OtherSubLineItem - @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("grouping") - @ExcludeMissing - private val grouping: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - private val quantity: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - private val type: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The total amount for this sub line item. */ - fun amount(): String = amount.getRequired("amount") - - fun grouping(): Optional = - Optional.ofNullable(grouping.getNullable("grouping")) - - fun name(): String = name.getRequired("name") - - fun quantity(): Double = quantity.getRequired("quantity") - - fun type(): Type = type.getRequired("type") - - /** The total amount for this sub line item. */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - @JsonProperty("grouping") - @ExcludeMissing - fun _grouping(): JsonField = grouping - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("quantity") - @ExcludeMissing - fun _quantity(): JsonField = quantity - - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): OtherSubLineItem = apply { - if (validated) { - return@apply - } - - amount() - grouping().ifPresent { it.validate() } - name() - quantity() - type() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [OtherSubLineItem]. */ - class Builder internal constructor() { - - private var amount: JsonField? = null - private var grouping: JsonField? = null - private var name: JsonField? = null - private var quantity: JsonField? = null - private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(otherSubLineItem: OtherSubLineItem) = apply { - amount = otherSubLineItem.amount - grouping = otherSubLineItem.grouping - name = otherSubLineItem.name - quantity = otherSubLineItem.quantity - type = otherSubLineItem.type - additionalProperties = otherSubLineItem.additionalProperties.toMutableMap() - } - - /** The total amount for this sub line item. */ - fun amount(amount: String) = amount(JsonField.of(amount)) - - /** The total amount for this sub line item. */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun grouping(grouping: Grouping?) = grouping(JsonField.ofNullable(grouping)) - - fun grouping(grouping: Optional) = grouping(grouping.orElse(null)) - - fun grouping(grouping: JsonField) = apply { this.grouping = grouping } - - fun name(name: String) = name(JsonField.of(name)) - - fun name(name: JsonField) = apply { this.name = name } - - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun type(type: Type) = type(JsonField.of(type)) - - 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) - } - - fun build(): OtherSubLineItem = - OtherSubLineItem( - checkRequired("amount", amount), - checkRequired("grouping", grouping), - checkRequired("name", name), - checkRequired("quantity", quantity), - checkRequired("type", type), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Grouping - @JsonCreator - private constructor( - @JsonProperty("key") - @ExcludeMissing - private val key: JsonField = JsonMissing.of(), - @JsonProperty("value") - @ExcludeMissing - private val value: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun key(): String = key.getRequired("key") - - /** No value indicates the default group */ - fun value(): Optional = Optional.ofNullable(value.getNullable("value")) - - @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key - - /** No value indicates the default group */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Grouping = apply { - if (validated) { - return@apply - } - - key() - value() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Grouping]. */ - class Builder internal constructor() { - - private var key: JsonField? = null - private var value: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(grouping: Grouping) = apply { - key = grouping.key - value = grouping.value - additionalProperties = grouping.additionalProperties.toMutableMap() - } - - fun key(key: String) = key(JsonField.of(key)) - - fun key(key: JsonField) = apply { this.key = key } - - /** No value indicates the default group */ - fun value(value: String?) = value(JsonField.ofNullable(value)) - - /** No value indicates the default group */ - fun value(value: Optional) = value(value.orElse(null)) - - /** No value indicates the default group */ - fun value(value: JsonField) = apply { this.value = 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) - } - - fun build(): Grouping = - Grouping( - checkRequired("key", key), - checkRequired("value", value), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Grouping && key == other.key && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(key, value, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Grouping{key=$key, value=$value, additionalProperties=$additionalProperties}" - } - - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val NULL = of("'null'") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - NULL - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - NULL, - /** - * An enum member indicating that [Type] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - NULL -> Value.NULL - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - NULL -> Known.NULL - else -> throw OrbInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is OtherSubLineItem && amount == other.amount && grouping == other.grouping && name == other.name && quantity == other.quantity && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, grouping, name, quantity, type, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "OtherSubLineItem{amount=$amount, grouping=$grouping, name=$name, quantity=$quantity, type=$type, additionalProperties=$additionalProperties}" - } - } - - @NoAutoDetect - class TaxAmount - @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("tax_rate_description") - @ExcludeMissing - private val taxRateDescription: JsonField = JsonMissing.of(), - @JsonProperty("tax_rate_percentage") - @ExcludeMissing - private val taxRatePercentage: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The amount of additional tax incurred by this tax rate. */ - fun amount(): String = amount.getRequired("amount") - - /** The human-readable description of the applied tax rate. */ - fun taxRateDescription(): String = - taxRateDescription.getRequired("tax_rate_description") - - /** The tax rate percentage, out of 100. */ - fun taxRatePercentage(): Optional = - Optional.ofNullable(taxRatePercentage.getNullable("tax_rate_percentage")) - - /** The amount of additional tax incurred by this tax rate. */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** The human-readable description of the applied tax rate. */ - @JsonProperty("tax_rate_description") - @ExcludeMissing - fun _taxRateDescription(): JsonField = taxRateDescription - - /** The tax rate percentage, out of 100. */ - @JsonProperty("tax_rate_percentage") - @ExcludeMissing - fun _taxRatePercentage(): JsonField = taxRatePercentage - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TaxAmount = apply { - if (validated) { - return@apply - } - - amount() - taxRateDescription() - taxRatePercentage() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TaxAmount]. */ - class Builder internal constructor() { - - private var amount: JsonField? = null - private var taxRateDescription: JsonField? = null - private var taxRatePercentage: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(taxAmount: TaxAmount) = apply { - amount = taxAmount.amount - taxRateDescription = taxAmount.taxRateDescription - taxRatePercentage = taxAmount.taxRatePercentage - additionalProperties = taxAmount.additionalProperties.toMutableMap() - } - - /** The amount of additional tax incurred by this tax rate. */ - fun amount(amount: String) = amount(JsonField.of(amount)) - - /** The amount of additional tax incurred by this tax rate. */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** The human-readable description of the applied tax rate. */ - fun taxRateDescription(taxRateDescription: String) = - taxRateDescription(JsonField.of(taxRateDescription)) - - /** The human-readable description of the applied tax rate. */ - fun taxRateDescription(taxRateDescription: JsonField) = apply { - this.taxRateDescription = taxRateDescription - } - - /** The tax rate percentage, out of 100. */ - fun taxRatePercentage(taxRatePercentage: String?) = - taxRatePercentage(JsonField.ofNullable(taxRatePercentage)) - - /** The tax rate percentage, out of 100. */ - fun taxRatePercentage(taxRatePercentage: Optional) = - taxRatePercentage(taxRatePercentage.orElse(null)) - - /** The tax rate percentage, out of 100. */ - fun taxRatePercentage(taxRatePercentage: JsonField) = apply { - this.taxRatePercentage = taxRatePercentage - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): TaxAmount = - TaxAmount( - checkRequired("amount", amount), - checkRequired("taxRateDescription", taxRateDescription), - checkRequired("taxRatePercentage", taxRatePercentage), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TaxAmount && amount == other.amount && taxRateDescription == other.taxRateDescription && taxRatePercentage == other.taxRatePercentage && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, taxRateDescription, taxRatePercentage, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TaxAmount{amount=$amount, taxRateDescription=$taxRateDescription, taxRatePercentage=$taxRatePercentage, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is LineItem && id == other.id && adjustedSubtotal == other.adjustedSubtotal && adjustments == other.adjustments && amount == other.amount && creditsApplied == other.creditsApplied && discount == other.discount && endDate == other.endDate && filter == other.filter && grouping == other.grouping && maximum == other.maximum && maximumAmount == other.maximumAmount && minimum == other.minimum && minimumAmount == other.minimumAmount && name == other.name && partiallyInvoicedAmount == other.partiallyInvoicedAmount && price == other.price && quantity == other.quantity && startDate == other.startDate && subLineItems == other.subLineItems && subtotal == other.subtotal && taxAmounts == other.taxAmounts && usageCustomerIds == other.usageCustomerIds && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustedSubtotal, adjustments, amount, creditsApplied, discount, endDate, filter, grouping, maximum, maximumAmount, minimum, minimumAmount, name, partiallyInvoicedAmount, price, quantity, startDate, subLineItems, subtotal, taxAmounts, usageCustomerIds, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "LineItem{id=$id, adjustedSubtotal=$adjustedSubtotal, adjustments=$adjustments, amount=$amount, creditsApplied=$creditsApplied, discount=$discount, endDate=$endDate, filter=$filter, grouping=$grouping, maximum=$maximum, maximumAmount=$maximumAmount, minimum=$minimum, minimumAmount=$minimumAmount, name=$name, partiallyInvoicedAmount=$partiallyInvoicedAmount, price=$price, quantity=$quantity, startDate=$startDate, subLineItems=$subLineItems, subtotal=$subtotal, taxAmounts=$taxAmounts, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Maximum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, this - * can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Maximum amount applied */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, this - * can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Maximum amount applied */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Maximum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - maximumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Maximum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = maximum.maximumAmount - additionalProperties = maximum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Maximum = - Maximum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, - checkRequired("maximumAmount", maximumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Maximum && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, maximumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Maximum{appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Minimum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, this - * can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Minimum amount applied */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, this - * can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Minimum amount applied */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Minimum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - minimumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Minimum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var minimumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } - minimumAmount = minimum.minimumAmount - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Minimum = - Minimum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, - checkRequired("minimumAmount", minimumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Minimum && appliesToPriceIds == other.appliesToPriceIds && minimumAmount == other.minimumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, minimumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PaymentAttempt - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("payment_provider") - @ExcludeMissing - private val paymentProvider: JsonField = JsonMissing.of(), - @JsonProperty("payment_provider_id") - @ExcludeMissing - private val paymentProviderId: JsonField = JsonMissing.of(), - @JsonProperty("succeeded") - @ExcludeMissing - private val succeeded: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The ID of the payment attempt. */ - fun id(): String = id.getRequired("id") - - /** The amount of the payment attempt. */ - fun amount(): String = amount.getRequired("amount") - - /** The time at which the payment attempt was created. */ - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - /** The payment provider that attempted to collect the payment. */ - fun paymentProvider(): Optional = - Optional.ofNullable(paymentProvider.getNullable("payment_provider")) - - /** The ID of the payment attempt in the payment provider. */ - fun paymentProviderId(): Optional = - Optional.ofNullable(paymentProviderId.getNullable("payment_provider_id")) - - /** Whether the payment attempt succeeded. */ - fun succeeded(): Boolean = succeeded.getRequired("succeeded") - - /** The ID of the payment attempt. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** The amount of the payment attempt. */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** The time at which the payment attempt was created. */ - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - /** The payment provider that attempted to collect the payment. */ - @JsonProperty("payment_provider") - @ExcludeMissing - fun _paymentProvider(): JsonField = paymentProvider - - /** The ID of the payment attempt in the payment provider. */ - @JsonProperty("payment_provider_id") - @ExcludeMissing - fun _paymentProviderId(): JsonField = paymentProviderId - - /** Whether the payment attempt succeeded. */ - @JsonProperty("succeeded") @ExcludeMissing fun _succeeded(): JsonField = succeeded - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PaymentAttempt = apply { - if (validated) { - return@apply - } - - id() - amount() - createdAt() - paymentProvider() - paymentProviderId() - succeeded() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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 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 - succeeded = paymentAttempt.succeeded - additionalProperties = paymentAttempt.additionalProperties.toMutableMap() - } - - /** The ID of the payment attempt. */ - fun id(id: String) = id(JsonField.of(id)) - - /** The ID of the payment attempt. */ - fun id(id: JsonField) = apply { this.id = id } - - /** The amount of the payment attempt. */ - fun amount(amount: String) = amount(JsonField.of(amount)) - - /** The amount of the payment attempt. */ - 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)) - - /** The time at which the payment attempt was created. */ - 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)) - - /** The payment provider that attempted to collect the payment. */ - fun paymentProvider(paymentProvider: Optional) = - paymentProvider(paymentProvider.orElse(null)) - - /** The payment provider that attempted to collect the payment. */ - 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)) - - /** The ID of the payment attempt in the payment provider. */ - fun paymentProviderId(paymentProviderId: Optional) = - paymentProviderId(paymentProviderId.orElse(null)) - - /** The ID of the payment attempt in the payment provider. */ - fun paymentProviderId(paymentProviderId: JsonField) = apply { - this.paymentProviderId = paymentProviderId - } - - /** Whether the payment attempt succeeded. */ - fun succeeded(succeeded: Boolean) = succeeded(JsonField.of(succeeded)) - - /** Whether the payment attempt succeeded. */ - 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) - } - - fun build(): PaymentAttempt = - PaymentAttempt( - checkRequired("id", id), - checkRequired("amount", amount), - checkRequired("createdAt", createdAt), - checkRequired("paymentProvider", paymentProvider), - checkRequired("paymentProviderId", paymentProviderId), - checkRequired("succeeded", succeeded), - additionalProperties.toImmutable(), - ) - } - - /** 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PaymentProvider && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PaymentAttempt && id == other.id && amount == other.amount && createdAt == other.createdAt && paymentProvider == other.paymentProvider && paymentProviderId == other.paymentProviderId && succeeded == other.succeeded && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, amount, createdAt, paymentProvider, paymentProviderId, succeeded, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PaymentAttempt{id=$id, amount=$amount, createdAt=$createdAt, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, succeeded=$succeeded, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class ShippingAddress - @JsonCreator - private constructor( - @JsonProperty("city") - @ExcludeMissing - private val city: JsonField = JsonMissing.of(), - @JsonProperty("country") - @ExcludeMissing - private val country: JsonField = JsonMissing.of(), - @JsonProperty("line1") - @ExcludeMissing - private val line1: JsonField = JsonMissing.of(), - @JsonProperty("line2") - @ExcludeMissing - private val line2: JsonField = JsonMissing.of(), - @JsonProperty("postal_code") - @ExcludeMissing - private val postalCode: JsonField = JsonMissing.of(), - @JsonProperty("state") - @ExcludeMissing - private val state: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun city(): Optional = Optional.ofNullable(city.getNullable("city")) - - fun country(): Optional = Optional.ofNullable(country.getNullable("country")) - - fun line1(): Optional = Optional.ofNullable(line1.getNullable("line1")) - - fun line2(): Optional = Optional.ofNullable(line2.getNullable("line2")) - - fun postalCode(): Optional = - Optional.ofNullable(postalCode.getNullable("postal_code")) - - fun state(): Optional = Optional.ofNullable(state.getNullable("state")) - - @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city - - @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country - - @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField = line1 - - @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 - - @JsonProperty("postal_code") - @ExcludeMissing - fun _postalCode(): JsonField = postalCode - - @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): ShippingAddress = apply { - if (validated) { - return@apply - } - - city() - country() - line1() - line2() - postalCode() - state() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ShippingAddress]. */ - class Builder internal constructor() { - - private var city: JsonField? = null - private var country: JsonField? = null - private var line1: JsonField? = null - private var line2: JsonField? = null - private var postalCode: JsonField? = null - private var state: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(shippingAddress: ShippingAddress) = apply { - city = shippingAddress.city - country = shippingAddress.country - line1 = shippingAddress.line1 - line2 = shippingAddress.line2 - postalCode = shippingAddress.postalCode - state = shippingAddress.state - additionalProperties = shippingAddress.additionalProperties.toMutableMap() - } - - fun city(city: String?) = city(JsonField.ofNullable(city)) - - fun city(city: Optional) = city(city.orElse(null)) - - fun city(city: JsonField) = apply { this.city = city } - - fun country(country: String?) = country(JsonField.ofNullable(country)) - - fun country(country: Optional) = country(country.orElse(null)) - - fun country(country: JsonField) = apply { this.country = country } - - fun line1(line1: String?) = line1(JsonField.ofNullable(line1)) - - fun line1(line1: Optional) = line1(line1.orElse(null)) - - fun line1(line1: JsonField) = apply { this.line1 = line1 } - - fun line2(line2: String?) = line2(JsonField.ofNullable(line2)) - - fun line2(line2: Optional) = line2(line2.orElse(null)) - - fun line2(line2: JsonField) = apply { this.line2 = line2 } - - fun postalCode(postalCode: String?) = postalCode(JsonField.ofNullable(postalCode)) - - fun postalCode(postalCode: Optional) = postalCode(postalCode.orElse(null)) - - fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode } - - fun state(state: String?) = state(JsonField.ofNullable(state)) - - fun state(state: Optional) = state(state.orElse(null)) - - fun state(state: JsonField) = apply { this.state = state } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): ShippingAddress = - ShippingAddress( - checkRequired("city", city), - checkRequired("country", country), - checkRequired("line1", line1), - checkRequired("line2", line2), - checkRequired("postalCode", postalCode), - checkRequired("state", state), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ShippingAddress && city == other.city && country == other.country && line1 == other.line1 && line2 == other.line2 && postalCode == other.postalCode && state == other.state && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(city, country, line1, line2, postalCode, state, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ShippingAddress{city=$city, country=$country, line1=$line1, line2=$line2, postalCode=$postalCode, state=$state, 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 VOID = of("void") @JvmField val DRAFT = of("draft") @@ -11428,97 +2162,6 @@ private constructor( override fun toString() = value.toString() } - @NoAutoDetect - class Subscription - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Subscription = apply { - if (validated) { - return@apply - } - - id() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Subscription]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(subscription: Subscription) = apply { - id = subscription.id - additionalProperties = subscription.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - 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) - } - - fun build(): Subscription = - Subscription(checkRequired("id", id), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Subscription && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Subscription{id=$id, 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/InvoiceIssueParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueParams.kt index 1339a02a5..5b55d363f 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 @@ -121,6 +121,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Body]. */ @JvmStatic fun builder() = Builder() } @@ -200,6 +201,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [InvoiceIssueParams]. + * + * The following fields are required: + * ```java + * .invoiceId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLevelDiscountModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLevelDiscountModel.kt new file mode 100644 index 000000000..9a71795f3 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLevelDiscountModel.kt @@ -0,0 +1,198 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.BaseDeserializer +import com.withorb.api.core.BaseSerializer +import com.withorb.api.core.JsonValue +import com.withorb.api.core.getOrThrow +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +@JsonDeserialize(using = InvoiceLevelDiscountModel.Deserializer::class) +@JsonSerialize(using = InvoiceLevelDiscountModel.Serializer::class) +class InvoiceLevelDiscountModel +private constructor( + private val percentageDiscount: PercentageDiscount? = null, + private val amountDiscount: AmountDiscount? = null, + private val trialDiscount: TrialDiscount? = null, + private val _json: JsonValue? = null, +) { + + fun percentageDiscount(): Optional = Optional.ofNullable(percentageDiscount) + + fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) + + fun trialDiscount(): Optional = Optional.ofNullable(trialDiscount) + + fun isPercentageDiscount(): Boolean = percentageDiscount != null + + fun isAmountDiscount(): Boolean = amountDiscount != null + + fun isTrialDiscount(): Boolean = trialDiscount != null + + fun asPercentageDiscount(): PercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") + + fun asAmountDiscount(): AmountDiscount = amountDiscount.getOrThrow("amountDiscount") + + fun asTrialDiscount(): TrialDiscount = trialDiscount.getOrThrow("trialDiscount") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + percentageDiscount != null -> visitor.visitPercentageDiscount(percentageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) + trialDiscount != null -> visitor.visitTrialDiscount(trialDiscount) + else -> visitor.unknown(_json) + } + } + + private var validated: Boolean = false + + fun validate(): InvoiceLevelDiscountModel = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitPercentageDiscount(percentageDiscount: PercentageDiscount) { + percentageDiscount.validate() + } + + override fun visitAmountDiscount(amountDiscount: AmountDiscount) { + amountDiscount.validate() + } + + override fun visitTrialDiscount(trialDiscount: TrialDiscount) { + trialDiscount.validate() + } + } + ) + validated = true + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InvoiceLevelDiscountModel && percentageDiscount == other.percentageDiscount && amountDiscount == other.amountDiscount && trialDiscount == other.trialDiscount /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(percentageDiscount, amountDiscount, trialDiscount) /* spotless:on */ + + override fun toString(): String = + when { + percentageDiscount != null -> + "InvoiceLevelDiscountModel{percentageDiscount=$percentageDiscount}" + amountDiscount != null -> "InvoiceLevelDiscountModel{amountDiscount=$amountDiscount}" + trialDiscount != null -> "InvoiceLevelDiscountModel{trialDiscount=$trialDiscount}" + _json != null -> "InvoiceLevelDiscountModel{_unknown=$_json}" + else -> throw IllegalStateException("Invalid InvoiceLevelDiscountModel") + } + + companion object { + + @JvmStatic + fun ofPercentageDiscount(percentageDiscount: PercentageDiscount) = + InvoiceLevelDiscountModel(percentageDiscount = percentageDiscount) + + @JvmStatic + fun ofAmountDiscount(amountDiscount: AmountDiscount) = + InvoiceLevelDiscountModel(amountDiscount = amountDiscount) + + @JvmStatic + fun ofTrialDiscount(trialDiscount: TrialDiscount) = + InvoiceLevelDiscountModel(trialDiscount = trialDiscount) + } + + /** + * An interface that defines how to map each variant of [InvoiceLevelDiscountModel] to a value + * of type [T]. + */ + interface Visitor { + + fun visitPercentageDiscount(percentageDiscount: PercentageDiscount): T + + fun visitAmountDiscount(amountDiscount: AmountDiscount): T + + fun visitTrialDiscount(trialDiscount: TrialDiscount): T + + /** + * Maps an unknown variant of [InvoiceLevelDiscountModel] to a value of type [T]. + * + * An instance of [InvoiceLevelDiscountModel] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the SDK is + * on an older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown InvoiceLevelDiscountModel: $json") + } + } + + internal class Deserializer : + BaseDeserializer(InvoiceLevelDiscountModel::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): InvoiceLevelDiscountModel { + val json = JsonValue.fromJsonNode(node) + val discountType = + json.asObject().getOrNull()?.get("discount_type")?.asString()?.getOrNull() + + when (discountType) { + "percentage" -> { + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return InvoiceLevelDiscountModel(percentageDiscount = it, _json = json) + } + } + "amount" -> { + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return InvoiceLevelDiscountModel(amountDiscount = it, _json = json) + } + } + "trial" -> { + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return InvoiceLevelDiscountModel(trialDiscount = it, _json = json) + } + } + } + + return InvoiceLevelDiscountModel(_json = json) + } + } + + internal class Serializer : + BaseSerializer(InvoiceLevelDiscountModel::class) { + + override fun serialize( + value: InvoiceLevelDiscountModel, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.percentageDiscount != null -> generator.writeObject(value.percentageDiscount) + value.amountDiscount != null -> generator.writeObject(value.amountDiscount) + value.trialDiscount != null -> generator.writeObject(value.trialDiscount) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid InvoiceLevelDiscountModel") + } + } + } +} 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 eec71cd23..81afc3551 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 @@ -179,6 +179,19 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .amount() + * .endDate() + * .invoiceId() + * .name() + * .quantity() + * .startDate() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -299,6 +312,19 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [InvoiceLineItemCreateParams]. + * + * The following fields are required: + * ```java + * .amount() + * .endDate() + * .invoiceId() + * .name() + * .quantity() + * .startDate() + * ``` + */ @JvmStatic fun builder() = Builder() } 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/InvoiceLineItemModel.kt similarity index 80% rename from orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt rename to orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemModel.kt index de121ed02..bd0a1bed5 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/InvoiceLineItemModel.kt @@ -21,6 +21,7 @@ import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.getOrThrow import com.withorb.api.core.immutableEmptyMap @@ -32,7 +33,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull @NoAutoDetect -class InvoiceLineItemCreateResponse +class InvoiceLineItemModel @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @@ -62,13 +63,13 @@ private constructor( private val grouping: JsonField = JsonMissing.of(), @JsonProperty("maximum") @ExcludeMissing - private val maximum: JsonField = JsonMissing.of(), + private val maximum: JsonField = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing private val maximumAmount: JsonField = JsonMissing.of(), @JsonProperty("minimum") @ExcludeMissing - private val minimum: JsonField = JsonMissing.of(), + private val minimum: JsonField = JsonMissing.of(), @JsonProperty("minimum_amount") @ExcludeMissing private val minimumAmount: JsonField = JsonMissing.of(), @@ -76,7 +77,9 @@ private constructor( @JsonProperty("partially_invoiced_amount") @ExcludeMissing private val partiallyInvoicedAmount: JsonField = JsonMissing.of(), - @JsonProperty("price") @ExcludeMissing private val price: JsonField = JsonMissing.of(), + @JsonProperty("price") + @ExcludeMissing + private val price: JsonField = JsonMissing.of(), @JsonProperty("quantity") @ExcludeMissing private val quantity: JsonField = JsonMissing.of(), @@ -91,7 +94,7 @@ private constructor( private val subtotal: JsonField = JsonMissing.of(), @JsonProperty("tax_amounts") @ExcludeMissing - private val taxAmounts: JsonField> = JsonMissing.of(), + private val taxAmounts: JsonField> = JsonMissing.of(), @JsonProperty("usage_customer_ids") @ExcludeMissing private val usageCustomerIds: JsonField> = JsonMissing.of(), @@ -136,7 +139,7 @@ private constructor( /** This field is deprecated in favor of `adjustments`. */ @Deprecated("deprecated") - fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) /** This field is deprecated in favor of `adjustments`. */ @Deprecated("deprecated") @@ -145,7 +148,7 @@ private constructor( /** This field is deprecated in favor of `adjustments`. */ @Deprecated("deprecated") - fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) /** This field is deprecated in favor of `adjustments`. */ @Deprecated("deprecated") @@ -171,7 +174,7 @@ private constructor( * For more on the types of prices, see * [the core concepts documentation](/core-concepts#plan-and-price) */ - fun price(): Optional = Optional.ofNullable(price.getNullable("price")) + fun price(): Optional = Optional.ofNullable(price.getNullable("price")) /** Either the fixed fee quantity or the usage during the service period. */ fun quantity(): Double = quantity.getRequired("quantity") @@ -191,7 +194,7 @@ private constructor( * An array of tax rates and their incurred tax amounts. Empty if no tax integration is * configured. */ - fun taxAmounts(): List = taxAmounts.getRequired("tax_amounts") + fun taxAmounts(): List = taxAmounts.getRequired("tax_amounts") /** A list of customer ids that were used to calculate the usage for this line item. */ fun usageCustomerIds(): Optional> = @@ -243,7 +246,7 @@ private constructor( @Deprecated("deprecated") @JsonProperty("maximum") @ExcludeMissing - fun _maximum(): JsonField = maximum + fun _maximum(): JsonField = maximum /** This field is deprecated in favor of `adjustments`. */ @Deprecated("deprecated") @@ -255,7 +258,7 @@ private constructor( @Deprecated("deprecated") @JsonProperty("minimum") @ExcludeMissing - fun _minimum(): JsonField = minimum + fun _minimum(): JsonField = minimum /** This field is deprecated in favor of `adjustments`. */ @Deprecated("deprecated") @@ -283,7 +286,7 @@ private constructor( * For more on the types of prices, see * [the core concepts documentation](/core-concepts#plan-and-price) */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price /** Either the fixed fee quantity or the usage during the service period. */ @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity @@ -309,7 +312,7 @@ private constructor( */ @JsonProperty("tax_amounts") @ExcludeMissing - fun _taxAmounts(): JsonField> = taxAmounts + fun _taxAmounts(): JsonField> = taxAmounts /** A list of customer ids that were used to calculate the usage for this line item. */ @JsonProperty("usage_customer_ids") @@ -322,7 +325,7 @@ private constructor( private var validated: Boolean = false - fun validate(): InvoiceLineItemCreateResponse = apply { + fun validate(): InvoiceLineItemModel = apply { if (validated) { return@apply } @@ -356,10 +359,39 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [InvoiceLineItemModel]. + * + * The following fields are required: + * ```java + * .id() + * .adjustedSubtotal() + * .adjustments() + * .amount() + * .creditsApplied() + * .discount() + * .endDate() + * .filter() + * .grouping() + * .maximum() + * .maximumAmount() + * .minimum() + * .minimumAmount() + * .name() + * .partiallyInvoicedAmount() + * .price() + * .quantity() + * .startDate() + * .subLineItems() + * .subtotal() + * .taxAmounts() + * .usageCustomerIds() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [InvoiceLineItemCreateResponse]. */ + /** A builder for [InvoiceLineItemModel]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -371,47 +403,46 @@ private constructor( private var endDate: JsonField? = null private var filter: JsonField? = null private var grouping: JsonField? = null - private var maximum: JsonField? = null + private var maximum: JsonField? = null private var maximumAmount: JsonField? = null - private var minimum: JsonField? = null + private var minimum: JsonField? = null private var minimumAmount: JsonField? = null private var name: JsonField? = null private var partiallyInvoicedAmount: JsonField? = null - private var price: JsonField? = null + private var price: JsonField? = null private var quantity: JsonField? = null private var startDate: JsonField? = null private var subLineItems: JsonField>? = null private var subtotal: JsonField? = null - private var taxAmounts: JsonField>? = null + private var taxAmounts: JsonField>? = null private var usageCustomerIds: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(invoiceLineItemCreateResponse: InvoiceLineItemCreateResponse) = apply { - id = invoiceLineItemCreateResponse.id - adjustedSubtotal = invoiceLineItemCreateResponse.adjustedSubtotal - adjustments = invoiceLineItemCreateResponse.adjustments.map { it.toMutableList() } - amount = invoiceLineItemCreateResponse.amount - creditsApplied = invoiceLineItemCreateResponse.creditsApplied - discount = invoiceLineItemCreateResponse.discount - endDate = invoiceLineItemCreateResponse.endDate - filter = invoiceLineItemCreateResponse.filter - grouping = invoiceLineItemCreateResponse.grouping - maximum = invoiceLineItemCreateResponse.maximum - maximumAmount = invoiceLineItemCreateResponse.maximumAmount - minimum = invoiceLineItemCreateResponse.minimum - minimumAmount = invoiceLineItemCreateResponse.minimumAmount - name = invoiceLineItemCreateResponse.name - partiallyInvoicedAmount = invoiceLineItemCreateResponse.partiallyInvoicedAmount - price = invoiceLineItemCreateResponse.price - quantity = invoiceLineItemCreateResponse.quantity - startDate = invoiceLineItemCreateResponse.startDate - subLineItems = invoiceLineItemCreateResponse.subLineItems.map { it.toMutableList() } - subtotal = invoiceLineItemCreateResponse.subtotal - taxAmounts = invoiceLineItemCreateResponse.taxAmounts.map { it.toMutableList() } - usageCustomerIds = - invoiceLineItemCreateResponse.usageCustomerIds.map { it.toMutableList() } - additionalProperties = invoiceLineItemCreateResponse.additionalProperties.toMutableMap() + internal fun from(invoiceLineItemModel: InvoiceLineItemModel) = apply { + id = invoiceLineItemModel.id + adjustedSubtotal = invoiceLineItemModel.adjustedSubtotal + adjustments = invoiceLineItemModel.adjustments.map { it.toMutableList() } + amount = invoiceLineItemModel.amount + creditsApplied = invoiceLineItemModel.creditsApplied + discount = invoiceLineItemModel.discount + endDate = invoiceLineItemModel.endDate + filter = invoiceLineItemModel.filter + grouping = invoiceLineItemModel.grouping + maximum = invoiceLineItemModel.maximum + maximumAmount = invoiceLineItemModel.maximumAmount + minimum = invoiceLineItemModel.minimum + minimumAmount = invoiceLineItemModel.minimumAmount + name = invoiceLineItemModel.name + partiallyInvoicedAmount = invoiceLineItemModel.partiallyInvoicedAmount + price = invoiceLineItemModel.price + quantity = invoiceLineItemModel.quantity + startDate = invoiceLineItemModel.startDate + subLineItems = invoiceLineItemModel.subLineItems.map { it.toMutableList() } + subtotal = invoiceLineItemModel.subtotal + taxAmounts = invoiceLineItemModel.taxAmounts.map { it.toMutableList() } + usageCustomerIds = invoiceLineItemModel.usageCustomerIds.map { it.toMutableList() } + additionalProperties = invoiceLineItemModel.additionalProperties.toMutableMap() } /** A unique ID for this line item. */ @@ -446,14 +477,8 @@ private constructor( /** All adjustments (ie. maximums, minimums, discounts) applied to the line item. */ fun addAdjustment(adjustment: Adjustment) = apply { adjustments = - (adjustments ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(adjustment) + (adjustments ?: JsonField.of(mutableListOf())).also { + checkKnown("adjustments", it).add(adjustment) } } @@ -558,15 +583,15 @@ private constructor( /** This field is deprecated in favor of `adjustments`. */ @Deprecated("deprecated") - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) /** This field is deprecated in favor of `adjustments`. */ @Deprecated("deprecated") - fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) /** This field is deprecated in favor of `adjustments`. */ @Deprecated("deprecated") - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } /** This field is deprecated in favor of `adjustments`. */ @Deprecated("deprecated") @@ -586,15 +611,15 @@ private constructor( /** This field is deprecated in favor of `adjustments`. */ @Deprecated("deprecated") - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) /** This field is deprecated in favor of `adjustments`. */ @Deprecated("deprecated") - fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) /** This field is deprecated in favor of `adjustments`. */ @Deprecated("deprecated") - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } /** This field is deprecated in favor of `adjustments`. */ @Deprecated("deprecated") @@ -639,7 +664,7 @@ private constructor( * For more on the types of prices, see * [the core concepts documentation](/core-concepts#plan-and-price) */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) + fun price(price: PriceModel?) = price(JsonField.ofNullable(price)) /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -653,7 +678,7 @@ private constructor( * For more on the types of prices, see * [the core concepts documentation](/core-concepts#plan-and-price) */ - fun price(price: Optional) = price(price.orElse(null)) + fun price(price: Optional) = price(price.orElse(null)) /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -667,7 +692,7 @@ private constructor( * For more on the types of prices, see * [the core concepts documentation](/core-concepts#plan-and-price) */ - fun price(price: JsonField) = apply { this.price = price } + fun price(price: JsonField) = apply { this.price = price } /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -681,7 +706,7 @@ private constructor( * For more on the types of prices, see * [the core concepts documentation](/core-concepts#plan-and-price) */ - fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) + fun price(unitPrice: PriceModel.UnitPrice) = price(PriceModel.ofUnitPrice(unitPrice)) /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -695,7 +720,8 @@ private constructor( * For more on the types of prices, see * [the core concepts documentation](/core-concepts#plan-and-price) */ - fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) + fun price(packagePrice: PriceModel.PackagePrice) = + price(PriceModel.ofPackagePrice(packagePrice)) /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -709,7 +735,8 @@ private constructor( * For more on the types of prices, see * [the core concepts documentation](/core-concepts#plan-and-price) */ - fun price(matrix: Price.MatrixPrice) = price(Price.ofMatrix(matrix)) + fun price(matrixPrice: PriceModel.MatrixPrice) = + price(PriceModel.ofMatrixPrice(matrixPrice)) /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -723,7 +750,8 @@ private constructor( * For more on the types of prices, see * [the core concepts documentation](/core-concepts#plan-and-price) */ - fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) + fun price(tieredPrice: PriceModel.TieredPrice) = + price(PriceModel.ofTieredPrice(tieredPrice)) /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -737,7 +765,8 @@ private constructor( * For more on the types of prices, see * [the core concepts documentation](/core-concepts#plan-and-price) */ - fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) + fun price(tieredBpsPrice: PriceModel.TieredBpsPrice) = + price(PriceModel.ofTieredBpsPrice(tieredBpsPrice)) /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -751,7 +780,7 @@ private constructor( * For more on the types of prices, see * [the core concepts documentation](/core-concepts#plan-and-price) */ - fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) + fun price(bpsPrice: PriceModel.BpsPrice) = price(PriceModel.ofBpsPrice(bpsPrice)) /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -765,7 +794,8 @@ private constructor( * For more on the types of prices, see * [the core concepts documentation](/core-concepts#plan-and-price) */ - fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) + fun price(bulkBpsPrice: PriceModel.BulkBpsPrice) = + price(PriceModel.ofBulkBpsPrice(bulkBpsPrice)) /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -779,7 +809,7 @@ private constructor( * For more on the types of prices, see * [the core concepts documentation](/core-concepts#plan-and-price) */ - fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) + fun price(bulkPrice: PriceModel.BulkPrice) = price(PriceModel.ofBulkPrice(bulkPrice)) /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -793,8 +823,8 @@ private constructor( * For more on the types of prices, see * [the core concepts documentation](/core-concepts#plan-and-price) */ - fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + fun price(thresholdTotalAmountPrice: PriceModel.ThresholdTotalAmountPrice) = + price(PriceModel.ofThresholdTotalAmountPrice(thresholdTotalAmountPrice)) /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -808,8 +838,8 @@ private constructor( * For more on the types of prices, see * [the core concepts documentation](/core-concepts#plan-and-price) */ - fun price(tieredPackage: Price.TieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) + fun price(tieredPackagePrice: PriceModel.TieredPackagePrice) = + price(PriceModel.ofTieredPackagePrice(tieredPackagePrice)) /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -823,8 +853,8 @@ private constructor( * For more on the types of prices, see * [the core concepts documentation](/core-concepts#plan-and-price) */ - fun price(groupedTiered: Price.GroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) + fun price(groupedTieredPrice: PriceModel.GroupedTieredPrice) = + price(PriceModel.ofGroupedTieredPrice(groupedTieredPrice)) /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -838,8 +868,8 @@ private constructor( * For more on the types of prices, see * [the core concepts documentation](/core-concepts#plan-and-price) */ - fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) + fun price(tieredWithMinimumPrice: PriceModel.TieredWithMinimumPrice) = + price(PriceModel.ofTieredWithMinimumPrice(tieredWithMinimumPrice)) /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -853,8 +883,8 @@ private constructor( * For more on the types of prices, see * [the core concepts documentation](/core-concepts#plan-and-price) */ - fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + fun price(tieredPackageWithMinimumPrice: PriceModel.TieredPackageWithMinimumPrice) = + price(PriceModel.ofTieredPackageWithMinimumPrice(tieredPackageWithMinimumPrice)) /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -868,8 +898,8 @@ private constructor( * For more on the types of prices, see * [the core concepts documentation](/core-concepts#plan-and-price) */ - fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) + fun price(packageWithAllocationPrice: PriceModel.PackageWithAllocationPrice) = + price(PriceModel.ofPackageWithAllocationPrice(packageWithAllocationPrice)) /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -883,8 +913,8 @@ private constructor( * For more on the types of prices, see * [the core concepts documentation](/core-concepts#plan-and-price) */ - fun price(unitWithPercent: Price.UnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) + fun price(unitWithPercentPrice: PriceModel.UnitWithPercentPrice) = + price(PriceModel.ofUnitWithPercentPrice(unitWithPercentPrice)) /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -898,8 +928,8 @@ private constructor( * For more on the types of prices, see * [the core concepts documentation](/core-concepts#plan-and-price) */ - fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) + fun price(matrixWithAllocationPrice: PriceModel.MatrixWithAllocationPrice) = + price(PriceModel.ofMatrixWithAllocationPrice(matrixWithAllocationPrice)) /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -913,8 +943,8 @@ private constructor( * For more on the types of prices, see * [the core concepts documentation](/core-concepts#plan-and-price) */ - fun price(tieredWithProration: Price.TieredWithProrationPrice) = - price(Price.ofTieredWithProration(tieredWithProration)) + fun price(tieredWithProrationPrice: PriceModel.TieredWithProrationPrice) = + price(PriceModel.ofTieredWithProrationPrice(tieredWithProrationPrice)) /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -928,8 +958,8 @@ private constructor( * For more on the types of prices, see * [the core concepts documentation](/core-concepts#plan-and-price) */ - fun price(unitWithProration: Price.UnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) + fun price(unitWithProrationPrice: PriceModel.UnitWithProrationPrice) = + price(PriceModel.ofUnitWithProrationPrice(unitWithProrationPrice)) /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -943,8 +973,8 @@ private constructor( * For more on the types of prices, see * [the core concepts documentation](/core-concepts#plan-and-price) */ - fun price(groupedAllocation: Price.GroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) + fun price(groupedAllocationPrice: PriceModel.GroupedAllocationPrice) = + price(PriceModel.ofGroupedAllocationPrice(groupedAllocationPrice)) /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -958,8 +988,8 @@ private constructor( * For more on the types of prices, see * [the core concepts documentation](/core-concepts#plan-and-price) */ - fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + fun price(groupedWithProratedMinimumPrice: PriceModel.GroupedWithProratedMinimumPrice) = + price(PriceModel.ofGroupedWithProratedMinimumPrice(groupedWithProratedMinimumPrice)) /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -973,8 +1003,8 @@ private constructor( * For more on the types of prices, see * [the core concepts documentation](/core-concepts#plan-and-price) */ - fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + fun price(groupedWithMeteredMinimumPrice: PriceModel.GroupedWithMeteredMinimumPrice) = + price(PriceModel.ofGroupedWithMeteredMinimumPrice(groupedWithMeteredMinimumPrice)) /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -988,8 +1018,8 @@ private constructor( * For more on the types of prices, see * [the core concepts documentation](/core-concepts#plan-and-price) */ - fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + fun price(matrixWithDisplayNamePrice: PriceModel.MatrixWithDisplayNamePrice) = + price(PriceModel.ofMatrixWithDisplayNamePrice(matrixWithDisplayNamePrice)) /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -1003,8 +1033,8 @@ private constructor( * For more on the types of prices, see * [the core concepts documentation](/core-concepts#plan-and-price) */ - fun price(bulkWithProration: Price.BulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) + fun price(bulkWithProrationPrice: PriceModel.BulkWithProrationPrice) = + price(PriceModel.ofBulkWithProrationPrice(bulkWithProrationPrice)) /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -1018,8 +1048,8 @@ private constructor( * For more on the types of prices, see * [the core concepts documentation](/core-concepts#plan-and-price) */ - fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) + fun price(groupedTieredPackagePrice: PriceModel.GroupedTieredPackagePrice) = + price(PriceModel.ofGroupedTieredPackagePrice(groupedTieredPackagePrice)) /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -1033,8 +1063,8 @@ private constructor( * For more on the types of prices, see * [the core concepts documentation](/core-concepts#plan-and-price) */ - fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + fun price(maxGroupTieredPackagePrice: PriceModel.MaxGroupTieredPackagePrice) = + price(PriceModel.ofMaxGroupTieredPackagePrice(maxGroupTieredPackagePrice)) /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -1048,8 +1078,12 @@ private constructor( * For more on the types of prices, see * [the core concepts documentation](/core-concepts#plan-and-price) */ - fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = - price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + fun price( + scalableMatrixWithUnitPricingPrice: PriceModel.ScalableMatrixWithUnitPricingPrice + ) = + price( + PriceModel.ofScalableMatrixWithUnitPricingPrice(scalableMatrixWithUnitPricingPrice) + ) /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -1063,8 +1097,14 @@ private constructor( * For more on the types of prices, see * [the core concepts documentation](/core-concepts#plan-and-price) */ - fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice) = - price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + fun price( + scalableMatrixWithTieredPricingPrice: PriceModel.ScalableMatrixWithTieredPricingPrice + ) = + price( + PriceModel.ofScalableMatrixWithTieredPricingPrice( + scalableMatrixWithTieredPricingPrice + ) + ) /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -1078,8 +1118,8 @@ private constructor( * For more on the types of prices, see * [the core concepts documentation](/core-concepts#plan-and-price) */ - fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + fun price(cumulativeGroupedBulkPrice: PriceModel.CumulativeGroupedBulkPrice) = + price(PriceModel.ofCumulativeGroupedBulkPrice(cumulativeGroupedBulkPrice)) /** Either the fixed fee quantity or the usage during the service period. */ fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) @@ -1113,14 +1153,8 @@ private constructor( */ fun addSubLineItem(subLineItem: SubLineItem) = apply { subLineItems = - (subLineItems ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(subLineItem) + (subLineItems ?: JsonField.of(mutableListOf())).also { + checkKnown("subLineItems", it).add(subLineItem) } } @@ -1155,13 +1189,13 @@ private constructor( * An array of tax rates and their incurred tax amounts. Empty if no tax integration is * configured. */ - fun taxAmounts(taxAmounts: List) = taxAmounts(JsonField.of(taxAmounts)) + fun taxAmounts(taxAmounts: List) = taxAmounts(JsonField.of(taxAmounts)) /** * An array of tax rates and their incurred tax amounts. Empty if no tax integration is * configured. */ - fun taxAmounts(taxAmounts: JsonField>) = apply { + fun taxAmounts(taxAmounts: JsonField>) = apply { this.taxAmounts = taxAmounts.map { it.toMutableList() } } @@ -1169,16 +1203,10 @@ private constructor( * An array of tax rates and their incurred tax amounts. Empty if no tax integration is * configured. */ - fun addTaxAmount(taxAmount: TaxAmount) = apply { + fun addTaxAmount(taxAmount: TaxAmountModel) = apply { taxAmounts = - (taxAmounts ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(taxAmount) + (taxAmounts ?: JsonField.of(mutableListOf())).also { + checkKnown("taxAmounts", it).add(taxAmount) } } @@ -1198,14 +1226,8 @@ private constructor( /** A list of customer ids that were used to calculate the usage for this line item. */ fun addUsageCustomerId(usageCustomerId: String) = apply { usageCustomerIds = - (usageCustomerIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(usageCustomerId) + (usageCustomerIds ?: JsonField.of(mutableListOf())).also { + checkKnown("usageCustomerIds", it).add(usageCustomerId) } } @@ -1228,8 +1250,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): InvoiceLineItemCreateResponse = - InvoiceLineItemCreateResponse( + fun build(): InvoiceLineItemModel = + InvoiceLineItemModel( checkRequired("id", id), checkRequired("adjustedSubtotal", adjustedSubtotal), checkRequired("adjustments", adjustments).map { it.toImmutable() }, @@ -1639,6 +1661,21 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [MonetaryUsageDiscountAdjustment]. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .amount() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .reason() + * .usageDiscount() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1699,14 +1736,8 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun addAppliesToPriceId(appliesToPriceId: String) = apply { appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) } } @@ -2018,6 +2049,21 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [MonetaryAmountDiscountAdjustment]. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .amount() + * .amountDiscount() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .reason() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -2095,14 +2141,8 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun addAppliesToPriceId(appliesToPriceId: String) = apply { appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) } } @@ -2399,6 +2439,21 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [MonetaryPercentageDiscountAdjustment]. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .amount() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .percentageDiscount() + * .reason() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -2461,14 +2516,8 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun addAppliesToPriceId(appliesToPriceId: String) = apply { appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) } } @@ -2790,6 +2839,22 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [MonetaryMinimumAdjustment]. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .amount() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .itemId() + * .minimumAmount() + * .reason() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -2850,14 +2915,8 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun addAppliesToPriceId(appliesToPriceId: String) = apply { appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) } } @@ -3176,6 +3235,21 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [MonetaryMaximumAdjustment]. + * + * The following fields are required: + * ```java + * .id() + * .adjustmentType() + * .amount() + * .appliesToPriceIds() + * .isInvoiceLevel() + * .maximumAmount() + * .reason() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -3234,14 +3308,8 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun addAppliesToPriceId(appliesToPriceId: String) = apply { appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) } } @@ -3441,328 +3509,6 @@ private constructor( } } - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - @NoAutoDetect - class Maximum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, this - * can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Maximum amount applied */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, this - * can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Maximum amount applied */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Maximum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - maximumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Maximum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = maximum.maximumAmount - additionalProperties = maximum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Maximum = - Maximum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, - checkRequired("maximumAmount", maximumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Maximum && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, maximumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Maximum{appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, additionalProperties=$additionalProperties}" - } - - /** This field is deprecated in favor of `adjustments`. */ - @Deprecated("deprecated") - @NoAutoDetect - class Minimum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, this - * can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Minimum amount applied */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, this - * can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Minimum amount applied */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Minimum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - minimumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Minimum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var minimumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } - minimumAmount = minimum.minimumAmount - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Minimum = - Minimum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, - checkRequired("minimumAmount", minimumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Minimum && appliesToPriceIds == other.appliesToPriceIds && minimumAmount == other.minimumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, minimumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" - } - @JsonDeserialize(using = SubLineItem.Deserializer::class) @JsonSerialize(using = SubLineItem.Serializer::class) class SubLineItem @@ -3939,7 +3685,7 @@ private constructor( private val amount: JsonField = JsonMissing.of(), @JsonProperty("grouping") @ExcludeMissing - private val grouping: JsonField = JsonMissing.of(), + private val grouping: JsonField = JsonMissing.of(), @JsonProperty("matrix_config") @ExcludeMissing private val matrixConfig: JsonField = JsonMissing.of(), @@ -3959,7 +3705,7 @@ private constructor( /** The total amount for this sub line item. */ fun amount(): String = amount.getRequired("amount") - fun grouping(): Optional = + fun grouping(): Optional = Optional.ofNullable(grouping.getNullable("grouping")) fun matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_config") @@ -3975,7 +3721,7 @@ private constructor( @JsonProperty("grouping") @ExcludeMissing - fun _grouping(): JsonField = grouping + fun _grouping(): JsonField = grouping @JsonProperty("matrix_config") @ExcludeMissing @@ -4011,6 +3757,19 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [MatrixSubLineItem]. + * + * The following fields are required: + * ```java + * .amount() + * .grouping() + * .matrixConfig() + * .name() + * .quantity() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -4018,7 +3777,7 @@ private constructor( class Builder internal constructor() { private var amount: JsonField? = null - private var grouping: JsonField? = null + private var grouping: JsonField? = null private var matrixConfig: JsonField? = null private var name: JsonField? = null private var quantity: JsonField? = null @@ -4042,11 +3801,15 @@ private constructor( /** The total amount for this sub line item. */ fun amount(amount: JsonField) = apply { this.amount = amount } - fun grouping(grouping: Grouping?) = grouping(JsonField.ofNullable(grouping)) + fun grouping(grouping: SubLineItemGroupingModel?) = + grouping(JsonField.ofNullable(grouping)) - fun grouping(grouping: Optional) = grouping(grouping.orElse(null)) + fun grouping(grouping: Optional) = + grouping(grouping.orElse(null)) - fun grouping(grouping: JsonField) = apply { this.grouping = grouping } + fun grouping(grouping: JsonField) = apply { + this.grouping = grouping + } fun matrixConfig(matrixConfig: MatrixConfig) = matrixConfig(JsonField.of(matrixConfig)) @@ -4101,128 +3864,6 @@ private constructor( ) } - @NoAutoDetect - class Grouping - @JsonCreator - private constructor( - @JsonProperty("key") - @ExcludeMissing - private val key: JsonField = JsonMissing.of(), - @JsonProperty("value") - @ExcludeMissing - private val value: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun key(): String = key.getRequired("key") - - /** No value indicates the default group */ - fun value(): Optional = Optional.ofNullable(value.getNullable("value")) - - @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key - - /** No value indicates the default group */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Grouping = apply { - if (validated) { - return@apply - } - - key() - value() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Grouping]. */ - class Builder internal constructor() { - - private var key: JsonField? = null - private var value: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(grouping: Grouping) = apply { - key = grouping.key - value = grouping.value - additionalProperties = grouping.additionalProperties.toMutableMap() - } - - fun key(key: String) = key(JsonField.of(key)) - - fun key(key: JsonField) = apply { this.key = key } - - /** No value indicates the default group */ - fun value(value: String?) = value(JsonField.ofNullable(value)) - - /** No value indicates the default group */ - fun value(value: Optional) = value(value.orElse(null)) - - /** No value indicates the default group */ - fun value(value: JsonField) = apply { this.value = 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) - } - - fun build(): Grouping = - Grouping( - checkRequired("key", key), - checkRequired("value", value), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Grouping && key == other.key && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(key, value, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Grouping{key=$key, value=$value, additionalProperties=$additionalProperties}" - } - @NoAutoDetect class MatrixConfig @JsonCreator @@ -4262,6 +3903,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [MatrixConfig]. + * + * The following fields are required: + * ```java + * .dimensionValues() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -4289,14 +3938,8 @@ private constructor( /** The ordered dimension values for this line item. */ fun addDimensionValue(dimensionValue: String) = apply { dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) + (dimensionValues ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensionValues", it).add(dimensionValue) } } @@ -4473,7 +4116,7 @@ private constructor( private val amount: JsonField = JsonMissing.of(), @JsonProperty("grouping") @ExcludeMissing - private val grouping: JsonField = JsonMissing.of(), + private val grouping: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @@ -4493,7 +4136,7 @@ private constructor( /** The total amount for this sub line item. */ fun amount(): String = amount.getRequired("amount") - fun grouping(): Optional = + fun grouping(): Optional = Optional.ofNullable(grouping.getNullable("grouping")) fun name(): String = name.getRequired("name") @@ -4509,7 +4152,7 @@ private constructor( @JsonProperty("grouping") @ExcludeMissing - fun _grouping(): JsonField = grouping + fun _grouping(): JsonField = grouping @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @@ -4545,6 +4188,19 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [TierSubLineItem]. + * + * The following fields are required: + * ```java + * .amount() + * .grouping() + * .name() + * .quantity() + * .tierConfig() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -4552,7 +4208,7 @@ private constructor( class Builder internal constructor() { private var amount: JsonField? = null - private var grouping: JsonField? = null + private var grouping: JsonField? = null private var name: JsonField? = null private var quantity: JsonField? = null private var tierConfig: JsonField? = null @@ -4576,11 +4232,15 @@ private constructor( /** The total amount for this sub line item. */ fun amount(amount: JsonField) = apply { this.amount = amount } - fun grouping(grouping: Grouping?) = grouping(JsonField.ofNullable(grouping)) + fun grouping(grouping: SubLineItemGroupingModel?) = + grouping(JsonField.ofNullable(grouping)) - fun grouping(grouping: Optional) = grouping(grouping.orElse(null)) + fun grouping(grouping: Optional) = + grouping(grouping.orElse(null)) - fun grouping(grouping: JsonField) = apply { this.grouping = grouping } + fun grouping(grouping: JsonField) = apply { + this.grouping = grouping + } fun name(name: String) = name(JsonField.of(name)) @@ -4634,128 +4294,6 @@ private constructor( ) } - @NoAutoDetect - class Grouping - @JsonCreator - private constructor( - @JsonProperty("key") - @ExcludeMissing - private val key: JsonField = JsonMissing.of(), - @JsonProperty("value") - @ExcludeMissing - private val value: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun key(): String = key.getRequired("key") - - /** No value indicates the default group */ - fun value(): Optional = Optional.ofNullable(value.getNullable("value")) - - @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key - - /** No value indicates the default group */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Grouping = apply { - if (validated) { - return@apply - } - - key() - value() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Grouping]. */ - class Builder internal constructor() { - - private var key: JsonField? = null - private var value: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(grouping: Grouping) = apply { - key = grouping.key - value = grouping.value - additionalProperties = grouping.additionalProperties.toMutableMap() - } - - fun key(key: String) = key(JsonField.of(key)) - - fun key(key: JsonField) = apply { this.key = key } - - /** No value indicates the default group */ - fun value(value: String?) = value(JsonField.ofNullable(value)) - - /** No value indicates the default group */ - fun value(value: Optional) = value(value.orElse(null)) - - /** No value indicates the default group */ - fun value(value: JsonField) = apply { this.value = 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) - } - - fun build(): Grouping = - Grouping( - checkRequired("key", key), - checkRequired("value", value), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Grouping && key == other.key && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(key, value, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Grouping{key=$key, value=$value, additionalProperties=$additionalProperties}" - } - @NoAutoDetect class TierConfig @JsonCreator @@ -4813,6 +4351,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [TierConfig]. + * + * The following fields are required: + * ```java + * .firstUnit() + * .lastUnit() + * .unitAmount() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -5027,7 +4575,7 @@ private constructor( private val amount: JsonField = JsonMissing.of(), @JsonProperty("grouping") @ExcludeMissing - private val grouping: JsonField = JsonMissing.of(), + private val grouping: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @@ -5044,7 +4592,7 @@ private constructor( /** The total amount for this sub line item. */ fun amount(): String = amount.getRequired("amount") - fun grouping(): Optional = + fun grouping(): Optional = Optional.ofNullable(grouping.getNullable("grouping")) fun name(): String = name.getRequired("name") @@ -5058,7 +4606,7 @@ private constructor( @JsonProperty("grouping") @ExcludeMissing - fun _grouping(): JsonField = grouping + fun _grouping(): JsonField = grouping @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @@ -5089,6 +4637,18 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [OtherSubLineItem]. + * + * The following fields are required: + * ```java + * .amount() + * .grouping() + * .name() + * .quantity() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -5096,7 +4656,7 @@ private constructor( class Builder internal constructor() { private var amount: JsonField? = null - private var grouping: JsonField? = null + private var grouping: JsonField? = null private var name: JsonField? = null private var quantity: JsonField? = null private var type: JsonField? = null @@ -5118,11 +4678,15 @@ private constructor( /** The total amount for this sub line item. */ fun amount(amount: JsonField) = apply { this.amount = amount } - fun grouping(grouping: Grouping?) = grouping(JsonField.ofNullable(grouping)) + fun grouping(grouping: SubLineItemGroupingModel?) = + grouping(JsonField.ofNullable(grouping)) - fun grouping(grouping: Optional) = grouping(grouping.orElse(null)) + fun grouping(grouping: Optional) = + grouping(grouping.orElse(null)) - fun grouping(grouping: JsonField) = apply { this.grouping = grouping } + fun grouping(grouping: JsonField) = apply { + this.grouping = grouping + } fun name(name: String) = name(JsonField.of(name)) @@ -5169,128 +4733,6 @@ private constructor( ) } - @NoAutoDetect - class Grouping - @JsonCreator - private constructor( - @JsonProperty("key") - @ExcludeMissing - private val key: JsonField = JsonMissing.of(), - @JsonProperty("value") - @ExcludeMissing - private val value: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun key(): String = key.getRequired("key") - - /** No value indicates the default group */ - fun value(): Optional = Optional.ofNullable(value.getNullable("value")) - - @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key - - /** No value indicates the default group */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Grouping = apply { - if (validated) { - return@apply - } - - key() - value() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Grouping]. */ - class Builder internal constructor() { - - private var key: JsonField? = null - private var value: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(grouping: Grouping) = apply { - key = grouping.key - value = grouping.value - additionalProperties = grouping.additionalProperties.toMutableMap() - } - - fun key(key: String) = key(JsonField.of(key)) - - fun key(key: JsonField) = apply { this.key = key } - - /** No value indicates the default group */ - fun value(value: String?) = value(JsonField.ofNullable(value)) - - /** No value indicates the default group */ - fun value(value: Optional) = value(value.orElse(null)) - - /** No value indicates the default group */ - fun value(value: JsonField) = apply { this.value = 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) - } - - fun build(): Grouping = - Grouping( - checkRequired("key", key), - checkRequired("value", value), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Grouping && key == other.key && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(key, value, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Grouping{key=$key, value=$value, additionalProperties=$additionalProperties}" - } - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -5407,166 +4849,12 @@ private constructor( } } - @NoAutoDetect - class TaxAmount - @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("tax_rate_description") - @ExcludeMissing - private val taxRateDescription: JsonField = JsonMissing.of(), - @JsonProperty("tax_rate_percentage") - @ExcludeMissing - private val taxRatePercentage: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The amount of additional tax incurred by this tax rate. */ - fun amount(): String = amount.getRequired("amount") - - /** The human-readable description of the applied tax rate. */ - fun taxRateDescription(): String = taxRateDescription.getRequired("tax_rate_description") - - /** The tax rate percentage, out of 100. */ - fun taxRatePercentage(): Optional = - Optional.ofNullable(taxRatePercentage.getNullable("tax_rate_percentage")) - - /** The amount of additional tax incurred by this tax rate. */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** The human-readable description of the applied tax rate. */ - @JsonProperty("tax_rate_description") - @ExcludeMissing - fun _taxRateDescription(): JsonField = taxRateDescription - - /** The tax rate percentage, out of 100. */ - @JsonProperty("tax_rate_percentage") - @ExcludeMissing - fun _taxRatePercentage(): JsonField = taxRatePercentage - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TaxAmount = apply { - if (validated) { - return@apply - } - - amount() - taxRateDescription() - taxRatePercentage() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TaxAmount]. */ - class Builder internal constructor() { - - private var amount: JsonField? = null - private var taxRateDescription: JsonField? = null - private var taxRatePercentage: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(taxAmount: TaxAmount) = apply { - amount = taxAmount.amount - taxRateDescription = taxAmount.taxRateDescription - taxRatePercentage = taxAmount.taxRatePercentage - additionalProperties = taxAmount.additionalProperties.toMutableMap() - } - - /** The amount of additional tax incurred by this tax rate. */ - fun amount(amount: String) = amount(JsonField.of(amount)) - - /** The amount of additional tax incurred by this tax rate. */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** The human-readable description of the applied tax rate. */ - fun taxRateDescription(taxRateDescription: String) = - taxRateDescription(JsonField.of(taxRateDescription)) - - /** The human-readable description of the applied tax rate. */ - fun taxRateDescription(taxRateDescription: JsonField) = apply { - this.taxRateDescription = taxRateDescription - } - - /** The tax rate percentage, out of 100. */ - fun taxRatePercentage(taxRatePercentage: String?) = - taxRatePercentage(JsonField.ofNullable(taxRatePercentage)) - - /** The tax rate percentage, out of 100. */ - fun taxRatePercentage(taxRatePercentage: Optional) = - taxRatePercentage(taxRatePercentage.orElse(null)) - - /** The tax rate percentage, out of 100. */ - fun taxRatePercentage(taxRatePercentage: JsonField) = apply { - this.taxRatePercentage = taxRatePercentage - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): TaxAmount = - TaxAmount( - checkRequired("amount", amount), - checkRequired("taxRateDescription", taxRateDescription), - checkRequired("taxRatePercentage", taxRatePercentage), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TaxAmount && amount == other.amount && taxRateDescription == other.taxRateDescription && taxRatePercentage == other.taxRatePercentage && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, taxRateDescription, taxRatePercentage, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TaxAmount{amount=$amount, taxRateDescription=$taxRateDescription, taxRatePercentage=$taxRatePercentage, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is InvoiceLineItemCreateResponse && id == other.id && adjustedSubtotal == other.adjustedSubtotal && adjustments == other.adjustments && amount == other.amount && creditsApplied == other.creditsApplied && discount == other.discount && endDate == other.endDate && filter == other.filter && grouping == other.grouping && maximum == other.maximum && maximumAmount == other.maximumAmount && minimum == other.minimum && minimumAmount == other.minimumAmount && name == other.name && partiallyInvoicedAmount == other.partiallyInvoicedAmount && price == other.price && quantity == other.quantity && startDate == other.startDate && subLineItems == other.subLineItems && subtotal == other.subtotal && taxAmounts == other.taxAmounts && usageCustomerIds == other.usageCustomerIds && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is InvoiceLineItemModel && id == other.id && adjustedSubtotal == other.adjustedSubtotal && adjustments == other.adjustments && amount == other.amount && creditsApplied == other.creditsApplied && discount == other.discount && endDate == other.endDate && filter == other.filter && grouping == other.grouping && maximum == other.maximum && maximumAmount == other.maximumAmount && minimum == other.minimum && minimumAmount == other.minimumAmount && name == other.name && partiallyInvoicedAmount == other.partiallyInvoicedAmount && price == other.price && quantity == other.quantity && startDate == other.startDate && subLineItems == other.subLineItems && subtotal == other.subtotal && taxAmounts == other.taxAmounts && usageCustomerIds == other.usageCustomerIds && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -5576,5 +4864,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "InvoiceLineItemCreateResponse{id=$id, adjustedSubtotal=$adjustedSubtotal, adjustments=$adjustments, amount=$amount, creditsApplied=$creditsApplied, discount=$discount, endDate=$endDate, filter=$filter, grouping=$grouping, maximum=$maximum, maximumAmount=$maximumAmount, minimum=$minimum, minimumAmount=$minimumAmount, name=$name, partiallyInvoicedAmount=$partiallyInvoicedAmount, price=$price, quantity=$quantity, startDate=$startDate, subLineItems=$subLineItems, subtotal=$subtotal, taxAmounts=$taxAmounts, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" + "InvoiceLineItemModel{id=$id, adjustedSubtotal=$adjustedSubtotal, adjustments=$adjustments, amount=$amount, creditsApplied=$creditsApplied, discount=$discount, endDate=$endDate, filter=$filter, grouping=$grouping, maximum=$maximum, maximumAmount=$maximumAmount, minimum=$minimum, minimumAmount=$minimumAmount, name=$name, partiallyInvoicedAmount=$partiallyInvoicedAmount, price=$price, quantity=$quantity, startDate=$startDate, subLineItems=$subLineItems, subtotal=$subtotal, taxAmounts=$taxAmounts, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPage.kt index de9caa315..978fb21e1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPage.kt @@ -42,7 +42,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -97,20 +97,20 @@ private constructor( class Response @JsonCreator constructor( - @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), + @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = Optional.ofNullable(data) + fun _data(): Optional>> = Optional.ofNullable(data) @JsonProperty("pagination_metadata") fun _paginationMetadata(): Optional> = @@ -149,12 +149,13 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [InvoiceListPage]. */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -165,9 +166,9 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { this.data = data } fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) @@ -184,9 +185,9 @@ private constructor( } } - class AutoPager(private val firstPage: InvoiceListPage) : Iterable { + class AutoPager(private val firstPage: InvoiceListPage) : Iterable { - override fun iterator(): Iterator = iterator { + override fun iterator(): Iterator = iterator { var page = firstPage var index = 0 while (true) { @@ -198,7 +199,7 @@ private constructor( } } - fun stream(): Stream { + fun stream(): Stream { return StreamSupport.stream(spliterator(), false) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPageAsync.kt index 2d5aa7f00..63870e55d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListPageAsync.kt @@ -43,7 +43,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -103,20 +103,20 @@ private constructor( class Response @JsonCreator constructor( - @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), + @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = Optional.ofNullable(data) + fun _data(): Optional>> = Optional.ofNullable(data) @JsonProperty("pagination_metadata") fun _paginationMetadata(): Optional> = @@ -155,12 +155,13 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [InvoiceListPageAsync]. */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -171,9 +172,9 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { this.data = data } fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) @@ -192,9 +193,9 @@ private constructor( class AutoPager(private val firstPage: InvoiceListPageAsync) { - fun forEach(action: Predicate, executor: Executor): CompletableFuture { + fun forEach(action: Predicate, executor: Executor): CompletableFuture { fun CompletableFuture>.forEach( - action: (Invoice) -> Boolean, + action: (InvoiceModel) -> Boolean, executor: Executor, ): CompletableFuture = thenComposeAsync( @@ -210,8 +211,8 @@ private constructor( .forEach(action::test, executor) } - fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() + fun toList(executor: Executor): CompletableFuture> { + val values = mutableListOf() return forEach(values::add, executor).thenApply { values } } } 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 10ad06225..d93c005da 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 @@ -163,6 +163,7 @@ private constructor( @JvmStatic fun none(): InvoiceListParams = builder().build() + /** Returns a mutable builder for constructing an instance of [InvoiceListParams]. */ @JvmStatic fun builder() = Builder() } 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 bd64219a2..8c0d0a75b 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 @@ -134,6 +134,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .paymentReceivedDate() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -230,6 +238,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [InvoiceMarkPaidParams]. + * + * The following fields are required: + * ```java + * .invoiceId() + * .paymentReceivedDate() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceModel.kt new file mode 100644 index 000000000..f723ed0bb --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceModel.kt @@ -0,0 +1,2187 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +/** + * 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. + */ +@NoAutoDetect +class InvoiceModel +@JsonCreator +private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("amount_due") + @ExcludeMissing + private val amountDue: JsonField = JsonMissing.of(), + @JsonProperty("auto_collection") + @ExcludeMissing + private val autoCollection: JsonField = JsonMissing.of(), + @JsonProperty("billing_address") + @ExcludeMissing + private val billingAddress: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_notes") + @ExcludeMissing + private val creditNotes: JsonField> = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("customer") + @ExcludeMissing + private val customer: JsonField = JsonMissing.of(), + @JsonProperty("customer_balance_transactions") + @ExcludeMissing + private val customerBalanceTransactions: JsonField> = + JsonMissing.of(), + @JsonProperty("customer_tax_id") + @ExcludeMissing + private val customerTaxId: JsonField = JsonMissing.of(), + @JsonProperty("discount") @ExcludeMissing private val discount: JsonValue = JsonMissing.of(), + @JsonProperty("discounts") + @ExcludeMissing + private val discounts: JsonField> = JsonMissing.of(), + @JsonProperty("due_date") + @ExcludeMissing + private val dueDate: JsonField = JsonMissing.of(), + @JsonProperty("eligible_to_issue_at") + @ExcludeMissing + private val eligibleToIssueAt: JsonField = JsonMissing.of(), + @JsonProperty("hosted_invoice_url") + @ExcludeMissing + private val hostedInvoiceUrl: JsonField = JsonMissing.of(), + @JsonProperty("invoice_date") + @ExcludeMissing + private val invoiceDate: JsonField = JsonMissing.of(), + @JsonProperty("invoice_number") + @ExcludeMissing + private val invoiceNumber: JsonField = JsonMissing.of(), + @JsonProperty("invoice_pdf") + @ExcludeMissing + private val invoicePdf: JsonField = JsonMissing.of(), + @JsonProperty("invoice_source") + @ExcludeMissing + private val invoiceSource: JsonField = JsonMissing.of(), + @JsonProperty("issue_failed_at") + @ExcludeMissing + private val issueFailedAt: JsonField = JsonMissing.of(), + @JsonProperty("issued_at") + @ExcludeMissing + private val issuedAt: JsonField = JsonMissing.of(), + @JsonProperty("line_items") + @ExcludeMissing + private val lineItems: JsonField> = JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("memo") @ExcludeMissing private val memo: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("paid_at") + @ExcludeMissing + private val paidAt: JsonField = JsonMissing.of(), + @JsonProperty("payment_attempts") + @ExcludeMissing + private val paymentAttempts: JsonField> = JsonMissing.of(), + @JsonProperty("payment_failed_at") + @ExcludeMissing + private val paymentFailedAt: JsonField = JsonMissing.of(), + @JsonProperty("payment_started_at") + @ExcludeMissing + private val paymentStartedAt: JsonField = JsonMissing.of(), + @JsonProperty("scheduled_issue_at") + @ExcludeMissing + private val scheduledIssueAt: JsonField = JsonMissing.of(), + @JsonProperty("shipping_address") + @ExcludeMissing + private val shippingAddress: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + private val status: JsonField = JsonMissing.of(), + @JsonProperty("subscription") + @ExcludeMissing + private val subscription: JsonField = JsonMissing.of(), + @JsonProperty("subtotal") + @ExcludeMissing + private val subtotal: JsonField = JsonMissing.of(), + @JsonProperty("sync_failed_at") + @ExcludeMissing + private val syncFailedAt: JsonField = JsonMissing.of(), + @JsonProperty("total") @ExcludeMissing private val total: JsonField = JsonMissing.of(), + @JsonProperty("voided_at") + @ExcludeMissing + private val voidedAt: JsonField = JsonMissing.of(), + @JsonProperty("will_auto_issue") + @ExcludeMissing + private val willAutoIssue: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + 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. + */ + fun amountDue(): String = amountDue.getRequired("amount_due") + + fun autoCollection(): AutoCollectionModel = autoCollection.getRequired("auto_collection") + + fun billingAddress(): Optional = + Optional.ofNullable(billingAddress.getNullable("billing_address")) + + /** The creation time of the resource in Orb. */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** A list of credit notes associated with the invoice */ + fun creditNotes(): List = creditNotes.getRequired("credit_notes") + + /** An ISO 4217 currency string or `credits` */ + fun currency(): String = currency.getRequired("currency") + + fun customer(): CustomerMinifiedModel = customer.getRequired("customer") + + 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 | + * |--------------------|------------|-------------------------------------------------------------------------------------------------------| + * |Andorra |`ad_nrt` |Andorran NRT Number | + * |Argentina |`ar_cuit` |Argentinian Tax ID Number | + * |Australia |`au_abn` |Australian Business Number (AU ABN) | + * |Australia |`au_arn` |Australian Taxation Office Reference Number | + * |Austria |`eu_vat` |European VAT Number | + * |Bahrain |`bh_vat` |Bahraini VAT Number | + * |Belgium |`eu_vat` |European VAT Number | + * |Bolivia |`bo_tin` |Bolivian Tax ID | + * |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 | + * |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) | + * |Chile |`cl_tin` |Chilean TIN | + * |China |`cn_tin` |Chinese Tax ID | + * |Colombia |`co_nit` |Colombian NIT Number | + * |Costa Rica |`cr_tin` |Costa Rican Tax ID | + * |Croatia |`eu_vat` |European VAT Number | + * |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 | + * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Finland |`eu_vat` |European VAT Number | + * |France |`eu_vat` |European VAT Number | + * |Georgia |`ge_vat` |Georgian VAT | + * |Germany |`eu_vat` |European VAT Number | + * |Greece |`eu_vat` |European VAT Number | + * |Hong Kong |`hk_br` |Hong Kong BR Number | + * |Hungary |`eu_vat` |European VAT Number | + * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | + * |Iceland |`is_vat` |Icelandic VAT | + * |India |`in_gst` |Indian GST Number | + * |Indonesia |`id_npwp` |Indonesian NPWP Number | + * |Ireland |`eu_vat` |European VAT Number | + * |Israel |`il_vat` |Israel VAT | + * |Italy |`eu_vat` |European VAT Number | + * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | + * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | + * |Latvia |`eu_vat` |European VAT Number | + * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | + * |Mexico |`mx_rfc` |Mexican RFC Number | + * |Netherlands |`eu_vat` |European VAT Number | + * |New Zealand |`nz_gst` |New Zealand GST Number | + * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | + * |Norway |`no_vat` |Norwegian VAT Number | + * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | + * |Oman |`om_vat` |Omani VAT Number | + * |Peru |`pe_ruc` |Peruvian RUC Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Poland |`eu_vat` |European VAT Number | + * |Portugal |`eu_vat` |European VAT Number | + * |Romania |`eu_vat` |European VAT Number | + * |Romania |`ro_tin` |Romanian Tax ID Number | + * |Russia |`ru_inn` |Russian INN | + * |Russia |`ru_kpp` |Russian KPP | + * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | + * |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 | + * |Sweden |`eu_vat` |European VAT Number | + * |Switzerland |`ch_vat` |Switzerland VAT Number | + * |Taiwan |`tw_vat` |Taiwanese VAT | + * |Thailand |`th_vat` |Thai VAT | + * |Turkey |`tr_tin` |Turkish Tax Identification Number | + * |Ukraine |`ua_vat` |Ukrainian VAT | + * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | + * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | + * |United Kingdom |`gb_vat` |United Kingdom VAT Number | + * |United States |`us_ein` |United States EIN | + * |Uruguay |`uy_ruc` |Uruguayan RUC Number | + * |Venezuela |`ve_rif` |Venezuelan RIF Number | + * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + */ + fun customerTaxId(): Optional = + Optional.ofNullable(customerTaxId.getNullable("customer_tax_id")) + + /** + * This field is deprecated in favor of `discounts`. If a `discounts` list is provided, the + * first discount in the list will be returned. If the list is empty, `None` will be returned. + */ + @Deprecated("deprecated") + @JsonProperty("discount") + @ExcludeMissing + fun _discount(): JsonValue = discount + + fun discounts(): List = discounts.getRequired("discounts") + + /** + * When the invoice payment is due. The due date is null if the invoice is not yet finalized. + */ + fun dueDate(): Optional = Optional.ofNullable(dueDate.getNullable("due_date")) + + /** + * If the invoice has a status of `draft`, this will be the time that the invoice will be + * eligible to be issued, otherwise it will be `null`. If `auto-issue` is true, the invoice will + * automatically begin issuing at this time. + */ + fun eligibleToIssueAt(): Optional = + Optional.ofNullable(eligibleToIssueAt.getNullable("eligible_to_issue_at")) + + /** + * A URL for the customer-facing invoice portal. This URL expires 30 days after the invoice's + * due date, or 60 days after being re-generated through the UI. + */ + fun hostedInvoiceUrl(): Optional = + Optional.ofNullable(hostedInvoiceUrl.getNullable("hosted_invoice_url")) + + /** The scheduled date of the invoice */ + 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. + */ + fun invoiceNumber(): String = invoiceNumber.getRequired("invoice_number") + + /** The link to download the PDF representation of the `Invoice`. */ + fun invoicePdf(): Optional = Optional.ofNullable(invoicePdf.getNullable("invoice_pdf")) + + 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.) + */ + fun issueFailedAt(): Optional = + Optional.ofNullable(issueFailedAt.getNullable("issue_failed_at")) + + /** + * If the invoice has been issued, this will be the time it transitioned to `issued` (even if it + * is now in a different state.) + */ + fun issuedAt(): Optional = + Optional.ofNullable(issuedAt.getNullable("issued_at")) + + /** The breakdown of prices in this invoice. */ + fun lineItems(): List = lineItems.getRequired("line_items") + + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** Free-form text which is available on the invoice PDF and the Orb invoice portal. */ + fun memo(): Optional = Optional.ofNullable(memo.getNullable("memo")) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an empty + * dictionary. Individual keys can be removed by setting the value to `null`, and the entire + * metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + /** If the invoice has a status of `paid`, this gives a timestamp when the invoice was paid. */ + fun paidAt(): Optional = Optional.ofNullable(paidAt.getNullable("paid_at")) + + /** A list of payment attempts associated with the invoice */ + 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. + */ + fun paymentFailedAt(): Optional = + Optional.ofNullable(paymentFailedAt.getNullable("payment_failed_at")) + + /** + * If payment was attempted on this invoice, this will be the start time of the most recent + * attempt. This field is especially useful for delayed-notification payment mechanisms (like + * bank transfers), where payment can take 3 days or more. + */ + fun paymentStartedAt(): Optional = + Optional.ofNullable(paymentStartedAt.getNullable("payment_started_at")) + + /** + * If the invoice is in draft, this timestamp will reflect when the invoice is scheduled to be + * issued. + */ + fun scheduledIssueAt(): Optional = + Optional.ofNullable(scheduledIssueAt.getNullable("scheduled_issue_at")) + + fun shippingAddress(): Optional = + Optional.ofNullable(shippingAddress.getNullable("shipping_address")) + + fun status(): Status = status.getRequired("status") + + fun subscription(): Optional = + Optional.ofNullable(subscription.getNullable("subscription")) + + /** The total before any discounts and minimums are applied. */ + fun subtotal(): String = subtotal.getRequired("subtotal") + + /** + * If the invoice failed to sync, this will be the last time an external invoicing provider sync + * was attempted. This field will always be `null` for invoices using Orb Invoicing. + */ + fun syncFailedAt(): Optional = + Optional.ofNullable(syncFailedAt.getNullable("sync_failed_at")) + + /** The total after any minimums and discounts have been applied. */ + fun total(): String = total.getRequired("total") + + /** + * If the invoice has a status of `void`, this gives a timestamp when the invoice was voided. + */ + fun voidedAt(): Optional = + Optional.ofNullable(voidedAt.getNullable("voided_at")) + + /** + * This is true if the invoice will be automatically issued in the future, and false otherwise. + */ + fun willAutoIssue(): Boolean = willAutoIssue.getRequired("will_auto_issue") + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = 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. + */ + @JsonProperty("amount_due") @ExcludeMissing fun _amountDue(): JsonField = amountDue + + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection + + @JsonProperty("billing_address") + @ExcludeMissing + fun _billingAddress(): JsonField = billingAddress + + /** The creation time of the resource in Orb. */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** A list of credit notes associated with the invoice */ + @JsonProperty("credit_notes") + @ExcludeMissing + fun _creditNotes(): JsonField> = creditNotes + + /** An ISO 4217 currency string or `credits` */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @JsonProperty("customer") + @ExcludeMissing + fun _customer(): JsonField = customer + + @JsonProperty("customer_balance_transactions") + @ExcludeMissing + fun _customerBalanceTransactions(): JsonField> = + customerBalanceTransactions + + /** + * 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 | + * |--------------------|------------|-------------------------------------------------------------------------------------------------------| + * |Andorra |`ad_nrt` |Andorran NRT Number | + * |Argentina |`ar_cuit` |Argentinian Tax ID Number | + * |Australia |`au_abn` |Australian Business Number (AU ABN) | + * |Australia |`au_arn` |Australian Taxation Office Reference Number | + * |Austria |`eu_vat` |European VAT Number | + * |Bahrain |`bh_vat` |Bahraini VAT Number | + * |Belgium |`eu_vat` |European VAT Number | + * |Bolivia |`bo_tin` |Bolivian Tax ID | + * |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 | + * |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) | + * |Chile |`cl_tin` |Chilean TIN | + * |China |`cn_tin` |Chinese Tax ID | + * |Colombia |`co_nit` |Colombian NIT Number | + * |Costa Rica |`cr_tin` |Costa Rican Tax ID | + * |Croatia |`eu_vat` |European VAT Number | + * |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 | + * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Finland |`eu_vat` |European VAT Number | + * |France |`eu_vat` |European VAT Number | + * |Georgia |`ge_vat` |Georgian VAT | + * |Germany |`eu_vat` |European VAT Number | + * |Greece |`eu_vat` |European VAT Number | + * |Hong Kong |`hk_br` |Hong Kong BR Number | + * |Hungary |`eu_vat` |European VAT Number | + * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | + * |Iceland |`is_vat` |Icelandic VAT | + * |India |`in_gst` |Indian GST Number | + * |Indonesia |`id_npwp` |Indonesian NPWP Number | + * |Ireland |`eu_vat` |European VAT Number | + * |Israel |`il_vat` |Israel VAT | + * |Italy |`eu_vat` |European VAT Number | + * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | + * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | + * |Latvia |`eu_vat` |European VAT Number | + * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | + * |Mexico |`mx_rfc` |Mexican RFC Number | + * |Netherlands |`eu_vat` |European VAT Number | + * |New Zealand |`nz_gst` |New Zealand GST Number | + * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | + * |Norway |`no_vat` |Norwegian VAT Number | + * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | + * |Oman |`om_vat` |Omani VAT Number | + * |Peru |`pe_ruc` |Peruvian RUC Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Poland |`eu_vat` |European VAT Number | + * |Portugal |`eu_vat` |European VAT Number | + * |Romania |`eu_vat` |European VAT Number | + * |Romania |`ro_tin` |Romanian Tax ID Number | + * |Russia |`ru_inn` |Russian INN | + * |Russia |`ru_kpp` |Russian KPP | + * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | + * |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 | + * |Sweden |`eu_vat` |European VAT Number | + * |Switzerland |`ch_vat` |Switzerland VAT Number | + * |Taiwan |`tw_vat` |Taiwanese VAT | + * |Thailand |`th_vat` |Thai VAT | + * |Turkey |`tr_tin` |Turkish Tax Identification Number | + * |Ukraine |`ua_vat` |Ukrainian VAT | + * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | + * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | + * |United Kingdom |`gb_vat` |United Kingdom VAT Number | + * |United States |`us_ein` |United States EIN | + * |Uruguay |`uy_ruc` |Uruguayan RUC Number | + * |Venezuela |`ve_rif` |Venezuelan RIF Number | + * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + */ + @JsonProperty("customer_tax_id") + @ExcludeMissing + fun _customerTaxId(): JsonField = customerTaxId + + @JsonProperty("discounts") + @ExcludeMissing + fun _discounts(): JsonField> = discounts + + /** + * When the invoice payment is due. The due date is null if the invoice is not yet finalized. + */ + @JsonProperty("due_date") @ExcludeMissing fun _dueDate(): JsonField = 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. + */ + @JsonProperty("eligible_to_issue_at") + @ExcludeMissing + fun _eligibleToIssueAt(): JsonField = 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. + */ + @JsonProperty("hosted_invoice_url") + @ExcludeMissing + fun _hostedInvoiceUrl(): JsonField = hostedInvoiceUrl + + /** The scheduled date of the invoice */ + @JsonProperty("invoice_date") + @ExcludeMissing + fun _invoiceDate(): JsonField = 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. + */ + @JsonProperty("invoice_number") + @ExcludeMissing + fun _invoiceNumber(): JsonField = invoiceNumber + + /** The link to download the PDF representation of the `Invoice`. */ + @JsonProperty("invoice_pdf") @ExcludeMissing fun _invoicePdf(): JsonField = invoicePdf + + @JsonProperty("invoice_source") + @ExcludeMissing + fun _invoiceSource(): JsonField = 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.) + */ + @JsonProperty("issue_failed_at") + @ExcludeMissing + fun _issueFailedAt(): JsonField = 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.) + */ + @JsonProperty("issued_at") @ExcludeMissing fun _issuedAt(): JsonField = issuedAt + + /** The breakdown of prices in this invoice. */ + @JsonProperty("line_items") + @ExcludeMissing + fun _lineItems(): JsonField> = lineItems + + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount + + /** Free-form text which is available on the invoice PDF and the Orb invoice portal. */ + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** If the invoice has a status of `paid`, this gives a timestamp when the invoice was paid. */ + @JsonProperty("paid_at") @ExcludeMissing fun _paidAt(): JsonField = paidAt + + /** A list of payment attempts associated with the invoice */ + @JsonProperty("payment_attempts") + @ExcludeMissing + fun _paymentAttempts(): JsonField> = paymentAttempts + + /** + * If payment was attempted on this invoice but failed, this will be the time of the most recent + * attempt. + */ + @JsonProperty("payment_failed_at") + @ExcludeMissing + fun _paymentFailedAt(): JsonField = 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. + */ + @JsonProperty("payment_started_at") + @ExcludeMissing + fun _paymentStartedAt(): JsonField = paymentStartedAt + + /** + * If the invoice is in draft, this timestamp will reflect when the invoice is scheduled to be + * issued. + */ + @JsonProperty("scheduled_issue_at") + @ExcludeMissing + fun _scheduledIssueAt(): JsonField = scheduledIssueAt + + @JsonProperty("shipping_address") + @ExcludeMissing + fun _shippingAddress(): JsonField = shippingAddress + + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + @JsonProperty("subscription") + @ExcludeMissing + fun _subscription(): JsonField = subscription + + /** The total before any discounts and minimums are applied. */ + @JsonProperty("subtotal") @ExcludeMissing fun _subtotal(): JsonField = subtotal + + /** + * If the invoice failed to sync, this will be the last time an external invoicing provider sync + * was attempted. This field will always be `null` for invoices using Orb Invoicing. + */ + @JsonProperty("sync_failed_at") + @ExcludeMissing + fun _syncFailedAt(): JsonField = syncFailedAt + + /** The total after any minimums and discounts have been applied. */ + @JsonProperty("total") @ExcludeMissing fun _total(): JsonField = total + + /** + * If the invoice has a status of `void`, this gives a timestamp when the invoice was voided. + */ + @JsonProperty("voided_at") @ExcludeMissing fun _voidedAt(): JsonField = voidedAt + + /** + * This is true if the invoice will be automatically issued in the future, and false otherwise. + */ + @JsonProperty("will_auto_issue") + @ExcludeMissing + fun _willAutoIssue(): JsonField = willAutoIssue + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): InvoiceModel = apply { + if (validated) { + return@apply + } + + id() + amountDue() + autoCollection().validate() + billingAddress().ifPresent { it.validate() } + createdAt() + creditNotes().forEach { it.validate() } + currency() + customer().validate() + customerBalanceTransactions().forEach { it.validate() } + customerTaxId().ifPresent { it.validate() } + discounts().forEach { it.validate() } + dueDate() + eligibleToIssueAt() + hostedInvoiceUrl() + invoiceDate() + invoiceNumber() + invoicePdf() + invoiceSource() + issueFailedAt() + issuedAt() + lineItems().forEach { it.validate() } + maximum().ifPresent { it.validate() } + maximumAmount() + memo() + metadata().validate() + minimum().ifPresent { it.validate() } + minimumAmount() + paidAt() + paymentAttempts().forEach { it.validate() } + paymentFailedAt() + paymentStartedAt() + scheduledIssueAt() + shippingAddress().ifPresent { it.validate() } + status() + subscription().ifPresent { it.validate() } + subtotal() + syncFailedAt() + total() + voidedAt() + willAutoIssue() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InvoiceModel]. + * + * The following fields are required: + * ```java + * .id() + * .amountDue() + * .autoCollection() + * .billingAddress() + * .createdAt() + * .creditNotes() + * .currency() + * .customer() + * .customerBalanceTransactions() + * .customerTaxId() + * .discount() + * .discounts() + * .dueDate() + * .eligibleToIssueAt() + * .hostedInvoiceUrl() + * .invoiceDate() + * .invoiceNumber() + * .invoicePdf() + * .invoiceSource() + * .issueFailedAt() + * .issuedAt() + * .lineItems() + * .maximum() + * .maximumAmount() + * .memo() + * .metadata() + * .minimum() + * .minimumAmount() + * .paidAt() + * .paymentAttempts() + * .paymentFailedAt() + * .paymentStartedAt() + * .scheduledIssueAt() + * .shippingAddress() + * .status() + * .subscription() + * .subtotal() + * .syncFailedAt() + * .total() + * .voidedAt() + * .willAutoIssue() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InvoiceModel]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var amountDue: JsonField? = null + private var autoCollection: JsonField? = null + private var billingAddress: JsonField? = null + private var createdAt: JsonField? = null + private var creditNotes: JsonField>? = null + private var currency: JsonField? = null + private var customer: JsonField? = null + private var customerBalanceTransactions: + JsonField>? = + null + private var customerTaxId: JsonField? = null + private var discount: JsonValue? = null + private var discounts: JsonField>? = null + private var dueDate: JsonField? = null + private var eligibleToIssueAt: JsonField? = null + private var hostedInvoiceUrl: JsonField? = null + private var invoiceDate: JsonField? = null + private var invoiceNumber: JsonField? = null + private var invoicePdf: JsonField? = null + private var invoiceSource: JsonField? = null + private var issueFailedAt: JsonField? = null + private var issuedAt: JsonField? = null + private var lineItems: JsonField>? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var memo: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var paidAt: JsonField? = null + private var paymentAttempts: JsonField>? = null + private var paymentFailedAt: JsonField? = null + private var paymentStartedAt: JsonField? = null + private var scheduledIssueAt: JsonField? = null + private var shippingAddress: JsonField? = null + private var status: JsonField? = null + private var subscription: JsonField? = null + private var subtotal: JsonField? = null + private var syncFailedAt: JsonField? = null + private var total: JsonField? = null + private var voidedAt: JsonField? = null + private var willAutoIssue: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(invoiceModel: InvoiceModel) = apply { + id = invoiceModel.id + amountDue = invoiceModel.amountDue + autoCollection = invoiceModel.autoCollection + billingAddress = invoiceModel.billingAddress + createdAt = invoiceModel.createdAt + creditNotes = invoiceModel.creditNotes.map { it.toMutableList() } + currency = invoiceModel.currency + customer = invoiceModel.customer + customerBalanceTransactions = + invoiceModel.customerBalanceTransactions.map { it.toMutableList() } + customerTaxId = invoiceModel.customerTaxId + discount = invoiceModel.discount + discounts = invoiceModel.discounts.map { it.toMutableList() } + dueDate = invoiceModel.dueDate + eligibleToIssueAt = invoiceModel.eligibleToIssueAt + hostedInvoiceUrl = invoiceModel.hostedInvoiceUrl + invoiceDate = invoiceModel.invoiceDate + invoiceNumber = invoiceModel.invoiceNumber + invoicePdf = invoiceModel.invoicePdf + invoiceSource = invoiceModel.invoiceSource + issueFailedAt = invoiceModel.issueFailedAt + issuedAt = invoiceModel.issuedAt + lineItems = invoiceModel.lineItems.map { it.toMutableList() } + maximum = invoiceModel.maximum + maximumAmount = invoiceModel.maximumAmount + memo = invoiceModel.memo + metadata = invoiceModel.metadata + minimum = invoiceModel.minimum + minimumAmount = invoiceModel.minimumAmount + paidAt = invoiceModel.paidAt + paymentAttempts = invoiceModel.paymentAttempts.map { it.toMutableList() } + paymentFailedAt = invoiceModel.paymentFailedAt + paymentStartedAt = invoiceModel.paymentStartedAt + scheduledIssueAt = invoiceModel.scheduledIssueAt + shippingAddress = invoiceModel.shippingAddress + status = invoiceModel.status + subscription = invoiceModel.subscription + subtotal = invoiceModel.subtotal + syncFailedAt = invoiceModel.syncFailedAt + total = invoiceModel.total + voidedAt = invoiceModel.voidedAt + willAutoIssue = invoiceModel.willAutoIssue + additionalProperties = invoiceModel.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + 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)) + + /** + * 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: JsonField) = apply { this.amountDue = amountDue } + + fun autoCollection(autoCollection: AutoCollectionModel) = + autoCollection(JsonField.of(autoCollection)) + + fun autoCollection(autoCollection: JsonField) = apply { + this.autoCollection = autoCollection + } + + fun billingAddress(billingAddress: AddressModel?) = + billingAddress(JsonField.ofNullable(billingAddress)) + + fun billingAddress(billingAddress: Optional) = + billingAddress(billingAddress.orElse(null)) + + fun billingAddress(billingAddress: JsonField) = apply { + this.billingAddress = billingAddress + } + + /** The creation time of the resource in Orb. */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** The creation time of the resource in Orb. */ + 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)) + + /** A list of credit notes associated with the invoice */ + fun creditNotes(creditNotes: JsonField>) = apply { + this.creditNotes = creditNotes.map { it.toMutableList() } + } + + /** A list of credit notes associated with the invoice */ + fun addCreditNote(creditNote: CreditNoteSummaryModel) = 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)) + + /** An ISO 4217 currency string or `credits` */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun customer(customer: CustomerMinifiedModel) = customer(JsonField.of(customer)) + + fun customer(customer: JsonField) = apply { + this.customer = customer + } + + fun customerBalanceTransactions( + customerBalanceTransactions: List + ) = customerBalanceTransactions(JsonField.of(customerBalanceTransactions)) + + fun customerBalanceTransactions( + customerBalanceTransactions: JsonField> + ) = apply { + this.customerBalanceTransactions = + customerBalanceTransactions.map { it.toMutableList() } + } + + fun addCustomerBalanceTransaction( + customerBalanceTransaction: CustomerBalanceTransactionModel + ) = 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 | + * |--------------------|------------|-------------------------------------------------------------------------------------------------------| + * |Andorra |`ad_nrt` |Andorran NRT Number | + * |Argentina |`ar_cuit` |Argentinian Tax ID Number | + * |Australia |`au_abn` |Australian Business Number (AU ABN) | + * |Australia |`au_arn` |Australian Taxation Office Reference Number | + * |Austria |`eu_vat` |European VAT Number | + * |Bahrain |`bh_vat` |Bahraini VAT Number | + * |Belgium |`eu_vat` |European VAT Number | + * |Bolivia |`bo_tin` |Bolivian Tax ID | + * |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 | + * |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) | + * |Chile |`cl_tin` |Chilean TIN | + * |China |`cn_tin` |Chinese Tax ID | + * |Colombia |`co_nit` |Colombian NIT Number | + * |Costa Rica |`cr_tin` |Costa Rican Tax ID | + * |Croatia |`eu_vat` |European VAT Number | + * |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 | + * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Finland |`eu_vat` |European VAT Number | + * |France |`eu_vat` |European VAT Number | + * |Georgia |`ge_vat` |Georgian VAT | + * |Germany |`eu_vat` |European VAT Number | + * |Greece |`eu_vat` |European VAT Number | + * |Hong Kong |`hk_br` |Hong Kong BR Number | + * |Hungary |`eu_vat` |European VAT Number | + * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | + * |Iceland |`is_vat` |Icelandic VAT | + * |India |`in_gst` |Indian GST Number | + * |Indonesia |`id_npwp` |Indonesian NPWP Number | + * |Ireland |`eu_vat` |European VAT Number | + * |Israel |`il_vat` |Israel VAT | + * |Italy |`eu_vat` |European VAT Number | + * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | + * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | + * |Latvia |`eu_vat` |European VAT Number | + * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | + * |Mexico |`mx_rfc` |Mexican RFC Number | + * |Netherlands |`eu_vat` |European VAT Number | + * |New Zealand |`nz_gst` |New Zealand GST Number | + * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | + * |Norway |`no_vat` |Norwegian VAT Number | + * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | + * |Oman |`om_vat` |Omani VAT Number | + * |Peru |`pe_ruc` |Peruvian RUC Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Poland |`eu_vat` |European VAT Number | + * |Portugal |`eu_vat` |European VAT Number | + * |Romania |`eu_vat` |European VAT Number | + * |Romania |`ro_tin` |Romanian Tax ID Number | + * |Russia |`ru_inn` |Russian INN | + * |Russia |`ru_kpp` |Russian KPP | + * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | + * |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 | + * |Sweden |`eu_vat` |European VAT Number | + * |Switzerland |`ch_vat` |Switzerland VAT Number | + * |Taiwan |`tw_vat` |Taiwanese VAT | + * |Thailand |`th_vat` |Thai VAT | + * |Turkey |`tr_tin` |Turkish Tax Identification Number | + * |Ukraine |`ua_vat` |Ukrainian VAT | + * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | + * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | + * |United Kingdom |`gb_vat` |United Kingdom VAT Number | + * |United States |`us_ein` |United States EIN | + * |Uruguay |`uy_ruc` |Uruguayan RUC Number | + * |Venezuela |`ve_rif` |Venezuelan RIF Number | + * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + */ + fun customerTaxId(customerTaxId: CustomerTaxIdModel?) = + customerTaxId(JsonField.ofNullable(customerTaxId)) + + /** + * 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 | + * |--------------------|------------|-------------------------------------------------------------------------------------------------------| + * |Andorra |`ad_nrt` |Andorran NRT Number | + * |Argentina |`ar_cuit` |Argentinian Tax ID Number | + * |Australia |`au_abn` |Australian Business Number (AU ABN) | + * |Australia |`au_arn` |Australian Taxation Office Reference Number | + * |Austria |`eu_vat` |European VAT Number | + * |Bahrain |`bh_vat` |Bahraini VAT Number | + * |Belgium |`eu_vat` |European VAT Number | + * |Bolivia |`bo_tin` |Bolivian Tax ID | + * |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 | + * |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) | + * |Chile |`cl_tin` |Chilean TIN | + * |China |`cn_tin` |Chinese Tax ID | + * |Colombia |`co_nit` |Colombian NIT Number | + * |Costa Rica |`cr_tin` |Costa Rican Tax ID | + * |Croatia |`eu_vat` |European VAT Number | + * |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 | + * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Finland |`eu_vat` |European VAT Number | + * |France |`eu_vat` |European VAT Number | + * |Georgia |`ge_vat` |Georgian VAT | + * |Germany |`eu_vat` |European VAT Number | + * |Greece |`eu_vat` |European VAT Number | + * |Hong Kong |`hk_br` |Hong Kong BR Number | + * |Hungary |`eu_vat` |European VAT Number | + * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | + * |Iceland |`is_vat` |Icelandic VAT | + * |India |`in_gst` |Indian GST Number | + * |Indonesia |`id_npwp` |Indonesian NPWP Number | + * |Ireland |`eu_vat` |European VAT Number | + * |Israel |`il_vat` |Israel VAT | + * |Italy |`eu_vat` |European VAT Number | + * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | + * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | + * |Latvia |`eu_vat` |European VAT Number | + * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | + * |Mexico |`mx_rfc` |Mexican RFC Number | + * |Netherlands |`eu_vat` |European VAT Number | + * |New Zealand |`nz_gst` |New Zealand GST Number | + * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | + * |Norway |`no_vat` |Norwegian VAT Number | + * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | + * |Oman |`om_vat` |Omani VAT Number | + * |Peru |`pe_ruc` |Peruvian RUC Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Poland |`eu_vat` |European VAT Number | + * |Portugal |`eu_vat` |European VAT Number | + * |Romania |`eu_vat` |European VAT Number | + * |Romania |`ro_tin` |Romanian Tax ID Number | + * |Russia |`ru_inn` |Russian INN | + * |Russia |`ru_kpp` |Russian KPP | + * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | + * |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 | + * |Sweden |`eu_vat` |European VAT Number | + * |Switzerland |`ch_vat` |Switzerland VAT Number | + * |Taiwan |`tw_vat` |Taiwanese VAT | + * |Thailand |`th_vat` |Thai VAT | + * |Turkey |`tr_tin` |Turkish Tax Identification Number | + * |Ukraine |`ua_vat` |Ukrainian VAT | + * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | + * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | + * |United Kingdom |`gb_vat` |United Kingdom VAT Number | + * |United States |`us_ein` |United States EIN | + * |Uruguay |`uy_ruc` |Uruguayan RUC Number | + * |Venezuela |`ve_rif` |Venezuelan RIF Number | + * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + */ + fun customerTaxId(customerTaxId: Optional) = + customerTaxId(customerTaxId.orElse(null)) + + /** + * 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 | + * |--------------------|------------|-------------------------------------------------------------------------------------------------------| + * |Andorra |`ad_nrt` |Andorran NRT Number | + * |Argentina |`ar_cuit` |Argentinian Tax ID Number | + * |Australia |`au_abn` |Australian Business Number (AU ABN) | + * |Australia |`au_arn` |Australian Taxation Office Reference Number | + * |Austria |`eu_vat` |European VAT Number | + * |Bahrain |`bh_vat` |Bahraini VAT Number | + * |Belgium |`eu_vat` |European VAT Number | + * |Bolivia |`bo_tin` |Bolivian Tax ID | + * |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 | + * |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) | + * |Chile |`cl_tin` |Chilean TIN | + * |China |`cn_tin` |Chinese Tax ID | + * |Colombia |`co_nit` |Colombian NIT Number | + * |Costa Rica |`cr_tin` |Costa Rican Tax ID | + * |Croatia |`eu_vat` |European VAT Number | + * |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 | + * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Finland |`eu_vat` |European VAT Number | + * |France |`eu_vat` |European VAT Number | + * |Georgia |`ge_vat` |Georgian VAT | + * |Germany |`eu_vat` |European VAT Number | + * |Greece |`eu_vat` |European VAT Number | + * |Hong Kong |`hk_br` |Hong Kong BR Number | + * |Hungary |`eu_vat` |European VAT Number | + * |Hungary |`hu_tin` |Hungary Tax Number (adószám) | + * |Iceland |`is_vat` |Icelandic VAT | + * |India |`in_gst` |Indian GST Number | + * |Indonesia |`id_npwp` |Indonesian NPWP Number | + * |Ireland |`eu_vat` |European VAT Number | + * |Israel |`il_vat` |Israel VAT | + * |Italy |`eu_vat` |European VAT Number | + * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | + * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | + * |Latvia |`eu_vat` |European VAT Number | + * |Liechtenstein |`li_uid` |Liechtensteinian UID 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 | + * |Mexico |`mx_rfc` |Mexican RFC Number | + * |Netherlands |`eu_vat` |European VAT Number | + * |New Zealand |`nz_gst` |New Zealand GST Number | + * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | + * |Norway |`no_vat` |Norwegian VAT Number | + * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | + * |Oman |`om_vat` |Omani VAT Number | + * |Peru |`pe_ruc` |Peruvian RUC Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Poland |`eu_vat` |European VAT Number | + * |Portugal |`eu_vat` |European VAT Number | + * |Romania |`eu_vat` |European VAT Number | + * |Romania |`ro_tin` |Romanian Tax ID Number | + * |Russia |`ru_inn` |Russian INN | + * |Russia |`ru_kpp` |Russian KPP | + * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | + * |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 | + * |Sweden |`eu_vat` |European VAT Number | + * |Switzerland |`ch_vat` |Switzerland VAT Number | + * |Taiwan |`tw_vat` |Taiwanese VAT | + * |Thailand |`th_vat` |Thai VAT | + * |Turkey |`tr_tin` |Turkish Tax Identification Number | + * |Ukraine |`ua_vat` |Ukrainian VAT | + * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | + * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | + * |United Kingdom |`gb_vat` |United Kingdom VAT Number | + * |United States |`us_ein` |United States EIN | + * |Uruguay |`uy_ruc` |Uruguayan RUC Number | + * |Venezuela |`ve_rif` |Venezuelan RIF Number | + * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + */ + fun customerTaxId(customerTaxId: JsonField) = apply { + this.customerTaxId = customerTaxId + } + + /** + * This field is deprecated in favor of `discounts`. If a `discounts` list is provided, the + * first discount in the list will be returned. If the list is empty, `None` will be + * returned. + */ + @Deprecated("deprecated") + fun discount(discount: JsonValue) = apply { this.discount = discount } + + fun discounts(discounts: List) = discounts(JsonField.of(discounts)) + + fun discounts(discounts: JsonField>) = apply { + this.discounts = discounts.map { it.toMutableList() } + } + + fun addDiscount(discount: InvoiceLevelDiscount) = apply { + discounts = + (discounts ?: JsonField.of(mutableListOf())).also { + checkKnown("discounts", it).add(discount) + } + } + + fun addDiscount(percentage: PercentageDiscount) = + addDiscount(InvoiceLevelDiscount.ofPercentage(percentage)) + + fun addDiscount(amount: AmountDiscount) = addDiscount(InvoiceLevelDiscount.ofAmount(amount)) + + fun addDiscount(trial: TrialDiscount) = addDiscount(InvoiceLevelDiscount.ofTrial(trial)) + + fun addTrialDiscount(appliesToPriceIds: List) = + addDiscount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) + + /** + * 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)) + + /** + * When the invoice payment is due. The due date is null if the invoice is not yet + * finalized. + */ + fun dueDate(dueDate: Optional) = dueDate(dueDate.orElse(null)) + + /** + * When the invoice payment is due. The due date is null if the invoice is not yet + * finalized. + */ + 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)) + + /** + * 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: Optional) = + eligibleToIssueAt(eligibleToIssueAt.orElse(null)) + + /** + * 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: 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)) + + /** + * 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: Optional) = + hostedInvoiceUrl(hostedInvoiceUrl.orElse(null)) + + /** + * 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: JsonField) = apply { + this.hostedInvoiceUrl = hostedInvoiceUrl + } + + /** The scheduled date of the invoice */ + fun invoiceDate(invoiceDate: OffsetDateTime) = invoiceDate(JsonField.of(invoiceDate)) + + /** The scheduled date of the invoice */ + 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)) + + /** + * 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: JsonField) = apply { + this.invoiceNumber = invoiceNumber + } + + /** The link to download the PDF representation of the `Invoice`. */ + fun invoicePdf(invoicePdf: String?) = invoicePdf(JsonField.ofNullable(invoicePdf)) + + /** The link to download the PDF representation of the `Invoice`. */ + fun invoicePdf(invoicePdf: Optional) = invoicePdf(invoicePdf.orElse(null)) + + /** The link to download the PDF representation of the `Invoice`. */ + fun invoicePdf(invoicePdf: JsonField) = apply { this.invoicePdf = invoicePdf } + + fun invoiceSource(invoiceSource: InvoiceSource) = invoiceSource(JsonField.of(invoiceSource)) + + 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)) + + /** + * 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: Optional) = + issueFailedAt(issueFailedAt.orElse(null)) + + /** + * 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: 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)) + + /** + * 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: Optional) = issuedAt(issuedAt.orElse(null)) + + /** + * 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: JsonField) = apply { this.issuedAt = issuedAt } + + /** The breakdown of prices in this invoice. */ + fun lineItems(lineItems: List) = lineItems(JsonField.of(lineItems)) + + /** The breakdown of prices in this invoice. */ + fun lineItems(lineItems: JsonField>) = apply { + this.lineItems = lineItems.map { it.toMutableList() } + } + + /** The breakdown of prices in this invoice. */ + fun addLineItem(lineItem: InvoiceLineItemModel) = apply { + lineItems = + (lineItems ?: JsonField.of(mutableListOf())).also { + checkKnown("lineItems", it).add(lineItem) + } + } + + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) + + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + /** Free-form text which is available on the invoice PDF and the Orb invoice portal. */ + fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) + + /** Free-form text which is available on the invoice PDF and the Orb invoice portal. */ + fun memo(memo: Optional) = memo(memo.orElse(null)) + + /** Free-form text which is available on the invoice PDF and the Orb invoice portal. */ + 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)) + + /** + * 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: JsonField) = apply { this.metadata = metadata } + + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** + * If the invoice has a status of `paid`, this gives a timestamp when the invoice was paid. + */ + fun paidAt(paidAt: OffsetDateTime?) = paidAt(JsonField.ofNullable(paidAt)) + + /** + * If the invoice has a status of `paid`, this gives a timestamp when the invoice was paid. + */ + fun paidAt(paidAt: Optional) = paidAt(paidAt.orElse(null)) + + /** + * If the invoice has a status of `paid`, this gives a timestamp when the invoice was paid. + */ + 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)) + + /** A list of payment attempts associated with the invoice */ + fun paymentAttempts(paymentAttempts: JsonField>) = apply { + this.paymentAttempts = paymentAttempts.map { it.toMutableList() } + } + + /** A list of payment attempts associated with the invoice */ + fun addPaymentAttempt(paymentAttempt: PaymentAttemptModel) = 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)) + + /** + * If payment was attempted on this invoice but failed, this will be the time of the most + * recent attempt. + */ + fun paymentFailedAt(paymentFailedAt: Optional) = + paymentFailedAt(paymentFailedAt.orElse(null)) + + /** + * If payment was attempted on this invoice but failed, this will be the time of the most + * recent attempt. + */ + 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)) + + /** + * 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: Optional) = + paymentStartedAt(paymentStartedAt.orElse(null)) + + /** + * 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: 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)) + + /** + * If the invoice is in draft, this timestamp will reflect when the invoice is scheduled to + * be issued. + */ + fun scheduledIssueAt(scheduledIssueAt: Optional) = + scheduledIssueAt(scheduledIssueAt.orElse(null)) + + /** + * If the invoice is in draft, this timestamp will reflect when the invoice is scheduled to + * be issued. + */ + fun scheduledIssueAt(scheduledIssueAt: JsonField) = apply { + this.scheduledIssueAt = scheduledIssueAt + } + + fun shippingAddress(shippingAddress: AddressModel?) = + shippingAddress(JsonField.ofNullable(shippingAddress)) + + fun shippingAddress(shippingAddress: Optional) = + shippingAddress(shippingAddress.orElse(null)) + + fun shippingAddress(shippingAddress: JsonField) = apply { + this.shippingAddress = shippingAddress + } + + fun status(status: Status) = status(JsonField.of(status)) + + fun status(status: JsonField) = apply { this.status = status } + + fun subscription(subscription: SubscriptionMinifiedModel?) = + subscription(JsonField.ofNullable(subscription)) + + fun subscription(subscription: Optional) = + subscription(subscription.orElse(null)) + + fun subscription(subscription: JsonField) = apply { + this.subscription = subscription + } + + /** The total before any discounts and minimums are applied. */ + fun subtotal(subtotal: String) = subtotal(JsonField.of(subtotal)) + + /** The total before any discounts and minimums are applied. */ + fun subtotal(subtotal: JsonField) = apply { this.subtotal = subtotal } + + /** + * If the invoice failed to sync, this will be the last time an external invoicing provider + * sync was attempted. This field will always be `null` for invoices using Orb Invoicing. + */ + fun syncFailedAt(syncFailedAt: OffsetDateTime?) = + syncFailedAt(JsonField.ofNullable(syncFailedAt)) + + /** + * 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: Optional) = + syncFailedAt(syncFailedAt.orElse(null)) + + /** + * 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: JsonField) = apply { + this.syncFailedAt = syncFailedAt + } + + /** The total after any minimums and discounts have been applied. */ + fun total(total: String) = total(JsonField.of(total)) + + /** The total after any minimums and discounts have been applied. */ + 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)) + + /** + * If the invoice has a status of `void`, this gives a timestamp when the invoice was + * voided. + */ + fun voidedAt(voidedAt: Optional) = voidedAt(voidedAt.orElse(null)) + + /** + * If the invoice has a status of `void`, this gives a timestamp when the invoice was + * voided. + */ + 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)) + + /** + * This is true if the invoice will be automatically issued in the future, and false + * otherwise. + */ + 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) + } + + fun build(): InvoiceModel = + InvoiceModel( + checkRequired("id", id), + checkRequired("amountDue", amountDue), + checkRequired("autoCollection", autoCollection), + checkRequired("billingAddress", billingAddress), + checkRequired("createdAt", createdAt), + checkRequired("creditNotes", creditNotes).map { it.toImmutable() }, + checkRequired("currency", currency), + checkRequired("customer", customer), + checkRequired("customerBalanceTransactions", customerBalanceTransactions).map { + it.toImmutable() + }, + checkRequired("customerTaxId", customerTaxId), + checkRequired("discount", discount), + checkRequired("discounts", discounts).map { it.toImmutable() }, + checkRequired("dueDate", dueDate), + checkRequired("eligibleToIssueAt", eligibleToIssueAt), + checkRequired("hostedInvoiceUrl", hostedInvoiceUrl), + checkRequired("invoiceDate", invoiceDate), + checkRequired("invoiceNumber", invoiceNumber), + checkRequired("invoicePdf", invoicePdf), + checkRequired("invoiceSource", invoiceSource), + checkRequired("issueFailedAt", issueFailedAt), + checkRequired("issuedAt", issuedAt), + checkRequired("lineItems", lineItems).map { it.toImmutable() }, + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("memo", memo), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("paidAt", paidAt), + checkRequired("paymentAttempts", paymentAttempts).map { it.toImmutable() }, + checkRequired("paymentFailedAt", paymentFailedAt), + checkRequired("paymentStartedAt", paymentStartedAt), + checkRequired("scheduledIssueAt", scheduledIssueAt), + checkRequired("shippingAddress", shippingAddress), + checkRequired("status", status), + checkRequired("subscription", subscription), + checkRequired("subtotal", subtotal), + checkRequired("syncFailedAt", syncFailedAt), + checkRequired("total", total), + checkRequired("voidedAt", voidedAt), + checkRequired("willAutoIssue", willAutoIssue), + additionalProperties.toImmutable(), + ) + } + + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InvoiceSource && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an empty + * dictionary. Individual keys can be removed by setting the value to `null`, and the entire + * metadata mapping can be cleared by setting `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InvoiceModel && id == other.id && amountDue == other.amountDue && autoCollection == other.autoCollection && billingAddress == other.billingAddress && createdAt == other.createdAt && creditNotes == other.creditNotes && currency == other.currency && customer == other.customer && customerBalanceTransactions == other.customerBalanceTransactions && customerTaxId == other.customerTaxId && discount == other.discount && discounts == other.discounts && dueDate == other.dueDate && eligibleToIssueAt == other.eligibleToIssueAt && hostedInvoiceUrl == other.hostedInvoiceUrl && invoiceDate == other.invoiceDate && invoiceNumber == other.invoiceNumber && invoicePdf == other.invoicePdf && invoiceSource == other.invoiceSource && issueFailedAt == other.issueFailedAt && issuedAt == other.issuedAt && lineItems == other.lineItems && maximum == other.maximum && maximumAmount == other.maximumAmount && memo == other.memo && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && paidAt == other.paidAt && paymentAttempts == other.paymentAttempts && paymentFailedAt == other.paymentFailedAt && paymentStartedAt == other.paymentStartedAt && scheduledIssueAt == other.scheduledIssueAt && shippingAddress == other.shippingAddress && status == other.status && subscription == other.subscription && subtotal == other.subtotal && syncFailedAt == other.syncFailedAt && total == other.total && voidedAt == other.voidedAt && willAutoIssue == other.willAutoIssue && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, amountDue, autoCollection, billingAddress, createdAt, creditNotes, currency, customer, customerBalanceTransactions, customerTaxId, discount, discounts, dueDate, eligibleToIssueAt, hostedInvoiceUrl, invoiceDate, invoiceNumber, invoicePdf, invoiceSource, issueFailedAt, issuedAt, lineItems, maximum, maximumAmount, memo, metadata, minimum, minimumAmount, paidAt, paymentAttempts, paymentFailedAt, paymentStartedAt, scheduledIssueAt, shippingAddress, status, subscription, subtotal, syncFailedAt, total, voidedAt, willAutoIssue, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InvoiceModel{id=$id, amountDue=$amountDue, autoCollection=$autoCollection, billingAddress=$billingAddress, createdAt=$createdAt, creditNotes=$creditNotes, currency=$currency, customer=$customer, customerBalanceTransactions=$customerBalanceTransactions, customerTaxId=$customerTaxId, discount=$discount, discounts=$discounts, dueDate=$dueDate, eligibleToIssueAt=$eligibleToIssueAt, hostedInvoiceUrl=$hostedInvoiceUrl, invoiceDate=$invoiceDate, invoiceNumber=$invoiceNumber, invoicePdf=$invoicePdf, invoiceSource=$invoiceSource, issueFailedAt=$issueFailedAt, issuedAt=$issuedAt, lineItems=$lineItems, maximum=$maximum, maximumAmount=$maximumAmount, memo=$memo, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, paidAt=$paidAt, paymentAttempts=$paymentAttempts, paymentFailedAt=$paymentFailedAt, paymentStartedAt=$paymentStartedAt, scheduledIssueAt=$scheduledIssueAt, shippingAddress=$shippingAddress, status=$status, subscription=$subscription, subtotal=$subtotal, syncFailedAt=$syncFailedAt, total=$total, voidedAt=$voidedAt, willAutoIssue=$willAutoIssue, additionalProperties=$additionalProperties}" +} 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 c6a544b6d..1b7b255a0 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 @@ -51,6 +51,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [InvoicePayParams]. + * + * The following fields are required: + * ```java + * .invoiceId() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 579eaa158..dfe34da26 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 @@ -113,6 +113,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Body]. */ @JvmStatic fun builder() = Builder() } @@ -193,6 +194,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [InvoiceUpdateParams]. + * + * The following fields are required: + * ```java + * .invoiceId() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -393,6 +402,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceVoidInvoiceParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceVoidInvoiceParams.kt index 17d740292..a0c60698c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceVoidInvoiceParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceVoidInvoiceParams.kt @@ -58,6 +58,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [InvoiceVoidInvoiceParams]. + * + * The following fields are required: + * ```java + * .invoiceId() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 89df66505..5bdc8aa8c 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 @@ -6,16 +6,15 @@ 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.NoAutoDetect +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.immutableEmptyMap import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import java.util.Objects @@ -34,7 +33,8 @@ private constructor( private val createdAt: JsonField = JsonMissing.of(), @JsonProperty("external_connections") @ExcludeMissing - private val externalConnections: JsonField> = JsonMissing.of(), + private val externalConnections: JsonField> = + JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -43,7 +43,7 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - fun externalConnections(): List = + fun externalConnections(): List = externalConnections.getRequired("external_connections") fun name(): String = name.getRequired("name") @@ -56,7 +56,7 @@ private constructor( @JsonProperty("external_connections") @ExcludeMissing - fun _externalConnections(): JsonField> = externalConnections + fun _externalConnections(): JsonField> = externalConnections @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @@ -82,6 +82,17 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Item]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .externalConnections() + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -90,7 +101,7 @@ private constructor( private var id: JsonField? = null private var createdAt: JsonField? = null - private var externalConnections: JsonField>? = null + private var externalConnections: JsonField>? = null private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -111,23 +122,18 @@ private constructor( fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - fun externalConnections(externalConnections: List) = + fun externalConnections(externalConnections: List) = externalConnections(JsonField.of(externalConnections)) - fun externalConnections(externalConnections: JsonField>) = apply { - this.externalConnections = externalConnections.map { it.toMutableList() } - } + fun externalConnections(externalConnections: JsonField>) = + apply { + this.externalConnections = externalConnections.map { it.toMutableList() } + } - fun addExternalConnection(externalConnection: ExternalConnection) = apply { + fun addExternalConnection(externalConnection: ItemExternalConnectionModel) = apply { externalConnections = - (externalConnections ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(externalConnection) + (externalConnections ?: JsonField.of(mutableListOf())).also { + checkKnown("externalConnections", it).add(externalConnection) } } @@ -164,265 +170,6 @@ private constructor( ) } - @NoAutoDetect - class ExternalConnection - @JsonCreator - private constructor( - @JsonProperty("external_connection_name") - @ExcludeMissing - private val externalConnectionName: JsonField = JsonMissing.of(), - @JsonProperty("external_entity_id") - @ExcludeMissing - private val externalEntityId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun externalConnectionName(): ExternalConnectionName = - externalConnectionName.getRequired("external_connection_name") - - fun externalEntityId(): String = externalEntityId.getRequired("external_entity_id") - - @JsonProperty("external_connection_name") - @ExcludeMissing - fun _externalConnectionName(): JsonField = externalConnectionName - - @JsonProperty("external_entity_id") - @ExcludeMissing - fun _externalEntityId(): JsonField = externalEntityId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): ExternalConnection = apply { - if (validated) { - return@apply - } - - externalConnectionName() - externalEntityId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ExternalConnection]. */ - class Builder internal constructor() { - - private var externalConnectionName: JsonField? = null - private var externalEntityId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(externalConnection: ExternalConnection) = apply { - externalConnectionName = externalConnection.externalConnectionName - externalEntityId = externalConnection.externalEntityId - additionalProperties = externalConnection.additionalProperties.toMutableMap() - } - - fun externalConnectionName(externalConnectionName: ExternalConnectionName) = - externalConnectionName(JsonField.of(externalConnectionName)) - - fun externalConnectionName(externalConnectionName: JsonField) = - apply { - this.externalConnectionName = externalConnectionName - } - - fun externalEntityId(externalEntityId: String) = - externalEntityId(JsonField.of(externalEntityId)) - - fun externalEntityId(externalEntityId: JsonField) = apply { - this.externalEntityId = externalEntityId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): ExternalConnection = - ExternalConnection( - checkRequired("externalConnectionName", externalConnectionName), - checkRequired("externalEntityId", externalEntityId), - additionalProperties.toImmutable(), - ) - } - - class ExternalConnectionName - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API 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") - - @JvmField val QUICKBOOKS = of("quickbooks") - - @JvmField val BILL_COM = of("bill.com") - - @JvmField val NETSUITE = of("netsuite") - - @JvmField val TAXJAR = of("taxjar") - - @JvmField val AVALARA = of("avalara") - - @JvmField val ANROK = of("anrok") - - @JvmStatic fun of(value: String) = ExternalConnectionName(JsonField.of(value)) - } - - /** An enum containing [ExternalConnectionName]'s known values. */ - enum class Known { - STRIPE, - QUICKBOOKS, - BILL_COM, - NETSUITE, - TAXJAR, - AVALARA, - ANROK, - } - - /** - * An enum containing [ExternalConnectionName]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ExternalConnectionName] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may 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, - QUICKBOOKS, - BILL_COM, - NETSUITE, - TAXJAR, - AVALARA, - ANROK, - /** - * An enum member indicating that [ExternalConnectionName] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 - QUICKBOOKS -> Value.QUICKBOOKS - BILL_COM -> Value.BILL_COM - NETSUITE -> Value.NETSUITE - TAXJAR -> Value.TAXJAR - AVALARA -> Value.AVALARA - ANROK -> Value.ANROK - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to 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 - QUICKBOOKS -> Known.QUICKBOOKS - BILL_COM -> Known.BILL_COM - NETSUITE -> Known.NETSUITE - TAXJAR -> Known.TAXJAR - AVALARA -> Known.AVALARA - ANROK -> Known.ANROK - else -> throw OrbInvalidDataException("Unknown ExternalConnectionName: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is ExternalConnectionName && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ExternalConnection && externalConnectionName == other.externalConnectionName && externalEntityId == other.externalEntityId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(externalConnectionName, externalEntityId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ExternalConnection{externalConnectionName=$externalConnectionName, externalEntityId=$externalEntityId, 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/ItemCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemCreateParams.kt index f8cfdcf7f..84527b503 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 @@ -81,6 +81,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -146,6 +154,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ItemCreateParams]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemExternalConnectionModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemExternalConnectionModel.kt new file mode 100644 index 000000000..a68e5960d --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemExternalConnectionModel.kt @@ -0,0 +1,285 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Objects + +@NoAutoDetect +class ItemExternalConnectionModel +@JsonCreator +private constructor( + @JsonProperty("external_connection_name") + @ExcludeMissing + private val externalConnectionName: JsonField = JsonMissing.of(), + @JsonProperty("external_entity_id") + @ExcludeMissing + private val externalEntityId: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun externalConnectionName(): ExternalConnectionName = + externalConnectionName.getRequired("external_connection_name") + + fun externalEntityId(): String = externalEntityId.getRequired("external_entity_id") + + @JsonProperty("external_connection_name") + @ExcludeMissing + fun _externalConnectionName(): JsonField = externalConnectionName + + @JsonProperty("external_entity_id") + @ExcludeMissing + fun _externalEntityId(): JsonField = externalEntityId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): ItemExternalConnectionModel = apply { + if (validated) { + return@apply + } + + externalConnectionName() + externalEntityId() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ItemExternalConnectionModel]. + * + * The following fields are required: + * ```java + * .externalConnectionName() + * .externalEntityId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ItemExternalConnectionModel]. */ + class Builder internal constructor() { + + private var externalConnectionName: JsonField? = null + private var externalEntityId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(itemExternalConnectionModel: ItemExternalConnectionModel) = apply { + externalConnectionName = itemExternalConnectionModel.externalConnectionName + externalEntityId = itemExternalConnectionModel.externalEntityId + additionalProperties = itemExternalConnectionModel.additionalProperties.toMutableMap() + } + + fun externalConnectionName(externalConnectionName: ExternalConnectionName) = + externalConnectionName(JsonField.of(externalConnectionName)) + + fun externalConnectionName(externalConnectionName: JsonField) = + apply { + this.externalConnectionName = externalConnectionName + } + + fun externalEntityId(externalEntityId: String) = + externalEntityId(JsonField.of(externalEntityId)) + + fun externalEntityId(externalEntityId: JsonField) = apply { + this.externalEntityId = externalEntityId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): ItemExternalConnectionModel = + ItemExternalConnectionModel( + checkRequired("externalConnectionName", externalConnectionName), + checkRequired("externalEntityId", externalEntityId), + additionalProperties.toImmutable(), + ) + } + + class ExternalConnectionName + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API 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") + + @JvmField val QUICKBOOKS = of("quickbooks") + + @JvmField val BILL_COM = of("bill.com") + + @JvmField val NETSUITE = of("netsuite") + + @JvmField val TAXJAR = of("taxjar") + + @JvmField val AVALARA = of("avalara") + + @JvmField val ANROK = of("anrok") + + @JvmStatic fun of(value: String) = ExternalConnectionName(JsonField.of(value)) + } + + /** An enum containing [ExternalConnectionName]'s known values. */ + enum class Known { + STRIPE, + QUICKBOOKS, + BILL_COM, + NETSUITE, + TAXJAR, + AVALARA, + ANROK, + } + + /** + * An enum containing [ExternalConnectionName]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [ExternalConnectionName] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may 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, + QUICKBOOKS, + BILL_COM, + NETSUITE, + TAXJAR, + AVALARA, + ANROK, + /** + * An enum member indicating that [ExternalConnectionName] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead 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 + QUICKBOOKS -> Value.QUICKBOOKS + BILL_COM -> Value.BILL_COM + NETSUITE -> Value.NETSUITE + TAXJAR -> Value.TAXJAR + AVALARA -> Value.AVALARA + ANROK -> Value.ANROK + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to 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 + QUICKBOOKS -> Known.QUICKBOOKS + BILL_COM -> Known.BILL_COM + NETSUITE -> Known.NETSUITE + TAXJAR -> Known.TAXJAR + AVALARA -> Known.AVALARA + ANROK -> Known.ANROK + else -> throw OrbInvalidDataException("Unknown ExternalConnectionName: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if 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 + } + + return /* spotless:off */ other is ExternalConnectionName && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ItemExternalConnectionModel && externalConnectionName == other.externalConnectionName && externalEntityId == other.externalEntityId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(externalConnectionName, externalEntityId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ItemExternalConnectionModel{externalConnectionName=$externalConnectionName, externalEntityId=$externalEntityId, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemFetchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemFetchParams.kt index e0d9388ee..d1f529947 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemFetchParams.kt @@ -38,6 +38,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ItemFetchParams]. + * + * The following fields are required: + * ```java + * .itemId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListPage.kt index ba8aaf7c7..97ae7fb6e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListPage.kt @@ -29,7 +29,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -84,20 +84,20 @@ private constructor( class Response @JsonCreator constructor( - @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), + @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = Optional.ofNullable(data) + fun _data(): Optional>> = Optional.ofNullable(data) @JsonProperty("pagination_metadata") fun _paginationMetadata(): Optional> = @@ -136,12 +136,13 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [ItemListPage]. */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -152,9 +153,9 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { this.data = data } fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) @@ -171,9 +172,9 @@ private constructor( } } - class AutoPager(private val firstPage: ItemListPage) : Iterable { + class AutoPager(private val firstPage: ItemListPage) : Iterable { - override fun iterator(): Iterator = iterator { + override fun iterator(): Iterator = iterator { var page = firstPage var index = 0 while (true) { @@ -185,7 +186,7 @@ private constructor( } } - fun stream(): Stream { + fun stream(): Stream { return StreamSupport.stream(spliterator(), false) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListPageAsync.kt index fd6308b48..ea3ea4682 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListPageAsync.kt @@ -30,7 +30,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -87,20 +87,20 @@ private constructor( class Response @JsonCreator constructor( - @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), + @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = Optional.ofNullable(data) + fun _data(): Optional>> = Optional.ofNullable(data) @JsonProperty("pagination_metadata") fun _paginationMetadata(): Optional> = @@ -139,12 +139,13 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [ItemListPageAsync]. */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -155,9 +156,9 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { this.data = data } fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) @@ -176,9 +177,9 @@ private constructor( class AutoPager(private val firstPage: ItemListPageAsync) { - fun forEach(action: Predicate, executor: Executor): CompletableFuture { + fun forEach(action: Predicate, executor: Executor): CompletableFuture { fun CompletableFuture>.forEach( - action: (Item) -> Boolean, + action: (ItemModel) -> Boolean, executor: Executor, ): CompletableFuture = thenComposeAsync( @@ -194,8 +195,8 @@ private constructor( .forEach(action::test, executor) } - fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() + fun toList(executor: Executor): CompletableFuture> { + val values = mutableListOf() return forEach(values::add, executor).thenApply { values } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListParams.kt index 0d221c9d2..3872986ba 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListParams.kt @@ -47,6 +47,7 @@ private constructor( @JvmStatic fun none(): ItemListParams = builder().build() + /** Returns a mutable builder for constructing an instance of [ItemListParams]. */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemModel.kt new file mode 100644 index 000000000..6d31f8fc4 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemModel.kt @@ -0,0 +1,189 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.time.OffsetDateTime +import java.util.Objects + +/** + * 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. + */ +@NoAutoDetect +class ItemModel +@JsonCreator +private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("external_connections") + @ExcludeMissing + private val externalConnections: JsonField> = + JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun id(): String = id.getRequired("id") + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + fun externalConnections(): List = + externalConnections.getRequired("external_connections") + + fun name(): String = name.getRequired("name") + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + @JsonProperty("external_connections") + @ExcludeMissing + fun _externalConnections(): JsonField> = externalConnections + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): ItemModel = apply { + if (validated) { + return@apply + } + + id() + createdAt() + externalConnections().forEach { it.validate() } + name() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ItemModel]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .externalConnections() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ItemModel]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var createdAt: JsonField? = null + private var externalConnections: JsonField>? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(itemModel: ItemModel) = apply { + id = itemModel.id + createdAt = itemModel.createdAt + externalConnections = itemModel.externalConnections.map { it.toMutableList() } + name = itemModel.name + additionalProperties = itemModel.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + fun externalConnections(externalConnections: List) = + externalConnections(JsonField.of(externalConnections)) + + fun externalConnections(externalConnections: JsonField>) = + apply { + this.externalConnections = externalConnections.map { it.toMutableList() } + } + + fun addExternalConnection(externalConnection: ItemExternalConnectionModel) = apply { + externalConnections = + (externalConnections ?: JsonField.of(mutableListOf())).also { + checkKnown("externalConnections", it).add(externalConnection) + } + } + + fun name(name: String) = name(JsonField.of(name)) + + 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) + } + + fun build(): ItemModel = + ItemModel( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("externalConnections", externalConnections).map { it.toImmutable() }, + checkRequired("name", name), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ItemModel && id == other.id && createdAt == other.createdAt && externalConnections == other.externalConnections && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, createdAt, externalConnections, name, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ItemModel{id=$id, createdAt=$createdAt, externalConnections=$externalConnections, name=$name, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemSlimModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemSlimModel.kt new file mode 100644 index 000000000..d94cace5c --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemSlimModel.kt @@ -0,0 +1,133 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects + +@NoAutoDetect +class ItemSlimModel +@JsonCreator +private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun id(): String = id.getRequired("id") + + fun name(): String = name.getRequired("name") + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): ItemSlimModel = apply { + if (validated) { + return@apply + } + + id() + name() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ItemSlimModel]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ItemSlimModel]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(itemSlimModel: ItemSlimModel) = apply { + id = itemSlimModel.id + name = itemSlimModel.name + additionalProperties = itemSlimModel.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun name(name: String) = name(JsonField.of(name)) + + 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) + } + + fun build(): ItemSlimModel = + ItemSlimModel( + checkRequired("id", id), + checkRequired("name", name), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ItemSlimModel && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ItemSlimModel{id=$id, name=$name, additionalProperties=$additionalProperties}" +} 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 08b73fc13..4657ed77a 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 @@ -6,19 +6,18 @@ 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.NoAutoDetect import com.withorb.api.core.Params +import com.withorb.api.core.checkKnown 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.immutableEmptyMap import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException import java.util.Objects import java.util.Optional @@ -33,11 +32,13 @@ private constructor( fun itemId(): String = itemId - fun externalConnections(): Optional> = body.externalConnections() + fun externalConnections(): Optional> = + body.externalConnections() fun name(): Optional = body.name() - fun _externalConnections(): JsonField> = body._externalConnections() + fun _externalConnections(): JsonField> = + body._externalConnections() fun _name(): JsonField = body._name() @@ -71,7 +72,8 @@ private constructor( private constructor( @JsonProperty("external_connections") @ExcludeMissing - private val externalConnections: JsonField> = JsonMissing.of(), + private val externalConnections: JsonField> = + JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), @@ -79,14 +81,15 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - fun externalConnections(): Optional> = + fun externalConnections(): Optional> = Optional.ofNullable(externalConnections.getNullable("external_connections")) fun name(): Optional = Optional.ofNullable(name.getNullable("name")) @JsonProperty("external_connections") @ExcludeMissing - fun _externalConnections(): JsonField> = externalConnections + fun _externalConnections(): JsonField> = + externalConnections @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @@ -110,13 +113,15 @@ private constructor( 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 externalConnections: JsonField>? = null + private var externalConnections: JsonField>? = + null private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -127,27 +132,21 @@ private constructor( additionalProperties = body.additionalProperties.toMutableMap() } - fun externalConnections(externalConnections: List?) = + fun externalConnections(externalConnections: List?) = externalConnections(JsonField.ofNullable(externalConnections)) - fun externalConnections(externalConnections: Optional>) = - externalConnections(externalConnections.orElse(null)) + fun externalConnections( + externalConnections: Optional> + ) = externalConnections(externalConnections.orElse(null)) - fun externalConnections(externalConnections: JsonField>) = - apply { - this.externalConnections = externalConnections.map { it.toMutableList() } - } + fun externalConnections( + externalConnections: JsonField> + ) = apply { this.externalConnections = externalConnections.map { it.toMutableList() } } - fun addExternalConnection(externalConnection: ExternalConnection) = apply { + fun addExternalConnection(externalConnection: ItemExternalConnectionModel) = apply { externalConnections = - (externalConnections ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(externalConnection) + (externalConnections ?: JsonField.of(mutableListOf())).also { + checkKnown("externalConnections", it).add(externalConnection) } } @@ -206,6 +205,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [ItemUpdateParams]. + * + * The following fields are required: + * ```java + * .itemId() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -228,18 +235,19 @@ private constructor( fun itemId(itemId: String) = apply { this.itemId = itemId } - fun externalConnections(externalConnections: List?) = apply { + fun externalConnections(externalConnections: List?) = apply { body.externalConnections(externalConnections) } - fun externalConnections(externalConnections: Optional>) = + fun externalConnections(externalConnections: Optional>) = externalConnections(externalConnections.orElse(null)) - fun externalConnections(externalConnections: JsonField>) = apply { - body.externalConnections(externalConnections) - } + fun externalConnections(externalConnections: JsonField>) = + apply { + body.externalConnections(externalConnections) + } - fun addExternalConnection(externalConnection: ExternalConnection) = apply { + fun addExternalConnection(externalConnection: ItemExternalConnectionModel) = apply { body.addExternalConnection(externalConnection) } @@ -375,265 +383,6 @@ private constructor( ) } - @NoAutoDetect - class ExternalConnection - @JsonCreator - private constructor( - @JsonProperty("external_connection_name") - @ExcludeMissing - private val externalConnectionName: JsonField = JsonMissing.of(), - @JsonProperty("external_entity_id") - @ExcludeMissing - private val externalEntityId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun externalConnectionName(): ExternalConnectionName = - externalConnectionName.getRequired("external_connection_name") - - fun externalEntityId(): String = externalEntityId.getRequired("external_entity_id") - - @JsonProperty("external_connection_name") - @ExcludeMissing - fun _externalConnectionName(): JsonField = externalConnectionName - - @JsonProperty("external_entity_id") - @ExcludeMissing - fun _externalEntityId(): JsonField = externalEntityId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): ExternalConnection = apply { - if (validated) { - return@apply - } - - externalConnectionName() - externalEntityId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ExternalConnection]. */ - class Builder internal constructor() { - - private var externalConnectionName: JsonField? = null - private var externalEntityId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(externalConnection: ExternalConnection) = apply { - externalConnectionName = externalConnection.externalConnectionName - externalEntityId = externalConnection.externalEntityId - additionalProperties = externalConnection.additionalProperties.toMutableMap() - } - - fun externalConnectionName(externalConnectionName: ExternalConnectionName) = - externalConnectionName(JsonField.of(externalConnectionName)) - - fun externalConnectionName(externalConnectionName: JsonField) = - apply { - this.externalConnectionName = externalConnectionName - } - - fun externalEntityId(externalEntityId: String) = - externalEntityId(JsonField.of(externalEntityId)) - - fun externalEntityId(externalEntityId: JsonField) = apply { - this.externalEntityId = externalEntityId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): ExternalConnection = - ExternalConnection( - checkRequired("externalConnectionName", externalConnectionName), - checkRequired("externalEntityId", externalEntityId), - additionalProperties.toImmutable(), - ) - } - - class ExternalConnectionName - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API 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") - - @JvmField val QUICKBOOKS = of("quickbooks") - - @JvmField val BILL_COM = of("bill.com") - - @JvmField val NETSUITE = of("netsuite") - - @JvmField val TAXJAR = of("taxjar") - - @JvmField val AVALARA = of("avalara") - - @JvmField val ANROK = of("anrok") - - @JvmStatic fun of(value: String) = ExternalConnectionName(JsonField.of(value)) - } - - /** An enum containing [ExternalConnectionName]'s known values. */ - enum class Known { - STRIPE, - QUICKBOOKS, - BILL_COM, - NETSUITE, - TAXJAR, - AVALARA, - ANROK, - } - - /** - * An enum containing [ExternalConnectionName]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ExternalConnectionName] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may 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, - QUICKBOOKS, - BILL_COM, - NETSUITE, - TAXJAR, - AVALARA, - ANROK, - /** - * An enum member indicating that [ExternalConnectionName] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 - QUICKBOOKS -> Value.QUICKBOOKS - BILL_COM -> Value.BILL_COM - NETSUITE -> Value.NETSUITE - TAXJAR -> Value.TAXJAR - AVALARA -> Value.AVALARA - ANROK -> Value.ANROK - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to 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 - QUICKBOOKS -> Known.QUICKBOOKS - BILL_COM -> Known.BILL_COM - NETSUITE -> Known.NETSUITE - TAXJAR -> Known.TAXJAR - AVALARA -> Known.AVALARA - ANROK -> Known.ANROK - else -> throw OrbInvalidDataException("Unknown ExternalConnectionName: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is ExternalConnectionName && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ExternalConnection && externalConnectionName == other.externalConnectionName && externalEntityId == other.externalEntityId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(externalConnectionName, externalEntityId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ExternalConnection{externalConnectionName=$externalConnectionName, externalEntityId=$externalEntityId, 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/MatrixConfigModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MatrixConfigModel.kt new file mode 100644 index 000000000..c90790191 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MatrixConfigModel.kt @@ -0,0 +1,196 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects + +@NoAutoDetect +class MatrixConfigModel +@JsonCreator +private constructor( + @JsonProperty("default_unit_amount") + @ExcludeMissing + private val defaultUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("dimensions") + @ExcludeMissing + private val dimensions: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_values") + @ExcludeMissing + private val matrixValues: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** Default per unit rate for any usage not bucketed into a specified matrix_value */ + fun defaultUnitAmount(): String = defaultUnitAmount.getRequired("default_unit_amount") + + /** One or two event property values to evaluate matrix groups by */ + fun dimensions(): List = dimensions.getRequired("dimensions") + + /** Matrix values for specified matrix grouping keys */ + fun matrixValues(): List = matrixValues.getRequired("matrix_values") + + /** Default per unit rate for any usage not bucketed into a specified matrix_value */ + @JsonProperty("default_unit_amount") + @ExcludeMissing + fun _defaultUnitAmount(): JsonField = defaultUnitAmount + + /** One or two event property values to evaluate matrix groups by */ + @JsonProperty("dimensions") + @ExcludeMissing + fun _dimensions(): JsonField> = dimensions + + /** Matrix values for specified matrix grouping keys */ + @JsonProperty("matrix_values") + @ExcludeMissing + fun _matrixValues(): JsonField> = matrixValues + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): MatrixConfigModel = apply { + if (validated) { + return@apply + } + + defaultUnitAmount() + dimensions() + matrixValues().forEach { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MatrixConfigModel]. + * + * The following fields are required: + * ```java + * .defaultUnitAmount() + * .dimensions() + * .matrixValues() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixConfigModel]. */ + class Builder internal constructor() { + + private var defaultUnitAmount: JsonField? = null + private var dimensions: JsonField>? = null + private var matrixValues: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(matrixConfigModel: MatrixConfigModel) = apply { + defaultUnitAmount = matrixConfigModel.defaultUnitAmount + dimensions = matrixConfigModel.dimensions.map { it.toMutableList() } + matrixValues = matrixConfigModel.matrixValues.map { it.toMutableList() } + additionalProperties = matrixConfigModel.additionalProperties.toMutableMap() + } + + /** Default per unit rate for any usage not bucketed into a specified matrix_value */ + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) + + /** Default per unit rate for any usage not bucketed into a specified matrix_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)) + + /** One or two event property values to evaluate matrix groups by */ + fun dimensions(dimensions: JsonField>) = apply { + this.dimensions = dimensions.map { it.toMutableList() } + } + + /** One or two event property values to evaluate matrix groups by */ + fun addDimension(dimension: String) = apply { + dimensions = + (dimensions ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensions", it).add(dimension) + } + } + + /** Matrix values for specified matrix grouping keys */ + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) + + /** Matrix values for specified matrix grouping keys */ + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues.map { it.toMutableList() } + } + + /** Matrix values for specified matrix grouping keys */ + fun addMatrixValue(matrixValue: MatrixValueModel) = 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) + } + + fun build(): MatrixConfigModel = + MatrixConfigModel( + checkRequired("defaultUnitAmount", defaultUnitAmount), + checkRequired("dimensions", dimensions).map { it.toImmutable() }, + checkRequired("matrixValues", matrixValues).map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MatrixConfigModel && defaultUnitAmount == other.defaultUnitAmount && dimensions == other.dimensions && matrixValues == other.matrixValues && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(defaultUnitAmount, dimensions, matrixValues, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixConfigModel{defaultUnitAmount=$defaultUnitAmount, dimensions=$dimensions, matrixValues=$matrixValues, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/MatrixValueModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MatrixValueModel.kt new file mode 100644 index 000000000..01e9e0afb --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MatrixValueModel.kt @@ -0,0 +1,179 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects + +@NoAutoDetect +class MatrixValueModel +@JsonCreator +private constructor( + @JsonProperty("dimension_values") + @ExcludeMissing + private val dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + private val unitAmount: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** + * One or two matrix keys to filter usage to this Matrix value by. For example, + * ["region", "tier"] could be used to filter cloud usage by a cloud region and an instance + * tier. + */ + fun dimensionValues(): List = dimensionValues.getRequired("dimension_values") + + /** Unit price for the specified dimension_values */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * One or two matrix keys to filter usage to this Matrix value by. For example, + * ["region", "tier"] could be used to filter cloud usage by a cloud region and an instance + * tier. + */ + @JsonProperty("dimension_values") + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues + + /** Unit price for the specified dimension_values */ + @JsonProperty("unit_amount") @ExcludeMissing fun _unitAmount(): JsonField = unitAmount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): MatrixValueModel = apply { + if (validated) { + return@apply + } + + dimensionValues() + unitAmount() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MatrixValueModel]. + * + * The following fields are required: + * ```java + * .dimensionValues() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixValueModel]. */ + class Builder internal constructor() { + + private var dimensionValues: JsonField>? = null + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(matrixValueModel: MatrixValueModel) = apply { + dimensionValues = matrixValueModel.dimensionValues.map { it.toMutableList() } + unitAmount = matrixValueModel.unitAmount + additionalProperties = matrixValueModel.additionalProperties.toMutableMap() + } + + /** + * One or two matrix keys to filter usage to this Matrix value by. For example, + * ["region", "tier"] could be used to filter cloud usage by a cloud region and an instance + * tier. + */ + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) + + /** + * One or two matrix keys to filter usage to this Matrix value by. For example, + * ["region", "tier"] could be used to filter cloud usage by a cloud region and an instance + * tier. + */ + fun dimensionValues(dimensionValues: JsonField>) = apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } + } + + /** + * One or two matrix keys to filter usage to this Matrix value by. For example, + * ["region", "tier"] could be used to filter cloud usage by a cloud region and an instance + * tier. + */ + fun addDimensionValue(dimensionValue: String) = apply { + dimensionValues = + (dimensionValues ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensionValues", it).add(dimensionValue) + } + } + + /** Unit price for the specified dimension_values */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** Unit price for the specified dimension_values */ + 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 build(): MatrixValueModel = + MatrixValueModel( + checkRequired("dimensionValues", dimensionValues).map { it.toImmutable() }, + checkRequired("unitAmount", unitAmount), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MatrixValueModel && dimensionValues == other.dimensionValues && unitAmount == other.unitAmount && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(dimensionValues, unitAmount, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixValueModel{dimensionValues=$dimensionValues, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/MatrixWithAllocationConfigModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MatrixWithAllocationConfigModel.kt new file mode 100644 index 000000000..cd31fb7aa --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MatrixWithAllocationConfigModel.kt @@ -0,0 +1,220 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects + +@NoAutoDetect +class MatrixWithAllocationConfigModel +@JsonCreator +private constructor( + @JsonProperty("allocation") + @ExcludeMissing + private val allocation: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_amount") + @ExcludeMissing + private val defaultUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("dimensions") + @ExcludeMissing + private val dimensions: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_values") + @ExcludeMissing + private val matrixValues: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** Allocation to be used to calculate the price */ + fun allocation(): Double = allocation.getRequired("allocation") + + /** Default per unit rate for any usage not bucketed into a specified matrix_value */ + fun defaultUnitAmount(): String = defaultUnitAmount.getRequired("default_unit_amount") + + /** One or two event property values to evaluate matrix groups by */ + fun dimensions(): List = dimensions.getRequired("dimensions") + + /** Matrix values for specified matrix grouping keys */ + fun matrixValues(): List = matrixValues.getRequired("matrix_values") + + /** Allocation to be used to calculate the price */ + @JsonProperty("allocation") @ExcludeMissing fun _allocation(): JsonField = allocation + + /** Default per unit rate for any usage not bucketed into a specified matrix_value */ + @JsonProperty("default_unit_amount") + @ExcludeMissing + fun _defaultUnitAmount(): JsonField = defaultUnitAmount + + /** One or two event property values to evaluate matrix groups by */ + @JsonProperty("dimensions") + @ExcludeMissing + fun _dimensions(): JsonField> = dimensions + + /** Matrix values for specified matrix grouping keys */ + @JsonProperty("matrix_values") + @ExcludeMissing + fun _matrixValues(): JsonField> = matrixValues + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): MatrixWithAllocationConfigModel = apply { + if (validated) { + return@apply + } + + allocation() + defaultUnitAmount() + dimensions() + matrixValues().forEach { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixWithAllocationConfigModel]. + * + * The following fields are required: + * ```java + * .allocation() + * .defaultUnitAmount() + * .dimensions() + * .matrixValues() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixWithAllocationConfigModel]. */ + class Builder internal constructor() { + + private var allocation: JsonField? = null + private var defaultUnitAmount: JsonField? = null + private var dimensions: JsonField>? = null + private var matrixValues: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(matrixWithAllocationConfigModel: MatrixWithAllocationConfigModel) = + apply { + allocation = matrixWithAllocationConfigModel.allocation + defaultUnitAmount = matrixWithAllocationConfigModel.defaultUnitAmount + dimensions = matrixWithAllocationConfigModel.dimensions.map { it.toMutableList() } + matrixValues = + matrixWithAllocationConfigModel.matrixValues.map { it.toMutableList() } + additionalProperties = + matrixWithAllocationConfigModel.additionalProperties.toMutableMap() + } + + /** Allocation to be used to calculate the price */ + fun allocation(allocation: Double) = allocation(JsonField.of(allocation)) + + /** Allocation to be used to calculate the price */ + fun allocation(allocation: JsonField) = apply { this.allocation = allocation } + + /** Default per unit rate for any usage not bucketed into a specified matrix_value */ + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) + + /** Default per unit rate for any usage not bucketed into a specified matrix_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)) + + /** One or two event property values to evaluate matrix groups by */ + fun dimensions(dimensions: JsonField>) = apply { + this.dimensions = dimensions.map { it.toMutableList() } + } + + /** One or two event property values to evaluate matrix groups by */ + fun addDimension(dimension: String) = apply { + dimensions = + (dimensions ?: JsonField.of(mutableListOf())).also { + checkKnown("dimensions", it).add(dimension) + } + } + + /** Matrix values for specified matrix grouping keys */ + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) + + /** Matrix values for specified matrix grouping keys */ + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues.map { it.toMutableList() } + } + + /** Matrix values for specified matrix grouping keys */ + fun addMatrixValue(matrixValue: MatrixValueModel) = 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) + } + + fun build(): MatrixWithAllocationConfigModel = + MatrixWithAllocationConfigModel( + checkRequired("allocation", allocation), + checkRequired("defaultUnitAmount", defaultUnitAmount), + checkRequired("dimensions", dimensions).map { it.toImmutable() }, + checkRequired("matrixValues", matrixValues).map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MatrixWithAllocationConfigModel && allocation == other.allocation && defaultUnitAmount == other.defaultUnitAmount && dimensions == other.dimensions && matrixValues == other.matrixValues && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(allocation, defaultUnitAmount, dimensions, matrixValues, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithAllocationConfigModel{allocation=$allocation, defaultUnitAmount=$defaultUnitAmount, dimensions=$dimensions, matrixValues=$matrixValues, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/MaximumIntervalModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MaximumIntervalModel.kt new file mode 100644 index 000000000..8e4d29e97 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MaximumIntervalModel.kt @@ -0,0 +1,259 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class MaximumIntervalModel +@JsonCreator +private constructor( + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + private val endDate: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + private val startDate: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** The price ids that this maximum interval applies to. */ + fun appliesToPriceIds(): List = appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The price interval ids that this maximum interval applies to. */ + fun appliesToPriceIntervalIds(): List = + appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") + + /** The end date of the maximum interval. */ + fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) + + /** + * The maximum amount to charge in a given billing period for the price intervals this transform + * applies to. + */ + fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") + + /** The start date of the maximum interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The price ids that this maximum interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** The price interval ids that this maximum interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds + + /** The end date of the maximum interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + /** + * The maximum amount to charge in a given billing period for the price intervals this transform + * applies to. + */ + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount + + /** The start date of the maximum interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): MaximumIntervalModel = apply { + if (validated) { + return@apply + } + + appliesToPriceIds() + appliesToPriceIntervalIds() + endDate() + maximumAmount() + startDate() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MaximumIntervalModel]. + * + * The following fields are required: + * ```java + * .appliesToPriceIds() + * .appliesToPriceIntervalIds() + * .endDate() + * .maximumAmount() + * .startDate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MaximumIntervalModel]. */ + class Builder internal constructor() { + + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var maximumAmount: JsonField? = null + private var startDate: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(maximumIntervalModel: MaximumIntervalModel) = apply { + appliesToPriceIds = maximumIntervalModel.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + maximumIntervalModel.appliesToPriceIntervalIds.map { it.toMutableList() } + endDate = maximumIntervalModel.endDate + maximumAmount = maximumIntervalModel.maximumAmount + startDate = maximumIntervalModel.startDate + additionalProperties = maximumIntervalModel.additionalProperties.toMutableMap() + } + + /** The price ids that this maximum interval applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price ids that this maximum interval applies to. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this maximum interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** The price interval ids that this maximum interval applies to. */ + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = + appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) + + /** The price interval ids that this maximum interval applies to. */ + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds.map { it.toMutableList() } + } + + /** The price interval ids that this maximum interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIntervalIds", it).add(appliesToPriceIntervalId) + } + } + + /** The end date of the maximum interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the maximum interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) + + /** The end date of the maximum interval. */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** + * The maximum amount to charge in a given billing period for the price intervals this + * transform applies to. + */ + fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) + + /** + * The maximum amount to charge in a given billing period for the price intervals this + * transform applies to. + */ + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + /** The start date of the maximum interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the maximum interval. */ + 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) + } + + fun build(): MaximumIntervalModel = + MaximumIntervalModel( + checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, + checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { + it.toImmutable() + }, + checkRequired("endDate", endDate), + checkRequired("maximumAmount", maximumAmount), + checkRequired("startDate", startDate), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MaximumIntervalModel && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && maximumAmount == other.maximumAmount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, endDate, maximumAmount, startDate, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MaximumIntervalModel{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, maximumAmount=$maximumAmount, startDate=$startDate, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/MaximumModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MaximumModel.kt new file mode 100644 index 000000000..8b95a3480 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MaximumModel.kt @@ -0,0 +1,178 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects + +@NoAutoDetect +class MaximumModel +@JsonCreator +private constructor( + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** + * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, this can + * be a subset of prices. + */ + fun appliesToPriceIds(): List = appliesToPriceIds.getRequired("applies_to_price_ids") + + /** Maximum amount applied */ + fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") + + /** + * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, this can + * be a subset of prices. + */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** Maximum amount applied */ + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): MaximumModel = apply { + if (validated) { + return@apply + } + + appliesToPriceIds() + maximumAmount() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MaximumModel]. + * + * The following fields are required: + * ```java + * .appliesToPriceIds() + * .maximumAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MaximumModel]. */ + class Builder internal constructor() { + + private var appliesToPriceIds: JsonField>? = null + private var maximumAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(maximumModel: MaximumModel) = apply { + appliesToPriceIds = maximumModel.appliesToPriceIds.map { it.toMutableList() } + maximumAmount = maximumModel.maximumAmount + additionalProperties = maximumModel.additionalProperties.toMutableMap() + } + + /** + * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, this + * can be a subset of prices. + */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** + * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, this + * can be a subset of prices. + */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, this + * can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** Maximum amount applied */ + fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) + + /** Maximum amount applied */ + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): MaximumModel = + MaximumModel( + checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, + checkRequired("maximumAmount", maximumAmount), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MaximumModel && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, maximumAmount, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MaximumModel{appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, additionalProperties=$additionalProperties}" +} 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 57de8d224..e7ac78a1a 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 @@ -167,6 +167,17 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .description() + * .itemId() + * .name() + * .sql() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -292,6 +303,17 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [MetricCreateParams]. + * + * The following fields are required: + * ```java + * .description() + * .itemId() + * .name() + * .sql() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -514,6 +536,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } 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 5323bc8f3..3a5803fd0 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 @@ -41,6 +41,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [MetricFetchParams]. + * + * The following fields are required: + * ```java + * .metricId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListPage.kt index 2ab860281..5b69238a5 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListPage.kt @@ -32,7 +32,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -87,20 +87,21 @@ private constructor( class Response @JsonCreator constructor( - @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), + @JsonProperty("data") + private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = Optional.ofNullable(data) + fun _data(): Optional>> = Optional.ofNullable(data) @JsonProperty("pagination_metadata") fun _paginationMetadata(): Optional> = @@ -139,12 +140,13 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [MetricListPage]. */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -155,9 +157,9 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { this.data = data } fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) @@ -174,9 +176,9 @@ private constructor( } } - class AutoPager(private val firstPage: MetricListPage) : Iterable { + class AutoPager(private val firstPage: MetricListPage) : Iterable { - override fun iterator(): Iterator = iterator { + override fun iterator(): Iterator = iterator { var page = firstPage var index = 0 while (true) { @@ -188,7 +190,7 @@ private constructor( } } - fun stream(): Stream { + fun stream(): Stream { return StreamSupport.stream(spliterator(), false) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListPageAsync.kt index 723eced5d..33a7732dd 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListPageAsync.kt @@ -33,7 +33,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -90,20 +90,21 @@ private constructor( class Response @JsonCreator constructor( - @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), + @JsonProperty("data") + private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = Optional.ofNullable(data) + fun _data(): Optional>> = Optional.ofNullable(data) @JsonProperty("pagination_metadata") fun _paginationMetadata(): Optional> = @@ -142,12 +143,13 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [MetricListPageAsync]. */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -158,9 +160,9 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { this.data = data } fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) @@ -180,11 +182,11 @@ private constructor( class AutoPager(private val firstPage: MetricListPageAsync) { fun forEach( - action: Predicate, + action: Predicate, executor: Executor, ): CompletableFuture { fun CompletableFuture>.forEach( - action: (BillableMetric) -> Boolean, + action: (BillableMetricModel) -> Boolean, executor: Executor, ): CompletableFuture = thenComposeAsync( @@ -200,8 +202,8 @@ private constructor( .forEach(action::test, executor) } - fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() + fun toList(executor: Executor): CompletableFuture> { + val values = mutableListOf() return forEach(values::add, executor).thenApply { values } } } 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 df6afe1ec..6a372c3cf 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 @@ -88,6 +88,7 @@ private constructor( @JvmStatic fun none(): MetricListParams = builder().build() + /** Returns a mutable builder for constructing an instance of [MetricListParams]. */ @JvmStatic fun builder() = Builder() } 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 0c5bed30b..c81dfeeb2 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 @@ -111,6 +111,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Body]. */ @JvmStatic fun builder() = Builder() } @@ -191,6 +192,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [MetricUpdateParams]. + * + * The following fields are required: + * ```java + * .metricId() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -391,6 +400,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/MinimumIntervalModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MinimumIntervalModel.kt new file mode 100644 index 000000000..b40952a85 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MinimumIntervalModel.kt @@ -0,0 +1,259 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class MinimumIntervalModel +@JsonCreator +private constructor( + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + private val endDate: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + private val startDate: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** The price ids that this minimum interval applies to. */ + fun appliesToPriceIds(): List = appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The price interval ids that this minimum interval applies to. */ + fun appliesToPriceIntervalIds(): List = + appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") + + /** The end date of the minimum interval. */ + fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) + + /** + * The minimum amount to charge in a given billing period for the price intervals this minimum + * applies to. + */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** The start date of the minimum interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The price ids that this minimum interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** The price interval ids that this minimum interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds + + /** The end date of the minimum interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + /** + * The minimum amount to charge in a given billing period for the price intervals this minimum + * applies to. + */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** The start date of the minimum interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): MinimumIntervalModel = apply { + if (validated) { + return@apply + } + + appliesToPriceIds() + appliesToPriceIntervalIds() + endDate() + minimumAmount() + startDate() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MinimumIntervalModel]. + * + * The following fields are required: + * ```java + * .appliesToPriceIds() + * .appliesToPriceIntervalIds() + * .endDate() + * .minimumAmount() + * .startDate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MinimumIntervalModel]. */ + class Builder internal constructor() { + + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var minimumAmount: JsonField? = null + private var startDate: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(minimumIntervalModel: MinimumIntervalModel) = apply { + appliesToPriceIds = minimumIntervalModel.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + minimumIntervalModel.appliesToPriceIntervalIds.map { it.toMutableList() } + endDate = minimumIntervalModel.endDate + minimumAmount = minimumIntervalModel.minimumAmount + startDate = minimumIntervalModel.startDate + additionalProperties = minimumIntervalModel.additionalProperties.toMutableMap() + } + + /** The price ids that this minimum interval applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price ids that this minimum interval applies to. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this minimum interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** The price interval ids that this minimum interval applies to. */ + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = + appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) + + /** The price interval ids that this minimum interval applies to. */ + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds.map { it.toMutableList() } + } + + /** The price interval ids that this minimum interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIntervalIds", it).add(appliesToPriceIntervalId) + } + } + + /** The end date of the minimum interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the minimum interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) + + /** The end date of the minimum interval. */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** + * The minimum amount to charge in a given billing period for the price intervals this + * minimum applies to. + */ + fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) + + /** + * The minimum amount to charge in a given billing period for the price intervals this + * minimum applies to. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** The start date of the minimum interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the minimum interval. */ + 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) + } + + fun build(): MinimumIntervalModel = + MinimumIntervalModel( + checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, + checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { + it.toImmutable() + }, + checkRequired("endDate", endDate), + checkRequired("minimumAmount", minimumAmount), + checkRequired("startDate", startDate), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MinimumIntervalModel && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && minimumAmount == other.minimumAmount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, endDate, minimumAmount, startDate, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MinimumIntervalModel{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, minimumAmount=$minimumAmount, startDate=$startDate, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/MinimumModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MinimumModel.kt new file mode 100644 index 000000000..89be32045 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MinimumModel.kt @@ -0,0 +1,178 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects + +@NoAutoDetect +class MinimumModel +@JsonCreator +private constructor( + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** + * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, this can + * be a subset of prices. + */ + fun appliesToPriceIds(): List = appliesToPriceIds.getRequired("applies_to_price_ids") + + /** Minimum amount applied */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, this can + * be a subset of prices. + */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** Minimum amount applied */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): MinimumModel = apply { + if (validated) { + return@apply + } + + appliesToPriceIds() + minimumAmount() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MinimumModel]. + * + * The following fields are required: + * ```java + * .appliesToPriceIds() + * .minimumAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MinimumModel]. */ + class Builder internal constructor() { + + private var appliesToPriceIds: JsonField>? = null + private var minimumAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(minimumModel: MinimumModel) = apply { + appliesToPriceIds = minimumModel.appliesToPriceIds.map { it.toMutableList() } + minimumAmount = minimumModel.minimumAmount + additionalProperties = minimumModel.additionalProperties.toMutableMap() + } + + /** + * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, this + * can be a subset of prices. + */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** + * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, this + * can be a subset of prices. + */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, this + * can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** Minimum amount applied */ + fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) + + /** Minimum amount applied */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): MinimumModel = + MinimumModel( + checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, + checkRequired("minimumAmount", minimumAmount), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MinimumModel && appliesToPriceIds == other.appliesToPriceIds && minimumAmount == other.minimumAmount && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, minimumAmount, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MinimumModel{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/MutatedSubscriptionModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MutatedSubscriptionModel.kt new file mode 100644 index 000000000..0946d6cd4 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MutatedSubscriptionModel.kt @@ -0,0 +1,1429 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.BaseDeserializer +import com.withorb.api.core.BaseSerializer +import com.withorb.api.core.Enum +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.getOrThrow +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +@NoAutoDetect +class MutatedSubscriptionModel +@JsonCreator +private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("active_plan_phase_order") + @ExcludeMissing + private val activePlanPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("adjustment_intervals") + @ExcludeMissing + private val adjustmentIntervals: JsonField> = JsonMissing.of(), + @JsonProperty("auto_collection") + @ExcludeMissing + private val autoCollection: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_anchor_configuration") + @ExcludeMissing + private val billingCycleAnchorConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("billing_cycle_day") + @ExcludeMissing + private val billingCycleDay: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("current_billing_period_end_date") + @ExcludeMissing + private val currentBillingPeriodEndDate: JsonField = JsonMissing.of(), + @JsonProperty("current_billing_period_start_date") + @ExcludeMissing + private val currentBillingPeriodStartDate: JsonField = JsonMissing.of(), + @JsonProperty("customer") + @ExcludeMissing + private val customer: JsonField = JsonMissing.of(), + @JsonProperty("default_invoice_memo") + @ExcludeMissing + private val defaultInvoiceMemo: JsonField = JsonMissing.of(), + @JsonProperty("discount_intervals") + @ExcludeMissing + private val discountIntervals: JsonField> = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + private val endDate: JsonField = JsonMissing.of(), + @JsonProperty("fixed_fee_quantity_schedule") + @ExcludeMissing + private val fixedFeeQuantitySchedule: JsonField> = + JsonMissing.of(), + @JsonProperty("invoicing_threshold") + @ExcludeMissing + private val invoicingThreshold: JsonField = JsonMissing.of(), + @JsonProperty("maximum_intervals") + @ExcludeMissing + private val maximumIntervals: JsonField> = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum_intervals") + @ExcludeMissing + private val minimumIntervals: JsonField> = JsonMissing.of(), + @JsonProperty("net_terms") + @ExcludeMissing + private val netTerms: JsonField = JsonMissing.of(), + @JsonProperty("plan") @ExcludeMissing private val plan: JsonField = JsonMissing.of(), + @JsonProperty("price_intervals") + @ExcludeMissing + private val priceIntervals: JsonField> = JsonMissing.of(), + @JsonProperty("redeemed_coupon") + @ExcludeMissing + private val redeemedCoupon: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + private val startDate: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + private val status: JsonField = JsonMissing.of(), + @JsonProperty("trial_info") + @ExcludeMissing + private val trialInfo: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun id(): String = id.getRequired("id") + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + fun activePlanPhaseOrder(): Optional = + Optional.ofNullable(activePlanPhaseOrder.getNullable("active_plan_phase_order")) + + /** The adjustment intervals for this subscription. */ + fun adjustmentIntervals(): List = + adjustmentIntervals.getRequired("adjustment_intervals") + + /** + * Determines whether issued invoices for this subscription will automatically be charged with + * the saved payment method on the due date. This property defaults to the plan's behavior. If + * null, defaults to the customer's setting. + */ + fun autoCollection(): Optional = + Optional.ofNullable(autoCollection.getNullable("auto_collection")) + + fun billingCycleAnchorConfiguration(): BillingCycleAnchorConfigurationModel = + billingCycleAnchorConfiguration.getRequired("billing_cycle_anchor_configuration") + + /** + * The day of the month on which the billing cycle is anchored. If the maximum number of days in + * a month is greater than this value, the last day of the month is the billing cycle day (e.g. + * billing_cycle_day=31 for April means the billing period begins on the 30th. + */ + fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the instant + * returned is not part of the billing period. Set to null for subscriptions that are not + * currently active. + */ + fun currentBillingPeriodEndDate(): Optional = + Optional.ofNullable( + currentBillingPeriodEndDate.getNullable("current_billing_period_end_date") + ) + + /** + * The start date of the current billing period. This is an inclusive timestamp; the instant + * returned is exactly the beginning of the billing period. Set to null if the subscription is + * not currently active. + */ + fun currentBillingPeriodStartDate(): Optional = + Optional.ofNullable( + currentBillingPeriodStartDate.getNullable("current_billing_period_start_date") + ) + + /** + * 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 customer(): CustomerModel = customer.getRequired("customer") + + /** + * Determines the default memo on this subscriptions' invoices. Note that if this is not + * provided, it is determined by the plan configuration. + */ + fun defaultInvoiceMemo(): Optional = + Optional.ofNullable(defaultInvoiceMemo.getNullable("default_invoice_memo")) + + /** The discount intervals for this subscription. */ + fun discountIntervals(): List = + discountIntervals.getRequired("discount_intervals") + + /** The date Orb stops billing for this subscription. */ + fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) + + fun fixedFeeQuantitySchedule(): List = + fixedFeeQuantitySchedule.getRequired("fixed_fee_quantity_schedule") + + fun invoicingThreshold(): Optional = + Optional.ofNullable(invoicingThreshold.getNullable("invoicing_threshold")) + + /** The maximum intervals for this subscription. */ + fun maximumIntervals(): List = + maximumIntervals.getRequired("maximum_intervals") + + /** + * 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.getRequired("metadata") + + /** The minimum intervals for this subscription. */ + fun minimumIntervals(): List = + minimumIntervals.getRequired("minimum_intervals") + + /** + * Determines the difference between the invoice issue date for subscription invoices as the + * date that they are due. A value of `0` here represents that the invoice is due on issue, + * whereas a value of `30` represents that the customer has a month to pay the invoice. + */ + fun netTerms(): Long = netTerms.getRequired("net_terms") + + /** + * 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 plan(): PlanModel = plan.getRequired("plan") + + /** The price intervals for this subscription. */ + fun priceIntervals(): List = priceIntervals.getRequired("price_intervals") + + fun redeemedCoupon(): Optional = + Optional.ofNullable(redeemedCoupon.getNullable("redeemed_coupon")) + + /** The date Orb starts billing for this subscription. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + fun status(): Status = status.getRequired("status") + + fun trialInfo(): SubscriptionTrialInfoModel = trialInfo.getRequired("trial_info") + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + @JsonProperty("active_plan_phase_order") + @ExcludeMissing + fun _activePlanPhaseOrder(): JsonField = activePlanPhaseOrder + + /** The adjustment intervals for this subscription. */ + @JsonProperty("adjustment_intervals") + @ExcludeMissing + fun _adjustmentIntervals(): JsonField> = adjustmentIntervals + + /** + * Determines whether issued invoices for this subscription will automatically be charged with + * the saved payment method on the due date. This property defaults to the plan's behavior. If + * null, defaults to the customer's setting. + */ + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection + + @JsonProperty("billing_cycle_anchor_configuration") + @ExcludeMissing + fun _billingCycleAnchorConfiguration(): JsonField = + billingCycleAnchorConfiguration + + /** + * The day of the month on which the billing cycle is anchored. If the maximum number of days in + * a month is greater than this value, the last day of the month is the billing cycle day (e.g. + * billing_cycle_day=31 for April means the billing period begins on the 30th. + */ + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun _billingCycleDay(): JsonField = billingCycleDay + + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the instant + * returned is not part of the billing period. Set to null for subscriptions that are not + * currently active. + */ + @JsonProperty("current_billing_period_end_date") + @ExcludeMissing + fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate + + /** + * The start date of the current billing period. This is an inclusive timestamp; the instant + * returned is exactly the beginning of the billing period. Set to null if the subscription is + * not currently active. + */ + @JsonProperty("current_billing_period_start_date") + @ExcludeMissing + fun _currentBillingPeriodStartDate(): JsonField = currentBillingPeriodStartDate + + /** + * 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. + */ + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer + + /** + * Determines the default memo on this subscriptions' invoices. Note that if this is not + * provided, it is determined by the plan configuration. + */ + @JsonProperty("default_invoice_memo") + @ExcludeMissing + fun _defaultInvoiceMemo(): JsonField = defaultInvoiceMemo + + /** The discount intervals for this subscription. */ + @JsonProperty("discount_intervals") + @ExcludeMissing + fun _discountIntervals(): JsonField> = discountIntervals + + /** The date Orb stops billing for this subscription. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + @JsonProperty("fixed_fee_quantity_schedule") + @ExcludeMissing + fun _fixedFeeQuantitySchedule(): JsonField> = + fixedFeeQuantitySchedule + + @JsonProperty("invoicing_threshold") + @ExcludeMissing + fun _invoicingThreshold(): JsonField = invoicingThreshold + + /** The maximum intervals for this subscription. */ + @JsonProperty("maximum_intervals") + @ExcludeMissing + fun _maximumIntervals(): JsonField> = maximumIntervals + + /** + * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** The minimum intervals for this subscription. */ + @JsonProperty("minimum_intervals") + @ExcludeMissing + fun _minimumIntervals(): JsonField> = minimumIntervals + + /** + * Determines the difference between the invoice issue date for subscription invoices as the + * date that they are due. A value of `0` here represents that the invoice is due on issue, + * whereas a value of `30` represents that the customer has a month to pay the invoice. + */ + @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms + + /** + * 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). + */ + @JsonProperty("plan") @ExcludeMissing fun _plan(): JsonField = plan + + /** The price intervals for this subscription. */ + @JsonProperty("price_intervals") + @ExcludeMissing + fun _priceIntervals(): JsonField> = priceIntervals + + @JsonProperty("redeemed_coupon") + @ExcludeMissing + fun _redeemedCoupon(): JsonField = redeemedCoupon + + /** The date Orb starts billing for this subscription. */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + @JsonProperty("trial_info") + @ExcludeMissing + fun _trialInfo(): JsonField = trialInfo + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): MutatedSubscriptionModel = apply { + if (validated) { + return@apply + } + + id() + activePlanPhaseOrder() + adjustmentIntervals().forEach { it.validate() } + autoCollection() + billingCycleAnchorConfiguration().validate() + billingCycleDay() + createdAt() + currentBillingPeriodEndDate() + currentBillingPeriodStartDate() + customer().validate() + defaultInvoiceMemo() + discountIntervals().forEach { it.validate() } + endDate() + fixedFeeQuantitySchedule().forEach { it.validate() } + invoicingThreshold() + maximumIntervals().forEach { it.validate() } + metadata().validate() + minimumIntervals().forEach { it.validate() } + netTerms() + plan().validate() + priceIntervals().forEach { it.validate() } + redeemedCoupon().ifPresent { it.validate() } + startDate() + status() + trialInfo().validate() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MutatedSubscriptionModel]. + * + * The following fields are required: + * ```java + * .id() + * .activePlanPhaseOrder() + * .adjustmentIntervals() + * .autoCollection() + * .billingCycleAnchorConfiguration() + * .billingCycleDay() + * .createdAt() + * .currentBillingPeriodEndDate() + * .currentBillingPeriodStartDate() + * .customer() + * .defaultInvoiceMemo() + * .discountIntervals() + * .endDate() + * .fixedFeeQuantitySchedule() + * .invoicingThreshold() + * .maximumIntervals() + * .metadata() + * .minimumIntervals() + * .netTerms() + * .plan() + * .priceIntervals() + * .redeemedCoupon() + * .startDate() + * .status() + * .trialInfo() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MutatedSubscriptionModel]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var activePlanPhaseOrder: JsonField? = null + private var adjustmentIntervals: JsonField>? = null + private var autoCollection: JsonField? = null + private var billingCycleAnchorConfiguration: + JsonField? = + null + private var billingCycleDay: JsonField? = null + private var createdAt: JsonField? = null + private var currentBillingPeriodEndDate: JsonField? = null + private var currentBillingPeriodStartDate: JsonField? = null + private var customer: JsonField? = null + private var defaultInvoiceMemo: JsonField? = null + private var discountIntervals: JsonField>? = null + private var endDate: JsonField? = null + private var fixedFeeQuantitySchedule: + JsonField>? = + null + private var invoicingThreshold: JsonField? = null + private var maximumIntervals: JsonField>? = null + private var metadata: JsonField? = null + private var minimumIntervals: JsonField>? = null + private var netTerms: JsonField? = null + private var plan: JsonField? = null + private var priceIntervals: JsonField>? = null + private var redeemedCoupon: JsonField? = null + private var startDate: JsonField? = null + private var status: JsonField? = null + private var trialInfo: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(mutatedSubscriptionModel: MutatedSubscriptionModel) = apply { + id = mutatedSubscriptionModel.id + activePlanPhaseOrder = mutatedSubscriptionModel.activePlanPhaseOrder + adjustmentIntervals = + mutatedSubscriptionModel.adjustmentIntervals.map { it.toMutableList() } + autoCollection = mutatedSubscriptionModel.autoCollection + billingCycleAnchorConfiguration = + mutatedSubscriptionModel.billingCycleAnchorConfiguration + billingCycleDay = mutatedSubscriptionModel.billingCycleDay + createdAt = mutatedSubscriptionModel.createdAt + currentBillingPeriodEndDate = mutatedSubscriptionModel.currentBillingPeriodEndDate + currentBillingPeriodStartDate = mutatedSubscriptionModel.currentBillingPeriodStartDate + customer = mutatedSubscriptionModel.customer + defaultInvoiceMemo = mutatedSubscriptionModel.defaultInvoiceMemo + discountIntervals = + mutatedSubscriptionModel.discountIntervals.map { it.toMutableList() } + endDate = mutatedSubscriptionModel.endDate + fixedFeeQuantitySchedule = + mutatedSubscriptionModel.fixedFeeQuantitySchedule.map { it.toMutableList() } + invoicingThreshold = mutatedSubscriptionModel.invoicingThreshold + maximumIntervals = mutatedSubscriptionModel.maximumIntervals.map { it.toMutableList() } + metadata = mutatedSubscriptionModel.metadata + minimumIntervals = mutatedSubscriptionModel.minimumIntervals.map { it.toMutableList() } + netTerms = mutatedSubscriptionModel.netTerms + plan = mutatedSubscriptionModel.plan + priceIntervals = mutatedSubscriptionModel.priceIntervals.map { it.toMutableList() } + redeemedCoupon = mutatedSubscriptionModel.redeemedCoupon + startDate = mutatedSubscriptionModel.startDate + status = mutatedSubscriptionModel.status + trialInfo = mutatedSubscriptionModel.trialInfo + additionalProperties = mutatedSubscriptionModel.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + fun activePlanPhaseOrder(activePlanPhaseOrder: Long?) = + activePlanPhaseOrder(JsonField.ofNullable(activePlanPhaseOrder)) + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + fun activePlanPhaseOrder(activePlanPhaseOrder: Long) = + activePlanPhaseOrder(activePlanPhaseOrder as Long?) + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun activePlanPhaseOrder(activePlanPhaseOrder: Optional) = + activePlanPhaseOrder(activePlanPhaseOrder.orElse(null) as Long?) + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + fun activePlanPhaseOrder(activePlanPhaseOrder: JsonField) = apply { + this.activePlanPhaseOrder = activePlanPhaseOrder + } + + /** The adjustment intervals for this subscription. */ + fun adjustmentIntervals(adjustmentIntervals: List) = + adjustmentIntervals(JsonField.of(adjustmentIntervals)) + + /** The adjustment intervals for this subscription. */ + fun adjustmentIntervals(adjustmentIntervals: JsonField>) = + apply { + this.adjustmentIntervals = adjustmentIntervals.map { it.toMutableList() } + } + + /** The adjustment intervals for this subscription. */ + fun addAdjustmentInterval(adjustmentInterval: AdjustmentIntervalModel) = apply { + adjustmentIntervals = + (adjustmentIntervals ?: JsonField.of(mutableListOf())).also { + checkKnown("adjustmentIntervals", it).add(adjustmentInterval) + } + } + + /** + * Determines whether issued invoices for this subscription will automatically be charged + * with the saved payment method on the due date. This property defaults to the plan's + * behavior. If null, defaults to the customer's setting. + */ + fun autoCollection(autoCollection: Boolean?) = + autoCollection(JsonField.ofNullable(autoCollection)) + + /** + * Determines whether issued invoices for this subscription will automatically be charged + * with the saved payment method on the due date. This property defaults to the plan's + * behavior. If null, defaults to the customer's setting. + */ + fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) + + /** + * Determines whether issued invoices for this subscription will automatically be charged + * with the saved payment method on the due date. This property defaults to the plan's + * behavior. If null, defaults to the customer's setting. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun autoCollection(autoCollection: Optional) = + autoCollection(autoCollection.orElse(null) as Boolean?) + + /** + * Determines whether issued invoices for this subscription will automatically be charged + * with the saved payment method on the due date. This property defaults to the plan's + * behavior. If null, defaults to the customer's setting. + */ + fun autoCollection(autoCollection: JsonField) = apply { + this.autoCollection = autoCollection + } + + fun billingCycleAnchorConfiguration( + billingCycleAnchorConfiguration: BillingCycleAnchorConfigurationModel + ) = billingCycleAnchorConfiguration(JsonField.of(billingCycleAnchorConfiguration)) + + fun billingCycleAnchorConfiguration( + billingCycleAnchorConfiguration: JsonField + ) = apply { this.billingCycleAnchorConfiguration = billingCycleAnchorConfiguration } + + /** + * The day of the month on which the billing cycle is anchored. If the maximum number of + * days in a month is greater than this value, the last day of the month is the billing + * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the + * 30th. + */ + fun billingCycleDay(billingCycleDay: Long) = billingCycleDay(JsonField.of(billingCycleDay)) + + /** + * The day of the month on which the billing cycle is anchored. If the maximum number of + * days in a month is greater than this value, the last day of the month is the billing + * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the + * 30th. + */ + fun billingCycleDay(billingCycleDay: JsonField) = apply { + this.billingCycleDay = billingCycleDay + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is not part of the billing period. Set to null for subscriptions that + * are not currently active. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = + currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is not part of the billing period. Set to null for subscriptions that + * are not currently active. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = + currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is not part of the billing period. Set to null for subscriptions that + * are not currently active. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: JsonField) = + apply { + this.currentBillingPeriodEndDate = currentBillingPeriodEndDate + } + + /** + * The start date of the current billing period. This is an inclusive timestamp; the instant + * returned is exactly the beginning of the billing period. Set to null if the subscription + * is not currently active. + */ + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = + currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) + + /** + * The start date of the current billing period. This is an inclusive timestamp; the instant + * returned is exactly the beginning of the billing period. Set to null if the subscription + * is not currently active. + */ + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: Optional) = + currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) + + /** + * The start date of the current billing period. This is an inclusive timestamp; the instant + * returned is exactly the beginning of the billing period. Set to null if the subscription + * is not currently active. + */ + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: JsonField + ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } + + /** + * 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 customer(customer: CustomerModel) = customer(JsonField.of(customer)) + + /** + * 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 customer(customer: JsonField) = apply { this.customer = customer } + + /** + * Determines the default memo on this subscriptions' invoices. Note that if this is not + * provided, it is determined by the plan configuration. + */ + fun defaultInvoiceMemo(defaultInvoiceMemo: String?) = + defaultInvoiceMemo(JsonField.ofNullable(defaultInvoiceMemo)) + + /** + * Determines the default memo on this subscriptions' invoices. Note that if this is not + * provided, it is determined by the plan configuration. + */ + fun defaultInvoiceMemo(defaultInvoiceMemo: Optional) = + defaultInvoiceMemo(defaultInvoiceMemo.orElse(null)) + + /** + * Determines the default memo on this subscriptions' invoices. Note that if this is not + * provided, it is determined by the plan configuration. + */ + fun defaultInvoiceMemo(defaultInvoiceMemo: JsonField) = apply { + this.defaultInvoiceMemo = defaultInvoiceMemo + } + + /** The discount intervals for this subscription. */ + fun discountIntervals(discountIntervals: List) = + discountIntervals(JsonField.of(discountIntervals)) + + /** The discount intervals for this subscription. */ + fun discountIntervals(discountIntervals: JsonField>) = apply { + this.discountIntervals = discountIntervals.map { it.toMutableList() } + } + + /** The discount intervals for this subscription. */ + fun addDiscountInterval(discountInterval: DiscountInterval) = apply { + discountIntervals = + (discountIntervals ?: JsonField.of(mutableListOf())).also { + checkKnown("discountIntervals", it).add(discountInterval) + } + } + + /** The discount intervals for this subscription. */ + fun addDiscountInterval(amountDiscountIntervalModel: AmountDiscountIntervalModel) = + addDiscountInterval( + DiscountInterval.ofAmountDiscountIntervalModel(amountDiscountIntervalModel) + ) + + /** The discount intervals for this subscription. */ + fun addDiscountInterval(percentageDiscountIntervalModel: PercentageDiscountIntervalModel) = + addDiscountInterval( + DiscountInterval.ofPercentageDiscountIntervalModel(percentageDiscountIntervalModel) + ) + + /** The discount intervals for this subscription. */ + fun addDiscountInterval(usageDiscountIntervalModel: UsageDiscountIntervalModel) = + addDiscountInterval( + DiscountInterval.ofUsageDiscountIntervalModel(usageDiscountIntervalModel) + ) + + /** The date Orb stops billing for this subscription. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The date Orb stops billing for this subscription. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) + + /** The date Orb stops billing for this subscription. */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun fixedFeeQuantitySchedule( + fixedFeeQuantitySchedule: List + ) = fixedFeeQuantitySchedule(JsonField.of(fixedFeeQuantitySchedule)) + + fun fixedFeeQuantitySchedule( + fixedFeeQuantitySchedule: JsonField> + ) = apply { + this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule.map { it.toMutableList() } + } + + fun addFixedFeeQuantitySchedule( + fixedFeeQuantitySchedule: FixedFeeQuantityScheduleEntryModel + ) = apply { + this.fixedFeeQuantitySchedule = + (this.fixedFeeQuantitySchedule ?: JsonField.of(mutableListOf())).also { + checkKnown("fixedFeeQuantitySchedule", it).add(fixedFeeQuantitySchedule) + } + } + + fun invoicingThreshold(invoicingThreshold: String?) = + invoicingThreshold(JsonField.ofNullable(invoicingThreshold)) + + fun invoicingThreshold(invoicingThreshold: Optional) = + invoicingThreshold(invoicingThreshold.orElse(null)) + + fun invoicingThreshold(invoicingThreshold: JsonField) = apply { + this.invoicingThreshold = invoicingThreshold + } + + /** The maximum intervals for this subscription. */ + fun maximumIntervals(maximumIntervals: List) = + maximumIntervals(JsonField.of(maximumIntervals)) + + /** The maximum intervals for this subscription. */ + fun maximumIntervals(maximumIntervals: JsonField>) = apply { + this.maximumIntervals = maximumIntervals.map { it.toMutableList() } + } + + /** The maximum intervals for this subscription. */ + fun addMaximumInterval(maximumInterval: MaximumIntervalModel) = apply { + maximumIntervals = + (maximumIntervals ?: JsonField.of(mutableListOf())).also { + checkKnown("maximumIntervals", it).add(maximumInterval) + } + } + + /** + * 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)) + + /** + * 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: JsonField) = apply { this.metadata = metadata } + + /** The minimum intervals for this subscription. */ + fun minimumIntervals(minimumIntervals: List) = + minimumIntervals(JsonField.of(minimumIntervals)) + + /** The minimum intervals for this subscription. */ + fun minimumIntervals(minimumIntervals: JsonField>) = apply { + this.minimumIntervals = minimumIntervals.map { it.toMutableList() } + } + + /** The minimum intervals for this subscription. */ + fun addMinimumInterval(minimumInterval: MinimumIntervalModel) = apply { + minimumIntervals = + (minimumIntervals ?: JsonField.of(mutableListOf())).also { + checkKnown("minimumIntervals", it).add(minimumInterval) + } + } + + /** + * Determines the difference between the invoice issue date for subscription invoices as the + * date that they are due. A value of `0` here represents that the invoice is due on issue, + * whereas a value of `30` represents that the customer has a month to pay the invoice. + */ + fun netTerms(netTerms: Long) = netTerms(JsonField.of(netTerms)) + + /** + * Determines the difference between the invoice issue date for subscription invoices as the + * date that they are due. A value of `0` here represents that the invoice is due on issue, + * whereas a value of `30` represents that the customer has a month to pay the invoice. + */ + fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } + + /** + * 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 plan(plan: PlanModel) = plan(JsonField.of(plan)) + + /** + * 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 plan(plan: JsonField) = apply { this.plan = plan } + + /** The price intervals for this subscription. */ + fun priceIntervals(priceIntervals: List) = + priceIntervals(JsonField.of(priceIntervals)) + + /** The price intervals for this subscription. */ + fun priceIntervals(priceIntervals: JsonField>) = apply { + this.priceIntervals = priceIntervals.map { it.toMutableList() } + } + + /** The price intervals for this subscription. */ + fun addPriceInterval(priceInterval: PriceIntervalModel) = apply { + priceIntervals = + (priceIntervals ?: JsonField.of(mutableListOf())).also { + checkKnown("priceIntervals", it).add(priceInterval) + } + } + + fun redeemedCoupon(redeemedCoupon: CouponRedemptionModel?) = + redeemedCoupon(JsonField.ofNullable(redeemedCoupon)) + + fun redeemedCoupon(redeemedCoupon: Optional) = + redeemedCoupon(redeemedCoupon.orElse(null)) + + fun redeemedCoupon(redeemedCoupon: JsonField) = apply { + this.redeemedCoupon = redeemedCoupon + } + + /** The date Orb starts billing for this subscription. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The date Orb starts billing for this subscription. */ + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + fun status(status: Status) = status(JsonField.of(status)) + + fun status(status: JsonField) = apply { this.status = status } + + fun trialInfo(trialInfo: SubscriptionTrialInfoModel) = trialInfo(JsonField.of(trialInfo)) + + fun trialInfo(trialInfo: JsonField) = apply { + this.trialInfo = trialInfo + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): MutatedSubscriptionModel = + MutatedSubscriptionModel( + checkRequired("id", id), + checkRequired("activePlanPhaseOrder", activePlanPhaseOrder), + checkRequired("adjustmentIntervals", adjustmentIntervals).map { it.toImmutable() }, + checkRequired("autoCollection", autoCollection), + checkRequired("billingCycleAnchorConfiguration", billingCycleAnchorConfiguration), + checkRequired("billingCycleDay", billingCycleDay), + checkRequired("createdAt", createdAt), + checkRequired("currentBillingPeriodEndDate", currentBillingPeriodEndDate), + checkRequired("currentBillingPeriodStartDate", currentBillingPeriodStartDate), + checkRequired("customer", customer), + checkRequired("defaultInvoiceMemo", defaultInvoiceMemo), + checkRequired("discountIntervals", discountIntervals).map { it.toImmutable() }, + checkRequired("endDate", endDate), + checkRequired("fixedFeeQuantitySchedule", fixedFeeQuantitySchedule).map { + it.toImmutable() + }, + checkRequired("invoicingThreshold", invoicingThreshold), + checkRequired("maximumIntervals", maximumIntervals).map { it.toImmutable() }, + checkRequired("metadata", metadata), + checkRequired("minimumIntervals", minimumIntervals).map { it.toImmutable() }, + checkRequired("netTerms", netTerms), + checkRequired("plan", plan), + checkRequired("priceIntervals", priceIntervals).map { it.toImmutable() }, + checkRequired("redeemedCoupon", redeemedCoupon), + checkRequired("startDate", startDate), + checkRequired("status", status), + checkRequired("trialInfo", trialInfo), + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(using = DiscountInterval.Deserializer::class) + @JsonSerialize(using = DiscountInterval.Serializer::class) + class DiscountInterval + private constructor( + private val amountDiscountIntervalModel: AmountDiscountIntervalModel? = null, + private val percentageDiscountIntervalModel: PercentageDiscountIntervalModel? = null, + private val usageDiscountIntervalModel: UsageDiscountIntervalModel? = null, + private val _json: JsonValue? = null, + ) { + + fun amountDiscountIntervalModel(): Optional = + Optional.ofNullable(amountDiscountIntervalModel) + + fun percentageDiscountIntervalModel(): Optional = + Optional.ofNullable(percentageDiscountIntervalModel) + + fun usageDiscountIntervalModel(): Optional = + Optional.ofNullable(usageDiscountIntervalModel) + + fun isAmountDiscountIntervalModel(): Boolean = amountDiscountIntervalModel != null + + fun isPercentageDiscountIntervalModel(): Boolean = percentageDiscountIntervalModel != null + + fun isUsageDiscountIntervalModel(): Boolean = usageDiscountIntervalModel != null + + fun asAmountDiscountIntervalModel(): AmountDiscountIntervalModel = + amountDiscountIntervalModel.getOrThrow("amountDiscountIntervalModel") + + fun asPercentageDiscountIntervalModel(): PercentageDiscountIntervalModel = + percentageDiscountIntervalModel.getOrThrow("percentageDiscountIntervalModel") + + fun asUsageDiscountIntervalModel(): UsageDiscountIntervalModel = + usageDiscountIntervalModel.getOrThrow("usageDiscountIntervalModel") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + amountDiscountIntervalModel != null -> + visitor.visitAmountDiscountIntervalModel(amountDiscountIntervalModel) + percentageDiscountIntervalModel != null -> + visitor.visitPercentageDiscountIntervalModel(percentageDiscountIntervalModel) + usageDiscountIntervalModel != null -> + visitor.visitUsageDiscountIntervalModel(usageDiscountIntervalModel) + else -> visitor.unknown(_json) + } + } + + private var validated: Boolean = false + + fun validate(): DiscountInterval = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitAmountDiscountIntervalModel( + amountDiscountIntervalModel: AmountDiscountIntervalModel + ) { + amountDiscountIntervalModel.validate() + } + + override fun visitPercentageDiscountIntervalModel( + percentageDiscountIntervalModel: PercentageDiscountIntervalModel + ) { + percentageDiscountIntervalModel.validate() + } + + override fun visitUsageDiscountIntervalModel( + usageDiscountIntervalModel: UsageDiscountIntervalModel + ) { + usageDiscountIntervalModel.validate() + } + } + ) + validated = true + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountInterval && amountDiscountIntervalModel == other.amountDiscountIntervalModel && percentageDiscountIntervalModel == other.percentageDiscountIntervalModel && usageDiscountIntervalModel == other.usageDiscountIntervalModel /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(amountDiscountIntervalModel, percentageDiscountIntervalModel, usageDiscountIntervalModel) /* spotless:on */ + + override fun toString(): String = + when { + amountDiscountIntervalModel != null -> + "DiscountInterval{amountDiscountIntervalModel=$amountDiscountIntervalModel}" + percentageDiscountIntervalModel != null -> + "DiscountInterval{percentageDiscountIntervalModel=$percentageDiscountIntervalModel}" + usageDiscountIntervalModel != null -> + "DiscountInterval{usageDiscountIntervalModel=$usageDiscountIntervalModel}" + _json != null -> "DiscountInterval{_unknown=$_json}" + else -> throw IllegalStateException("Invalid DiscountInterval") + } + + companion object { + + @JvmStatic + fun ofAmountDiscountIntervalModel( + amountDiscountIntervalModel: AmountDiscountIntervalModel + ) = DiscountInterval(amountDiscountIntervalModel = amountDiscountIntervalModel) + + @JvmStatic + fun ofPercentageDiscountIntervalModel( + percentageDiscountIntervalModel: PercentageDiscountIntervalModel + ) = DiscountInterval(percentageDiscountIntervalModel = percentageDiscountIntervalModel) + + @JvmStatic + fun ofUsageDiscountIntervalModel( + usageDiscountIntervalModel: UsageDiscountIntervalModel + ) = DiscountInterval(usageDiscountIntervalModel = usageDiscountIntervalModel) + } + + /** + * An interface that defines how to map each variant of [DiscountInterval] to a value of + * type [T]. + */ + interface Visitor { + + fun visitAmountDiscountIntervalModel( + amountDiscountIntervalModel: AmountDiscountIntervalModel + ): T + + fun visitPercentageDiscountIntervalModel( + percentageDiscountIntervalModel: PercentageDiscountIntervalModel + ): T + + fun visitUsageDiscountIntervalModel( + usageDiscountIntervalModel: UsageDiscountIntervalModel + ): T + + /** + * Maps an unknown variant of [DiscountInterval] to a value of type [T]. + * + * An instance of [DiscountInterval] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the SDK + * is on an older version than the API, then the API may respond with new variants that + * the SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown DiscountInterval: $json") + } + } + + internal class Deserializer : BaseDeserializer(DiscountInterval::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): DiscountInterval { + val json = JsonValue.fromJsonNode(node) + val discountType = + json.asObject().getOrNull()?.get("discount_type")?.asString()?.getOrNull() + + when (discountType) { + "amount" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return DiscountInterval( + amountDiscountIntervalModel = it, + _json = json, + ) + } + } + "percentage" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return DiscountInterval( + percentageDiscountIntervalModel = it, + _json = json, + ) + } + } + "usage" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return DiscountInterval( + usageDiscountIntervalModel = it, + _json = json, + ) + } + } + } + + return DiscountInterval(_json = json) + } + } + + internal class Serializer : BaseSerializer(DiscountInterval::class) { + + override fun serialize( + value: DiscountInterval, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.amountDiscountIntervalModel != null -> + generator.writeObject(value.amountDiscountIntervalModel) + value.percentageDiscountIntervalModel != null -> + generator.writeObject(value.percentageDiscountIntervalModel) + value.usageDiscountIntervalModel != null -> + generator.writeObject(value.usageDiscountIntervalModel) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid DiscountInterval") + } + } + } + } + + /** + * 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`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class 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 ENDED = of("ended") + + @JvmField val UPCOMING = of("upcoming") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + ENDED, + UPCOMING, + } + + /** + * 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, + ENDED, + UPCOMING, + /** 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 + ENDED -> Value.ENDED + UPCOMING -> Value.UPCOMING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to 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 + ENDED -> Known.ENDED + UPCOMING -> Known.UPCOMING + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MutatedSubscriptionModel && id == other.id && activePlanPhaseOrder == other.activePlanPhaseOrder && adjustmentIntervals == other.adjustmentIntervals && autoCollection == other.autoCollection && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && billingCycleDay == other.billingCycleDay && createdAt == other.createdAt && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && customer == other.customer && defaultInvoiceMemo == other.defaultInvoiceMemo && discountIntervals == other.discountIntervals && endDate == other.endDate && fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && invoicingThreshold == other.invoicingThreshold && maximumIntervals == other.maximumIntervals && metadata == other.metadata && minimumIntervals == other.minimumIntervals && netTerms == other.netTerms && plan == other.plan && priceIntervals == other.priceIntervals && redeemedCoupon == other.redeemedCoupon && startDate == other.startDate && status == other.status && trialInfo == other.trialInfo && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, activePlanPhaseOrder, adjustmentIntervals, autoCollection, billingCycleAnchorConfiguration, billingCycleDay, createdAt, currentBillingPeriodEndDate, currentBillingPeriodStartDate, customer, defaultInvoiceMemo, discountIntervals, endDate, fixedFeeQuantitySchedule, invoicingThreshold, maximumIntervals, metadata, minimumIntervals, netTerms, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MutatedSubscriptionModel{id=$id, activePlanPhaseOrder=$activePlanPhaseOrder, adjustmentIntervals=$adjustmentIntervals, autoCollection=$autoCollection, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, billingCycleDay=$billingCycleDay, createdAt=$createdAt, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, customer=$customer, defaultInvoiceMemo=$defaultInvoiceMemo, discountIntervals=$discountIntervals, endDate=$endDate, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, invoicingThreshold=$invoicingThreshold, maximumIntervals=$maximumIntervals, metadata=$metadata, minimumIntervals=$minimumIntervals, netTerms=$netTerms, plan=$plan, priceIntervals=$priceIntervals, redeemedCoupon=$redeemedCoupon, startDate=$startDate, status=$status, trialInfo=$trialInfo, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAccountingSyncConfigurationModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAccountingSyncConfigurationModel.kt new file mode 100644 index 000000000..4432c3f3d --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAccountingSyncConfigurationModel.kt @@ -0,0 +1,289 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class NewAccountingSyncConfigurationModel +@JsonCreator +private constructor( + @JsonProperty("accounting_providers") + @ExcludeMissing + private val accountingProviders: JsonField> = JsonMissing.of(), + @JsonProperty("excluded") + @ExcludeMissing + private val excluded: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun accountingProviders(): Optional> = + Optional.ofNullable(accountingProviders.getNullable("accounting_providers")) + + fun excluded(): Optional = Optional.ofNullable(excluded.getNullable("excluded")) + + @JsonProperty("accounting_providers") + @ExcludeMissing + fun _accountingProviders(): JsonField> = accountingProviders + + @JsonProperty("excluded") @ExcludeMissing fun _excluded(): JsonField = excluded + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewAccountingSyncConfigurationModel = apply { + if (validated) { + return@apply + } + + accountingProviders().ifPresent { it.forEach { it.validate() } } + excluded() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewAccountingSyncConfigurationModel]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewAccountingSyncConfigurationModel]. */ + class Builder internal constructor() { + + private var accountingProviders: JsonField>? = null + private var excluded: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + newAccountingSyncConfigurationModel: NewAccountingSyncConfigurationModel + ) = apply { + accountingProviders = + newAccountingSyncConfigurationModel.accountingProviders.map { it.toMutableList() } + excluded = newAccountingSyncConfigurationModel.excluded + additionalProperties = + newAccountingSyncConfigurationModel.additionalProperties.toMutableMap() + } + + fun accountingProviders(accountingProviders: List?) = + accountingProviders(JsonField.ofNullable(accountingProviders)) + + fun accountingProviders(accountingProviders: Optional>) = + accountingProviders(accountingProviders.orElse(null)) + + fun accountingProviders(accountingProviders: JsonField>) = apply { + this.accountingProviders = accountingProviders.map { it.toMutableList() } + } + + fun addAccountingProvider(accountingProvider: AccountingProvider) = apply { + accountingProviders = + (accountingProviders ?: JsonField.of(mutableListOf())).also { + checkKnown("accountingProviders", it).add(accountingProvider) + } + } + + fun excluded(excluded: Boolean?) = excluded(JsonField.ofNullable(excluded)) + + fun excluded(excluded: Boolean) = excluded(excluded as Boolean?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun excluded(excluded: Optional) = excluded(excluded.orElse(null) as Boolean?) + + fun excluded(excluded: JsonField) = apply { this.excluded = excluded } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): NewAccountingSyncConfigurationModel = + NewAccountingSyncConfigurationModel( + (accountingProviders ?: JsonMissing.of()).map { it.toImmutable() }, + excluded, + additionalProperties.toImmutable(), + ) + } + + @NoAutoDetect + class AccountingProvider + @JsonCreator + private constructor( + @JsonProperty("external_provider_id") + @ExcludeMissing + private val externalProviderId: JsonField = JsonMissing.of(), + @JsonProperty("provider_type") + @ExcludeMissing + private val providerType: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun externalProviderId(): String = externalProviderId.getRequired("external_provider_id") + + fun providerType(): String = providerType.getRequired("provider_type") + + @JsonProperty("external_provider_id") + @ExcludeMissing + fun _externalProviderId(): JsonField = externalProviderId + + @JsonProperty("provider_type") + @ExcludeMissing + fun _providerType(): JsonField = providerType + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): AccountingProvider = apply { + if (validated) { + return@apply + } + + externalProviderId() + providerType() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AccountingProvider]. + * + * The following fields are required: + * ```java + * .externalProviderId() + * .providerType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AccountingProvider]. */ + class Builder internal constructor() { + + private var externalProviderId: JsonField? = null + private var providerType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(accountingProvider: AccountingProvider) = apply { + externalProviderId = accountingProvider.externalProviderId + providerType = accountingProvider.providerType + additionalProperties = accountingProvider.additionalProperties.toMutableMap() + } + + fun externalProviderId(externalProviderId: String) = + externalProviderId(JsonField.of(externalProviderId)) + + fun externalProviderId(externalProviderId: JsonField) = apply { + this.externalProviderId = externalProviderId + } + + fun providerType(providerType: String) = providerType(JsonField.of(providerType)) + + fun providerType(providerType: JsonField) = apply { + this.providerType = providerType + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): AccountingProvider = + AccountingProvider( + checkRequired("externalProviderId", externalProviderId), + checkRequired("providerType", providerType), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AccountingProvider && externalProviderId == other.externalProviderId && providerType == other.providerType && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(externalProviderId, providerType, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AccountingProvider{externalProviderId=$externalProviderId, providerType=$providerType, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewAccountingSyncConfigurationModel && accountingProviders == other.accountingProviders && excluded == other.excluded && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(accountingProviders, excluded, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewAccountingSyncConfigurationModel{accountingProviders=$accountingProviders, excluded=$excluded, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAdjustmentModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAdjustmentModel.kt new file mode 100644 index 000000000..7714a2094 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAdjustmentModel.kt @@ -0,0 +1,1771 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.BaseDeserializer +import com.withorb.api.core.BaseSerializer +import com.withorb.api.core.Enum +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.getOrThrow +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +@JsonDeserialize(using = NewAdjustmentModel.Deserializer::class) +@JsonSerialize(using = NewAdjustmentModel.Serializer::class) +class NewAdjustmentModel +private constructor( + private val percentageDiscount: NewPercentageDiscount? = null, + private val usageDiscount: NewUsageDiscount? = null, + private val amountDiscount: NewAmountDiscount? = null, + private val minimum: NewMinimum? = null, + private val maximum: NewMaximum? = null, + private val _json: JsonValue? = null, +) { + + fun percentageDiscount(): Optional = + Optional.ofNullable(percentageDiscount) + + fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) + + fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) + + fun minimum(): Optional = Optional.ofNullable(minimum) + + fun maximum(): Optional = Optional.ofNullable(maximum) + + fun isPercentageDiscount(): Boolean = percentageDiscount != null + + fun isUsageDiscount(): Boolean = usageDiscount != null + + fun isAmountDiscount(): Boolean = amountDiscount != null + + fun isMinimum(): Boolean = minimum != null + + fun isMaximum(): Boolean = maximum != null + + fun asPercentageDiscount(): NewPercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") + + fun asUsageDiscount(): NewUsageDiscount = usageDiscount.getOrThrow("usageDiscount") + + fun asAmountDiscount(): NewAmountDiscount = amountDiscount.getOrThrow("amountDiscount") + + fun asMinimum(): NewMinimum = minimum.getOrThrow("minimum") + + fun asMaximum(): NewMaximum = maximum.getOrThrow("maximum") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + percentageDiscount != null -> visitor.visitPercentageDiscount(percentageDiscount) + usageDiscount != null -> visitor.visitUsageDiscount(usageDiscount) + amountDiscount != null -> visitor.visitAmountDiscount(amountDiscount) + minimum != null -> visitor.visitMinimum(minimum) + maximum != null -> visitor.visitMaximum(maximum) + else -> visitor.unknown(_json) + } + } + + private var validated: Boolean = false + + fun validate(): NewAdjustmentModel = 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 + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewAdjustmentModel && percentageDiscount == other.percentageDiscount && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount && minimum == other.minimum && maximum == other.maximum /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) /* spotless:on */ + + override fun toString(): String = + when { + percentageDiscount != null -> + "NewAdjustmentModel{percentageDiscount=$percentageDiscount}" + usageDiscount != null -> "NewAdjustmentModel{usageDiscount=$usageDiscount}" + amountDiscount != null -> "NewAdjustmentModel{amountDiscount=$amountDiscount}" + minimum != null -> "NewAdjustmentModel{minimum=$minimum}" + maximum != null -> "NewAdjustmentModel{maximum=$maximum}" + _json != null -> "NewAdjustmentModel{_unknown=$_json}" + else -> throw IllegalStateException("Invalid NewAdjustmentModel") + } + + companion object { + + @JvmStatic + fun ofPercentageDiscount(percentageDiscount: NewPercentageDiscount) = + NewAdjustmentModel(percentageDiscount = percentageDiscount) + + @JvmStatic + fun ofUsageDiscount(usageDiscount: NewUsageDiscount) = + NewAdjustmentModel(usageDiscount = usageDiscount) + + @JvmStatic + fun ofAmountDiscount(amountDiscount: NewAmountDiscount) = + NewAdjustmentModel(amountDiscount = amountDiscount) + + @JvmStatic fun ofMinimum(minimum: NewMinimum) = NewAdjustmentModel(minimum = minimum) + + @JvmStatic fun ofMaximum(maximum: NewMaximum) = NewAdjustmentModel(maximum = maximum) + } + + /** + * An interface that defines how to map each variant of [NewAdjustmentModel] 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 [NewAdjustmentModel] to a value of type [T]. + * + * An instance of [NewAdjustmentModel] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is unaware + * of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown NewAdjustmentModel: $json") + } + } + + internal class Deserializer : BaseDeserializer(NewAdjustmentModel::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): NewAdjustmentModel { + val json = JsonValue.fromJsonNode(node) + val adjustmentType = + json.asObject().getOrNull()?.get("adjustment_type")?.asString()?.getOrNull() + + when (adjustmentType) { + "percentage_discount" -> { + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return NewAdjustmentModel(percentageDiscount = it, _json = json) + } + } + "usage_discount" -> { + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return NewAdjustmentModel(usageDiscount = it, _json = json) + } + } + "amount_discount" -> { + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return NewAdjustmentModel(amountDiscount = it, _json = json) + } + } + "minimum" -> { + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return NewAdjustmentModel(minimum = it, _json = json) + } + } + "maximum" -> { + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return NewAdjustmentModel(maximum = it, _json = json) + } + } + } + + return NewAdjustmentModel(_json = json) + } + } + + internal class Serializer : BaseSerializer(NewAdjustmentModel::class) { + + override fun serialize( + value: NewAdjustmentModel, + 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 NewAdjustmentModel") + } + } + } + + @NoAutoDetect + class NewPercentageDiscount + @JsonCreator + private constructor( + @JsonProperty("adjustment_type") + @ExcludeMissing + private val adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("percentage_discount") + @ExcludeMissing + private val percentageDiscount: JsonField = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + private val isInvoiceLevel: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + fun percentageDiscount(): Double = percentageDiscount.getRequired("percentage_discount") + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will be + * applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(): Optional = + Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType + + /** The set of price IDs to which this adjustment applies. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + @JsonProperty("percentage_discount") + @ExcludeMissing + fun _percentageDiscount(): JsonField = percentageDiscount + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will be + * applied at the invoice level, possibly to multiple prices. + */ + @JsonProperty("is_invoice_level") + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewPercentageDiscount = apply { + if (validated) { + return@apply + } + + adjustmentType() + appliesToPriceIds() + percentageDiscount() + isInvoiceLevel() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [NewPercentageDiscount]. + * + * The following fields are required: + * ```java + * .adjustmentType() + * .appliesToPriceIds() + * .percentageDiscount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewPercentageDiscount]. */ + class Builder internal constructor() { + + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var percentageDiscount: JsonField? = null + private var isInvoiceLevel: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(newPercentageDiscount: NewPercentageDiscount) = apply { + adjustmentType = newPercentageDiscount.adjustmentType + appliesToPriceIds = + newPercentageDiscount.appliesToPriceIds.map { it.toMutableList() } + percentageDiscount = newPercentageDiscount.percentageDiscount + isInvoiceLevel = newPercentageDiscount.isInvoiceLevel + additionalProperties = newPercentageDiscount.additionalProperties.toMutableMap() + } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The set of price IDs to which this adjustment applies. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + fun percentageDiscount(percentageDiscount: Double) = + percentageDiscount(JsonField.of(percentageDiscount)) + + fun percentageDiscount(percentageDiscount: JsonField) = apply { + this.percentageDiscount = percentageDiscount + } + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will be + * applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(isInvoiceLevel: Boolean) = + isInvoiceLevel(JsonField.of(isInvoiceLevel)) + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will be + * applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): NewPercentageDiscount = + NewPercentageDiscount( + checkRequired("adjustmentType", adjustmentType), + checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, + checkRequired("percentageDiscount", percentageDiscount), + isInvoiceLevel, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PERCENTAGE_DISCOUNT = of("percentage_discount") + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + /** An enum containing [AdjustmentType]'s known values. */ + enum class Known { + PERCENTAGE_DISCOUNT + } + + /** + * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AdjustmentType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PERCENTAGE_DISCOUNT, + /** + * An enum member indicating that [AdjustmentType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewPercentageDiscount && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && percentageDiscount == other.percentageDiscount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(adjustmentType, appliesToPriceIds, percentageDiscount, isInvoiceLevel, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewPercentageDiscount{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, percentageDiscount=$percentageDiscount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewUsageDiscount + @JsonCreator + private constructor( + @JsonProperty("adjustment_type") + @ExcludeMissing + private val adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("usage_discount") + @ExcludeMissing + private val usageDiscount: JsonField = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + private val isInvoiceLevel: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will be + * applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(): Optional = + Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType + + /** The set of price IDs to which this adjustment applies. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will be + * applied at the invoice level, possibly to multiple prices. + */ + @JsonProperty("is_invoice_level") + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewUsageDiscount = apply { + if (validated) { + return@apply + } + + adjustmentType() + appliesToPriceIds() + usageDiscount() + isInvoiceLevel() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [NewUsageDiscount]. + * + * The following fields are required: + * ```java + * .adjustmentType() + * .appliesToPriceIds() + * .usageDiscount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewUsageDiscount]. */ + class Builder internal constructor() { + + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var usageDiscount: JsonField? = null + private var isInvoiceLevel: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(newUsageDiscount: NewUsageDiscount) = apply { + adjustmentType = newUsageDiscount.adjustmentType + appliesToPriceIds = newUsageDiscount.appliesToPriceIds.map { it.toMutableList() } + usageDiscount = newUsageDiscount.usageDiscount + isInvoiceLevel = newUsageDiscount.isInvoiceLevel + additionalProperties = newUsageDiscount.additionalProperties.toMutableMap() + } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The set of price IDs to which this adjustment applies. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + fun usageDiscount(usageDiscount: Double) = usageDiscount(JsonField.of(usageDiscount)) + + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount + } + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will be + * applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(isInvoiceLevel: Boolean) = + isInvoiceLevel(JsonField.of(isInvoiceLevel)) + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will be + * applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): NewUsageDiscount = + NewUsageDiscount( + checkRequired("adjustmentType", adjustmentType), + checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, + checkRequired("usageDiscount", usageDiscount), + isInvoiceLevel, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_DISCOUNT = of("usage_discount") + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + /** An enum containing [AdjustmentType]'s known values. */ + enum class Known { + USAGE_DISCOUNT + } + + /** + * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AdjustmentType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_DISCOUNT, + /** + * An enum member indicating that [AdjustmentType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_DISCOUNT -> Value.USAGE_DISCOUNT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_DISCOUNT -> Known.USAGE_DISCOUNT + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewUsageDiscount && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && usageDiscount == other.usageDiscount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(adjustmentType, appliesToPriceIds, usageDiscount, isInvoiceLevel, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewUsageDiscount{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, usageDiscount=$usageDiscount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewAmountDiscount + @JsonCreator + private constructor( + @JsonProperty("adjustment_type") + @ExcludeMissing + private val adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("amount_discount") + @ExcludeMissing + private val amountDiscount: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + private val isInvoiceLevel: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will be + * applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(): Optional = + Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType + + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount(): JsonField = amountDiscount + + /** The set of price IDs to which this adjustment applies. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will be + * applied at the invoice level, possibly to multiple prices. + */ + @JsonProperty("is_invoice_level") + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewAmountDiscount = apply { + if (validated) { + return@apply + } + + adjustmentType() + amountDiscount() + appliesToPriceIds() + isInvoiceLevel() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [NewAmountDiscount]. + * + * The following fields are required: + * ```java + * .adjustmentType() + * .amountDiscount() + * .appliesToPriceIds() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewAmountDiscount]. */ + class Builder internal constructor() { + + private var adjustmentType: JsonField? = null + private var amountDiscount: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(newAmountDiscount: NewAmountDiscount) = apply { + adjustmentType = newAmountDiscount.adjustmentType + amountDiscount = newAmountDiscount.amountDiscount + appliesToPriceIds = newAmountDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = newAmountDiscount.isInvoiceLevel + additionalProperties = newAmountDiscount.additionalProperties.toMutableMap() + } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + fun amountDiscount(amountDiscount: String) = + amountDiscount(JsonField.of(amountDiscount)) + + fun amountDiscount(amountDiscount: JsonField) = apply { + this.amountDiscount = amountDiscount + } + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The set of price IDs to which this adjustment applies. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will be + * applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(isInvoiceLevel: Boolean) = + isInvoiceLevel(JsonField.of(isInvoiceLevel)) + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will be + * applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): NewAmountDiscount = + NewAmountDiscount( + checkRequired("adjustmentType", adjustmentType), + checkRequired("amountDiscount", amountDiscount), + checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, + isInvoiceLevel, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val AMOUNT_DISCOUNT = of("amount_discount") + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + /** An enum containing [AdjustmentType]'s known values. */ + enum class Known { + AMOUNT_DISCOUNT + } + + /** + * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AdjustmentType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AMOUNT_DISCOUNT, + /** + * An enum member indicating that [AdjustmentType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewAmountDiscount && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(adjustmentType, amountDiscount, appliesToPriceIds, isInvoiceLevel, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewAmountDiscount{adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewMinimum + @JsonCreator + private constructor( + @JsonProperty("adjustment_type") + @ExcludeMissing + private val adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + private val isInvoiceLevel: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The item ID that revenue from this minimum will be attributed to. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will be + * applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(): Optional = + Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType + + /** The set of price IDs to which this adjustment applies. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** The item ID that revenue from this minimum will be attributed to. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will be + * applied at the invoice level, possibly to multiple prices. + */ + @JsonProperty("is_invoice_level") + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewMinimum = apply { + if (validated) { + return@apply + } + + adjustmentType() + appliesToPriceIds() + itemId() + minimumAmount() + isInvoiceLevel() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [NewMinimum]. + * + * The following fields are required: + * ```java + * .adjustmentType() + * .appliesToPriceIds() + * .itemId() + * .minimumAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewMinimum]. */ + class Builder internal constructor() { + + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var itemId: JsonField? = null + private var minimumAmount: JsonField? = null + private var isInvoiceLevel: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(newMinimum: NewMinimum) = apply { + adjustmentType = newMinimum.adjustmentType + appliesToPriceIds = newMinimum.appliesToPriceIds.map { it.toMutableList() } + itemId = newMinimum.itemId + minimumAmount = newMinimum.minimumAmount + isInvoiceLevel = newMinimum.isInvoiceLevel + additionalProperties = newMinimum.additionalProperties.toMutableMap() + } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The set of price IDs to which this adjustment applies. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** The item ID that revenue from this minimum will be attributed to. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** The item ID that revenue from this minimum will be attributed to. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will be + * applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(isInvoiceLevel: Boolean) = + isInvoiceLevel(JsonField.of(isInvoiceLevel)) + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will be + * applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): NewMinimum = + NewMinimum( + checkRequired("adjustmentType", adjustmentType), + checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, + checkRequired("itemId", itemId), + checkRequired("minimumAmount", minimumAmount), + isInvoiceLevel, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val MINIMUM = of("minimum") + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + /** An enum containing [AdjustmentType]'s known values. */ + enum class Known { + MINIMUM + } + + /** + * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AdjustmentType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MINIMUM, + /** + * An enum member indicating that [AdjustmentType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MINIMUM -> Value.MINIMUM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MINIMUM -> Known.MINIMUM + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewMinimum && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && itemId == other.itemId && minimumAmount == other.minimumAmount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(adjustmentType, appliesToPriceIds, itemId, minimumAmount, isInvoiceLevel, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewMinimum{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, itemId=$itemId, minimumAmount=$minimumAmount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewMaximum + @JsonCreator + private constructor( + @JsonProperty("adjustment_type") + @ExcludeMissing + private val adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + private val isInvoiceLevel: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will be + * applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(): Optional = + Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) + + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType + + /** The set of price IDs to which this adjustment applies. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will be + * applied at the invoice level, possibly to multiple prices. + */ + @JsonProperty("is_invoice_level") + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewMaximum = apply { + if (validated) { + return@apply + } + + adjustmentType() + appliesToPriceIds() + maximumAmount() + isInvoiceLevel() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [NewMaximum]. + * + * The following fields are required: + * ```java + * .adjustmentType() + * .appliesToPriceIds() + * .maximumAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewMaximum]. */ + class Builder internal constructor() { + + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var maximumAmount: JsonField? = null + private var isInvoiceLevel: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(newMaximum: NewMaximum) = apply { + adjustmentType = newMaximum.adjustmentType + appliesToPriceIds = newMaximum.appliesToPriceIds.map { it.toMutableList() } + maximumAmount = newMaximum.maximumAmount + isInvoiceLevel = newMaximum.isInvoiceLevel + additionalProperties = newMaximum.additionalProperties.toMutableMap() + } + + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + fun adjustmentType(adjustmentType: JsonField) = apply { + this.adjustmentType = adjustmentType + } + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The set of price IDs to which this adjustment applies. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) + + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will be + * applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(isInvoiceLevel: Boolean) = + isInvoiceLevel(JsonField.of(isInvoiceLevel)) + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will be + * applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): NewMaximum = + NewMaximum( + checkRequired("adjustmentType", adjustmentType), + checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, + checkRequired("maximumAmount", maximumAmount), + isInvoiceLevel, + additionalProperties.toImmutable(), + ) + } + + class AdjustmentType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val MAXIMUM = of("maximum") + + @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) + } + + /** An enum containing [AdjustmentType]'s known values. */ + enum class Known { + MAXIMUM + } + + /** + * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AdjustmentType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MAXIMUM, + /** + * An enum member indicating that [AdjustmentType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MAXIMUM -> Value.MAXIMUM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MAXIMUM -> Known.MAXIMUM + else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewMaximum && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(adjustmentType, appliesToPriceIds, maximumAmount, isInvoiceLevel, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewMaximum{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAllocationPriceModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAllocationPriceModel.kt new file mode 100644 index 000000000..6fca251cb --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewAllocationPriceModel.kt @@ -0,0 +1,337 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Objects + +@NoAutoDetect +class NewAllocationPriceModel +@JsonCreator +private constructor( + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("expires_at_end_of_cadence") + @ExcludeMissing + private val expiresAtEndOfCadence: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** An amount of the currency to allocate to the customer at the specified cadence. */ + fun amount(): String = amount.getRequired("amount") + + /** The cadence at which to allocate the amount to the customer. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * An ISO 4217 currency string or a custom pricing unit identifier in which to bill this price. + */ + fun currency(): String = currency.getRequired("currency") + + /** + * Whether the allocated amount should expire at the end of the cadence or roll over to the next + * period. + */ + fun expiresAtEndOfCadence(): Boolean = + expiresAtEndOfCadence.getRequired("expires_at_end_of_cadence") + + /** An amount of the currency to allocate to the customer at the specified cadence. */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** The cadence at which to allocate the amount to the customer. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** + * An ISO 4217 currency string or a custom pricing unit identifier in which to bill this price. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Whether the allocated amount should expire at the end of the cadence or roll over to the next + * period. + */ + @JsonProperty("expires_at_end_of_cadence") + @ExcludeMissing + fun _expiresAtEndOfCadence(): JsonField = expiresAtEndOfCadence + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewAllocationPriceModel = apply { + if (validated) { + return@apply + } + + amount() + cadence() + currency() + expiresAtEndOfCadence() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [NewAllocationPriceModel]. + * + * The following fields are required: + * ```java + * .amount() + * .cadence() + * .currency() + * .expiresAtEndOfCadence() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewAllocationPriceModel]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var expiresAtEndOfCadence: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(newAllocationPriceModel: NewAllocationPriceModel) = apply { + amount = newAllocationPriceModel.amount + cadence = newAllocationPriceModel.cadence + currency = newAllocationPriceModel.currency + expiresAtEndOfCadence = newAllocationPriceModel.expiresAtEndOfCadence + additionalProperties = newAllocationPriceModel.additionalProperties.toMutableMap() + } + + /** An amount of the currency to allocate to the customer at the specified cadence. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** An amount of the currency to allocate to the customer at the specified cadence. */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The cadence at which to allocate the amount to the customer. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence at which to allocate the amount to the customer. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** + * An ISO 4217 currency string or a custom pricing unit identifier in which to bill this + * price. + */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * An ISO 4217 currency string or a custom pricing unit identifier in which to bill this + * price. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** + * Whether the allocated amount should expire at the end of the cadence or roll over to the + * next period. + */ + fun expiresAtEndOfCadence(expiresAtEndOfCadence: Boolean) = + expiresAtEndOfCadence(JsonField.of(expiresAtEndOfCadence)) + + /** + * Whether the allocated amount should expire at the end of the cadence or roll over to the + * next period. + */ + fun expiresAtEndOfCadence(expiresAtEndOfCadence: JsonField) = apply { + this.expiresAtEndOfCadence = expiresAtEndOfCadence + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): NewAllocationPriceModel = + NewAllocationPriceModel( + checkRequired("amount", amount), + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("expiresAtEndOfCadence", expiresAtEndOfCadence), + additionalProperties.toImmutable(), + ) + } + + /** The cadence at which to allocate the amount to the customer. */ + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewAllocationPriceModel && amount == other.amount && cadence == other.cadence && currency == other.currency && expiresAtEndOfCadence == other.expiresAtEndOfCadence && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(amount, cadence, currency, expiresAtEndOfCadence, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewAllocationPriceModel{amount=$amount, cadence=$cadence, currency=$currency, expiresAtEndOfCadence=$expiresAtEndOfCadence, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewBillingCycleConfigurationModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewBillingCycleConfigurationModel.kt new file mode 100644 index 000000000..24edb869a --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewBillingCycleConfigurationModel.kt @@ -0,0 +1,255 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Objects + +@NoAutoDetect +class NewBillingCycleConfigurationModel +@JsonCreator +private constructor( + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** The duration of the billing period. */ + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewBillingCycleConfigurationModel = apply { + if (validated) { + return@apply + } + + duration() + durationUnit() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewBillingCycleConfigurationModel]. + * + * The following fields are required: + * ```java + * .duration() + * .durationUnit() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewBillingCycleConfigurationModel]. */ + class Builder internal constructor() { + + private var duration: JsonField? = null + private var durationUnit: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(newBillingCycleConfigurationModel: NewBillingCycleConfigurationModel) = + apply { + duration = newBillingCycleConfigurationModel.duration + durationUnit = newBillingCycleConfigurationModel.durationUnit + additionalProperties = + newBillingCycleConfigurationModel.additionalProperties.toMutableMap() + } + + /** The duration of the billing period. */ + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { + this.durationUnit = durationUnit + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): NewBillingCycleConfigurationModel = + NewBillingCycleConfigurationModel( + checkRequired("duration", duration), + checkRequired("durationUnit", durationUnit), + additionalProperties.toImmutable(), + ) + } + + /** The unit of billing period duration. */ + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val DAY = of("day") + + @JvmField val MONTH = of("month") + + @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) + } + + /** An enum containing [DurationUnit]'s known values. */ + enum class Known { + DAY, + MONTH, + } + + /** + * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [DurationUnit] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + DAY, + MONTH, + /** + * An enum member indicating that [DurationUnit] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + DAY -> Value.DAY + MONTH -> Value.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) { + DAY -> Known.DAY + MONTH -> Known.MONTH + else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if 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 + } + + return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewBillingCycleConfigurationModel && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewBillingCycleConfigurationModel{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingPriceModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingPriceModel.kt new file mode 100644 index 000000000..bc5ad5c1e --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewFloatingPriceModel.kt @@ -0,0 +1,25829 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.BaseDeserializer +import com.withorb.api.core.BaseSerializer +import com.withorb.api.core.Enum +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.getOrThrow +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +@JsonDeserialize(using = NewFloatingPriceModel.Deserializer::class) +@JsonSerialize(using = NewFloatingPriceModel.Serializer::class) +class NewFloatingPriceModel +private constructor( + private val unitPrice: NewFloatingUnitPrice? = null, + private val packagePrice: NewFloatingPackagePrice? = null, + private val matrixPrice: NewFloatingMatrixPrice? = null, + private val matrixWithAllocationPrice: NewFloatingMatrixWithAllocationPrice? = null, + private val tieredPrice: NewFloatingTieredPrice? = null, + private val tieredBpsPrice: NewFloatingTieredBpsPrice? = null, + private val bpsPrice: NewFloatingBpsPrice? = null, + private val bulkBpsPrice: NewFloatingBulkBpsPrice? = null, + private val bulkPrice: NewFloatingBulkPrice? = null, + private val thresholdTotalAmountPrice: NewFloatingThresholdTotalAmountPrice? = null, + private val tieredPackagePrice: NewFloatingTieredPackagePrice? = null, + private val groupedTieredPrice: NewFloatingGroupedTieredPrice? = null, + private val maxGroupTieredPackagePrice: NewFloatingMaxGroupTieredPackagePrice? = null, + private val tieredWithMinimumPrice: NewFloatingTieredWithMinimumPrice? = null, + private val packageWithAllocationPrice: NewFloatingPackageWithAllocationPrice? = null, + private val tieredPackageWithMinimumPrice: NewFloatingTieredPackageWithMinimumPrice? = null, + private val unitWithPercentPrice: NewFloatingUnitWithPercentPrice? = null, + private val tieredWithProrationPrice: NewFloatingTieredWithProrationPrice? = null, + private val unitWithProrationPrice: NewFloatingUnitWithProrationPrice? = null, + private val groupedAllocationPrice: NewFloatingGroupedAllocationPrice? = null, + private val groupedWithProratedMinimumPrice: NewFloatingGroupedWithProratedMinimumPrice? = null, + private val groupedWithMeteredMinimumPrice: NewFloatingGroupedWithMeteredMinimumPrice? = null, + private val matrixWithDisplayNamePrice: NewFloatingMatrixWithDisplayNamePrice? = null, + private val bulkWithProrationPrice: NewFloatingBulkWithProrationPrice? = null, + private val groupedTieredPackagePrice: NewFloatingGroupedTieredPackagePrice? = null, + private val scalableMatrixWithUnitPricingPrice: NewFloatingScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricingPrice: + NewFloatingScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulkPrice: NewFloatingCumulativeGroupedBulkPrice? = null, + private val _json: JsonValue? = null, +) { + + fun unitPrice(): Optional = Optional.ofNullable(unitPrice) + + fun packagePrice(): Optional = Optional.ofNullable(packagePrice) + + fun matrixPrice(): Optional = Optional.ofNullable(matrixPrice) + + fun matrixWithAllocationPrice(): Optional = + Optional.ofNullable(matrixWithAllocationPrice) + + fun tieredPrice(): Optional = Optional.ofNullable(tieredPrice) + + fun tieredBpsPrice(): Optional = Optional.ofNullable(tieredBpsPrice) + + fun bpsPrice(): Optional = Optional.ofNullable(bpsPrice) + + fun bulkBpsPrice(): Optional = Optional.ofNullable(bulkBpsPrice) + + fun bulkPrice(): Optional = Optional.ofNullable(bulkPrice) + + fun thresholdTotalAmountPrice(): Optional = + Optional.ofNullable(thresholdTotalAmountPrice) + + fun tieredPackagePrice(): Optional = + Optional.ofNullable(tieredPackagePrice) + + fun groupedTieredPrice(): Optional = + Optional.ofNullable(groupedTieredPrice) + + fun maxGroupTieredPackagePrice(): Optional = + Optional.ofNullable(maxGroupTieredPackagePrice) + + fun tieredWithMinimumPrice(): Optional = + Optional.ofNullable(tieredWithMinimumPrice) + + fun packageWithAllocationPrice(): Optional = + Optional.ofNullable(packageWithAllocationPrice) + + fun tieredPackageWithMinimumPrice(): Optional = + Optional.ofNullable(tieredPackageWithMinimumPrice) + + fun unitWithPercentPrice(): Optional = + Optional.ofNullable(unitWithPercentPrice) + + fun tieredWithProrationPrice(): Optional = + Optional.ofNullable(tieredWithProrationPrice) + + fun unitWithProrationPrice(): Optional = + Optional.ofNullable(unitWithProrationPrice) + + fun groupedAllocationPrice(): Optional = + Optional.ofNullable(groupedAllocationPrice) + + fun groupedWithProratedMinimumPrice(): Optional = + Optional.ofNullable(groupedWithProratedMinimumPrice) + + fun groupedWithMeteredMinimumPrice(): Optional = + Optional.ofNullable(groupedWithMeteredMinimumPrice) + + fun matrixWithDisplayNamePrice(): Optional = + Optional.ofNullable(matrixWithDisplayNamePrice) + + fun bulkWithProrationPrice(): Optional = + Optional.ofNullable(bulkWithProrationPrice) + + fun groupedTieredPackagePrice(): Optional = + Optional.ofNullable(groupedTieredPackagePrice) + + fun scalableMatrixWithUnitPricingPrice(): + Optional = + Optional.ofNullable(scalableMatrixWithUnitPricingPrice) + + fun scalableMatrixWithTieredPricingPrice(): + Optional = + Optional.ofNullable(scalableMatrixWithTieredPricingPrice) + + fun cumulativeGroupedBulkPrice(): Optional = + Optional.ofNullable(cumulativeGroupedBulkPrice) + + fun isUnitPrice(): Boolean = unitPrice != null + + fun isPackagePrice(): Boolean = packagePrice != null + + fun isMatrixPrice(): Boolean = matrixPrice != null + + fun isMatrixWithAllocationPrice(): Boolean = matrixWithAllocationPrice != null + + fun isTieredPrice(): Boolean = tieredPrice != null + + fun isTieredBpsPrice(): Boolean = tieredBpsPrice != null + + fun isBpsPrice(): Boolean = bpsPrice != null + + fun isBulkBpsPrice(): Boolean = bulkBpsPrice != null + + fun isBulkPrice(): Boolean = bulkPrice != null + + fun isThresholdTotalAmountPrice(): Boolean = thresholdTotalAmountPrice != null + + fun isTieredPackagePrice(): Boolean = tieredPackagePrice != null + + fun isGroupedTieredPrice(): Boolean = groupedTieredPrice != null + + fun isMaxGroupTieredPackagePrice(): Boolean = maxGroupTieredPackagePrice != null + + fun isTieredWithMinimumPrice(): Boolean = tieredWithMinimumPrice != null + + fun isPackageWithAllocationPrice(): Boolean = packageWithAllocationPrice != null + + fun isTieredPackageWithMinimumPrice(): Boolean = tieredPackageWithMinimumPrice != null + + fun isUnitWithPercentPrice(): Boolean = unitWithPercentPrice != null + + fun isTieredWithProrationPrice(): Boolean = tieredWithProrationPrice != null + + fun isUnitWithProrationPrice(): Boolean = unitWithProrationPrice != null + + fun isGroupedAllocationPrice(): Boolean = groupedAllocationPrice != null + + fun isGroupedWithProratedMinimumPrice(): Boolean = groupedWithProratedMinimumPrice != null + + fun isGroupedWithMeteredMinimumPrice(): Boolean = groupedWithMeteredMinimumPrice != null + + fun isMatrixWithDisplayNamePrice(): Boolean = matrixWithDisplayNamePrice != null + + fun isBulkWithProrationPrice(): Boolean = bulkWithProrationPrice != null + + fun isGroupedTieredPackagePrice(): Boolean = groupedTieredPackagePrice != null + + fun isScalableMatrixWithUnitPricingPrice(): Boolean = scalableMatrixWithUnitPricingPrice != null + + fun isScalableMatrixWithTieredPricingPrice(): Boolean = + scalableMatrixWithTieredPricingPrice != null + + fun isCumulativeGroupedBulkPrice(): Boolean = cumulativeGroupedBulkPrice != null + + fun asUnitPrice(): NewFloatingUnitPrice = unitPrice.getOrThrow("unitPrice") + + fun asPackagePrice(): NewFloatingPackagePrice = packagePrice.getOrThrow("packagePrice") + + fun asMatrixPrice(): NewFloatingMatrixPrice = matrixPrice.getOrThrow("matrixPrice") + + fun asMatrixWithAllocationPrice(): NewFloatingMatrixWithAllocationPrice = + matrixWithAllocationPrice.getOrThrow("matrixWithAllocationPrice") + + fun asTieredPrice(): NewFloatingTieredPrice = tieredPrice.getOrThrow("tieredPrice") + + fun asTieredBpsPrice(): NewFloatingTieredBpsPrice = tieredBpsPrice.getOrThrow("tieredBpsPrice") + + fun asBpsPrice(): NewFloatingBpsPrice = bpsPrice.getOrThrow("bpsPrice") + + fun asBulkBpsPrice(): NewFloatingBulkBpsPrice = bulkBpsPrice.getOrThrow("bulkBpsPrice") + + fun asBulkPrice(): NewFloatingBulkPrice = bulkPrice.getOrThrow("bulkPrice") + + fun asThresholdTotalAmountPrice(): NewFloatingThresholdTotalAmountPrice = + thresholdTotalAmountPrice.getOrThrow("thresholdTotalAmountPrice") + + fun asTieredPackagePrice(): NewFloatingTieredPackagePrice = + tieredPackagePrice.getOrThrow("tieredPackagePrice") + + fun asGroupedTieredPrice(): NewFloatingGroupedTieredPrice = + groupedTieredPrice.getOrThrow("groupedTieredPrice") + + fun asMaxGroupTieredPackagePrice(): NewFloatingMaxGroupTieredPackagePrice = + maxGroupTieredPackagePrice.getOrThrow("maxGroupTieredPackagePrice") + + fun asTieredWithMinimumPrice(): NewFloatingTieredWithMinimumPrice = + tieredWithMinimumPrice.getOrThrow("tieredWithMinimumPrice") + + fun asPackageWithAllocationPrice(): NewFloatingPackageWithAllocationPrice = + packageWithAllocationPrice.getOrThrow("packageWithAllocationPrice") + + fun asTieredPackageWithMinimumPrice(): NewFloatingTieredPackageWithMinimumPrice = + tieredPackageWithMinimumPrice.getOrThrow("tieredPackageWithMinimumPrice") + + fun asUnitWithPercentPrice(): NewFloatingUnitWithPercentPrice = + unitWithPercentPrice.getOrThrow("unitWithPercentPrice") + + fun asTieredWithProrationPrice(): NewFloatingTieredWithProrationPrice = + tieredWithProrationPrice.getOrThrow("tieredWithProrationPrice") + + fun asUnitWithProrationPrice(): NewFloatingUnitWithProrationPrice = + unitWithProrationPrice.getOrThrow("unitWithProrationPrice") + + fun asGroupedAllocationPrice(): NewFloatingGroupedAllocationPrice = + groupedAllocationPrice.getOrThrow("groupedAllocationPrice") + + fun asGroupedWithProratedMinimumPrice(): NewFloatingGroupedWithProratedMinimumPrice = + groupedWithProratedMinimumPrice.getOrThrow("groupedWithProratedMinimumPrice") + + fun asGroupedWithMeteredMinimumPrice(): NewFloatingGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimumPrice.getOrThrow("groupedWithMeteredMinimumPrice") + + fun asMatrixWithDisplayNamePrice(): NewFloatingMatrixWithDisplayNamePrice = + matrixWithDisplayNamePrice.getOrThrow("matrixWithDisplayNamePrice") + + fun asBulkWithProrationPrice(): NewFloatingBulkWithProrationPrice = + bulkWithProrationPrice.getOrThrow("bulkWithProrationPrice") + + fun asGroupedTieredPackagePrice(): NewFloatingGroupedTieredPackagePrice = + groupedTieredPackagePrice.getOrThrow("groupedTieredPackagePrice") + + fun asScalableMatrixWithUnitPricingPrice(): NewFloatingScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricingPrice.getOrThrow("scalableMatrixWithUnitPricingPrice") + + fun asScalableMatrixWithTieredPricingPrice(): NewFloatingScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricingPrice.getOrThrow("scalableMatrixWithTieredPricingPrice") + + fun asCumulativeGroupedBulkPrice(): NewFloatingCumulativeGroupedBulkPrice = + cumulativeGroupedBulkPrice.getOrThrow("cumulativeGroupedBulkPrice") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + unitPrice != null -> visitor.visitUnitPrice(unitPrice) + packagePrice != null -> visitor.visitPackagePrice(packagePrice) + matrixPrice != null -> visitor.visitMatrixPrice(matrixPrice) + matrixWithAllocationPrice != null -> + visitor.visitMatrixWithAllocationPrice(matrixWithAllocationPrice) + tieredPrice != null -> visitor.visitTieredPrice(tieredPrice) + tieredBpsPrice != null -> visitor.visitTieredBpsPrice(tieredBpsPrice) + bpsPrice != null -> visitor.visitBpsPrice(bpsPrice) + bulkBpsPrice != null -> visitor.visitBulkBpsPrice(bulkBpsPrice) + bulkPrice != null -> visitor.visitBulkPrice(bulkPrice) + thresholdTotalAmountPrice != null -> + visitor.visitThresholdTotalAmountPrice(thresholdTotalAmountPrice) + tieredPackagePrice != null -> visitor.visitTieredPackagePrice(tieredPackagePrice) + groupedTieredPrice != null -> visitor.visitGroupedTieredPrice(groupedTieredPrice) + maxGroupTieredPackagePrice != null -> + visitor.visitMaxGroupTieredPackagePrice(maxGroupTieredPackagePrice) + tieredWithMinimumPrice != null -> + visitor.visitTieredWithMinimumPrice(tieredWithMinimumPrice) + packageWithAllocationPrice != null -> + visitor.visitPackageWithAllocationPrice(packageWithAllocationPrice) + tieredPackageWithMinimumPrice != null -> + visitor.visitTieredPackageWithMinimumPrice(tieredPackageWithMinimumPrice) + unitWithPercentPrice != null -> visitor.visitUnitWithPercentPrice(unitWithPercentPrice) + tieredWithProrationPrice != null -> + visitor.visitTieredWithProrationPrice(tieredWithProrationPrice) + unitWithProrationPrice != null -> + visitor.visitUnitWithProrationPrice(unitWithProrationPrice) + groupedAllocationPrice != null -> + visitor.visitGroupedAllocationPrice(groupedAllocationPrice) + groupedWithProratedMinimumPrice != null -> + visitor.visitGroupedWithProratedMinimumPrice(groupedWithProratedMinimumPrice) + groupedWithMeteredMinimumPrice != null -> + visitor.visitGroupedWithMeteredMinimumPrice(groupedWithMeteredMinimumPrice) + matrixWithDisplayNamePrice != null -> + visitor.visitMatrixWithDisplayNamePrice(matrixWithDisplayNamePrice) + bulkWithProrationPrice != null -> + visitor.visitBulkWithProrationPrice(bulkWithProrationPrice) + groupedTieredPackagePrice != null -> + visitor.visitGroupedTieredPackagePrice(groupedTieredPackagePrice) + scalableMatrixWithUnitPricingPrice != null -> + visitor.visitScalableMatrixWithUnitPricingPrice(scalableMatrixWithUnitPricingPrice) + scalableMatrixWithTieredPricingPrice != null -> + visitor.visitScalableMatrixWithTieredPricingPrice( + scalableMatrixWithTieredPricingPrice + ) + cumulativeGroupedBulkPrice != null -> + visitor.visitCumulativeGroupedBulkPrice(cumulativeGroupedBulkPrice) + else -> visitor.unknown(_json) + } + } + + private var validated: Boolean = false + + fun validate(): NewFloatingPriceModel = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnitPrice(unitPrice: NewFloatingUnitPrice) { + unitPrice.validate() + } + + override fun visitPackagePrice(packagePrice: NewFloatingPackagePrice) { + packagePrice.validate() + } + + override fun visitMatrixPrice(matrixPrice: NewFloatingMatrixPrice) { + matrixPrice.validate() + } + + override fun visitMatrixWithAllocationPrice( + matrixWithAllocationPrice: NewFloatingMatrixWithAllocationPrice + ) { + matrixWithAllocationPrice.validate() + } + + override fun visitTieredPrice(tieredPrice: NewFloatingTieredPrice) { + tieredPrice.validate() + } + + override fun visitTieredBpsPrice(tieredBpsPrice: NewFloatingTieredBpsPrice) { + tieredBpsPrice.validate() + } + + override fun visitBpsPrice(bpsPrice: NewFloatingBpsPrice) { + bpsPrice.validate() + } + + override fun visitBulkBpsPrice(bulkBpsPrice: NewFloatingBulkBpsPrice) { + bulkBpsPrice.validate() + } + + override fun visitBulkPrice(bulkPrice: NewFloatingBulkPrice) { + bulkPrice.validate() + } + + override fun visitThresholdTotalAmountPrice( + thresholdTotalAmountPrice: NewFloatingThresholdTotalAmountPrice + ) { + thresholdTotalAmountPrice.validate() + } + + override fun visitTieredPackagePrice( + tieredPackagePrice: NewFloatingTieredPackagePrice + ) { + tieredPackagePrice.validate() + } + + override fun visitGroupedTieredPrice( + groupedTieredPrice: NewFloatingGroupedTieredPrice + ) { + groupedTieredPrice.validate() + } + + override fun visitMaxGroupTieredPackagePrice( + maxGroupTieredPackagePrice: NewFloatingMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackagePrice.validate() + } + + override fun visitTieredWithMinimumPrice( + tieredWithMinimumPrice: NewFloatingTieredWithMinimumPrice + ) { + tieredWithMinimumPrice.validate() + } + + override fun visitPackageWithAllocationPrice( + packageWithAllocationPrice: NewFloatingPackageWithAllocationPrice + ) { + packageWithAllocationPrice.validate() + } + + override fun visitTieredPackageWithMinimumPrice( + tieredPackageWithMinimumPrice: NewFloatingTieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimumPrice.validate() + } + + override fun visitUnitWithPercentPrice( + unitWithPercentPrice: NewFloatingUnitWithPercentPrice + ) { + unitWithPercentPrice.validate() + } + + override fun visitTieredWithProrationPrice( + tieredWithProrationPrice: NewFloatingTieredWithProrationPrice + ) { + tieredWithProrationPrice.validate() + } + + override fun visitUnitWithProrationPrice( + unitWithProrationPrice: NewFloatingUnitWithProrationPrice + ) { + unitWithProrationPrice.validate() + } + + override fun visitGroupedAllocationPrice( + groupedAllocationPrice: NewFloatingGroupedAllocationPrice + ) { + groupedAllocationPrice.validate() + } + + override fun visitGroupedWithProratedMinimumPrice( + groupedWithProratedMinimumPrice: NewFloatingGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimumPrice.validate() + } + + override fun visitGroupedWithMeteredMinimumPrice( + groupedWithMeteredMinimumPrice: NewFloatingGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimumPrice.validate() + } + + override fun visitMatrixWithDisplayNamePrice( + matrixWithDisplayNamePrice: NewFloatingMatrixWithDisplayNamePrice + ) { + matrixWithDisplayNamePrice.validate() + } + + override fun visitBulkWithProrationPrice( + bulkWithProrationPrice: NewFloatingBulkWithProrationPrice + ) { + bulkWithProrationPrice.validate() + } + + override fun visitGroupedTieredPackagePrice( + groupedTieredPackagePrice: NewFloatingGroupedTieredPackagePrice + ) { + groupedTieredPackagePrice.validate() + } + + override fun visitScalableMatrixWithUnitPricingPrice( + scalableMatrixWithUnitPricingPrice: + NewFloatingScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricingPrice.validate() + } + + override fun visitScalableMatrixWithTieredPricingPrice( + scalableMatrixWithTieredPricingPrice: + NewFloatingScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricingPrice.validate() + } + + override fun visitCumulativeGroupedBulkPrice( + cumulativeGroupedBulkPrice: NewFloatingCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulkPrice.validate() + } + } + ) + validated = true + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewFloatingPriceModel && unitPrice == other.unitPrice && packagePrice == other.packagePrice && matrixPrice == other.matrixPrice && matrixWithAllocationPrice == other.matrixWithAllocationPrice && tieredPrice == other.tieredPrice && tieredBpsPrice == other.tieredBpsPrice && bpsPrice == other.bpsPrice && bulkBpsPrice == other.bulkBpsPrice && bulkPrice == other.bulkPrice && thresholdTotalAmountPrice == other.thresholdTotalAmountPrice && tieredPackagePrice == other.tieredPackagePrice && groupedTieredPrice == other.groupedTieredPrice && maxGroupTieredPackagePrice == other.maxGroupTieredPackagePrice && tieredWithMinimumPrice == other.tieredWithMinimumPrice && packageWithAllocationPrice == other.packageWithAllocationPrice && tieredPackageWithMinimumPrice == other.tieredPackageWithMinimumPrice && unitWithPercentPrice == other.unitWithPercentPrice && tieredWithProrationPrice == other.tieredWithProrationPrice && unitWithProrationPrice == other.unitWithProrationPrice && groupedAllocationPrice == other.groupedAllocationPrice && groupedWithProratedMinimumPrice == other.groupedWithProratedMinimumPrice && groupedWithMeteredMinimumPrice == other.groupedWithMeteredMinimumPrice && matrixWithDisplayNamePrice == other.matrixWithDisplayNamePrice && bulkWithProrationPrice == other.bulkWithProrationPrice && groupedTieredPackagePrice == other.groupedTieredPackagePrice && scalableMatrixWithUnitPricingPrice == other.scalableMatrixWithUnitPricingPrice && scalableMatrixWithTieredPricingPrice == other.scalableMatrixWithTieredPricingPrice && cumulativeGroupedBulkPrice == other.cumulativeGroupedBulkPrice /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(unitPrice, packagePrice, matrixPrice, matrixWithAllocationPrice, tieredPrice, tieredBpsPrice, bpsPrice, bulkBpsPrice, bulkPrice, thresholdTotalAmountPrice, tieredPackagePrice, groupedTieredPrice, maxGroupTieredPackagePrice, tieredWithMinimumPrice, packageWithAllocationPrice, tieredPackageWithMinimumPrice, unitWithPercentPrice, tieredWithProrationPrice, unitWithProrationPrice, groupedAllocationPrice, groupedWithProratedMinimumPrice, groupedWithMeteredMinimumPrice, matrixWithDisplayNamePrice, bulkWithProrationPrice, groupedTieredPackagePrice, scalableMatrixWithUnitPricingPrice, scalableMatrixWithTieredPricingPrice, cumulativeGroupedBulkPrice) /* spotless:on */ + + override fun toString(): String = + when { + unitPrice != null -> "NewFloatingPriceModel{unitPrice=$unitPrice}" + packagePrice != null -> "NewFloatingPriceModel{packagePrice=$packagePrice}" + matrixPrice != null -> "NewFloatingPriceModel{matrixPrice=$matrixPrice}" + matrixWithAllocationPrice != null -> + "NewFloatingPriceModel{matrixWithAllocationPrice=$matrixWithAllocationPrice}" + tieredPrice != null -> "NewFloatingPriceModel{tieredPrice=$tieredPrice}" + tieredBpsPrice != null -> "NewFloatingPriceModel{tieredBpsPrice=$tieredBpsPrice}" + bpsPrice != null -> "NewFloatingPriceModel{bpsPrice=$bpsPrice}" + bulkBpsPrice != null -> "NewFloatingPriceModel{bulkBpsPrice=$bulkBpsPrice}" + bulkPrice != null -> "NewFloatingPriceModel{bulkPrice=$bulkPrice}" + thresholdTotalAmountPrice != null -> + "NewFloatingPriceModel{thresholdTotalAmountPrice=$thresholdTotalAmountPrice}" + tieredPackagePrice != null -> + "NewFloatingPriceModel{tieredPackagePrice=$tieredPackagePrice}" + groupedTieredPrice != null -> + "NewFloatingPriceModel{groupedTieredPrice=$groupedTieredPrice}" + maxGroupTieredPackagePrice != null -> + "NewFloatingPriceModel{maxGroupTieredPackagePrice=$maxGroupTieredPackagePrice}" + tieredWithMinimumPrice != null -> + "NewFloatingPriceModel{tieredWithMinimumPrice=$tieredWithMinimumPrice}" + packageWithAllocationPrice != null -> + "NewFloatingPriceModel{packageWithAllocationPrice=$packageWithAllocationPrice}" + tieredPackageWithMinimumPrice != null -> + "NewFloatingPriceModel{tieredPackageWithMinimumPrice=$tieredPackageWithMinimumPrice}" + unitWithPercentPrice != null -> + "NewFloatingPriceModel{unitWithPercentPrice=$unitWithPercentPrice}" + tieredWithProrationPrice != null -> + "NewFloatingPriceModel{tieredWithProrationPrice=$tieredWithProrationPrice}" + unitWithProrationPrice != null -> + "NewFloatingPriceModel{unitWithProrationPrice=$unitWithProrationPrice}" + groupedAllocationPrice != null -> + "NewFloatingPriceModel{groupedAllocationPrice=$groupedAllocationPrice}" + groupedWithProratedMinimumPrice != null -> + "NewFloatingPriceModel{groupedWithProratedMinimumPrice=$groupedWithProratedMinimumPrice}" + groupedWithMeteredMinimumPrice != null -> + "NewFloatingPriceModel{groupedWithMeteredMinimumPrice=$groupedWithMeteredMinimumPrice}" + matrixWithDisplayNamePrice != null -> + "NewFloatingPriceModel{matrixWithDisplayNamePrice=$matrixWithDisplayNamePrice}" + bulkWithProrationPrice != null -> + "NewFloatingPriceModel{bulkWithProrationPrice=$bulkWithProrationPrice}" + groupedTieredPackagePrice != null -> + "NewFloatingPriceModel{groupedTieredPackagePrice=$groupedTieredPackagePrice}" + scalableMatrixWithUnitPricingPrice != null -> + "NewFloatingPriceModel{scalableMatrixWithUnitPricingPrice=$scalableMatrixWithUnitPricingPrice}" + scalableMatrixWithTieredPricingPrice != null -> + "NewFloatingPriceModel{scalableMatrixWithTieredPricingPrice=$scalableMatrixWithTieredPricingPrice}" + cumulativeGroupedBulkPrice != null -> + "NewFloatingPriceModel{cumulativeGroupedBulkPrice=$cumulativeGroupedBulkPrice}" + _json != null -> "NewFloatingPriceModel{_unknown=$_json}" + else -> throw IllegalStateException("Invalid NewFloatingPriceModel") + } + + companion object { + + @JvmStatic + fun ofUnitPrice(unitPrice: NewFloatingUnitPrice) = + NewFloatingPriceModel(unitPrice = unitPrice) + + @JvmStatic + fun ofPackagePrice(packagePrice: NewFloatingPackagePrice) = + NewFloatingPriceModel(packagePrice = packagePrice) + + @JvmStatic + fun ofMatrixPrice(matrixPrice: NewFloatingMatrixPrice) = + NewFloatingPriceModel(matrixPrice = matrixPrice) + + @JvmStatic + fun ofMatrixWithAllocationPrice( + matrixWithAllocationPrice: NewFloatingMatrixWithAllocationPrice + ) = NewFloatingPriceModel(matrixWithAllocationPrice = matrixWithAllocationPrice) + + @JvmStatic + fun ofTieredPrice(tieredPrice: NewFloatingTieredPrice) = + NewFloatingPriceModel(tieredPrice = tieredPrice) + + @JvmStatic + fun ofTieredBpsPrice(tieredBpsPrice: NewFloatingTieredBpsPrice) = + NewFloatingPriceModel(tieredBpsPrice = tieredBpsPrice) + + @JvmStatic + fun ofBpsPrice(bpsPrice: NewFloatingBpsPrice) = NewFloatingPriceModel(bpsPrice = bpsPrice) + + @JvmStatic + fun ofBulkBpsPrice(bulkBpsPrice: NewFloatingBulkBpsPrice) = + NewFloatingPriceModel(bulkBpsPrice = bulkBpsPrice) + + @JvmStatic + fun ofBulkPrice(bulkPrice: NewFloatingBulkPrice) = + NewFloatingPriceModel(bulkPrice = bulkPrice) + + @JvmStatic + fun ofThresholdTotalAmountPrice( + thresholdTotalAmountPrice: NewFloatingThresholdTotalAmountPrice + ) = NewFloatingPriceModel(thresholdTotalAmountPrice = thresholdTotalAmountPrice) + + @JvmStatic + fun ofTieredPackagePrice(tieredPackagePrice: NewFloatingTieredPackagePrice) = + NewFloatingPriceModel(tieredPackagePrice = tieredPackagePrice) + + @JvmStatic + fun ofGroupedTieredPrice(groupedTieredPrice: NewFloatingGroupedTieredPrice) = + NewFloatingPriceModel(groupedTieredPrice = groupedTieredPrice) + + @JvmStatic + fun ofMaxGroupTieredPackagePrice( + maxGroupTieredPackagePrice: NewFloatingMaxGroupTieredPackagePrice + ) = NewFloatingPriceModel(maxGroupTieredPackagePrice = maxGroupTieredPackagePrice) + + @JvmStatic + fun ofTieredWithMinimumPrice(tieredWithMinimumPrice: NewFloatingTieredWithMinimumPrice) = + NewFloatingPriceModel(tieredWithMinimumPrice = tieredWithMinimumPrice) + + @JvmStatic + fun ofPackageWithAllocationPrice( + packageWithAllocationPrice: NewFloatingPackageWithAllocationPrice + ) = NewFloatingPriceModel(packageWithAllocationPrice = packageWithAllocationPrice) + + @JvmStatic + fun ofTieredPackageWithMinimumPrice( + tieredPackageWithMinimumPrice: NewFloatingTieredPackageWithMinimumPrice + ) = NewFloatingPriceModel(tieredPackageWithMinimumPrice = tieredPackageWithMinimumPrice) + + @JvmStatic + fun ofUnitWithPercentPrice(unitWithPercentPrice: NewFloatingUnitWithPercentPrice) = + NewFloatingPriceModel(unitWithPercentPrice = unitWithPercentPrice) + + @JvmStatic + fun ofTieredWithProrationPrice( + tieredWithProrationPrice: NewFloatingTieredWithProrationPrice + ) = NewFloatingPriceModel(tieredWithProrationPrice = tieredWithProrationPrice) + + @JvmStatic + fun ofUnitWithProrationPrice(unitWithProrationPrice: NewFloatingUnitWithProrationPrice) = + NewFloatingPriceModel(unitWithProrationPrice = unitWithProrationPrice) + + @JvmStatic + fun ofGroupedAllocationPrice(groupedAllocationPrice: NewFloatingGroupedAllocationPrice) = + NewFloatingPriceModel(groupedAllocationPrice = groupedAllocationPrice) + + @JvmStatic + fun ofGroupedWithProratedMinimumPrice( + groupedWithProratedMinimumPrice: NewFloatingGroupedWithProratedMinimumPrice + ) = NewFloatingPriceModel(groupedWithProratedMinimumPrice = groupedWithProratedMinimumPrice) + + @JvmStatic + fun ofGroupedWithMeteredMinimumPrice( + groupedWithMeteredMinimumPrice: NewFloatingGroupedWithMeteredMinimumPrice + ) = NewFloatingPriceModel(groupedWithMeteredMinimumPrice = groupedWithMeteredMinimumPrice) + + @JvmStatic + fun ofMatrixWithDisplayNamePrice( + matrixWithDisplayNamePrice: NewFloatingMatrixWithDisplayNamePrice + ) = NewFloatingPriceModel(matrixWithDisplayNamePrice = matrixWithDisplayNamePrice) + + @JvmStatic + fun ofBulkWithProrationPrice(bulkWithProrationPrice: NewFloatingBulkWithProrationPrice) = + NewFloatingPriceModel(bulkWithProrationPrice = bulkWithProrationPrice) + + @JvmStatic + fun ofGroupedTieredPackagePrice( + groupedTieredPackagePrice: NewFloatingGroupedTieredPackagePrice + ) = NewFloatingPriceModel(groupedTieredPackagePrice = groupedTieredPackagePrice) + + @JvmStatic + fun ofScalableMatrixWithUnitPricingPrice( + scalableMatrixWithUnitPricingPrice: NewFloatingScalableMatrixWithUnitPricingPrice + ) = + NewFloatingPriceModel( + scalableMatrixWithUnitPricingPrice = scalableMatrixWithUnitPricingPrice + ) + + @JvmStatic + fun ofScalableMatrixWithTieredPricingPrice( + scalableMatrixWithTieredPricingPrice: NewFloatingScalableMatrixWithTieredPricingPrice + ) = + NewFloatingPriceModel( + scalableMatrixWithTieredPricingPrice = scalableMatrixWithTieredPricingPrice + ) + + @JvmStatic + fun ofCumulativeGroupedBulkPrice( + cumulativeGroupedBulkPrice: NewFloatingCumulativeGroupedBulkPrice + ) = NewFloatingPriceModel(cumulativeGroupedBulkPrice = cumulativeGroupedBulkPrice) + } + + /** + * An interface that defines how to map each variant of [NewFloatingPriceModel] to a value of + * type [T]. + */ + interface Visitor { + + fun visitUnitPrice(unitPrice: NewFloatingUnitPrice): T + + fun visitPackagePrice(packagePrice: NewFloatingPackagePrice): T + + fun visitMatrixPrice(matrixPrice: NewFloatingMatrixPrice): T + + fun visitMatrixWithAllocationPrice( + matrixWithAllocationPrice: NewFloatingMatrixWithAllocationPrice + ): T + + fun visitTieredPrice(tieredPrice: NewFloatingTieredPrice): T + + fun visitTieredBpsPrice(tieredBpsPrice: NewFloatingTieredBpsPrice): T + + fun visitBpsPrice(bpsPrice: NewFloatingBpsPrice): T + + fun visitBulkBpsPrice(bulkBpsPrice: NewFloatingBulkBpsPrice): T + + fun visitBulkPrice(bulkPrice: NewFloatingBulkPrice): T + + fun visitThresholdTotalAmountPrice( + thresholdTotalAmountPrice: NewFloatingThresholdTotalAmountPrice + ): T + + fun visitTieredPackagePrice(tieredPackagePrice: NewFloatingTieredPackagePrice): T + + fun visitGroupedTieredPrice(groupedTieredPrice: NewFloatingGroupedTieredPrice): T + + fun visitMaxGroupTieredPackagePrice( + maxGroupTieredPackagePrice: NewFloatingMaxGroupTieredPackagePrice + ): T + + fun visitTieredWithMinimumPrice( + tieredWithMinimumPrice: NewFloatingTieredWithMinimumPrice + ): T + + fun visitPackageWithAllocationPrice( + packageWithAllocationPrice: NewFloatingPackageWithAllocationPrice + ): T + + fun visitTieredPackageWithMinimumPrice( + tieredPackageWithMinimumPrice: NewFloatingTieredPackageWithMinimumPrice + ): T + + fun visitUnitWithPercentPrice(unitWithPercentPrice: NewFloatingUnitWithPercentPrice): T + + fun visitTieredWithProrationPrice( + tieredWithProrationPrice: NewFloatingTieredWithProrationPrice + ): T + + fun visitUnitWithProrationPrice( + unitWithProrationPrice: NewFloatingUnitWithProrationPrice + ): T + + fun visitGroupedAllocationPrice( + groupedAllocationPrice: NewFloatingGroupedAllocationPrice + ): T + + fun visitGroupedWithProratedMinimumPrice( + groupedWithProratedMinimumPrice: NewFloatingGroupedWithProratedMinimumPrice + ): T + + fun visitGroupedWithMeteredMinimumPrice( + groupedWithMeteredMinimumPrice: NewFloatingGroupedWithMeteredMinimumPrice + ): T + + fun visitMatrixWithDisplayNamePrice( + matrixWithDisplayNamePrice: NewFloatingMatrixWithDisplayNamePrice + ): T + + fun visitBulkWithProrationPrice( + bulkWithProrationPrice: NewFloatingBulkWithProrationPrice + ): T + + fun visitGroupedTieredPackagePrice( + groupedTieredPackagePrice: NewFloatingGroupedTieredPackagePrice + ): T + + fun visitScalableMatrixWithUnitPricingPrice( + scalableMatrixWithUnitPricingPrice: NewFloatingScalableMatrixWithUnitPricingPrice + ): T + + fun visitScalableMatrixWithTieredPricingPrice( + scalableMatrixWithTieredPricingPrice: NewFloatingScalableMatrixWithTieredPricingPrice + ): T + + fun visitCumulativeGroupedBulkPrice( + cumulativeGroupedBulkPrice: NewFloatingCumulativeGroupedBulkPrice + ): T + + /** + * Maps an unknown variant of [NewFloatingPriceModel] to a value of type [T]. + * + * An instance of [NewFloatingPriceModel] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the SDK is + * on an older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown NewFloatingPriceModel: $json") + } + } + + internal class Deserializer : + BaseDeserializer(NewFloatingPriceModel::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): NewFloatingPriceModel { + val json = JsonValue.fromJsonNode(node) + val modelType = json.asObject().getOrNull()?.get("model_type")?.asString()?.getOrNull() + + when (modelType) { + "unit" -> { + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return NewFloatingPriceModel(unitPrice = it, _json = json) + } + } + "package" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return NewFloatingPriceModel(packagePrice = it, _json = json) + } + } + "matrix" -> { + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return NewFloatingPriceModel(matrixPrice = it, _json = json) + } + } + "matrix_with_allocation" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return NewFloatingPriceModel( + matrixWithAllocationPrice = it, + _json = json, + ) + } + } + "tiered" -> { + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return NewFloatingPriceModel(tieredPrice = it, _json = json) + } + } + "tiered_bps" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return NewFloatingPriceModel(tieredBpsPrice = it, _json = json) + } + } + "bps" -> { + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return NewFloatingPriceModel(bpsPrice = it, _json = json) + } + } + "bulk_bps" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return NewFloatingPriceModel(bulkBpsPrice = it, _json = json) + } + } + "bulk" -> { + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return NewFloatingPriceModel(bulkPrice = it, _json = json) + } + } + "threshold_total_amount" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return NewFloatingPriceModel( + thresholdTotalAmountPrice = it, + _json = json, + ) + } + } + "tiered_package" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return NewFloatingPriceModel(tieredPackagePrice = it, _json = json) + } + } + "grouped_tiered" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return NewFloatingPriceModel(groupedTieredPrice = it, _json = json) + } + } + "max_group_tiered_package" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return NewFloatingPriceModel( + maxGroupTieredPackagePrice = it, + _json = json, + ) + } + } + "tiered_with_minimum" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return NewFloatingPriceModel(tieredWithMinimumPrice = it, _json = json) + } + } + "package_with_allocation" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return NewFloatingPriceModel( + packageWithAllocationPrice = it, + _json = json, + ) + } + } + "tiered_package_with_minimum" -> { + tryDeserialize( + node, + jacksonTypeRef(), + ) { + it.validate() + } + ?.let { + return NewFloatingPriceModel( + tieredPackageWithMinimumPrice = it, + _json = json, + ) + } + } + "unit_with_percent" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return NewFloatingPriceModel(unitWithPercentPrice = it, _json = json) + } + } + "tiered_with_proration" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return NewFloatingPriceModel( + tieredWithProrationPrice = it, + _json = json, + ) + } + } + "unit_with_proration" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return NewFloatingPriceModel(unitWithProrationPrice = it, _json = json) + } + } + "grouped_allocation" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return NewFloatingPriceModel(groupedAllocationPrice = it, _json = json) + } + } + "grouped_with_prorated_minimum" -> { + tryDeserialize( + node, + jacksonTypeRef(), + ) { + it.validate() + } + ?.let { + return NewFloatingPriceModel( + groupedWithProratedMinimumPrice = it, + _json = json, + ) + } + } + "grouped_with_metered_minimum" -> { + tryDeserialize( + node, + jacksonTypeRef(), + ) { + it.validate() + } + ?.let { + return NewFloatingPriceModel( + groupedWithMeteredMinimumPrice = it, + _json = json, + ) + } + } + "matrix_with_display_name" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return NewFloatingPriceModel( + matrixWithDisplayNamePrice = it, + _json = json, + ) + } + } + "bulk_with_proration" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return NewFloatingPriceModel(bulkWithProrationPrice = it, _json = json) + } + } + "grouped_tiered_package" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return NewFloatingPriceModel( + groupedTieredPackagePrice = it, + _json = json, + ) + } + } + "scalable_matrix_with_unit_pricing" -> { + tryDeserialize( + node, + jacksonTypeRef(), + ) { + it.validate() + } + ?.let { + return NewFloatingPriceModel( + scalableMatrixWithUnitPricingPrice = it, + _json = json, + ) + } + } + "scalable_matrix_with_tiered_pricing" -> { + tryDeserialize( + node, + jacksonTypeRef(), + ) { + it.validate() + } + ?.let { + return NewFloatingPriceModel( + scalableMatrixWithTieredPricingPrice = it, + _json = json, + ) + } + } + "cumulative_grouped_bulk" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return NewFloatingPriceModel( + cumulativeGroupedBulkPrice = it, + _json = json, + ) + } + } + } + + return NewFloatingPriceModel(_json = json) + } + } + + internal class Serializer : + BaseSerializer(NewFloatingPriceModel::class) { + + override fun serialize( + value: NewFloatingPriceModel, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unitPrice != null -> generator.writeObject(value.unitPrice) + value.packagePrice != null -> generator.writeObject(value.packagePrice) + value.matrixPrice != null -> generator.writeObject(value.matrixPrice) + value.matrixWithAllocationPrice != null -> + generator.writeObject(value.matrixWithAllocationPrice) + value.tieredPrice != null -> generator.writeObject(value.tieredPrice) + value.tieredBpsPrice != null -> generator.writeObject(value.tieredBpsPrice) + value.bpsPrice != null -> generator.writeObject(value.bpsPrice) + value.bulkBpsPrice != null -> generator.writeObject(value.bulkBpsPrice) + value.bulkPrice != null -> generator.writeObject(value.bulkPrice) + value.thresholdTotalAmountPrice != null -> + generator.writeObject(value.thresholdTotalAmountPrice) + value.tieredPackagePrice != null -> generator.writeObject(value.tieredPackagePrice) + value.groupedTieredPrice != null -> generator.writeObject(value.groupedTieredPrice) + value.maxGroupTieredPackagePrice != null -> + generator.writeObject(value.maxGroupTieredPackagePrice) + value.tieredWithMinimumPrice != null -> + generator.writeObject(value.tieredWithMinimumPrice) + value.packageWithAllocationPrice != null -> + generator.writeObject(value.packageWithAllocationPrice) + value.tieredPackageWithMinimumPrice != null -> + generator.writeObject(value.tieredPackageWithMinimumPrice) + value.unitWithPercentPrice != null -> + generator.writeObject(value.unitWithPercentPrice) + value.tieredWithProrationPrice != null -> + generator.writeObject(value.tieredWithProrationPrice) + value.unitWithProrationPrice != null -> + generator.writeObject(value.unitWithProrationPrice) + value.groupedAllocationPrice != null -> + generator.writeObject(value.groupedAllocationPrice) + value.groupedWithProratedMinimumPrice != null -> + generator.writeObject(value.groupedWithProratedMinimumPrice) + value.groupedWithMeteredMinimumPrice != null -> + generator.writeObject(value.groupedWithMeteredMinimumPrice) + value.matrixWithDisplayNamePrice != null -> + generator.writeObject(value.matrixWithDisplayNamePrice) + value.bulkWithProrationPrice != null -> + generator.writeObject(value.bulkWithProrationPrice) + value.groupedTieredPackagePrice != null -> + generator.writeObject(value.groupedTieredPackagePrice) + value.scalableMatrixWithUnitPricingPrice != null -> + generator.writeObject(value.scalableMatrixWithUnitPricingPrice) + value.scalableMatrixWithTieredPricingPrice != null -> + generator.writeObject(value.scalableMatrixWithTieredPricingPrice) + value.cumulativeGroupedBulkPrice != null -> + generator.writeObject(value.cumulativeGroupedBulkPrice) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid NewFloatingPriceModel") + } + } + } + + @NoAutoDetect + class NewFloatingUnitPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("unit_config") + @ExcludeMissing + private val unitConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun unitConfig(): UnitConfigModel = unitConfig.getRequired("unit_config") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** An ISO 4217 currency string for which this price is billed in. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("unit_config") + @ExcludeMissing + fun _unitConfig(): JsonField = unitConfig + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewFloatingUnitPrice = apply { + if (validated) { + return@apply + } + + cadence() + currency() + itemId() + modelType() + name() + unitConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [NewFloatingUnitPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .currency() + * .itemId() + * .modelType() + * .name() + * .unitConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewFloatingUnitPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var 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 externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(newFloatingUnitPrice: NewFloatingUnitPrice) = apply { + cadence = newFloatingUnitPrice.cadence + currency = newFloatingUnitPrice.currency + itemId = newFloatingUnitPrice.itemId + modelType = newFloatingUnitPrice.modelType + name = newFloatingUnitPrice.name + unitConfig = newFloatingUnitPrice.unitConfig + billableMetricId = newFloatingUnitPrice.billableMetricId + billedInAdvance = newFloatingUnitPrice.billedInAdvance + billingCycleConfiguration = newFloatingUnitPrice.billingCycleConfiguration + conversionRate = newFloatingUnitPrice.conversionRate + externalPriceId = newFloatingUnitPrice.externalPriceId + fixedPriceQuantity = newFloatingUnitPrice.fixedPriceQuantity + invoiceGroupingKey = newFloatingUnitPrice.invoiceGroupingKey + invoicingCycleConfiguration = newFloatingUnitPrice.invoicingCycleConfiguration + metadata = newFloatingUnitPrice.metadata + additionalProperties = newFloatingUnitPrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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)) + + /** An ISO 4217 currency string for which this price is billed in. */ + 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)) + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun unitConfig(unitConfig: UnitConfigModel) = unitConfig(JsonField.of(unitConfig)) + + 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)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) + } + + fun build(): NewFloatingUnitPrice = + NewFloatingUnitPrice( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("unitConfig", unitConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewFloatingUnitPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && unitConfig == other.unitConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, unitConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingUnitPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingPackagePrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("package_config") + @ExcludeMissing + private val packageConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun packageConfig(): PackageConfigModel = packageConfig.getRequired("package_config") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** An ISO 4217 currency string for which this price is billed in. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("package_config") + @ExcludeMissing + fun _packageConfig(): JsonField = packageConfig + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewFloatingPackagePrice = apply { + if (validated) { + return@apply + } + + cadence() + currency() + itemId() + modelType() + name() + packageConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [NewFloatingPackagePrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .currency() + * .itemId() + * .modelType() + * .name() + * .packageConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewFloatingPackagePrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var packageConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(newFloatingPackagePrice: NewFloatingPackagePrice) = apply { + cadence = newFloatingPackagePrice.cadence + currency = newFloatingPackagePrice.currency + itemId = newFloatingPackagePrice.itemId + modelType = newFloatingPackagePrice.modelType + name = newFloatingPackagePrice.name + packageConfig = newFloatingPackagePrice.packageConfig + billableMetricId = newFloatingPackagePrice.billableMetricId + billedInAdvance = newFloatingPackagePrice.billedInAdvance + billingCycleConfiguration = newFloatingPackagePrice.billingCycleConfiguration + conversionRate = newFloatingPackagePrice.conversionRate + externalPriceId = newFloatingPackagePrice.externalPriceId + fixedPriceQuantity = newFloatingPackagePrice.fixedPriceQuantity + invoiceGroupingKey = newFloatingPackagePrice.invoiceGroupingKey + invoicingCycleConfiguration = newFloatingPackagePrice.invoicingCycleConfiguration + metadata = newFloatingPackagePrice.metadata + additionalProperties = newFloatingPackagePrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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)) + + /** An ISO 4217 currency string for which this price is billed in. */ + 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)) + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun packageConfig(packageConfig: PackageConfigModel) = + packageConfig(JsonField.of(packageConfig)) + + fun packageConfig(packageConfig: JsonField) = apply { + this.packageConfig = packageConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) + } + + fun build(): NewFloatingPackagePrice = + NewFloatingPackagePrice( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("packageConfig", packageConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PACKAGE = of("package") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + PACKAGE + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PACKAGE, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PACKAGE -> Value.PACKAGE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PACKAGE -> Known.PACKAGE + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewFloatingPackagePrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && packageConfig == other.packageConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, packageConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingPackagePrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingMatrixPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("matrix_config") + @ExcludeMissing + private val matrixConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun matrixConfig(): MatrixConfigModel = matrixConfig.getRequired("matrix_config") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** An ISO 4217 currency string for which this price is billed in. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("matrix_config") + @ExcludeMissing + fun _matrixConfig(): JsonField = matrixConfig + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewFloatingMatrixPrice = apply { + if (validated) { + return@apply + } + + cadence() + currency() + itemId() + matrixConfig().validate() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [NewFloatingMatrixPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .currency() + * .itemId() + * .matrixConfig() + * .modelType() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewFloatingMatrixPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var matrixConfig: JsonField? = null + private var modelType: JsonField? = null + private var 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 externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(newFloatingMatrixPrice: NewFloatingMatrixPrice) = apply { + cadence = newFloatingMatrixPrice.cadence + currency = newFloatingMatrixPrice.currency + itemId = newFloatingMatrixPrice.itemId + matrixConfig = newFloatingMatrixPrice.matrixConfig + modelType = newFloatingMatrixPrice.modelType + name = newFloatingMatrixPrice.name + billableMetricId = newFloatingMatrixPrice.billableMetricId + billedInAdvance = newFloatingMatrixPrice.billedInAdvance + billingCycleConfiguration = newFloatingMatrixPrice.billingCycleConfiguration + conversionRate = newFloatingMatrixPrice.conversionRate + externalPriceId = newFloatingMatrixPrice.externalPriceId + fixedPriceQuantity = newFloatingMatrixPrice.fixedPriceQuantity + invoiceGroupingKey = newFloatingMatrixPrice.invoiceGroupingKey + invoicingCycleConfiguration = newFloatingMatrixPrice.invoicingCycleConfiguration + metadata = newFloatingMatrixPrice.metadata + additionalProperties = newFloatingMatrixPrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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)) + + /** An ISO 4217 currency string for which this price is billed in. */ + 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)) + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun matrixConfig(matrixConfig: MatrixConfigModel) = + matrixConfig(JsonField.of(matrixConfig)) + + fun matrixConfig(matrixConfig: JsonField) = apply { + this.matrixConfig = matrixConfig + } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + 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)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) + } + + fun build(): NewFloatingMatrixPrice = + NewFloatingMatrixPrice( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + checkRequired("matrixConfig", matrixConfig), + checkRequired("modelType", modelType), + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val MATRIX = of("matrix") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + MATRIX + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MATRIX, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MATRIX -> Value.MATRIX + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MATRIX -> Known.MATRIX + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewFloatingMatrixPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && matrixConfig == other.matrixConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, matrixConfig, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingMatrixPrice{cadence=$cadence, currency=$currency, itemId=$itemId, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingMatrixWithAllocationPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("matrix_with_allocation_config") + @ExcludeMissing + private val matrixWithAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun matrixWithAllocationConfig(): MatrixWithAllocationConfigModel = + matrixWithAllocationConfig.getRequired("matrix_with_allocation_config") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** An ISO 4217 currency string for which this price is billed in. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("matrix_with_allocation_config") + @ExcludeMissing + fun _matrixWithAllocationConfig(): JsonField = + matrixWithAllocationConfig + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewFloatingMatrixWithAllocationPrice = apply { + if (validated) { + return@apply + } + + cadence() + currency() + itemId() + matrixWithAllocationConfig().validate() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewFloatingMatrixWithAllocationPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .currency() + * .itemId() + * .matrixWithAllocationConfig() + * .modelType() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewFloatingMatrixWithAllocationPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var matrixWithAllocationConfig: JsonField? = + null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + newFloatingMatrixWithAllocationPrice: NewFloatingMatrixWithAllocationPrice + ) = apply { + cadence = newFloatingMatrixWithAllocationPrice.cadence + currency = newFloatingMatrixWithAllocationPrice.currency + itemId = newFloatingMatrixWithAllocationPrice.itemId + matrixWithAllocationConfig = + newFloatingMatrixWithAllocationPrice.matrixWithAllocationConfig + modelType = newFloatingMatrixWithAllocationPrice.modelType + name = newFloatingMatrixWithAllocationPrice.name + billableMetricId = newFloatingMatrixWithAllocationPrice.billableMetricId + billedInAdvance = newFloatingMatrixWithAllocationPrice.billedInAdvance + billingCycleConfiguration = + newFloatingMatrixWithAllocationPrice.billingCycleConfiguration + conversionRate = newFloatingMatrixWithAllocationPrice.conversionRate + externalPriceId = newFloatingMatrixWithAllocationPrice.externalPriceId + fixedPriceQuantity = newFloatingMatrixWithAllocationPrice.fixedPriceQuantity + invoiceGroupingKey = newFloatingMatrixWithAllocationPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newFloatingMatrixWithAllocationPrice.invoicingCycleConfiguration + metadata = newFloatingMatrixWithAllocationPrice.metadata + additionalProperties = + newFloatingMatrixWithAllocationPrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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)) + + /** An ISO 4217 currency string for which this price is billed in. */ + 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)) + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun matrixWithAllocationConfig( + matrixWithAllocationConfig: MatrixWithAllocationConfigModel + ) = matrixWithAllocationConfig(JsonField.of(matrixWithAllocationConfig)) + + fun matrixWithAllocationConfig( + matrixWithAllocationConfig: JsonField + ) = apply { this.matrixWithAllocationConfig = matrixWithAllocationConfig } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + 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)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) + } + + fun build(): NewFloatingMatrixWithAllocationPrice = + NewFloatingMatrixWithAllocationPrice( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + checkRequired("matrixWithAllocationConfig", matrixWithAllocationConfig), + checkRequired("modelType", modelType), + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val MATRIX_WITH_ALLOCATION = of("matrix_with_allocation") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + MATRIX_WITH_ALLOCATION + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MATRIX_WITH_ALLOCATION, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MATRIX_WITH_ALLOCATION -> Value.MATRIX_WITH_ALLOCATION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MATRIX_WITH_ALLOCATION -> Known.MATRIX_WITH_ALLOCATION + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewFloatingMatrixWithAllocationPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && matrixWithAllocationConfig == other.matrixWithAllocationConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, matrixWithAllocationConfig, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingMatrixWithAllocationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, matrixWithAllocationConfig=$matrixWithAllocationConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingTieredPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_config") + @ExcludeMissing + private val tieredConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun tieredConfig(): TieredConfigModel = tieredConfig.getRequired("tiered_config") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** An ISO 4217 currency string for which this price is billed in. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("tiered_config") + @ExcludeMissing + fun _tieredConfig(): JsonField = tieredConfig + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewFloatingTieredPrice = apply { + if (validated) { + return@apply + } + + cadence() + currency() + itemId() + modelType() + name() + tieredConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [NewFloatingTieredPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .currency() + * .itemId() + * .modelType() + * .name() + * .tieredConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewFloatingTieredPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(newFloatingTieredPrice: NewFloatingTieredPrice) = apply { + cadence = newFloatingTieredPrice.cadence + currency = newFloatingTieredPrice.currency + itemId = newFloatingTieredPrice.itemId + modelType = newFloatingTieredPrice.modelType + name = newFloatingTieredPrice.name + tieredConfig = newFloatingTieredPrice.tieredConfig + billableMetricId = newFloatingTieredPrice.billableMetricId + billedInAdvance = newFloatingTieredPrice.billedInAdvance + billingCycleConfiguration = newFloatingTieredPrice.billingCycleConfiguration + conversionRate = newFloatingTieredPrice.conversionRate + externalPriceId = newFloatingTieredPrice.externalPriceId + fixedPriceQuantity = newFloatingTieredPrice.fixedPriceQuantity + invoiceGroupingKey = newFloatingTieredPrice.invoiceGroupingKey + invoicingCycleConfiguration = newFloatingTieredPrice.invoicingCycleConfiguration + metadata = newFloatingTieredPrice.metadata + additionalProperties = newFloatingTieredPrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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)) + + /** An ISO 4217 currency string for which this price is billed in. */ + 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)) + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun tieredConfig(tieredConfig: TieredConfigModel) = + tieredConfig(JsonField.of(tieredConfig)) + + fun tieredConfig(tieredConfig: JsonField) = apply { + this.tieredConfig = tieredConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) + } + + fun build(): NewFloatingTieredPrice = + NewFloatingTieredPrice( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("tieredConfig", tieredConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TIERED = of("tiered") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + TIERED + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TIERED, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TIERED -> Value.TIERED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TIERED -> Known.TIERED + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewFloatingTieredPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredConfig == other.tieredConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, tieredConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingTieredPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingTieredBpsPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_bps_config") + @ExcludeMissing + private val tieredBpsConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun tieredBpsConfig(): TieredBpsConfigModel = + tieredBpsConfig.getRequired("tiered_bps_config") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** An ISO 4217 currency string for which this price is billed in. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("tiered_bps_config") + @ExcludeMissing + fun _tieredBpsConfig(): JsonField = tieredBpsConfig + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewFloatingTieredBpsPrice = apply { + if (validated) { + return@apply + } + + cadence() + currency() + itemId() + modelType() + name() + tieredBpsConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewFloatingTieredBpsPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .currency() + * .itemId() + * .modelType() + * .name() + * .tieredBpsConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewFloatingTieredBpsPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredBpsConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(newFloatingTieredBpsPrice: NewFloatingTieredBpsPrice) = apply { + cadence = newFloatingTieredBpsPrice.cadence + currency = newFloatingTieredBpsPrice.currency + itemId = newFloatingTieredBpsPrice.itemId + modelType = newFloatingTieredBpsPrice.modelType + name = newFloatingTieredBpsPrice.name + tieredBpsConfig = newFloatingTieredBpsPrice.tieredBpsConfig + billableMetricId = newFloatingTieredBpsPrice.billableMetricId + billedInAdvance = newFloatingTieredBpsPrice.billedInAdvance + billingCycleConfiguration = newFloatingTieredBpsPrice.billingCycleConfiguration + conversionRate = newFloatingTieredBpsPrice.conversionRate + externalPriceId = newFloatingTieredBpsPrice.externalPriceId + fixedPriceQuantity = newFloatingTieredBpsPrice.fixedPriceQuantity + invoiceGroupingKey = newFloatingTieredBpsPrice.invoiceGroupingKey + invoicingCycleConfiguration = newFloatingTieredBpsPrice.invoicingCycleConfiguration + metadata = newFloatingTieredBpsPrice.metadata + additionalProperties = newFloatingTieredBpsPrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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)) + + /** An ISO 4217 currency string for which this price is billed in. */ + 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)) + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun tieredBpsConfig(tieredBpsConfig: TieredBpsConfigModel) = + tieredBpsConfig(JsonField.of(tieredBpsConfig)) + + fun tieredBpsConfig(tieredBpsConfig: JsonField) = apply { + this.tieredBpsConfig = tieredBpsConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) + } + + fun build(): NewFloatingTieredBpsPrice = + NewFloatingTieredBpsPrice( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("tieredBpsConfig", tieredBpsConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TIERED_BPS = of("tiered_bps") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + TIERED_BPS + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TIERED_BPS, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TIERED_BPS -> Value.TIERED_BPS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TIERED_BPS -> Known.TIERED_BPS + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewFloatingTieredBpsPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredBpsConfig == other.tieredBpsConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, tieredBpsConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingTieredBpsPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredBpsConfig=$tieredBpsConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingBpsPrice + @JsonCreator + private constructor( + @JsonProperty("bps_config") + @ExcludeMissing + private val bpsConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun bpsConfig(): BpsConfigModel = bpsConfig.getRequired("bps_config") + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + @JsonProperty("bps_config") + @ExcludeMissing + fun _bpsConfig(): JsonField = bpsConfig + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** An ISO 4217 currency string for which this price is billed in. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewFloatingBpsPrice = apply { + if (validated) { + return@apply + } + + bpsConfig().validate() + cadence() + currency() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [NewFloatingBpsPrice]. + * + * The following fields are required: + * ```java + * .bpsConfig() + * .cadence() + * .currency() + * .itemId() + * .modelType() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewFloatingBpsPrice]. */ + class Builder internal constructor() { + + private var bpsConfig: JsonField? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(newFloatingBpsPrice: NewFloatingBpsPrice) = apply { + bpsConfig = newFloatingBpsPrice.bpsConfig + cadence = newFloatingBpsPrice.cadence + currency = newFloatingBpsPrice.currency + itemId = newFloatingBpsPrice.itemId + modelType = newFloatingBpsPrice.modelType + name = newFloatingBpsPrice.name + billableMetricId = newFloatingBpsPrice.billableMetricId + billedInAdvance = newFloatingBpsPrice.billedInAdvance + billingCycleConfiguration = newFloatingBpsPrice.billingCycleConfiguration + conversionRate = newFloatingBpsPrice.conversionRate + externalPriceId = newFloatingBpsPrice.externalPriceId + fixedPriceQuantity = newFloatingBpsPrice.fixedPriceQuantity + invoiceGroupingKey = newFloatingBpsPrice.invoiceGroupingKey + invoicingCycleConfiguration = newFloatingBpsPrice.invoicingCycleConfiguration + metadata = newFloatingBpsPrice.metadata + additionalProperties = newFloatingBpsPrice.additionalProperties.toMutableMap() + } + + fun bpsConfig(bpsConfig: BpsConfigModel) = bpsConfig(JsonField.of(bpsConfig)) + + fun bpsConfig(bpsConfig: JsonField) = apply { + this.bpsConfig = bpsConfig + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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)) + + /** An ISO 4217 currency string for which this price is billed in. */ + 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)) + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + 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)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) + } + + fun build(): NewFloatingBpsPrice = + NewFloatingBpsPrice( + checkRequired("bpsConfig", bpsConfig), + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val BPS = of("bps") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + BPS + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + BPS, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + BPS -> Value.BPS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + BPS -> Known.BPS + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewFloatingBpsPrice && bpsConfig == other.bpsConfig && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(bpsConfig, cadence, currency, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingBpsPrice{bpsConfig=$bpsConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingBulkBpsPrice + @JsonCreator + private constructor( + @JsonProperty("bulk_bps_config") + @ExcludeMissing + private val bulkBpsConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun bulkBpsConfig(): BulkBpsConfigModel = bulkBpsConfig.getRequired("bulk_bps_config") + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + @JsonProperty("bulk_bps_config") + @ExcludeMissing + fun _bulkBpsConfig(): JsonField = bulkBpsConfig + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** An ISO 4217 currency string for which this price is billed in. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewFloatingBulkBpsPrice = apply { + if (validated) { + return@apply + } + + bulkBpsConfig().validate() + cadence() + currency() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [NewFloatingBulkBpsPrice]. + * + * The following fields are required: + * ```java + * .bulkBpsConfig() + * .cadence() + * .currency() + * .itemId() + * .modelType() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewFloatingBulkBpsPrice]. */ + class Builder internal constructor() { + + private var bulkBpsConfig: JsonField? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(newFloatingBulkBpsPrice: NewFloatingBulkBpsPrice) = apply { + bulkBpsConfig = newFloatingBulkBpsPrice.bulkBpsConfig + cadence = newFloatingBulkBpsPrice.cadence + currency = newFloatingBulkBpsPrice.currency + itemId = newFloatingBulkBpsPrice.itemId + modelType = newFloatingBulkBpsPrice.modelType + name = newFloatingBulkBpsPrice.name + billableMetricId = newFloatingBulkBpsPrice.billableMetricId + billedInAdvance = newFloatingBulkBpsPrice.billedInAdvance + billingCycleConfiguration = newFloatingBulkBpsPrice.billingCycleConfiguration + conversionRate = newFloatingBulkBpsPrice.conversionRate + externalPriceId = newFloatingBulkBpsPrice.externalPriceId + fixedPriceQuantity = newFloatingBulkBpsPrice.fixedPriceQuantity + invoiceGroupingKey = newFloatingBulkBpsPrice.invoiceGroupingKey + invoicingCycleConfiguration = newFloatingBulkBpsPrice.invoicingCycleConfiguration + metadata = newFloatingBulkBpsPrice.metadata + additionalProperties = newFloatingBulkBpsPrice.additionalProperties.toMutableMap() + } + + fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfigModel) = + bulkBpsConfig(JsonField.of(bulkBpsConfig)) + + fun bulkBpsConfig(bulkBpsConfig: JsonField) = apply { + this.bulkBpsConfig = bulkBpsConfig + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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)) + + /** An ISO 4217 currency string for which this price is billed in. */ + 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)) + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + 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)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) + } + + fun build(): NewFloatingBulkBpsPrice = + NewFloatingBulkBpsPrice( + checkRequired("bulkBpsConfig", bulkBpsConfig), + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val BULK_BPS = of("bulk_bps") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + BULK_BPS + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + BULK_BPS, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + BULK_BPS -> Value.BULK_BPS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + BULK_BPS -> Known.BULK_BPS + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewFloatingBulkBpsPrice && bulkBpsConfig == other.bulkBpsConfig && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(bulkBpsConfig, cadence, currency, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingBulkBpsPrice{bulkBpsConfig=$bulkBpsConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingBulkPrice + @JsonCreator + private constructor( + @JsonProperty("bulk_config") + @ExcludeMissing + private val bulkConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun bulkConfig(): BulkConfigModel = bulkConfig.getRequired("bulk_config") + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + @JsonProperty("bulk_config") + @ExcludeMissing + fun _bulkConfig(): JsonField = bulkConfig + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** An ISO 4217 currency string for which this price is billed in. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewFloatingBulkPrice = apply { + if (validated) { + return@apply + } + + bulkConfig().validate() + cadence() + currency() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [NewFloatingBulkPrice]. + * + * The following fields are required: + * ```java + * .bulkConfig() + * .cadence() + * .currency() + * .itemId() + * .modelType() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewFloatingBulkPrice]. */ + class Builder internal constructor() { + + private var bulkConfig: JsonField? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var 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 externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(newFloatingBulkPrice: NewFloatingBulkPrice) = apply { + bulkConfig = newFloatingBulkPrice.bulkConfig + cadence = newFloatingBulkPrice.cadence + currency = newFloatingBulkPrice.currency + itemId = newFloatingBulkPrice.itemId + modelType = newFloatingBulkPrice.modelType + name = newFloatingBulkPrice.name + billableMetricId = newFloatingBulkPrice.billableMetricId + billedInAdvance = newFloatingBulkPrice.billedInAdvance + billingCycleConfiguration = newFloatingBulkPrice.billingCycleConfiguration + conversionRate = newFloatingBulkPrice.conversionRate + externalPriceId = newFloatingBulkPrice.externalPriceId + fixedPriceQuantity = newFloatingBulkPrice.fixedPriceQuantity + invoiceGroupingKey = newFloatingBulkPrice.invoiceGroupingKey + invoicingCycleConfiguration = newFloatingBulkPrice.invoicingCycleConfiguration + metadata = newFloatingBulkPrice.metadata + additionalProperties = newFloatingBulkPrice.additionalProperties.toMutableMap() + } + + fun bulkConfig(bulkConfig: BulkConfigModel) = bulkConfig(JsonField.of(bulkConfig)) + + fun bulkConfig(bulkConfig: JsonField) = apply { + this.bulkConfig = bulkConfig + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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)) + + /** An ISO 4217 currency string for which this price is billed in. */ + 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)) + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + 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)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) + } + + fun build(): NewFloatingBulkPrice = + NewFloatingBulkPrice( + checkRequired("bulkConfig", bulkConfig), + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val BULK = of("bulk") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + BULK + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + BULK, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + BULK -> Value.BULK + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + BULK -> Known.BULK + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewFloatingBulkPrice && bulkConfig == other.bulkConfig && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(bulkConfig, cadence, currency, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingBulkPrice{bulkConfig=$bulkConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingThresholdTotalAmountPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("threshold_total_amount_config") + @ExcludeMissing + private val thresholdTotalAmountConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun thresholdTotalAmountConfig(): CustomRatingFunctionConfigModel = + thresholdTotalAmountConfig.getRequired("threshold_total_amount_config") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** An ISO 4217 currency string for which this price is billed in. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("threshold_total_amount_config") + @ExcludeMissing + fun _thresholdTotalAmountConfig(): JsonField = + thresholdTotalAmountConfig + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewFloatingThresholdTotalAmountPrice = apply { + if (validated) { + return@apply + } + + cadence() + currency() + itemId() + modelType() + name() + thresholdTotalAmountConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewFloatingThresholdTotalAmountPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .currency() + * .itemId() + * .modelType() + * .name() + * .thresholdTotalAmountConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewFloatingThresholdTotalAmountPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var thresholdTotalAmountConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + newFloatingThresholdTotalAmountPrice: NewFloatingThresholdTotalAmountPrice + ) = apply { + cadence = newFloatingThresholdTotalAmountPrice.cadence + currency = newFloatingThresholdTotalAmountPrice.currency + itemId = newFloatingThresholdTotalAmountPrice.itemId + modelType = newFloatingThresholdTotalAmountPrice.modelType + name = newFloatingThresholdTotalAmountPrice.name + thresholdTotalAmountConfig = + newFloatingThresholdTotalAmountPrice.thresholdTotalAmountConfig + billableMetricId = newFloatingThresholdTotalAmountPrice.billableMetricId + billedInAdvance = newFloatingThresholdTotalAmountPrice.billedInAdvance + billingCycleConfiguration = + newFloatingThresholdTotalAmountPrice.billingCycleConfiguration + conversionRate = newFloatingThresholdTotalAmountPrice.conversionRate + externalPriceId = newFloatingThresholdTotalAmountPrice.externalPriceId + fixedPriceQuantity = newFloatingThresholdTotalAmountPrice.fixedPriceQuantity + invoiceGroupingKey = newFloatingThresholdTotalAmountPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newFloatingThresholdTotalAmountPrice.invoicingCycleConfiguration + metadata = newFloatingThresholdTotalAmountPrice.metadata + additionalProperties = + newFloatingThresholdTotalAmountPrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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)) + + /** An ISO 4217 currency string for which this price is billed in. */ + 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)) + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun thresholdTotalAmountConfig( + thresholdTotalAmountConfig: CustomRatingFunctionConfigModel + ) = thresholdTotalAmountConfig(JsonField.of(thresholdTotalAmountConfig)) + + fun thresholdTotalAmountConfig( + thresholdTotalAmountConfig: JsonField + ) = apply { this.thresholdTotalAmountConfig = thresholdTotalAmountConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) + } + + fun build(): NewFloatingThresholdTotalAmountPrice = + NewFloatingThresholdTotalAmountPrice( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("thresholdTotalAmountConfig", thresholdTotalAmountConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val THRESHOLD_TOTAL_AMOUNT = of("threshold_total_amount") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + THRESHOLD_TOTAL_AMOUNT + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + THRESHOLD_TOTAL_AMOUNT, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + THRESHOLD_TOTAL_AMOUNT -> Value.THRESHOLD_TOTAL_AMOUNT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + THRESHOLD_TOTAL_AMOUNT -> Known.THRESHOLD_TOTAL_AMOUNT + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewFloatingThresholdTotalAmountPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, thresholdTotalAmountConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingThresholdTotalAmountPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingTieredPackagePrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_package_config") + @ExcludeMissing + private val tieredPackageConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun tieredPackageConfig(): CustomRatingFunctionConfigModel = + tieredPackageConfig.getRequired("tiered_package_config") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** An ISO 4217 currency string for which this price is billed in. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("tiered_package_config") + @ExcludeMissing + fun _tieredPackageConfig(): JsonField = tieredPackageConfig + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewFloatingTieredPackagePrice = apply { + if (validated) { + return@apply + } + + cadence() + currency() + itemId() + modelType() + name() + tieredPackageConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewFloatingTieredPackagePrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .currency() + * .itemId() + * .modelType() + * .name() + * .tieredPackageConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewFloatingTieredPackagePrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredPackageConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(newFloatingTieredPackagePrice: NewFloatingTieredPackagePrice) = + apply { + cadence = newFloatingTieredPackagePrice.cadence + currency = newFloatingTieredPackagePrice.currency + itemId = newFloatingTieredPackagePrice.itemId + modelType = newFloatingTieredPackagePrice.modelType + name = newFloatingTieredPackagePrice.name + tieredPackageConfig = newFloatingTieredPackagePrice.tieredPackageConfig + billableMetricId = newFloatingTieredPackagePrice.billableMetricId + billedInAdvance = newFloatingTieredPackagePrice.billedInAdvance + billingCycleConfiguration = + newFloatingTieredPackagePrice.billingCycleConfiguration + conversionRate = newFloatingTieredPackagePrice.conversionRate + externalPriceId = newFloatingTieredPackagePrice.externalPriceId + fixedPriceQuantity = newFloatingTieredPackagePrice.fixedPriceQuantity + invoiceGroupingKey = newFloatingTieredPackagePrice.invoiceGroupingKey + invoicingCycleConfiguration = + newFloatingTieredPackagePrice.invoicingCycleConfiguration + metadata = newFloatingTieredPackagePrice.metadata + additionalProperties = + newFloatingTieredPackagePrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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)) + + /** An ISO 4217 currency string for which this price is billed in. */ + 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)) + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun tieredPackageConfig(tieredPackageConfig: CustomRatingFunctionConfigModel) = + tieredPackageConfig(JsonField.of(tieredPackageConfig)) + + fun tieredPackageConfig( + tieredPackageConfig: JsonField + ) = apply { this.tieredPackageConfig = tieredPackageConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) + } + + fun build(): NewFloatingTieredPackagePrice = + NewFloatingTieredPackagePrice( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("tieredPackageConfig", tieredPackageConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TIERED_PACKAGE = of("tiered_package") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + TIERED_PACKAGE + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TIERED_PACKAGE, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TIERED_PACKAGE -> Value.TIERED_PACKAGE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TIERED_PACKAGE -> Known.TIERED_PACKAGE + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewFloatingTieredPackagePrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredPackageConfig == other.tieredPackageConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, tieredPackageConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingTieredPackagePrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingGroupedTieredPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("grouped_tiered_config") + @ExcludeMissing + private val groupedTieredConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + fun groupedTieredConfig(): CustomRatingFunctionConfigModel = + groupedTieredConfig.getRequired("grouped_tiered_config") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** An ISO 4217 currency string for which this price is billed in. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @JsonProperty("grouped_tiered_config") + @ExcludeMissing + fun _groupedTieredConfig(): JsonField = groupedTieredConfig + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewFloatingGroupedTieredPrice = apply { + if (validated) { + return@apply + } + + cadence() + currency() + groupedTieredConfig().validate() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewFloatingGroupedTieredPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .currency() + * .groupedTieredConfig() + * .itemId() + * .modelType() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewFloatingGroupedTieredPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var groupedTieredConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var 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 externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(newFloatingGroupedTieredPrice: NewFloatingGroupedTieredPrice) = + apply { + cadence = newFloatingGroupedTieredPrice.cadence + currency = newFloatingGroupedTieredPrice.currency + groupedTieredConfig = newFloatingGroupedTieredPrice.groupedTieredConfig + itemId = newFloatingGroupedTieredPrice.itemId + modelType = newFloatingGroupedTieredPrice.modelType + name = newFloatingGroupedTieredPrice.name + billableMetricId = newFloatingGroupedTieredPrice.billableMetricId + billedInAdvance = newFloatingGroupedTieredPrice.billedInAdvance + billingCycleConfiguration = + newFloatingGroupedTieredPrice.billingCycleConfiguration + conversionRate = newFloatingGroupedTieredPrice.conversionRate + externalPriceId = newFloatingGroupedTieredPrice.externalPriceId + fixedPriceQuantity = newFloatingGroupedTieredPrice.fixedPriceQuantity + invoiceGroupingKey = newFloatingGroupedTieredPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newFloatingGroupedTieredPrice.invoicingCycleConfiguration + metadata = newFloatingGroupedTieredPrice.metadata + additionalProperties = + newFloatingGroupedTieredPrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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)) + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun groupedTieredConfig(groupedTieredConfig: CustomRatingFunctionConfigModel) = + groupedTieredConfig(JsonField.of(groupedTieredConfig)) + + fun groupedTieredConfig( + groupedTieredConfig: JsonField + ) = apply { this.groupedTieredConfig = groupedTieredConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + 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)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) + } + + fun build(): NewFloatingGroupedTieredPrice = + NewFloatingGroupedTieredPrice( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("groupedTieredConfig", groupedTieredConfig), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val GROUPED_TIERED = of("grouped_tiered") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + GROUPED_TIERED + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GROUPED_TIERED, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GROUPED_TIERED -> Value.GROUPED_TIERED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + GROUPED_TIERED -> Known.GROUPED_TIERED + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewFloatingGroupedTieredPrice && cadence == other.cadence && currency == other.currency && groupedTieredConfig == other.groupedTieredConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, currency, groupedTieredConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingGroupedTieredPrice{cadence=$cadence, currency=$currency, groupedTieredConfig=$groupedTieredConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingMaxGroupTieredPackagePrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("max_group_tiered_package_config") + @ExcludeMissing + private val maxGroupTieredPackageConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun maxGroupTieredPackageConfig(): CustomRatingFunctionConfigModel = + maxGroupTieredPackageConfig.getRequired("max_group_tiered_package_config") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** An ISO 4217 currency string for which this price is billed in. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("max_group_tiered_package_config") + @ExcludeMissing + fun _maxGroupTieredPackageConfig(): JsonField = + maxGroupTieredPackageConfig + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewFloatingMaxGroupTieredPackagePrice = apply { + if (validated) { + return@apply + } + + cadence() + currency() + itemId() + maxGroupTieredPackageConfig().validate() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewFloatingMaxGroupTieredPackagePrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .currency() + * .itemId() + * .maxGroupTieredPackageConfig() + * .modelType() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewFloatingMaxGroupTieredPackagePrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var maxGroupTieredPackageConfig: JsonField? = + null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + newFloatingMaxGroupTieredPackagePrice: NewFloatingMaxGroupTieredPackagePrice + ) = apply { + cadence = newFloatingMaxGroupTieredPackagePrice.cadence + currency = newFloatingMaxGroupTieredPackagePrice.currency + itemId = newFloatingMaxGroupTieredPackagePrice.itemId + maxGroupTieredPackageConfig = + newFloatingMaxGroupTieredPackagePrice.maxGroupTieredPackageConfig + modelType = newFloatingMaxGroupTieredPackagePrice.modelType + name = newFloatingMaxGroupTieredPackagePrice.name + billableMetricId = newFloatingMaxGroupTieredPackagePrice.billableMetricId + billedInAdvance = newFloatingMaxGroupTieredPackagePrice.billedInAdvance + billingCycleConfiguration = + newFloatingMaxGroupTieredPackagePrice.billingCycleConfiguration + conversionRate = newFloatingMaxGroupTieredPackagePrice.conversionRate + externalPriceId = newFloatingMaxGroupTieredPackagePrice.externalPriceId + fixedPriceQuantity = newFloatingMaxGroupTieredPackagePrice.fixedPriceQuantity + invoiceGroupingKey = newFloatingMaxGroupTieredPackagePrice.invoiceGroupingKey + invoicingCycleConfiguration = + newFloatingMaxGroupTieredPackagePrice.invoicingCycleConfiguration + metadata = newFloatingMaxGroupTieredPackagePrice.metadata + additionalProperties = + newFloatingMaxGroupTieredPackagePrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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)) + + /** An ISO 4217 currency string for which this price is billed in. */ + 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)) + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun maxGroupTieredPackageConfig( + maxGroupTieredPackageConfig: CustomRatingFunctionConfigModel + ) = maxGroupTieredPackageConfig(JsonField.of(maxGroupTieredPackageConfig)) + + fun maxGroupTieredPackageConfig( + maxGroupTieredPackageConfig: JsonField + ) = apply { this.maxGroupTieredPackageConfig = maxGroupTieredPackageConfig } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + 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)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) + } + + fun build(): NewFloatingMaxGroupTieredPackagePrice = + NewFloatingMaxGroupTieredPackagePrice( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + checkRequired("maxGroupTieredPackageConfig", maxGroupTieredPackageConfig), + checkRequired("modelType", modelType), + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val MAX_GROUP_TIERED_PACKAGE = of("max_group_tiered_package") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + MAX_GROUP_TIERED_PACKAGE + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MAX_GROUP_TIERED_PACKAGE, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MAX_GROUP_TIERED_PACKAGE -> Value.MAX_GROUP_TIERED_PACKAGE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MAX_GROUP_TIERED_PACKAGE -> Known.MAX_GROUP_TIERED_PACKAGE + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewFloatingMaxGroupTieredPackagePrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && maxGroupTieredPackageConfig == other.maxGroupTieredPackageConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, maxGroupTieredPackageConfig, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingMaxGroupTieredPackagePrice{cadence=$cadence, currency=$currency, itemId=$itemId, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingTieredWithMinimumPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_minimum_config") + @ExcludeMissing + private val tieredWithMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun tieredWithMinimumConfig(): CustomRatingFunctionConfigModel = + tieredWithMinimumConfig.getRequired("tiered_with_minimum_config") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** An ISO 4217 currency string for which this price is billed in. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("tiered_with_minimum_config") + @ExcludeMissing + fun _tieredWithMinimumConfig(): JsonField = + tieredWithMinimumConfig + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewFloatingTieredWithMinimumPrice = apply { + if (validated) { + return@apply + } + + cadence() + currency() + itemId() + modelType() + name() + tieredWithMinimumConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewFloatingTieredWithMinimumPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .currency() + * .itemId() + * .modelType() + * .name() + * .tieredWithMinimumConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewFloatingTieredWithMinimumPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredWithMinimumConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + newFloatingTieredWithMinimumPrice: NewFloatingTieredWithMinimumPrice + ) = apply { + cadence = newFloatingTieredWithMinimumPrice.cadence + currency = newFloatingTieredWithMinimumPrice.currency + itemId = newFloatingTieredWithMinimumPrice.itemId + modelType = newFloatingTieredWithMinimumPrice.modelType + name = newFloatingTieredWithMinimumPrice.name + tieredWithMinimumConfig = newFloatingTieredWithMinimumPrice.tieredWithMinimumConfig + billableMetricId = newFloatingTieredWithMinimumPrice.billableMetricId + billedInAdvance = newFloatingTieredWithMinimumPrice.billedInAdvance + billingCycleConfiguration = + newFloatingTieredWithMinimumPrice.billingCycleConfiguration + conversionRate = newFloatingTieredWithMinimumPrice.conversionRate + externalPriceId = newFloatingTieredWithMinimumPrice.externalPriceId + fixedPriceQuantity = newFloatingTieredWithMinimumPrice.fixedPriceQuantity + invoiceGroupingKey = newFloatingTieredWithMinimumPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newFloatingTieredWithMinimumPrice.invoicingCycleConfiguration + metadata = newFloatingTieredWithMinimumPrice.metadata + additionalProperties = + newFloatingTieredWithMinimumPrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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)) + + /** An ISO 4217 currency string for which this price is billed in. */ + 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)) + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun tieredWithMinimumConfig(tieredWithMinimumConfig: CustomRatingFunctionConfigModel) = + tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) + + fun tieredWithMinimumConfig( + tieredWithMinimumConfig: JsonField + ) = apply { this.tieredWithMinimumConfig = tieredWithMinimumConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) + } + + fun build(): NewFloatingTieredWithMinimumPrice = + NewFloatingTieredWithMinimumPrice( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("tieredWithMinimumConfig", tieredWithMinimumConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TIERED_WITH_MINIMUM = of("tiered_with_minimum") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + TIERED_WITH_MINIMUM + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TIERED_WITH_MINIMUM, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TIERED_WITH_MINIMUM -> Value.TIERED_WITH_MINIMUM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TIERED_WITH_MINIMUM -> Known.TIERED_WITH_MINIMUM + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewFloatingTieredWithMinimumPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredWithMinimumConfig == other.tieredWithMinimumConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, tieredWithMinimumConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingTieredWithMinimumPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingPackageWithAllocationPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("package_with_allocation_config") + @ExcludeMissing + private val packageWithAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun packageWithAllocationConfig(): CustomRatingFunctionConfigModel = + packageWithAllocationConfig.getRequired("package_with_allocation_config") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** An ISO 4217 currency string for which this price is billed in. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("package_with_allocation_config") + @ExcludeMissing + fun _packageWithAllocationConfig(): JsonField = + packageWithAllocationConfig + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewFloatingPackageWithAllocationPrice = apply { + if (validated) { + return@apply + } + + cadence() + currency() + itemId() + modelType() + name() + packageWithAllocationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewFloatingPackageWithAllocationPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .currency() + * .itemId() + * .modelType() + * .name() + * .packageWithAllocationConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewFloatingPackageWithAllocationPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var packageWithAllocationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + newFloatingPackageWithAllocationPrice: NewFloatingPackageWithAllocationPrice + ) = apply { + cadence = newFloatingPackageWithAllocationPrice.cadence + currency = newFloatingPackageWithAllocationPrice.currency + itemId = newFloatingPackageWithAllocationPrice.itemId + modelType = newFloatingPackageWithAllocationPrice.modelType + name = newFloatingPackageWithAllocationPrice.name + packageWithAllocationConfig = + newFloatingPackageWithAllocationPrice.packageWithAllocationConfig + billableMetricId = newFloatingPackageWithAllocationPrice.billableMetricId + billedInAdvance = newFloatingPackageWithAllocationPrice.billedInAdvance + billingCycleConfiguration = + newFloatingPackageWithAllocationPrice.billingCycleConfiguration + conversionRate = newFloatingPackageWithAllocationPrice.conversionRate + externalPriceId = newFloatingPackageWithAllocationPrice.externalPriceId + fixedPriceQuantity = newFloatingPackageWithAllocationPrice.fixedPriceQuantity + invoiceGroupingKey = newFloatingPackageWithAllocationPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newFloatingPackageWithAllocationPrice.invoicingCycleConfiguration + metadata = newFloatingPackageWithAllocationPrice.metadata + additionalProperties = + newFloatingPackageWithAllocationPrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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)) + + /** An ISO 4217 currency string for which this price is billed in. */ + 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)) + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun packageWithAllocationConfig( + packageWithAllocationConfig: CustomRatingFunctionConfigModel + ) = packageWithAllocationConfig(JsonField.of(packageWithAllocationConfig)) + + fun packageWithAllocationConfig( + packageWithAllocationConfig: JsonField + ) = apply { this.packageWithAllocationConfig = packageWithAllocationConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) + } + + fun build(): NewFloatingPackageWithAllocationPrice = + NewFloatingPackageWithAllocationPrice( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("packageWithAllocationConfig", packageWithAllocationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PACKAGE_WITH_ALLOCATION = of("package_with_allocation") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + PACKAGE_WITH_ALLOCATION + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PACKAGE_WITH_ALLOCATION, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PACKAGE_WITH_ALLOCATION -> Value.PACKAGE_WITH_ALLOCATION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PACKAGE_WITH_ALLOCATION -> Known.PACKAGE_WITH_ALLOCATION + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewFloatingPackageWithAllocationPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && packageWithAllocationConfig == other.packageWithAllocationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, packageWithAllocationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingPackageWithAllocationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingTieredPackageWithMinimumPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_package_with_minimum_config") + @ExcludeMissing + private val tieredPackageWithMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun tieredPackageWithMinimumConfig(): CustomRatingFunctionConfigModel = + tieredPackageWithMinimumConfig.getRequired("tiered_package_with_minimum_config") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** An ISO 4217 currency string for which this price is billed in. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("tiered_package_with_minimum_config") + @ExcludeMissing + fun _tieredPackageWithMinimumConfig(): JsonField = + tieredPackageWithMinimumConfig + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewFloatingTieredPackageWithMinimumPrice = apply { + if (validated) { + return@apply + } + + cadence() + currency() + itemId() + modelType() + name() + tieredPackageWithMinimumConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewFloatingTieredPackageWithMinimumPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .currency() + * .itemId() + * .modelType() + * .name() + * .tieredPackageWithMinimumConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewFloatingTieredPackageWithMinimumPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredPackageWithMinimumConfig: + JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + newFloatingTieredPackageWithMinimumPrice: NewFloatingTieredPackageWithMinimumPrice + ) = apply { + cadence = newFloatingTieredPackageWithMinimumPrice.cadence + currency = newFloatingTieredPackageWithMinimumPrice.currency + itemId = newFloatingTieredPackageWithMinimumPrice.itemId + modelType = newFloatingTieredPackageWithMinimumPrice.modelType + name = newFloatingTieredPackageWithMinimumPrice.name + tieredPackageWithMinimumConfig = + newFloatingTieredPackageWithMinimumPrice.tieredPackageWithMinimumConfig + billableMetricId = newFloatingTieredPackageWithMinimumPrice.billableMetricId + billedInAdvance = newFloatingTieredPackageWithMinimumPrice.billedInAdvance + billingCycleConfiguration = + newFloatingTieredPackageWithMinimumPrice.billingCycleConfiguration + conversionRate = newFloatingTieredPackageWithMinimumPrice.conversionRate + externalPriceId = newFloatingTieredPackageWithMinimumPrice.externalPriceId + fixedPriceQuantity = newFloatingTieredPackageWithMinimumPrice.fixedPriceQuantity + invoiceGroupingKey = newFloatingTieredPackageWithMinimumPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newFloatingTieredPackageWithMinimumPrice.invoicingCycleConfiguration + metadata = newFloatingTieredPackageWithMinimumPrice.metadata + additionalProperties = + newFloatingTieredPackageWithMinimumPrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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)) + + /** An ISO 4217 currency string for which this price is billed in. */ + 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)) + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun tieredPackageWithMinimumConfig( + tieredPackageWithMinimumConfig: CustomRatingFunctionConfigModel + ) = tieredPackageWithMinimumConfig(JsonField.of(tieredPackageWithMinimumConfig)) + + fun tieredPackageWithMinimumConfig( + tieredPackageWithMinimumConfig: JsonField + ) = apply { this.tieredPackageWithMinimumConfig = tieredPackageWithMinimumConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) + } + + fun build(): NewFloatingTieredPackageWithMinimumPrice = + NewFloatingTieredPackageWithMinimumPrice( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("tieredPackageWithMinimumConfig", tieredPackageWithMinimumConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TIERED_PACKAGE_WITH_MINIMUM = of("tiered_package_with_minimum") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + TIERED_PACKAGE_WITH_MINIMUM + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TIERED_PACKAGE_WITH_MINIMUM, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TIERED_PACKAGE_WITH_MINIMUM -> Value.TIERED_PACKAGE_WITH_MINIMUM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TIERED_PACKAGE_WITH_MINIMUM -> Known.TIERED_PACKAGE_WITH_MINIMUM + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewFloatingTieredPackageWithMinimumPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredPackageWithMinimumConfig == other.tieredPackageWithMinimumConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, tieredPackageWithMinimumConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingTieredPackageWithMinimumPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingUnitWithPercentPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("unit_with_percent_config") + @ExcludeMissing + private val unitWithPercentConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun unitWithPercentConfig(): CustomRatingFunctionConfigModel = + unitWithPercentConfig.getRequired("unit_with_percent_config") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** An ISO 4217 currency string for which this price is billed in. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("unit_with_percent_config") + @ExcludeMissing + fun _unitWithPercentConfig(): JsonField = + unitWithPercentConfig + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewFloatingUnitWithPercentPrice = apply { + if (validated) { + return@apply + } + + cadence() + currency() + itemId() + modelType() + name() + unitWithPercentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewFloatingUnitWithPercentPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .currency() + * .itemId() + * .modelType() + * .name() + * .unitWithPercentConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewFloatingUnitWithPercentPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var unitWithPercentConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(newFloatingUnitWithPercentPrice: NewFloatingUnitWithPercentPrice) = + apply { + cadence = newFloatingUnitWithPercentPrice.cadence + currency = newFloatingUnitWithPercentPrice.currency + itemId = newFloatingUnitWithPercentPrice.itemId + modelType = newFloatingUnitWithPercentPrice.modelType + name = newFloatingUnitWithPercentPrice.name + unitWithPercentConfig = newFloatingUnitWithPercentPrice.unitWithPercentConfig + billableMetricId = newFloatingUnitWithPercentPrice.billableMetricId + billedInAdvance = newFloatingUnitWithPercentPrice.billedInAdvance + billingCycleConfiguration = + newFloatingUnitWithPercentPrice.billingCycleConfiguration + conversionRate = newFloatingUnitWithPercentPrice.conversionRate + externalPriceId = newFloatingUnitWithPercentPrice.externalPriceId + fixedPriceQuantity = newFloatingUnitWithPercentPrice.fixedPriceQuantity + invoiceGroupingKey = newFloatingUnitWithPercentPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newFloatingUnitWithPercentPrice.invoicingCycleConfiguration + metadata = newFloatingUnitWithPercentPrice.metadata + additionalProperties = + newFloatingUnitWithPercentPrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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)) + + /** An ISO 4217 currency string for which this price is billed in. */ + 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)) + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun unitWithPercentConfig(unitWithPercentConfig: CustomRatingFunctionConfigModel) = + unitWithPercentConfig(JsonField.of(unitWithPercentConfig)) + + fun unitWithPercentConfig( + unitWithPercentConfig: JsonField + ) = apply { this.unitWithPercentConfig = unitWithPercentConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) + } + + fun build(): NewFloatingUnitWithPercentPrice = + NewFloatingUnitWithPercentPrice( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("unitWithPercentConfig", unitWithPercentConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val UNIT_WITH_PERCENT = of("unit_with_percent") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + UNIT_WITH_PERCENT + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + UNIT_WITH_PERCENT, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + UNIT_WITH_PERCENT -> Value.UNIT_WITH_PERCENT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + UNIT_WITH_PERCENT -> Known.UNIT_WITH_PERCENT + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewFloatingUnitWithPercentPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && unitWithPercentConfig == other.unitWithPercentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, unitWithPercentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingUnitWithPercentPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingTieredWithProrationPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + private val tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun tieredWithProrationConfig(): CustomRatingFunctionConfigModel = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** An ISO 4217 currency string for which this price is billed in. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewFloatingTieredWithProrationPrice = apply { + if (validated) { + return@apply + } + + cadence() + currency() + itemId() + modelType() + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewFloatingTieredWithProrationPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .currency() + * .itemId() + * .modelType() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewFloatingTieredWithProrationPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var 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 externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + newFloatingTieredWithProrationPrice: NewFloatingTieredWithProrationPrice + ) = apply { + cadence = newFloatingTieredWithProrationPrice.cadence + currency = newFloatingTieredWithProrationPrice.currency + itemId = newFloatingTieredWithProrationPrice.itemId + modelType = newFloatingTieredWithProrationPrice.modelType + name = newFloatingTieredWithProrationPrice.name + tieredWithProrationConfig = + newFloatingTieredWithProrationPrice.tieredWithProrationConfig + billableMetricId = newFloatingTieredWithProrationPrice.billableMetricId + billedInAdvance = newFloatingTieredWithProrationPrice.billedInAdvance + billingCycleConfiguration = + newFloatingTieredWithProrationPrice.billingCycleConfiguration + conversionRate = newFloatingTieredWithProrationPrice.conversionRate + externalPriceId = newFloatingTieredWithProrationPrice.externalPriceId + fixedPriceQuantity = newFloatingTieredWithProrationPrice.fixedPriceQuantity + invoiceGroupingKey = newFloatingTieredWithProrationPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newFloatingTieredWithProrationPrice.invoicingCycleConfiguration + metadata = newFloatingTieredWithProrationPrice.metadata + additionalProperties = + newFloatingTieredWithProrationPrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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)) + + /** An ISO 4217 currency string for which this price is billed in. */ + 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)) + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun tieredWithProrationConfig( + tieredWithProrationConfig: CustomRatingFunctionConfigModel + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + 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)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) + } + + fun build(): NewFloatingTieredWithProrationPrice = + NewFloatingTieredWithProrationPrice( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TIERED_WITH_PRORATION = of("tiered_with_proration") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + TIERED_WITH_PRORATION + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TIERED_WITH_PRORATION, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TIERED_WITH_PRORATION -> Value.TIERED_WITH_PRORATION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TIERED_WITH_PRORATION -> Known.TIERED_WITH_PRORATION + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewFloatingTieredWithProrationPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingTieredWithProrationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingUnitWithProrationPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("unit_with_proration_config") + @ExcludeMissing + private val unitWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun unitWithProrationConfig(): CustomRatingFunctionConfigModel = + unitWithProrationConfig.getRequired("unit_with_proration_config") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** An ISO 4217 currency string for which this price is billed in. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("unit_with_proration_config") + @ExcludeMissing + fun _unitWithProrationConfig(): JsonField = + unitWithProrationConfig + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewFloatingUnitWithProrationPrice = apply { + if (validated) { + return@apply + } + + cadence() + currency() + itemId() + modelType() + name() + unitWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewFloatingUnitWithProrationPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .currency() + * .itemId() + * .modelType() + * .name() + * .unitWithProrationConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewFloatingUnitWithProrationPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var unitWithProrationConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + newFloatingUnitWithProrationPrice: NewFloatingUnitWithProrationPrice + ) = apply { + cadence = newFloatingUnitWithProrationPrice.cadence + currency = newFloatingUnitWithProrationPrice.currency + itemId = newFloatingUnitWithProrationPrice.itemId + modelType = newFloatingUnitWithProrationPrice.modelType + name = newFloatingUnitWithProrationPrice.name + unitWithProrationConfig = newFloatingUnitWithProrationPrice.unitWithProrationConfig + billableMetricId = newFloatingUnitWithProrationPrice.billableMetricId + billedInAdvance = newFloatingUnitWithProrationPrice.billedInAdvance + billingCycleConfiguration = + newFloatingUnitWithProrationPrice.billingCycleConfiguration + conversionRate = newFloatingUnitWithProrationPrice.conversionRate + externalPriceId = newFloatingUnitWithProrationPrice.externalPriceId + fixedPriceQuantity = newFloatingUnitWithProrationPrice.fixedPriceQuantity + invoiceGroupingKey = newFloatingUnitWithProrationPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newFloatingUnitWithProrationPrice.invoicingCycleConfiguration + metadata = newFloatingUnitWithProrationPrice.metadata + additionalProperties = + newFloatingUnitWithProrationPrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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)) + + /** An ISO 4217 currency string for which this price is billed in. */ + 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)) + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun unitWithProrationConfig(unitWithProrationConfig: CustomRatingFunctionConfigModel) = + unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) + + fun unitWithProrationConfig( + unitWithProrationConfig: JsonField + ) = apply { this.unitWithProrationConfig = unitWithProrationConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) + } + + fun build(): NewFloatingUnitWithProrationPrice = + NewFloatingUnitWithProrationPrice( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("unitWithProrationConfig", unitWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val UNIT_WITH_PRORATION = of("unit_with_proration") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + UNIT_WITH_PRORATION + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + UNIT_WITH_PRORATION, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + UNIT_WITH_PRORATION -> Value.UNIT_WITH_PRORATION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + UNIT_WITH_PRORATION -> Known.UNIT_WITH_PRORATION + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewFloatingUnitWithProrationPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && unitWithProrationConfig == other.unitWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, unitWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingUnitWithProrationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingGroupedAllocationPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("grouped_allocation_config") + @ExcludeMissing + private val groupedAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + fun groupedAllocationConfig(): CustomRatingFunctionConfigModel = + groupedAllocationConfig.getRequired("grouped_allocation_config") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** An ISO 4217 currency string for which this price is billed in. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @JsonProperty("grouped_allocation_config") + @ExcludeMissing + fun _groupedAllocationConfig(): JsonField = + groupedAllocationConfig + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewFloatingGroupedAllocationPrice = apply { + if (validated) { + return@apply + } + + cadence() + currency() + groupedAllocationConfig().validate() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewFloatingGroupedAllocationPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .currency() + * .groupedAllocationConfig() + * .itemId() + * .modelType() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewFloatingGroupedAllocationPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var groupedAllocationConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var 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 externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + newFloatingGroupedAllocationPrice: NewFloatingGroupedAllocationPrice + ) = apply { + cadence = newFloatingGroupedAllocationPrice.cadence + currency = newFloatingGroupedAllocationPrice.currency + groupedAllocationConfig = newFloatingGroupedAllocationPrice.groupedAllocationConfig + itemId = newFloatingGroupedAllocationPrice.itemId + modelType = newFloatingGroupedAllocationPrice.modelType + name = newFloatingGroupedAllocationPrice.name + billableMetricId = newFloatingGroupedAllocationPrice.billableMetricId + billedInAdvance = newFloatingGroupedAllocationPrice.billedInAdvance + billingCycleConfiguration = + newFloatingGroupedAllocationPrice.billingCycleConfiguration + conversionRate = newFloatingGroupedAllocationPrice.conversionRate + externalPriceId = newFloatingGroupedAllocationPrice.externalPriceId + fixedPriceQuantity = newFloatingGroupedAllocationPrice.fixedPriceQuantity + invoiceGroupingKey = newFloatingGroupedAllocationPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newFloatingGroupedAllocationPrice.invoicingCycleConfiguration + metadata = newFloatingGroupedAllocationPrice.metadata + additionalProperties = + newFloatingGroupedAllocationPrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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)) + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun groupedAllocationConfig(groupedAllocationConfig: CustomRatingFunctionConfigModel) = + groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) + + fun groupedAllocationConfig( + groupedAllocationConfig: JsonField + ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + 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)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) + } + + fun build(): NewFloatingGroupedAllocationPrice = + NewFloatingGroupedAllocationPrice( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("groupedAllocationConfig", groupedAllocationConfig), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val GROUPED_ALLOCATION = of("grouped_allocation") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + GROUPED_ALLOCATION + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GROUPED_ALLOCATION, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GROUPED_ALLOCATION -> Value.GROUPED_ALLOCATION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + GROUPED_ALLOCATION -> Known.GROUPED_ALLOCATION + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewFloatingGroupedAllocationPrice && cadence == other.cadence && currency == other.currency && groupedAllocationConfig == other.groupedAllocationConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, currency, groupedAllocationConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingGroupedAllocationPrice{cadence=$cadence, currency=$currency, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingGroupedWithProratedMinimumPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_prorated_minimum_config") + @ExcludeMissing + private val groupedWithProratedMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + fun groupedWithProratedMinimumConfig(): CustomRatingFunctionConfigModel = + groupedWithProratedMinimumConfig.getRequired("grouped_with_prorated_minimum_config") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** An ISO 4217 currency string for which this price is billed in. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @JsonProperty("grouped_with_prorated_minimum_config") + @ExcludeMissing + fun _groupedWithProratedMinimumConfig(): JsonField = + groupedWithProratedMinimumConfig + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewFloatingGroupedWithProratedMinimumPrice = apply { + if (validated) { + return@apply + } + + cadence() + currency() + groupedWithProratedMinimumConfig().validate() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewFloatingGroupedWithProratedMinimumPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .currency() + * .groupedWithProratedMinimumConfig() + * .itemId() + * .modelType() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewFloatingGroupedWithProratedMinimumPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var groupedWithProratedMinimumConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + newFloatingGroupedWithProratedMinimumPrice: + NewFloatingGroupedWithProratedMinimumPrice + ) = apply { + cadence = newFloatingGroupedWithProratedMinimumPrice.cadence + currency = newFloatingGroupedWithProratedMinimumPrice.currency + groupedWithProratedMinimumConfig = + newFloatingGroupedWithProratedMinimumPrice.groupedWithProratedMinimumConfig + itemId = newFloatingGroupedWithProratedMinimumPrice.itemId + modelType = newFloatingGroupedWithProratedMinimumPrice.modelType + name = newFloatingGroupedWithProratedMinimumPrice.name + billableMetricId = newFloatingGroupedWithProratedMinimumPrice.billableMetricId + billedInAdvance = newFloatingGroupedWithProratedMinimumPrice.billedInAdvance + billingCycleConfiguration = + newFloatingGroupedWithProratedMinimumPrice.billingCycleConfiguration + conversionRate = newFloatingGroupedWithProratedMinimumPrice.conversionRate + externalPriceId = newFloatingGroupedWithProratedMinimumPrice.externalPriceId + fixedPriceQuantity = newFloatingGroupedWithProratedMinimumPrice.fixedPriceQuantity + invoiceGroupingKey = newFloatingGroupedWithProratedMinimumPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newFloatingGroupedWithProratedMinimumPrice.invoicingCycleConfiguration + metadata = newFloatingGroupedWithProratedMinimumPrice.metadata + additionalProperties = + newFloatingGroupedWithProratedMinimumPrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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)) + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: CustomRatingFunctionConfigModel + ) = groupedWithProratedMinimumConfig(JsonField.of(groupedWithProratedMinimumConfig)) + + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: JsonField + ) = apply { this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + 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)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) + } + + fun build(): NewFloatingGroupedWithProratedMinimumPrice = + NewFloatingGroupedWithProratedMinimumPrice( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired( + "groupedWithProratedMinimumConfig", + groupedWithProratedMinimumConfig, + ), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val GROUPED_WITH_PRORATED_MINIMUM = of("grouped_with_prorated_minimum") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + GROUPED_WITH_PRORATED_MINIMUM + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GROUPED_WITH_PRORATED_MINIMUM, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GROUPED_WITH_PRORATED_MINIMUM -> Value.GROUPED_WITH_PRORATED_MINIMUM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + GROUPED_WITH_PRORATED_MINIMUM -> Known.GROUPED_WITH_PRORATED_MINIMUM + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewFloatingGroupedWithProratedMinimumPrice && cadence == other.cadence && currency == other.currency && groupedWithProratedMinimumConfig == other.groupedWithProratedMinimumConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, currency, groupedWithProratedMinimumConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingGroupedWithProratedMinimumPrice{cadence=$cadence, currency=$currency, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingGroupedWithMeteredMinimumPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_metered_minimum_config") + @ExcludeMissing + private val groupedWithMeteredMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + fun groupedWithMeteredMinimumConfig(): CustomRatingFunctionConfigModel = + groupedWithMeteredMinimumConfig.getRequired("grouped_with_metered_minimum_config") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** An ISO 4217 currency string for which this price is billed in. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @JsonProperty("grouped_with_metered_minimum_config") + @ExcludeMissing + fun _groupedWithMeteredMinimumConfig(): JsonField = + groupedWithMeteredMinimumConfig + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewFloatingGroupedWithMeteredMinimumPrice = apply { + if (validated) { + return@apply + } + + cadence() + currency() + groupedWithMeteredMinimumConfig().validate() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewFloatingGroupedWithMeteredMinimumPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .currency() + * .groupedWithMeteredMinimumConfig() + * .itemId() + * .modelType() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewFloatingGroupedWithMeteredMinimumPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var groupedWithMeteredMinimumConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + newFloatingGroupedWithMeteredMinimumPrice: NewFloatingGroupedWithMeteredMinimumPrice + ) = apply { + cadence = newFloatingGroupedWithMeteredMinimumPrice.cadence + currency = newFloatingGroupedWithMeteredMinimumPrice.currency + groupedWithMeteredMinimumConfig = + newFloatingGroupedWithMeteredMinimumPrice.groupedWithMeteredMinimumConfig + itemId = newFloatingGroupedWithMeteredMinimumPrice.itemId + modelType = newFloatingGroupedWithMeteredMinimumPrice.modelType + name = newFloatingGroupedWithMeteredMinimumPrice.name + billableMetricId = newFloatingGroupedWithMeteredMinimumPrice.billableMetricId + billedInAdvance = newFloatingGroupedWithMeteredMinimumPrice.billedInAdvance + billingCycleConfiguration = + newFloatingGroupedWithMeteredMinimumPrice.billingCycleConfiguration + conversionRate = newFloatingGroupedWithMeteredMinimumPrice.conversionRate + externalPriceId = newFloatingGroupedWithMeteredMinimumPrice.externalPriceId + fixedPriceQuantity = newFloatingGroupedWithMeteredMinimumPrice.fixedPriceQuantity + invoiceGroupingKey = newFloatingGroupedWithMeteredMinimumPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newFloatingGroupedWithMeteredMinimumPrice.invoicingCycleConfiguration + metadata = newFloatingGroupedWithMeteredMinimumPrice.metadata + additionalProperties = + newFloatingGroupedWithMeteredMinimumPrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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)) + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: CustomRatingFunctionConfigModel + ) = groupedWithMeteredMinimumConfig(JsonField.of(groupedWithMeteredMinimumConfig)) + + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: JsonField + ) = apply { this.groupedWithMeteredMinimumConfig = groupedWithMeteredMinimumConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + 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)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) + } + + fun build(): NewFloatingGroupedWithMeteredMinimumPrice = + NewFloatingGroupedWithMeteredMinimumPrice( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired( + "groupedWithMeteredMinimumConfig", + groupedWithMeteredMinimumConfig, + ), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val GROUPED_WITH_METERED_MINIMUM = of("grouped_with_metered_minimum") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + GROUPED_WITH_METERED_MINIMUM + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GROUPED_WITH_METERED_MINIMUM, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GROUPED_WITH_METERED_MINIMUM -> Value.GROUPED_WITH_METERED_MINIMUM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + GROUPED_WITH_METERED_MINIMUM -> Known.GROUPED_WITH_METERED_MINIMUM + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewFloatingGroupedWithMeteredMinimumPrice && cadence == other.cadence && currency == other.currency && groupedWithMeteredMinimumConfig == other.groupedWithMeteredMinimumConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, currency, groupedWithMeteredMinimumConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingGroupedWithMeteredMinimumPrice{cadence=$cadence, currency=$currency, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingMatrixWithDisplayNamePrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + private val matrixWithDisplayNameConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun matrixWithDisplayNameConfig(): CustomRatingFunctionConfigModel = + matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_config") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** An ISO 4217 currency string for which this price is billed in. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + fun _matrixWithDisplayNameConfig(): JsonField = + matrixWithDisplayNameConfig + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewFloatingMatrixWithDisplayNamePrice = apply { + if (validated) { + return@apply + } + + cadence() + currency() + itemId() + matrixWithDisplayNameConfig().validate() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewFloatingMatrixWithDisplayNamePrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .currency() + * .itemId() + * .matrixWithDisplayNameConfig() + * .modelType() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewFloatingMatrixWithDisplayNamePrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var matrixWithDisplayNameConfig: JsonField? = + null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + newFloatingMatrixWithDisplayNamePrice: NewFloatingMatrixWithDisplayNamePrice + ) = apply { + cadence = newFloatingMatrixWithDisplayNamePrice.cadence + currency = newFloatingMatrixWithDisplayNamePrice.currency + itemId = newFloatingMatrixWithDisplayNamePrice.itemId + matrixWithDisplayNameConfig = + newFloatingMatrixWithDisplayNamePrice.matrixWithDisplayNameConfig + modelType = newFloatingMatrixWithDisplayNamePrice.modelType + name = newFloatingMatrixWithDisplayNamePrice.name + billableMetricId = newFloatingMatrixWithDisplayNamePrice.billableMetricId + billedInAdvance = newFloatingMatrixWithDisplayNamePrice.billedInAdvance + billingCycleConfiguration = + newFloatingMatrixWithDisplayNamePrice.billingCycleConfiguration + conversionRate = newFloatingMatrixWithDisplayNamePrice.conversionRate + externalPriceId = newFloatingMatrixWithDisplayNamePrice.externalPriceId + fixedPriceQuantity = newFloatingMatrixWithDisplayNamePrice.fixedPriceQuantity + invoiceGroupingKey = newFloatingMatrixWithDisplayNamePrice.invoiceGroupingKey + invoicingCycleConfiguration = + newFloatingMatrixWithDisplayNamePrice.invoicingCycleConfiguration + metadata = newFloatingMatrixWithDisplayNamePrice.metadata + additionalProperties = + newFloatingMatrixWithDisplayNamePrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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)) + + /** An ISO 4217 currency string for which this price is billed in. */ + 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)) + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: CustomRatingFunctionConfigModel + ) = matrixWithDisplayNameConfig(JsonField.of(matrixWithDisplayNameConfig)) + + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: JsonField + ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + 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)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) + } + + fun build(): NewFloatingMatrixWithDisplayNamePrice = + NewFloatingMatrixWithDisplayNamePrice( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + checkRequired("matrixWithDisplayNameConfig", matrixWithDisplayNameConfig), + checkRequired("modelType", modelType), + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val MATRIX_WITH_DISPLAY_NAME = of("matrix_with_display_name") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + MATRIX_WITH_DISPLAY_NAME + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MATRIX_WITH_DISPLAY_NAME, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MATRIX_WITH_DISPLAY_NAME -> Value.MATRIX_WITH_DISPLAY_NAME + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MATRIX_WITH_DISPLAY_NAME -> Known.MATRIX_WITH_DISPLAY_NAME + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewFloatingMatrixWithDisplayNamePrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && matrixWithDisplayNameConfig == other.matrixWithDisplayNameConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, matrixWithDisplayNameConfig, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingMatrixWithDisplayNamePrice{cadence=$cadence, currency=$currency, itemId=$itemId, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingBulkWithProrationPrice + @JsonCreator + private constructor( + @JsonProperty("bulk_with_proration_config") + @ExcludeMissing + private val bulkWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun bulkWithProrationConfig(): CustomRatingFunctionConfigModel = + bulkWithProrationConfig.getRequired("bulk_with_proration_config") + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + @JsonProperty("bulk_with_proration_config") + @ExcludeMissing + fun _bulkWithProrationConfig(): JsonField = + bulkWithProrationConfig + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** An ISO 4217 currency string for which this price is billed in. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewFloatingBulkWithProrationPrice = apply { + if (validated) { + return@apply + } + + bulkWithProrationConfig().validate() + cadence() + currency() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewFloatingBulkWithProrationPrice]. + * + * The following fields are required: + * ```java + * .bulkWithProrationConfig() + * .cadence() + * .currency() + * .itemId() + * .modelType() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewFloatingBulkWithProrationPrice]. */ + class Builder internal constructor() { + + private var bulkWithProrationConfig: JsonField? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var 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 externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + newFloatingBulkWithProrationPrice: NewFloatingBulkWithProrationPrice + ) = apply { + bulkWithProrationConfig = newFloatingBulkWithProrationPrice.bulkWithProrationConfig + cadence = newFloatingBulkWithProrationPrice.cadence + currency = newFloatingBulkWithProrationPrice.currency + itemId = newFloatingBulkWithProrationPrice.itemId + modelType = newFloatingBulkWithProrationPrice.modelType + name = newFloatingBulkWithProrationPrice.name + billableMetricId = newFloatingBulkWithProrationPrice.billableMetricId + billedInAdvance = newFloatingBulkWithProrationPrice.billedInAdvance + billingCycleConfiguration = + newFloatingBulkWithProrationPrice.billingCycleConfiguration + conversionRate = newFloatingBulkWithProrationPrice.conversionRate + externalPriceId = newFloatingBulkWithProrationPrice.externalPriceId + fixedPriceQuantity = newFloatingBulkWithProrationPrice.fixedPriceQuantity + invoiceGroupingKey = newFloatingBulkWithProrationPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newFloatingBulkWithProrationPrice.invoicingCycleConfiguration + metadata = newFloatingBulkWithProrationPrice.metadata + additionalProperties = + newFloatingBulkWithProrationPrice.additionalProperties.toMutableMap() + } + + fun bulkWithProrationConfig(bulkWithProrationConfig: CustomRatingFunctionConfigModel) = + bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) + + fun bulkWithProrationConfig( + bulkWithProrationConfig: JsonField + ) = apply { this.bulkWithProrationConfig = bulkWithProrationConfig } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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)) + + /** An ISO 4217 currency string for which this price is billed in. */ + 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)) + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + 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)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) + } + + fun build(): NewFloatingBulkWithProrationPrice = + NewFloatingBulkWithProrationPrice( + checkRequired("bulkWithProrationConfig", bulkWithProrationConfig), + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val BULK_WITH_PRORATION = of("bulk_with_proration") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + BULK_WITH_PRORATION + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + BULK_WITH_PRORATION, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + BULK_WITH_PRORATION -> Value.BULK_WITH_PRORATION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + BULK_WITH_PRORATION -> Known.BULK_WITH_PRORATION + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewFloatingBulkWithProrationPrice && bulkWithProrationConfig == other.bulkWithProrationConfig && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(bulkWithProrationConfig, cadence, currency, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingBulkWithProrationPrice{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingGroupedTieredPackagePrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("grouped_tiered_package_config") + @ExcludeMissing + private val groupedTieredPackageConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + fun groupedTieredPackageConfig(): CustomRatingFunctionConfigModel = + groupedTieredPackageConfig.getRequired("grouped_tiered_package_config") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** An ISO 4217 currency string for which this price is billed in. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @JsonProperty("grouped_tiered_package_config") + @ExcludeMissing + fun _groupedTieredPackageConfig(): JsonField = + groupedTieredPackageConfig + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewFloatingGroupedTieredPackagePrice = apply { + if (validated) { + return@apply + } + + cadence() + currency() + groupedTieredPackageConfig().validate() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewFloatingGroupedTieredPackagePrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .currency() + * .groupedTieredPackageConfig() + * .itemId() + * .modelType() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewFloatingGroupedTieredPackagePrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var groupedTieredPackageConfig: JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + newFloatingGroupedTieredPackagePrice: NewFloatingGroupedTieredPackagePrice + ) = apply { + cadence = newFloatingGroupedTieredPackagePrice.cadence + currency = newFloatingGroupedTieredPackagePrice.currency + groupedTieredPackageConfig = + newFloatingGroupedTieredPackagePrice.groupedTieredPackageConfig + itemId = newFloatingGroupedTieredPackagePrice.itemId + modelType = newFloatingGroupedTieredPackagePrice.modelType + name = newFloatingGroupedTieredPackagePrice.name + billableMetricId = newFloatingGroupedTieredPackagePrice.billableMetricId + billedInAdvance = newFloatingGroupedTieredPackagePrice.billedInAdvance + billingCycleConfiguration = + newFloatingGroupedTieredPackagePrice.billingCycleConfiguration + conversionRate = newFloatingGroupedTieredPackagePrice.conversionRate + externalPriceId = newFloatingGroupedTieredPackagePrice.externalPriceId + fixedPriceQuantity = newFloatingGroupedTieredPackagePrice.fixedPriceQuantity + invoiceGroupingKey = newFloatingGroupedTieredPackagePrice.invoiceGroupingKey + invoicingCycleConfiguration = + newFloatingGroupedTieredPackagePrice.invoicingCycleConfiguration + metadata = newFloatingGroupedTieredPackagePrice.metadata + additionalProperties = + newFloatingGroupedTieredPackagePrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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)) + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun groupedTieredPackageConfig( + groupedTieredPackageConfig: CustomRatingFunctionConfigModel + ) = groupedTieredPackageConfig(JsonField.of(groupedTieredPackageConfig)) + + fun groupedTieredPackageConfig( + groupedTieredPackageConfig: JsonField + ) = apply { this.groupedTieredPackageConfig = groupedTieredPackageConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + 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)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) + } + + fun build(): NewFloatingGroupedTieredPackagePrice = + NewFloatingGroupedTieredPackagePrice( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("groupedTieredPackageConfig", groupedTieredPackageConfig), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val GROUPED_TIERED_PACKAGE = of("grouped_tiered_package") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + GROUPED_TIERED_PACKAGE + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GROUPED_TIERED_PACKAGE, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GROUPED_TIERED_PACKAGE -> Value.GROUPED_TIERED_PACKAGE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + GROUPED_TIERED_PACKAGE -> Known.GROUPED_TIERED_PACKAGE + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewFloatingGroupedTieredPackagePrice && cadence == other.cadence && currency == other.currency && groupedTieredPackageConfig == other.groupedTieredPackageConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, currency, groupedTieredPackageConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingGroupedTieredPackagePrice{cadence=$cadence, currency=$currency, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingScalableMatrixWithUnitPricingPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("scalable_matrix_with_unit_pricing_config") + @ExcludeMissing + private val scalableMatrixWithUnitPricingConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun scalableMatrixWithUnitPricingConfig(): CustomRatingFunctionConfigModel = + scalableMatrixWithUnitPricingConfig.getRequired( + "scalable_matrix_with_unit_pricing_config" + ) + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** An ISO 4217 currency string for which this price is billed in. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("scalable_matrix_with_unit_pricing_config") + @ExcludeMissing + fun _scalableMatrixWithUnitPricingConfig(): JsonField = + scalableMatrixWithUnitPricingConfig + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewFloatingScalableMatrixWithUnitPricingPrice = apply { + if (validated) { + return@apply + } + + cadence() + currency() + itemId() + modelType() + name() + scalableMatrixWithUnitPricingConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewFloatingScalableMatrixWithUnitPricingPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .currency() + * .itemId() + * .modelType() + * .name() + * .scalableMatrixWithUnitPricingConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewFloatingScalableMatrixWithUnitPricingPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var scalableMatrixWithUnitPricingConfig: + JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + newFloatingScalableMatrixWithUnitPricingPrice: + NewFloatingScalableMatrixWithUnitPricingPrice + ) = apply { + cadence = newFloatingScalableMatrixWithUnitPricingPrice.cadence + currency = newFloatingScalableMatrixWithUnitPricingPrice.currency + itemId = newFloatingScalableMatrixWithUnitPricingPrice.itemId + modelType = newFloatingScalableMatrixWithUnitPricingPrice.modelType + name = newFloatingScalableMatrixWithUnitPricingPrice.name + scalableMatrixWithUnitPricingConfig = + newFloatingScalableMatrixWithUnitPricingPrice + .scalableMatrixWithUnitPricingConfig + billableMetricId = newFloatingScalableMatrixWithUnitPricingPrice.billableMetricId + billedInAdvance = newFloatingScalableMatrixWithUnitPricingPrice.billedInAdvance + billingCycleConfiguration = + newFloatingScalableMatrixWithUnitPricingPrice.billingCycleConfiguration + conversionRate = newFloatingScalableMatrixWithUnitPricingPrice.conversionRate + externalPriceId = newFloatingScalableMatrixWithUnitPricingPrice.externalPriceId + fixedPriceQuantity = + newFloatingScalableMatrixWithUnitPricingPrice.fixedPriceQuantity + invoiceGroupingKey = + newFloatingScalableMatrixWithUnitPricingPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newFloatingScalableMatrixWithUnitPricingPrice.invoicingCycleConfiguration + metadata = newFloatingScalableMatrixWithUnitPricingPrice.metadata + additionalProperties = + newFloatingScalableMatrixWithUnitPricingPrice.additionalProperties + .toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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)) + + /** An ISO 4217 currency string for which this price is billed in. */ + 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)) + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun scalableMatrixWithUnitPricingConfig( + scalableMatrixWithUnitPricingConfig: CustomRatingFunctionConfigModel + ) = + scalableMatrixWithUnitPricingConfig( + JsonField.of(scalableMatrixWithUnitPricingConfig) + ) + + fun scalableMatrixWithUnitPricingConfig( + scalableMatrixWithUnitPricingConfig: JsonField + ) = apply { + this.scalableMatrixWithUnitPricingConfig = scalableMatrixWithUnitPricingConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) + } + + fun build(): NewFloatingScalableMatrixWithUnitPricingPrice = + NewFloatingScalableMatrixWithUnitPricingPrice( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired( + "scalableMatrixWithUnitPricingConfig", + scalableMatrixWithUnitPricingConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField + val SCALABLE_MATRIX_WITH_UNIT_PRICING = of("scalable_matrix_with_unit_pricing") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + SCALABLE_MATRIX_WITH_UNIT_PRICING + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SCALABLE_MATRIX_WITH_UNIT_PRICING, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SCALABLE_MATRIX_WITH_UNIT_PRICING -> Value.SCALABLE_MATRIX_WITH_UNIT_PRICING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SCALABLE_MATRIX_WITH_UNIT_PRICING -> Known.SCALABLE_MATRIX_WITH_UNIT_PRICING + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewFloatingScalableMatrixWithUnitPricingPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && scalableMatrixWithUnitPricingConfig == other.scalableMatrixWithUnitPricingConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, scalableMatrixWithUnitPricingConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingScalableMatrixWithUnitPricingPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingScalableMatrixWithTieredPricingPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("scalable_matrix_with_tiered_pricing_config") + @ExcludeMissing + private val scalableMatrixWithTieredPricingConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun scalableMatrixWithTieredPricingConfig(): CustomRatingFunctionConfigModel = + scalableMatrixWithTieredPricingConfig.getRequired( + "scalable_matrix_with_tiered_pricing_config" + ) + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** An ISO 4217 currency string for which this price is billed in. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("scalable_matrix_with_tiered_pricing_config") + @ExcludeMissing + fun _scalableMatrixWithTieredPricingConfig(): JsonField = + scalableMatrixWithTieredPricingConfig + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewFloatingScalableMatrixWithTieredPricingPrice = apply { + if (validated) { + return@apply + } + + cadence() + currency() + itemId() + modelType() + name() + scalableMatrixWithTieredPricingConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewFloatingScalableMatrixWithTieredPricingPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .currency() + * .itemId() + * .modelType() + * .name() + * .scalableMatrixWithTieredPricingConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewFloatingScalableMatrixWithTieredPricingPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var scalableMatrixWithTieredPricingConfig: + JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + newFloatingScalableMatrixWithTieredPricingPrice: + NewFloatingScalableMatrixWithTieredPricingPrice + ) = apply { + cadence = newFloatingScalableMatrixWithTieredPricingPrice.cadence + currency = newFloatingScalableMatrixWithTieredPricingPrice.currency + itemId = newFloatingScalableMatrixWithTieredPricingPrice.itemId + modelType = newFloatingScalableMatrixWithTieredPricingPrice.modelType + name = newFloatingScalableMatrixWithTieredPricingPrice.name + scalableMatrixWithTieredPricingConfig = + newFloatingScalableMatrixWithTieredPricingPrice + .scalableMatrixWithTieredPricingConfig + billableMetricId = newFloatingScalableMatrixWithTieredPricingPrice.billableMetricId + billedInAdvance = newFloatingScalableMatrixWithTieredPricingPrice.billedInAdvance + billingCycleConfiguration = + newFloatingScalableMatrixWithTieredPricingPrice.billingCycleConfiguration + conversionRate = newFloatingScalableMatrixWithTieredPricingPrice.conversionRate + externalPriceId = newFloatingScalableMatrixWithTieredPricingPrice.externalPriceId + fixedPriceQuantity = + newFloatingScalableMatrixWithTieredPricingPrice.fixedPriceQuantity + invoiceGroupingKey = + newFloatingScalableMatrixWithTieredPricingPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newFloatingScalableMatrixWithTieredPricingPrice.invoicingCycleConfiguration + metadata = newFloatingScalableMatrixWithTieredPricingPrice.metadata + additionalProperties = + newFloatingScalableMatrixWithTieredPricingPrice.additionalProperties + .toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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)) + + /** An ISO 4217 currency string for which this price is billed in. */ + 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)) + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun scalableMatrixWithTieredPricingConfig( + scalableMatrixWithTieredPricingConfig: CustomRatingFunctionConfigModel + ) = + scalableMatrixWithTieredPricingConfig( + JsonField.of(scalableMatrixWithTieredPricingConfig) + ) + + fun scalableMatrixWithTieredPricingConfig( + scalableMatrixWithTieredPricingConfig: JsonField + ) = apply { + this.scalableMatrixWithTieredPricingConfig = scalableMatrixWithTieredPricingConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) + } + + fun build(): NewFloatingScalableMatrixWithTieredPricingPrice = + NewFloatingScalableMatrixWithTieredPricingPrice( + checkRequired("cadence", cadence), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired( + "scalableMatrixWithTieredPricingConfig", + scalableMatrixWithTieredPricingConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField + val SCALABLE_MATRIX_WITH_TIERED_PRICING = of("scalable_matrix_with_tiered_pricing") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + SCALABLE_MATRIX_WITH_TIERED_PRICING + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SCALABLE_MATRIX_WITH_TIERED_PRICING, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SCALABLE_MATRIX_WITH_TIERED_PRICING -> Value.SCALABLE_MATRIX_WITH_TIERED_PRICING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SCALABLE_MATRIX_WITH_TIERED_PRICING -> Known.SCALABLE_MATRIX_WITH_TIERED_PRICING + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewFloatingScalableMatrixWithTieredPricingPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && scalableMatrixWithTieredPricingConfig == other.scalableMatrixWithTieredPricingConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, scalableMatrixWithTieredPricingConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingScalableMatrixWithTieredPricingPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingCumulativeGroupedBulkPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_bulk_config") + @ExcludeMissing + private val cumulativeGroupedBulkConfig: JsonField = + JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun cumulativeGroupedBulkConfig(): CustomRatingFunctionConfigModel = + cumulativeGroupedBulkConfig.getRequired("cumulative_grouped_bulk_config") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + @JsonProperty("cumulative_grouped_bulk_config") + @ExcludeMissing + fun _cumulativeGroupedBulkConfig(): JsonField = + cumulativeGroupedBulkConfig + + /** An ISO 4217 currency string for which this price is billed in. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewFloatingCumulativeGroupedBulkPrice = apply { + if (validated) { + return@apply + } + + cadence() + cumulativeGroupedBulkConfig().validate() + currency() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewFloatingCumulativeGroupedBulkPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .cumulativeGroupedBulkConfig() + * .currency() + * .itemId() + * .modelType() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewFloatingCumulativeGroupedBulkPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var cumulativeGroupedBulkConfig: JsonField? = + null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + newFloatingCumulativeGroupedBulkPrice: NewFloatingCumulativeGroupedBulkPrice + ) = apply { + cadence = newFloatingCumulativeGroupedBulkPrice.cadence + cumulativeGroupedBulkConfig = + newFloatingCumulativeGroupedBulkPrice.cumulativeGroupedBulkConfig + currency = newFloatingCumulativeGroupedBulkPrice.currency + itemId = newFloatingCumulativeGroupedBulkPrice.itemId + modelType = newFloatingCumulativeGroupedBulkPrice.modelType + name = newFloatingCumulativeGroupedBulkPrice.name + billableMetricId = newFloatingCumulativeGroupedBulkPrice.billableMetricId + billedInAdvance = newFloatingCumulativeGroupedBulkPrice.billedInAdvance + billingCycleConfiguration = + newFloatingCumulativeGroupedBulkPrice.billingCycleConfiguration + conversionRate = newFloatingCumulativeGroupedBulkPrice.conversionRate + externalPriceId = newFloatingCumulativeGroupedBulkPrice.externalPriceId + fixedPriceQuantity = newFloatingCumulativeGroupedBulkPrice.fixedPriceQuantity + invoiceGroupingKey = newFloatingCumulativeGroupedBulkPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newFloatingCumulativeGroupedBulkPrice.invoicingCycleConfiguration + metadata = newFloatingCumulativeGroupedBulkPrice.metadata + additionalProperties = + newFloatingCumulativeGroupedBulkPrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun cumulativeGroupedBulkConfig( + cumulativeGroupedBulkConfig: CustomRatingFunctionConfigModel + ) = cumulativeGroupedBulkConfig(JsonField.of(cumulativeGroupedBulkConfig)) + + fun cumulativeGroupedBulkConfig( + cumulativeGroupedBulkConfig: JsonField + ) = apply { this.cumulativeGroupedBulkConfig = cumulativeGroupedBulkConfig } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** An ISO 4217 currency string for which this price is billed in. */ + 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)) + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + 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)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) + } + + fun build(): NewFloatingCumulativeGroupedBulkPrice = + NewFloatingCumulativeGroupedBulkPrice( + checkRequired("cadence", cadence), + checkRequired("cumulativeGroupedBulkConfig", cumulativeGroupedBulkConfig), + checkRequired("currency", currency), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CUMULATIVE_GROUPED_BULK = of("cumulative_grouped_bulk") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + CUMULATIVE_GROUPED_BULK + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CUMULATIVE_GROUPED_BULK, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CUMULATIVE_GROUPED_BULK -> Value.CUMULATIVE_GROUPED_BULK + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CUMULATIVE_GROUPED_BULK -> Known.CUMULATIVE_GROUPED_BULK + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewFloatingCumulativeGroupedBulkPrice && cadence == other.cadence && cumulativeGroupedBulkConfig == other.cumulativeGroupedBulkConfig && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, cumulativeGroupedBulkConfig, currency, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingCumulativeGroupedBulkPrice{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewReportingConfigurationModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewReportingConfigurationModel.kt new file mode 100644 index 000000000..4955da8c7 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewReportingConfigurationModel.kt @@ -0,0 +1,123 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects + +@NoAutoDetect +class NewReportingConfigurationModel +@JsonCreator +private constructor( + @JsonProperty("exempt") + @ExcludeMissing + private val exempt: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun exempt(): Boolean = exempt.getRequired("exempt") + + @JsonProperty("exempt") @ExcludeMissing fun _exempt(): JsonField = exempt + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewReportingConfigurationModel = apply { + if (validated) { + return@apply + } + + exempt() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewReportingConfigurationModel]. + * + * The following fields are required: + * ```java + * .exempt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewReportingConfigurationModel]. */ + class Builder internal constructor() { + + private var exempt: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(newReportingConfigurationModel: NewReportingConfigurationModel) = apply { + exempt = newReportingConfigurationModel.exempt + additionalProperties = + newReportingConfigurationModel.additionalProperties.toMutableMap() + } + + fun exempt(exempt: Boolean) = exempt(JsonField.of(exempt)) + + fun exempt(exempt: JsonField) = apply { this.exempt = exempt } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): NewReportingConfigurationModel = + NewReportingConfigurationModel( + checkRequired("exempt", exempt), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewReportingConfigurationModel && exempt == other.exempt && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(exempt, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewReportingConfigurationModel{exempt=$exempt, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPriceModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPriceModel.kt new file mode 100644 index 000000000..73be94ced --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewSubscriptionPriceModel.kt @@ -0,0 +1,24632 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.BaseDeserializer +import com.withorb.api.core.BaseSerializer +import com.withorb.api.core.Enum +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.getOrThrow +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +@JsonDeserialize(using = NewSubscriptionPriceModel.Deserializer::class) +@JsonSerialize(using = NewSubscriptionPriceModel.Serializer::class) +class NewSubscriptionPriceModel +private constructor( + private val unitPrice: NewSubscriptionUnitPrice? = null, + private val packagePrice: NewSubscriptionPackagePrice? = null, + private val matrixPrice: NewSubscriptionMatrixPrice? = null, + private val tieredPrice: NewSubscriptionTieredPrice? = null, + private val tieredBpsPrice: NewSubscriptionTieredBpsPrice? = null, + private val bpsPrice: NewSubscriptionBpsPrice? = null, + private val bulkBpsPrice: NewSubscriptionBulkBpsPrice? = null, + private val bulkPrice: NewSubscriptionBulkPrice? = null, + private val thresholdTotalAmountPrice: NewSubscriptionThresholdTotalAmountPrice? = null, + private val tieredPackagePrice: NewSubscriptionTieredPackagePrice? = null, + private val tieredWithMinimumPrice: NewSubscriptionTieredWithMinimumPrice? = null, + private val unitWithPercentPrice: NewSubscriptionUnitWithPercentPrice? = null, + private val packageWithAllocationPrice: NewSubscriptionPackageWithAllocationPrice? = null, + private val tierWithProrationPrice: NewSubscriptionTierWithProrationPrice? = null, + private val unitWithProrationPrice: NewSubscriptionUnitWithProrationPrice? = null, + private val groupedAllocationPrice: NewSubscriptionGroupedAllocationPrice? = null, + private val groupedWithProratedMinimumPrice: NewSubscriptionGroupedWithProratedMinimumPrice? = + null, + private val bulkWithProrationPrice: NewSubscriptionBulkWithProrationPrice? = null, + private val scalableMatrixWithUnitPricingPrice: + NewSubscriptionScalableMatrixWithUnitPricingPrice? = + null, + private val scalableMatrixWithTieredPricingPrice: + NewSubscriptionScalableMatrixWithTieredPricingPrice? = + null, + private val cumulativeGroupedBulkPrice: NewSubscriptionCumulativeGroupedBulkPrice? = null, + private val maxGroupTieredPackagePrice: NewSubscriptionMaxGroupTieredPackagePrice? = null, + private val groupedWithMeteredMinimumPrice: NewSubscriptionGroupedWithMeteredMinimumPrice? = + null, + private val matrixWithDisplayNamePrice: NewSubscriptionMatrixWithDisplayNamePrice? = null, + private val groupedTieredPackagePrice: NewSubscriptionGroupedTieredPackagePrice? = null, + private val _json: JsonValue? = null, +) { + + fun unitPrice(): Optional = Optional.ofNullable(unitPrice) + + fun packagePrice(): Optional = Optional.ofNullable(packagePrice) + + fun matrixPrice(): Optional = Optional.ofNullable(matrixPrice) + + fun tieredPrice(): Optional = Optional.ofNullable(tieredPrice) + + fun tieredBpsPrice(): Optional = + Optional.ofNullable(tieredBpsPrice) + + fun bpsPrice(): Optional = Optional.ofNullable(bpsPrice) + + fun bulkBpsPrice(): Optional = Optional.ofNullable(bulkBpsPrice) + + fun bulkPrice(): Optional = Optional.ofNullable(bulkPrice) + + fun thresholdTotalAmountPrice(): Optional = + Optional.ofNullable(thresholdTotalAmountPrice) + + fun tieredPackagePrice(): Optional = + Optional.ofNullable(tieredPackagePrice) + + fun tieredWithMinimumPrice(): Optional = + Optional.ofNullable(tieredWithMinimumPrice) + + fun unitWithPercentPrice(): Optional = + Optional.ofNullable(unitWithPercentPrice) + + fun packageWithAllocationPrice(): Optional = + Optional.ofNullable(packageWithAllocationPrice) + + fun tierWithProrationPrice(): Optional = + Optional.ofNullable(tierWithProrationPrice) + + fun unitWithProrationPrice(): Optional = + Optional.ofNullable(unitWithProrationPrice) + + fun groupedAllocationPrice(): Optional = + Optional.ofNullable(groupedAllocationPrice) + + fun groupedWithProratedMinimumPrice(): + Optional = + Optional.ofNullable(groupedWithProratedMinimumPrice) + + fun bulkWithProrationPrice(): Optional = + Optional.ofNullable(bulkWithProrationPrice) + + fun scalableMatrixWithUnitPricingPrice(): + Optional = + Optional.ofNullable(scalableMatrixWithUnitPricingPrice) + + fun scalableMatrixWithTieredPricingPrice(): + Optional = + Optional.ofNullable(scalableMatrixWithTieredPricingPrice) + + fun cumulativeGroupedBulkPrice(): Optional = + Optional.ofNullable(cumulativeGroupedBulkPrice) + + fun maxGroupTieredPackagePrice(): Optional = + Optional.ofNullable(maxGroupTieredPackagePrice) + + fun groupedWithMeteredMinimumPrice(): Optional = + Optional.ofNullable(groupedWithMeteredMinimumPrice) + + fun matrixWithDisplayNamePrice(): Optional = + Optional.ofNullable(matrixWithDisplayNamePrice) + + fun groupedTieredPackagePrice(): Optional = + Optional.ofNullable(groupedTieredPackagePrice) + + fun isUnitPrice(): Boolean = unitPrice != null + + fun isPackagePrice(): Boolean = packagePrice != null + + fun isMatrixPrice(): Boolean = matrixPrice != null + + fun isTieredPrice(): Boolean = tieredPrice != null + + fun isTieredBpsPrice(): Boolean = tieredBpsPrice != null + + fun isBpsPrice(): Boolean = bpsPrice != null + + fun isBulkBpsPrice(): Boolean = bulkBpsPrice != null + + fun isBulkPrice(): Boolean = bulkPrice != null + + fun isThresholdTotalAmountPrice(): Boolean = thresholdTotalAmountPrice != null + + fun isTieredPackagePrice(): Boolean = tieredPackagePrice != null + + fun isTieredWithMinimumPrice(): Boolean = tieredWithMinimumPrice != null + + fun isUnitWithPercentPrice(): Boolean = unitWithPercentPrice != null + + fun isPackageWithAllocationPrice(): Boolean = packageWithAllocationPrice != null + + fun isTierWithProrationPrice(): Boolean = tierWithProrationPrice != null + + fun isUnitWithProrationPrice(): Boolean = unitWithProrationPrice != null + + fun isGroupedAllocationPrice(): Boolean = groupedAllocationPrice != null + + fun isGroupedWithProratedMinimumPrice(): Boolean = groupedWithProratedMinimumPrice != null + + fun isBulkWithProrationPrice(): Boolean = bulkWithProrationPrice != null + + fun isScalableMatrixWithUnitPricingPrice(): Boolean = scalableMatrixWithUnitPricingPrice != null + + fun isScalableMatrixWithTieredPricingPrice(): Boolean = + scalableMatrixWithTieredPricingPrice != null + + fun isCumulativeGroupedBulkPrice(): Boolean = cumulativeGroupedBulkPrice != null + + fun isMaxGroupTieredPackagePrice(): Boolean = maxGroupTieredPackagePrice != null + + fun isGroupedWithMeteredMinimumPrice(): Boolean = groupedWithMeteredMinimumPrice != null + + fun isMatrixWithDisplayNamePrice(): Boolean = matrixWithDisplayNamePrice != null + + fun isGroupedTieredPackagePrice(): Boolean = groupedTieredPackagePrice != null + + fun asUnitPrice(): NewSubscriptionUnitPrice = unitPrice.getOrThrow("unitPrice") + + fun asPackagePrice(): NewSubscriptionPackagePrice = packagePrice.getOrThrow("packagePrice") + + fun asMatrixPrice(): NewSubscriptionMatrixPrice = matrixPrice.getOrThrow("matrixPrice") + + fun asTieredPrice(): NewSubscriptionTieredPrice = tieredPrice.getOrThrow("tieredPrice") + + fun asTieredBpsPrice(): NewSubscriptionTieredBpsPrice = + tieredBpsPrice.getOrThrow("tieredBpsPrice") + + fun asBpsPrice(): NewSubscriptionBpsPrice = bpsPrice.getOrThrow("bpsPrice") + + fun asBulkBpsPrice(): NewSubscriptionBulkBpsPrice = bulkBpsPrice.getOrThrow("bulkBpsPrice") + + fun asBulkPrice(): NewSubscriptionBulkPrice = bulkPrice.getOrThrow("bulkPrice") + + fun asThresholdTotalAmountPrice(): NewSubscriptionThresholdTotalAmountPrice = + thresholdTotalAmountPrice.getOrThrow("thresholdTotalAmountPrice") + + fun asTieredPackagePrice(): NewSubscriptionTieredPackagePrice = + tieredPackagePrice.getOrThrow("tieredPackagePrice") + + fun asTieredWithMinimumPrice(): NewSubscriptionTieredWithMinimumPrice = + tieredWithMinimumPrice.getOrThrow("tieredWithMinimumPrice") + + fun asUnitWithPercentPrice(): NewSubscriptionUnitWithPercentPrice = + unitWithPercentPrice.getOrThrow("unitWithPercentPrice") + + fun asPackageWithAllocationPrice(): NewSubscriptionPackageWithAllocationPrice = + packageWithAllocationPrice.getOrThrow("packageWithAllocationPrice") + + fun asTierWithProrationPrice(): NewSubscriptionTierWithProrationPrice = + tierWithProrationPrice.getOrThrow("tierWithProrationPrice") + + fun asUnitWithProrationPrice(): NewSubscriptionUnitWithProrationPrice = + unitWithProrationPrice.getOrThrow("unitWithProrationPrice") + + fun asGroupedAllocationPrice(): NewSubscriptionGroupedAllocationPrice = + groupedAllocationPrice.getOrThrow("groupedAllocationPrice") + + fun asGroupedWithProratedMinimumPrice(): NewSubscriptionGroupedWithProratedMinimumPrice = + groupedWithProratedMinimumPrice.getOrThrow("groupedWithProratedMinimumPrice") + + fun asBulkWithProrationPrice(): NewSubscriptionBulkWithProrationPrice = + bulkWithProrationPrice.getOrThrow("bulkWithProrationPrice") + + fun asScalableMatrixWithUnitPricingPrice(): NewSubscriptionScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricingPrice.getOrThrow("scalableMatrixWithUnitPricingPrice") + + fun asScalableMatrixWithTieredPricingPrice(): + NewSubscriptionScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricingPrice.getOrThrow("scalableMatrixWithTieredPricingPrice") + + fun asCumulativeGroupedBulkPrice(): NewSubscriptionCumulativeGroupedBulkPrice = + cumulativeGroupedBulkPrice.getOrThrow("cumulativeGroupedBulkPrice") + + fun asMaxGroupTieredPackagePrice(): NewSubscriptionMaxGroupTieredPackagePrice = + maxGroupTieredPackagePrice.getOrThrow("maxGroupTieredPackagePrice") + + fun asGroupedWithMeteredMinimumPrice(): NewSubscriptionGroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimumPrice.getOrThrow("groupedWithMeteredMinimumPrice") + + fun asMatrixWithDisplayNamePrice(): NewSubscriptionMatrixWithDisplayNamePrice = + matrixWithDisplayNamePrice.getOrThrow("matrixWithDisplayNamePrice") + + fun asGroupedTieredPackagePrice(): NewSubscriptionGroupedTieredPackagePrice = + groupedTieredPackagePrice.getOrThrow("groupedTieredPackagePrice") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + unitPrice != null -> visitor.visitUnitPrice(unitPrice) + packagePrice != null -> visitor.visitPackagePrice(packagePrice) + matrixPrice != null -> visitor.visitMatrixPrice(matrixPrice) + tieredPrice != null -> visitor.visitTieredPrice(tieredPrice) + tieredBpsPrice != null -> visitor.visitTieredBpsPrice(tieredBpsPrice) + bpsPrice != null -> visitor.visitBpsPrice(bpsPrice) + bulkBpsPrice != null -> visitor.visitBulkBpsPrice(bulkBpsPrice) + bulkPrice != null -> visitor.visitBulkPrice(bulkPrice) + thresholdTotalAmountPrice != null -> + visitor.visitThresholdTotalAmountPrice(thresholdTotalAmountPrice) + tieredPackagePrice != null -> visitor.visitTieredPackagePrice(tieredPackagePrice) + tieredWithMinimumPrice != null -> + visitor.visitTieredWithMinimumPrice(tieredWithMinimumPrice) + unitWithPercentPrice != null -> visitor.visitUnitWithPercentPrice(unitWithPercentPrice) + packageWithAllocationPrice != null -> + visitor.visitPackageWithAllocationPrice(packageWithAllocationPrice) + tierWithProrationPrice != null -> + visitor.visitTierWithProrationPrice(tierWithProrationPrice) + unitWithProrationPrice != null -> + visitor.visitUnitWithProrationPrice(unitWithProrationPrice) + groupedAllocationPrice != null -> + visitor.visitGroupedAllocationPrice(groupedAllocationPrice) + groupedWithProratedMinimumPrice != null -> + visitor.visitGroupedWithProratedMinimumPrice(groupedWithProratedMinimumPrice) + bulkWithProrationPrice != null -> + visitor.visitBulkWithProrationPrice(bulkWithProrationPrice) + scalableMatrixWithUnitPricingPrice != null -> + visitor.visitScalableMatrixWithUnitPricingPrice(scalableMatrixWithUnitPricingPrice) + scalableMatrixWithTieredPricingPrice != null -> + visitor.visitScalableMatrixWithTieredPricingPrice( + scalableMatrixWithTieredPricingPrice + ) + cumulativeGroupedBulkPrice != null -> + visitor.visitCumulativeGroupedBulkPrice(cumulativeGroupedBulkPrice) + maxGroupTieredPackagePrice != null -> + visitor.visitMaxGroupTieredPackagePrice(maxGroupTieredPackagePrice) + groupedWithMeteredMinimumPrice != null -> + visitor.visitGroupedWithMeteredMinimumPrice(groupedWithMeteredMinimumPrice) + matrixWithDisplayNamePrice != null -> + visitor.visitMatrixWithDisplayNamePrice(matrixWithDisplayNamePrice) + groupedTieredPackagePrice != null -> + visitor.visitGroupedTieredPackagePrice(groupedTieredPackagePrice) + else -> visitor.unknown(_json) + } + } + + private var validated: Boolean = false + + fun validate(): NewSubscriptionPriceModel = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnitPrice(unitPrice: NewSubscriptionUnitPrice) { + unitPrice.validate() + } + + override fun visitPackagePrice(packagePrice: NewSubscriptionPackagePrice) { + packagePrice.validate() + } + + override fun visitMatrixPrice(matrixPrice: NewSubscriptionMatrixPrice) { + matrixPrice.validate() + } + + override fun visitTieredPrice(tieredPrice: NewSubscriptionTieredPrice) { + tieredPrice.validate() + } + + override fun visitTieredBpsPrice(tieredBpsPrice: NewSubscriptionTieredBpsPrice) { + tieredBpsPrice.validate() + } + + override fun visitBpsPrice(bpsPrice: NewSubscriptionBpsPrice) { + bpsPrice.validate() + } + + override fun visitBulkBpsPrice(bulkBpsPrice: NewSubscriptionBulkBpsPrice) { + bulkBpsPrice.validate() + } + + override fun visitBulkPrice(bulkPrice: NewSubscriptionBulkPrice) { + bulkPrice.validate() + } + + override fun visitThresholdTotalAmountPrice( + thresholdTotalAmountPrice: NewSubscriptionThresholdTotalAmountPrice + ) { + thresholdTotalAmountPrice.validate() + } + + override fun visitTieredPackagePrice( + tieredPackagePrice: NewSubscriptionTieredPackagePrice + ) { + tieredPackagePrice.validate() + } + + override fun visitTieredWithMinimumPrice( + tieredWithMinimumPrice: NewSubscriptionTieredWithMinimumPrice + ) { + tieredWithMinimumPrice.validate() + } + + override fun visitUnitWithPercentPrice( + unitWithPercentPrice: NewSubscriptionUnitWithPercentPrice + ) { + unitWithPercentPrice.validate() + } + + override fun visitPackageWithAllocationPrice( + packageWithAllocationPrice: NewSubscriptionPackageWithAllocationPrice + ) { + packageWithAllocationPrice.validate() + } + + override fun visitTierWithProrationPrice( + tierWithProrationPrice: NewSubscriptionTierWithProrationPrice + ) { + tierWithProrationPrice.validate() + } + + override fun visitUnitWithProrationPrice( + unitWithProrationPrice: NewSubscriptionUnitWithProrationPrice + ) { + unitWithProrationPrice.validate() + } + + override fun visitGroupedAllocationPrice( + groupedAllocationPrice: NewSubscriptionGroupedAllocationPrice + ) { + groupedAllocationPrice.validate() + } + + override fun visitGroupedWithProratedMinimumPrice( + groupedWithProratedMinimumPrice: NewSubscriptionGroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimumPrice.validate() + } + + override fun visitBulkWithProrationPrice( + bulkWithProrationPrice: NewSubscriptionBulkWithProrationPrice + ) { + bulkWithProrationPrice.validate() + } + + override fun visitScalableMatrixWithUnitPricingPrice( + scalableMatrixWithUnitPricingPrice: + NewSubscriptionScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricingPrice.validate() + } + + override fun visitScalableMatrixWithTieredPricingPrice( + scalableMatrixWithTieredPricingPrice: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricingPrice.validate() + } + + override fun visitCumulativeGroupedBulkPrice( + cumulativeGroupedBulkPrice: NewSubscriptionCumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulkPrice.validate() + } + + override fun visitMaxGroupTieredPackagePrice( + maxGroupTieredPackagePrice: NewSubscriptionMaxGroupTieredPackagePrice + ) { + maxGroupTieredPackagePrice.validate() + } + + override fun visitGroupedWithMeteredMinimumPrice( + groupedWithMeteredMinimumPrice: NewSubscriptionGroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimumPrice.validate() + } + + override fun visitMatrixWithDisplayNamePrice( + matrixWithDisplayNamePrice: NewSubscriptionMatrixWithDisplayNamePrice + ) { + matrixWithDisplayNamePrice.validate() + } + + override fun visitGroupedTieredPackagePrice( + groupedTieredPackagePrice: NewSubscriptionGroupedTieredPackagePrice + ) { + groupedTieredPackagePrice.validate() + } + } + ) + validated = true + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewSubscriptionPriceModel && unitPrice == other.unitPrice && packagePrice == other.packagePrice && matrixPrice == other.matrixPrice && tieredPrice == other.tieredPrice && tieredBpsPrice == other.tieredBpsPrice && bpsPrice == other.bpsPrice && bulkBpsPrice == other.bulkBpsPrice && bulkPrice == other.bulkPrice && thresholdTotalAmountPrice == other.thresholdTotalAmountPrice && tieredPackagePrice == other.tieredPackagePrice && tieredWithMinimumPrice == other.tieredWithMinimumPrice && unitWithPercentPrice == other.unitWithPercentPrice && packageWithAllocationPrice == other.packageWithAllocationPrice && tierWithProrationPrice == other.tierWithProrationPrice && unitWithProrationPrice == other.unitWithProrationPrice && groupedAllocationPrice == other.groupedAllocationPrice && groupedWithProratedMinimumPrice == other.groupedWithProratedMinimumPrice && bulkWithProrationPrice == other.bulkWithProrationPrice && scalableMatrixWithUnitPricingPrice == other.scalableMatrixWithUnitPricingPrice && scalableMatrixWithTieredPricingPrice == other.scalableMatrixWithTieredPricingPrice && cumulativeGroupedBulkPrice == other.cumulativeGroupedBulkPrice && maxGroupTieredPackagePrice == other.maxGroupTieredPackagePrice && groupedWithMeteredMinimumPrice == other.groupedWithMeteredMinimumPrice && matrixWithDisplayNamePrice == other.matrixWithDisplayNamePrice && groupedTieredPackagePrice == other.groupedTieredPackagePrice /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(unitPrice, packagePrice, matrixPrice, tieredPrice, tieredBpsPrice, bpsPrice, bulkBpsPrice, bulkPrice, thresholdTotalAmountPrice, tieredPackagePrice, tieredWithMinimumPrice, unitWithPercentPrice, packageWithAllocationPrice, tierWithProrationPrice, unitWithProrationPrice, groupedAllocationPrice, groupedWithProratedMinimumPrice, bulkWithProrationPrice, scalableMatrixWithUnitPricingPrice, scalableMatrixWithTieredPricingPrice, cumulativeGroupedBulkPrice, maxGroupTieredPackagePrice, groupedWithMeteredMinimumPrice, matrixWithDisplayNamePrice, groupedTieredPackagePrice) /* spotless:on */ + + override fun toString(): String = + when { + unitPrice != null -> "NewSubscriptionPriceModel{unitPrice=$unitPrice}" + packagePrice != null -> "NewSubscriptionPriceModel{packagePrice=$packagePrice}" + matrixPrice != null -> "NewSubscriptionPriceModel{matrixPrice=$matrixPrice}" + tieredPrice != null -> "NewSubscriptionPriceModel{tieredPrice=$tieredPrice}" + tieredBpsPrice != null -> "NewSubscriptionPriceModel{tieredBpsPrice=$tieredBpsPrice}" + bpsPrice != null -> "NewSubscriptionPriceModel{bpsPrice=$bpsPrice}" + bulkBpsPrice != null -> "NewSubscriptionPriceModel{bulkBpsPrice=$bulkBpsPrice}" + bulkPrice != null -> "NewSubscriptionPriceModel{bulkPrice=$bulkPrice}" + thresholdTotalAmountPrice != null -> + "NewSubscriptionPriceModel{thresholdTotalAmountPrice=$thresholdTotalAmountPrice}" + tieredPackagePrice != null -> + "NewSubscriptionPriceModel{tieredPackagePrice=$tieredPackagePrice}" + tieredWithMinimumPrice != null -> + "NewSubscriptionPriceModel{tieredWithMinimumPrice=$tieredWithMinimumPrice}" + unitWithPercentPrice != null -> + "NewSubscriptionPriceModel{unitWithPercentPrice=$unitWithPercentPrice}" + packageWithAllocationPrice != null -> + "NewSubscriptionPriceModel{packageWithAllocationPrice=$packageWithAllocationPrice}" + tierWithProrationPrice != null -> + "NewSubscriptionPriceModel{tierWithProrationPrice=$tierWithProrationPrice}" + unitWithProrationPrice != null -> + "NewSubscriptionPriceModel{unitWithProrationPrice=$unitWithProrationPrice}" + groupedAllocationPrice != null -> + "NewSubscriptionPriceModel{groupedAllocationPrice=$groupedAllocationPrice}" + groupedWithProratedMinimumPrice != null -> + "NewSubscriptionPriceModel{groupedWithProratedMinimumPrice=$groupedWithProratedMinimumPrice}" + bulkWithProrationPrice != null -> + "NewSubscriptionPriceModel{bulkWithProrationPrice=$bulkWithProrationPrice}" + scalableMatrixWithUnitPricingPrice != null -> + "NewSubscriptionPriceModel{scalableMatrixWithUnitPricingPrice=$scalableMatrixWithUnitPricingPrice}" + scalableMatrixWithTieredPricingPrice != null -> + "NewSubscriptionPriceModel{scalableMatrixWithTieredPricingPrice=$scalableMatrixWithTieredPricingPrice}" + cumulativeGroupedBulkPrice != null -> + "NewSubscriptionPriceModel{cumulativeGroupedBulkPrice=$cumulativeGroupedBulkPrice}" + maxGroupTieredPackagePrice != null -> + "NewSubscriptionPriceModel{maxGroupTieredPackagePrice=$maxGroupTieredPackagePrice}" + groupedWithMeteredMinimumPrice != null -> + "NewSubscriptionPriceModel{groupedWithMeteredMinimumPrice=$groupedWithMeteredMinimumPrice}" + matrixWithDisplayNamePrice != null -> + "NewSubscriptionPriceModel{matrixWithDisplayNamePrice=$matrixWithDisplayNamePrice}" + groupedTieredPackagePrice != null -> + "NewSubscriptionPriceModel{groupedTieredPackagePrice=$groupedTieredPackagePrice}" + _json != null -> "NewSubscriptionPriceModel{_unknown=$_json}" + else -> throw IllegalStateException("Invalid NewSubscriptionPriceModel") + } + + companion object { + + @JvmStatic + fun ofUnitPrice(unitPrice: NewSubscriptionUnitPrice) = + NewSubscriptionPriceModel(unitPrice = unitPrice) + + @JvmStatic + fun ofPackagePrice(packagePrice: NewSubscriptionPackagePrice) = + NewSubscriptionPriceModel(packagePrice = packagePrice) + + @JvmStatic + fun ofMatrixPrice(matrixPrice: NewSubscriptionMatrixPrice) = + NewSubscriptionPriceModel(matrixPrice = matrixPrice) + + @JvmStatic + fun ofTieredPrice(tieredPrice: NewSubscriptionTieredPrice) = + NewSubscriptionPriceModel(tieredPrice = tieredPrice) + + @JvmStatic + fun ofTieredBpsPrice(tieredBpsPrice: NewSubscriptionTieredBpsPrice) = + NewSubscriptionPriceModel(tieredBpsPrice = tieredBpsPrice) + + @JvmStatic + fun ofBpsPrice(bpsPrice: NewSubscriptionBpsPrice) = + NewSubscriptionPriceModel(bpsPrice = bpsPrice) + + @JvmStatic + fun ofBulkBpsPrice(bulkBpsPrice: NewSubscriptionBulkBpsPrice) = + NewSubscriptionPriceModel(bulkBpsPrice = bulkBpsPrice) + + @JvmStatic + fun ofBulkPrice(bulkPrice: NewSubscriptionBulkPrice) = + NewSubscriptionPriceModel(bulkPrice = bulkPrice) + + @JvmStatic + fun ofThresholdTotalAmountPrice( + thresholdTotalAmountPrice: NewSubscriptionThresholdTotalAmountPrice + ) = NewSubscriptionPriceModel(thresholdTotalAmountPrice = thresholdTotalAmountPrice) + + @JvmStatic + fun ofTieredPackagePrice(tieredPackagePrice: NewSubscriptionTieredPackagePrice) = + NewSubscriptionPriceModel(tieredPackagePrice = tieredPackagePrice) + + @JvmStatic + fun ofTieredWithMinimumPrice( + tieredWithMinimumPrice: NewSubscriptionTieredWithMinimumPrice + ) = NewSubscriptionPriceModel(tieredWithMinimumPrice = tieredWithMinimumPrice) + + @JvmStatic + fun ofUnitWithPercentPrice(unitWithPercentPrice: NewSubscriptionUnitWithPercentPrice) = + NewSubscriptionPriceModel(unitWithPercentPrice = unitWithPercentPrice) + + @JvmStatic + fun ofPackageWithAllocationPrice( + packageWithAllocationPrice: NewSubscriptionPackageWithAllocationPrice + ) = NewSubscriptionPriceModel(packageWithAllocationPrice = packageWithAllocationPrice) + + @JvmStatic + fun ofTierWithProrationPrice( + tierWithProrationPrice: NewSubscriptionTierWithProrationPrice + ) = NewSubscriptionPriceModel(tierWithProrationPrice = tierWithProrationPrice) + + @JvmStatic + fun ofUnitWithProrationPrice( + unitWithProrationPrice: NewSubscriptionUnitWithProrationPrice + ) = NewSubscriptionPriceModel(unitWithProrationPrice = unitWithProrationPrice) + + @JvmStatic + fun ofGroupedAllocationPrice( + groupedAllocationPrice: NewSubscriptionGroupedAllocationPrice + ) = NewSubscriptionPriceModel(groupedAllocationPrice = groupedAllocationPrice) + + @JvmStatic + fun ofGroupedWithProratedMinimumPrice( + groupedWithProratedMinimumPrice: NewSubscriptionGroupedWithProratedMinimumPrice + ) = + NewSubscriptionPriceModel( + groupedWithProratedMinimumPrice = groupedWithProratedMinimumPrice + ) + + @JvmStatic + fun ofBulkWithProrationPrice( + bulkWithProrationPrice: NewSubscriptionBulkWithProrationPrice + ) = NewSubscriptionPriceModel(bulkWithProrationPrice = bulkWithProrationPrice) + + @JvmStatic + fun ofScalableMatrixWithUnitPricingPrice( + scalableMatrixWithUnitPricingPrice: NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = + NewSubscriptionPriceModel( + scalableMatrixWithUnitPricingPrice = scalableMatrixWithUnitPricingPrice + ) + + @JvmStatic + fun ofScalableMatrixWithTieredPricingPrice( + scalableMatrixWithTieredPricingPrice: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = + NewSubscriptionPriceModel( + scalableMatrixWithTieredPricingPrice = scalableMatrixWithTieredPricingPrice + ) + + @JvmStatic + fun ofCumulativeGroupedBulkPrice( + cumulativeGroupedBulkPrice: NewSubscriptionCumulativeGroupedBulkPrice + ) = NewSubscriptionPriceModel(cumulativeGroupedBulkPrice = cumulativeGroupedBulkPrice) + + @JvmStatic + fun ofMaxGroupTieredPackagePrice( + maxGroupTieredPackagePrice: NewSubscriptionMaxGroupTieredPackagePrice + ) = NewSubscriptionPriceModel(maxGroupTieredPackagePrice = maxGroupTieredPackagePrice) + + @JvmStatic + fun ofGroupedWithMeteredMinimumPrice( + groupedWithMeteredMinimumPrice: NewSubscriptionGroupedWithMeteredMinimumPrice + ) = + NewSubscriptionPriceModel( + groupedWithMeteredMinimumPrice = groupedWithMeteredMinimumPrice + ) + + @JvmStatic + fun ofMatrixWithDisplayNamePrice( + matrixWithDisplayNamePrice: NewSubscriptionMatrixWithDisplayNamePrice + ) = NewSubscriptionPriceModel(matrixWithDisplayNamePrice = matrixWithDisplayNamePrice) + + @JvmStatic + fun ofGroupedTieredPackagePrice( + groupedTieredPackagePrice: NewSubscriptionGroupedTieredPackagePrice + ) = NewSubscriptionPriceModel(groupedTieredPackagePrice = groupedTieredPackagePrice) + } + + /** + * An interface that defines how to map each variant of [NewSubscriptionPriceModel] to a value + * of type [T]. + */ + interface Visitor { + + fun visitUnitPrice(unitPrice: NewSubscriptionUnitPrice): T + + fun visitPackagePrice(packagePrice: NewSubscriptionPackagePrice): T + + fun visitMatrixPrice(matrixPrice: NewSubscriptionMatrixPrice): T + + fun visitTieredPrice(tieredPrice: NewSubscriptionTieredPrice): T + + fun visitTieredBpsPrice(tieredBpsPrice: NewSubscriptionTieredBpsPrice): T + + fun visitBpsPrice(bpsPrice: NewSubscriptionBpsPrice): T + + fun visitBulkBpsPrice(bulkBpsPrice: NewSubscriptionBulkBpsPrice): T + + fun visitBulkPrice(bulkPrice: NewSubscriptionBulkPrice): T + + fun visitThresholdTotalAmountPrice( + thresholdTotalAmountPrice: NewSubscriptionThresholdTotalAmountPrice + ): T + + fun visitTieredPackagePrice(tieredPackagePrice: NewSubscriptionTieredPackagePrice): T + + fun visitTieredWithMinimumPrice( + tieredWithMinimumPrice: NewSubscriptionTieredWithMinimumPrice + ): T + + fun visitUnitWithPercentPrice(unitWithPercentPrice: NewSubscriptionUnitWithPercentPrice): T + + fun visitPackageWithAllocationPrice( + packageWithAllocationPrice: NewSubscriptionPackageWithAllocationPrice + ): T + + fun visitTierWithProrationPrice( + tierWithProrationPrice: NewSubscriptionTierWithProrationPrice + ): T + + fun visitUnitWithProrationPrice( + unitWithProrationPrice: NewSubscriptionUnitWithProrationPrice + ): T + + fun visitGroupedAllocationPrice( + groupedAllocationPrice: NewSubscriptionGroupedAllocationPrice + ): T + + fun visitGroupedWithProratedMinimumPrice( + groupedWithProratedMinimumPrice: NewSubscriptionGroupedWithProratedMinimumPrice + ): T + + fun visitBulkWithProrationPrice( + bulkWithProrationPrice: NewSubscriptionBulkWithProrationPrice + ): T + + fun visitScalableMatrixWithUnitPricingPrice( + scalableMatrixWithUnitPricingPrice: NewSubscriptionScalableMatrixWithUnitPricingPrice + ): T + + fun visitScalableMatrixWithTieredPricingPrice( + scalableMatrixWithTieredPricingPrice: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ): T + + fun visitCumulativeGroupedBulkPrice( + cumulativeGroupedBulkPrice: NewSubscriptionCumulativeGroupedBulkPrice + ): T + + fun visitMaxGroupTieredPackagePrice( + maxGroupTieredPackagePrice: NewSubscriptionMaxGroupTieredPackagePrice + ): T + + fun visitGroupedWithMeteredMinimumPrice( + groupedWithMeteredMinimumPrice: NewSubscriptionGroupedWithMeteredMinimumPrice + ): T + + fun visitMatrixWithDisplayNamePrice( + matrixWithDisplayNamePrice: NewSubscriptionMatrixWithDisplayNamePrice + ): T + + fun visitGroupedTieredPackagePrice( + groupedTieredPackagePrice: NewSubscriptionGroupedTieredPackagePrice + ): T + + /** + * Maps an unknown variant of [NewSubscriptionPriceModel] to a value of type [T]. + * + * An instance of [NewSubscriptionPriceModel] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the SDK is + * on an older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown NewSubscriptionPriceModel: $json") + } + } + + internal class Deserializer : + BaseDeserializer(NewSubscriptionPriceModel::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): NewSubscriptionPriceModel { + val json = JsonValue.fromJsonNode(node) + val modelType = json.asObject().getOrNull()?.get("model_type")?.asString()?.getOrNull() + + when (modelType) { + "unit" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return NewSubscriptionPriceModel(unitPrice = it, _json = json) + } + } + "package" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return NewSubscriptionPriceModel(packagePrice = it, _json = json) + } + } + "matrix" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return NewSubscriptionPriceModel(matrixPrice = it, _json = json) + } + } + "tiered" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return NewSubscriptionPriceModel(tieredPrice = it, _json = json) + } + } + "tiered_bps" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return NewSubscriptionPriceModel(tieredBpsPrice = it, _json = json) + } + } + "bps" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return NewSubscriptionPriceModel(bpsPrice = it, _json = json) + } + } + "bulk_bps" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return NewSubscriptionPriceModel(bulkBpsPrice = it, _json = json) + } + } + "bulk" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return NewSubscriptionPriceModel(bulkPrice = it, _json = json) + } + } + "threshold_total_amount" -> { + tryDeserialize( + node, + jacksonTypeRef(), + ) { + it.validate() + } + ?.let { + return NewSubscriptionPriceModel( + thresholdTotalAmountPrice = it, + _json = json, + ) + } + } + "tiered_package" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return NewSubscriptionPriceModel(tieredPackagePrice = it, _json = json) + } + } + "tiered_with_minimum" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return NewSubscriptionPriceModel( + tieredWithMinimumPrice = it, + _json = json, + ) + } + } + "unit_with_percent" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return NewSubscriptionPriceModel( + unitWithPercentPrice = it, + _json = json, + ) + } + } + "package_with_allocation" -> { + tryDeserialize( + node, + jacksonTypeRef(), + ) { + it.validate() + } + ?.let { + return NewSubscriptionPriceModel( + packageWithAllocationPrice = it, + _json = json, + ) + } + } + "tiered_with_proration" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return NewSubscriptionPriceModel( + tierWithProrationPrice = it, + _json = json, + ) + } + } + "unit_with_proration" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return NewSubscriptionPriceModel( + unitWithProrationPrice = it, + _json = json, + ) + } + } + "grouped_allocation" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return NewSubscriptionPriceModel( + groupedAllocationPrice = it, + _json = json, + ) + } + } + "grouped_with_prorated_minimum" -> { + tryDeserialize( + node, + jacksonTypeRef(), + ) { + it.validate() + } + ?.let { + return NewSubscriptionPriceModel( + groupedWithProratedMinimumPrice = it, + _json = json, + ) + } + } + "bulk_with_proration" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return NewSubscriptionPriceModel( + bulkWithProrationPrice = it, + _json = json, + ) + } + } + "scalable_matrix_with_unit_pricing" -> { + tryDeserialize( + node, + jacksonTypeRef(), + ) { + it.validate() + } + ?.let { + return NewSubscriptionPriceModel( + scalableMatrixWithUnitPricingPrice = it, + _json = json, + ) + } + } + "scalable_matrix_with_tiered_pricing" -> { + tryDeserialize( + node, + jacksonTypeRef(), + ) { + it.validate() + } + ?.let { + return NewSubscriptionPriceModel( + scalableMatrixWithTieredPricingPrice = it, + _json = json, + ) + } + } + "cumulative_grouped_bulk" -> { + tryDeserialize( + node, + jacksonTypeRef(), + ) { + it.validate() + } + ?.let { + return NewSubscriptionPriceModel( + cumulativeGroupedBulkPrice = it, + _json = json, + ) + } + } + "max_group_tiered_package" -> { + tryDeserialize( + node, + jacksonTypeRef(), + ) { + it.validate() + } + ?.let { + return NewSubscriptionPriceModel( + maxGroupTieredPackagePrice = it, + _json = json, + ) + } + } + "grouped_with_metered_minimum" -> { + tryDeserialize( + node, + jacksonTypeRef(), + ) { + it.validate() + } + ?.let { + return NewSubscriptionPriceModel( + groupedWithMeteredMinimumPrice = it, + _json = json, + ) + } + } + "matrix_with_display_name" -> { + tryDeserialize( + node, + jacksonTypeRef(), + ) { + it.validate() + } + ?.let { + return NewSubscriptionPriceModel( + matrixWithDisplayNamePrice = it, + _json = json, + ) + } + } + "grouped_tiered_package" -> { + tryDeserialize( + node, + jacksonTypeRef(), + ) { + it.validate() + } + ?.let { + return NewSubscriptionPriceModel( + groupedTieredPackagePrice = it, + _json = json, + ) + } + } + } + + return NewSubscriptionPriceModel(_json = json) + } + } + + internal class Serializer : + BaseSerializer(NewSubscriptionPriceModel::class) { + + override fun serialize( + value: NewSubscriptionPriceModel, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unitPrice != null -> generator.writeObject(value.unitPrice) + value.packagePrice != null -> generator.writeObject(value.packagePrice) + value.matrixPrice != null -> generator.writeObject(value.matrixPrice) + value.tieredPrice != null -> generator.writeObject(value.tieredPrice) + value.tieredBpsPrice != null -> generator.writeObject(value.tieredBpsPrice) + value.bpsPrice != null -> generator.writeObject(value.bpsPrice) + value.bulkBpsPrice != null -> generator.writeObject(value.bulkBpsPrice) + value.bulkPrice != null -> generator.writeObject(value.bulkPrice) + value.thresholdTotalAmountPrice != null -> + generator.writeObject(value.thresholdTotalAmountPrice) + value.tieredPackagePrice != null -> generator.writeObject(value.tieredPackagePrice) + value.tieredWithMinimumPrice != null -> + generator.writeObject(value.tieredWithMinimumPrice) + value.unitWithPercentPrice != null -> + generator.writeObject(value.unitWithPercentPrice) + value.packageWithAllocationPrice != null -> + generator.writeObject(value.packageWithAllocationPrice) + value.tierWithProrationPrice != null -> + generator.writeObject(value.tierWithProrationPrice) + value.unitWithProrationPrice != null -> + generator.writeObject(value.unitWithProrationPrice) + value.groupedAllocationPrice != null -> + generator.writeObject(value.groupedAllocationPrice) + value.groupedWithProratedMinimumPrice != null -> + generator.writeObject(value.groupedWithProratedMinimumPrice) + value.bulkWithProrationPrice != null -> + generator.writeObject(value.bulkWithProrationPrice) + value.scalableMatrixWithUnitPricingPrice != null -> + generator.writeObject(value.scalableMatrixWithUnitPricingPrice) + value.scalableMatrixWithTieredPricingPrice != null -> + generator.writeObject(value.scalableMatrixWithTieredPricingPrice) + value.cumulativeGroupedBulkPrice != null -> + generator.writeObject(value.cumulativeGroupedBulkPrice) + value.maxGroupTieredPackagePrice != null -> + generator.writeObject(value.maxGroupTieredPackagePrice) + value.groupedWithMeteredMinimumPrice != null -> + generator.writeObject(value.groupedWithMeteredMinimumPrice) + value.matrixWithDisplayNamePrice != null -> + generator.writeObject(value.matrixWithDisplayNamePrice) + value.groupedTieredPackagePrice != null -> + generator.writeObject(value.groupedTieredPackagePrice) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid NewSubscriptionPriceModel") + } + } + } + + @NoAutoDetect + class NewSubscriptionUnitPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("unit_config") + @ExcludeMissing + private val unitConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun unitConfig(): UnitConfigModel = unitConfig.getRequired("unit_config") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("unit_config") + @ExcludeMissing + fun _unitConfig(): JsonField = unitConfig + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewSubscriptionUnitPrice = apply { + if (validated) { + return@apply + } + + cadence() + itemId() + modelType() + name() + unitConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [NewSubscriptionUnitPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .modelType() + * .name() + * .unitConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewSubscriptionUnitPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var 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 currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(newSubscriptionUnitPrice: NewSubscriptionUnitPrice) = apply { + cadence = newSubscriptionUnitPrice.cadence + itemId = newSubscriptionUnitPrice.itemId + modelType = newSubscriptionUnitPrice.modelType + name = newSubscriptionUnitPrice.name + unitConfig = newSubscriptionUnitPrice.unitConfig + billableMetricId = newSubscriptionUnitPrice.billableMetricId + billedInAdvance = newSubscriptionUnitPrice.billedInAdvance + billingCycleConfiguration = newSubscriptionUnitPrice.billingCycleConfiguration + conversionRate = newSubscriptionUnitPrice.conversionRate + currency = newSubscriptionUnitPrice.currency + externalPriceId = newSubscriptionUnitPrice.externalPriceId + fixedPriceQuantity = newSubscriptionUnitPrice.fixedPriceQuantity + invoiceGroupingKey = newSubscriptionUnitPrice.invoiceGroupingKey + invoicingCycleConfiguration = newSubscriptionUnitPrice.invoicingCycleConfiguration + metadata = newSubscriptionUnitPrice.metadata + referenceId = newSubscriptionUnitPrice.referenceId + additionalProperties = newSubscriptionUnitPrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun unitConfig(unitConfig: UnitConfigModel) = unitConfig(JsonField.of(unitConfig)) + + 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)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * 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. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + 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) + } + + fun build(): NewSubscriptionUnitPrice = + NewSubscriptionUnitPrice( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("unitConfig", unitConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + currency, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewSubscriptionUnitPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && unitConfig == other.unitConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, unitConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewSubscriptionUnitPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewSubscriptionPackagePrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("package_config") + @ExcludeMissing + private val packageConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun packageConfig(): PackageConfigModel = packageConfig.getRequired("package_config") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("package_config") + @ExcludeMissing + fun _packageConfig(): JsonField = packageConfig + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewSubscriptionPackagePrice = apply { + if (validated) { + return@apply + } + + cadence() + itemId() + modelType() + name() + packageConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewSubscriptionPackagePrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .modelType() + * .name() + * .packageConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewSubscriptionPackagePrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var packageConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(newSubscriptionPackagePrice: NewSubscriptionPackagePrice) = apply { + cadence = newSubscriptionPackagePrice.cadence + itemId = newSubscriptionPackagePrice.itemId + modelType = newSubscriptionPackagePrice.modelType + name = newSubscriptionPackagePrice.name + packageConfig = newSubscriptionPackagePrice.packageConfig + billableMetricId = newSubscriptionPackagePrice.billableMetricId + billedInAdvance = newSubscriptionPackagePrice.billedInAdvance + billingCycleConfiguration = newSubscriptionPackagePrice.billingCycleConfiguration + conversionRate = newSubscriptionPackagePrice.conversionRate + currency = newSubscriptionPackagePrice.currency + externalPriceId = newSubscriptionPackagePrice.externalPriceId + fixedPriceQuantity = newSubscriptionPackagePrice.fixedPriceQuantity + invoiceGroupingKey = newSubscriptionPackagePrice.invoiceGroupingKey + invoicingCycleConfiguration = + newSubscriptionPackagePrice.invoicingCycleConfiguration + metadata = newSubscriptionPackagePrice.metadata + referenceId = newSubscriptionPackagePrice.referenceId + additionalProperties = + newSubscriptionPackagePrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun packageConfig(packageConfig: PackageConfigModel) = + packageConfig(JsonField.of(packageConfig)) + + fun packageConfig(packageConfig: JsonField) = apply { + this.packageConfig = packageConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * 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. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + 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) + } + + fun build(): NewSubscriptionPackagePrice = + NewSubscriptionPackagePrice( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("packageConfig", packageConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + currency, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PACKAGE = of("package") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + PACKAGE + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PACKAGE, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PACKAGE -> Value.PACKAGE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PACKAGE -> Known.PACKAGE + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewSubscriptionPackagePrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && packageConfig == other.packageConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, packageConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewSubscriptionPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewSubscriptionMatrixPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("matrix_config") + @ExcludeMissing + private val matrixConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun matrixConfig(): MatrixConfigModel = matrixConfig.getRequired("matrix_config") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("matrix_config") + @ExcludeMissing + fun _matrixConfig(): JsonField = matrixConfig + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewSubscriptionMatrixPrice = apply { + if (validated) { + return@apply + } + + cadence() + itemId() + matrixConfig().validate() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewSubscriptionMatrixPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .matrixConfig() + * .modelType() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewSubscriptionMatrixPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var matrixConfig: JsonField? = null + private var modelType: JsonField? = null + private var 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 currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(newSubscriptionMatrixPrice: NewSubscriptionMatrixPrice) = apply { + cadence = newSubscriptionMatrixPrice.cadence + itemId = newSubscriptionMatrixPrice.itemId + matrixConfig = newSubscriptionMatrixPrice.matrixConfig + modelType = newSubscriptionMatrixPrice.modelType + name = newSubscriptionMatrixPrice.name + billableMetricId = newSubscriptionMatrixPrice.billableMetricId + billedInAdvance = newSubscriptionMatrixPrice.billedInAdvance + billingCycleConfiguration = newSubscriptionMatrixPrice.billingCycleConfiguration + conversionRate = newSubscriptionMatrixPrice.conversionRate + currency = newSubscriptionMatrixPrice.currency + externalPriceId = newSubscriptionMatrixPrice.externalPriceId + fixedPriceQuantity = newSubscriptionMatrixPrice.fixedPriceQuantity + invoiceGroupingKey = newSubscriptionMatrixPrice.invoiceGroupingKey + invoicingCycleConfiguration = newSubscriptionMatrixPrice.invoicingCycleConfiguration + metadata = newSubscriptionMatrixPrice.metadata + referenceId = newSubscriptionMatrixPrice.referenceId + additionalProperties = + newSubscriptionMatrixPrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun matrixConfig(matrixConfig: MatrixConfigModel) = + matrixConfig(JsonField.of(matrixConfig)) + + fun matrixConfig(matrixConfig: JsonField) = apply { + this.matrixConfig = matrixConfig + } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + 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)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * 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. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + 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) + } + + fun build(): NewSubscriptionMatrixPrice = + NewSubscriptionMatrixPrice( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("matrixConfig", matrixConfig), + checkRequired("modelType", modelType), + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + currency, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val MATRIX = of("matrix") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + MATRIX + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MATRIX, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MATRIX -> Value.MATRIX + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MATRIX -> Known.MATRIX + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewSubscriptionMatrixPrice && cadence == other.cadence && itemId == other.itemId && matrixConfig == other.matrixConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, itemId, matrixConfig, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewSubscriptionMatrixPrice{cadence=$cadence, itemId=$itemId, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewSubscriptionTieredPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_config") + @ExcludeMissing + private val tieredConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun tieredConfig(): TieredConfigModel = tieredConfig.getRequired("tiered_config") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("tiered_config") + @ExcludeMissing + fun _tieredConfig(): JsonField = tieredConfig + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewSubscriptionTieredPrice = apply { + if (validated) { + return@apply + } + + cadence() + itemId() + modelType() + name() + tieredConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewSubscriptionTieredPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .modelType() + * .name() + * .tieredConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewSubscriptionTieredPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(newSubscriptionTieredPrice: NewSubscriptionTieredPrice) = apply { + cadence = newSubscriptionTieredPrice.cadence + itemId = newSubscriptionTieredPrice.itemId + modelType = newSubscriptionTieredPrice.modelType + name = newSubscriptionTieredPrice.name + tieredConfig = newSubscriptionTieredPrice.tieredConfig + billableMetricId = newSubscriptionTieredPrice.billableMetricId + billedInAdvance = newSubscriptionTieredPrice.billedInAdvance + billingCycleConfiguration = newSubscriptionTieredPrice.billingCycleConfiguration + conversionRate = newSubscriptionTieredPrice.conversionRate + currency = newSubscriptionTieredPrice.currency + externalPriceId = newSubscriptionTieredPrice.externalPriceId + fixedPriceQuantity = newSubscriptionTieredPrice.fixedPriceQuantity + invoiceGroupingKey = newSubscriptionTieredPrice.invoiceGroupingKey + invoicingCycleConfiguration = newSubscriptionTieredPrice.invoicingCycleConfiguration + metadata = newSubscriptionTieredPrice.metadata + referenceId = newSubscriptionTieredPrice.referenceId + additionalProperties = + newSubscriptionTieredPrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun tieredConfig(tieredConfig: TieredConfigModel) = + tieredConfig(JsonField.of(tieredConfig)) + + fun tieredConfig(tieredConfig: JsonField) = apply { + this.tieredConfig = tieredConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * 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. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + 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) + } + + fun build(): NewSubscriptionTieredPrice = + NewSubscriptionTieredPrice( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("tieredConfig", tieredConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + currency, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TIERED = of("tiered") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + TIERED + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TIERED, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TIERED -> Value.TIERED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TIERED -> Known.TIERED + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewSubscriptionTieredPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredConfig == other.tieredConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewSubscriptionTieredPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewSubscriptionTieredBpsPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_bps_config") + @ExcludeMissing + private val tieredBpsConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun tieredBpsConfig(): TieredBpsConfigModel = + tieredBpsConfig.getRequired("tiered_bps_config") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("tiered_bps_config") + @ExcludeMissing + fun _tieredBpsConfig(): JsonField = tieredBpsConfig + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewSubscriptionTieredBpsPrice = apply { + if (validated) { + return@apply + } + + cadence() + itemId() + modelType() + name() + tieredBpsConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewSubscriptionTieredBpsPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .modelType() + * .name() + * .tieredBpsConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewSubscriptionTieredBpsPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredBpsConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(newSubscriptionTieredBpsPrice: NewSubscriptionTieredBpsPrice) = + apply { + cadence = newSubscriptionTieredBpsPrice.cadence + itemId = newSubscriptionTieredBpsPrice.itemId + modelType = newSubscriptionTieredBpsPrice.modelType + name = newSubscriptionTieredBpsPrice.name + tieredBpsConfig = newSubscriptionTieredBpsPrice.tieredBpsConfig + billableMetricId = newSubscriptionTieredBpsPrice.billableMetricId + billedInAdvance = newSubscriptionTieredBpsPrice.billedInAdvance + billingCycleConfiguration = + newSubscriptionTieredBpsPrice.billingCycleConfiguration + conversionRate = newSubscriptionTieredBpsPrice.conversionRate + currency = newSubscriptionTieredBpsPrice.currency + externalPriceId = newSubscriptionTieredBpsPrice.externalPriceId + fixedPriceQuantity = newSubscriptionTieredBpsPrice.fixedPriceQuantity + invoiceGroupingKey = newSubscriptionTieredBpsPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newSubscriptionTieredBpsPrice.invoicingCycleConfiguration + metadata = newSubscriptionTieredBpsPrice.metadata + referenceId = newSubscriptionTieredBpsPrice.referenceId + additionalProperties = + newSubscriptionTieredBpsPrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun tieredBpsConfig(tieredBpsConfig: TieredBpsConfigModel) = + tieredBpsConfig(JsonField.of(tieredBpsConfig)) + + fun tieredBpsConfig(tieredBpsConfig: JsonField) = apply { + this.tieredBpsConfig = tieredBpsConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * 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. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + 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) + } + + fun build(): NewSubscriptionTieredBpsPrice = + NewSubscriptionTieredBpsPrice( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("tieredBpsConfig", tieredBpsConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + currency, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TIERED_BPS = of("tiered_bps") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + TIERED_BPS + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TIERED_BPS, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TIERED_BPS -> Value.TIERED_BPS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TIERED_BPS -> Known.TIERED_BPS + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewSubscriptionTieredBpsPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredBpsConfig == other.tieredBpsConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredBpsConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewSubscriptionTieredBpsPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredBpsConfig=$tieredBpsConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewSubscriptionBpsPrice + @JsonCreator + private constructor( + @JsonProperty("bps_config") + @ExcludeMissing + private val bpsConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun bpsConfig(): BpsConfigModel = bpsConfig.getRequired("bps_config") + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + @JsonProperty("bps_config") + @ExcludeMissing + fun _bpsConfig(): JsonField = bpsConfig + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewSubscriptionBpsPrice = apply { + if (validated) { + return@apply + } + + bpsConfig().validate() + cadence() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [NewSubscriptionBpsPrice]. + * + * The following fields are required: + * ```java + * .bpsConfig() + * .cadence() + * .itemId() + * .modelType() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewSubscriptionBpsPrice]. */ + class Builder internal constructor() { + + private var bpsConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(newSubscriptionBpsPrice: NewSubscriptionBpsPrice) = apply { + bpsConfig = newSubscriptionBpsPrice.bpsConfig + cadence = newSubscriptionBpsPrice.cadence + itemId = newSubscriptionBpsPrice.itemId + modelType = newSubscriptionBpsPrice.modelType + name = newSubscriptionBpsPrice.name + billableMetricId = newSubscriptionBpsPrice.billableMetricId + billedInAdvance = newSubscriptionBpsPrice.billedInAdvance + billingCycleConfiguration = newSubscriptionBpsPrice.billingCycleConfiguration + conversionRate = newSubscriptionBpsPrice.conversionRate + currency = newSubscriptionBpsPrice.currency + externalPriceId = newSubscriptionBpsPrice.externalPriceId + fixedPriceQuantity = newSubscriptionBpsPrice.fixedPriceQuantity + invoiceGroupingKey = newSubscriptionBpsPrice.invoiceGroupingKey + invoicingCycleConfiguration = newSubscriptionBpsPrice.invoicingCycleConfiguration + metadata = newSubscriptionBpsPrice.metadata + referenceId = newSubscriptionBpsPrice.referenceId + additionalProperties = newSubscriptionBpsPrice.additionalProperties.toMutableMap() + } + + fun bpsConfig(bpsConfig: BpsConfigModel) = bpsConfig(JsonField.of(bpsConfig)) + + fun bpsConfig(bpsConfig: JsonField) = apply { + this.bpsConfig = bpsConfig + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + 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)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * 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. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + 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) + } + + fun build(): NewSubscriptionBpsPrice = + NewSubscriptionBpsPrice( + checkRequired("bpsConfig", bpsConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + currency, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val BPS = of("bps") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + BPS + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + BPS, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + BPS -> Value.BPS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + BPS -> Known.BPS + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewSubscriptionBpsPrice && bpsConfig == other.bpsConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(bpsConfig, cadence, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewSubscriptionBpsPrice{bpsConfig=$bpsConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewSubscriptionBulkBpsPrice + @JsonCreator + private constructor( + @JsonProperty("bulk_bps_config") + @ExcludeMissing + private val bulkBpsConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun bulkBpsConfig(): BulkBpsConfigModel = bulkBpsConfig.getRequired("bulk_bps_config") + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + @JsonProperty("bulk_bps_config") + @ExcludeMissing + fun _bulkBpsConfig(): JsonField = bulkBpsConfig + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewSubscriptionBulkBpsPrice = apply { + if (validated) { + return@apply + } + + bulkBpsConfig().validate() + cadence() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewSubscriptionBulkBpsPrice]. + * + * The following fields are required: + * ```java + * .bulkBpsConfig() + * .cadence() + * .itemId() + * .modelType() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewSubscriptionBulkBpsPrice]. */ + class Builder internal constructor() { + + private var bulkBpsConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(newSubscriptionBulkBpsPrice: NewSubscriptionBulkBpsPrice) = apply { + bulkBpsConfig = newSubscriptionBulkBpsPrice.bulkBpsConfig + cadence = newSubscriptionBulkBpsPrice.cadence + itemId = newSubscriptionBulkBpsPrice.itemId + modelType = newSubscriptionBulkBpsPrice.modelType + name = newSubscriptionBulkBpsPrice.name + billableMetricId = newSubscriptionBulkBpsPrice.billableMetricId + billedInAdvance = newSubscriptionBulkBpsPrice.billedInAdvance + billingCycleConfiguration = newSubscriptionBulkBpsPrice.billingCycleConfiguration + conversionRate = newSubscriptionBulkBpsPrice.conversionRate + currency = newSubscriptionBulkBpsPrice.currency + externalPriceId = newSubscriptionBulkBpsPrice.externalPriceId + fixedPriceQuantity = newSubscriptionBulkBpsPrice.fixedPriceQuantity + invoiceGroupingKey = newSubscriptionBulkBpsPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newSubscriptionBulkBpsPrice.invoicingCycleConfiguration + metadata = newSubscriptionBulkBpsPrice.metadata + referenceId = newSubscriptionBulkBpsPrice.referenceId + additionalProperties = + newSubscriptionBulkBpsPrice.additionalProperties.toMutableMap() + } + + fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfigModel) = + bulkBpsConfig(JsonField.of(bulkBpsConfig)) + + fun bulkBpsConfig(bulkBpsConfig: JsonField) = apply { + this.bulkBpsConfig = bulkBpsConfig + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + 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)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * 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. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + 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) + } + + fun build(): NewSubscriptionBulkBpsPrice = + NewSubscriptionBulkBpsPrice( + checkRequired("bulkBpsConfig", bulkBpsConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + currency, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val BULK_BPS = of("bulk_bps") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + BULK_BPS + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + BULK_BPS, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + BULK_BPS -> Value.BULK_BPS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + BULK_BPS -> Known.BULK_BPS + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewSubscriptionBulkBpsPrice && bulkBpsConfig == other.bulkBpsConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(bulkBpsConfig, cadence, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewSubscriptionBulkBpsPrice{bulkBpsConfig=$bulkBpsConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewSubscriptionBulkPrice + @JsonCreator + private constructor( + @JsonProperty("bulk_config") + @ExcludeMissing + private val bulkConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun bulkConfig(): BulkConfigModel = bulkConfig.getRequired("bulk_config") + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + @JsonProperty("bulk_config") + @ExcludeMissing + fun _bulkConfig(): JsonField = bulkConfig + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewSubscriptionBulkPrice = apply { + if (validated) { + return@apply + } + + bulkConfig().validate() + cadence() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [NewSubscriptionBulkPrice]. + * + * The following fields are required: + * ```java + * .bulkConfig() + * .cadence() + * .itemId() + * .modelType() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewSubscriptionBulkPrice]. */ + class Builder internal constructor() { + + private var bulkConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var 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 currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(newSubscriptionBulkPrice: NewSubscriptionBulkPrice) = apply { + bulkConfig = newSubscriptionBulkPrice.bulkConfig + cadence = newSubscriptionBulkPrice.cadence + itemId = newSubscriptionBulkPrice.itemId + modelType = newSubscriptionBulkPrice.modelType + name = newSubscriptionBulkPrice.name + billableMetricId = newSubscriptionBulkPrice.billableMetricId + billedInAdvance = newSubscriptionBulkPrice.billedInAdvance + billingCycleConfiguration = newSubscriptionBulkPrice.billingCycleConfiguration + conversionRate = newSubscriptionBulkPrice.conversionRate + currency = newSubscriptionBulkPrice.currency + externalPriceId = newSubscriptionBulkPrice.externalPriceId + fixedPriceQuantity = newSubscriptionBulkPrice.fixedPriceQuantity + invoiceGroupingKey = newSubscriptionBulkPrice.invoiceGroupingKey + invoicingCycleConfiguration = newSubscriptionBulkPrice.invoicingCycleConfiguration + metadata = newSubscriptionBulkPrice.metadata + referenceId = newSubscriptionBulkPrice.referenceId + additionalProperties = newSubscriptionBulkPrice.additionalProperties.toMutableMap() + } + + fun bulkConfig(bulkConfig: BulkConfigModel) = bulkConfig(JsonField.of(bulkConfig)) + + fun bulkConfig(bulkConfig: JsonField) = apply { + this.bulkConfig = bulkConfig + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + 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)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * 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. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + 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) + } + + fun build(): NewSubscriptionBulkPrice = + NewSubscriptionBulkPrice( + checkRequired("bulkConfig", bulkConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + currency, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val BULK = of("bulk") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + BULK + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + BULK, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + BULK -> Value.BULK + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + BULK -> Known.BULK + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewSubscriptionBulkPrice && bulkConfig == other.bulkConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(bulkConfig, cadence, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewSubscriptionBulkPrice{bulkConfig=$bulkConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewSubscriptionThresholdTotalAmountPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("threshold_total_amount_config") + @ExcludeMissing + private val thresholdTotalAmountConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun thresholdTotalAmountConfig(): CustomRatingFunctionConfigModel = + thresholdTotalAmountConfig.getRequired("threshold_total_amount_config") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("threshold_total_amount_config") + @ExcludeMissing + fun _thresholdTotalAmountConfig(): JsonField = + thresholdTotalAmountConfig + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewSubscriptionThresholdTotalAmountPrice = apply { + if (validated) { + return@apply + } + + cadence() + itemId() + modelType() + name() + thresholdTotalAmountConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewSubscriptionThresholdTotalAmountPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .modelType() + * .name() + * .thresholdTotalAmountConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewSubscriptionThresholdTotalAmountPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var thresholdTotalAmountConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + newSubscriptionThresholdTotalAmountPrice: NewSubscriptionThresholdTotalAmountPrice + ) = apply { + cadence = newSubscriptionThresholdTotalAmountPrice.cadence + itemId = newSubscriptionThresholdTotalAmountPrice.itemId + modelType = newSubscriptionThresholdTotalAmountPrice.modelType + name = newSubscriptionThresholdTotalAmountPrice.name + thresholdTotalAmountConfig = + newSubscriptionThresholdTotalAmountPrice.thresholdTotalAmountConfig + billableMetricId = newSubscriptionThresholdTotalAmountPrice.billableMetricId + billedInAdvance = newSubscriptionThresholdTotalAmountPrice.billedInAdvance + billingCycleConfiguration = + newSubscriptionThresholdTotalAmountPrice.billingCycleConfiguration + conversionRate = newSubscriptionThresholdTotalAmountPrice.conversionRate + currency = newSubscriptionThresholdTotalAmountPrice.currency + externalPriceId = newSubscriptionThresholdTotalAmountPrice.externalPriceId + fixedPriceQuantity = newSubscriptionThresholdTotalAmountPrice.fixedPriceQuantity + invoiceGroupingKey = newSubscriptionThresholdTotalAmountPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newSubscriptionThresholdTotalAmountPrice.invoicingCycleConfiguration + metadata = newSubscriptionThresholdTotalAmountPrice.metadata + referenceId = newSubscriptionThresholdTotalAmountPrice.referenceId + additionalProperties = + newSubscriptionThresholdTotalAmountPrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun thresholdTotalAmountConfig( + thresholdTotalAmountConfig: CustomRatingFunctionConfigModel + ) = thresholdTotalAmountConfig(JsonField.of(thresholdTotalAmountConfig)) + + fun thresholdTotalAmountConfig( + thresholdTotalAmountConfig: JsonField + ) = apply { this.thresholdTotalAmountConfig = thresholdTotalAmountConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * 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. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + 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) + } + + fun build(): NewSubscriptionThresholdTotalAmountPrice = + NewSubscriptionThresholdTotalAmountPrice( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("thresholdTotalAmountConfig", thresholdTotalAmountConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + currency, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val THRESHOLD_TOTAL_AMOUNT = of("threshold_total_amount") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + THRESHOLD_TOTAL_AMOUNT + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + THRESHOLD_TOTAL_AMOUNT, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + THRESHOLD_TOTAL_AMOUNT -> Value.THRESHOLD_TOTAL_AMOUNT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + THRESHOLD_TOTAL_AMOUNT -> Known.THRESHOLD_TOTAL_AMOUNT + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewSubscriptionThresholdTotalAmountPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, thresholdTotalAmountConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewSubscriptionThresholdTotalAmountPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewSubscriptionTieredPackagePrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_package_config") + @ExcludeMissing + private val tieredPackageConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun tieredPackageConfig(): CustomRatingFunctionConfigModel = + tieredPackageConfig.getRequired("tiered_package_config") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("tiered_package_config") + @ExcludeMissing + fun _tieredPackageConfig(): JsonField = tieredPackageConfig + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewSubscriptionTieredPackagePrice = apply { + if (validated) { + return@apply + } + + cadence() + itemId() + modelType() + name() + tieredPackageConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewSubscriptionTieredPackagePrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .modelType() + * .name() + * .tieredPackageConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewSubscriptionTieredPackagePrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredPackageConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + newSubscriptionTieredPackagePrice: NewSubscriptionTieredPackagePrice + ) = apply { + cadence = newSubscriptionTieredPackagePrice.cadence + itemId = newSubscriptionTieredPackagePrice.itemId + modelType = newSubscriptionTieredPackagePrice.modelType + name = newSubscriptionTieredPackagePrice.name + tieredPackageConfig = newSubscriptionTieredPackagePrice.tieredPackageConfig + billableMetricId = newSubscriptionTieredPackagePrice.billableMetricId + billedInAdvance = newSubscriptionTieredPackagePrice.billedInAdvance + billingCycleConfiguration = + newSubscriptionTieredPackagePrice.billingCycleConfiguration + conversionRate = newSubscriptionTieredPackagePrice.conversionRate + currency = newSubscriptionTieredPackagePrice.currency + externalPriceId = newSubscriptionTieredPackagePrice.externalPriceId + fixedPriceQuantity = newSubscriptionTieredPackagePrice.fixedPriceQuantity + invoiceGroupingKey = newSubscriptionTieredPackagePrice.invoiceGroupingKey + invoicingCycleConfiguration = + newSubscriptionTieredPackagePrice.invoicingCycleConfiguration + metadata = newSubscriptionTieredPackagePrice.metadata + referenceId = newSubscriptionTieredPackagePrice.referenceId + additionalProperties = + newSubscriptionTieredPackagePrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun tieredPackageConfig(tieredPackageConfig: CustomRatingFunctionConfigModel) = + tieredPackageConfig(JsonField.of(tieredPackageConfig)) + + fun tieredPackageConfig( + tieredPackageConfig: JsonField + ) = apply { this.tieredPackageConfig = tieredPackageConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * 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. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + 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) + } + + fun build(): NewSubscriptionTieredPackagePrice = + NewSubscriptionTieredPackagePrice( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("tieredPackageConfig", tieredPackageConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + currency, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TIERED_PACKAGE = of("tiered_package") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + TIERED_PACKAGE + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TIERED_PACKAGE, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TIERED_PACKAGE -> Value.TIERED_PACKAGE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TIERED_PACKAGE -> Known.TIERED_PACKAGE + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewSubscriptionTieredPackagePrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredPackageConfig == other.tieredPackageConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredPackageConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewSubscriptionTieredPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewSubscriptionTieredWithMinimumPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_minimum_config") + @ExcludeMissing + private val tieredWithMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun tieredWithMinimumConfig(): CustomRatingFunctionConfigModel = + tieredWithMinimumConfig.getRequired("tiered_with_minimum_config") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("tiered_with_minimum_config") + @ExcludeMissing + fun _tieredWithMinimumConfig(): JsonField = + tieredWithMinimumConfig + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewSubscriptionTieredWithMinimumPrice = apply { + if (validated) { + return@apply + } + + cadence() + itemId() + modelType() + name() + tieredWithMinimumConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewSubscriptionTieredWithMinimumPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .modelType() + * .name() + * .tieredWithMinimumConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewSubscriptionTieredWithMinimumPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredWithMinimumConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + newSubscriptionTieredWithMinimumPrice: NewSubscriptionTieredWithMinimumPrice + ) = apply { + cadence = newSubscriptionTieredWithMinimumPrice.cadence + itemId = newSubscriptionTieredWithMinimumPrice.itemId + modelType = newSubscriptionTieredWithMinimumPrice.modelType + name = newSubscriptionTieredWithMinimumPrice.name + tieredWithMinimumConfig = + newSubscriptionTieredWithMinimumPrice.tieredWithMinimumConfig + billableMetricId = newSubscriptionTieredWithMinimumPrice.billableMetricId + billedInAdvance = newSubscriptionTieredWithMinimumPrice.billedInAdvance + billingCycleConfiguration = + newSubscriptionTieredWithMinimumPrice.billingCycleConfiguration + conversionRate = newSubscriptionTieredWithMinimumPrice.conversionRate + currency = newSubscriptionTieredWithMinimumPrice.currency + externalPriceId = newSubscriptionTieredWithMinimumPrice.externalPriceId + fixedPriceQuantity = newSubscriptionTieredWithMinimumPrice.fixedPriceQuantity + invoiceGroupingKey = newSubscriptionTieredWithMinimumPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newSubscriptionTieredWithMinimumPrice.invoicingCycleConfiguration + metadata = newSubscriptionTieredWithMinimumPrice.metadata + referenceId = newSubscriptionTieredWithMinimumPrice.referenceId + additionalProperties = + newSubscriptionTieredWithMinimumPrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun tieredWithMinimumConfig(tieredWithMinimumConfig: CustomRatingFunctionConfigModel) = + tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) + + fun tieredWithMinimumConfig( + tieredWithMinimumConfig: JsonField + ) = apply { this.tieredWithMinimumConfig = tieredWithMinimumConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * 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. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + 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) + } + + fun build(): NewSubscriptionTieredWithMinimumPrice = + NewSubscriptionTieredWithMinimumPrice( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("tieredWithMinimumConfig", tieredWithMinimumConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + currency, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TIERED_WITH_MINIMUM = of("tiered_with_minimum") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + TIERED_WITH_MINIMUM + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TIERED_WITH_MINIMUM, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TIERED_WITH_MINIMUM -> Value.TIERED_WITH_MINIMUM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TIERED_WITH_MINIMUM -> Known.TIERED_WITH_MINIMUM + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewSubscriptionTieredWithMinimumPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredWithMinimumConfig == other.tieredWithMinimumConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredWithMinimumConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewSubscriptionTieredWithMinimumPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewSubscriptionUnitWithPercentPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("unit_with_percent_config") + @ExcludeMissing + private val unitWithPercentConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun unitWithPercentConfig(): CustomRatingFunctionConfigModel = + unitWithPercentConfig.getRequired("unit_with_percent_config") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("unit_with_percent_config") + @ExcludeMissing + fun _unitWithPercentConfig(): JsonField = + unitWithPercentConfig + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewSubscriptionUnitWithPercentPrice = apply { + if (validated) { + return@apply + } + + cadence() + itemId() + modelType() + name() + unitWithPercentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewSubscriptionUnitWithPercentPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .modelType() + * .name() + * .unitWithPercentConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewSubscriptionUnitWithPercentPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var unitWithPercentConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + newSubscriptionUnitWithPercentPrice: NewSubscriptionUnitWithPercentPrice + ) = apply { + cadence = newSubscriptionUnitWithPercentPrice.cadence + itemId = newSubscriptionUnitWithPercentPrice.itemId + modelType = newSubscriptionUnitWithPercentPrice.modelType + name = newSubscriptionUnitWithPercentPrice.name + unitWithPercentConfig = newSubscriptionUnitWithPercentPrice.unitWithPercentConfig + billableMetricId = newSubscriptionUnitWithPercentPrice.billableMetricId + billedInAdvance = newSubscriptionUnitWithPercentPrice.billedInAdvance + billingCycleConfiguration = + newSubscriptionUnitWithPercentPrice.billingCycleConfiguration + conversionRate = newSubscriptionUnitWithPercentPrice.conversionRate + currency = newSubscriptionUnitWithPercentPrice.currency + externalPriceId = newSubscriptionUnitWithPercentPrice.externalPriceId + fixedPriceQuantity = newSubscriptionUnitWithPercentPrice.fixedPriceQuantity + invoiceGroupingKey = newSubscriptionUnitWithPercentPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newSubscriptionUnitWithPercentPrice.invoicingCycleConfiguration + metadata = newSubscriptionUnitWithPercentPrice.metadata + referenceId = newSubscriptionUnitWithPercentPrice.referenceId + additionalProperties = + newSubscriptionUnitWithPercentPrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun unitWithPercentConfig(unitWithPercentConfig: CustomRatingFunctionConfigModel) = + unitWithPercentConfig(JsonField.of(unitWithPercentConfig)) + + fun unitWithPercentConfig( + unitWithPercentConfig: JsonField + ) = apply { this.unitWithPercentConfig = unitWithPercentConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * 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. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + 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) + } + + fun build(): NewSubscriptionUnitWithPercentPrice = + NewSubscriptionUnitWithPercentPrice( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("unitWithPercentConfig", unitWithPercentConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + currency, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val UNIT_WITH_PERCENT = of("unit_with_percent") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + UNIT_WITH_PERCENT + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + UNIT_WITH_PERCENT, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + UNIT_WITH_PERCENT -> Value.UNIT_WITH_PERCENT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + UNIT_WITH_PERCENT -> Known.UNIT_WITH_PERCENT + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewSubscriptionUnitWithPercentPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && unitWithPercentConfig == other.unitWithPercentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, unitWithPercentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewSubscriptionUnitWithPercentPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewSubscriptionPackageWithAllocationPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("package_with_allocation_config") + @ExcludeMissing + private val packageWithAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun packageWithAllocationConfig(): CustomRatingFunctionConfigModel = + packageWithAllocationConfig.getRequired("package_with_allocation_config") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("package_with_allocation_config") + @ExcludeMissing + fun _packageWithAllocationConfig(): JsonField = + packageWithAllocationConfig + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewSubscriptionPackageWithAllocationPrice = apply { + if (validated) { + return@apply + } + + cadence() + itemId() + modelType() + name() + packageWithAllocationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewSubscriptionPackageWithAllocationPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .modelType() + * .name() + * .packageWithAllocationConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewSubscriptionPackageWithAllocationPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var packageWithAllocationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + newSubscriptionPackageWithAllocationPrice: NewSubscriptionPackageWithAllocationPrice + ) = apply { + cadence = newSubscriptionPackageWithAllocationPrice.cadence + itemId = newSubscriptionPackageWithAllocationPrice.itemId + modelType = newSubscriptionPackageWithAllocationPrice.modelType + name = newSubscriptionPackageWithAllocationPrice.name + packageWithAllocationConfig = + newSubscriptionPackageWithAllocationPrice.packageWithAllocationConfig + billableMetricId = newSubscriptionPackageWithAllocationPrice.billableMetricId + billedInAdvance = newSubscriptionPackageWithAllocationPrice.billedInAdvance + billingCycleConfiguration = + newSubscriptionPackageWithAllocationPrice.billingCycleConfiguration + conversionRate = newSubscriptionPackageWithAllocationPrice.conversionRate + currency = newSubscriptionPackageWithAllocationPrice.currency + externalPriceId = newSubscriptionPackageWithAllocationPrice.externalPriceId + fixedPriceQuantity = newSubscriptionPackageWithAllocationPrice.fixedPriceQuantity + invoiceGroupingKey = newSubscriptionPackageWithAllocationPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newSubscriptionPackageWithAllocationPrice.invoicingCycleConfiguration + metadata = newSubscriptionPackageWithAllocationPrice.metadata + referenceId = newSubscriptionPackageWithAllocationPrice.referenceId + additionalProperties = + newSubscriptionPackageWithAllocationPrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun packageWithAllocationConfig( + packageWithAllocationConfig: CustomRatingFunctionConfigModel + ) = packageWithAllocationConfig(JsonField.of(packageWithAllocationConfig)) + + fun packageWithAllocationConfig( + packageWithAllocationConfig: JsonField + ) = apply { this.packageWithAllocationConfig = packageWithAllocationConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * 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. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + 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) + } + + fun build(): NewSubscriptionPackageWithAllocationPrice = + NewSubscriptionPackageWithAllocationPrice( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("packageWithAllocationConfig", packageWithAllocationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + currency, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PACKAGE_WITH_ALLOCATION = of("package_with_allocation") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + PACKAGE_WITH_ALLOCATION + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PACKAGE_WITH_ALLOCATION, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PACKAGE_WITH_ALLOCATION -> Value.PACKAGE_WITH_ALLOCATION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PACKAGE_WITH_ALLOCATION -> Known.PACKAGE_WITH_ALLOCATION + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewSubscriptionPackageWithAllocationPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && packageWithAllocationConfig == other.packageWithAllocationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, packageWithAllocationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewSubscriptionPackageWithAllocationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewSubscriptionTierWithProrationPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + private val tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun tieredWithProrationConfig(): CustomRatingFunctionConfigModel = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewSubscriptionTierWithProrationPrice = apply { + if (validated) { + return@apply + } + + cadence() + itemId() + modelType() + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewSubscriptionTierWithProrationPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .modelType() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewSubscriptionTierWithProrationPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + newSubscriptionTierWithProrationPrice: NewSubscriptionTierWithProrationPrice + ) = apply { + cadence = newSubscriptionTierWithProrationPrice.cadence + itemId = newSubscriptionTierWithProrationPrice.itemId + modelType = newSubscriptionTierWithProrationPrice.modelType + name = newSubscriptionTierWithProrationPrice.name + tieredWithProrationConfig = + newSubscriptionTierWithProrationPrice.tieredWithProrationConfig + billableMetricId = newSubscriptionTierWithProrationPrice.billableMetricId + billedInAdvance = newSubscriptionTierWithProrationPrice.billedInAdvance + billingCycleConfiguration = + newSubscriptionTierWithProrationPrice.billingCycleConfiguration + conversionRate = newSubscriptionTierWithProrationPrice.conversionRate + currency = newSubscriptionTierWithProrationPrice.currency + externalPriceId = newSubscriptionTierWithProrationPrice.externalPriceId + fixedPriceQuantity = newSubscriptionTierWithProrationPrice.fixedPriceQuantity + invoiceGroupingKey = newSubscriptionTierWithProrationPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newSubscriptionTierWithProrationPrice.invoicingCycleConfiguration + metadata = newSubscriptionTierWithProrationPrice.metadata + referenceId = newSubscriptionTierWithProrationPrice.referenceId + additionalProperties = + newSubscriptionTierWithProrationPrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun tieredWithProrationConfig( + tieredWithProrationConfig: CustomRatingFunctionConfigModel + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + 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)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * 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. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + 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) + } + + fun build(): NewSubscriptionTierWithProrationPrice = + NewSubscriptionTierWithProrationPrice( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + currency, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TIERED_WITH_PRORATION = of("tiered_with_proration") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + TIERED_WITH_PRORATION + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TIERED_WITH_PRORATION, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TIERED_WITH_PRORATION -> Value.TIERED_WITH_PRORATION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TIERED_WITH_PRORATION -> Known.TIERED_WITH_PRORATION + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewSubscriptionTierWithProrationPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewSubscriptionTierWithProrationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewSubscriptionUnitWithProrationPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("unit_with_proration_config") + @ExcludeMissing + private val unitWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun unitWithProrationConfig(): CustomRatingFunctionConfigModel = + unitWithProrationConfig.getRequired("unit_with_proration_config") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("unit_with_proration_config") + @ExcludeMissing + fun _unitWithProrationConfig(): JsonField = + unitWithProrationConfig + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewSubscriptionUnitWithProrationPrice = apply { + if (validated) { + return@apply + } + + cadence() + itemId() + modelType() + name() + unitWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewSubscriptionUnitWithProrationPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .modelType() + * .name() + * .unitWithProrationConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewSubscriptionUnitWithProrationPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var unitWithProrationConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + newSubscriptionUnitWithProrationPrice: NewSubscriptionUnitWithProrationPrice + ) = apply { + cadence = newSubscriptionUnitWithProrationPrice.cadence + itemId = newSubscriptionUnitWithProrationPrice.itemId + modelType = newSubscriptionUnitWithProrationPrice.modelType + name = newSubscriptionUnitWithProrationPrice.name + unitWithProrationConfig = + newSubscriptionUnitWithProrationPrice.unitWithProrationConfig + billableMetricId = newSubscriptionUnitWithProrationPrice.billableMetricId + billedInAdvance = newSubscriptionUnitWithProrationPrice.billedInAdvance + billingCycleConfiguration = + newSubscriptionUnitWithProrationPrice.billingCycleConfiguration + conversionRate = newSubscriptionUnitWithProrationPrice.conversionRate + currency = newSubscriptionUnitWithProrationPrice.currency + externalPriceId = newSubscriptionUnitWithProrationPrice.externalPriceId + fixedPriceQuantity = newSubscriptionUnitWithProrationPrice.fixedPriceQuantity + invoiceGroupingKey = newSubscriptionUnitWithProrationPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newSubscriptionUnitWithProrationPrice.invoicingCycleConfiguration + metadata = newSubscriptionUnitWithProrationPrice.metadata + referenceId = newSubscriptionUnitWithProrationPrice.referenceId + additionalProperties = + newSubscriptionUnitWithProrationPrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun unitWithProrationConfig(unitWithProrationConfig: CustomRatingFunctionConfigModel) = + unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) + + fun unitWithProrationConfig( + unitWithProrationConfig: JsonField + ) = apply { this.unitWithProrationConfig = unitWithProrationConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * 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. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + 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) + } + + fun build(): NewSubscriptionUnitWithProrationPrice = + NewSubscriptionUnitWithProrationPrice( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("unitWithProrationConfig", unitWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + currency, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val UNIT_WITH_PRORATION = of("unit_with_proration") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + UNIT_WITH_PRORATION + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + UNIT_WITH_PRORATION, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + UNIT_WITH_PRORATION -> Value.UNIT_WITH_PRORATION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + UNIT_WITH_PRORATION -> Known.UNIT_WITH_PRORATION + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewSubscriptionUnitWithProrationPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && unitWithProrationConfig == other.unitWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, unitWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewSubscriptionUnitWithProrationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewSubscriptionGroupedAllocationPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_allocation_config") + @ExcludeMissing + private val groupedAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun groupedAllocationConfig(): CustomRatingFunctionConfigModel = + groupedAllocationConfig.getRequired("grouped_allocation_config") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + @JsonProperty("grouped_allocation_config") + @ExcludeMissing + fun _groupedAllocationConfig(): JsonField = + groupedAllocationConfig + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewSubscriptionGroupedAllocationPrice = apply { + if (validated) { + return@apply + } + + cadence() + groupedAllocationConfig().validate() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewSubscriptionGroupedAllocationPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedAllocationConfig() + * .itemId() + * .modelType() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewSubscriptionGroupedAllocationPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedAllocationConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var 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 currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + newSubscriptionGroupedAllocationPrice: NewSubscriptionGroupedAllocationPrice + ) = apply { + cadence = newSubscriptionGroupedAllocationPrice.cadence + groupedAllocationConfig = + newSubscriptionGroupedAllocationPrice.groupedAllocationConfig + itemId = newSubscriptionGroupedAllocationPrice.itemId + modelType = newSubscriptionGroupedAllocationPrice.modelType + name = newSubscriptionGroupedAllocationPrice.name + billableMetricId = newSubscriptionGroupedAllocationPrice.billableMetricId + billedInAdvance = newSubscriptionGroupedAllocationPrice.billedInAdvance + billingCycleConfiguration = + newSubscriptionGroupedAllocationPrice.billingCycleConfiguration + conversionRate = newSubscriptionGroupedAllocationPrice.conversionRate + currency = newSubscriptionGroupedAllocationPrice.currency + externalPriceId = newSubscriptionGroupedAllocationPrice.externalPriceId + fixedPriceQuantity = newSubscriptionGroupedAllocationPrice.fixedPriceQuantity + invoiceGroupingKey = newSubscriptionGroupedAllocationPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newSubscriptionGroupedAllocationPrice.invoicingCycleConfiguration + metadata = newSubscriptionGroupedAllocationPrice.metadata + referenceId = newSubscriptionGroupedAllocationPrice.referenceId + additionalProperties = + newSubscriptionGroupedAllocationPrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun groupedAllocationConfig(groupedAllocationConfig: CustomRatingFunctionConfigModel) = + groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) + + fun groupedAllocationConfig( + groupedAllocationConfig: JsonField + ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + 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)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * 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. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + 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) + } + + fun build(): NewSubscriptionGroupedAllocationPrice = + NewSubscriptionGroupedAllocationPrice( + checkRequired("cadence", cadence), + checkRequired("groupedAllocationConfig", groupedAllocationConfig), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + currency, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val GROUPED_ALLOCATION = of("grouped_allocation") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + GROUPED_ALLOCATION + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GROUPED_ALLOCATION, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GROUPED_ALLOCATION -> Value.GROUPED_ALLOCATION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + GROUPED_ALLOCATION -> Known.GROUPED_ALLOCATION + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewSubscriptionGroupedAllocationPrice && cadence == other.cadence && groupedAllocationConfig == other.groupedAllocationConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, groupedAllocationConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewSubscriptionGroupedAllocationPrice{cadence=$cadence, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewSubscriptionGroupedWithProratedMinimumPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_prorated_minimum_config") + @ExcludeMissing + private val groupedWithProratedMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun groupedWithProratedMinimumConfig(): CustomRatingFunctionConfigModel = + groupedWithProratedMinimumConfig.getRequired("grouped_with_prorated_minimum_config") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + @JsonProperty("grouped_with_prorated_minimum_config") + @ExcludeMissing + fun _groupedWithProratedMinimumConfig(): JsonField = + groupedWithProratedMinimumConfig + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewSubscriptionGroupedWithProratedMinimumPrice = apply { + if (validated) { + return@apply + } + + cadence() + groupedWithProratedMinimumConfig().validate() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewSubscriptionGroupedWithProratedMinimumPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithProratedMinimumConfig() + * .itemId() + * .modelType() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewSubscriptionGroupedWithProratedMinimumPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithProratedMinimumConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + newSubscriptionGroupedWithProratedMinimumPrice: + NewSubscriptionGroupedWithProratedMinimumPrice + ) = apply { + cadence = newSubscriptionGroupedWithProratedMinimumPrice.cadence + groupedWithProratedMinimumConfig = + newSubscriptionGroupedWithProratedMinimumPrice.groupedWithProratedMinimumConfig + itemId = newSubscriptionGroupedWithProratedMinimumPrice.itemId + modelType = newSubscriptionGroupedWithProratedMinimumPrice.modelType + name = newSubscriptionGroupedWithProratedMinimumPrice.name + billableMetricId = newSubscriptionGroupedWithProratedMinimumPrice.billableMetricId + billedInAdvance = newSubscriptionGroupedWithProratedMinimumPrice.billedInAdvance + billingCycleConfiguration = + newSubscriptionGroupedWithProratedMinimumPrice.billingCycleConfiguration + conversionRate = newSubscriptionGroupedWithProratedMinimumPrice.conversionRate + currency = newSubscriptionGroupedWithProratedMinimumPrice.currency + externalPriceId = newSubscriptionGroupedWithProratedMinimumPrice.externalPriceId + fixedPriceQuantity = + newSubscriptionGroupedWithProratedMinimumPrice.fixedPriceQuantity + invoiceGroupingKey = + newSubscriptionGroupedWithProratedMinimumPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newSubscriptionGroupedWithProratedMinimumPrice.invoicingCycleConfiguration + metadata = newSubscriptionGroupedWithProratedMinimumPrice.metadata + referenceId = newSubscriptionGroupedWithProratedMinimumPrice.referenceId + additionalProperties = + newSubscriptionGroupedWithProratedMinimumPrice.additionalProperties + .toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: CustomRatingFunctionConfigModel + ) = groupedWithProratedMinimumConfig(JsonField.of(groupedWithProratedMinimumConfig)) + + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: JsonField + ) = apply { this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + 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)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * 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. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + 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) + } + + fun build(): NewSubscriptionGroupedWithProratedMinimumPrice = + NewSubscriptionGroupedWithProratedMinimumPrice( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithProratedMinimumConfig", + groupedWithProratedMinimumConfig, + ), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + currency, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val GROUPED_WITH_PRORATED_MINIMUM = of("grouped_with_prorated_minimum") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + GROUPED_WITH_PRORATED_MINIMUM + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GROUPED_WITH_PRORATED_MINIMUM, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GROUPED_WITH_PRORATED_MINIMUM -> Value.GROUPED_WITH_PRORATED_MINIMUM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + GROUPED_WITH_PRORATED_MINIMUM -> Known.GROUPED_WITH_PRORATED_MINIMUM + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewSubscriptionGroupedWithProratedMinimumPrice && cadence == other.cadence && groupedWithProratedMinimumConfig == other.groupedWithProratedMinimumConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, groupedWithProratedMinimumConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewSubscriptionGroupedWithProratedMinimumPrice{cadence=$cadence, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewSubscriptionBulkWithProrationPrice + @JsonCreator + private constructor( + @JsonProperty("bulk_with_proration_config") + @ExcludeMissing + private val bulkWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun bulkWithProrationConfig(): CustomRatingFunctionConfigModel = + bulkWithProrationConfig.getRequired("bulk_with_proration_config") + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + @JsonProperty("bulk_with_proration_config") + @ExcludeMissing + fun _bulkWithProrationConfig(): JsonField = + bulkWithProrationConfig + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewSubscriptionBulkWithProrationPrice = apply { + if (validated) { + return@apply + } + + bulkWithProrationConfig().validate() + cadence() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewSubscriptionBulkWithProrationPrice]. + * + * The following fields are required: + * ```java + * .bulkWithProrationConfig() + * .cadence() + * .itemId() + * .modelType() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewSubscriptionBulkWithProrationPrice]. */ + class Builder internal constructor() { + + private var bulkWithProrationConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var 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 currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + newSubscriptionBulkWithProrationPrice: NewSubscriptionBulkWithProrationPrice + ) = apply { + bulkWithProrationConfig = + newSubscriptionBulkWithProrationPrice.bulkWithProrationConfig + cadence = newSubscriptionBulkWithProrationPrice.cadence + itemId = newSubscriptionBulkWithProrationPrice.itemId + modelType = newSubscriptionBulkWithProrationPrice.modelType + name = newSubscriptionBulkWithProrationPrice.name + billableMetricId = newSubscriptionBulkWithProrationPrice.billableMetricId + billedInAdvance = newSubscriptionBulkWithProrationPrice.billedInAdvance + billingCycleConfiguration = + newSubscriptionBulkWithProrationPrice.billingCycleConfiguration + conversionRate = newSubscriptionBulkWithProrationPrice.conversionRate + currency = newSubscriptionBulkWithProrationPrice.currency + externalPriceId = newSubscriptionBulkWithProrationPrice.externalPriceId + fixedPriceQuantity = newSubscriptionBulkWithProrationPrice.fixedPriceQuantity + invoiceGroupingKey = newSubscriptionBulkWithProrationPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newSubscriptionBulkWithProrationPrice.invoicingCycleConfiguration + metadata = newSubscriptionBulkWithProrationPrice.metadata + referenceId = newSubscriptionBulkWithProrationPrice.referenceId + additionalProperties = + newSubscriptionBulkWithProrationPrice.additionalProperties.toMutableMap() + } + + fun bulkWithProrationConfig(bulkWithProrationConfig: CustomRatingFunctionConfigModel) = + bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) + + fun bulkWithProrationConfig( + bulkWithProrationConfig: JsonField + ) = apply { this.bulkWithProrationConfig = bulkWithProrationConfig } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + 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)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * 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. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + 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) + } + + fun build(): NewSubscriptionBulkWithProrationPrice = + NewSubscriptionBulkWithProrationPrice( + checkRequired("bulkWithProrationConfig", bulkWithProrationConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + currency, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val BULK_WITH_PRORATION = of("bulk_with_proration") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + BULK_WITH_PRORATION + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + BULK_WITH_PRORATION, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + BULK_WITH_PRORATION -> Value.BULK_WITH_PRORATION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + BULK_WITH_PRORATION -> Known.BULK_WITH_PRORATION + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewSubscriptionBulkWithProrationPrice && bulkWithProrationConfig == other.bulkWithProrationConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(bulkWithProrationConfig, cadence, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewSubscriptionBulkWithProrationPrice{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewSubscriptionScalableMatrixWithUnitPricingPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("scalable_matrix_with_unit_pricing_config") + @ExcludeMissing + private val scalableMatrixWithUnitPricingConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun scalableMatrixWithUnitPricingConfig(): CustomRatingFunctionConfigModel = + scalableMatrixWithUnitPricingConfig.getRequired( + "scalable_matrix_with_unit_pricing_config" + ) + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("scalable_matrix_with_unit_pricing_config") + @ExcludeMissing + fun _scalableMatrixWithUnitPricingConfig(): JsonField = + scalableMatrixWithUnitPricingConfig + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewSubscriptionScalableMatrixWithUnitPricingPrice = apply { + if (validated) { + return@apply + } + + cadence() + itemId() + modelType() + name() + scalableMatrixWithUnitPricingConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewSubscriptionScalableMatrixWithUnitPricingPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .modelType() + * .name() + * .scalableMatrixWithUnitPricingConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewSubscriptionScalableMatrixWithUnitPricingPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var scalableMatrixWithUnitPricingConfig: + JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + newSubscriptionScalableMatrixWithUnitPricingPrice: + NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = apply { + cadence = newSubscriptionScalableMatrixWithUnitPricingPrice.cadence + itemId = newSubscriptionScalableMatrixWithUnitPricingPrice.itemId + modelType = newSubscriptionScalableMatrixWithUnitPricingPrice.modelType + name = newSubscriptionScalableMatrixWithUnitPricingPrice.name + scalableMatrixWithUnitPricingConfig = + newSubscriptionScalableMatrixWithUnitPricingPrice + .scalableMatrixWithUnitPricingConfig + billableMetricId = + newSubscriptionScalableMatrixWithUnitPricingPrice.billableMetricId + billedInAdvance = newSubscriptionScalableMatrixWithUnitPricingPrice.billedInAdvance + billingCycleConfiguration = + newSubscriptionScalableMatrixWithUnitPricingPrice.billingCycleConfiguration + conversionRate = newSubscriptionScalableMatrixWithUnitPricingPrice.conversionRate + currency = newSubscriptionScalableMatrixWithUnitPricingPrice.currency + externalPriceId = newSubscriptionScalableMatrixWithUnitPricingPrice.externalPriceId + fixedPriceQuantity = + newSubscriptionScalableMatrixWithUnitPricingPrice.fixedPriceQuantity + invoiceGroupingKey = + newSubscriptionScalableMatrixWithUnitPricingPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newSubscriptionScalableMatrixWithUnitPricingPrice.invoicingCycleConfiguration + metadata = newSubscriptionScalableMatrixWithUnitPricingPrice.metadata + referenceId = newSubscriptionScalableMatrixWithUnitPricingPrice.referenceId + additionalProperties = + newSubscriptionScalableMatrixWithUnitPricingPrice.additionalProperties + .toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun scalableMatrixWithUnitPricingConfig( + scalableMatrixWithUnitPricingConfig: CustomRatingFunctionConfigModel + ) = + scalableMatrixWithUnitPricingConfig( + JsonField.of(scalableMatrixWithUnitPricingConfig) + ) + + fun scalableMatrixWithUnitPricingConfig( + scalableMatrixWithUnitPricingConfig: JsonField + ) = apply { + this.scalableMatrixWithUnitPricingConfig = scalableMatrixWithUnitPricingConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * 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. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + 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) + } + + fun build(): NewSubscriptionScalableMatrixWithUnitPricingPrice = + NewSubscriptionScalableMatrixWithUnitPricingPrice( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired( + "scalableMatrixWithUnitPricingConfig", + scalableMatrixWithUnitPricingConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + currency, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField + val SCALABLE_MATRIX_WITH_UNIT_PRICING = of("scalable_matrix_with_unit_pricing") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + SCALABLE_MATRIX_WITH_UNIT_PRICING + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SCALABLE_MATRIX_WITH_UNIT_PRICING, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SCALABLE_MATRIX_WITH_UNIT_PRICING -> Value.SCALABLE_MATRIX_WITH_UNIT_PRICING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SCALABLE_MATRIX_WITH_UNIT_PRICING -> Known.SCALABLE_MATRIX_WITH_UNIT_PRICING + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewSubscriptionScalableMatrixWithUnitPricingPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && scalableMatrixWithUnitPricingConfig == other.scalableMatrixWithUnitPricingConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, scalableMatrixWithUnitPricingConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewSubscriptionScalableMatrixWithUnitPricingPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewSubscriptionScalableMatrixWithTieredPricingPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("scalable_matrix_with_tiered_pricing_config") + @ExcludeMissing + private val scalableMatrixWithTieredPricingConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun scalableMatrixWithTieredPricingConfig(): CustomRatingFunctionConfigModel = + scalableMatrixWithTieredPricingConfig.getRequired( + "scalable_matrix_with_tiered_pricing_config" + ) + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("scalable_matrix_with_tiered_pricing_config") + @ExcludeMissing + fun _scalableMatrixWithTieredPricingConfig(): JsonField = + scalableMatrixWithTieredPricingConfig + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewSubscriptionScalableMatrixWithTieredPricingPrice = apply { + if (validated) { + return@apply + } + + cadence() + itemId() + modelType() + name() + scalableMatrixWithTieredPricingConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewSubscriptionScalableMatrixWithTieredPricingPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .modelType() + * .name() + * .scalableMatrixWithTieredPricingConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewSubscriptionScalableMatrixWithTieredPricingPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var scalableMatrixWithTieredPricingConfig: + JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + newSubscriptionScalableMatrixWithTieredPricingPrice: + NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = apply { + cadence = newSubscriptionScalableMatrixWithTieredPricingPrice.cadence + itemId = newSubscriptionScalableMatrixWithTieredPricingPrice.itemId + modelType = newSubscriptionScalableMatrixWithTieredPricingPrice.modelType + name = newSubscriptionScalableMatrixWithTieredPricingPrice.name + scalableMatrixWithTieredPricingConfig = + newSubscriptionScalableMatrixWithTieredPricingPrice + .scalableMatrixWithTieredPricingConfig + billableMetricId = + newSubscriptionScalableMatrixWithTieredPricingPrice.billableMetricId + billedInAdvance = + newSubscriptionScalableMatrixWithTieredPricingPrice.billedInAdvance + billingCycleConfiguration = + newSubscriptionScalableMatrixWithTieredPricingPrice.billingCycleConfiguration + conversionRate = newSubscriptionScalableMatrixWithTieredPricingPrice.conversionRate + currency = newSubscriptionScalableMatrixWithTieredPricingPrice.currency + externalPriceId = + newSubscriptionScalableMatrixWithTieredPricingPrice.externalPriceId + fixedPriceQuantity = + newSubscriptionScalableMatrixWithTieredPricingPrice.fixedPriceQuantity + invoiceGroupingKey = + newSubscriptionScalableMatrixWithTieredPricingPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newSubscriptionScalableMatrixWithTieredPricingPrice.invoicingCycleConfiguration + metadata = newSubscriptionScalableMatrixWithTieredPricingPrice.metadata + referenceId = newSubscriptionScalableMatrixWithTieredPricingPrice.referenceId + additionalProperties = + newSubscriptionScalableMatrixWithTieredPricingPrice.additionalProperties + .toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun scalableMatrixWithTieredPricingConfig( + scalableMatrixWithTieredPricingConfig: CustomRatingFunctionConfigModel + ) = + scalableMatrixWithTieredPricingConfig( + JsonField.of(scalableMatrixWithTieredPricingConfig) + ) + + fun scalableMatrixWithTieredPricingConfig( + scalableMatrixWithTieredPricingConfig: JsonField + ) = apply { + this.scalableMatrixWithTieredPricingConfig = scalableMatrixWithTieredPricingConfig + } + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * 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. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + 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) + } + + fun build(): NewSubscriptionScalableMatrixWithTieredPricingPrice = + NewSubscriptionScalableMatrixWithTieredPricingPrice( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired( + "scalableMatrixWithTieredPricingConfig", + scalableMatrixWithTieredPricingConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + currency, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField + val SCALABLE_MATRIX_WITH_TIERED_PRICING = of("scalable_matrix_with_tiered_pricing") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + SCALABLE_MATRIX_WITH_TIERED_PRICING + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SCALABLE_MATRIX_WITH_TIERED_PRICING, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SCALABLE_MATRIX_WITH_TIERED_PRICING -> Value.SCALABLE_MATRIX_WITH_TIERED_PRICING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SCALABLE_MATRIX_WITH_TIERED_PRICING -> Known.SCALABLE_MATRIX_WITH_TIERED_PRICING + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewSubscriptionScalableMatrixWithTieredPricingPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && scalableMatrixWithTieredPricingConfig == other.scalableMatrixWithTieredPricingConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, scalableMatrixWithTieredPricingConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewSubscriptionScalableMatrixWithTieredPricingPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewSubscriptionCumulativeGroupedBulkPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_bulk_config") + @ExcludeMissing + private val cumulativeGroupedBulkConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun cumulativeGroupedBulkConfig(): CustomRatingFunctionConfigModel = + cumulativeGroupedBulkConfig.getRequired("cumulative_grouped_bulk_config") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + @JsonProperty("cumulative_grouped_bulk_config") + @ExcludeMissing + fun _cumulativeGroupedBulkConfig(): JsonField = + cumulativeGroupedBulkConfig + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewSubscriptionCumulativeGroupedBulkPrice = apply { + if (validated) { + return@apply + } + + cadence() + cumulativeGroupedBulkConfig().validate() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewSubscriptionCumulativeGroupedBulkPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .cumulativeGroupedBulkConfig() + * .itemId() + * .modelType() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewSubscriptionCumulativeGroupedBulkPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var cumulativeGroupedBulkConfig: JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var 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 currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + newSubscriptionCumulativeGroupedBulkPrice: NewSubscriptionCumulativeGroupedBulkPrice + ) = apply { + cadence = newSubscriptionCumulativeGroupedBulkPrice.cadence + cumulativeGroupedBulkConfig = + newSubscriptionCumulativeGroupedBulkPrice.cumulativeGroupedBulkConfig + itemId = newSubscriptionCumulativeGroupedBulkPrice.itemId + modelType = newSubscriptionCumulativeGroupedBulkPrice.modelType + name = newSubscriptionCumulativeGroupedBulkPrice.name + billableMetricId = newSubscriptionCumulativeGroupedBulkPrice.billableMetricId + billedInAdvance = newSubscriptionCumulativeGroupedBulkPrice.billedInAdvance + billingCycleConfiguration = + newSubscriptionCumulativeGroupedBulkPrice.billingCycleConfiguration + conversionRate = newSubscriptionCumulativeGroupedBulkPrice.conversionRate + currency = newSubscriptionCumulativeGroupedBulkPrice.currency + externalPriceId = newSubscriptionCumulativeGroupedBulkPrice.externalPriceId + fixedPriceQuantity = newSubscriptionCumulativeGroupedBulkPrice.fixedPriceQuantity + invoiceGroupingKey = newSubscriptionCumulativeGroupedBulkPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newSubscriptionCumulativeGroupedBulkPrice.invoicingCycleConfiguration + metadata = newSubscriptionCumulativeGroupedBulkPrice.metadata + referenceId = newSubscriptionCumulativeGroupedBulkPrice.referenceId + additionalProperties = + newSubscriptionCumulativeGroupedBulkPrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun cumulativeGroupedBulkConfig( + cumulativeGroupedBulkConfig: CustomRatingFunctionConfigModel + ) = cumulativeGroupedBulkConfig(JsonField.of(cumulativeGroupedBulkConfig)) + + fun cumulativeGroupedBulkConfig( + cumulativeGroupedBulkConfig: JsonField + ) = apply { this.cumulativeGroupedBulkConfig = cumulativeGroupedBulkConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + 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)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * 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. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + 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) + } + + fun build(): NewSubscriptionCumulativeGroupedBulkPrice = + NewSubscriptionCumulativeGroupedBulkPrice( + checkRequired("cadence", cadence), + checkRequired("cumulativeGroupedBulkConfig", cumulativeGroupedBulkConfig), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + currency, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CUMULATIVE_GROUPED_BULK = of("cumulative_grouped_bulk") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + CUMULATIVE_GROUPED_BULK + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CUMULATIVE_GROUPED_BULK, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CUMULATIVE_GROUPED_BULK -> Value.CUMULATIVE_GROUPED_BULK + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CUMULATIVE_GROUPED_BULK -> Known.CUMULATIVE_GROUPED_BULK + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewSubscriptionCumulativeGroupedBulkPrice && cadence == other.cadence && cumulativeGroupedBulkConfig == other.cumulativeGroupedBulkConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, cumulativeGroupedBulkConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewSubscriptionCumulativeGroupedBulkPrice{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewSubscriptionMaxGroupTieredPackagePrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("max_group_tiered_package_config") + @ExcludeMissing + private val maxGroupTieredPackageConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun maxGroupTieredPackageConfig(): CustomRatingFunctionConfigModel = + maxGroupTieredPackageConfig.getRequired("max_group_tiered_package_config") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("max_group_tiered_package_config") + @ExcludeMissing + fun _maxGroupTieredPackageConfig(): JsonField = + maxGroupTieredPackageConfig + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewSubscriptionMaxGroupTieredPackagePrice = apply { + if (validated) { + return@apply + } + + cadence() + itemId() + maxGroupTieredPackageConfig().validate() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewSubscriptionMaxGroupTieredPackagePrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .maxGroupTieredPackageConfig() + * .modelType() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewSubscriptionMaxGroupTieredPackagePrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var maxGroupTieredPackageConfig: JsonField? = + null + private var modelType: JsonField? = null + private var 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 currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + newSubscriptionMaxGroupTieredPackagePrice: NewSubscriptionMaxGroupTieredPackagePrice + ) = apply { + cadence = newSubscriptionMaxGroupTieredPackagePrice.cadence + itemId = newSubscriptionMaxGroupTieredPackagePrice.itemId + maxGroupTieredPackageConfig = + newSubscriptionMaxGroupTieredPackagePrice.maxGroupTieredPackageConfig + modelType = newSubscriptionMaxGroupTieredPackagePrice.modelType + name = newSubscriptionMaxGroupTieredPackagePrice.name + billableMetricId = newSubscriptionMaxGroupTieredPackagePrice.billableMetricId + billedInAdvance = newSubscriptionMaxGroupTieredPackagePrice.billedInAdvance + billingCycleConfiguration = + newSubscriptionMaxGroupTieredPackagePrice.billingCycleConfiguration + conversionRate = newSubscriptionMaxGroupTieredPackagePrice.conversionRate + currency = newSubscriptionMaxGroupTieredPackagePrice.currency + externalPriceId = newSubscriptionMaxGroupTieredPackagePrice.externalPriceId + fixedPriceQuantity = newSubscriptionMaxGroupTieredPackagePrice.fixedPriceQuantity + invoiceGroupingKey = newSubscriptionMaxGroupTieredPackagePrice.invoiceGroupingKey + invoicingCycleConfiguration = + newSubscriptionMaxGroupTieredPackagePrice.invoicingCycleConfiguration + metadata = newSubscriptionMaxGroupTieredPackagePrice.metadata + referenceId = newSubscriptionMaxGroupTieredPackagePrice.referenceId + additionalProperties = + newSubscriptionMaxGroupTieredPackagePrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun maxGroupTieredPackageConfig( + maxGroupTieredPackageConfig: CustomRatingFunctionConfigModel + ) = maxGroupTieredPackageConfig(JsonField.of(maxGroupTieredPackageConfig)) + + fun maxGroupTieredPackageConfig( + maxGroupTieredPackageConfig: JsonField + ) = apply { this.maxGroupTieredPackageConfig = maxGroupTieredPackageConfig } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + 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)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * 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. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + 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) + } + + fun build(): NewSubscriptionMaxGroupTieredPackagePrice = + NewSubscriptionMaxGroupTieredPackagePrice( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("maxGroupTieredPackageConfig", maxGroupTieredPackageConfig), + checkRequired("modelType", modelType), + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + currency, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val MAX_GROUP_TIERED_PACKAGE = of("max_group_tiered_package") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + MAX_GROUP_TIERED_PACKAGE + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MAX_GROUP_TIERED_PACKAGE, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MAX_GROUP_TIERED_PACKAGE -> Value.MAX_GROUP_TIERED_PACKAGE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MAX_GROUP_TIERED_PACKAGE -> Known.MAX_GROUP_TIERED_PACKAGE + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewSubscriptionMaxGroupTieredPackagePrice && cadence == other.cadence && itemId == other.itemId && maxGroupTieredPackageConfig == other.maxGroupTieredPackageConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, itemId, maxGroupTieredPackageConfig, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewSubscriptionMaxGroupTieredPackagePrice{cadence=$cadence, itemId=$itemId, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewSubscriptionGroupedWithMeteredMinimumPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_metered_minimum_config") + @ExcludeMissing + private val groupedWithMeteredMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun groupedWithMeteredMinimumConfig(): CustomRatingFunctionConfigModel = + groupedWithMeteredMinimumConfig.getRequired("grouped_with_metered_minimum_config") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + @JsonProperty("grouped_with_metered_minimum_config") + @ExcludeMissing + fun _groupedWithMeteredMinimumConfig(): JsonField = + groupedWithMeteredMinimumConfig + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewSubscriptionGroupedWithMeteredMinimumPrice = apply { + if (validated) { + return@apply + } + + cadence() + groupedWithMeteredMinimumConfig().validate() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewSubscriptionGroupedWithMeteredMinimumPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithMeteredMinimumConfig() + * .itemId() + * .modelType() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewSubscriptionGroupedWithMeteredMinimumPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedWithMeteredMinimumConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + newSubscriptionGroupedWithMeteredMinimumPrice: + NewSubscriptionGroupedWithMeteredMinimumPrice + ) = apply { + cadence = newSubscriptionGroupedWithMeteredMinimumPrice.cadence + groupedWithMeteredMinimumConfig = + newSubscriptionGroupedWithMeteredMinimumPrice.groupedWithMeteredMinimumConfig + itemId = newSubscriptionGroupedWithMeteredMinimumPrice.itemId + modelType = newSubscriptionGroupedWithMeteredMinimumPrice.modelType + name = newSubscriptionGroupedWithMeteredMinimumPrice.name + billableMetricId = newSubscriptionGroupedWithMeteredMinimumPrice.billableMetricId + billedInAdvance = newSubscriptionGroupedWithMeteredMinimumPrice.billedInAdvance + billingCycleConfiguration = + newSubscriptionGroupedWithMeteredMinimumPrice.billingCycleConfiguration + conversionRate = newSubscriptionGroupedWithMeteredMinimumPrice.conversionRate + currency = newSubscriptionGroupedWithMeteredMinimumPrice.currency + externalPriceId = newSubscriptionGroupedWithMeteredMinimumPrice.externalPriceId + fixedPriceQuantity = + newSubscriptionGroupedWithMeteredMinimumPrice.fixedPriceQuantity + invoiceGroupingKey = + newSubscriptionGroupedWithMeteredMinimumPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newSubscriptionGroupedWithMeteredMinimumPrice.invoicingCycleConfiguration + metadata = newSubscriptionGroupedWithMeteredMinimumPrice.metadata + referenceId = newSubscriptionGroupedWithMeteredMinimumPrice.referenceId + additionalProperties = + newSubscriptionGroupedWithMeteredMinimumPrice.additionalProperties + .toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: CustomRatingFunctionConfigModel + ) = groupedWithMeteredMinimumConfig(JsonField.of(groupedWithMeteredMinimumConfig)) + + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: JsonField + ) = apply { this.groupedWithMeteredMinimumConfig = groupedWithMeteredMinimumConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + 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)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * 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. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + 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) + } + + fun build(): NewSubscriptionGroupedWithMeteredMinimumPrice = + NewSubscriptionGroupedWithMeteredMinimumPrice( + checkRequired("cadence", cadence), + checkRequired( + "groupedWithMeteredMinimumConfig", + groupedWithMeteredMinimumConfig, + ), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + currency, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val GROUPED_WITH_METERED_MINIMUM = of("grouped_with_metered_minimum") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + GROUPED_WITH_METERED_MINIMUM + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GROUPED_WITH_METERED_MINIMUM, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GROUPED_WITH_METERED_MINIMUM -> Value.GROUPED_WITH_METERED_MINIMUM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + GROUPED_WITH_METERED_MINIMUM -> Known.GROUPED_WITH_METERED_MINIMUM + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewSubscriptionGroupedWithMeteredMinimumPrice && cadence == other.cadence && groupedWithMeteredMinimumConfig == other.groupedWithMeteredMinimumConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, groupedWithMeteredMinimumConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewSubscriptionGroupedWithMeteredMinimumPrice{cadence=$cadence, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewSubscriptionMatrixWithDisplayNamePrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + private val matrixWithDisplayNameConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun matrixWithDisplayNameConfig(): CustomRatingFunctionConfigModel = + matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_config") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + fun _matrixWithDisplayNameConfig(): JsonField = + matrixWithDisplayNameConfig + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewSubscriptionMatrixWithDisplayNamePrice = apply { + if (validated) { + return@apply + } + + cadence() + itemId() + matrixWithDisplayNameConfig().validate() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewSubscriptionMatrixWithDisplayNamePrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .matrixWithDisplayNameConfig() + * .modelType() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewSubscriptionMatrixWithDisplayNamePrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var matrixWithDisplayNameConfig: JsonField? = + null + private var modelType: JsonField? = null + private var 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 currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + newSubscriptionMatrixWithDisplayNamePrice: NewSubscriptionMatrixWithDisplayNamePrice + ) = apply { + cadence = newSubscriptionMatrixWithDisplayNamePrice.cadence + itemId = newSubscriptionMatrixWithDisplayNamePrice.itemId + matrixWithDisplayNameConfig = + newSubscriptionMatrixWithDisplayNamePrice.matrixWithDisplayNameConfig + modelType = newSubscriptionMatrixWithDisplayNamePrice.modelType + name = newSubscriptionMatrixWithDisplayNamePrice.name + billableMetricId = newSubscriptionMatrixWithDisplayNamePrice.billableMetricId + billedInAdvance = newSubscriptionMatrixWithDisplayNamePrice.billedInAdvance + billingCycleConfiguration = + newSubscriptionMatrixWithDisplayNamePrice.billingCycleConfiguration + conversionRate = newSubscriptionMatrixWithDisplayNamePrice.conversionRate + currency = newSubscriptionMatrixWithDisplayNamePrice.currency + externalPriceId = newSubscriptionMatrixWithDisplayNamePrice.externalPriceId + fixedPriceQuantity = newSubscriptionMatrixWithDisplayNamePrice.fixedPriceQuantity + invoiceGroupingKey = newSubscriptionMatrixWithDisplayNamePrice.invoiceGroupingKey + invoicingCycleConfiguration = + newSubscriptionMatrixWithDisplayNamePrice.invoicingCycleConfiguration + metadata = newSubscriptionMatrixWithDisplayNamePrice.metadata + referenceId = newSubscriptionMatrixWithDisplayNamePrice.referenceId + additionalProperties = + newSubscriptionMatrixWithDisplayNamePrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: CustomRatingFunctionConfigModel + ) = matrixWithDisplayNameConfig(JsonField.of(matrixWithDisplayNameConfig)) + + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: JsonField + ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + 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)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * 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. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + 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) + } + + fun build(): NewSubscriptionMatrixWithDisplayNamePrice = + NewSubscriptionMatrixWithDisplayNamePrice( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("matrixWithDisplayNameConfig", matrixWithDisplayNameConfig), + checkRequired("modelType", modelType), + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + currency, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val MATRIX_WITH_DISPLAY_NAME = of("matrix_with_display_name") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + MATRIX_WITH_DISPLAY_NAME + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MATRIX_WITH_DISPLAY_NAME, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MATRIX_WITH_DISPLAY_NAME -> Value.MATRIX_WITH_DISPLAY_NAME + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MATRIX_WITH_DISPLAY_NAME -> Known.MATRIX_WITH_DISPLAY_NAME + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewSubscriptionMatrixWithDisplayNamePrice && cadence == other.cadence && itemId == other.itemId && matrixWithDisplayNameConfig == other.matrixWithDisplayNameConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, itemId, matrixWithDisplayNameConfig, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewSubscriptionMatrixWithDisplayNamePrice{cadence=$cadence, itemId=$itemId, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewSubscriptionGroupedTieredPackagePrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_tiered_package_config") + @ExcludeMissing + private val groupedTieredPackageConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun groupedTieredPackageConfig(): CustomRatingFunctionConfigModel = + groupedTieredPackageConfig.getRequired("grouped_tiered_package_config") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + @JsonProperty("grouped_tiered_package_config") + @ExcludeMissing + fun _groupedTieredPackageConfig(): JsonField = + groupedTieredPackageConfig + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price is + * billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * A transient ID that can be used to reference this price when adding adjustments in the + * same API call. + */ + @JsonProperty("reference_id") + @ExcludeMissing + fun _referenceId(): JsonField = referenceId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewSubscriptionGroupedTieredPackagePrice = apply { + if (validated) { + return@apply + } + + cadence() + groupedTieredPackageConfig().validate() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + referenceId() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewSubscriptionGroupedTieredPackagePrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedTieredPackageConfig() + * .itemId() + * .modelType() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewSubscriptionGroupedTieredPackagePrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var groupedTieredPackageConfig: JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var 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 currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + newSubscriptionGroupedTieredPackagePrice: NewSubscriptionGroupedTieredPackagePrice + ) = apply { + cadence = newSubscriptionGroupedTieredPackagePrice.cadence + groupedTieredPackageConfig = + newSubscriptionGroupedTieredPackagePrice.groupedTieredPackageConfig + itemId = newSubscriptionGroupedTieredPackagePrice.itemId + modelType = newSubscriptionGroupedTieredPackagePrice.modelType + name = newSubscriptionGroupedTieredPackagePrice.name + billableMetricId = newSubscriptionGroupedTieredPackagePrice.billableMetricId + billedInAdvance = newSubscriptionGroupedTieredPackagePrice.billedInAdvance + billingCycleConfiguration = + newSubscriptionGroupedTieredPackagePrice.billingCycleConfiguration + conversionRate = newSubscriptionGroupedTieredPackagePrice.conversionRate + currency = newSubscriptionGroupedTieredPackagePrice.currency + externalPriceId = newSubscriptionGroupedTieredPackagePrice.externalPriceId + fixedPriceQuantity = newSubscriptionGroupedTieredPackagePrice.fixedPriceQuantity + invoiceGroupingKey = newSubscriptionGroupedTieredPackagePrice.invoiceGroupingKey + invoicingCycleConfiguration = + newSubscriptionGroupedTieredPackagePrice.invoicingCycleConfiguration + metadata = newSubscriptionGroupedTieredPackagePrice.metadata + referenceId = newSubscriptionGroupedTieredPackagePrice.referenceId + additionalProperties = + newSubscriptionGroupedTieredPackagePrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun groupedTieredPackageConfig( + groupedTieredPackageConfig: CustomRatingFunctionConfigModel + ) = groupedTieredPackageConfig(JsonField.of(groupedTieredPackageConfig)) + + fun groupedTieredPackageConfig( + groupedTieredPackageConfig: JsonField + ) = apply { this.groupedTieredPackageConfig = groupedTieredPackageConfig } + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + 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)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * 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. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + 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)) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + + /** + * A transient ID that can be used to reference this price when adding adjustments in + * the same API call. + */ + 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) + } + + fun build(): NewSubscriptionGroupedTieredPackagePrice = + NewSubscriptionGroupedTieredPackagePrice( + checkRequired("cadence", cadence), + checkRequired("groupedTieredPackageConfig", groupedTieredPackageConfig), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + currency, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + referenceId, + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val GROUPED_TIERED_PACKAGE = of("grouped_tiered_package") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + GROUPED_TIERED_PACKAGE + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GROUPED_TIERED_PACKAGE, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GROUPED_TIERED_PACKAGE -> Value.GROUPED_TIERED_PACKAGE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + GROUPED_TIERED_PACKAGE -> Known.GROUPED_TIERED_PACKAGE + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewSubscriptionGroupedTieredPackagePrice && cadence == other.cadence && groupedTieredPackageConfig == other.groupedTieredPackageConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, groupedTieredPackageConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewSubscriptionGroupedTieredPackagePrice{cadence=$cadence, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/NewTaxConfigurationModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewTaxConfigurationModel.kt new file mode 100644 index 000000000..f41800e0e --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/NewTaxConfigurationModel.kt @@ -0,0 +1,664 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.BaseDeserializer +import com.withorb.api.core.BaseSerializer +import com.withorb.api.core.Enum +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.getOrThrow +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +@JsonDeserialize(using = NewTaxConfigurationModel.Deserializer::class) +@JsonSerialize(using = NewTaxConfigurationModel.Serializer::class) +class NewTaxConfigurationModel +private constructor( + private val avalaraTaxConfiguration: NewAvalaraTaxConfiguration? = null, + private val jarConfiguration: NewTaxJarConfiguration? = null, + private val _json: JsonValue? = null, +) { + + fun avalaraTaxConfiguration(): Optional = + Optional.ofNullable(avalaraTaxConfiguration) + + fun jarConfiguration(): Optional = Optional.ofNullable(jarConfiguration) + + fun isAvalaraTaxConfiguration(): Boolean = avalaraTaxConfiguration != null + + fun isJarConfiguration(): Boolean = jarConfiguration != null + + fun asAvalaraTaxConfiguration(): NewAvalaraTaxConfiguration = + avalaraTaxConfiguration.getOrThrow("avalaraTaxConfiguration") + + fun asJarConfiguration(): NewTaxJarConfiguration = + jarConfiguration.getOrThrow("jarConfiguration") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + avalaraTaxConfiguration != null -> + visitor.visitAvalaraTaxConfiguration(avalaraTaxConfiguration) + jarConfiguration != null -> visitor.visitJarConfiguration(jarConfiguration) + else -> visitor.unknown(_json) + } + } + + private var validated: Boolean = false + + fun validate(): NewTaxConfigurationModel = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitAvalaraTaxConfiguration( + avalaraTaxConfiguration: NewAvalaraTaxConfiguration + ) { + avalaraTaxConfiguration.validate() + } + + override fun visitJarConfiguration(jarConfiguration: NewTaxJarConfiguration) { + jarConfiguration.validate() + } + } + ) + validated = true + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewTaxConfigurationModel && avalaraTaxConfiguration == other.avalaraTaxConfiguration && jarConfiguration == other.jarConfiguration /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(avalaraTaxConfiguration, jarConfiguration) /* spotless:on */ + + override fun toString(): String = + when { + avalaraTaxConfiguration != null -> + "NewTaxConfigurationModel{avalaraTaxConfiguration=$avalaraTaxConfiguration}" + jarConfiguration != null -> + "NewTaxConfigurationModel{jarConfiguration=$jarConfiguration}" + _json != null -> "NewTaxConfigurationModel{_unknown=$_json}" + else -> throw IllegalStateException("Invalid NewTaxConfigurationModel") + } + + companion object { + + @JvmStatic + fun ofAvalaraTaxConfiguration(avalaraTaxConfiguration: NewAvalaraTaxConfiguration) = + NewTaxConfigurationModel(avalaraTaxConfiguration = avalaraTaxConfiguration) + + @JvmStatic + fun ofJarConfiguration(jarConfiguration: NewTaxJarConfiguration) = + NewTaxConfigurationModel(jarConfiguration = jarConfiguration) + } + + /** + * An interface that defines how to map each variant of [NewTaxConfigurationModel] to a value of + * type [T]. + */ + interface Visitor { + + fun visitAvalaraTaxConfiguration(avalaraTaxConfiguration: NewAvalaraTaxConfiguration): T + + fun visitJarConfiguration(jarConfiguration: NewTaxJarConfiguration): T + + /** + * Maps an unknown variant of [NewTaxConfigurationModel] to a value of type [T]. + * + * An instance of [NewTaxConfigurationModel] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the SDK is + * on an older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown NewTaxConfigurationModel: $json") + } + } + + internal class Deserializer : + BaseDeserializer(NewTaxConfigurationModel::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): NewTaxConfigurationModel { + val json = JsonValue.fromJsonNode(node) + val taxProvider = + json.asObject().getOrNull()?.get("tax_provider")?.asString()?.getOrNull() + + when (taxProvider) { + "avalara" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return NewTaxConfigurationModel( + avalaraTaxConfiguration = it, + _json = json, + ) + } + } + "taxjar" -> { + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return NewTaxConfigurationModel(jarConfiguration = it, _json = json) + } + } + } + + return NewTaxConfigurationModel(_json = json) + } + } + + internal class Serializer : + BaseSerializer(NewTaxConfigurationModel::class) { + + override fun serialize( + value: NewTaxConfigurationModel, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.avalaraTaxConfiguration != null -> + generator.writeObject(value.avalaraTaxConfiguration) + value.jarConfiguration != null -> generator.writeObject(value.jarConfiguration) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid NewTaxConfigurationModel") + } + } + } + + @NoAutoDetect + class NewAvalaraTaxConfiguration + @JsonCreator + private constructor( + @JsonProperty("tax_exempt") + @ExcludeMissing + private val taxExempt: JsonField = JsonMissing.of(), + @JsonProperty("tax_provider") + @ExcludeMissing + private val taxProvider: JsonField = JsonMissing.of(), + @JsonProperty("tax_exemption_code") + @ExcludeMissing + private val taxExemptionCode: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun taxExempt(): Boolean = taxExempt.getRequired("tax_exempt") + + fun taxProvider(): TaxProvider = taxProvider.getRequired("tax_provider") + + fun taxExemptionCode(): Optional = + Optional.ofNullable(taxExemptionCode.getNullable("tax_exemption_code")) + + @JsonProperty("tax_exempt") @ExcludeMissing fun _taxExempt(): JsonField = taxExempt + + @JsonProperty("tax_provider") + @ExcludeMissing + fun _taxProvider(): JsonField = taxProvider + + @JsonProperty("tax_exemption_code") + @ExcludeMissing + fun _taxExemptionCode(): JsonField = taxExemptionCode + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewAvalaraTaxConfiguration = apply { + if (validated) { + return@apply + } + + taxExempt() + taxProvider() + taxExemptionCode() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewAvalaraTaxConfiguration]. + * + * The following fields are required: + * ```java + * .taxExempt() + * .taxProvider() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewAvalaraTaxConfiguration]. */ + class Builder internal constructor() { + + private var taxExempt: JsonField? = null + private var taxProvider: JsonField? = null + private var taxExemptionCode: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(newAvalaraTaxConfiguration: NewAvalaraTaxConfiguration) = apply { + taxExempt = newAvalaraTaxConfiguration.taxExempt + taxProvider = newAvalaraTaxConfiguration.taxProvider + taxExemptionCode = newAvalaraTaxConfiguration.taxExemptionCode + additionalProperties = + newAvalaraTaxConfiguration.additionalProperties.toMutableMap() + } + + fun taxExempt(taxExempt: Boolean) = taxExempt(JsonField.of(taxExempt)) + + fun taxExempt(taxExempt: JsonField) = apply { this.taxExempt = taxExempt } + + fun taxProvider(taxProvider: TaxProvider) = taxProvider(JsonField.of(taxProvider)) + + fun taxProvider(taxProvider: JsonField) = apply { + this.taxProvider = taxProvider + } + + fun taxExemptionCode(taxExemptionCode: String?) = + taxExemptionCode(JsonField.ofNullable(taxExemptionCode)) + + fun taxExemptionCode(taxExemptionCode: Optional) = + taxExemptionCode(taxExemptionCode.orElse(null)) + + fun taxExemptionCode(taxExemptionCode: JsonField) = apply { + this.taxExemptionCode = taxExemptionCode + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): NewAvalaraTaxConfiguration = + NewAvalaraTaxConfiguration( + checkRequired("taxExempt", taxExempt), + checkRequired("taxProvider", taxProvider), + taxExemptionCode, + additionalProperties.toImmutable(), + ) + } + + class TaxProvider @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val AVALARA = of("avalara") + + @JvmStatic fun of(value: String) = TaxProvider(JsonField.of(value)) + } + + /** An enum containing [TaxProvider]'s known values. */ + enum class Known { + AVALARA + } + + /** + * An enum containing [TaxProvider]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TaxProvider] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AVALARA, + /** + * An enum member indicating that [TaxProvider] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AVALARA -> Value.AVALARA + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + AVALARA -> Known.AVALARA + else -> throw OrbInvalidDataException("Unknown TaxProvider: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TaxProvider && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewAvalaraTaxConfiguration && taxExempt == other.taxExempt && taxProvider == other.taxProvider && taxExemptionCode == other.taxExemptionCode && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(taxExempt, taxProvider, taxExemptionCode, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewAvalaraTaxConfiguration{taxExempt=$taxExempt, taxProvider=$taxProvider, taxExemptionCode=$taxExemptionCode, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewTaxJarConfiguration + @JsonCreator + private constructor( + @JsonProperty("tax_exempt") + @ExcludeMissing + private val taxExempt: JsonField = JsonMissing.of(), + @JsonProperty("tax_provider") + @ExcludeMissing + private val taxProvider: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun taxExempt(): Boolean = taxExempt.getRequired("tax_exempt") + + fun taxProvider(): TaxProvider = taxProvider.getRequired("tax_provider") + + @JsonProperty("tax_exempt") @ExcludeMissing fun _taxExempt(): JsonField = taxExempt + + @JsonProperty("tax_provider") + @ExcludeMissing + fun _taxProvider(): JsonField = taxProvider + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewTaxJarConfiguration = apply { + if (validated) { + return@apply + } + + taxExempt() + taxProvider() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [NewTaxJarConfiguration]. + * + * The following fields are required: + * ```java + * .taxExempt() + * .taxProvider() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewTaxJarConfiguration]. */ + class Builder internal constructor() { + + private var taxExempt: JsonField? = null + private var taxProvider: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(newTaxJarConfiguration: NewTaxJarConfiguration) = apply { + taxExempt = newTaxJarConfiguration.taxExempt + taxProvider = newTaxJarConfiguration.taxProvider + additionalProperties = newTaxJarConfiguration.additionalProperties.toMutableMap() + } + + fun taxExempt(taxExempt: Boolean) = taxExempt(JsonField.of(taxExempt)) + + fun taxExempt(taxExempt: JsonField) = apply { this.taxExempt = taxExempt } + + fun taxProvider(taxProvider: TaxProvider) = taxProvider(JsonField.of(taxProvider)) + + fun taxProvider(taxProvider: JsonField) = apply { + this.taxProvider = taxProvider + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): NewTaxJarConfiguration = + NewTaxJarConfiguration( + checkRequired("taxExempt", taxExempt), + checkRequired("taxProvider", taxProvider), + additionalProperties.toImmutable(), + ) + } + + class TaxProvider @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TAXJAR = of("taxjar") + + @JvmStatic fun of(value: String) = TaxProvider(JsonField.of(value)) + } + + /** An enum containing [TaxProvider]'s known values. */ + enum class Known { + TAXJAR + } + + /** + * An enum containing [TaxProvider]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TaxProvider] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TAXJAR, + /** + * An enum member indicating that [TaxProvider] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TAXJAR -> Value.TAXJAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TAXJAR -> Known.TAXJAR + else -> throw OrbInvalidDataException("Unknown TaxProvider: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TaxProvider && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewTaxJarConfiguration && taxExempt == other.taxExempt && taxProvider == other.taxProvider && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(taxExempt, taxProvider, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewTaxJarConfiguration{taxExempt=$taxExempt, taxProvider=$taxProvider, additionalProperties=$additionalProperties}" + } +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PackageConfigModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PackageConfigModel.kt new file mode 100644 index 000000000..6054cba51 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PackageConfigModel.kt @@ -0,0 +1,161 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects + +@NoAutoDetect +class PackageConfigModel +@JsonCreator +private constructor( + @JsonProperty("package_amount") + @ExcludeMissing + private val packageAmount: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + private val packageSize: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** A currency amount to rate usage by */ + fun packageAmount(): String = packageAmount.getRequired("package_amount") + + /** + * An integer amount to represent package size. For example, 1000 here would divide usage by + * 1000 before multiplying by package_amount in rating + */ + fun packageSize(): Long = packageSize.getRequired("package_size") + + /** A currency amount to rate usage by */ + @JsonProperty("package_amount") + @ExcludeMissing + fun _packageAmount(): JsonField = packageAmount + + /** + * An integer amount to represent package size. For example, 1000 here would divide usage by + * 1000 before multiplying by package_amount in rating + */ + @JsonProperty("package_size") @ExcludeMissing fun _packageSize(): JsonField = packageSize + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): PackageConfigModel = apply { + if (validated) { + return@apply + } + + packageAmount() + packageSize() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PackageConfigModel]. + * + * The following fields are required: + * ```java + * .packageAmount() + * .packageSize() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PackageConfigModel]. */ + class Builder internal constructor() { + + private var packageAmount: JsonField? = null + private var packageSize: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(packageConfigModel: PackageConfigModel) = apply { + packageAmount = packageConfigModel.packageAmount + packageSize = packageConfigModel.packageSize + additionalProperties = packageConfigModel.additionalProperties.toMutableMap() + } + + /** A currency amount to rate usage by */ + fun packageAmount(packageAmount: String) = packageAmount(JsonField.of(packageAmount)) + + /** A currency amount to rate usage by */ + fun packageAmount(packageAmount: JsonField) = apply { + this.packageAmount = packageAmount + } + + /** + * An integer amount to represent package size. For example, 1000 here would divide usage by + * 1000 before multiplying by package_amount in rating + */ + fun packageSize(packageSize: Long) = packageSize(JsonField.of(packageSize)) + + /** + * An integer amount to represent package size. For example, 1000 here would divide usage by + * 1000 before multiplying by package_amount in rating + */ + fun packageSize(packageSize: JsonField) = apply { this.packageSize = packageSize } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): PackageConfigModel = + PackageConfigModel( + checkRequired("packageAmount", packageAmount), + checkRequired("packageSize", packageSize), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PackageConfigModel && packageAmount == other.packageAmount && packageSize == other.packageSize && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(packageAmount, packageSize, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PackageConfigModel{packageAmount=$packageAmount, packageSize=$packageSize, additionalProperties=$additionalProperties}" +} 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 c012514dd..43f8b77d9 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 @@ -58,6 +58,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [PaginationMetadata]. + * + * The following fields are required: + * ```java + * .hasMore() + * .nextCursor() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PaginationMetadataModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PaginationMetadataModel.kt new file mode 100644 index 000000000..8246c132b --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PaginationMetadataModel.kt @@ -0,0 +1,140 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class PaginationMetadataModel +@JsonCreator +private constructor( + @JsonProperty("has_more") + @ExcludeMissing + private val hasMore: JsonField = JsonMissing.of(), + @JsonProperty("next_cursor") + @ExcludeMissing + private val nextCursor: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun hasMore(): Boolean = hasMore.getRequired("has_more") + + fun nextCursor(): Optional = Optional.ofNullable(nextCursor.getNullable("next_cursor")) + + @JsonProperty("has_more") @ExcludeMissing fun _hasMore(): JsonField = hasMore + + @JsonProperty("next_cursor") @ExcludeMissing fun _nextCursor(): JsonField = nextCursor + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): PaginationMetadataModel = apply { + if (validated) { + return@apply + } + + hasMore() + nextCursor() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PaginationMetadataModel]. + * + * The following fields are required: + * ```java + * .hasMore() + * .nextCursor() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PaginationMetadataModel]. */ + class Builder internal constructor() { + + private var hasMore: JsonField? = null + private var nextCursor: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(paginationMetadataModel: PaginationMetadataModel) = apply { + hasMore = paginationMetadataModel.hasMore + nextCursor = paginationMetadataModel.nextCursor + additionalProperties = paginationMetadataModel.additionalProperties.toMutableMap() + } + + fun hasMore(hasMore: Boolean) = hasMore(JsonField.of(hasMore)) + + fun hasMore(hasMore: JsonField) = apply { this.hasMore = hasMore } + + fun nextCursor(nextCursor: String?) = nextCursor(JsonField.ofNullable(nextCursor)) + + fun nextCursor(nextCursor: Optional) = nextCursor(nextCursor.orElse(null)) + + fun nextCursor(nextCursor: JsonField) = apply { this.nextCursor = nextCursor } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): PaginationMetadataModel = + PaginationMetadataModel( + checkRequired("hasMore", hasMore), + checkRequired("nextCursor", nextCursor), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PaginationMetadataModel && hasMore == other.hasMore && nextCursor == other.nextCursor && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(hasMore, nextCursor, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PaginationMetadataModel{hasMore=$hasMore, nextCursor=$nextCursor, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PaymentAttemptModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PaymentAttemptModel.kt new file mode 100644 index 000000000..9e2bcf057 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PaymentAttemptModel.kt @@ -0,0 +1,345 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class PaymentAttemptModel +@JsonCreator +private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("payment_provider") + @ExcludeMissing + private val paymentProvider: JsonField = JsonMissing.of(), + @JsonProperty("payment_provider_id") + @ExcludeMissing + private val paymentProviderId: JsonField = JsonMissing.of(), + @JsonProperty("succeeded") + @ExcludeMissing + private val succeeded: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** The ID of the payment attempt. */ + fun id(): String = id.getRequired("id") + + /** The amount of the payment attempt. */ + fun amount(): String = amount.getRequired("amount") + + /** The time at which the payment attempt was created. */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** The payment provider that attempted to collect the payment. */ + fun paymentProvider(): Optional = + Optional.ofNullable(paymentProvider.getNullable("payment_provider")) + + /** The ID of the payment attempt in the payment provider. */ + fun paymentProviderId(): Optional = + Optional.ofNullable(paymentProviderId.getNullable("payment_provider_id")) + + /** Whether the payment attempt succeeded. */ + fun succeeded(): Boolean = succeeded.getRequired("succeeded") + + /** The ID of the payment attempt. */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** The amount of the payment attempt. */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** The time at which the payment attempt was created. */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** The payment provider that attempted to collect the payment. */ + @JsonProperty("payment_provider") + @ExcludeMissing + fun _paymentProvider(): JsonField = paymentProvider + + /** The ID of the payment attempt in the payment provider. */ + @JsonProperty("payment_provider_id") + @ExcludeMissing + fun _paymentProviderId(): JsonField = paymentProviderId + + /** Whether the payment attempt succeeded. */ + @JsonProperty("succeeded") @ExcludeMissing fun _succeeded(): JsonField = succeeded + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): PaymentAttemptModel = apply { + if (validated) { + return@apply + } + + id() + amount() + createdAt() + paymentProvider() + paymentProviderId() + succeeded() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PaymentAttemptModel]. + * + * The following fields are required: + * ```java + * .id() + * .amount() + * .createdAt() + * .paymentProvider() + * .paymentProviderId() + * .succeeded() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PaymentAttemptModel]. */ + 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 succeeded: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(paymentAttemptModel: PaymentAttemptModel) = apply { + id = paymentAttemptModel.id + amount = paymentAttemptModel.amount + createdAt = paymentAttemptModel.createdAt + paymentProvider = paymentAttemptModel.paymentProvider + paymentProviderId = paymentAttemptModel.paymentProviderId + succeeded = paymentAttemptModel.succeeded + additionalProperties = paymentAttemptModel.additionalProperties.toMutableMap() + } + + /** The ID of the payment attempt. */ + fun id(id: String) = id(JsonField.of(id)) + + /** The ID of the payment attempt. */ + fun id(id: JsonField) = apply { this.id = id } + + /** The amount of the payment attempt. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** The amount of the payment attempt. */ + 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)) + + /** The time at which the payment attempt was created. */ + 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)) + + /** The payment provider that attempted to collect the payment. */ + fun paymentProvider(paymentProvider: Optional) = + paymentProvider(paymentProvider.orElse(null)) + + /** The payment provider that attempted to collect the payment. */ + 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)) + + /** The ID of the payment attempt in the payment provider. */ + fun paymentProviderId(paymentProviderId: Optional) = + paymentProviderId(paymentProviderId.orElse(null)) + + /** The ID of the payment attempt in the payment provider. */ + fun paymentProviderId(paymentProviderId: JsonField) = apply { + this.paymentProviderId = paymentProviderId + } + + /** Whether the payment attempt succeeded. */ + fun succeeded(succeeded: Boolean) = succeeded(JsonField.of(succeeded)) + + /** Whether the payment attempt succeeded. */ + 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) + } + + fun build(): PaymentAttemptModel = + PaymentAttemptModel( + checkRequired("id", id), + checkRequired("amount", amount), + checkRequired("createdAt", createdAt), + checkRequired("paymentProvider", paymentProvider), + checkRequired("paymentProviderId", paymentProviderId), + checkRequired("succeeded", succeeded), + additionalProperties.toImmutable(), + ) + } + + /** 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PaymentProvider && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PaymentAttemptModel && id == other.id && amount == other.amount && createdAt == other.createdAt && paymentProvider == other.paymentProvider && paymentProviderId == other.paymentProviderId && succeeded == other.succeeded && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, amount, createdAt, paymentProvider, paymentProviderId, succeeded, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PaymentAttemptModel{id=$id, amount=$amount, createdAt=$createdAt, paymentProvider=$paymentProvider, paymentProviderId=$paymentProviderId, succeeded=$succeeded, additionalProperties=$additionalProperties}" +} 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 f537d0244..6f6f7df7e 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 @@ -12,6 +12,7 @@ import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.immutableEmptyMap import com.withorb.api.core.toImmutable @@ -92,6 +93,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [PercentageDiscount]. + * + * The following fields are required: + * ```java + * .appliesToPriceIds() + * .discountType() + * .percentageDiscount() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -134,14 +145,8 @@ private constructor( */ fun addAppliesToPriceId(appliesToPriceId: String) = apply { appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PercentageDiscountIntervalModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PercentageDiscountIntervalModel.kt new file mode 100644 index 000000000..f76e68929 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PercentageDiscountIntervalModel.kt @@ -0,0 +1,370 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class PercentageDiscountIntervalModel +@JsonCreator +private constructor( + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), + @JsonProperty("discount_type") + @ExcludeMissing + private val discountType: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + private val endDate: JsonField = JsonMissing.of(), + @JsonProperty("percentage_discount") + @ExcludeMissing + private val percentageDiscount: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + private val startDate: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** The price ids that this discount interval applies to. */ + fun appliesToPriceIds(): List = appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The price interval ids that this discount interval applies to. */ + fun appliesToPriceIntervalIds(): List = + appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") + + fun discountType(): DiscountType = discountType.getRequired("discount_type") + + /** The end date of the discount interval. */ + fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) + + /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ + fun percentageDiscount(): Double = percentageDiscount.getRequired("percentage_discount") + + /** The start date of the discount interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** The price ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** The price interval ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds + + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType + + /** The end date of the discount interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ + @JsonProperty("percentage_discount") + @ExcludeMissing + fun _percentageDiscount(): JsonField = percentageDiscount + + /** The start date of the discount interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): PercentageDiscountIntervalModel = apply { + if (validated) { + return@apply + } + + appliesToPriceIds() + appliesToPriceIntervalIds() + discountType() + endDate() + percentageDiscount() + startDate() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PercentageDiscountIntervalModel]. + * + * The following fields are required: + * ```java + * .appliesToPriceIds() + * .appliesToPriceIntervalIds() + * .discountType() + * .endDate() + * .percentageDiscount() + * .startDate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PercentageDiscountIntervalModel]. */ + class Builder internal constructor() { + + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var percentageDiscount: JsonField? = null + private var startDate: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(percentageDiscountIntervalModel: PercentageDiscountIntervalModel) = + apply { + appliesToPriceIds = + percentageDiscountIntervalModel.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + percentageDiscountIntervalModel.appliesToPriceIntervalIds.map { + it.toMutableList() + } + discountType = percentageDiscountIntervalModel.discountType + endDate = percentageDiscountIntervalModel.endDate + percentageDiscount = percentageDiscountIntervalModel.percentageDiscount + startDate = percentageDiscountIntervalModel.startDate + additionalProperties = + percentageDiscountIntervalModel.additionalProperties.toMutableMap() + } + + /** The price ids that this discount interval applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price ids that this discount interval applies to. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this discount interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** The price interval ids that this discount interval applies to. */ + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = + appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) + + /** The price interval ids that this discount interval applies to. */ + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds.map { it.toMutableList() } + } + + /** The price interval ids that this discount interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIntervalIds", it).add(appliesToPriceIntervalId) + } + } + + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) + + fun discountType(discountType: JsonField) = apply { + this.discountType = discountType + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the discount interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) + + /** The end date of the discount interval. */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ + fun percentageDiscount(percentageDiscount: Double) = + percentageDiscount(JsonField.of(percentageDiscount)) + + /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ + fun percentageDiscount(percentageDiscount: JsonField) = apply { + this.percentageDiscount = percentageDiscount + } + + /** The start date of the discount interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the discount interval. */ + 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) + } + + fun build(): PercentageDiscountIntervalModel = + PercentageDiscountIntervalModel( + checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, + checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { + it.toImmutable() + }, + checkRequired("discountType", discountType), + checkRequired("endDate", endDate), + checkRequired("percentageDiscount", percentageDiscount), + checkRequired("startDate", startDate), + additionalProperties.toImmutable(), + ) + } + + class DiscountType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PERCENTAGE = of("percentage") + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + /** An enum containing [DiscountType]'s known values. */ + enum class Known { + PERCENTAGE + } + + /** + * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [DiscountType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PERCENTAGE, + /** + * An enum member indicating that [DiscountType] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PERCENTAGE -> Value.PERCENTAGE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + PERCENTAGE -> Known.PERCENTAGE + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PercentageDiscountIntervalModel && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, percentageDiscount, startDate, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PercentageDiscountIntervalModel{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PercentageDiscountModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PercentageDiscountModel.kt new file mode 100644 index 000000000..f8dfd5a38 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PercentageDiscountModel.kt @@ -0,0 +1,313 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class PercentageDiscountModel +@JsonCreator +private constructor( + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("discount_type") + @ExcludeMissing + private val discountType: JsonField = JsonMissing.of(), + @JsonProperty("percentage_discount") + @ExcludeMissing + private val percentageDiscount: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + private val reason: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** + * List of price_ids that this discount applies to. For plan/plan phase discounts, this can be a + * subset of prices. + */ + fun appliesToPriceIds(): List = appliesToPriceIds.getRequired("applies_to_price_ids") + + fun discountType(): DiscountType = discountType.getRequired("discount_type") + + /** Only available if discount_type is `percentage`. This is a number between 0 and 1. */ + fun percentageDiscount(): Double = percentageDiscount.getRequired("percentage_discount") + + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + /** + * List of price_ids that this discount applies to. For plan/plan phase discounts, this can be a + * subset of prices. + */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType + + /** Only available if discount_type is `percentage`. This is a number between 0 and 1. */ + @JsonProperty("percentage_discount") + @ExcludeMissing + fun _percentageDiscount(): JsonField = percentageDiscount + + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): PercentageDiscountModel = apply { + if (validated) { + return@apply + } + + appliesToPriceIds() + discountType() + percentageDiscount() + reason() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PercentageDiscountModel]. + * + * The following fields are required: + * ```java + * .appliesToPriceIds() + * .discountType() + * .percentageDiscount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PercentageDiscountModel]. */ + class Builder internal constructor() { + + private var appliesToPriceIds: JsonField>? = null + private var discountType: JsonField? = null + private var percentageDiscount: JsonField? = null + private var reason: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(percentageDiscountModel: PercentageDiscountModel) = apply { + appliesToPriceIds = percentageDiscountModel.appliesToPriceIds.map { it.toMutableList() } + discountType = percentageDiscountModel.discountType + percentageDiscount = percentageDiscountModel.percentageDiscount + reason = percentageDiscountModel.reason + additionalProperties = percentageDiscountModel.additionalProperties.toMutableMap() + } + + /** + * List of price_ids that this discount applies to. For plan/plan phase discounts, this can + * be a subset of prices. + */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** + * List of price_ids that this discount applies to. For plan/plan phase discounts, this can + * be a subset of prices. + */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this discount applies to. For plan/plan phase discounts, this can + * be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) + + fun discountType(discountType: JsonField) = apply { + this.discountType = discountType + } + + /** Only available if discount_type is `percentage`. This is a number between 0 and 1. */ + fun percentageDiscount(percentageDiscount: Double) = + percentageDiscount(JsonField.of(percentageDiscount)) + + /** Only available if discount_type is `percentage`. This is a number between 0 and 1. */ + fun percentageDiscount(percentageDiscount: JsonField) = apply { + this.percentageDiscount = percentageDiscount + } + + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + fun reason(reason: Optional) = reason(reason.orElse(null)) + + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): PercentageDiscountModel = + PercentageDiscountModel( + checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, + checkRequired("discountType", discountType), + checkRequired("percentageDiscount", percentageDiscount), + reason, + additionalProperties.toImmutable(), + ) + } + + class DiscountType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PERCENTAGE = of("percentage") + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + /** An enum containing [DiscountType]'s known values. */ + enum class Known { + PERCENTAGE + } + + /** + * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [DiscountType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PERCENTAGE, + /** + * An enum member indicating that [DiscountType] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PERCENTAGE -> Value.PERCENTAGE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + PERCENTAGE -> Known.PERCENTAGE + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PercentageDiscountModel && appliesToPriceIds == other.appliesToPriceIds && discountType == other.discountType && percentageDiscount == other.percentageDiscount && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, discountType, percentageDiscount, reason, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PercentageDiscountModel{appliesToPriceIds=$appliesToPriceIds, discountType=$discountType, percentageDiscount=$percentageDiscount, reason=$reason, additionalProperties=$additionalProperties}" +} 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 6de82acd9..2f4d705a7 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 @@ -6,30 +6,20 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.immutableEmptyMap import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import java.util.Objects import java.util.Optional -import kotlin.jvm.optionals.getOrNull /** * The [Plan](/core-concepts#plan-and-price) resource represents a plan that can be subscribed to by @@ -43,10 +33,10 @@ private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("adjustments") @ExcludeMissing - private val adjustments: JsonField> = JsonMissing.of(), + private val adjustments: JsonField> = JsonMissing.of(), @JsonProperty("base_plan") @ExcludeMissing - private val basePlan: JsonField = JsonMissing.of(), + private val basePlan: JsonField = JsonMissing.of(), @JsonProperty("base_plan_id") @ExcludeMissing private val basePlanId: JsonField = JsonMissing.of(), @@ -73,7 +63,7 @@ private constructor( private val invoicingCurrency: JsonField = JsonMissing.of(), @JsonProperty("maximum") @ExcludeMissing - private val maximum: JsonField = JsonMissing.of(), + private val maximum: JsonField = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing private val maximumAmount: JsonField = JsonMissing.of(), @@ -82,7 +72,7 @@ private constructor( private val metadata: JsonField = JsonMissing.of(), @JsonProperty("minimum") @ExcludeMissing - private val minimum: JsonField = JsonMissing.of(), + private val minimum: JsonField = JsonMissing.of(), @JsonProperty("minimum_amount") @ExcludeMissing private val minimumAmount: JsonField = JsonMissing.of(), @@ -95,7 +85,7 @@ private constructor( private val planPhases: JsonField> = JsonMissing.of(), @JsonProperty("prices") @ExcludeMissing - private val prices: JsonField> = JsonMissing.of(), + private val prices: JsonField> = JsonMissing.of(), @JsonProperty("product") @ExcludeMissing private val product: JsonField = JsonMissing.of(), @@ -117,9 +107,10 @@ private constructor( * Adjustments for this plan. If the plan has phases, this includes adjustments across all * phases of the plan. */ - fun adjustments(): List = adjustments.getRequired("adjustments") + fun adjustments(): List = adjustments.getRequired("adjustments") - fun basePlan(): Optional = Optional.ofNullable(basePlan.getNullable("base_plan")) + fun basePlan(): Optional = + Optional.ofNullable(basePlan.getNullable("base_plan")) /** * The parent plan id if the given plan was created by overriding one or more of the parent's @@ -156,7 +147,7 @@ private constructor( */ fun invoicingCurrency(): String = invoicingCurrency.getRequired("invoicing_currency") - fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) @@ -168,7 +159,7 @@ private constructor( */ fun metadata(): Metadata = metadata.getRequired("metadata") - fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) fun minimumAmount(): Optional = Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) @@ -190,7 +181,7 @@ private constructor( * Prices for this plan. If the plan has phases, this includes prices across all phases of the * plan. */ - fun prices(): List = prices.getRequired("prices") + fun prices(): List = prices.getRequired("prices") fun product(): Product = product.getRequired("product") @@ -208,9 +199,11 @@ private constructor( */ @JsonProperty("adjustments") @ExcludeMissing - fun _adjustments(): JsonField> = adjustments + fun _adjustments(): JsonField> = adjustments - @JsonProperty("base_plan") @ExcludeMissing fun _basePlan(): JsonField = basePlan + @JsonProperty("base_plan") + @ExcludeMissing + fun _basePlan(): JsonField = basePlan /** * The parent plan id if the given plan was created by overriding one or more of the parent's @@ -256,7 +249,7 @@ private constructor( @ExcludeMissing fun _invoicingCurrency(): JsonField = invoicingCurrency - @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum @JsonProperty("maximum_amount") @ExcludeMissing @@ -269,7 +262,7 @@ private constructor( */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum @JsonProperty("minimum_amount") @ExcludeMissing @@ -293,7 +286,7 @@ private constructor( * Prices for this plan. If the plan has phases, this includes prices across all phases of the * plan. */ - @JsonProperty("prices") @ExcludeMissing fun _prices(): JsonField> = prices + @JsonProperty("prices") @ExcludeMissing fun _prices(): JsonField> = prices @JsonProperty("product") @ExcludeMissing fun _product(): JsonField = product @@ -347,6 +340,37 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Plan]. + * + * The following fields are required: + * ```java + * .id() + * .adjustments() + * .basePlan() + * .basePlanId() + * .createdAt() + * .currency() + * .defaultInvoiceMemo() + * .description() + * .discount() + * .externalPlanId() + * .invoicingCurrency() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .name() + * .netTerms() + * .planPhases() + * .prices() + * .product() + * .status() + * .trialConfig() + * .version() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -354,8 +378,8 @@ private constructor( class Builder internal constructor() { private var id: JsonField? = null - private var adjustments: JsonField>? = null - private var basePlan: JsonField? = null + private var adjustments: JsonField>? = null + private var basePlan: JsonField? = null private var basePlanId: JsonField? = null private var createdAt: JsonField? = null private var currency: JsonField? = null @@ -364,15 +388,15 @@ private constructor( private var discount: JsonField? = null private var externalPlanId: JsonField? = null private var invoicingCurrency: JsonField? = null - private var maximum: JsonField? = null + private var maximum: JsonField? = null private var maximumAmount: JsonField? = null private var metadata: JsonField? = null - private var minimum: JsonField? = null + private var minimum: JsonField? = null private var minimumAmount: JsonField? = null private var name: JsonField? = null private var netTerms: JsonField? = null private var planPhases: JsonField>? = null - private var prices: JsonField>? = null + private var prices: JsonField>? = null private var product: JsonField? = null private var status: JsonField? = null private var trialConfig: JsonField? = null @@ -416,13 +440,13 @@ private constructor( * Adjustments for this plan. If the plan has phases, this includes adjustments across all * phases of the plan. */ - fun adjustments(adjustments: List) = adjustments(JsonField.of(adjustments)) + fun adjustments(adjustments: List) = adjustments(JsonField.of(adjustments)) /** * Adjustments for this plan. If the plan has phases, this includes adjustments across all * phases of the plan. */ - fun adjustments(adjustments: JsonField>) = apply { + fun adjustments(adjustments: JsonField>) = apply { this.adjustments = adjustments.map { it.toMutableList() } } @@ -430,16 +454,10 @@ private constructor( * Adjustments for this plan. If the plan has phases, this includes adjustments across all * phases of the plan. */ - fun addAdjustment(adjustment: Adjustment) = apply { + fun addAdjustment(adjustment: AdjustmentModel) = apply { adjustments = - (adjustments ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(adjustment) + (adjustments ?: JsonField.of(mutableListOf())).also { + checkKnown("adjustments", it).add(adjustment) } } @@ -447,43 +465,59 @@ private constructor( * Adjustments for this plan. If the plan has phases, this includes adjustments across all * phases of the plan. */ - fun addAdjustment(planPhaseUsageDiscount: Adjustment.PlanPhaseUsageDiscountAdjustment) = - addAdjustment(Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)) + fun addAdjustment( + planPhaseUsageDiscountAdjustment: AdjustmentModel.PlanPhaseUsageDiscountAdjustment + ) = + addAdjustment( + AdjustmentModel.ofPlanPhaseUsageDiscountAdjustment(planPhaseUsageDiscountAdjustment) + ) /** * Adjustments for this plan. If the plan has phases, this includes adjustments across all * phases of the plan. */ - fun addAdjustment(planPhaseAmountDiscount: Adjustment.PlanPhaseAmountDiscountAdjustment) = - addAdjustment(Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)) + fun addAdjustment( + planPhaseAmountDiscountAdjustment: AdjustmentModel.PlanPhaseAmountDiscountAdjustment + ) = + addAdjustment( + AdjustmentModel.ofPlanPhaseAmountDiscountAdjustment( + planPhaseAmountDiscountAdjustment + ) + ) /** * Adjustments for this plan. If the plan has phases, this includes adjustments across all * phases of the plan. */ fun addAdjustment( - planPhasePercentageDiscount: Adjustment.PlanPhasePercentageDiscountAdjustment - ) = addAdjustment(Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)) + planPhasePercentageDiscountAdjustment: + AdjustmentModel.PlanPhasePercentageDiscountAdjustment + ) = + addAdjustment( + AdjustmentModel.ofPlanPhasePercentageDiscountAdjustment( + planPhasePercentageDiscountAdjustment + ) + ) /** * Adjustments for this plan. If the plan has phases, this includes adjustments across all * phases of the plan. */ - fun addAdjustment(planPhaseMinimum: Adjustment.PlanPhaseMinimumAdjustment) = - addAdjustment(Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)) + fun addAdjustment(planPhaseMinimumAdjustment: AdjustmentModel.PlanPhaseMinimumAdjustment) = + addAdjustment(AdjustmentModel.ofPlanPhaseMinimumAdjustment(planPhaseMinimumAdjustment)) /** * Adjustments for this plan. If the plan has phases, this includes adjustments across all * phases of the plan. */ - fun addAdjustment(planPhaseMaximum: Adjustment.PlanPhaseMaximumAdjustment) = - addAdjustment(Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)) + fun addAdjustment(planPhaseMaximumAdjustment: AdjustmentModel.PlanPhaseMaximumAdjustment) = + addAdjustment(AdjustmentModel.ofPlanPhaseMaximumAdjustment(planPhaseMaximumAdjustment)) - fun basePlan(basePlan: BasePlan?) = basePlan(JsonField.ofNullable(basePlan)) + fun basePlan(basePlan: PlanMinifiedModel?) = basePlan(JsonField.ofNullable(basePlan)) - fun basePlan(basePlan: Optional) = basePlan(basePlan.orElse(null)) + fun basePlan(basePlan: Optional) = basePlan(basePlan.orElse(null)) - fun basePlan(basePlan: JsonField) = apply { this.basePlan = basePlan } + fun basePlan(basePlan: JsonField) = apply { this.basePlan = basePlan } /** * The parent plan id if the given plan was created by overriding one or more of the @@ -606,11 +640,11 @@ private constructor( this.invoicingCurrency = invoicingCurrency } - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) - fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } fun maximumAmount(maximumAmount: String?) = maximumAmount(JsonField.ofNullable(maximumAmount)) @@ -636,11 +670,11 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) - fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } fun minimumAmount(minimumAmount: String?) = minimumAmount(JsonField.ofNullable(minimumAmount)) @@ -699,14 +733,8 @@ private constructor( fun addPlanPhase(planPhase: PlanPhase) = apply { planPhases = - (planPhases ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(planPhase) + (planPhases ?: JsonField.of(mutableListOf())).also { + checkKnown("planPhases", it).add(planPhase) } } @@ -714,13 +742,13 @@ private constructor( * Prices for this plan. If the plan has phases, this includes prices across all phases of * the plan. */ - fun prices(prices: List) = prices(JsonField.of(prices)) + fun prices(prices: List) = prices(JsonField.of(prices)) /** * Prices for this plan. If the plan has phases, this includes prices across all phases of * the plan. */ - fun prices(prices: JsonField>) = apply { + fun prices(prices: JsonField>) = apply { this.prices = prices.map { it.toMutableList() } } @@ -728,16 +756,10 @@ private constructor( * Prices for this plan. If the plan has phases, this includes prices across all phases of * the plan. */ - fun addPrice(price: Price) = apply { + fun addPrice(price: PriceModel) = apply { prices = - (prices ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(price) + (prices ?: JsonField.of(mutableListOf())).also { + checkKnown("prices", it).add(price) } } @@ -745,190 +767,204 @@ private constructor( * Prices for this plan. If the plan has phases, this includes prices across all phases of * the plan. */ - fun addPrice(unit: Price.UnitPrice) = addPrice(Price.ofUnit(unit)) + fun addPrice(unitPrice: PriceModel.UnitPrice) = addPrice(PriceModel.ofUnitPrice(unitPrice)) /** * Prices for this plan. If the plan has phases, this includes prices across all phases of * the plan. */ - fun addPrice(packagePrice: Price.PackagePrice) = - addPrice(Price.ofPackagePrice(packagePrice)) + fun addPrice(packagePrice: PriceModel.PackagePrice) = + addPrice(PriceModel.ofPackagePrice(packagePrice)) /** * Prices for this plan. If the plan has phases, this includes prices across all phases of * the plan. */ - fun addPrice(matrix: Price.MatrixPrice) = addPrice(Price.ofMatrix(matrix)) + fun addPrice(matrixPrice: PriceModel.MatrixPrice) = + addPrice(PriceModel.ofMatrixPrice(matrixPrice)) /** * Prices for this plan. If the plan has phases, this includes prices across all phases of * the plan. */ - fun addPrice(tiered: Price.TieredPrice) = addPrice(Price.ofTiered(tiered)) + fun addPrice(tieredPrice: PriceModel.TieredPrice) = + addPrice(PriceModel.ofTieredPrice(tieredPrice)) /** * Prices for this plan. If the plan has phases, this includes prices across all phases of * the plan. */ - fun addPrice(tieredBps: Price.TieredBpsPrice) = addPrice(Price.ofTieredBps(tieredBps)) + fun addPrice(tieredBpsPrice: PriceModel.TieredBpsPrice) = + addPrice(PriceModel.ofTieredBpsPrice(tieredBpsPrice)) /** * Prices for this plan. If the plan has phases, this includes prices across all phases of * the plan. */ - fun addPrice(bps: Price.BpsPrice) = addPrice(Price.ofBps(bps)) + fun addPrice(bpsPrice: PriceModel.BpsPrice) = addPrice(PriceModel.ofBpsPrice(bpsPrice)) /** * Prices for this plan. If the plan has phases, this includes prices across all phases of * the plan. */ - fun addPrice(bulkBps: Price.BulkBpsPrice) = addPrice(Price.ofBulkBps(bulkBps)) + fun addPrice(bulkBpsPrice: PriceModel.BulkBpsPrice) = + addPrice(PriceModel.ofBulkBpsPrice(bulkBpsPrice)) /** * Prices for this plan. If the plan has phases, this includes prices across all phases of * the plan. */ - fun addPrice(bulk: Price.BulkPrice) = addPrice(Price.ofBulk(bulk)) + fun addPrice(bulkPrice: PriceModel.BulkPrice) = addPrice(PriceModel.ofBulkPrice(bulkPrice)) /** * Prices for this plan. If the plan has phases, this includes prices across all phases of * the plan. */ - fun addPrice(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = - addPrice(Price.ofThresholdTotalAmount(thresholdTotalAmount)) + fun addPrice(thresholdTotalAmountPrice: PriceModel.ThresholdTotalAmountPrice) = + addPrice(PriceModel.ofThresholdTotalAmountPrice(thresholdTotalAmountPrice)) /** * Prices for this plan. If the plan has phases, this includes prices across all phases of * the plan. */ - fun addPrice(tieredPackage: Price.TieredPackagePrice) = - addPrice(Price.ofTieredPackage(tieredPackage)) + fun addPrice(tieredPackagePrice: PriceModel.TieredPackagePrice) = + addPrice(PriceModel.ofTieredPackagePrice(tieredPackagePrice)) /** * Prices for this plan. If the plan has phases, this includes prices across all phases of * the plan. */ - fun addPrice(groupedTiered: Price.GroupedTieredPrice) = - addPrice(Price.ofGroupedTiered(groupedTiered)) + fun addPrice(groupedTieredPrice: PriceModel.GroupedTieredPrice) = + addPrice(PriceModel.ofGroupedTieredPrice(groupedTieredPrice)) /** * Prices for this plan. If the plan has phases, this includes prices across all phases of * the plan. */ - fun addPrice(tieredWithMinimum: Price.TieredWithMinimumPrice) = - addPrice(Price.ofTieredWithMinimum(tieredWithMinimum)) + fun addPrice(tieredWithMinimumPrice: PriceModel.TieredWithMinimumPrice) = + addPrice(PriceModel.ofTieredWithMinimumPrice(tieredWithMinimumPrice)) /** * Prices for this plan. If the plan has phases, this includes prices across all phases of * the plan. */ - fun addPrice(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = - addPrice(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) + fun addPrice(tieredPackageWithMinimumPrice: PriceModel.TieredPackageWithMinimumPrice) = + addPrice(PriceModel.ofTieredPackageWithMinimumPrice(tieredPackageWithMinimumPrice)) /** * Prices for this plan. If the plan has phases, this includes prices across all phases of * the plan. */ - fun addPrice(packageWithAllocation: Price.PackageWithAllocationPrice) = - addPrice(Price.ofPackageWithAllocation(packageWithAllocation)) + fun addPrice(packageWithAllocationPrice: PriceModel.PackageWithAllocationPrice) = + addPrice(PriceModel.ofPackageWithAllocationPrice(packageWithAllocationPrice)) /** * Prices for this plan. If the plan has phases, this includes prices across all phases of * the plan. */ - fun addPrice(unitWithPercent: Price.UnitWithPercentPrice) = - addPrice(Price.ofUnitWithPercent(unitWithPercent)) + fun addPrice(unitWithPercentPrice: PriceModel.UnitWithPercentPrice) = + addPrice(PriceModel.ofUnitWithPercentPrice(unitWithPercentPrice)) /** * Prices for this plan. If the plan has phases, this includes prices across all phases of * the plan. */ - fun addPrice(matrixWithAllocation: Price.MatrixWithAllocationPrice) = - addPrice(Price.ofMatrixWithAllocation(matrixWithAllocation)) + fun addPrice(matrixWithAllocationPrice: PriceModel.MatrixWithAllocationPrice) = + addPrice(PriceModel.ofMatrixWithAllocationPrice(matrixWithAllocationPrice)) /** * Prices for this plan. If the plan has phases, this includes prices across all phases of * the plan. */ - fun addPrice(tieredWithProration: Price.TieredWithProrationPrice) = - addPrice(Price.ofTieredWithProration(tieredWithProration)) + fun addPrice(tieredWithProrationPrice: PriceModel.TieredWithProrationPrice) = + addPrice(PriceModel.ofTieredWithProrationPrice(tieredWithProrationPrice)) /** * Prices for this plan. If the plan has phases, this includes prices across all phases of * the plan. */ - fun addPrice(unitWithProration: Price.UnitWithProrationPrice) = - addPrice(Price.ofUnitWithProration(unitWithProration)) + fun addPrice(unitWithProrationPrice: PriceModel.UnitWithProrationPrice) = + addPrice(PriceModel.ofUnitWithProrationPrice(unitWithProrationPrice)) /** * Prices for this plan. If the plan has phases, this includes prices across all phases of * the plan. */ - fun addPrice(groupedAllocation: Price.GroupedAllocationPrice) = - addPrice(Price.ofGroupedAllocation(groupedAllocation)) + fun addPrice(groupedAllocationPrice: PriceModel.GroupedAllocationPrice) = + addPrice(PriceModel.ofGroupedAllocationPrice(groupedAllocationPrice)) /** * Prices for this plan. If the plan has phases, this includes prices across all phases of * the plan. */ - fun addPrice(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = - addPrice(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) + fun addPrice(groupedWithProratedMinimumPrice: PriceModel.GroupedWithProratedMinimumPrice) = + addPrice(PriceModel.ofGroupedWithProratedMinimumPrice(groupedWithProratedMinimumPrice)) /** * Prices for this plan. If the plan has phases, this includes prices across all phases of * the plan. */ - fun addPrice(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = - addPrice(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) + fun addPrice(groupedWithMeteredMinimumPrice: PriceModel.GroupedWithMeteredMinimumPrice) = + addPrice(PriceModel.ofGroupedWithMeteredMinimumPrice(groupedWithMeteredMinimumPrice)) /** * Prices for this plan. If the plan has phases, this includes prices across all phases of * the plan. */ - fun addPrice(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = - addPrice(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) + fun addPrice(matrixWithDisplayNamePrice: PriceModel.MatrixWithDisplayNamePrice) = + addPrice(PriceModel.ofMatrixWithDisplayNamePrice(matrixWithDisplayNamePrice)) /** * Prices for this plan. If the plan has phases, this includes prices across all phases of * the plan. */ - fun addPrice(bulkWithProration: Price.BulkWithProrationPrice) = - addPrice(Price.ofBulkWithProration(bulkWithProration)) + fun addPrice(bulkWithProrationPrice: PriceModel.BulkWithProrationPrice) = + addPrice(PriceModel.ofBulkWithProrationPrice(bulkWithProrationPrice)) /** * Prices for this plan. If the plan has phases, this includes prices across all phases of * the plan. */ - fun addPrice(groupedTieredPackage: Price.GroupedTieredPackagePrice) = - addPrice(Price.ofGroupedTieredPackage(groupedTieredPackage)) + fun addPrice(groupedTieredPackagePrice: PriceModel.GroupedTieredPackagePrice) = + addPrice(PriceModel.ofGroupedTieredPackagePrice(groupedTieredPackagePrice)) /** * Prices for this plan. If the plan has phases, this includes prices across all phases of * the plan. */ - fun addPrice(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = - addPrice(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) + fun addPrice(maxGroupTieredPackagePrice: PriceModel.MaxGroupTieredPackagePrice) = + addPrice(PriceModel.ofMaxGroupTieredPackagePrice(maxGroupTieredPackagePrice)) /** * Prices for this plan. If the plan has phases, this includes prices across all phases of * the plan. */ - fun addPrice(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = - addPrice(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) + fun addPrice( + scalableMatrixWithUnitPricingPrice: PriceModel.ScalableMatrixWithUnitPricingPrice + ) = + addPrice( + PriceModel.ofScalableMatrixWithUnitPricingPrice(scalableMatrixWithUnitPricingPrice) + ) /** * Prices for this plan. If the plan has phases, this includes prices across all phases of * the plan. */ - fun addPrice(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice) = - addPrice(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + fun addPrice( + scalableMatrixWithTieredPricingPrice: PriceModel.ScalableMatrixWithTieredPricingPrice + ) = + addPrice( + PriceModel.ofScalableMatrixWithTieredPricingPrice( + scalableMatrixWithTieredPricingPrice + ) + ) /** * Prices for this plan. If the plan has phases, this includes prices across all phases of * the plan. */ - fun addPrice(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = - addPrice(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) + fun addPrice(cumulativeGroupedBulkPrice: PriceModel.CumulativeGroupedBulkPrice) = + addPrice(PriceModel.ofCumulativeGroupedBulkPrice(cumulativeGroupedBulkPrice)) fun product(product: Product) = product(JsonField.of(product)) @@ -977,2608 +1013,24 @@ private constructor( checkRequired("currency", currency), checkRequired("defaultInvoiceMemo", defaultInvoiceMemo), checkRequired("description", description), - checkRequired("discount", discount), - checkRequired("externalPlanId", externalPlanId), - checkRequired("invoicingCurrency", invoicingCurrency), - checkRequired("maximum", maximum), - checkRequired("maximumAmount", maximumAmount), - checkRequired("metadata", metadata), - checkRequired("minimum", minimum), - checkRequired("minimumAmount", minimumAmount), - checkRequired("name", name), - checkRequired("netTerms", netTerms), - checkRequired("planPhases", planPhases).map { it.toImmutable() }, - checkRequired("prices", prices).map { it.toImmutable() }, - checkRequired("product", product), - checkRequired("status", status), - checkRequired("trialConfig", trialConfig), - checkRequired("version", version), - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment? = null, - private val planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment? = null, - private val planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment? = null, - private val planPhaseMinimum: PlanPhaseMinimumAdjustment? = null, - private val planPhaseMaximum: PlanPhaseMaximumAdjustment? = null, - private val _json: JsonValue? = null, - ) { - - fun planPhaseUsageDiscount(): Optional = - Optional.ofNullable(planPhaseUsageDiscount) - - fun planPhaseAmountDiscount(): Optional = - Optional.ofNullable(planPhaseAmountDiscount) - - fun planPhasePercentageDiscount(): Optional = - Optional.ofNullable(planPhasePercentageDiscount) - - fun planPhaseMinimum(): Optional = - Optional.ofNullable(planPhaseMinimum) - - fun planPhaseMaximum(): Optional = - Optional.ofNullable(planPhaseMaximum) - - fun isPlanPhaseUsageDiscount(): Boolean = planPhaseUsageDiscount != null - - fun isPlanPhaseAmountDiscount(): Boolean = planPhaseAmountDiscount != null - - fun isPlanPhasePercentageDiscount(): Boolean = planPhasePercentageDiscount != null - - fun isPlanPhaseMinimum(): Boolean = planPhaseMinimum != null - - fun isPlanPhaseMaximum(): Boolean = planPhaseMaximum != null - - fun asPlanPhaseUsageDiscount(): PlanPhaseUsageDiscountAdjustment = - planPhaseUsageDiscount.getOrThrow("planPhaseUsageDiscount") - - fun asPlanPhaseAmountDiscount(): PlanPhaseAmountDiscountAdjustment = - planPhaseAmountDiscount.getOrThrow("planPhaseAmountDiscount") - - fun asPlanPhasePercentageDiscount(): PlanPhasePercentageDiscountAdjustment = - planPhasePercentageDiscount.getOrThrow("planPhasePercentageDiscount") - - fun asPlanPhaseMinimum(): PlanPhaseMinimumAdjustment = - planPhaseMinimum.getOrThrow("planPhaseMinimum") - - fun asPlanPhaseMaximum(): PlanPhaseMaximumAdjustment = - planPhaseMaximum.getOrThrow("planPhaseMaximum") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - planPhaseUsageDiscount != null -> - visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) - planPhaseAmountDiscount != null -> - visitor.visitPlanPhaseAmountDiscount(planPhaseAmountDiscount) - planPhasePercentageDiscount != null -> - visitor.visitPlanPhasePercentageDiscount(planPhasePercentageDiscount) - planPhaseMinimum != null -> visitor.visitPlanPhaseMinimum(planPhaseMinimum) - planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) { - planPhaseUsageDiscount.validate() - } - - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) { - planPhaseAmountDiscount.validate() - } - - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) { - planPhasePercentageDiscount.validate() - } - - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) { - planPhaseMinimum.validate() - } - - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) { - planPhaseMaximum.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Adjustment && planPhaseUsageDiscount == other.planPhaseUsageDiscount && planPhaseAmountDiscount == other.planPhaseAmountDiscount && planPhasePercentageDiscount == other.planPhasePercentageDiscount && planPhaseMinimum == other.planPhaseMinimum && planPhaseMaximum == other.planPhaseMaximum /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(planPhaseUsageDiscount, planPhaseAmountDiscount, planPhasePercentageDiscount, planPhaseMinimum, planPhaseMaximum) /* spotless:on */ - - override fun toString(): String = - when { - planPhaseUsageDiscount != null -> - "Adjustment{planPhaseUsageDiscount=$planPhaseUsageDiscount}" - planPhaseAmountDiscount != null -> - "Adjustment{planPhaseAmountDiscount=$planPhaseAmountDiscount}" - planPhasePercentageDiscount != null -> - "Adjustment{planPhasePercentageDiscount=$planPhasePercentageDiscount}" - planPhaseMinimum != null -> "Adjustment{planPhaseMinimum=$planPhaseMinimum}" - planPhaseMaximum != null -> "Adjustment{planPhaseMaximum=$planPhaseMaximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } - - companion object { - - @JvmStatic - fun ofPlanPhaseUsageDiscount(planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment) = - Adjustment(planPhaseUsageDiscount = planPhaseUsageDiscount) - - @JvmStatic - fun ofPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = Adjustment(planPhaseAmountDiscount = planPhaseAmountDiscount) - - @JvmStatic - fun ofPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = Adjustment(planPhasePercentageDiscount = planPhasePercentageDiscount) - - @JvmStatic - fun ofPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment) = - Adjustment(planPhaseMinimum = planPhaseMinimum) - - @JvmStatic - fun ofPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment) = - Adjustment(planPhaseMaximum = planPhaseMaximum) - } - - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type [T]. - */ - interface Visitor { - - fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ): T - - fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ): T - - fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ): T - - fun visitPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment): T - - fun visitPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment): T - - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the SDK - * is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } - - internal class Deserializer : BaseDeserializer(Adjustment::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = - json.asObject().getOrNull()?.get("adjustment_type")?.asString()?.getOrNull() - - when (adjustmentType) { - "usage_discount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseUsageDiscount = it, _json = json) - } - } - "amount_discount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseAmountDiscount = it, _json = json) - } - } - "percentage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhasePercentageDiscount = it, _json = json) - } - } - "minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMinimum = it, _json = json) - } - } - "maximum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMaximum = it, _json = json) - } - } - } - - return Adjustment(_json = json) - } - } - - internal class Serializer : BaseSerializer(Adjustment::class) { - - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.planPhaseUsageDiscount != null -> - generator.writeObject(value.planPhaseUsageDiscount) - value.planPhaseAmountDiscount != null -> - generator.writeObject(value.planPhaseAmountDiscount) - value.planPhasePercentageDiscount != null -> - generator.writeObject(value.planPhasePercentageDiscount) - value.planPhaseMinimum != null -> generator.writeObject(value.planPhaseMinimum) - value.planPhaseMaximum != null -> generator.writeObject(value.planPhaseMaximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") - } - } - } - - @NoAutoDetect - class PlanPhaseUsageDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonProperty("usage_discount") - @ExcludeMissing - private val usageDiscount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - /** - * The number of usage units by which to discount the price this adjustment applies to - * in a given billing period. - */ - fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - /** - * The number of usage units by which to discount the price this adjustment applies to - * in a given billing period. - */ - @JsonProperty("usage_discount") - @ExcludeMissing - fun _usageDiscount(): JsonField = usageDiscount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseUsageDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - planPhaseOrder() - reason() - usageDiscount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseUsageDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var usageDiscount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - planPhaseUsageDiscountAdjustment: PlanPhaseUsageDiscountAdjustment - ) = apply { - id = planPhaseUsageDiscountAdjustment.id - adjustmentType = planPhaseUsageDiscountAdjustment.adjustmentType - appliesToPriceIds = - planPhaseUsageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseUsageDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseUsageDiscountAdjustment.planPhaseOrder - reason = planPhaseUsageDiscountAdjustment.reason - usageDiscount = planPhaseUsageDiscountAdjustment.usageDiscount - additionalProperties = - planPhaseUsageDiscountAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - /** - * The number of usage units by which to discount the price this adjustment applies - * to in a given billing period. - */ - fun usageDiscount(usageDiscount: Double) = - usageDiscount(JsonField.of(usageDiscount)) - - /** - * The number of usage units by which to discount the price this adjustment applies - * to in a given billing period. - */ - fun usageDiscount(usageDiscount: JsonField) = apply { - this.usageDiscount = usageDiscount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseUsageDiscountAdjustment = - PlanPhaseUsageDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - checkRequired("usageDiscount", usageDiscount), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE_DISCOUNT -> Known.USAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseUsageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, planPhaseOrder, reason, usageDiscount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseUsageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhaseAmountDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("amount_discount") - @ExcludeMissing - private val amountDiscount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** - * The amount by which to discount the prices this adjustment applies to in a given - * billing period. - */ - fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** - * The amount by which to discount the prices this adjustment applies to in a given - * billing period. - */ - @JsonProperty("amount_discount") - @ExcludeMissing - fun _amountDiscount(): JsonField = amountDiscount - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseAmountDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - amountDiscount() - appliesToPriceIds() - isInvoiceLevel() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseAmountDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var amountDiscount: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - planPhaseAmountDiscountAdjustment: PlanPhaseAmountDiscountAdjustment - ) = apply { - id = planPhaseAmountDiscountAdjustment.id - adjustmentType = planPhaseAmountDiscountAdjustment.adjustmentType - amountDiscount = planPhaseAmountDiscountAdjustment.amountDiscount - appliesToPriceIds = - planPhaseAmountDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseAmountDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseAmountDiscountAdjustment.planPhaseOrder - reason = planPhaseAmountDiscountAdjustment.reason - additionalProperties = - planPhaseAmountDiscountAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** - * The amount by which to discount the prices this adjustment applies to in a given - * billing period. - */ - fun amountDiscount(amountDiscount: String) = - amountDiscount(JsonField.of(amountDiscount)) - - /** - * The amount by which to discount the prices this adjustment applies to in a given - * billing period. - */ - fun amountDiscount(amountDiscount: JsonField) = apply { - this.amountDiscount = amountDiscount - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseAmountDiscountAdjustment = - PlanPhaseAmountDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("amountDiscount", amountDiscount), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseAmountDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, amountDiscount, appliesToPriceIds, isInvoiceLevel, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseAmountDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhasePercentageDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("percentage_discount") - @ExcludeMissing - private val percentageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** - * The percentage (as a value between 0 and 1) by which to discount the price intervals - * this adjustment applies to in a given billing period. - */ - fun percentageDiscount(): Double = percentageDiscount.getRequired("percentage_discount") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** - * The percentage (as a value between 0 and 1) by which to discount the price intervals - * this adjustment applies to in a given billing period. - */ - @JsonProperty("percentage_discount") - @ExcludeMissing - fun _percentageDiscount(): JsonField = percentageDiscount - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhasePercentageDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - percentageDiscount() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhasePercentageDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var percentageDiscount: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - planPhasePercentageDiscountAdjustment: PlanPhasePercentageDiscountAdjustment - ) = apply { - id = planPhasePercentageDiscountAdjustment.id - adjustmentType = planPhasePercentageDiscountAdjustment.adjustmentType - appliesToPriceIds = - planPhasePercentageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhasePercentageDiscountAdjustment.isInvoiceLevel - percentageDiscount = planPhasePercentageDiscountAdjustment.percentageDiscount - planPhaseOrder = planPhasePercentageDiscountAdjustment.planPhaseOrder - reason = planPhasePercentageDiscountAdjustment.reason - additionalProperties = - planPhasePercentageDiscountAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(percentageDiscount: Double) = - percentageDiscount(JsonField.of(percentageDiscount)) - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(percentageDiscount: JsonField) = apply { - this.percentageDiscount = percentageDiscount - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhasePercentageDiscountAdjustment = - PlanPhasePercentageDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("percentageDiscount", percentageDiscount), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val PERCENTAGE_DISCOUNT = of("percentage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhasePercentageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, percentageDiscount, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhasePercentageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhaseMinimumAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(): String = itemId.getRequired("item_id") - - /** - * The minimum amount to charge in a given billing period for the prices this adjustment - * applies to. - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The item ID that revenue from this minimum will be attributed to. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - /** - * The minimum amount to charge in a given billing period for the prices this adjustment - * applies to. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseMinimumAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - itemId() - minimumAmount() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseMinimumAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var itemId: JsonField? = null - private var minimumAmount: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(planPhaseMinimumAdjustment: PlanPhaseMinimumAdjustment) = apply { - id = planPhaseMinimumAdjustment.id - adjustmentType = planPhaseMinimumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMinimumAdjustment.appliesToPriceIds.map { it.toMutableList() } - isInvoiceLevel = planPhaseMinimumAdjustment.isInvoiceLevel - itemId = planPhaseMinimumAdjustment.itemId - minimumAmount = planPhaseMinimumAdjustment.minimumAmount - planPhaseOrder = planPhaseMinimumAdjustment.planPhaseOrder - reason = planPhaseMinimumAdjustment.reason - additionalProperties = - planPhaseMinimumAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseMinimumAdjustment = - PlanPhaseMinimumAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("itemId", itemId), - checkRequired("minimumAmount", minimumAmount), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseMinimumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, itemId, minimumAmount, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseMinimumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhaseMaximumAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** - * The maximum amount to charge in a given billing period for the prices this adjustment - * applies to. - */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** - * The maximum amount to charge in a given billing period for the prices this adjustment - * applies to. - */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseMaximumAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - maximumAmount() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseMaximumAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var maximumAmount: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(planPhaseMaximumAdjustment: PlanPhaseMaximumAdjustment) = apply { - id = planPhaseMaximumAdjustment.id - adjustmentType = planPhaseMaximumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMaximumAdjustment.appliesToPriceIds.map { it.toMutableList() } - isInvoiceLevel = planPhaseMaximumAdjustment.isInvoiceLevel - maximumAmount = planPhaseMaximumAdjustment.maximumAmount - planPhaseOrder = planPhaseMaximumAdjustment.planPhaseOrder - reason = planPhaseMaximumAdjustment.reason - additionalProperties = - planPhaseMaximumAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseMaximumAdjustment = - PlanPhaseMaximumAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("maximumAmount", maximumAmount), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseMaximumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, maximumAmount, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseMaximumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - } - - @NoAutoDetect - class BasePlan - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("external_plan_id") - @ExcludeMissing - private val externalPlanId: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): Optional = Optional.ofNullable(id.getNullable("id")) - - /** - * An optional user-defined ID for this plan resource, used throughout the system as an - * alias for this Plan. Use this field to identify a plan by an existing identifier in your - * system. - */ - fun externalPlanId(): Optional = - Optional.ofNullable(externalPlanId.getNullable("external_plan_id")) - - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * An optional user-defined ID for this plan resource, used throughout the system as an - * alias for this Plan. Use this field to identify a plan by an existing identifier in your - * system. - */ - @JsonProperty("external_plan_id") - @ExcludeMissing - fun _externalPlanId(): JsonField = externalPlanId - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BasePlan = apply { - if (validated) { - return@apply - } - - id() - externalPlanId() - name() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BasePlan]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var externalPlanId: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(basePlan: BasePlan) = apply { - id = basePlan.id - externalPlanId = basePlan.externalPlanId - name = basePlan.name - additionalProperties = basePlan.additionalProperties.toMutableMap() - } - - fun id(id: String?) = id(JsonField.ofNullable(id)) - - fun id(id: Optional) = id(id.orElse(null)) - - fun id(id: JsonField) = apply { this.id = id } - - /** - * An optional user-defined ID for this plan resource, used throughout the system as an - * alias for this Plan. Use this field to identify a plan by an existing identifier in - * your system. - */ - fun externalPlanId(externalPlanId: String?) = - externalPlanId(JsonField.ofNullable(externalPlanId)) - - /** - * An optional user-defined ID for this plan resource, used throughout the system as an - * alias for this Plan. Use this field to identify a plan by an existing identifier in - * your system. - */ - fun externalPlanId(externalPlanId: Optional) = - externalPlanId(externalPlanId.orElse(null)) - - /** - * An optional user-defined ID for this plan resource, used throughout the system as an - * alias for this Plan. Use this field to identify a plan by an existing identifier in - * your system. - */ - fun externalPlanId(externalPlanId: JsonField) = apply { - this.externalPlanId = externalPlanId - } - - fun name(name: String?) = name(JsonField.ofNullable(name)) - - fun name(name: Optional) = name(name.orElse(null)) - - 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) - } - - fun build(): BasePlan = - BasePlan( - checkRequired("id", id), - checkRequired("externalPlanId", externalPlanId), - checkRequired("name", name), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BasePlan && id == other.id && externalPlanId == other.externalPlanId && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, externalPlanId, name, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BasePlan{id=$id, externalPlanId=$externalPlanId, name=$name, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Maximum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, this - * can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Maximum amount applied */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, this - * can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Maximum amount applied */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Maximum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - maximumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Maximum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = maximum.maximumAmount - additionalProperties = maximum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Maximum = - Maximum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, - checkRequired("maximumAmount", maximumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Maximum && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, maximumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Maximum{appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, additionalProperties=$additionalProperties}" + checkRequired("discount", discount), + checkRequired("externalPlanId", externalPlanId), + checkRequired("invoicingCurrency", invoicingCurrency), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("name", name), + checkRequired("netTerms", netTerms), + checkRequired("planPhases", planPhases).map { it.toImmutable() }, + checkRequired("prices", prices).map { it.toImmutable() }, + checkRequired("product", product), + checkRequired("status", status), + checkRequired("trialConfig", trialConfig), + checkRequired("version", version), + additionalProperties.toImmutable(), + ) } /** @@ -3612,6 +1064,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } @@ -3664,165 +1117,6 @@ private constructor( override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - @NoAutoDetect - class Minimum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, this - * can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Minimum amount applied */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, this - * can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Minimum amount applied */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Minimum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - minimumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Minimum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var minimumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } - minimumAmount = minimum.minimumAmount - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Minimum = - Minimum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, - checkRequired("minimumAmount", minimumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Minimum && appliesToPriceIds == other.appliesToPriceIds && minimumAmount == other.minimumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, minimumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" - } - @NoAutoDetect class PlanPhase @JsonCreator @@ -3842,13 +1136,13 @@ private constructor( private val durationUnit: JsonField = JsonMissing.of(), @JsonProperty("maximum") @ExcludeMissing - private val maximum: JsonField = JsonMissing.of(), + private val maximum: JsonField = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing private val maximumAmount: JsonField = JsonMissing.of(), @JsonProperty("minimum") @ExcludeMissing - private val minimum: JsonField = JsonMissing.of(), + private val minimum: JsonField = JsonMissing.of(), @JsonProperty("minimum_amount") @ExcludeMissing private val minimumAmount: JsonField = JsonMissing.of(), @@ -3878,12 +1172,12 @@ private constructor( fun durationUnit(): Optional = Optional.ofNullable(durationUnit.getNullable("duration_unit")) - fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) fun minimumAmount(): Optional = Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) @@ -3911,13 +1205,13 @@ private constructor( @ExcludeMissing fun _durationUnit(): JsonField = durationUnit - @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount(): JsonField = maximumAmount - @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum @JsonProperty("minimum_amount") @ExcludeMissing @@ -3957,6 +1251,24 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [PlanPhase]. + * + * The following fields are required: + * ```java + * .id() + * .description() + * .discount() + * .duration() + * .durationUnit() + * .maximum() + * .maximumAmount() + * .minimum() + * .minimumAmount() + * .name() + * .order() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -3968,9 +1280,9 @@ private constructor( private var discount: JsonField? = null private var duration: JsonField? = null private var durationUnit: JsonField? = null - private var maximum: JsonField? = null + private var maximum: JsonField? = null private var maximumAmount: JsonField? = null - private var minimum: JsonField? = null + private var minimum: JsonField? = null private var minimumAmount: JsonField? = null private var name: JsonField? = null private var order: JsonField? = null @@ -4062,11 +1374,11 @@ private constructor( this.durationUnit = durationUnit } - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) - fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } fun maximumAmount(maximumAmount: String?) = maximumAmount(JsonField.ofNullable(maximumAmount)) @@ -4078,11 +1390,11 @@ private constructor( this.maximumAmount = maximumAmount } - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) - fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } fun minimumAmount(minimumAmount: String?) = minimumAmount(JsonField.ofNullable(minimumAmount)) @@ -4260,336 +1572,6 @@ private constructor( override fun toString() = value.toString() } - @NoAutoDetect - class Maximum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Maximum amount applied */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Maximum amount applied */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Maximum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - maximumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Maximum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = maximum.maximumAmount - additionalProperties = maximum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Maximum = - Maximum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("maximumAmount", maximumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Maximum && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, maximumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Maximum{appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Minimum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Minimum amount applied */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Minimum amount applied */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Minimum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - minimumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Minimum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var minimumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } - minimumAmount = minimum.minimumAmount - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Minimum = - Minimum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("minimumAmount", minimumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Minimum && appliesToPriceIds == other.appliesToPriceIds && minimumAmount == other.minimumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, minimumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4658,6 +1640,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Product]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -4887,6 +1879,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [TrialConfig]. + * + * The following fields are required: + * ```java + * .trialPeriod() + * .trialPeriodUnit() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 ea575bbce..d4b1377c3 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 @@ -22,6 +22,7 @@ import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.Params +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.getOrThrow import com.withorb.api.core.http.Headers @@ -257,6 +258,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .currency() + * .name() + * .prices() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -316,14 +327,8 @@ private constructor( */ fun addPrice(price: Price) = apply { prices = - (prices ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(price) + (prices ?: JsonField.of(mutableListOf())).also { + checkKnown("prices", it).add(price) } } @@ -657,6 +662,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [PlanCreateParams]. + * + * The following fields are required: + * ```java + * .currency() + * .name() + * .prices() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -2109,7 +2124,7 @@ private constructor( private val name: JsonField = JsonMissing.of(), @JsonProperty("unit_config") @ExcludeMissing - private val unitConfig: JsonField = JsonMissing.of(), + private val unitConfig: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing private val billableMetricId: JsonField = JsonMissing.of(), @@ -2118,7 +2133,7 @@ private constructor( private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") @ExcludeMissing - private val billingCycleConfiguration: JsonField = + private val billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing @@ -2137,7 +2152,7 @@ private constructor( private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = + private val invoicingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing @@ -2157,7 +2172,7 @@ private constructor( /** The name of the price. */ fun name(): String = name.getRequired("name") - fun unitConfig(): UnitConfig = unitConfig.getRequired("unit_config") + fun unitConfig(): UnitConfigModel = unitConfig.getRequired("unit_config") /** * The id of the billable metric for the price. Only needed if the price is usage-based. @@ -2175,7 +2190,7 @@ private constructor( /** * For custom cadence: specifies the duration of the billing period in days or months. */ - fun billingCycleConfiguration(): Optional = + fun billingCycleConfiguration(): Optional = Optional.ofNullable( billingCycleConfiguration.getNullable("billing_cycle_configuration") ) @@ -2208,7 +2223,7 @@ private constructor( * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ - fun invoicingCycleConfiguration(): Optional = + fun invoicingCycleConfiguration(): Optional = Optional.ofNullable( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") ) @@ -2236,7 +2251,7 @@ private constructor( @JsonProperty("unit_config") @ExcludeMissing - fun _unitConfig(): JsonField = unitConfig + fun _unitConfig(): JsonField = unitConfig /** * The id of the billable metric for the price. Only needed if the price is usage-based. @@ -2258,7 +2273,7 @@ private constructor( */ @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = + fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @@ -2295,7 +2310,7 @@ private constructor( */ @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = + fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration /** @@ -2340,6 +2355,18 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [NewPlanUnitPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .modelType() + * .name() + * .unitConfig() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -2350,17 +2377,19 @@ private constructor( private var itemId: JsonField? = null private var modelType: JsonField? = null private var name: JsonField? = null - private var unitConfig: JsonField? = null + private var unitConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = + private var billingCycleConfiguration: + JsonField = JsonMissing.of() private var conversionRate: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() private var externalPriceId: JsonField = JsonMissing.of() private var fixedPriceQuantity: JsonField = JsonMissing.of() private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = + private var invoicingCycleConfiguration: + JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -2409,9 +2438,9 @@ private constructor( /** The name of the price. */ fun name(name: JsonField) = apply { this.name = name } - fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) + fun unitConfig(unitConfig: UnitConfigModel) = unitConfig(JsonField.of(unitConfig)) - fun unitConfig(unitConfig: JsonField) = apply { + fun unitConfig(unitConfig: JsonField) = apply { this.unitConfig = unitConfig } @@ -2472,7 +2501,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? + billingCycleConfiguration: NewBillingCycleConfigurationModel? ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** @@ -2480,7 +2509,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: Optional + billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) /** @@ -2488,7 +2517,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: JsonField + billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } /** The per unit conversion rate of the price currency to the invoicing currency. */ @@ -2588,7 +2617,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? + invoicingCycleConfiguration: NewBillingCycleConfigurationModel? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** @@ -2596,7 +2625,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional + invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) /** @@ -2604,7 +2633,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField + invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } /** @@ -2898,37 +2927,30 @@ private constructor( 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`. + */ @NoAutoDetect - class UnitConfig + class Metadata @JsonCreator private constructor( - @JsonProperty("unit_amount") - @ExcludeMissing - private val unitAmount: JsonField = JsonMissing.of(), @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { - /** Rate per unit of usage */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** Rate per unit of usage */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties private var validated: Boolean = false - fun validate(): UnitConfig = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } - unitAmount() validated = true } @@ -2936,27 +2958,18 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [UnitConfig]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { - private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unitConfig: UnitConfig) = apply { - unitAmount = unitConfig.unitAmount - additionalProperties = unitConfig.additionalProperties.toMutableMap() - } - - /** Rate per unit of usage */ - fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - - /** Rate per unit of usage */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -2981,11 +2994,7 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): UnitConfig = - UnitConfig( - checkRequired("unitAmount", unitAmount), - additionalProperties.toImmutable(), - ) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -2993,15119 +3002,856 @@ private constructor( return true } - return /* spotless:off */ other is UnitConfig && unitAmount == other.unitAmount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(unitAmount, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode - override fun toString() = - "UnitConfig{unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + return /* spotless:off */ other is NewPlanUnitPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && unitConfig == other.unitConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, unitConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit + override fun hashCode(): Int = hashCode - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + override fun toString() = + "NewPlanUnitPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } - private var validated: Boolean = false + @NoAutoDetect + class NewPlanPackagePrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("package_config") + @ExcludeMissing + private val packageConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") - duration() - durationUnit() - validated = true - } + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") - fun toBuilder() = Builder().from(this) + fun modelType(): ModelType = modelType.getRequired("model_type") - companion object { + /** The name of the price. */ + fun name(): String = name.getRequired("name") - @JvmStatic fun builder() = Builder() - } + fun packageConfig(): PackageConfigModel = packageConfig.getRequired("package_config") - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) - 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(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - fun build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @JsonProperty("package_config") + @ExcludeMissing + fun _packageConfig(): JsonField = packageConfig - companion object { + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - @JvmField val DAY = of("day") + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - @JvmField val MONTH = of("month") + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.MONTH - else -> Value._UNKNOWN - } + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - override fun hashCode() = value.hashCode() + private var validated: Boolean = false - override fun toString() = value.toString() + fun validate(): NewPlanPackagePrice = apply { + if (validated) { + return@apply } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } + cadence() + itemId() + modelType() + name() + packageConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ + fun toBuilder() = Builder().from(this) - override fun hashCode(): Int = hashCode + companion object { - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + /** + * Returns a mutable builder for constructing an instance of [NewPlanPackagePrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .modelType() + * .name() + * .packageConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() } - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + /** A builder for [NewPlanPackagePrice]. */ + class Builder internal constructor() { - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var packageConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: + JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + @JvmSynthetic + internal fun from(newPlanPackagePrice: NewPlanPackagePrice) = apply { + cadence = newPlanPackagePrice.cadence + itemId = newPlanPackagePrice.itemId + modelType = newPlanPackagePrice.modelType + name = newPlanPackagePrice.name + packageConfig = newPlanPackagePrice.packageConfig + billableMetricId = newPlanPackagePrice.billableMetricId + billedInAdvance = newPlanPackagePrice.billedInAdvance + billingCycleConfiguration = newPlanPackagePrice.billingCycleConfiguration + conversionRate = newPlanPackagePrice.conversionRate + currency = newPlanPackagePrice.currency + externalPriceId = newPlanPackagePrice.externalPriceId + fixedPriceQuantity = newPlanPackagePrice.fixedPriceQuantity + invoiceGroupingKey = newPlanPackagePrice.invoiceGroupingKey + invoicingCycleConfiguration = newPlanPackagePrice.invoicingCycleConfiguration + metadata = newPlanPackagePrice.metadata + additionalProperties = newPlanPackagePrice.additionalProperties.toMutableMap() + } - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - private var validated: Boolean = false + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - duration() - durationUnit() - validated = true + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType } - fun toBuilder() = Builder().from(this) + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - companion object { + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } - @JvmStatic fun builder() = Builder() + fun packageConfig(packageConfig: PackageConfigModel) = + packageConfig(JsonField.of(packageConfig)) + + fun packageConfig(packageConfig: JsonField) = apply { + this.packageConfig = packageConfig } - /** A builder for [InvoicingCycleConfiguration]. */ - 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 duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + 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)) - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) + /** + * If 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(billedInAdvance as Boolean?) - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - 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: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - 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: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - 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(conversionRate as Double?) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) - fun build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** + * 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 this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) - @JvmField val MONTH = of("month") + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.MONTH - else -> Value._UNKNOWN - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - override fun hashCode() = value.hashCode() + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - override fun toString() = value.toString() + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - override fun hashCode(): Int = hashCode + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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: Optional) = metadata(metadata.orElse(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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - private var validated: Boolean = false + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun validate(): Metadata = apply { - if (validated) { - return@apply + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - validated = true + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - /** A builder for [Metadata]. */ - class Builder internal constructor() { + fun build(): NewPlanPackagePrice = + NewPlanPackagePrice( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("packageConfig", packageConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + currency, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) + } - private var additionalProperties: MutableMap = mutableMapOf() + /** The cadence to bill for this price on. */ + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + companion object { - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JvmField val ANNUAL = of("annual") - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JvmField val MONTHLY = of("monthly") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JvmField val QUARTERLY = of("quarterly") - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } + @JvmField val ONE_TIME = of("one_time") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JvmField val CUSTOM = of("custom") - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewPlanUnitPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && unitConfig == other.unitConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, unitConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewPlanUnitPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewPlanPackagePrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("package_config") - @ExcludeMissing - private val packageConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun packageConfig(): PackageConfig = packageConfig.getRequired("package_config") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this price - * is billed. - */ - fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("package_config") - @ExcludeMissing - fun _packageConfig(): JsonField = packageConfig - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this price - * is billed. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewPlanPackagePrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - packageConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewPlanPackagePrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var packageConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newPlanPackagePrice: NewPlanPackagePrice) = apply { - cadence = newPlanPackagePrice.cadence - itemId = newPlanPackagePrice.itemId - modelType = newPlanPackagePrice.modelType - name = newPlanPackagePrice.name - packageConfig = newPlanPackagePrice.packageConfig - billableMetricId = newPlanPackagePrice.billableMetricId - billedInAdvance = newPlanPackagePrice.billedInAdvance - billingCycleConfiguration = newPlanPackagePrice.billingCycleConfiguration - conversionRate = newPlanPackagePrice.conversionRate - currency = newPlanPackagePrice.currency - externalPriceId = newPlanPackagePrice.externalPriceId - fixedPriceQuantity = newPlanPackagePrice.fixedPriceQuantity - invoiceGroupingKey = newPlanPackagePrice.invoiceGroupingKey - invoicingCycleConfiguration = newPlanPackagePrice.invoicingCycleConfiguration - metadata = newPlanPackagePrice.metadata - additionalProperties = newPlanPackagePrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun packageConfig(packageConfig: PackageConfig) = - packageConfig(JsonField.of(packageConfig)) - - fun packageConfig(packageConfig: JsonField) = apply { - this.packageConfig = packageConfig - } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewPlanPackagePrice = - NewPlanPackagePrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("packageConfig", packageConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val PACKAGE = of("package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - PACKAGE - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PACKAGE, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PACKAGE -> Value.PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PACKAGE -> Known.PACKAGE - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class PackageConfig - @JsonCreator - private constructor( - @JsonProperty("package_amount") - @ExcludeMissing - private val packageAmount: JsonField = JsonMissing.of(), - @JsonProperty("package_size") - @ExcludeMissing - private val packageSize: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** A currency amount to rate usage by */ - fun packageAmount(): String = packageAmount.getRequired("package_amount") - - /** - * An integer amount to represent package size. For example, 1000 here would divide - * usage by 1000 before multiplying by package_amount in rating - */ - fun packageSize(): Long = packageSize.getRequired("package_size") - - /** A currency amount to rate usage by */ - @JsonProperty("package_amount") - @ExcludeMissing - fun _packageAmount(): JsonField = packageAmount - - /** - * An integer amount to represent package size. For example, 1000 here would divide - * usage by 1000 before multiplying by package_amount in rating - */ - @JsonProperty("package_size") - @ExcludeMissing - fun _packageSize(): JsonField = packageSize - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PackageConfig = apply { - if (validated) { - return@apply - } - - packageAmount() - packageSize() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PackageConfig]. */ - class Builder internal constructor() { - - private var packageAmount: JsonField? = null - private var packageSize: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(packageConfig: PackageConfig) = apply { - packageAmount = packageConfig.packageAmount - packageSize = packageConfig.packageSize - additionalProperties = packageConfig.additionalProperties.toMutableMap() - } - - /** A currency amount to rate usage by */ - fun packageAmount(packageAmount: String) = - packageAmount(JsonField.of(packageAmount)) - - /** A currency amount to rate usage by */ - fun packageAmount(packageAmount: JsonField) = apply { - this.packageAmount = packageAmount - } - - /** - * An integer amount to represent package size. For example, 1000 here would - * divide usage by 1000 before multiplying by package_amount in rating - */ - fun packageSize(packageSize: Long) = packageSize(JsonField.of(packageSize)) - - /** - * An integer amount to represent package size. For example, 1000 here would - * divide usage by 1000 before multiplying by package_amount in rating - */ - fun packageSize(packageSize: JsonField) = apply { - this.packageSize = packageSize - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PackageConfig = - PackageConfig( - checkRequired("packageAmount", packageAmount), - checkRequired("packageSize", packageSize), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PackageConfig && packageAmount == other.packageAmount && packageSize == other.packageSize && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(packageAmount, packageSize, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PackageConfig{packageAmount=$packageAmount, packageSize=$packageSize, additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewPlanPackagePrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && packageConfig == other.packageConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, packageConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewPlanPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewPlanMatrixPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("matrix_config") - @ExcludeMissing - private val matrixConfig: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_config") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this price - * is billed. - */ - fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("matrix_config") - @ExcludeMissing - fun _matrixConfig(): JsonField = matrixConfig - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this price - * is billed. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewPlanMatrixPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - matrixConfig().validate() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewPlanMatrixPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var matrixConfig: JsonField? = null - private var modelType: JsonField? = null - private var 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 currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newPlanMatrixPrice: NewPlanMatrixPrice) = apply { - cadence = newPlanMatrixPrice.cadence - itemId = newPlanMatrixPrice.itemId - matrixConfig = newPlanMatrixPrice.matrixConfig - modelType = newPlanMatrixPrice.modelType - name = newPlanMatrixPrice.name - billableMetricId = newPlanMatrixPrice.billableMetricId - billedInAdvance = newPlanMatrixPrice.billedInAdvance - billingCycleConfiguration = newPlanMatrixPrice.billingCycleConfiguration - conversionRate = newPlanMatrixPrice.conversionRate - currency = newPlanMatrixPrice.currency - externalPriceId = newPlanMatrixPrice.externalPriceId - fixedPriceQuantity = newPlanMatrixPrice.fixedPriceQuantity - invoiceGroupingKey = newPlanMatrixPrice.invoiceGroupingKey - invoicingCycleConfiguration = newPlanMatrixPrice.invoicingCycleConfiguration - metadata = newPlanMatrixPrice.metadata - additionalProperties = newPlanMatrixPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun matrixConfig(matrixConfig: MatrixConfig) = - matrixConfig(JsonField.of(matrixConfig)) - - fun matrixConfig(matrixConfig: JsonField) = apply { - this.matrixConfig = matrixConfig - } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewPlanMatrixPrice = - NewPlanMatrixPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("matrixConfig", matrixConfig), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class MatrixConfig - @JsonCreator - private constructor( - @JsonProperty("default_unit_amount") - @ExcludeMissing - private val defaultUnitAmount: JsonField = JsonMissing.of(), - @JsonProperty("dimensions") - @ExcludeMissing - private val dimensions: JsonField> = JsonMissing.of(), - @JsonProperty("matrix_values") - @ExcludeMissing - private val matrixValues: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * Default per unit rate for any usage not bucketed into a specified matrix_value - */ - fun defaultUnitAmount(): String = - defaultUnitAmount.getRequired("default_unit_amount") - - /** One or two event property values to evaluate matrix groups by */ - fun dimensions(): List = dimensions.getRequired("dimensions") - - /** Matrix values for specified matrix grouping keys */ - fun matrixValues(): List = matrixValues.getRequired("matrix_values") - - /** - * Default per unit rate for any usage not bucketed into a specified matrix_value - */ - @JsonProperty("default_unit_amount") - @ExcludeMissing - fun _defaultUnitAmount(): JsonField = defaultUnitAmount - - /** One or two event property values to evaluate matrix groups by */ - @JsonProperty("dimensions") - @ExcludeMissing - fun _dimensions(): JsonField> = dimensions - - /** Matrix values for specified matrix grouping keys */ - @JsonProperty("matrix_values") - @ExcludeMissing - fun _matrixValues(): JsonField> = matrixValues - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MatrixConfig = apply { - if (validated) { - return@apply - } - - defaultUnitAmount() - dimensions() - matrixValues().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MatrixConfig]. */ - class Builder internal constructor() { - - private var defaultUnitAmount: JsonField? = null - private var dimensions: JsonField>? = null - private var matrixValues: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(matrixConfig: MatrixConfig) = apply { - defaultUnitAmount = matrixConfig.defaultUnitAmount - dimensions = matrixConfig.dimensions.map { it.toMutableList() } - matrixValues = matrixConfig.matrixValues.map { it.toMutableList() } - additionalProperties = matrixConfig.additionalProperties.toMutableMap() - } - - /** - * Default per unit rate for any usage not bucketed into a specified - * matrix_value - */ - fun defaultUnitAmount(defaultUnitAmount: String) = - defaultUnitAmount(JsonField.of(defaultUnitAmount)) - - /** - * Default per unit rate for any usage not bucketed into a specified - * matrix_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)) - - /** One or two event property values to evaluate matrix groups by */ - fun dimensions(dimensions: JsonField>) = apply { - this.dimensions = dimensions.map { it.toMutableList() } - } - - /** One or two event property values to evaluate matrix groups by */ - fun addDimension(dimension: String) = apply { - dimensions = - (dimensions ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimension) - } - } - - /** Matrix values for specified matrix grouping keys */ - fun matrixValues(matrixValues: List) = - matrixValues(JsonField.of(matrixValues)) - - /** Matrix values for specified matrix grouping keys */ - fun matrixValues(matrixValues: JsonField>) = apply { - this.matrixValues = matrixValues.map { it.toMutableList() } - } - - /** Matrix values for specified matrix grouping keys */ - fun addMatrixValue(matrixValue: MatrixValue) = apply { - matrixValues = - (matrixValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): MatrixConfig = - MatrixConfig( - checkRequired("defaultUnitAmount", defaultUnitAmount), - checkRequired("dimensions", dimensions).map { it.toImmutable() }, - checkRequired("matrixValues", matrixValues).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class MatrixValue - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - private val unitAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * One or two matrix keys to filter usage to this Matrix value by. For example, - * ["region", "tier"] could be used to filter cloud usage by a cloud region and - * an instance tier. - */ - fun dimensionValues(): List = - dimensionValues.getRequired("dimension_values") - - /** Unit price for the specified dimension_values */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** - * One or two matrix keys to filter usage to this Matrix value by. For example, - * ["region", "tier"] could be used to filter cloud usage by a cloud region and - * an instance tier. - */ - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - /** Unit price for the specified dimension_values */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MatrixValue = apply { - if (validated) { - return@apply - } - - dimensionValues() - unitAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MatrixValue]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(matrixValue: MatrixValue) = apply { - dimensionValues = matrixValue.dimensionValues.map { it.toMutableList() } - unitAmount = matrixValue.unitAmount - additionalProperties = matrixValue.additionalProperties.toMutableMap() - } - - /** - * One or two matrix keys to filter usage to this Matrix value by. For - * example, ["region", "tier"] could be used to filter cloud usage by a - * cloud region and an instance tier. - */ - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - /** - * One or two matrix keys to filter usage to this Matrix value by. For - * example, ["region", "tier"] could be used to filter cloud usage by a - * cloud region and an instance tier. - */ - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - /** - * One or two matrix keys to filter usage to this Matrix value by. For - * example, ["region", "tier"] could be used to filter cloud usage by a - * cloud region and an instance tier. - */ - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - /** Unit price for the specified dimension_values */ - fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - - /** Unit price for the specified dimension_values */ - 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 build(): MatrixValue = - MatrixValue( - checkRequired("dimensionValues", dimensionValues).map { - it.toImmutable() - }, - checkRequired("unitAmount", unitAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MatrixValue && dimensionValues == other.dimensionValues && unitAmount == other.unitAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, unitAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MatrixValue{dimensionValues=$dimensionValues, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MatrixConfig && defaultUnitAmount == other.defaultUnitAmount && dimensions == other.dimensions && matrixValues == other.matrixValues && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(defaultUnitAmount, dimensions, matrixValues, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MatrixConfig{defaultUnitAmount=$defaultUnitAmount, dimensions=$dimensions, matrixValues=$matrixValues, additionalProperties=$additionalProperties}" - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val MATRIX = of("matrix") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MATRIX - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MATRIX, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MATRIX -> Value.MATRIX - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - MATRIX -> Known.MATRIX - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewPlanMatrixPrice && cadence == other.cadence && itemId == other.itemId && matrixConfig == other.matrixConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, matrixConfig, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewPlanMatrixPrice{cadence=$cadence, itemId=$itemId, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewPlanTieredPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_config") - @ExcludeMissing - private val tieredConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun tieredConfig(): TieredConfig = tieredConfig.getRequired("tiered_config") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this price - * is billed. - */ - fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("tiered_config") - @ExcludeMissing - fun _tieredConfig(): JsonField = tieredConfig - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this price - * is billed. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewPlanTieredPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - tieredConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewPlanTieredPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var tieredConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newPlanTieredPrice: NewPlanTieredPrice) = apply { - cadence = newPlanTieredPrice.cadence - itemId = newPlanTieredPrice.itemId - modelType = newPlanTieredPrice.modelType - name = newPlanTieredPrice.name - tieredConfig = newPlanTieredPrice.tieredConfig - billableMetricId = newPlanTieredPrice.billableMetricId - billedInAdvance = newPlanTieredPrice.billedInAdvance - billingCycleConfiguration = newPlanTieredPrice.billingCycleConfiguration - conversionRate = newPlanTieredPrice.conversionRate - currency = newPlanTieredPrice.currency - externalPriceId = newPlanTieredPrice.externalPriceId - fixedPriceQuantity = newPlanTieredPrice.fixedPriceQuantity - invoiceGroupingKey = newPlanTieredPrice.invoiceGroupingKey - invoicingCycleConfiguration = newPlanTieredPrice.invoicingCycleConfiguration - metadata = newPlanTieredPrice.metadata - additionalProperties = newPlanTieredPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredConfig(tieredConfig: TieredConfig) = - tieredConfig(JsonField.of(tieredConfig)) - - fun tieredConfig(tieredConfig: JsonField) = apply { - this.tieredConfig = tieredConfig - } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewPlanTieredPrice = - NewPlanTieredPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("tieredConfig", tieredConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED = of("tiered") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED -> Value.TIERED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - TIERED -> Known.TIERED - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TieredConfig - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - private val tiers: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Tiers for rating based on total usage quantities into the specified tier */ - fun tiers(): List = tiers.getRequired("tiers") - - /** Tiers for rating based on total usage quantities into the specified tier */ - @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredConfig = apply { - if (validated) { - return@apply - } - - tiers().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tieredConfig: TieredConfig) = apply { - tiers = tieredConfig.tiers.map { it.toMutableList() } - additionalProperties = tieredConfig.additionalProperties.toMutableMap() - } - - /** Tiers for rating based on total usage quantities into the specified tier */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - - /** Tiers for rating based on total usage quantities into the specified tier */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** Tiers for rating based on total usage quantities into the specified tier */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): TieredConfig = - TieredConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Tier - @JsonCreator - private constructor( - @JsonProperty("first_unit") - @ExcludeMissing - private val firstUnit: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - private val unitAmount: JsonField = JsonMissing.of(), - @JsonProperty("last_unit") - @ExcludeMissing - private val lastUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Inclusive tier starting value */ - fun firstUnit(): Double = firstUnit.getRequired("first_unit") - - /** Amount per unit */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** Exclusive tier ending value. If null, this is treated as the last tier */ - fun lastUnit(): Optional = - Optional.ofNullable(lastUnit.getNullable("last_unit")) - - /** Inclusive tier starting value */ - @JsonProperty("first_unit") - @ExcludeMissing - fun _firstUnit(): JsonField = firstUnit - - /** Amount per unit */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - /** Exclusive tier ending value. If null, this is treated as the last tier */ - @JsonProperty("last_unit") - @ExcludeMissing - fun _lastUnit(): JsonField = lastUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - firstUnit() - unitAmount() - lastUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var firstUnit: JsonField? = null - private var unitAmount: JsonField? = null - private var lastUnit: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - firstUnit = tier.firstUnit - unitAmount = tier.unitAmount - lastUnit = tier.lastUnit - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Inclusive tier starting value */ - fun firstUnit(firstUnit: Double) = firstUnit(JsonField.of(firstUnit)) - - /** Inclusive tier starting value */ - fun firstUnit(firstUnit: JsonField) = apply { - this.firstUnit = firstUnit - } - - /** Amount per unit */ - fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - - /** Amount per unit */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - /** - * Exclusive tier ending value. If null, this is treated as the last tier - */ - fun lastUnit(lastUnit: Double?) = lastUnit(JsonField.ofNullable(lastUnit)) - - /** - * Exclusive tier ending value. If null, this is treated as the last tier - */ - fun lastUnit(lastUnit: Double) = lastUnit(lastUnit as Double?) - - /** - * Exclusive tier ending value. If null, this is treated as the last tier - */ - @Suppress( - "USELESS_CAST" - ) // See https://youtrack.jetbrains.com/issue/KT-74228 - fun lastUnit(lastUnit: Optional) = - lastUnit(lastUnit.orElse(null) as Double?) - - /** - * Exclusive tier ending value. If null, this is treated as the last tier - */ - fun lastUnit(lastUnit: JsonField) = apply { - this.lastUnit = lastUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Tier = - Tier( - checkRequired("firstUnit", firstUnit), - checkRequired("unitAmount", unitAmount), - lastUnit, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tier && firstUnit == other.firstUnit && unitAmount == other.unitAmount && lastUnit == other.lastUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(firstUnit, unitAmount, lastUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{firstUnit=$firstUnit, unitAmount=$unitAmount, lastUnit=$lastUnit, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredConfig && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredConfig{tiers=$tiers, additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewPlanTieredPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredConfig == other.tieredConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewPlanTieredPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewPlanTieredBpsPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_bps_config") - @ExcludeMissing - private val tieredBpsConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun tieredBpsConfig(): TieredBpsConfig = - tieredBpsConfig.getRequired("tiered_bps_config") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this price - * is billed. - */ - fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("tiered_bps_config") - @ExcludeMissing - fun _tieredBpsConfig(): JsonField = tieredBpsConfig - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this price - * is billed. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewPlanTieredBpsPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - tieredBpsConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewPlanTieredBpsPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var tieredBpsConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newPlanTieredBpsPrice: NewPlanTieredBpsPrice) = apply { - cadence = newPlanTieredBpsPrice.cadence - itemId = newPlanTieredBpsPrice.itemId - modelType = newPlanTieredBpsPrice.modelType - name = newPlanTieredBpsPrice.name - tieredBpsConfig = newPlanTieredBpsPrice.tieredBpsConfig - billableMetricId = newPlanTieredBpsPrice.billableMetricId - billedInAdvance = newPlanTieredBpsPrice.billedInAdvance - billingCycleConfiguration = newPlanTieredBpsPrice.billingCycleConfiguration - conversionRate = newPlanTieredBpsPrice.conversionRate - currency = newPlanTieredBpsPrice.currency - externalPriceId = newPlanTieredBpsPrice.externalPriceId - fixedPriceQuantity = newPlanTieredBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newPlanTieredBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = newPlanTieredBpsPrice.invoicingCycleConfiguration - metadata = newPlanTieredBpsPrice.metadata - additionalProperties = newPlanTieredBpsPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredBpsConfig(tieredBpsConfig: TieredBpsConfig) = - tieredBpsConfig(JsonField.of(tieredBpsConfig)) - - fun tieredBpsConfig(tieredBpsConfig: JsonField) = apply { - this.tieredBpsConfig = tieredBpsConfig - } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewPlanTieredBpsPrice = - NewPlanTieredBpsPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("tieredBpsConfig", tieredBpsConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED_BPS = of("tiered_bps") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_BPS -> Value.TIERED_BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - TIERED_BPS -> Known.TIERED_BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TieredBpsConfig - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - private val tiers: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into specified - * tiers - */ - fun tiers(): List = tiers.getRequired("tiers") - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into specified - * tiers - */ - @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredBpsConfig = apply { - if (validated) { - return@apply - } - - tiers().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredBpsConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tieredBpsConfig: TieredBpsConfig) = apply { - tiers = tieredBpsConfig.tiers.map { it.toMutableList() } - additionalProperties = tieredBpsConfig.additionalProperties.toMutableMap() - } - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into - * specified tiers - */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into - * specified tiers - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into - * specified tiers - */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): TieredBpsConfig = - TieredBpsConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Tier - @JsonCreator - private constructor( - @JsonProperty("bps") - @ExcludeMissing - private val bps: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_maximum") - @ExcludeMissing - private val perUnitMaximum: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Per-event basis point rate */ - fun bps(): Double = bps.getRequired("bps") - - /** Inclusive tier starting value */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** Exclusive tier ending value */ - fun maximumAmount(): Optional = - Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - - /** Per unit maximum to charge */ - fun perUnitMaximum(): Optional = - Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) - - /** Per-event basis point rate */ - @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps - - /** Inclusive tier starting value */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** Exclusive tier ending value */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** Per unit maximum to charge */ - @JsonProperty("per_unit_maximum") - @ExcludeMissing - fun _perUnitMaximum(): JsonField = perUnitMaximum - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - bps() - minimumAmount() - maximumAmount() - perUnitMaximum() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var bps: JsonField? = null - private var minimumAmount: JsonField? = null - private var maximumAmount: JsonField = JsonMissing.of() - private var perUnitMaximum: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - bps = tier.bps - minimumAmount = tier.minimumAmount - maximumAmount = tier.maximumAmount - perUnitMaximum = tier.perUnitMaximum - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Per-event basis point rate */ - fun bps(bps: Double) = bps(JsonField.of(bps)) - - /** Per-event basis point rate */ - fun bps(bps: JsonField) = apply { this.bps = bps } - - /** Inclusive tier starting value */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** Inclusive tier starting value */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** Exclusive tier ending value */ - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - /** Exclusive tier ending value */ - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.orElse(null)) - - /** Exclusive tier ending value */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** Per unit maximum to charge */ - fun perUnitMaximum(perUnitMaximum: String?) = - perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) - - /** Per unit maximum to charge */ - fun perUnitMaximum(perUnitMaximum: Optional) = - perUnitMaximum(perUnitMaximum.orElse(null)) - - /** Per unit maximum to charge */ - fun perUnitMaximum(perUnitMaximum: JsonField) = apply { - this.perUnitMaximum = perUnitMaximum - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): Tier = - Tier( - checkRequired("bps", bps), - checkRequired("minimumAmount", minimumAmount), - maximumAmount, - perUnitMaximum, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tier && bps == other.bps && minimumAmount == other.minimumAmount && maximumAmount == other.maximumAmount && perUnitMaximum == other.perUnitMaximum && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bps, minimumAmount, maximumAmount, perUnitMaximum, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{bps=$bps, minimumAmount=$minimumAmount, maximumAmount=$maximumAmount, perUnitMaximum=$perUnitMaximum, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredBpsConfig && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredBpsConfig{tiers=$tiers, additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewPlanTieredBpsPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredBpsConfig == other.tieredBpsConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredBpsConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewPlanTieredBpsPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredBpsConfig=$tieredBpsConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewPlanBpsPrice - @JsonCreator - private constructor( - @JsonProperty("bps_config") - @ExcludeMissing - private val bpsConfig: JsonField = JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun bpsConfig(): BpsConfig = bpsConfig.getRequired("bps_config") - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this price - * is billed. - */ - fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - @JsonProperty("bps_config") - @ExcludeMissing - fun _bpsConfig(): JsonField = bpsConfig - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this price - * is billed. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewPlanBpsPrice = apply { - if (validated) { - return@apply - } - - bpsConfig().validate() - cadence() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewPlanBpsPrice]. */ - class Builder internal constructor() { - - private var bpsConfig: JsonField? = null - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newPlanBpsPrice: NewPlanBpsPrice) = apply { - bpsConfig = newPlanBpsPrice.bpsConfig - cadence = newPlanBpsPrice.cadence - itemId = newPlanBpsPrice.itemId - modelType = newPlanBpsPrice.modelType - name = newPlanBpsPrice.name - billableMetricId = newPlanBpsPrice.billableMetricId - billedInAdvance = newPlanBpsPrice.billedInAdvance - billingCycleConfiguration = newPlanBpsPrice.billingCycleConfiguration - conversionRate = newPlanBpsPrice.conversionRate - currency = newPlanBpsPrice.currency - externalPriceId = newPlanBpsPrice.externalPriceId - fixedPriceQuantity = newPlanBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newPlanBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = newPlanBpsPrice.invoicingCycleConfiguration - metadata = newPlanBpsPrice.metadata - additionalProperties = newPlanBpsPrice.additionalProperties.toMutableMap() - } - - fun bpsConfig(bpsConfig: BpsConfig) = bpsConfig(JsonField.of(bpsConfig)) - - fun bpsConfig(bpsConfig: JsonField) = apply { - this.bpsConfig = bpsConfig - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewPlanBpsPrice = - NewPlanBpsPrice( - checkRequired("bpsConfig", bpsConfig), - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BpsConfig - @JsonCreator - private constructor( - @JsonProperty("bps") - @ExcludeMissing - private val bps: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_maximum") - @ExcludeMissing - private val perUnitMaximum: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Basis point take rate per event */ - fun bps(): Double = bps.getRequired("bps") - - /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(): Optional = - Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) - - /** Basis point take rate per event */ - @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps - - /** Optional currency amount maximum to cap spend per event */ - @JsonProperty("per_unit_maximum") - @ExcludeMissing - fun _perUnitMaximum(): JsonField = perUnitMaximum - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BpsConfig = apply { - if (validated) { - return@apply - } - - bps() - perUnitMaximum() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BpsConfig]. */ - class Builder internal constructor() { - - private var bps: JsonField? = null - private var perUnitMaximum: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(bpsConfig: BpsConfig) = apply { - bps = bpsConfig.bps - perUnitMaximum = bpsConfig.perUnitMaximum - additionalProperties = bpsConfig.additionalProperties.toMutableMap() - } - - /** Basis point take rate per event */ - fun bps(bps: Double) = bps(JsonField.of(bps)) - - /** Basis point take rate per event */ - fun bps(bps: JsonField) = apply { this.bps = bps } - - /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(perUnitMaximum: String?) = - perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) - - /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(perUnitMaximum: Optional) = - perUnitMaximum(perUnitMaximum.orElse(null)) - - /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(perUnitMaximum: JsonField) = apply { - this.perUnitMaximum = perUnitMaximum - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): BpsConfig = - BpsConfig( - checkRequired("bps", bps), - perUnitMaximum, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BpsConfig && bps == other.bps && perUnitMaximum == other.perUnitMaximum && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bps, perUnitMaximum, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BpsConfig{bps=$bps, perUnitMaximum=$perUnitMaximum, additionalProperties=$additionalProperties}" - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val BPS = of("bps") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BPS -> Value.BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - BPS -> Known.BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewPlanBpsPrice && bpsConfig == other.bpsConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bpsConfig, cadence, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewPlanBpsPrice{bpsConfig=$bpsConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewPlanBulkBpsPrice - @JsonCreator - private constructor( - @JsonProperty("bulk_bps_config") - @ExcludeMissing - private val bulkBpsConfig: JsonField = JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun bulkBpsConfig(): BulkBpsConfig = bulkBpsConfig.getRequired("bulk_bps_config") - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this price - * is billed. - */ - fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - @JsonProperty("bulk_bps_config") - @ExcludeMissing - fun _bulkBpsConfig(): JsonField = bulkBpsConfig - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this price - * is billed. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewPlanBulkBpsPrice = apply { - if (validated) { - return@apply - } - - bulkBpsConfig().validate() - cadence() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewPlanBulkBpsPrice]. */ - class Builder internal constructor() { - - private var bulkBpsConfig: JsonField? = null - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newPlanBulkBpsPrice: NewPlanBulkBpsPrice) = apply { - bulkBpsConfig = newPlanBulkBpsPrice.bulkBpsConfig - cadence = newPlanBulkBpsPrice.cadence - itemId = newPlanBulkBpsPrice.itemId - modelType = newPlanBulkBpsPrice.modelType - name = newPlanBulkBpsPrice.name - billableMetricId = newPlanBulkBpsPrice.billableMetricId - billedInAdvance = newPlanBulkBpsPrice.billedInAdvance - billingCycleConfiguration = newPlanBulkBpsPrice.billingCycleConfiguration - conversionRate = newPlanBulkBpsPrice.conversionRate - currency = newPlanBulkBpsPrice.currency - externalPriceId = newPlanBulkBpsPrice.externalPriceId - fixedPriceQuantity = newPlanBulkBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newPlanBulkBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = newPlanBulkBpsPrice.invoicingCycleConfiguration - metadata = newPlanBulkBpsPrice.metadata - additionalProperties = newPlanBulkBpsPrice.additionalProperties.toMutableMap() - } - - fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfig) = - bulkBpsConfig(JsonField.of(bulkBpsConfig)) - - fun bulkBpsConfig(bulkBpsConfig: JsonField) = apply { - this.bulkBpsConfig = bulkBpsConfig - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewPlanBulkBpsPrice = - NewPlanBulkBpsPrice( - checkRequired("bulkBpsConfig", bulkBpsConfig), - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BulkBpsConfig - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - private val tiers: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a single tier - * based on total volume - */ - fun tiers(): List = tiers.getRequired("tiers") - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a single tier - * based on total volume - */ - @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BulkBpsConfig = apply { - if (validated) { - return@apply - } - - tiers().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkBpsConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(bulkBpsConfig: BulkBpsConfig) = apply { - tiers = bulkBpsConfig.tiers.map { it.toMutableList() } - additionalProperties = bulkBpsConfig.additionalProperties.toMutableMap() - } - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a single - * tier based on total volume - */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a single - * tier based on total volume - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a single - * tier based on total volume - */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): BulkBpsConfig = - BulkBpsConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Tier - @JsonCreator - private constructor( - @JsonProperty("bps") - @ExcludeMissing - private val bps: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_maximum") - @ExcludeMissing - private val perUnitMaximum: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Basis points to rate on */ - fun bps(): Double = bps.getRequired("bps") - - /** Upper bound for tier */ - fun maximumAmount(): Optional = - Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(): Optional = - Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) - - /** Basis points to rate on */ - @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps - - /** Upper bound for tier */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** The maximum amount to charge for any one event */ - @JsonProperty("per_unit_maximum") - @ExcludeMissing - fun _perUnitMaximum(): JsonField = perUnitMaximum - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - bps() - maximumAmount() - perUnitMaximum() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var bps: JsonField? = null - private var maximumAmount: JsonField = JsonMissing.of() - private var perUnitMaximum: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - bps = tier.bps - maximumAmount = tier.maximumAmount - perUnitMaximum = tier.perUnitMaximum - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Basis points to rate on */ - fun bps(bps: Double) = bps(JsonField.of(bps)) - - /** Basis points to rate on */ - fun bps(bps: JsonField) = apply { this.bps = bps } - - /** Upper bound for tier */ - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - /** Upper bound for tier */ - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.orElse(null)) - - /** Upper bound for tier */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(perUnitMaximum: String?) = - perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) - - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(perUnitMaximum: Optional) = - perUnitMaximum(perUnitMaximum.orElse(null)) - - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(perUnitMaximum: JsonField) = apply { - this.perUnitMaximum = perUnitMaximum - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): Tier = - Tier( - checkRequired("bps", bps), - maximumAmount, - perUnitMaximum, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tier && bps == other.bps && maximumAmount == other.maximumAmount && perUnitMaximum == other.perUnitMaximum && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bps, maximumAmount, perUnitMaximum, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{bps=$bps, maximumAmount=$maximumAmount, perUnitMaximum=$perUnitMaximum, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BulkBpsConfig && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkBpsConfig{tiers=$tiers, additionalProperties=$additionalProperties}" - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val BULK_BPS = of("bulk_bps") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK_BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK_BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK_BPS -> Value.BULK_BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - BULK_BPS -> Known.BULK_BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewPlanBulkBpsPrice && bulkBpsConfig == other.bulkBpsConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bulkBpsConfig, cadence, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewPlanBulkBpsPrice{bulkBpsConfig=$bulkBpsConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewPlanBulkPrice - @JsonCreator - private constructor( - @JsonProperty("bulk_config") - @ExcludeMissing - private val bulkConfig: JsonField = JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun bulkConfig(): BulkConfig = bulkConfig.getRequired("bulk_config") - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this price - * is billed. - */ - fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - @JsonProperty("bulk_config") - @ExcludeMissing - fun _bulkConfig(): JsonField = bulkConfig - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this price - * is billed. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewPlanBulkPrice = apply { - if (validated) { - return@apply - } - - bulkConfig().validate() - cadence() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewPlanBulkPrice]. */ - class Builder internal constructor() { - - private var bulkConfig: JsonField? = null - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var 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 currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newPlanBulkPrice: NewPlanBulkPrice) = apply { - bulkConfig = newPlanBulkPrice.bulkConfig - cadence = newPlanBulkPrice.cadence - itemId = newPlanBulkPrice.itemId - modelType = newPlanBulkPrice.modelType - name = newPlanBulkPrice.name - billableMetricId = newPlanBulkPrice.billableMetricId - billedInAdvance = newPlanBulkPrice.billedInAdvance - billingCycleConfiguration = newPlanBulkPrice.billingCycleConfiguration - conversionRate = newPlanBulkPrice.conversionRate - currency = newPlanBulkPrice.currency - externalPriceId = newPlanBulkPrice.externalPriceId - fixedPriceQuantity = newPlanBulkPrice.fixedPriceQuantity - invoiceGroupingKey = newPlanBulkPrice.invoiceGroupingKey - invoicingCycleConfiguration = newPlanBulkPrice.invoicingCycleConfiguration - metadata = newPlanBulkPrice.metadata - additionalProperties = newPlanBulkPrice.additionalProperties.toMutableMap() - } - - fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) - - fun bulkConfig(bulkConfig: JsonField) = apply { - this.bulkConfig = bulkConfig - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewPlanBulkPrice = - NewPlanBulkPrice( - checkRequired("bulkConfig", bulkConfig), - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BulkConfig - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - private val tiers: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Bulk tiers for rating based on total usage volume */ - fun tiers(): List = tiers.getRequired("tiers") - - /** Bulk tiers for rating based on total usage volume */ - @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BulkConfig = apply { - if (validated) { - return@apply - } - - tiers().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(bulkConfig: BulkConfig) = apply { - tiers = bulkConfig.tiers.map { it.toMutableList() } - additionalProperties = bulkConfig.additionalProperties.toMutableMap() - } - - /** Bulk tiers for rating based on total usage volume */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - - /** Bulk tiers for rating based on total usage volume */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** Bulk tiers for rating based on total usage volume */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): BulkConfig = - BulkConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Tier - @JsonCreator - private constructor( - @JsonProperty("unit_amount") - @ExcludeMissing - private val unitAmount: JsonField = JsonMissing.of(), - @JsonProperty("maximum_units") - @ExcludeMissing - private val maximumUnits: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Amount per unit */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** Upper bound for this tier */ - fun maximumUnits(): Optional = - Optional.ofNullable(maximumUnits.getNullable("maximum_units")) - - /** Amount per unit */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - /** Upper bound for this tier */ - @JsonProperty("maximum_units") - @ExcludeMissing - fun _maximumUnits(): JsonField = maximumUnits - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - unitAmount() - maximumUnits() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var unitAmount: JsonField? = null - private var maximumUnits: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - unitAmount = tier.unitAmount - maximumUnits = tier.maximumUnits - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Amount per unit */ - fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - - /** Amount per unit */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - /** Upper bound for this tier */ - fun maximumUnits(maximumUnits: Double?) = - maximumUnits(JsonField.ofNullable(maximumUnits)) - - /** Upper bound for this tier */ - fun maximumUnits(maximumUnits: Double) = - maximumUnits(maximumUnits as Double?) - - /** Upper bound for this tier */ - @Suppress( - "USELESS_CAST" - ) // See https://youtrack.jetbrains.com/issue/KT-74228 - fun maximumUnits(maximumUnits: Optional) = - maximumUnits(maximumUnits.orElse(null) as Double?) - - /** Upper bound for this tier */ - fun maximumUnits(maximumUnits: JsonField) = apply { - this.maximumUnits = maximumUnits - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Tier = - Tier( - checkRequired("unitAmount", unitAmount), - maximumUnits, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tier && unitAmount == other.unitAmount && maximumUnits == other.maximumUnits && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(unitAmount, maximumUnits, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{unitAmount=$unitAmount, maximumUnits=$maximumUnits, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BulkConfig && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkConfig{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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val BULK = of("bulk") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK -> Value.BULK - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - BULK -> Known.BULK - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewPlanBulkPrice && bulkConfig == other.bulkConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bulkConfig, cadence, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewPlanBulkPrice{bulkConfig=$bulkConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewPlanThresholdTotalAmountPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("threshold_total_amount_config") - @ExcludeMissing - private val thresholdTotalAmountConfig: JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun thresholdTotalAmountConfig(): ThresholdTotalAmountConfig = - thresholdTotalAmountConfig.getRequired("threshold_total_amount_config") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this price - * is billed. - */ - fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("threshold_total_amount_config") - @ExcludeMissing - fun _thresholdTotalAmountConfig(): JsonField = - thresholdTotalAmountConfig - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this price - * is billed. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewPlanThresholdTotalAmountPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - thresholdTotalAmountConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewPlanThresholdTotalAmountPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var thresholdTotalAmountConfig: JsonField? = - null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newPlanThresholdTotalAmountPrice: NewPlanThresholdTotalAmountPrice - ) = apply { - cadence = newPlanThresholdTotalAmountPrice.cadence - itemId = newPlanThresholdTotalAmountPrice.itemId - modelType = newPlanThresholdTotalAmountPrice.modelType - name = newPlanThresholdTotalAmountPrice.name - thresholdTotalAmountConfig = - newPlanThresholdTotalAmountPrice.thresholdTotalAmountConfig - billableMetricId = newPlanThresholdTotalAmountPrice.billableMetricId - billedInAdvance = newPlanThresholdTotalAmountPrice.billedInAdvance - billingCycleConfiguration = - newPlanThresholdTotalAmountPrice.billingCycleConfiguration - conversionRate = newPlanThresholdTotalAmountPrice.conversionRate - currency = newPlanThresholdTotalAmountPrice.currency - externalPriceId = newPlanThresholdTotalAmountPrice.externalPriceId - fixedPriceQuantity = newPlanThresholdTotalAmountPrice.fixedPriceQuantity - invoiceGroupingKey = newPlanThresholdTotalAmountPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newPlanThresholdTotalAmountPrice.invoicingCycleConfiguration - metadata = newPlanThresholdTotalAmountPrice.metadata - additionalProperties = - newPlanThresholdTotalAmountPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun thresholdTotalAmountConfig( - thresholdTotalAmountConfig: ThresholdTotalAmountConfig - ) = thresholdTotalAmountConfig(JsonField.of(thresholdTotalAmountConfig)) - - fun thresholdTotalAmountConfig( - thresholdTotalAmountConfig: JsonField - ) = apply { this.thresholdTotalAmountConfig = thresholdTotalAmountConfig } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewPlanThresholdTotalAmountPrice = - NewPlanThresholdTotalAmountPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("thresholdTotalAmountConfig", thresholdTotalAmountConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val THRESHOLD_TOTAL_AMOUNT = of("threshold_total_amount") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - THRESHOLD_TOTAL_AMOUNT - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - THRESHOLD_TOTAL_AMOUNT, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - THRESHOLD_TOTAL_AMOUNT -> Value.THRESHOLD_TOTAL_AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - THRESHOLD_TOTAL_AMOUNT -> Known.THRESHOLD_TOTAL_AMOUNT - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class ThresholdTotalAmountConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): ThresholdTotalAmountConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ThresholdTotalAmountConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(thresholdTotalAmountConfig: ThresholdTotalAmountConfig) = - apply { - additionalProperties = - thresholdTotalAmountConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): ThresholdTotalAmountConfig = - ThresholdTotalAmountConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ThresholdTotalAmountConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ThresholdTotalAmountConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewPlanThresholdTotalAmountPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, thresholdTotalAmountConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewPlanThresholdTotalAmountPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewPlanTieredPackagePrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_package_config") - @ExcludeMissing - private val tieredPackageConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun tieredPackageConfig(): TieredPackageConfig = - tieredPackageConfig.getRequired("tiered_package_config") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this price - * is billed. - */ - fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("tiered_package_config") - @ExcludeMissing - fun _tieredPackageConfig(): JsonField = tieredPackageConfig - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this price - * is billed. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewPlanTieredPackagePrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - tieredPackageConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewPlanTieredPackagePrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var tieredPackageConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newPlanTieredPackagePrice: NewPlanTieredPackagePrice) = apply { - cadence = newPlanTieredPackagePrice.cadence - itemId = newPlanTieredPackagePrice.itemId - modelType = newPlanTieredPackagePrice.modelType - name = newPlanTieredPackagePrice.name - tieredPackageConfig = newPlanTieredPackagePrice.tieredPackageConfig - billableMetricId = newPlanTieredPackagePrice.billableMetricId - billedInAdvance = newPlanTieredPackagePrice.billedInAdvance - billingCycleConfiguration = newPlanTieredPackagePrice.billingCycleConfiguration - conversionRate = newPlanTieredPackagePrice.conversionRate - currency = newPlanTieredPackagePrice.currency - externalPriceId = newPlanTieredPackagePrice.externalPriceId - fixedPriceQuantity = newPlanTieredPackagePrice.fixedPriceQuantity - invoiceGroupingKey = newPlanTieredPackagePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newPlanTieredPackagePrice.invoicingCycleConfiguration - metadata = newPlanTieredPackagePrice.metadata - additionalProperties = - newPlanTieredPackagePrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = - tieredPackageConfig(JsonField.of(tieredPackageConfig)) - - fun tieredPackageConfig(tieredPackageConfig: JsonField) = - apply { - this.tieredPackageConfig = tieredPackageConfig - } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewPlanTieredPackagePrice = - NewPlanTieredPackagePrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("tieredPackageConfig", tieredPackageConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED_PACKAGE = of("tiered_package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_PACKAGE + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, } /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. * - * An instance of [ModelType] can contain an unknown value in a couple of cases: + * An instance of [Cadence] can contain an unknown value in a couple of cases: * - It was deserialized from data that doesn't match any known member. For example, * if the SDK is on an older version than the API, then the API may respond with * new members that the SDK is unaware of. * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - TIERED_PACKAGE, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_PACKAGE -> Value.TIERED_PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - TIERED_PACKAGE -> Known.TIERED_PACKAGE - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TieredPackageConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredPackageConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredPackageConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tieredPackageConfig: TieredPackageConfig) = apply { - additionalProperties = - tieredPackageConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): TieredPackageConfig = - TieredPackageConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredPackageConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } + _UNKNOWN, + } - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead 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 } - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_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 an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if 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 hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { - fun toBuilder() = Builder().from(this) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JvmField val PACKAGE = of("package") - fun build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** An enum containing [ModelType]'s known values. */ + enum class Known { + PACKAGE + } + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PACKAGE, /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } + _UNKNOWN, + } - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PACKAGE -> Value.PACKAGE + else -> Value._UNKNOWN } - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PACKAGE -> Known.PACKAGE + else -> throw OrbInvalidDataException("Unknown ModelType: $value") } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if 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 hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } /** @@ -18139,6 +3885,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } @@ -18199,21 +3946,21 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanTieredPackagePrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredPackageConfig == other.tieredPackageConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NewPlanPackagePrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && packageConfig == other.packageConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredPackageConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, packageConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanTieredPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewPlanPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } @NoAutoDetect - class NewPlanTieredWithMinimumPrice + class NewPlanMatrixPrice @JsonCreator private constructor( @JsonProperty("cadence") @@ -18222,16 +3969,15 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("matrix_config") + @ExcludeMissing + private val matrixConfig: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing private val modelType: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_minimum_config") - @ExcludeMissing - private val tieredWithMinimumConfig: JsonField = - JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing private val billableMetricId: JsonField = JsonMissing.of(), @@ -18240,7 +3986,7 @@ private constructor( private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") @ExcludeMissing - private val billingCycleConfiguration: JsonField = + private val billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing @@ -18259,7 +4005,7 @@ private constructor( private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = + private val invoicingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing @@ -18274,14 +4020,13 @@ private constructor( /** The id of the item the price will be associated with. */ fun itemId(): String = itemId.getRequired("item_id") + fun matrixConfig(): MatrixConfigModel = matrixConfig.getRequired("matrix_config") + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ fun name(): String = name.getRequired("name") - fun tieredWithMinimumConfig(): TieredWithMinimumConfig = - tieredWithMinimumConfig.getRequired("tiered_with_minimum_config") - /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ @@ -18298,7 +4043,7 @@ private constructor( /** * For custom cadence: specifies the duration of the billing period in days or months. */ - fun billingCycleConfiguration(): Optional = + fun billingCycleConfiguration(): Optional = Optional.ofNullable( billingCycleConfiguration.getNullable("billing_cycle_configuration") ) @@ -18331,7 +4076,7 @@ private constructor( * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ - fun invoicingCycleConfiguration(): Optional = + fun invoicingCycleConfiguration(): Optional = Optional.ofNullable( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") ) @@ -18350,6 +4095,10 @@ private constructor( /** The id of the item the price will be associated with. */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + @JsonProperty("matrix_config") + @ExcludeMissing + fun _matrixConfig(): JsonField = matrixConfig + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonField = modelType @@ -18357,11 +4106,6 @@ private constructor( /** The name of the price. */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("tiered_with_minimum_config") - @ExcludeMissing - fun _tieredWithMinimumConfig(): JsonField = - tieredWithMinimumConfig - /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ @@ -18382,7 +4126,7 @@ private constructor( */ @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = + fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @@ -18419,7 +4163,7 @@ private constructor( */ @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = + fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration /** @@ -18437,16 +4181,16 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPlanTieredWithMinimumPrice = apply { + fun validate(): NewPlanMatrixPrice = apply { if (validated) { return@apply } cadence() itemId() + matrixConfig().validate() modelType() name() - tieredWithMinimumConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration().ifPresent { it.validate() } @@ -18464,55 +4208,64 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [NewPlanMatrixPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .matrixConfig() + * .modelType() + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewPlanTieredWithMinimumPrice]. */ + /** A builder for [NewPlanMatrixPrice]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null + private var matrixConfig: JsonField? = null private var modelType: JsonField? = null private var name: JsonField? = null - private var tieredWithMinimumConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = + private var billingCycleConfiguration: + JsonField = JsonMissing.of() private var conversionRate: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() private var externalPriceId: JsonField = JsonMissing.of() private var fixedPriceQuantity: JsonField = JsonMissing.of() private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = + private var invoicingCycleConfiguration: + JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newPlanTieredWithMinimumPrice: NewPlanTieredWithMinimumPrice) = - apply { - cadence = newPlanTieredWithMinimumPrice.cadence - itemId = newPlanTieredWithMinimumPrice.itemId - modelType = newPlanTieredWithMinimumPrice.modelType - name = newPlanTieredWithMinimumPrice.name - tieredWithMinimumConfig = - newPlanTieredWithMinimumPrice.tieredWithMinimumConfig - billableMetricId = newPlanTieredWithMinimumPrice.billableMetricId - billedInAdvance = newPlanTieredWithMinimumPrice.billedInAdvance - billingCycleConfiguration = - newPlanTieredWithMinimumPrice.billingCycleConfiguration - conversionRate = newPlanTieredWithMinimumPrice.conversionRate - currency = newPlanTieredWithMinimumPrice.currency - externalPriceId = newPlanTieredWithMinimumPrice.externalPriceId - fixedPriceQuantity = newPlanTieredWithMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = newPlanTieredWithMinimumPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newPlanTieredWithMinimumPrice.invoicingCycleConfiguration - metadata = newPlanTieredWithMinimumPrice.metadata - additionalProperties = - newPlanTieredWithMinimumPrice.additionalProperties.toMutableMap() - } + internal fun from(newPlanMatrixPrice: NewPlanMatrixPrice) = apply { + cadence = newPlanMatrixPrice.cadence + itemId = newPlanMatrixPrice.itemId + matrixConfig = newPlanMatrixPrice.matrixConfig + modelType = newPlanMatrixPrice.modelType + name = newPlanMatrixPrice.name + billableMetricId = newPlanMatrixPrice.billableMetricId + billedInAdvance = newPlanMatrixPrice.billedInAdvance + billingCycleConfiguration = newPlanMatrixPrice.billingCycleConfiguration + conversionRate = newPlanMatrixPrice.conversionRate + currency = newPlanMatrixPrice.currency + externalPriceId = newPlanMatrixPrice.externalPriceId + fixedPriceQuantity = newPlanMatrixPrice.fixedPriceQuantity + invoiceGroupingKey = newPlanMatrixPrice.invoiceGroupingKey + invoicingCycleConfiguration = newPlanMatrixPrice.invoicingCycleConfiguration + metadata = newPlanMatrixPrice.metadata + additionalProperties = newPlanMatrixPrice.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -18526,6 +4279,13 @@ private constructor( /** The id of the item the price will be associated with. */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + fun matrixConfig(matrixConfig: MatrixConfigModel) = + matrixConfig(JsonField.of(matrixConfig)) + + fun matrixConfig(matrixConfig: JsonField) = apply { + this.matrixConfig = matrixConfig + } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) fun modelType(modelType: JsonField) = apply { @@ -18538,13 +4298,6 @@ private constructor( /** The name of the price. */ fun name(name: JsonField) = apply { this.name = name } - fun tieredWithMinimumConfig(tieredWithMinimumConfig: TieredWithMinimumConfig) = - tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) - - fun tieredWithMinimumConfig( - tieredWithMinimumConfig: JsonField - ) = apply { this.tieredWithMinimumConfig = tieredWithMinimumConfig } - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -18602,7 +4355,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? + billingCycleConfiguration: NewBillingCycleConfigurationModel? ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** @@ -18610,7 +4363,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: Optional + billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) /** @@ -18618,7 +4371,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: JsonField + billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } /** The per unit conversion rate of the price currency to the invoicing currency. */ @@ -18718,7 +4471,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? + invoicingCycleConfiguration: NewBillingCycleConfigurationModel? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** @@ -18726,7 +4479,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional + invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) /** @@ -18734,7 +4487,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField + invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } /** @@ -18780,13 +4533,13 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): NewPlanTieredWithMinimumPrice = - NewPlanTieredWithMinimumPrice( + fun build(): NewPlanMatrixPrice = + NewPlanMatrixPrice( checkRequired("cadence", cadence), checkRequired("itemId", itemId), + checkRequired("matrixConfig", matrixConfig), checkRequired("modelType", modelType), checkRequired("name", name), - checkRequired("tieredWithMinimumConfig", tieredWithMinimumConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -18922,683 +4675,1037 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val MATRIX = of("matrix") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + MATRIX + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MATRIX, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MATRIX -> Value.MATRIX + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MATRIX -> Known.MATRIX + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode() = value.hashCode() + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - class ModelType @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 /* spotless:off */ other is NewPlanMatrixPrice && cadence == other.cadence && itemId == other.itemId && matrixConfig == other.matrixConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } - companion object { + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, itemId, matrixConfig, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ - @JvmField val TIERED_WITH_MINIMUM = of("tiered_with_minimum") + override fun hashCode(): Int = hashCode - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } + override fun toString() = + "NewPlanMatrixPrice{cadence=$cadence, itemId=$itemId, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_WITH_MINIMUM - } + @NoAutoDetect + class NewPlanTieredPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_config") + @ExcludeMissing + private val tieredConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_WITH_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("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) { - TIERED_WITH_MINIMUM -> Value.TIERED_WITH_MINIMUM - else -> Value._UNKNOWN - } + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - TIERED_WITH_MINIMUM -> Known.TIERED_WITH_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } + fun modelType(): ModelType = modelType.getRequired("model_type") - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 price. */ + fun name(): String = name.getRequired("name") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun tieredConfig(): TieredConfigModel = tieredConfig.getRequired("tiered_config") + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("tiered_config") + @ExcludeMissing + fun _tieredConfig(): JsonField = tieredConfig + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - override fun hashCode() = value.hashCode() + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - override fun toString() = value.toString() - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @NoAutoDetect - class TieredWithMinimumConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - private var validated: Boolean = false + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - fun validate(): TieredWithMinimumConfig = 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. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - validated = true - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - fun toBuilder() = Builder().from(this) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - companion object { + private var validated: Boolean = false - @JvmStatic fun builder() = Builder() + fun validate(): NewPlanTieredPrice = apply { + if (validated) { + return@apply } - /** A builder for [TieredWithMinimumConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tieredWithMinimumConfig: TieredWithMinimumConfig) = apply { - additionalProperties = - tieredWithMinimumConfig.additionalProperties.toMutableMap() - } + cadence() + itemId() + modelType() + name() + tieredConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun toBuilder() = Builder().from(this) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + companion object { - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns a mutable builder for constructing an instance of [NewPlanTieredPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .modelType() + * .name() + * .tieredConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** A builder for [NewPlanTieredPrice]. */ + class Builder internal constructor() { - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: + JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun build(): TieredWithMinimumConfig = - TieredWithMinimumConfig(additionalProperties.toImmutable()) + @JvmSynthetic + internal fun from(newPlanTieredPrice: NewPlanTieredPrice) = apply { + cadence = newPlanTieredPrice.cadence + itemId = newPlanTieredPrice.itemId + modelType = newPlanTieredPrice.modelType + name = newPlanTieredPrice.name + tieredConfig = newPlanTieredPrice.tieredConfig + billableMetricId = newPlanTieredPrice.billableMetricId + billedInAdvance = newPlanTieredPrice.billedInAdvance + billingCycleConfiguration = newPlanTieredPrice.billingCycleConfiguration + conversionRate = newPlanTieredPrice.conversionRate + currency = newPlanTieredPrice.currency + externalPriceId = newPlanTieredPrice.externalPriceId + fixedPriceQuantity = newPlanTieredPrice.fixedPriceQuantity + invoiceGroupingKey = newPlanTieredPrice.invoiceGroupingKey + invoicingCycleConfiguration = newPlanTieredPrice.invoicingCycleConfiguration + metadata = newPlanTieredPrice.metadata + additionalProperties = newPlanTieredPrice.additionalProperties.toMutableMap() } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredWithMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - override fun hashCode(): Int = hashCode + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - override fun toString() = - "TieredWithMinimumConfig{additionalProperties=$additionalProperties}" - } + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit + fun tieredConfig(tieredConfig: TieredConfigModel) = + tieredConfig(JsonField.of(tieredConfig)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun tieredConfig(tieredConfig: JsonField) = apply { + this.tieredConfig = tieredConfig + } - private var validated: Boolean = false + /** + * The 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 validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) - duration() - durationUnit() - validated = true + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId } - fun toBuilder() = Builder().from(this) + /** + * If 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)) - 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(billedInAdvance as Boolean?) - @JvmStatic fun builder() = Builder() + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance } - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) - fun build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId } - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - companion object { + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - @JvmField val DAY = of("day") + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - @JvmField val MONTH = of("month") + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.MONTH - else -> Value._UNKNOWN - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the 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 - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - 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 /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + fun build(): NewPlanTieredPrice = + NewPlanTieredPrice( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("tieredConfig", tieredConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + currency, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) } - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } + /** The cadence to bill for this price on. */ + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { - fun toBuilder() = Builder().from(this) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { - @JvmStatic fun builder() = Builder() - } + @JvmField val ANNUAL = of("annual") - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val MONTHLY = of("monthly") - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + @JvmField val QUARTERLY = of("quarterly") - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } + @JvmField val ONE_TIME = of("one_time") - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) + @JvmField val CUSTOM = of("custom") - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN } - 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) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - fun build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ } - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { + override fun hashCode() = value.hashCode() - @JvmField val DAY = of("day") + override fun toString() = value.toString() + } - @JvmField val MONTH = of("month") + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(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 - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } + companion object { - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + @JvmField val TIERED = of("tiered") - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.MONTH - else -> Value._UNKNOWN - } + @JvmStatic fun of(value: String) = ModelType(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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } + /** An enum containing [ModelType]'s known values. */ + enum class Known { + TIERED + } + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TIERED, /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method 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 [ModelType] was instantiated with an unknown + * value. */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + _UNKNOWN, + } - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TIERED -> Value.TIERED + else -> Value._UNKNOWN } - override fun hashCode() = value.hashCode() + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TIERED -> Known.TIERED + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } - override fun toString() = value.toString() - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if 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 } - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } /** @@ -19632,6 +5739,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } @@ -19692,21 +5800,21 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanTieredWithMinimumPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredWithMinimumConfig == other.tieredWithMinimumConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NewPlanTieredPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredConfig == other.tieredConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredWithMinimumConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanTieredWithMinimumPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewPlanTieredPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } @NoAutoDetect - class NewPlanUnitWithPercentPrice + class NewPlanTieredBpsPrice @JsonCreator private constructor( @JsonProperty("cadence") @@ -19721,9 +5829,9 @@ private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("unit_with_percent_config") + @JsonProperty("tiered_bps_config") @ExcludeMissing - private val unitWithPercentConfig: JsonField = JsonMissing.of(), + private val tieredBpsConfig: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing private val billableMetricId: JsonField = JsonMissing.of(), @@ -19732,7 +5840,7 @@ private constructor( private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") @ExcludeMissing - private val billingCycleConfiguration: JsonField = + private val billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing @@ -19751,7 +5859,7 @@ private constructor( private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = + private val invoicingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing @@ -19771,8 +5879,8 @@ private constructor( /** The name of the price. */ fun name(): String = name.getRequired("name") - fun unitWithPercentConfig(): UnitWithPercentConfig = - unitWithPercentConfig.getRequired("unit_with_percent_config") + fun tieredBpsConfig(): TieredBpsConfigModel = + tieredBpsConfig.getRequired("tiered_bps_config") /** * The id of the billable metric for the price. Only needed if the price is usage-based. @@ -19790,7 +5898,7 @@ private constructor( /** * For custom cadence: specifies the duration of the billing period in days or months. */ - fun billingCycleConfiguration(): Optional = + fun billingCycleConfiguration(): Optional = Optional.ofNullable( billingCycleConfiguration.getNullable("billing_cycle_configuration") ) @@ -19823,7 +5931,7 @@ private constructor( * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ - fun invoicingCycleConfiguration(): Optional = + fun invoicingCycleConfiguration(): Optional = Optional.ofNullable( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") ) @@ -19849,9 +5957,9 @@ private constructor( /** The name of the price. */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("unit_with_percent_config") + @JsonProperty("tiered_bps_config") @ExcludeMissing - fun _unitWithPercentConfig(): JsonField = unitWithPercentConfig + fun _tieredBpsConfig(): JsonField = tieredBpsConfig /** * The id of the billable metric for the price. Only needed if the price is usage-based. @@ -19873,7 +5981,7 @@ private constructor( */ @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = + fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @@ -19910,7 +6018,7 @@ private constructor( */ @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = + fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration /** @@ -19928,7 +6036,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPlanUnitWithPercentPrice = apply { + fun validate(): NewPlanTieredBpsPrice = apply { if (validated) { return@apply } @@ -19937,7 +6045,7 @@ private constructor( itemId() modelType() name() - unitWithPercentConfig().validate() + tieredBpsConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration().ifPresent { it.validate() } @@ -19955,54 +6063,65 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [NewPlanTieredBpsPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .modelType() + * .name() + * .tieredBpsConfig() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewPlanUnitWithPercentPrice]. */ + /** A builder for [NewPlanTieredBpsPrice]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null private var modelType: JsonField? = null private var name: JsonField? = null - private var unitWithPercentConfig: JsonField? = null + private var tieredBpsConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = + private var billingCycleConfiguration: + JsonField = JsonMissing.of() private var conversionRate: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() private var externalPriceId: JsonField = JsonMissing.of() private var fixedPriceQuantity: JsonField = JsonMissing.of() private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = + private var invoicingCycleConfiguration: + JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newPlanUnitWithPercentPrice: NewPlanUnitWithPercentPrice) = - apply { - cadence = newPlanUnitWithPercentPrice.cadence - itemId = newPlanUnitWithPercentPrice.itemId - modelType = newPlanUnitWithPercentPrice.modelType - name = newPlanUnitWithPercentPrice.name - unitWithPercentConfig = newPlanUnitWithPercentPrice.unitWithPercentConfig - billableMetricId = newPlanUnitWithPercentPrice.billableMetricId - billedInAdvance = newPlanUnitWithPercentPrice.billedInAdvance - billingCycleConfiguration = - newPlanUnitWithPercentPrice.billingCycleConfiguration - conversionRate = newPlanUnitWithPercentPrice.conversionRate - currency = newPlanUnitWithPercentPrice.currency - externalPriceId = newPlanUnitWithPercentPrice.externalPriceId - fixedPriceQuantity = newPlanUnitWithPercentPrice.fixedPriceQuantity - invoiceGroupingKey = newPlanUnitWithPercentPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newPlanUnitWithPercentPrice.invoicingCycleConfiguration - metadata = newPlanUnitWithPercentPrice.metadata - additionalProperties = - newPlanUnitWithPercentPrice.additionalProperties.toMutableMap() - } + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(newPlanTieredBpsPrice: NewPlanTieredBpsPrice) = apply { + cadence = newPlanTieredBpsPrice.cadence + itemId = newPlanTieredBpsPrice.itemId + modelType = newPlanTieredBpsPrice.modelType + name = newPlanTieredBpsPrice.name + tieredBpsConfig = newPlanTieredBpsPrice.tieredBpsConfig + billableMetricId = newPlanTieredBpsPrice.billableMetricId + billedInAdvance = newPlanTieredBpsPrice.billedInAdvance + billingCycleConfiguration = newPlanTieredBpsPrice.billingCycleConfiguration + conversionRate = newPlanTieredBpsPrice.conversionRate + currency = newPlanTieredBpsPrice.currency + externalPriceId = newPlanTieredBpsPrice.externalPriceId + fixedPriceQuantity = newPlanTieredBpsPrice.fixedPriceQuantity + invoiceGroupingKey = newPlanTieredBpsPrice.invoiceGroupingKey + invoicingCycleConfiguration = newPlanTieredBpsPrice.invoicingCycleConfiguration + metadata = newPlanTieredBpsPrice.metadata + additionalProperties = newPlanTieredBpsPrice.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -20028,13 +6147,12 @@ private constructor( /** The name of the price. */ fun name(name: JsonField) = apply { this.name = name } - fun unitWithPercentConfig(unitWithPercentConfig: UnitWithPercentConfig) = - unitWithPercentConfig(JsonField.of(unitWithPercentConfig)) + fun tieredBpsConfig(tieredBpsConfig: TieredBpsConfigModel) = + tieredBpsConfig(JsonField.of(tieredBpsConfig)) - fun unitWithPercentConfig(unitWithPercentConfig: JsonField) = - apply { - this.unitWithPercentConfig = unitWithPercentConfig - } + fun tieredBpsConfig(tieredBpsConfig: JsonField) = apply { + this.tieredBpsConfig = tieredBpsConfig + } /** * The id of the billable metric for the price. Only needed if the price is @@ -20093,7 +6211,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? + billingCycleConfiguration: NewBillingCycleConfigurationModel? ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** @@ -20101,7 +6219,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: Optional + billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) /** @@ -20109,7 +6227,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: JsonField + billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } /** The per unit conversion rate of the price currency to the invoicing currency. */ @@ -20209,7 +6327,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? + invoicingCycleConfiguration: NewBillingCycleConfigurationModel? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** @@ -20217,7 +6335,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional + invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) /** @@ -20225,7 +6343,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField + invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } /** @@ -20271,13 +6389,13 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): NewPlanUnitWithPercentPrice = - NewPlanUnitWithPercentPrice( + fun build(): NewPlanTieredBpsPrice = + NewPlanTieredBpsPrice( checkRequired("cadence", cadence), checkRequired("itemId", itemId), checkRequired("modelType", modelType), checkRequired("name", name), - checkRequired("unitWithPercentConfig", unitWithPercentConfig), + checkRequired("tieredBpsConfig", tieredBpsConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -20436,14 +6554,14 @@ private constructor( companion object { - @JvmField val UNIT_WITH_PERCENT = of("unit_with_percent") + @JvmField val TIERED_BPS = of("tiered_bps") @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } /** An enum containing [ModelType]'s known values. */ enum class Known { - UNIT_WITH_PERCENT + TIERED_BPS } /** @@ -20456,7 +6574,7 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - UNIT_WITH_PERCENT, + TIERED_BPS, /** * An enum member indicating that [ModelType] was instantiated with an unknown * value. @@ -20473,7 +6591,7 @@ private constructor( */ fun value(): Value = when (this) { - UNIT_WITH_PERCENT -> Value.UNIT_WITH_PERCENT + TIERED_BPS -> Value.TIERED_BPS else -> Value._UNKNOWN } @@ -20488,608 +6606,961 @@ private constructor( */ fun known(): Known = when (this) { - UNIT_WITH_PERCENT -> Known.UNIT_WITH_PERCENT + TIERED_BPS -> Known.TIERED_BPS else -> throw OrbInvalidDataException("Unknown ModelType: $value") } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if 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 + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewPlanTieredBpsPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredBpsConfig == other.tieredBpsConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredBpsConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewPlanTieredBpsPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredBpsConfig=$tieredBpsConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewPlanBpsPrice + @JsonCreator + private constructor( + @JsonProperty("bps_config") + @ExcludeMissing + private val bpsConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun bpsConfig(): BpsConfigModel = bpsConfig.getRequired("bps_config") + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - override fun hashCode() = value.hashCode() + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - override fun toString() = value.toString() - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - @NoAutoDetect - class UnitWithPercentConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = 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(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) - private var validated: Boolean = false + @JsonProperty("bps_config") + @ExcludeMissing + fun _bpsConfig(): JsonField = bpsConfig - fun validate(): UnitWithPercentConfig = apply { - if (validated) { - return@apply - } + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - validated = true - } + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - fun toBuilder() = Builder().from(this) + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - companion object { + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JvmStatic fun builder() = Builder() - } + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - /** A builder for [UnitWithPercentConfig]. */ - class Builder internal constructor() { + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - private var additionalProperties: MutableMap = mutableMapOf() + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - @JvmSynthetic - internal fun from(unitWithPercentConfig: UnitWithPercentConfig) = apply { - additionalProperties = - unitWithPercentConfig.additionalProperties.toMutableMap() - } + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - 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. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - fun build(): UnitWithPercentConfig = - UnitWithPercentConfig(additionalProperties.toImmutable()) - } + /** + * User-specified key/value pairs for the resource. 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("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false - return /* spotless:off */ other is UnitWithPercentConfig && additionalProperties == other.additionalProperties /* spotless:on */ + fun validate(): NewPlanBpsPrice = apply { + if (validated) { + return@apply } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + bpsConfig().validate() + cadence() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } - override fun hashCode(): Int = hashCode + fun toBuilder() = Builder().from(this) + + companion object { - override fun toString() = - "UnitWithPercentConfig{additionalProperties=$additionalProperties}" + /** + * Returns a mutable builder for constructing an instance of [NewPlanBpsPrice]. + * + * The following fields are required: + * ```java + * .bpsConfig() + * .cadence() + * .itemId() + * .modelType() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() } - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + /** A builder for [NewPlanBpsPrice]. */ + class Builder internal constructor() { + + private var bpsConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: + JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(newPlanBpsPrice: NewPlanBpsPrice) = apply { + bpsConfig = newPlanBpsPrice.bpsConfig + cadence = newPlanBpsPrice.cadence + itemId = newPlanBpsPrice.itemId + modelType = newPlanBpsPrice.modelType + name = newPlanBpsPrice.name + billableMetricId = newPlanBpsPrice.billableMetricId + billedInAdvance = newPlanBpsPrice.billedInAdvance + billingCycleConfiguration = newPlanBpsPrice.billingCycleConfiguration + conversionRate = newPlanBpsPrice.conversionRate + currency = newPlanBpsPrice.currency + externalPriceId = newPlanBpsPrice.externalPriceId + fixedPriceQuantity = newPlanBpsPrice.fixedPriceQuantity + invoiceGroupingKey = newPlanBpsPrice.invoiceGroupingKey + invoicingCycleConfiguration = newPlanBpsPrice.invoicingCycleConfiguration + metadata = newPlanBpsPrice.metadata + additionalProperties = newPlanBpsPrice.additionalProperties.toMutableMap() + } - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") + fun bpsConfig(bpsConfig: BpsConfigModel) = bpsConfig(JsonField.of(bpsConfig)) - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + fun bpsConfig(bpsConfig: JsonField) = apply { + this.bpsConfig = bpsConfig + } - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - private var validated: Boolean = false + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - duration() - durationUnit() - validated = true + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType } - fun toBuilder() = Builder().from(this) + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - companion object { + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } - @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 [BillingCycleConfiguration]. */ - class Builder internal constructor() { + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.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)) - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) + /** + * If 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(billedInAdvance as Boolean?) - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - 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: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - 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: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - 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(conversionRate as Double?) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) - fun build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = 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) { - DAY -> Value.DAY - MONTH -> Value.MONTH - else -> Value._UNKNOWN - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(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") - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - override fun hashCode() = value.hashCode() + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - override fun toString() = value.toString() + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - override fun hashCode(): Int = hashCode + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_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`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - private var validated: Boolean = false + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - duration() - durationUnit() - validated = true + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - fun toBuilder() = Builder().from(this) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): NewPlanBpsPrice = + NewPlanBpsPrice( + checkRequired("bpsConfig", bpsConfig), + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + currency, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) + } + + /** 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 { - @JvmStatic fun builder() = Builder() - } + @JvmField val ANNUAL = of("annual") - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { + @JvmField val SEMI_ANNUAL = of("semi_annual") - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + @JvmField val MONTHLY = of("monthly") - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } + @JvmField val QUARTERLY = of("quarterly") - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) + @JvmField val ONE_TIME = of("one_time") - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } + @JvmField val CUSTOM = of("custom") - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - fun build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ } - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { + override fun hashCode() = value.hashCode() - @JvmField val DAY = of("day") + override fun toString() = value.toString() + } - @JvmField val MONTH = of("month") + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(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 - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } + companion object { - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + @JvmField val BPS = of("bps") - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.MONTH - else -> Value._UNKNOWN - } + @JvmStatic fun of(value: String) = ModelType(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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } + /** An enum containing [ModelType]'s known values. */ + enum class Known { + BPS + } + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + BPS, /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method 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 [ModelType] was instantiated with an unknown + * value. */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } + _UNKNOWN, + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return 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) { + BPS -> Value.BPS + else -> Value._UNKNOWN + } - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + BPS -> Known.BPS + else -> throw OrbInvalidDataException("Unknown ModelType: $value") } - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if 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 } - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } /** @@ -21123,6 +7594,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } @@ -21183,23 +7655,26 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanUnitWithPercentPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && unitWithPercentConfig == other.unitWithPercentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NewPlanBpsPrice && bpsConfig == other.bpsConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, unitWithPercentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(bpsConfig, cadence, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanUnitWithPercentPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewPlanBpsPrice{bpsConfig=$bpsConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } @NoAutoDetect - class NewPlanPackageWithAllocationPrice + class NewPlanBulkBpsPrice @JsonCreator private constructor( + @JsonProperty("bulk_bps_config") + @ExcludeMissing + private val bulkBpsConfig: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing private val cadence: JsonField = JsonMissing.of(), @@ -21212,10 +7687,6 @@ private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("package_with_allocation_config") - @ExcludeMissing - private val packageWithAllocationConfig: JsonField = - JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing private val billableMetricId: JsonField = JsonMissing.of(), @@ -21224,7 +7695,7 @@ private constructor( private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") @ExcludeMissing - private val billingCycleConfiguration: JsonField = + private val billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing @@ -21243,7 +7714,7 @@ private constructor( private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = + private val invoicingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing @@ -21252,6 +7723,8 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + fun bulkBpsConfig(): BulkBpsConfigModel = bulkBpsConfig.getRequired("bulk_bps_config") + /** The cadence to bill for this price on. */ fun cadence(): Cadence = cadence.getRequired("cadence") @@ -21263,9 +7736,6 @@ private constructor( /** The name of the price. */ fun name(): String = name.getRequired("name") - fun packageWithAllocationConfig(): PackageWithAllocationConfig = - packageWithAllocationConfig.getRequired("package_with_allocation_config") - /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ @@ -21282,7 +7752,7 @@ private constructor( /** * For custom cadence: specifies the duration of the billing period in days or months. */ - fun billingCycleConfiguration(): Optional = + fun billingCycleConfiguration(): Optional = Optional.ofNullable( billingCycleConfiguration.getNullable("billing_cycle_configuration") ) @@ -21315,7 +7785,7 @@ private constructor( * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ - fun invoicingCycleConfiguration(): Optional = + fun invoicingCycleConfiguration(): Optional = Optional.ofNullable( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") ) @@ -21328,6 +7798,10 @@ private constructor( fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + @JsonProperty("bulk_bps_config") + @ExcludeMissing + fun _bulkBpsConfig(): JsonField = bulkBpsConfig + /** The cadence to bill for this price on. */ @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence @@ -21341,11 +7815,6 @@ private constructor( /** The name of the price. */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("package_with_allocation_config") - @ExcludeMissing - fun _packageWithAllocationConfig(): JsonField = - packageWithAllocationConfig - /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ @@ -21366,7 +7835,7 @@ private constructor( */ @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = + fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @@ -21403,7 +7872,7 @@ private constructor( */ @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = + fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration /** @@ -21421,16 +7890,16 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPlanPackageWithAllocationPrice = apply { + fun validate(): NewPlanBulkBpsPrice = apply { if (validated) { return@apply } + bulkBpsConfig().validate() cadence() itemId() modelType() name() - packageWithAllocationConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration().ifPresent { it.validate() } @@ -21448,56 +7917,70 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [NewPlanBulkBpsPrice]. + * + * The following fields are required: + * ```java + * .bulkBpsConfig() + * .cadence() + * .itemId() + * .modelType() + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewPlanPackageWithAllocationPrice]. */ + /** A builder for [NewPlanBulkBpsPrice]. */ class Builder internal constructor() { + private var bulkBpsConfig: JsonField? = null private var cadence: JsonField? = null private var itemId: JsonField? = null private var modelType: JsonField? = null private var name: JsonField? = null - private var packageWithAllocationConfig: JsonField? = - null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = + private var billingCycleConfiguration: + JsonField = JsonMissing.of() private var conversionRate: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() private var externalPriceId: JsonField = JsonMissing.of() private var fixedPriceQuantity: JsonField = JsonMissing.of() private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = + private var invoicingCycleConfiguration: + JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newPlanPackageWithAllocationPrice: NewPlanPackageWithAllocationPrice - ) = apply { - cadence = newPlanPackageWithAllocationPrice.cadence - itemId = newPlanPackageWithAllocationPrice.itemId - modelType = newPlanPackageWithAllocationPrice.modelType - name = newPlanPackageWithAllocationPrice.name - packageWithAllocationConfig = - newPlanPackageWithAllocationPrice.packageWithAllocationConfig - billableMetricId = newPlanPackageWithAllocationPrice.billableMetricId - billedInAdvance = newPlanPackageWithAllocationPrice.billedInAdvance - billingCycleConfiguration = - newPlanPackageWithAllocationPrice.billingCycleConfiguration - conversionRate = newPlanPackageWithAllocationPrice.conversionRate - currency = newPlanPackageWithAllocationPrice.currency - externalPriceId = newPlanPackageWithAllocationPrice.externalPriceId - fixedPriceQuantity = newPlanPackageWithAllocationPrice.fixedPriceQuantity - invoiceGroupingKey = newPlanPackageWithAllocationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newPlanPackageWithAllocationPrice.invoicingCycleConfiguration - metadata = newPlanPackageWithAllocationPrice.metadata - additionalProperties = - newPlanPackageWithAllocationPrice.additionalProperties.toMutableMap() + internal fun from(newPlanBulkBpsPrice: NewPlanBulkBpsPrice) = apply { + bulkBpsConfig = newPlanBulkBpsPrice.bulkBpsConfig + cadence = newPlanBulkBpsPrice.cadence + itemId = newPlanBulkBpsPrice.itemId + modelType = newPlanBulkBpsPrice.modelType + name = newPlanBulkBpsPrice.name + billableMetricId = newPlanBulkBpsPrice.billableMetricId + billedInAdvance = newPlanBulkBpsPrice.billedInAdvance + billingCycleConfiguration = newPlanBulkBpsPrice.billingCycleConfiguration + conversionRate = newPlanBulkBpsPrice.conversionRate + currency = newPlanBulkBpsPrice.currency + externalPriceId = newPlanBulkBpsPrice.externalPriceId + fixedPriceQuantity = newPlanBulkBpsPrice.fixedPriceQuantity + invoiceGroupingKey = newPlanBulkBpsPrice.invoiceGroupingKey + invoicingCycleConfiguration = newPlanBulkBpsPrice.invoicingCycleConfiguration + metadata = newPlanBulkBpsPrice.metadata + additionalProperties = newPlanBulkBpsPrice.additionalProperties.toMutableMap() + } + + fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfigModel) = + bulkBpsConfig(JsonField.of(bulkBpsConfig)) + + fun bulkBpsConfig(bulkBpsConfig: JsonField) = apply { + this.bulkBpsConfig = bulkBpsConfig } /** The cadence to bill for this price on. */ @@ -21524,14 +8007,6 @@ private constructor( /** The name of the price. */ fun name(name: JsonField) = apply { this.name = name } - fun packageWithAllocationConfig( - packageWithAllocationConfig: PackageWithAllocationConfig - ) = packageWithAllocationConfig(JsonField.of(packageWithAllocationConfig)) - - fun packageWithAllocationConfig( - packageWithAllocationConfig: JsonField - ) = apply { this.packageWithAllocationConfig = packageWithAllocationConfig } - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -21589,7 +8064,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? + billingCycleConfiguration: NewBillingCycleConfigurationModel? ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** @@ -21597,7 +8072,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: Optional + billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) /** @@ -21605,7 +8080,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: JsonField + billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } /** The per unit conversion rate of the price currency to the invoicing currency. */ @@ -21705,7 +8180,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? + invoicingCycleConfiguration: NewBillingCycleConfigurationModel? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** @@ -21713,7 +8188,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional + invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) /** @@ -21721,7 +8196,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField + invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } /** @@ -21767,157 +8242,29 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): NewPlanPackageWithAllocationPrice = - NewPlanPackageWithAllocationPrice( + fun build(): NewPlanBulkBpsPrice = + NewPlanBulkBpsPrice( + checkRequired("bulkBpsConfig", bulkBpsConfig), checkRequired("cadence", cadence), checkRequired("itemId", itemId), checkRequired("modelType", modelType), checkRequired("name", name), - checkRequired("packageWithAllocationConfig", packageWithAllocationConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) } - class ModelType @JsonCreator private constructor(private val value: JsonField) : + /** The cadence to bill for this price on. */ + class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -21932,29 +8279,49 @@ private constructor( companion object { - @JvmField val PACKAGE_WITH_ALLOCATION = of("package_with_allocation") + @JvmField val ANNUAL = of("annual") - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + @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 [ModelType]'s known values. */ + /** An enum containing [Cadence]'s known values. */ enum class Known { - PACKAGE_WITH_ALLOCATION + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, } /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. * - * An instance of [ModelType] can contain an unknown value in a couple of cases: + * An instance of [Cadence] can contain an unknown value in a couple of cases: * - It was deserialized from data that doesn't match any known member. For example, * if the SDK is on an older version than the API, then the API may respond with * new members that the SDK is unaware of. * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - PACKAGE_WITH_ALLOCATION, + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, /** - * An enum member indicating that [ModelType] was instantiated with an unknown + * An enum member indicating that [Cadence] was instantiated with an unknown * value. */ _UNKNOWN, @@ -21969,7 +8336,12 @@ private constructor( */ fun value(): Value = when (this) { - PACKAGE_WITH_ALLOCATION -> Value.PACKAGE_WITH_ALLOCATION + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM else -> Value._UNKNOWN } @@ -21984,8 +8356,13 @@ private constructor( */ fun known(): Known = when (this) { - PACKAGE_WITH_ALLOCATION -> Known.PACKAGE_WITH_ALLOCATION - else -> throw OrbInvalidDataException("Unknown ModelType: $value") + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") } /** @@ -21997,596 +8374,120 @@ private constructor( * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class PackageWithAllocationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PackageWithAllocationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PackageWithAllocationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(packageWithAllocationConfig: PackageWithAllocationConfig) = - apply { - additionalProperties = - packageWithAllocationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): PackageWithAllocationConfig = - PackageWithAllocationConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PackageWithAllocationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PackageWithAllocationConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") } - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { - fun toBuilder() = Builder().from(this) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JvmField val BULK_BPS = of("bulk_bps") - fun build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** An enum containing [ModelType]'s known values. */ + enum class Known { + BULK_BPS + } + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + BULK_BPS, /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } + _UNKNOWN, + } - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + BULK_BPS -> Value.BULK_BPS + else -> Value._UNKNOWN } - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + BULK_BPS -> Known.BULK_BPS + else -> throw OrbInvalidDataException("Unknown ModelType: $value") } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if 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 hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } /** @@ -22620,6 +8521,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } @@ -22680,23 +8582,26 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanPackageWithAllocationPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && packageWithAllocationConfig == other.packageWithAllocationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NewPlanBulkBpsPrice && bulkBpsConfig == other.bulkBpsConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, packageWithAllocationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(bulkBpsConfig, cadence, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanPackageWithAllocationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewPlanBulkBpsPrice{bulkBpsConfig=$bulkBpsConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } @NoAutoDetect - class NewPlanTierWithProrationPrice + class NewPlanBulkPrice @JsonCreator private constructor( + @JsonProperty("bulk_config") + @ExcludeMissing + private val bulkConfig: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing private val cadence: JsonField = JsonMissing.of(), @@ -22709,10 +8614,6 @@ private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - private val tieredWithProrationConfig: JsonField = - JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing private val billableMetricId: JsonField = JsonMissing.of(), @@ -22721,7 +8622,7 @@ private constructor( private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") @ExcludeMissing - private val billingCycleConfiguration: JsonField = + private val billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing @@ -22740,7 +8641,7 @@ private constructor( private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = + private val invoicingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing @@ -22749,6 +8650,8 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + fun bulkConfig(): BulkConfigModel = bulkConfig.getRequired("bulk_config") + /** The cadence to bill for this price on. */ fun cadence(): Cadence = cadence.getRequired("cadence") @@ -22760,9 +8663,6 @@ private constructor( /** The name of the price. */ fun name(): String = name.getRequired("name") - 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. */ @@ -22779,7 +8679,7 @@ private constructor( /** * For custom cadence: specifies the duration of the billing period in days or months. */ - fun billingCycleConfiguration(): Optional = + fun billingCycleConfiguration(): Optional = Optional.ofNullable( billingCycleConfiguration.getNullable("billing_cycle_configuration") ) @@ -22812,7 +8712,7 @@ private constructor( * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ - fun invoicingCycleConfiguration(): Optional = + fun invoicingCycleConfiguration(): Optional = Optional.ofNullable( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") ) @@ -22825,6 +8725,10 @@ private constructor( fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + @JsonProperty("bulk_config") + @ExcludeMissing + fun _bulkConfig(): JsonField = bulkConfig + /** The cadence to bill for this price on. */ @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence @@ -22838,11 +8742,6 @@ private constructor( /** The name of the price. */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig - /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ @@ -22863,7 +8762,7 @@ private constructor( */ @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = + fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @@ -22900,7 +8799,7 @@ private constructor( */ @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = + fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration /** @@ -22918,16 +8817,16 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPlanTierWithProrationPrice = apply { + fun validate(): NewPlanBulkPrice = apply { if (validated) { return@apply } + bulkConfig().validate() cadence() itemId() modelType() name() - tieredWithProrationConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration().ifPresent { it.validate() } @@ -22945,55 +8844,70 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [NewPlanBulkPrice]. + * + * The following fields are required: + * ```java + * .bulkConfig() + * .cadence() + * .itemId() + * .modelType() + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewPlanTierWithProrationPrice]. */ + /** A builder for [NewPlanBulkPrice]. */ class Builder internal constructor() { + private var bulkConfig: JsonField? = null private var cadence: JsonField? = null private var itemId: JsonField? = null private var modelType: JsonField? = null private var name: JsonField? = null - private var tieredWithProrationConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = + private var billingCycleConfiguration: + JsonField = JsonMissing.of() private var conversionRate: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() private var externalPriceId: JsonField = JsonMissing.of() private var fixedPriceQuantity: JsonField = JsonMissing.of() private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = + private var invoicingCycleConfiguration: + JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newPlanTierWithProrationPrice: NewPlanTierWithProrationPrice) = - apply { - cadence = newPlanTierWithProrationPrice.cadence - itemId = newPlanTierWithProrationPrice.itemId - modelType = newPlanTierWithProrationPrice.modelType - name = newPlanTierWithProrationPrice.name - tieredWithProrationConfig = - newPlanTierWithProrationPrice.tieredWithProrationConfig - billableMetricId = newPlanTierWithProrationPrice.billableMetricId - billedInAdvance = newPlanTierWithProrationPrice.billedInAdvance - billingCycleConfiguration = - newPlanTierWithProrationPrice.billingCycleConfiguration - conversionRate = newPlanTierWithProrationPrice.conversionRate - currency = newPlanTierWithProrationPrice.currency - externalPriceId = newPlanTierWithProrationPrice.externalPriceId - fixedPriceQuantity = newPlanTierWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = newPlanTierWithProrationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newPlanTierWithProrationPrice.invoicingCycleConfiguration - metadata = newPlanTierWithProrationPrice.metadata - additionalProperties = - newPlanTierWithProrationPrice.additionalProperties.toMutableMap() - } + internal fun from(newPlanBulkPrice: NewPlanBulkPrice) = apply { + bulkConfig = newPlanBulkPrice.bulkConfig + cadence = newPlanBulkPrice.cadence + itemId = newPlanBulkPrice.itemId + modelType = newPlanBulkPrice.modelType + name = newPlanBulkPrice.name + billableMetricId = newPlanBulkPrice.billableMetricId + billedInAdvance = newPlanBulkPrice.billedInAdvance + billingCycleConfiguration = newPlanBulkPrice.billingCycleConfiguration + conversionRate = newPlanBulkPrice.conversionRate + currency = newPlanBulkPrice.currency + externalPriceId = newPlanBulkPrice.externalPriceId + fixedPriceQuantity = newPlanBulkPrice.fixedPriceQuantity + invoiceGroupingKey = newPlanBulkPrice.invoiceGroupingKey + invoicingCycleConfiguration = newPlanBulkPrice.invoicingCycleConfiguration + metadata = newPlanBulkPrice.metadata + additionalProperties = newPlanBulkPrice.additionalProperties.toMutableMap() + } + + fun bulkConfig(bulkConfig: BulkConfigModel) = bulkConfig(JsonField.of(bulkConfig)) + + fun bulkConfig(bulkConfig: JsonField) = apply { + this.bulkConfig = bulkConfig + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -23019,14 +8933,6 @@ private constructor( /** The name of the price. */ fun name(name: JsonField) = apply { this.name = name } - fun tieredWithProrationConfig( - tieredWithProrationConfig: TieredWithProrationConfig - ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - - 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. @@ -23084,7 +8990,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? + billingCycleConfiguration: NewBillingCycleConfigurationModel? ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** @@ -23092,7 +8998,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: Optional + billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) /** @@ -23100,7 +9006,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: JsonField + billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } /** The per unit conversion rate of the price currency to the invoicing currency. */ @@ -23200,7 +9106,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? + invoicingCycleConfiguration: NewBillingCycleConfigurationModel? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** @@ -23208,7 +9114,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional + invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) /** @@ -23216,7 +9122,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField + invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } /** @@ -23262,13 +9168,13 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): NewPlanTierWithProrationPrice = - NewPlanTierWithProrationPrice( + fun build(): NewPlanBulkPrice = + NewPlanBulkPrice( + checkRequired("bulkConfig", bulkConfig), checkRequired("cadence", cadence), checkRequired("itemId", itemId), checkRequired("modelType", modelType), checkRequired("name", name), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -23427,14 +9333,14 @@ private constructor( companion object { - @JvmField val TIERED_WITH_PRORATION = of("tiered_with_proration") + @JvmField val BULK = of("bulk") @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } /** An enum containing [ModelType]'s known values. */ enum class Known { - TIERED_WITH_PRORATION + BULK } /** @@ -23447,7 +9353,7 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - TIERED_WITH_PRORATION, + BULK, /** * An enum member indicating that [ModelType] was instantiated with an unknown * value. @@ -23464,624 +9370,990 @@ private constructor( */ fun value(): Value = when (this) { - TIERED_WITH_PRORATION -> Value.TIERED_WITH_PRORATION + BULK -> Value.BULK else -> Value._UNKNOWN } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - TIERED_WITH_PRORATION -> Known.TIERED_WITH_PRORATION - else -> throw OrbInvalidDataException("Unknown ModelType: $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) { + BULK -> Known.BULK + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewPlanBulkPrice && bulkConfig == other.bulkConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(bulkConfig, cadence, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewPlanBulkPrice{bulkConfig=$bulkConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewPlanThresholdTotalAmountPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("threshold_total_amount_config") + @ExcludeMissing + private val thresholdTotalAmountConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun thresholdTotalAmountConfig(): CustomRatingFunctionConfigModel = + thresholdTotalAmountConfig.getRequired("threshold_total_amount_config") + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("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") - } + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - override fun hashCode() = value.hashCode() + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) - 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`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) - @NoAutoDetect - class TieredWithProrationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - private var validated: Boolean = false + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - fun validate(): TieredWithProrationConfig = apply { - if (validated) { - return@apply - } + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - validated = true - } + @JsonProperty("threshold_total_amount_config") + @ExcludeMissing + fun _thresholdTotalAmountConfig(): JsonField = + thresholdTotalAmountConfig - fun toBuilder() = Builder().from(this) + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - @JvmStatic fun builder() = Builder() - } + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - /** A builder for [TieredWithProrationConfig]. */ - class Builder internal constructor() { + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - private var additionalProperties: MutableMap = mutableMapOf() + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JvmSynthetic - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = - apply { - additionalProperties = - tieredWithProrationConfig.additionalProperties.toMutableMap() - } + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + 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`. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig(additionalProperties.toImmutable()) + private var validated: Boolean = false + + fun validate(): NewPlanThresholdTotalAmountPrice = apply { + if (validated) { + return@apply } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + cadence() + itemId() + modelType() + name() + thresholdTotalAmountConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewPlanThresholdTotalAmountPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .modelType() + * .name() + * .thresholdTotalAmountConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewPlanThresholdTotalAmountPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var thresholdTotalAmountConfig: + JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: + JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - return /* spotless:off */ other is TieredWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ + @JvmSynthetic + internal fun from( + newPlanThresholdTotalAmountPrice: NewPlanThresholdTotalAmountPrice + ) = apply { + cadence = newPlanThresholdTotalAmountPrice.cadence + itemId = newPlanThresholdTotalAmountPrice.itemId + modelType = newPlanThresholdTotalAmountPrice.modelType + name = newPlanThresholdTotalAmountPrice.name + thresholdTotalAmountConfig = + newPlanThresholdTotalAmountPrice.thresholdTotalAmountConfig + billableMetricId = newPlanThresholdTotalAmountPrice.billableMetricId + billedInAdvance = newPlanThresholdTotalAmountPrice.billedInAdvance + billingCycleConfiguration = + newPlanThresholdTotalAmountPrice.billingCycleConfiguration + conversionRate = newPlanThresholdTotalAmountPrice.conversionRate + currency = newPlanThresholdTotalAmountPrice.currency + externalPriceId = newPlanThresholdTotalAmountPrice.externalPriceId + fixedPriceQuantity = newPlanThresholdTotalAmountPrice.fixedPriceQuantity + invoiceGroupingKey = newPlanThresholdTotalAmountPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newPlanThresholdTotalAmountPrice.invoicingCycleConfiguration + metadata = newPlanThresholdTotalAmountPrice.metadata + additionalProperties = + newPlanThresholdTotalAmountPrice.additionalProperties.toMutableMap() } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - override fun hashCode(): Int = hashCode + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - override fun toString() = - "TieredWithProrationConfig{additionalProperties=$additionalProperties}" - } + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun thresholdTotalAmountConfig( + thresholdTotalAmountConfig: CustomRatingFunctionConfigModel + ) = thresholdTotalAmountConfig(JsonField.of(thresholdTotalAmountConfig)) - private var validated: Boolean = false + fun thresholdTotalAmountConfig( + thresholdTotalAmountConfig: JsonField + ) = apply { this.thresholdTotalAmountConfig = thresholdTotalAmountConfig } - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - duration() - durationUnit() - validated = true + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId } - fun toBuilder() = Builder().from(this) + /** + * If 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)) - 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(billedInAdvance as Boolean?) - @JvmStatic fun builder() = Builder() + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance } - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) - fun build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId } - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - companion object { + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - @JvmField val DAY = of("day") + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - @JvmField val MONTH = of("month") + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.MONTH - else -> Value._UNKNOWN - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the 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 - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - 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 /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + fun build(): NewPlanThresholdTotalAmountPrice = + NewPlanThresholdTotalAmountPrice( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("thresholdTotalAmountConfig", thresholdTotalAmountConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + currency, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) } - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + /** The cadence to bill for this price on. */ + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the 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 unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit + companion object { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + @JvmField val ANNUAL = of("annual") - private var validated: Boolean = false + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } + @JvmField val MONTHLY = of("monthly") - duration() - durationUnit() - validated = true - } + @JvmField val QUARTERLY = of("quarterly") - fun toBuilder() = Builder().from(this) + @JvmField val ONE_TIME = of("one_time") - companion object { + @JvmField val CUSTOM = of("custom") - @JvmStatic fun builder() = Builder() + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) } - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN } - 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) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - fun build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ } - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { + override fun hashCode() = value.hashCode() - @JvmField val DAY = of("day") + override fun toString() = value.toString() + } - @JvmField val MONTH = of("month") + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(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 - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } + companion object { - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + @JvmField val THRESHOLD_TOTAL_AMOUNT = of("threshold_total_amount") - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.MONTH - else -> Value._UNKNOWN - } + @JvmStatic fun of(value: String) = ModelType(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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } + /** An enum containing [ModelType]'s known values. */ + enum class Known { + THRESHOLD_TOTAL_AMOUNT + } + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + THRESHOLD_TOTAL_AMOUNT, /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + THRESHOLD_TOTAL_AMOUNT -> Value.THRESHOLD_TOTAL_AMOUNT + else -> Value._UNKNOWN } - override fun hashCode() = value.hashCode() + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + THRESHOLD_TOTAL_AMOUNT -> Known.THRESHOLD_TOTAL_AMOUNT + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } - override fun toString() = value.toString() - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if 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 } - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } /** @@ -24115,6 +10387,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } @@ -24175,21 +10448,21 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanTierWithProrationPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NewPlanThresholdTotalAmountPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, thresholdTotalAmountConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanTierWithProrationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewPlanThresholdTotalAmountPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } @NoAutoDetect - class NewPlanUnitWithProrationPrice + class NewPlanTieredPackagePrice @JsonCreator private constructor( @JsonProperty("cadence") @@ -24204,9 +10477,9 @@ private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("unit_with_proration_config") + @JsonProperty("tiered_package_config") @ExcludeMissing - private val unitWithProrationConfig: JsonField = + private val tieredPackageConfig: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing @@ -24216,7 +10489,7 @@ private constructor( private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") @ExcludeMissing - private val billingCycleConfiguration: JsonField = + private val billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing @@ -24235,7 +10508,7 @@ private constructor( private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = + private val invoicingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing @@ -24255,8 +10528,8 @@ private constructor( /** The name of the price. */ fun name(): String = name.getRequired("name") - fun unitWithProrationConfig(): UnitWithProrationConfig = - unitWithProrationConfig.getRequired("unit_with_proration_config") + fun tieredPackageConfig(): CustomRatingFunctionConfigModel = + tieredPackageConfig.getRequired("tiered_package_config") /** * The id of the billable metric for the price. Only needed if the price is usage-based. @@ -24274,7 +10547,7 @@ private constructor( /** * For custom cadence: specifies the duration of the billing period in days or months. */ - fun billingCycleConfiguration(): Optional = + fun billingCycleConfiguration(): Optional = Optional.ofNullable( billingCycleConfiguration.getNullable("billing_cycle_configuration") ) @@ -24307,7 +10580,7 @@ private constructor( * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ - fun invoicingCycleConfiguration(): Optional = + fun invoicingCycleConfiguration(): Optional = Optional.ofNullable( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") ) @@ -24333,10 +10606,10 @@ private constructor( /** The name of the price. */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("unit_with_proration_config") + @JsonProperty("tiered_package_config") @ExcludeMissing - fun _unitWithProrationConfig(): JsonField = - unitWithProrationConfig + fun _tieredPackageConfig(): JsonField = + tieredPackageConfig /** * The id of the billable metric for the price. Only needed if the price is usage-based. @@ -24358,7 +10631,7 @@ private constructor( */ @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = + fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @@ -24395,7 +10668,7 @@ private constructor( */ @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = + fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration /** @@ -24413,7 +10686,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPlanUnitWithProrationPrice = apply { + fun validate(): NewPlanTieredPackagePrice = apply { if (validated) { return@apply } @@ -24422,7 +10695,7 @@ private constructor( itemId() modelType() name() - unitWithProrationConfig().validate() + tieredPackageConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration().ifPresent { it.validate() } @@ -24440,55 +10713,67 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [NewPlanTieredPackagePrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .modelType() + * .name() + * .tieredPackageConfig() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewPlanUnitWithProrationPrice]. */ + /** A builder for [NewPlanTieredPackagePrice]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null private var modelType: JsonField? = null private var name: JsonField? = null - private var unitWithProrationConfig: JsonField? = null + private var tieredPackageConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = + private var billingCycleConfiguration: + JsonField = JsonMissing.of() private var conversionRate: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() private var externalPriceId: JsonField = JsonMissing.of() private var fixedPriceQuantity: JsonField = JsonMissing.of() private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = + private var invoicingCycleConfiguration: + JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newPlanUnitWithProrationPrice: NewPlanUnitWithProrationPrice) = - apply { - cadence = newPlanUnitWithProrationPrice.cadence - itemId = newPlanUnitWithProrationPrice.itemId - modelType = newPlanUnitWithProrationPrice.modelType - name = newPlanUnitWithProrationPrice.name - unitWithProrationConfig = - newPlanUnitWithProrationPrice.unitWithProrationConfig - billableMetricId = newPlanUnitWithProrationPrice.billableMetricId - billedInAdvance = newPlanUnitWithProrationPrice.billedInAdvance - billingCycleConfiguration = - newPlanUnitWithProrationPrice.billingCycleConfiguration - conversionRate = newPlanUnitWithProrationPrice.conversionRate - currency = newPlanUnitWithProrationPrice.currency - externalPriceId = newPlanUnitWithProrationPrice.externalPriceId - fixedPriceQuantity = newPlanUnitWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = newPlanUnitWithProrationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newPlanUnitWithProrationPrice.invoicingCycleConfiguration - metadata = newPlanUnitWithProrationPrice.metadata - additionalProperties = - newPlanUnitWithProrationPrice.additionalProperties.toMutableMap() - } + internal fun from(newPlanTieredPackagePrice: NewPlanTieredPackagePrice) = apply { + cadence = newPlanTieredPackagePrice.cadence + itemId = newPlanTieredPackagePrice.itemId + modelType = newPlanTieredPackagePrice.modelType + name = newPlanTieredPackagePrice.name + tieredPackageConfig = newPlanTieredPackagePrice.tieredPackageConfig + billableMetricId = newPlanTieredPackagePrice.billableMetricId + billedInAdvance = newPlanTieredPackagePrice.billedInAdvance + billingCycleConfiguration = newPlanTieredPackagePrice.billingCycleConfiguration + conversionRate = newPlanTieredPackagePrice.conversionRate + currency = newPlanTieredPackagePrice.currency + externalPriceId = newPlanTieredPackagePrice.externalPriceId + fixedPriceQuantity = newPlanTieredPackagePrice.fixedPriceQuantity + invoiceGroupingKey = newPlanTieredPackagePrice.invoiceGroupingKey + invoicingCycleConfiguration = + newPlanTieredPackagePrice.invoicingCycleConfiguration + metadata = newPlanTieredPackagePrice.metadata + additionalProperties = + newPlanTieredPackagePrice.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -24514,12 +10799,12 @@ private constructor( /** The name of the price. */ fun name(name: JsonField) = apply { this.name = name } - fun unitWithProrationConfig(unitWithProrationConfig: UnitWithProrationConfig) = - unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) + fun tieredPackageConfig(tieredPackageConfig: CustomRatingFunctionConfigModel) = + tieredPackageConfig(JsonField.of(tieredPackageConfig)) - fun unitWithProrationConfig( - unitWithProrationConfig: JsonField - ) = apply { this.unitWithProrationConfig = unitWithProrationConfig } + fun tieredPackageConfig( + tieredPackageConfig: JsonField + ) = apply { this.tieredPackageConfig = tieredPackageConfig } /** * The id of the billable metric for the price. Only needed if the price is @@ -24578,7 +10863,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? + billingCycleConfiguration: NewBillingCycleConfigurationModel? ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** @@ -24586,7 +10871,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: Optional + billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) /** @@ -24594,7 +10879,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: JsonField + billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } /** The per unit conversion rate of the price currency to the invoicing currency. */ @@ -24694,7 +10979,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? + invoicingCycleConfiguration: NewBillingCycleConfigurationModel? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** @@ -24702,7 +10987,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional + invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) /** @@ -24710,7 +10995,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField + invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } /** @@ -24756,13 +11041,13 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): NewPlanUnitWithProrationPrice = - NewPlanUnitWithProrationPrice( + fun build(): NewPlanTieredPackagePrice = + NewPlanTieredPackagePrice( checkRequired("cadence", cadence), checkRequired("itemId", itemId), checkRequired("modelType", modelType), checkRequired("name", name), - checkRequired("unitWithProrationConfig", unitWithProrationConfig), + checkRequired("tieredPackageConfig", tieredPackageConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -24777,136 +11062,8 @@ private constructor( ) } - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : + /** The cadence to bill for this price on. */ + class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -24921,29 +11078,49 @@ private constructor( companion object { - @JvmField val UNIT_WITH_PRORATION = of("unit_with_proration") + @JvmField val ANNUAL = of("annual") - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + @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 [ModelType]'s known values. */ + /** An enum containing [Cadence]'s known values. */ enum class Known { - UNIT_WITH_PRORATION + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, } /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. * - * An instance of [ModelType] can contain an unknown value in a couple of cases: + * An instance of [Cadence] can contain an unknown value in a couple of cases: * - It was deserialized from data that doesn't match any known member. For example, * if the SDK is on an older version than the API, then the API may respond with * new members that the SDK is unaware of. * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - UNIT_WITH_PRORATION, + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, /** - * An enum member indicating that [ModelType] was instantiated with an unknown + * An enum member indicating that [Cadence] was instantiated with an unknown * value. */ _UNKNOWN, @@ -24958,7 +11135,12 @@ private constructor( */ fun value(): Value = when (this) { - UNIT_WITH_PRORATION -> Value.UNIT_WITH_PRORATION + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM else -> Value._UNKNOWN } @@ -24973,608 +11155,138 @@ private constructor( */ fun known(): Known = when (this) { - UNIT_WITH_PRORATION -> Known.UNIT_WITH_PRORATION - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class UnitWithProrationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): UnitWithProrationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnitWithProrationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unitWithProrationConfig: UnitWithProrationConfig) = apply { - additionalProperties = - unitWithProrationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): UnitWithProrationConfig = - UnitWithProrationConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UnitWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnitWithProrationConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ + ANNUAL -> Known.ANNUAL + SEMI_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 hashCode() = value.hashCode() - - override fun toString() = value.toString() - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if 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 } - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { - fun toBuilder() = Builder().from(this) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JvmField val TIERED_PACKAGE = of("tiered_package") - fun build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** An enum containing [ModelType]'s known values. */ + enum class Known { + TIERED_PACKAGE + } + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TIERED_PACKAGE, /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } + _UNKNOWN, + } - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TIERED_PACKAGE -> Value.TIERED_PACKAGE + else -> Value._UNKNOWN } - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TIERED_PACKAGE -> Known.TIERED_PACKAGE + else -> throw OrbInvalidDataException("Unknown ModelType: $value") } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if 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 hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } /** @@ -25608,6 +11320,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } @@ -25668,30 +11381,26 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanUnitWithProrationPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && unitWithProrationConfig == other.unitWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NewPlanTieredPackagePrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredPackageConfig == other.tieredPackageConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, unitWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredPackageConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanUnitWithProrationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewPlanTieredPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } @NoAutoDetect - class NewPlanGroupedAllocationPrice + class NewPlanTieredWithMinimumPrice @JsonCreator private constructor( @JsonProperty("cadence") @ExcludeMissing private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_allocation_config") - @ExcludeMissing - private val groupedAllocationConfig: JsonField = - JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing private val itemId: JsonField = JsonMissing.of(), @@ -25701,6 +11410,10 @@ private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_minimum_config") + @ExcludeMissing + private val tieredWithMinimumConfig: JsonField = + JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing private val billableMetricId: JsonField = JsonMissing.of(), @@ -25709,7 +11422,7 @@ private constructor( private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") @ExcludeMissing - private val billingCycleConfiguration: JsonField = + private val billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing @@ -25728,7 +11441,7 @@ private constructor( private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = + private val invoicingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing @@ -25740,9 +11453,6 @@ private constructor( /** The cadence to bill for this price on. */ fun cadence(): Cadence = cadence.getRequired("cadence") - fun groupedAllocationConfig(): GroupedAllocationConfig = - groupedAllocationConfig.getRequired("grouped_allocation_config") - /** The id of the item the price will be associated with. */ fun itemId(): String = itemId.getRequired("item_id") @@ -25751,6 +11461,9 @@ private constructor( /** The name of the price. */ fun name(): String = name.getRequired("name") + fun tieredWithMinimumConfig(): CustomRatingFunctionConfigModel = + tieredWithMinimumConfig.getRequired("tiered_with_minimum_config") + /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ @@ -25767,7 +11480,7 @@ private constructor( /** * For custom cadence: specifies the duration of the billing period in days or months. */ - fun billingCycleConfiguration(): Optional = + fun billingCycleConfiguration(): Optional = Optional.ofNullable( billingCycleConfiguration.getNullable("billing_cycle_configuration") ) @@ -25800,7 +11513,7 @@ private constructor( * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ - fun invoicingCycleConfiguration(): Optional = + fun invoicingCycleConfiguration(): Optional = Optional.ofNullable( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") ) @@ -25816,11 +11529,6 @@ private constructor( /** The cadence to bill for this price on. */ @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - @JsonProperty("grouped_allocation_config") - @ExcludeMissing - fun _groupedAllocationConfig(): JsonField = - groupedAllocationConfig - /** The id of the item the price will be associated with. */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId @@ -25831,6 +11539,11 @@ private constructor( /** The name of the price. */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("tiered_with_minimum_config") + @ExcludeMissing + fun _tieredWithMinimumConfig(): JsonField = + tieredWithMinimumConfig + /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ @@ -25851,7 +11564,7 @@ private constructor( */ @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = + fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @@ -25888,7 +11601,7 @@ private constructor( */ @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = + fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration /** @@ -25906,16 +11619,16 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPlanGroupedAllocationPrice = apply { + fun validate(): NewPlanTieredWithMinimumPrice = apply { if (validated) { return@apply } cadence() - groupedAllocationConfig().validate() itemId() modelType() name() + tieredWithMinimumConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration().ifPresent { it.validate() } @@ -25933,54 +11646,70 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [NewPlanTieredWithMinimumPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .modelType() + * .name() + * .tieredWithMinimumConfig() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewPlanGroupedAllocationPrice]. */ + /** A builder for [NewPlanTieredWithMinimumPrice]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var groupedAllocationConfig: JsonField? = null private var itemId: JsonField? = null private var modelType: JsonField? = null private var name: JsonField? = null + private var tieredWithMinimumConfig: JsonField? = + null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = + private var billingCycleConfiguration: + JsonField = JsonMissing.of() private var conversionRate: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() private var externalPriceId: JsonField = JsonMissing.of() private var fixedPriceQuantity: JsonField = JsonMissing.of() private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = + private var invoicingCycleConfiguration: + JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newPlanGroupedAllocationPrice: NewPlanGroupedAllocationPrice) = + internal fun from(newPlanTieredWithMinimumPrice: NewPlanTieredWithMinimumPrice) = apply { - cadence = newPlanGroupedAllocationPrice.cadence - groupedAllocationConfig = - newPlanGroupedAllocationPrice.groupedAllocationConfig - itemId = newPlanGroupedAllocationPrice.itemId - modelType = newPlanGroupedAllocationPrice.modelType - name = newPlanGroupedAllocationPrice.name - billableMetricId = newPlanGroupedAllocationPrice.billableMetricId - billedInAdvance = newPlanGroupedAllocationPrice.billedInAdvance + cadence = newPlanTieredWithMinimumPrice.cadence + itemId = newPlanTieredWithMinimumPrice.itemId + modelType = newPlanTieredWithMinimumPrice.modelType + name = newPlanTieredWithMinimumPrice.name + tieredWithMinimumConfig = + newPlanTieredWithMinimumPrice.tieredWithMinimumConfig + billableMetricId = newPlanTieredWithMinimumPrice.billableMetricId + billedInAdvance = newPlanTieredWithMinimumPrice.billedInAdvance billingCycleConfiguration = - newPlanGroupedAllocationPrice.billingCycleConfiguration - conversionRate = newPlanGroupedAllocationPrice.conversionRate - currency = newPlanGroupedAllocationPrice.currency - externalPriceId = newPlanGroupedAllocationPrice.externalPriceId - fixedPriceQuantity = newPlanGroupedAllocationPrice.fixedPriceQuantity - invoiceGroupingKey = newPlanGroupedAllocationPrice.invoiceGroupingKey + newPlanTieredWithMinimumPrice.billingCycleConfiguration + conversionRate = newPlanTieredWithMinimumPrice.conversionRate + currency = newPlanTieredWithMinimumPrice.currency + externalPriceId = newPlanTieredWithMinimumPrice.externalPriceId + fixedPriceQuantity = newPlanTieredWithMinimumPrice.fixedPriceQuantity + invoiceGroupingKey = newPlanTieredWithMinimumPrice.invoiceGroupingKey invoicingCycleConfiguration = - newPlanGroupedAllocationPrice.invoicingCycleConfiguration - metadata = newPlanGroupedAllocationPrice.metadata + newPlanTieredWithMinimumPrice.invoicingCycleConfiguration + metadata = newPlanTieredWithMinimumPrice.metadata additionalProperties = - newPlanGroupedAllocationPrice.additionalProperties.toMutableMap() + newPlanTieredWithMinimumPrice.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -25989,13 +11718,6 @@ private constructor( /** The cadence to bill for this price on. */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = - groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) - - fun groupedAllocationConfig( - groupedAllocationConfig: JsonField - ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -26014,6 +11736,14 @@ private constructor( /** The name of the price. */ fun name(name: JsonField) = apply { this.name = name } + fun tieredWithMinimumConfig( + tieredWithMinimumConfig: CustomRatingFunctionConfigModel + ) = tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) + + fun tieredWithMinimumConfig( + tieredWithMinimumConfig: JsonField + ) = apply { this.tieredWithMinimumConfig = tieredWithMinimumConfig } + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -26071,7 +11801,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? + billingCycleConfiguration: NewBillingCycleConfigurationModel? ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** @@ -26079,7 +11809,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: Optional + billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) /** @@ -26087,7 +11817,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: JsonField + billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } /** The per unit conversion rate of the price currency to the invoicing currency. */ @@ -26187,7 +11917,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? + invoicingCycleConfiguration: NewBillingCycleConfigurationModel? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** @@ -26195,7 +11925,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional + invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) /** @@ -26203,287 +11933,75 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewPlanGroupedAllocationPrice = - NewPlanGroupedAllocationPrice( - checkRequired("cadence", cadence), - checkRequired("groupedAllocationConfig", groupedAllocationConfig), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class GroupedAllocationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): GroupedAllocationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [GroupedAllocationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(groupedAllocationConfig: GroupedAllocationConfig) = apply { - additionalProperties = - groupedAllocationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - 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) - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) - 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: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun build(): GroupedAllocationConfig = - GroupedAllocationConfig(additionalProperties.toImmutable()) + 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 /* spotless:off */ other is GroupedAllocationConfig && additionalProperties == other.additionalProperties /* spotless:on */ + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun toString() = - "GroupedAllocationConfig{additionalProperties=$additionalProperties}" + fun build(): NewPlanTieredWithMinimumPrice = + NewPlanTieredWithMinimumPrice( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("tieredWithMinimumConfig", tieredWithMinimumConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + currency, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) } - class ModelType @JsonCreator private constructor(private val value: JsonField) : + /** The cadence to bill for this price on. */ + class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -26498,29 +12016,49 @@ private constructor( companion object { - @JvmField val GROUPED_ALLOCATION = of("grouped_allocation") + @JvmField val ANNUAL = of("annual") - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + @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 [ModelType]'s known values. */ + /** An enum containing [Cadence]'s known values. */ enum class Known { - GROUPED_ALLOCATION + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, } /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. * - * An instance of [ModelType] can contain an unknown value in a couple of cases: + * An instance of [Cadence] can contain an unknown value in a couple of cases: * - It was deserialized from data that doesn't match any known member. For example, * if the SDK is on an older version than the API, then the API may respond with * new members that the SDK is unaware of. * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - GROUPED_ALLOCATION, + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, /** - * An enum member indicating that [ModelType] was instantiated with an unknown + * An enum member indicating that [Cadence] was instantiated with an unknown * value. */ _UNKNOWN, @@ -26535,7 +12073,12 @@ private constructor( */ fun value(): Value = when (this) { - GROUPED_ALLOCATION -> Value.GROUPED_ALLOCATION + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM else -> Value._UNKNOWN } @@ -26550,524 +12093,138 @@ private constructor( */ fun known(): Known = when (this) { - GROUPED_ALLOCATION -> Known.GROUPED_ALLOCATION - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ + ANNUAL -> Known.ANNUAL + SEMI_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 hashCode() = value.hashCode() - - override fun toString() = value.toString() - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if 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 } - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { - fun toBuilder() = Builder().from(this) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JvmField val TIERED_WITH_MINIMUM = of("tiered_with_minimum") - fun build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** An enum containing [ModelType]'s known values. */ + enum class Known { + TIERED_WITH_MINIMUM + } + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TIERED_WITH_MINIMUM, /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } + _UNKNOWN, + } - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TIERED_WITH_MINIMUM -> Value.TIERED_WITH_MINIMUM + else -> Value._UNKNOWN } - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TIERED_WITH_MINIMUM -> Known.TIERED_WITH_MINIMUM + else -> throw OrbInvalidDataException("Unknown ModelType: $value") } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if 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 hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } /** @@ -27101,6 +12258,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } @@ -27161,31 +12319,26 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanGroupedAllocationPrice && cadence == other.cadence && groupedAllocationConfig == other.groupedAllocationConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NewPlanTieredWithMinimumPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredWithMinimumConfig == other.tieredWithMinimumConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, groupedAllocationConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredWithMinimumConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanGroupedAllocationPrice{cadence=$cadence, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewPlanTieredWithMinimumPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } @NoAutoDetect - class NewPlanGroupedWithProratedMinimumPrice + class NewPlanUnitWithPercentPrice @JsonCreator private constructor( @JsonProperty("cadence") @ExcludeMissing private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_prorated_minimum_config") - @ExcludeMissing - private val groupedWithProratedMinimumConfig: - JsonField = - JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing private val itemId: JsonField = JsonMissing.of(), @@ -27195,6 +12348,10 @@ private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("unit_with_percent_config") + @ExcludeMissing + private val unitWithPercentConfig: JsonField = + JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing private val billableMetricId: JsonField = JsonMissing.of(), @@ -27203,7 +12360,7 @@ private constructor( private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") @ExcludeMissing - private val billingCycleConfiguration: JsonField = + private val billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing @@ -27222,7 +12379,7 @@ private constructor( private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = + private val invoicingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing @@ -27234,9 +12391,6 @@ private constructor( /** The cadence to bill for this price on. */ fun cadence(): Cadence = cadence.getRequired("cadence") - fun groupedWithProratedMinimumConfig(): GroupedWithProratedMinimumConfig = - groupedWithProratedMinimumConfig.getRequired("grouped_with_prorated_minimum_config") - /** The id of the item the price will be associated with. */ fun itemId(): String = itemId.getRequired("item_id") @@ -27245,6 +12399,9 @@ private constructor( /** The name of the price. */ fun name(): String = name.getRequired("name") + fun unitWithPercentConfig(): CustomRatingFunctionConfigModel = + unitWithPercentConfig.getRequired("unit_with_percent_config") + /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ @@ -27261,7 +12418,7 @@ private constructor( /** * For custom cadence: specifies the duration of the billing period in days or months. */ - fun billingCycleConfiguration(): Optional = + fun billingCycleConfiguration(): Optional = Optional.ofNullable( billingCycleConfiguration.getNullable("billing_cycle_configuration") ) @@ -27294,7 +12451,7 @@ private constructor( * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ - fun invoicingCycleConfiguration(): Optional = + fun invoicingCycleConfiguration(): Optional = Optional.ofNullable( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") ) @@ -27310,11 +12467,6 @@ private constructor( /** The cadence to bill for this price on. */ @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - @JsonProperty("grouped_with_prorated_minimum_config") - @ExcludeMissing - fun _groupedWithProratedMinimumConfig(): JsonField = - groupedWithProratedMinimumConfig - /** The id of the item the price will be associated with. */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId @@ -27325,6 +12477,11 @@ private constructor( /** The name of the price. */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("unit_with_percent_config") + @ExcludeMissing + fun _unitWithPercentConfig(): JsonField = + unitWithPercentConfig + /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ @@ -27345,7 +12502,7 @@ private constructor( */ @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = + fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @@ -27382,7 +12539,7 @@ private constructor( */ @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = + fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration /** @@ -27400,16 +12557,16 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPlanGroupedWithProratedMinimumPrice = apply { + fun validate(): NewPlanUnitWithPercentPrice = apply { if (validated) { return@apply } cadence() - groupedWithProratedMinimumConfig().validate() itemId() modelType() name() + unitWithPercentConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration().ifPresent { it.validate() } @@ -27427,58 +12584,70 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [NewPlanUnitWithPercentPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .modelType() + * .name() + * .unitWithPercentConfig() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewPlanGroupedWithProratedMinimumPrice]. */ + /** A builder for [NewPlanUnitWithPercentPrice]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var groupedWithProratedMinimumConfig: - JsonField? = - null private var itemId: JsonField? = null private var modelType: JsonField? = null private var name: JsonField? = null + private var unitWithPercentConfig: JsonField? = + null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = + private var billingCycleConfiguration: + JsonField = JsonMissing.of() private var conversionRate: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() private var externalPriceId: JsonField = JsonMissing.of() private var fixedPriceQuantity: JsonField = JsonMissing.of() private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = + private var invoicingCycleConfiguration: + JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newPlanGroupedWithProratedMinimumPrice: NewPlanGroupedWithProratedMinimumPrice - ) = apply { - cadence = newPlanGroupedWithProratedMinimumPrice.cadence - groupedWithProratedMinimumConfig = - newPlanGroupedWithProratedMinimumPrice.groupedWithProratedMinimumConfig - itemId = newPlanGroupedWithProratedMinimumPrice.itemId - modelType = newPlanGroupedWithProratedMinimumPrice.modelType - name = newPlanGroupedWithProratedMinimumPrice.name - billableMetricId = newPlanGroupedWithProratedMinimumPrice.billableMetricId - billedInAdvance = newPlanGroupedWithProratedMinimumPrice.billedInAdvance - billingCycleConfiguration = - newPlanGroupedWithProratedMinimumPrice.billingCycleConfiguration - conversionRate = newPlanGroupedWithProratedMinimumPrice.conversionRate - currency = newPlanGroupedWithProratedMinimumPrice.currency - externalPriceId = newPlanGroupedWithProratedMinimumPrice.externalPriceId - fixedPriceQuantity = newPlanGroupedWithProratedMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = newPlanGroupedWithProratedMinimumPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newPlanGroupedWithProratedMinimumPrice.invoicingCycleConfiguration - metadata = newPlanGroupedWithProratedMinimumPrice.metadata - additionalProperties = - newPlanGroupedWithProratedMinimumPrice.additionalProperties.toMutableMap() - } + internal fun from(newPlanUnitWithPercentPrice: NewPlanUnitWithPercentPrice) = + apply { + cadence = newPlanUnitWithPercentPrice.cadence + itemId = newPlanUnitWithPercentPrice.itemId + modelType = newPlanUnitWithPercentPrice.modelType + name = newPlanUnitWithPercentPrice.name + unitWithPercentConfig = newPlanUnitWithPercentPrice.unitWithPercentConfig + billableMetricId = newPlanUnitWithPercentPrice.billableMetricId + billedInAdvance = newPlanUnitWithPercentPrice.billedInAdvance + billingCycleConfiguration = + newPlanUnitWithPercentPrice.billingCycleConfiguration + conversionRate = newPlanUnitWithPercentPrice.conversionRate + currency = newPlanUnitWithPercentPrice.currency + externalPriceId = newPlanUnitWithPercentPrice.externalPriceId + fixedPriceQuantity = newPlanUnitWithPercentPrice.fixedPriceQuantity + invoiceGroupingKey = newPlanUnitWithPercentPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newPlanUnitWithPercentPrice.invoicingCycleConfiguration + metadata = newPlanUnitWithPercentPrice.metadata + additionalProperties = + newPlanUnitWithPercentPrice.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -27486,16 +12655,6 @@ private constructor( /** The cadence to bill for this price on. */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun groupedWithProratedMinimumConfig( - groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig - ) = groupedWithProratedMinimumConfig(JsonField.of(groupedWithProratedMinimumConfig)) - - fun groupedWithProratedMinimumConfig( - groupedWithProratedMinimumConfig: JsonField - ) = apply { - this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig - } - /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -27514,6 +12673,13 @@ private constructor( /** The name of the price. */ fun name(name: JsonField) = apply { this.name = name } + fun unitWithPercentConfig(unitWithPercentConfig: CustomRatingFunctionConfigModel) = + unitWithPercentConfig(JsonField.of(unitWithPercentConfig)) + + fun unitWithPercentConfig( + unitWithPercentConfig: JsonField + ) = apply { this.unitWithPercentConfig = unitWithPercentConfig } + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -27571,7 +12737,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? + billingCycleConfiguration: NewBillingCycleConfigurationModel? ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** @@ -27579,7 +12745,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: Optional + billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) /** @@ -27587,7 +12753,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: JsonField + billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } /** The per unit conversion rate of the price currency to the invoicing currency. */ @@ -27687,7 +12853,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? + invoicingCycleConfiguration: NewBillingCycleConfigurationModel? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** @@ -27695,7 +12861,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional + invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) /** @@ -27703,7 +12869,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField + invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } /** @@ -27749,16 +12915,13 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): NewPlanGroupedWithProratedMinimumPrice = - NewPlanGroupedWithProratedMinimumPrice( + fun build(): NewPlanUnitWithPercentPrice = + NewPlanUnitWithPercentPrice( checkRequired("cadence", cadence), - checkRequired( - "groupedWithProratedMinimumConfig", - groupedWithProratedMinimumConfig, - ), checkRequired("itemId", itemId), checkRequired("modelType", modelType), checkRequired("name", name), + checkRequired("unitWithPercentConfig", unitWithPercentConfig), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -27902,92 +13065,6 @@ private constructor( override fun toString() = value.toString() } - @NoAutoDetect - class GroupedWithProratedMinimumConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): GroupedWithProratedMinimumConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [GroupedWithProratedMinimumConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig - ) = apply { - additionalProperties = - groupedWithProratedMinimumConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): GroupedWithProratedMinimumConfig = - GroupedWithProratedMinimumConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GroupedWithProratedMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedWithProratedMinimumConfig{additionalProperties=$additionalProperties}" - } - class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -28003,15 +13080,14 @@ private constructor( companion object { - @JvmField - val GROUPED_WITH_PRORATED_MINIMUM = of("grouped_with_prorated_minimum") + @JvmField val UNIT_WITH_PERCENT = of("unit_with_percent") @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } /** An enum containing [ModelType]'s known values. */ enum class Known { - GROUPED_WITH_PRORATED_MINIMUM + UNIT_WITH_PERCENT } /** @@ -28024,7 +13100,7 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - GROUPED_WITH_PRORATED_MINIMUM, + UNIT_WITH_PERCENT, /** * An enum member indicating that [ModelType] was instantiated with an unknown * value. @@ -28041,7 +13117,7 @@ private constructor( */ fun value(): Value = when (this) { - GROUPED_WITH_PRORATED_MINIMUM -> Value.GROUPED_WITH_PRORATED_MINIMUM + UNIT_WITH_PERCENT -> Value.UNIT_WITH_PERCENT else -> Value._UNKNOWN } @@ -28056,328 +13132,61 @@ private constructor( */ fun known(): Known = when (this) { - GROUPED_WITH_PRORATED_MINIMUM -> Known.GROUPED_WITH_PRORATED_MINIMUM + UNIT_WITH_PERCENT -> Known.UNIT_WITH_PERCENT else -> throw OrbInvalidDataException("Unknown ModelType: $value") } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if 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 } - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. */ @NoAutoDetect - class InvoicingCycleConfiguration + class Metadata @JsonCreator private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties private var validated: Boolean = false - fun validate(): InvoicingCycleConfiguration = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } - duration() - durationUnit() validated = true } @@ -28385,38 +13194,18 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [InvoicingCycleConfiguration]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { - private var duration: JsonField? = null - private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -28441,1642 +13230,1815 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } - /** The unit of billing period duration. */ - class DurationUnit - @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 /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } - companion object { + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - @JvmField val DAY = of("day") + override fun hashCode(): Int = hashCode - @JvmField val MONTH = of("month") + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } + return /* spotless:off */ other is NewPlanUnitWithPercentPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && unitWithPercentConfig == other.unitWithPercentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, unitWithPercentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.MONTH - else -> Value._UNKNOWN - } + override fun hashCode(): Int = hashCode - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } + override fun toString() = + "NewPlanUnitWithPercentPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } + @NoAutoDetect + class NewPlanPackageWithAllocationPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("package_with_allocation_config") + @ExcludeMissing + private val packageWithAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") - override fun hashCode() = value.hashCode() + /** The name of the price. */ + fun name(): String = name.getRequired("name") - override fun toString() = value.toString() - } + fun packageWithAllocationConfig(): CustomRatingFunctionConfigModel = + packageWithAllocationConfig.getRequired("package_with_allocation_config") + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("package_with_allocation_config") + @ExcludeMissing + fun _packageWithAllocationConfig(): JsonField = + packageWithAllocationConfig + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - override fun hashCode(): Int = hashCode + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - fun toBuilder() = Builder().from(this) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - companion object { + private var validated: Boolean = false - @JvmStatic fun builder() = Builder() + fun validate(): NewPlanPackageWithAllocationPrice = apply { + if (validated) { + return@apply } - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + cadence() + itemId() + modelType() + name() + packageWithAllocationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun toBuilder() = Builder().from(this) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + companion object { - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns a mutable builder for constructing an instance of + * [NewPlanPackageWithAllocationPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .modelType() + * .name() + * .packageWithAllocationConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** A builder for [NewPlanPackageWithAllocationPrice]. */ + class Builder internal constructor() { - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var packageWithAllocationConfig: + JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: + JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + @JvmSynthetic + internal fun from( + newPlanPackageWithAllocationPrice: NewPlanPackageWithAllocationPrice + ) = apply { + cadence = newPlanPackageWithAllocationPrice.cadence + itemId = newPlanPackageWithAllocationPrice.itemId + modelType = newPlanPackageWithAllocationPrice.modelType + name = newPlanPackageWithAllocationPrice.name + packageWithAllocationConfig = + newPlanPackageWithAllocationPrice.packageWithAllocationConfig + billableMetricId = newPlanPackageWithAllocationPrice.billableMetricId + billedInAdvance = newPlanPackageWithAllocationPrice.billedInAdvance + billingCycleConfiguration = + newPlanPackageWithAllocationPrice.billingCycleConfiguration + conversionRate = newPlanPackageWithAllocationPrice.conversionRate + currency = newPlanPackageWithAllocationPrice.currency + externalPriceId = newPlanPackageWithAllocationPrice.externalPriceId + fixedPriceQuantity = newPlanPackageWithAllocationPrice.fixedPriceQuantity + invoiceGroupingKey = newPlanPackageWithAllocationPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newPlanPackageWithAllocationPrice.invoicingCycleConfiguration + metadata = newPlanPackageWithAllocationPrice.metadata + additionalProperties = + newPlanPackageWithAllocationPrice.additionalProperties.toMutableMap() } - 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 /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - override fun hashCode(): Int = hashCode + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType } - return /* spotless:off */ other is NewPlanGroupedWithProratedMinimumPrice && cadence == other.cadence && groupedWithProratedMinimumConfig == other.groupedWithProratedMinimumConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, groupedWithProratedMinimumConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewPlanGroupedWithProratedMinimumPrice{cadence=$cadence, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - @NoAutoDetect - class NewPlanGroupedWithMeteredMinimumPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_metered_minimum_config") - @ExcludeMissing - private val groupedWithMeteredMinimumConfig: - JsonField = - JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") + fun packageWithAllocationConfig( + packageWithAllocationConfig: CustomRatingFunctionConfigModel + ) = packageWithAllocationConfig(JsonField.of(packageWithAllocationConfig)) - fun groupedWithMeteredMinimumConfig(): GroupedWithMeteredMinimumConfig = - groupedWithMeteredMinimumConfig.getRequired("grouped_with_metered_minimum_config") + fun packageWithAllocationConfig( + packageWithAllocationConfig: JsonField + ) = apply { this.packageWithAllocationConfig = packageWithAllocationConfig } - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - fun modelType(): ModelType = modelType.getRequired("model_type") + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) - /** The name of the price. */ - fun name(): String = name.getRequired("name") + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) - /** - * If 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(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + /** + * If 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(billedInAdvance as Boolean?) - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this price - * is billed. - */ - fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - @JsonProperty("grouped_with_metered_minimum_config") - @ExcludeMissing - fun _groupedWithMeteredMinimumConfig(): JsonField = - groupedWithMeteredMinimumConfig + /** + * 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 item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + 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)) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + + /** The property used to group this price on an invoice */ + 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: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this price - * is billed. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = 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`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - private var validated: Boolean = false + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - fun validate(): NewPlanGroupedWithMeteredMinimumPrice = apply { - if (validated) { - return@apply + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - cadence() - groupedWithMeteredMinimumConfig().validate() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true + fun build(): NewPlanPackageWithAllocationPrice = + NewPlanPackageWithAllocationPrice( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("packageWithAllocationConfig", packageWithAllocationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + currency, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) } - 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 - @JvmStatic fun builder() = Builder() - } + companion object { - /** A builder for [NewPlanGroupedWithMeteredMinimumPrice]. */ - class Builder internal constructor() { + @JvmField val ANNUAL = of("annual") - private var cadence: JsonField? = null - private var groupedWithMeteredMinimumConfig: - JsonField? = - null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + @JvmField val SEMI_ANNUAL = of("semi_annual") - @JvmSynthetic - internal fun from( - newPlanGroupedWithMeteredMinimumPrice: NewPlanGroupedWithMeteredMinimumPrice - ) = apply { - cadence = newPlanGroupedWithMeteredMinimumPrice.cadence - groupedWithMeteredMinimumConfig = - newPlanGroupedWithMeteredMinimumPrice.groupedWithMeteredMinimumConfig - itemId = newPlanGroupedWithMeteredMinimumPrice.itemId - modelType = newPlanGroupedWithMeteredMinimumPrice.modelType - name = newPlanGroupedWithMeteredMinimumPrice.name - billableMetricId = newPlanGroupedWithMeteredMinimumPrice.billableMetricId - billedInAdvance = newPlanGroupedWithMeteredMinimumPrice.billedInAdvance - billingCycleConfiguration = - newPlanGroupedWithMeteredMinimumPrice.billingCycleConfiguration - conversionRate = newPlanGroupedWithMeteredMinimumPrice.conversionRate - currency = newPlanGroupedWithMeteredMinimumPrice.currency - externalPriceId = newPlanGroupedWithMeteredMinimumPrice.externalPriceId - fixedPriceQuantity = newPlanGroupedWithMeteredMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = newPlanGroupedWithMeteredMinimumPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newPlanGroupedWithMeteredMinimumPrice.invoicingCycleConfiguration - metadata = newPlanGroupedWithMeteredMinimumPrice.metadata - additionalProperties = - newPlanGroupedWithMeteredMinimumPrice.additionalProperties.toMutableMap() - } + @JvmField val MONTHLY = of("monthly") - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + @JvmField val QUARTERLY = of("quarterly") - /** The cadence to bill for this price on. */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + @JvmField val ONE_TIME = of("one_time") - fun groupedWithMeteredMinimumConfig( - groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig - ) = groupedWithMeteredMinimumConfig(JsonField.of(groupedWithMeteredMinimumConfig)) + @JvmField val CUSTOM = of("custom") - fun groupedWithMeteredMinimumConfig( - groupedWithMeteredMinimumConfig: JsonField - ) = apply { this.groupedWithMeteredMinimumConfig = groupedWithMeteredMinimumConfig } + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + /** 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") + } - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if 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 modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ } - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) + override fun hashCode() = value.hashCode() - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } + override fun toString() = value.toString() + } - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * 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 billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId + companion object { + + @JvmField val PACKAGE_WITH_ALLOCATION = of("package_with_allocation") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + PACKAGE_WITH_ALLOCATION } /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. + * 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. */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) + enum class Value { + PACKAGE_WITH_ALLOCATION, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * 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. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ - fun billedInAdvance(billedInAdvance: Boolean) = - billedInAdvance(billedInAdvance as Boolean?) + fun value(): Value = + when (this) { + PACKAGE_WITH_ALLOCATION -> Value.PACKAGE_WITH_ALLOCATION + 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. + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + fun known(): Known = + when (this) { + PACKAGE_WITH_ALLOCATION -> Known.PACKAGE_WITH_ALLOCATION + else -> throw OrbInvalidDataException("Unknown ModelType: $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. + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ } - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + override fun hashCode() = value.hashCode() - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + override fun toString() = value.toString() + } - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) + private var validated: Boolean = false - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate + validated = true } - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + fun toBuilder() = Builder().from(this) - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) + companion object { - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + /** 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** An alias for the price. */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + override fun hashCode(): Int = hashCode - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + return /* spotless:off */ other is NewPlanPackageWithAllocationPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && packageWithAllocationConfig == other.packageWithAllocationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey - } + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, packageWithAllocationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + override fun hashCode(): Int = hashCode - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + override fun toString() = + "NewPlanPackageWithAllocationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + @NoAutoDetect + class NewPlanTierWithProrationPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + private val tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_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`. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun modelType(): ModelType = modelType.getRequired("model_type") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** The name of the price. */ + fun name(): String = name.getRequired("name") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun tieredWithProrationConfig(): CustomRatingFunctionConfigModel = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) - fun build(): NewPlanGroupedWithMeteredMinimumPrice = - NewPlanGroupedWithMeteredMinimumPrice( - checkRequired("cadence", cadence), - checkRequired( - "groupedWithMeteredMinimumConfig", - groupedWithMeteredMinimumConfig, - ), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - /** The cadence to bill for this price on. */ - class Cadence @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the 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 alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - companion object { + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - @JvmField val ANNUAL = of("annual") + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - @JvmField val SEMI_ANNUAL = of("semi_annual") + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) - @JvmField val MONTHLY = of("monthly") + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) - @JvmField val QUARTERLY = of("quarterly") + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - @JvmField val ONE_TIME = of("one_time") + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JvmField val CUSTOM = of("custom") + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) - } + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig - /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Cadence] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is 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. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ANNUAL -> 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_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. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + 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. - * - * @throws OrbInvalidDataException if 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. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - override fun hashCode() = value.hashCode() + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - override fun toString() = value.toString() - } + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - @NoAutoDetect - class GroupedWithMeteredMinimumConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = 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`. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - private var validated: Boolean = false + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - fun validate(): GroupedWithMeteredMinimumConfig = apply { - if (validated) { - return@apply - } + private var validated: Boolean = false - validated = true + fun validate(): NewPlanTierWithProrationPrice = apply { + if (validated) { + return@apply } - fun toBuilder() = Builder().from(this) + cadence() + itemId() + modelType() + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } - companion object { + fun toBuilder() = Builder().from(this) - @JvmStatic fun builder() = Builder() - } + companion object { - /** A builder for [GroupedWithMeteredMinimumConfig]. */ - class Builder internal constructor() { + /** + * Returns a mutable builder for constructing an instance of + * [NewPlanTierWithProrationPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .modelType() + * .name() + * .tieredWithProrationConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - private var additionalProperties: MutableMap = mutableMapOf() + /** A builder for [NewPlanTierWithProrationPrice]. */ + class Builder internal constructor() { - @JvmSynthetic - internal fun from( - groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig - ) = apply { + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: + JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(newPlanTierWithProrationPrice: NewPlanTierWithProrationPrice) = + apply { + cadence = newPlanTierWithProrationPrice.cadence + itemId = newPlanTierWithProrationPrice.itemId + modelType = newPlanTierWithProrationPrice.modelType + name = newPlanTierWithProrationPrice.name + tieredWithProrationConfig = + newPlanTierWithProrationPrice.tieredWithProrationConfig + billableMetricId = newPlanTierWithProrationPrice.billableMetricId + billedInAdvance = newPlanTierWithProrationPrice.billedInAdvance + billingCycleConfiguration = + newPlanTierWithProrationPrice.billingCycleConfiguration + conversionRate = newPlanTierWithProrationPrice.conversionRate + currency = newPlanTierWithProrationPrice.currency + externalPriceId = newPlanTierWithProrationPrice.externalPriceId + fixedPriceQuantity = newPlanTierWithProrationPrice.fixedPriceQuantity + invoiceGroupingKey = newPlanTierWithProrationPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newPlanTierWithProrationPrice.invoicingCycleConfiguration + metadata = newPlanTierWithProrationPrice.metadata additionalProperties = - groupedWithMeteredMinimumConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + newPlanTierWithProrationPrice.additionalProperties.toMutableMap() } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun build(): GroupedWithMeteredMinimumConfig = - GroupedWithMeteredMinimumConfig(additionalProperties.toImmutable()) - } + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - return /* spotless:off */ other is GroupedWithMeteredMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - override fun hashCode(): Int = hashCode + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } - override fun toString() = - "GroupedWithMeteredMinimumConfig{additionalProperties=$additionalProperties}" - } + fun tieredWithProrationConfig( + tieredWithProrationConfig: CustomRatingFunctionConfigModel + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * The id of the billable metric for the price. Only needed if the price is + * usage-based. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val GROUPED_WITH_METERED_MINIMUM = of("grouped_with_metered_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_WITH_METERED_MINIMUM - } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) /** - * 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. + * The id of the billable metric for the price. Only needed if the price is + * usage-based. */ - enum class Value { - GROUPED_WITH_METERED_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId } /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. */ - fun value(): Value = - when (this) { - GROUPED_WITH_METERED_MINIMUM -> Value.GROUPED_WITH_METERED_MINIMUM - else -> Value._UNKNOWN - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. + * If 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 known(): Known = - when (this) { - GROUPED_WITH_METERED_MINIMUM -> Known.GROUPED_WITH_METERED_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } + fun billedInAdvance(billedInAdvance: Boolean) = + billedInAdvance(billedInAdvance as Boolean?) /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. + * If 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 asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance } - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - private var validated: Boolean = false + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - duration() - durationUnit() - validated = true - } + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - fun toBuilder() = Builder().from(this) + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - companion object { + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) - @JvmStatic fun builder() = Builder() + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - fun build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId } - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - companion object { + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - @JvmField val DAY = of("day") + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - @JvmField val MONTH = of("month") + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.MONTH - else -> Value._UNKNOWN - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the 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 - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - 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 /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + fun build(): NewPlanTierWithProrationPrice = + NewPlanTierWithProrationPrice( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + currency, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) } - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + /** The cadence to bill for this price on. */ + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the 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 unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit + companion object { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + @JvmField val ANNUAL = of("annual") - private var validated: Boolean = false + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } + @JvmField val MONTHLY = of("monthly") - duration() - durationUnit() - validated = true - } + @JvmField val QUARTERLY = of("quarterly") - fun toBuilder() = Builder().from(this) + @JvmField val ONE_TIME = of("one_time") - companion object { + @JvmField val CUSTOM = of("custom") - @JvmStatic fun builder() = Builder() + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) } - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN } - 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) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - fun build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ } - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { + override fun hashCode() = value.hashCode() - @JvmField val DAY = of("day") + override fun toString() = value.toString() + } - @JvmField val MONTH = of("month") + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(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 - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } + companion object { - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + @JvmField val TIERED_WITH_PRORATION = of("tiered_with_proration") - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.MONTH - else -> Value._UNKNOWN - } + @JvmStatic fun of(value: String) = ModelType(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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } + /** An enum containing [ModelType]'s known values. */ + enum class Known { + TIERED_WITH_PRORATION + } + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TIERED_WITH_PRORATION, /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method 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 [ModelType] was instantiated with an unknown + * value. */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + _UNKNOWN, + } - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TIERED_WITH_PRORATION -> Value.TIERED_WITH_PRORATION + else -> Value._UNKNOWN } - override fun hashCode() = value.hashCode() + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TIERED_WITH_PRORATION -> Known.TIERED_WITH_PRORATION + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } - override fun toString() = value.toString() - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if 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 } - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } /** @@ -30110,6 +15072,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } @@ -30170,21 +15133,21 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanGroupedWithMeteredMinimumPrice && cadence == other.cadence && groupedWithMeteredMinimumConfig == other.groupedWithMeteredMinimumConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NewPlanTierWithProrationPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, groupedWithMeteredMinimumConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanGroupedWithMeteredMinimumPrice{cadence=$cadence, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewPlanTierWithProrationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } @NoAutoDetect - class NewPlanMatrixWithDisplayNamePrice + class NewPlanUnitWithProrationPrice @JsonCreator private constructor( @JsonProperty("cadence") @@ -30193,16 +15156,16 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("matrix_with_display_name_config") - @ExcludeMissing - private val matrixWithDisplayNameConfig: JsonField = - JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing private val modelType: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("unit_with_proration_config") + @ExcludeMissing + private val unitWithProrationConfig: JsonField = + JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing private val billableMetricId: JsonField = JsonMissing.of(), @@ -30211,7 +15174,7 @@ private constructor( private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") @ExcludeMissing - private val billingCycleConfiguration: JsonField = + private val billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing @@ -30230,7 +15193,7 @@ private constructor( private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = + private val invoicingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing @@ -30245,14 +15208,14 @@ private constructor( /** The id of the item the price will be associated with. */ fun itemId(): String = itemId.getRequired("item_id") - fun matrixWithDisplayNameConfig(): MatrixWithDisplayNameConfig = - matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_config") - fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ fun name(): String = name.getRequired("name") + fun unitWithProrationConfig(): CustomRatingFunctionConfigModel = + unitWithProrationConfig.getRequired("unit_with_proration_config") + /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ @@ -30269,7 +15232,7 @@ private constructor( /** * For custom cadence: specifies the duration of the billing period in days or months. */ - fun billingCycleConfiguration(): Optional = + fun billingCycleConfiguration(): Optional = Optional.ofNullable( billingCycleConfiguration.getNullable("billing_cycle_configuration") ) @@ -30282,1298 +15245,1676 @@ private constructor( * An ISO 4217 currency string, or custom pricing unit identifier, in which this price * is billed. */ - fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("unit_with_proration_config") + @ExcludeMissing + fun _unitWithProrationConfig(): JsonField = + unitWithProrationConfig + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = 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(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + private var validated: Boolean = false - @JsonProperty("matrix_with_display_name_config") - @ExcludeMissing - fun _matrixWithDisplayNameConfig(): JsonField = - matrixWithDisplayNameConfig + fun validate(): NewPlanUnitWithProrationPrice = apply { + if (validated) { + return@apply + } - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType + cadence() + itemId() + modelType() + name() + unitWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NewPlanUnitWithProrationPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .modelType() + * .name() + * .unitWithProrationConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NewPlanUnitWithProrationPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var unitWithProrationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: + JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(newPlanUnitWithProrationPrice: NewPlanUnitWithProrationPrice) = + apply { + cadence = newPlanUnitWithProrationPrice.cadence + itemId = newPlanUnitWithProrationPrice.itemId + modelType = newPlanUnitWithProrationPrice.modelType + name = newPlanUnitWithProrationPrice.name + unitWithProrationConfig = + newPlanUnitWithProrationPrice.unitWithProrationConfig + billableMetricId = newPlanUnitWithProrationPrice.billableMetricId + billedInAdvance = newPlanUnitWithProrationPrice.billedInAdvance + billingCycleConfiguration = + newPlanUnitWithProrationPrice.billingCycleConfiguration + conversionRate = newPlanUnitWithProrationPrice.conversionRate + currency = newPlanUnitWithProrationPrice.currency + externalPriceId = newPlanUnitWithProrationPrice.externalPriceId + fixedPriceQuantity = newPlanUnitWithProrationPrice.fixedPriceQuantity + invoiceGroupingKey = newPlanUnitWithProrationPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newPlanUnitWithProrationPrice.invoicingCycleConfiguration + metadata = newPlanUnitWithProrationPrice.metadata + additionalProperties = + newPlanUnitWithProrationPrice.additionalProperties.toMutableMap() + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + 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 id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun unitWithProrationConfig( + unitWithProrationConfig: CustomRatingFunctionConfigModel + ) = unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) + + fun unitWithProrationConfig( + unitWithProrationConfig: JsonField + ) = apply { this.unitWithProrationConfig = unitWithProrationConfig } + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + 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)) + + /** + * If 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(billedInAdvance as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + 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)) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * 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. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = billableMetricId + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this price - * is billed. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - /** - * User-specified key/value pairs for the resource. 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("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = 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: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) - private var validated: Boolean = false + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun validate(): NewPlanMatrixWithDisplayNamePrice = apply { - if (validated) { - return@apply - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - cadence() - itemId() - matrixWithDisplayNameConfig().validate() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) - fun toBuilder() = Builder().from(this) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - companion object { + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - @JvmStatic fun builder() = Builder() - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** A builder for [NewPlanMatrixWithDisplayNamePrice]. */ - class Builder internal constructor() { + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var matrixWithDisplayNameConfig: JsonField? = - null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - @JvmSynthetic - internal fun from( - newPlanMatrixWithDisplayNamePrice: NewPlanMatrixWithDisplayNamePrice - ) = apply { - cadence = newPlanMatrixWithDisplayNamePrice.cadence - itemId = newPlanMatrixWithDisplayNamePrice.itemId - matrixWithDisplayNameConfig = - newPlanMatrixWithDisplayNamePrice.matrixWithDisplayNameConfig - modelType = newPlanMatrixWithDisplayNamePrice.modelType - name = newPlanMatrixWithDisplayNamePrice.name - billableMetricId = newPlanMatrixWithDisplayNamePrice.billableMetricId - billedInAdvance = newPlanMatrixWithDisplayNamePrice.billedInAdvance - billingCycleConfiguration = - newPlanMatrixWithDisplayNamePrice.billingCycleConfiguration - conversionRate = newPlanMatrixWithDisplayNamePrice.conversionRate - currency = newPlanMatrixWithDisplayNamePrice.currency - externalPriceId = newPlanMatrixWithDisplayNamePrice.externalPriceId - fixedPriceQuantity = newPlanMatrixWithDisplayNamePrice.fixedPriceQuantity - invoiceGroupingKey = newPlanMatrixWithDisplayNamePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newPlanMatrixWithDisplayNamePrice.invoicingCycleConfiguration - metadata = newPlanMatrixWithDisplayNamePrice.metadata - additionalProperties = - newPlanMatrixWithDisplayNamePrice.additionalProperties.toMutableMap() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + fun build(): NewPlanUnitWithProrationPrice = + NewPlanUnitWithProrationPrice( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("unitWithProrationConfig", unitWithProrationConfig), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + currency, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) + } - /** The cadence to bill for this price on. */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + /** The cadence to bill for this price on. */ + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + companion object { - fun matrixWithDisplayNameConfig( - matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig - ) = matrixWithDisplayNameConfig(JsonField.of(matrixWithDisplayNameConfig)) + @JvmField val ANNUAL = of("annual") - fun matrixWithDisplayNameConfig( - matrixWithDisplayNameConfig: JsonField - ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + @JvmField val MONTHLY = of("monthly") - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + @JvmField val QUARTERLY = of("quarterly") - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) + @JvmField val ONE_TIME = of("one_time") - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } + @JvmField val CUSTOM = of("custom") - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then 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 billableMetricId(billableMetricId: JsonField) = apply { - this.billableMetricId = billableMetricId + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * 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. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ - fun billedInAdvance(billedInAdvance: Boolean?) = - billedInAdvance(JsonField.ofNullable(billedInAdvance)) + fun value(): Value = + when (this) { + ANNUAL -> 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. + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. */ - fun billedInAdvance(billedInAdvance: Boolean) = - billedInAdvance(billedInAdvance as Boolean?) + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $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. + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(billedInAdvance: JsonField) = apply { - this.billedInAdvance = billedInAdvance + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ } - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) + override fun hashCode() = value.hashCode() - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { /** - * For custom cadence: specifies the duration of the billing period in days or - * months. + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * 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 billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) + companion object { - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) + @JvmField val UNIT_WITH_PRORATION = of("unit_with_proration") - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate + /** An enum containing [ModelType]'s known values. */ + enum class Known { + UNIT_WITH_PRORATION } /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. + * 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. */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + enum class Value { + UNIT_WITH_PRORATION, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. */ - fun currency(currency: Optional) = currency(currency.orElse(null)) + fun value(): Value = + when (this) { + UNIT_WITH_PRORATION -> Value.UNIT_WITH_PRORATION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + UNIT_WITH_PRORATION -> Known.UNIT_WITH_PRORATION + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) + override fun hashCode() = value.hashCode() - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) + override fun toString() = value.toString() + } - /** An alias for the price. */ - 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`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { - /** - * 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 - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) + private var validated: Boolean = false - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + fun validate(): Metadata = apply { + if (validated) { + return@apply + } - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity + validated = true } - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = - invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + fun toBuilder() = Builder().from(this) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + companion object { - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() } - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + /** A builder for [Metadata]. */ + 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. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.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`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + 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: JsonField) = apply { this.metadata = metadata } + 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 build(): Metadata = Metadata(additionalProperties.toImmutable()) } - 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 /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - fun build(): NewPlanMatrixWithDisplayNamePrice = - NewPlanMatrixWithDisplayNamePrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("matrixWithDisplayNameConfig", matrixWithDisplayNameConfig), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) + return /* spotless:off */ other is NewPlanUnitWithProrationPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && unitWithProrationConfig == other.unitWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, unitWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewPlanUnitWithProrationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewPlanGroupedAllocationPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_allocation_config") + @ExcludeMissing + private val groupedAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + /** The cadence to bill for this price on. */ - class Cadence @JsonCreator private constructor(private val value: JsonField) : - Enum { + fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + fun groupedAllocationConfig(): CustomRatingFunctionConfigModel = + groupedAllocationConfig.getRequired("grouped_allocation_config") - companion object { + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") - @JvmField val ANNUAL = of("annual") + fun modelType(): ModelType = modelType.getRequired("model_type") - @JvmField val SEMI_ANNUAL = of("semi_annual") + /** The name of the price. */ + fun name(): String = name.getRequired("name") - @JvmField val MONTHLY = of("monthly") + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - @JvmField val QUARTERLY = of("quarterly") + /** + * If 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(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - @JvmField val ONE_TIME = of("one_time") + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) - @JvmField val CUSTOM = of("custom") + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) - /** An enum containing [Cadence]'s known values. */ - enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, - } + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_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, - } + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_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") - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } + @JsonProperty("grouped_allocation_config") + @ExcludeMissing + fun _groupedAllocationConfig(): JsonField = + groupedAllocationConfig - override fun hashCode() = value.hashCode() + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - override fun toString() = value.toString() - } + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - @NoAutoDetect - class MatrixWithDisplayNameConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - private var validated: Boolean = false + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - fun validate(): MatrixWithDisplayNameConfig = apply { - if (validated) { - return@apply - } + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - validated = true - } + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - fun toBuilder() = Builder().from(this) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - companion object { + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - @JvmStatic fun builder() = Builder() - } + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - /** A builder for [MatrixWithDisplayNameConfig]. */ - class Builder internal constructor() { + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - private var additionalProperties: MutableMap = mutableMapOf() + private var validated: Boolean = false - @JvmSynthetic - internal fun from(matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig) = - apply { - additionalProperties = - matrixWithDisplayNameConfig.additionalProperties.toMutableMap() - } + fun validate(): NewPlanGroupedAllocationPrice = apply { + if (validated) { + return@apply + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + cadence() + groupedAllocationConfig().validate() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } - 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 + * [NewPlanGroupedAllocationPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedAllocationConfig() + * .itemId() + * .modelType() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** A builder for [NewPlanGroupedAllocationPrice]. */ + class Builder internal constructor() { - fun build(): MatrixWithDisplayNameConfig = - MatrixWithDisplayNameConfig(additionalProperties.toImmutable()) - } + private var cadence: JsonField? = null + private var groupedAllocationConfig: JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: + JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + @JvmSynthetic + internal fun from(newPlanGroupedAllocationPrice: NewPlanGroupedAllocationPrice) = + apply { + cadence = newPlanGroupedAllocationPrice.cadence + groupedAllocationConfig = + newPlanGroupedAllocationPrice.groupedAllocationConfig + itemId = newPlanGroupedAllocationPrice.itemId + modelType = newPlanGroupedAllocationPrice.modelType + name = newPlanGroupedAllocationPrice.name + billableMetricId = newPlanGroupedAllocationPrice.billableMetricId + billedInAdvance = newPlanGroupedAllocationPrice.billedInAdvance + billingCycleConfiguration = + newPlanGroupedAllocationPrice.billingCycleConfiguration + conversionRate = newPlanGroupedAllocationPrice.conversionRate + currency = newPlanGroupedAllocationPrice.currency + externalPriceId = newPlanGroupedAllocationPrice.externalPriceId + fixedPriceQuantity = newPlanGroupedAllocationPrice.fixedPriceQuantity + invoiceGroupingKey = newPlanGroupedAllocationPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newPlanGroupedAllocationPrice.invoicingCycleConfiguration + metadata = newPlanGroupedAllocationPrice.metadata + additionalProperties = + newPlanGroupedAllocationPrice.additionalProperties.toMutableMap() } - return /* spotless:off */ other is MatrixWithDisplayNameConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - override fun hashCode(): Int = hashCode + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - override fun toString() = - "MatrixWithDisplayNameConfig{additionalProperties=$additionalProperties}" - } + fun groupedAllocationConfig( + groupedAllocationConfig: CustomRatingFunctionConfigModel + ) = groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { + fun groupedAllocationConfig( + groupedAllocationConfig: JsonField + ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - companion object { + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - @JvmField val MATRIX_WITH_DISPLAY_NAME = of("matrix_with_display_name") + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType } - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MATRIX_WITH_DISPLAY_NAME - } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MATRIX_WITH_DISPLAY_NAME, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. + * The id of the billable metric for the price. Only needed if the price is + * usage-based. */ - fun value(): Value = - when (this) { - MATRIX_WITH_DISPLAY_NAME -> Value.MATRIX_WITH_DISPLAY_NAME - else -> Value._UNKNOWN - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. + * The id of the billable metric for the price. Only needed if the price is + * usage-based. */ - fun known(): Known = - when (this) { - MATRIX_WITH_DISPLAY_NAME -> Known.MATRIX_WITH_DISPLAY_NAME - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(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. + * The id of the billable metric for the price. Only needed if the price is + * usage-based. */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId } - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - 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 toBuilder() = Builder().from(this) + /** + * If 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(billedInAdvance as Boolean?) - 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. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - @JvmStatic fun builder() = Builder() + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance } - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) - fun build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId } - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - companion object { + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - @JvmField val DAY = of("day") + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - @JvmField val MONTH = of("month") + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.MONTH - else -> Value._UNKNOWN - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the 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 - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - 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 /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } + fun build(): NewPlanGroupedAllocationPrice = + NewPlanGroupedAllocationPrice( + checkRequired("cadence", cadence), + checkRequired("groupedAllocationConfig", groupedAllocationConfig), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + currency, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) + } - duration() - durationUnit() - validated = true - } + /** The cadence to bill for this price on. */ + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { - fun toBuilder() = Builder().from(this) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { - @JvmStatic fun builder() = Builder() - } + @JvmField val ANNUAL = of("annual") - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { + @JvmField val SEMI_ANNUAL = of("semi_annual") - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + @JvmField val MONTHLY = of("monthly") - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } + @JvmField val QUARTERLY = of("quarterly") - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) + @JvmField val ONE_TIME = of("one_time") - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } + @JvmField val CUSTOM = of("custom") - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - fun build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ } - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { + override fun hashCode() = value.hashCode() - @JvmField val DAY = of("day") + override fun toString() = value.toString() + } - @JvmField val MONTH = of("month") + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(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 - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } + companion object { - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + @JvmField val GROUPED_ALLOCATION = of("grouped_allocation") - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.MONTH - else -> Value._UNKNOWN - } + @JvmStatic fun of(value: String) = ModelType(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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } + /** An enum containing [ModelType]'s known values. */ + enum class Known { + GROUPED_ALLOCATION + } + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GROUPED_ALLOCATION, /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method 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 [ModelType] was instantiated with an unknown + * value. */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + _UNKNOWN, + } - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GROUPED_ALLOCATION -> Value.GROUPED_ALLOCATION + else -> Value._UNKNOWN } - override fun hashCode() = value.hashCode() + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + GROUPED_ALLOCATION -> Known.GROUPED_ALLOCATION + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } - override fun toString() = value.toString() - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if 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 } - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } /** @@ -31607,6 +16948,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } @@ -31667,30 +17009,31 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanMatrixWithDisplayNamePrice && cadence == other.cadence && itemId == other.itemId && matrixWithDisplayNameConfig == other.matrixWithDisplayNameConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NewPlanGroupedAllocationPrice && cadence == other.cadence && groupedAllocationConfig == other.groupedAllocationConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, matrixWithDisplayNameConfig, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(cadence, groupedAllocationConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanMatrixWithDisplayNamePrice{cadence=$cadence, itemId=$itemId, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewPlanGroupedAllocationPrice{cadence=$cadence, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } @NoAutoDetect - class NewPlanBulkWithProrationPrice + class NewPlanGroupedWithProratedMinimumPrice @JsonCreator private constructor( - @JsonProperty("bulk_with_proration_config") - @ExcludeMissing - private val bulkWithProrationConfig: JsonField = - JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_prorated_minimum_config") + @ExcludeMissing + private val groupedWithProratedMinimumConfig: + JsonField = + JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing private val itemId: JsonField = JsonMissing.of(), @@ -31708,7 +17051,7 @@ private constructor( private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") @ExcludeMissing - private val billingCycleConfiguration: JsonField = + private val billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing @@ -31727,7 +17070,7 @@ private constructor( private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = + private val invoicingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing @@ -31736,12 +17079,12 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - fun bulkWithProrationConfig(): BulkWithProrationConfig = - bulkWithProrationConfig.getRequired("bulk_with_proration_config") - /** The cadence to bill for this price on. */ fun cadence(): Cadence = cadence.getRequired("cadence") + fun groupedWithProratedMinimumConfig(): CustomRatingFunctionConfigModel = + groupedWithProratedMinimumConfig.getRequired("grouped_with_prorated_minimum_config") + /** The id of the item the price will be associated with. */ fun itemId(): String = itemId.getRequired("item_id") @@ -31766,7 +17109,7 @@ private constructor( /** * For custom cadence: specifies the duration of the billing period in days or months. */ - fun billingCycleConfiguration(): Optional = + fun billingCycleConfiguration(): Optional = Optional.ofNullable( billingCycleConfiguration.getNullable("billing_cycle_configuration") ) @@ -31799,7 +17142,7 @@ private constructor( * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ - fun invoicingCycleConfiguration(): Optional = + fun invoicingCycleConfiguration(): Optional = Optional.ofNullable( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") ) @@ -31812,14 +17155,14 @@ private constructor( fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - @JsonProperty("bulk_with_proration_config") - @ExcludeMissing - fun _bulkWithProrationConfig(): JsonField = - bulkWithProrationConfig - /** The cadence to bill for this price on. */ @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + @JsonProperty("grouped_with_prorated_minimum_config") + @ExcludeMissing + fun _groupedWithProratedMinimumConfig(): JsonField = + groupedWithProratedMinimumConfig + /** The id of the item the price will be associated with. */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId @@ -31850,7 +17193,7 @@ private constructor( */ @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = + fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @@ -31887,7 +17230,7 @@ private constructor( */ @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = + fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration /** @@ -31905,13 +17248,13 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPlanBulkWithProrationPrice = apply { + fun validate(): NewPlanGroupedWithProratedMinimumPrice = apply { if (validated) { return@apply } - bulkWithProrationConfig().validate() cadence() + groupedWithProratedMinimumConfig().validate() itemId() modelType() name() @@ -31932,62 +17275,73 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [NewPlanGroupedWithProratedMinimumPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithProratedMinimumConfig() + * .itemId() + * .modelType() + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewPlanBulkWithProrationPrice]. */ + /** A builder for [NewPlanGroupedWithProratedMinimumPrice]. */ class Builder internal constructor() { - private var bulkWithProrationConfig: JsonField? = null private var cadence: JsonField? = null + private var groupedWithProratedMinimumConfig: + JsonField? = + null private var itemId: JsonField? = null private var modelType: JsonField? = null private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = + private var billingCycleConfiguration: + JsonField = JsonMissing.of() private var conversionRate: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() private var externalPriceId: JsonField = JsonMissing.of() private var fixedPriceQuantity: JsonField = JsonMissing.of() private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = + private var invoicingCycleConfiguration: + JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newPlanBulkWithProrationPrice: NewPlanBulkWithProrationPrice) = - apply { - bulkWithProrationConfig = - newPlanBulkWithProrationPrice.bulkWithProrationConfig - cadence = newPlanBulkWithProrationPrice.cadence - itemId = newPlanBulkWithProrationPrice.itemId - modelType = newPlanBulkWithProrationPrice.modelType - name = newPlanBulkWithProrationPrice.name - billableMetricId = newPlanBulkWithProrationPrice.billableMetricId - billedInAdvance = newPlanBulkWithProrationPrice.billedInAdvance - billingCycleConfiguration = - newPlanBulkWithProrationPrice.billingCycleConfiguration - conversionRate = newPlanBulkWithProrationPrice.conversionRate - currency = newPlanBulkWithProrationPrice.currency - externalPriceId = newPlanBulkWithProrationPrice.externalPriceId - fixedPriceQuantity = newPlanBulkWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = newPlanBulkWithProrationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newPlanBulkWithProrationPrice.invoicingCycleConfiguration - metadata = newPlanBulkWithProrationPrice.metadata - additionalProperties = - newPlanBulkWithProrationPrice.additionalProperties.toMutableMap() - } - - fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = - bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) - - fun bulkWithProrationConfig( - bulkWithProrationConfig: JsonField - ) = apply { this.bulkWithProrationConfig = bulkWithProrationConfig } + internal fun from( + newPlanGroupedWithProratedMinimumPrice: NewPlanGroupedWithProratedMinimumPrice + ) = apply { + cadence = newPlanGroupedWithProratedMinimumPrice.cadence + groupedWithProratedMinimumConfig = + newPlanGroupedWithProratedMinimumPrice.groupedWithProratedMinimumConfig + itemId = newPlanGroupedWithProratedMinimumPrice.itemId + modelType = newPlanGroupedWithProratedMinimumPrice.modelType + name = newPlanGroupedWithProratedMinimumPrice.name + billableMetricId = newPlanGroupedWithProratedMinimumPrice.billableMetricId + billedInAdvance = newPlanGroupedWithProratedMinimumPrice.billedInAdvance + billingCycleConfiguration = + newPlanGroupedWithProratedMinimumPrice.billingCycleConfiguration + conversionRate = newPlanGroupedWithProratedMinimumPrice.conversionRate + currency = newPlanGroupedWithProratedMinimumPrice.currency + externalPriceId = newPlanGroupedWithProratedMinimumPrice.externalPriceId + fixedPriceQuantity = newPlanGroupedWithProratedMinimumPrice.fixedPriceQuantity + invoiceGroupingKey = newPlanGroupedWithProratedMinimumPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newPlanGroupedWithProratedMinimumPrice.invoicingCycleConfiguration + metadata = newPlanGroupedWithProratedMinimumPrice.metadata + additionalProperties = + newPlanGroupedWithProratedMinimumPrice.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -31995,6 +17349,16 @@ private constructor( /** The cadence to bill for this price on. */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: CustomRatingFunctionConfigModel + ) = groupedWithProratedMinimumConfig(JsonField.of(groupedWithProratedMinimumConfig)) + + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: JsonField + ) = apply { + this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig + } + /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -32070,7 +17434,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? + billingCycleConfiguration: NewBillingCycleConfigurationModel? ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** @@ -32078,7 +17442,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: Optional + billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) /** @@ -32086,7 +17450,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: JsonField + billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } /** The per unit conversion rate of the price currency to the invoicing currency. */ @@ -32186,7 +17550,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? + invoicingCycleConfiguration: NewBillingCycleConfigurationModel? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** @@ -32194,7 +17558,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional + invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) /** @@ -32202,7 +17566,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField + invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } /** @@ -32248,10 +17612,13 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): NewPlanBulkWithProrationPrice = - NewPlanBulkWithProrationPrice( - checkRequired("bulkWithProrationConfig", bulkWithProrationConfig), + fun build(): NewPlanGroupedWithProratedMinimumPrice = + NewPlanGroupedWithProratedMinimumPrice( checkRequired("cadence", cadence), + checkRequired( + "groupedWithProratedMinimumConfig", + groupedWithProratedMinimumConfig, + ), checkRequired("itemId", itemId), checkRequired("modelType", modelType), checkRequired("name", name), @@ -32269,90 +17636,6 @@ private constructor( ) } - @NoAutoDetect - class BulkWithProrationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BulkWithProrationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkWithProrationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(bulkWithProrationConfig: BulkWithProrationConfig) = apply { - additionalProperties = - bulkWithProrationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): BulkWithProrationConfig = - BulkWithProrationConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BulkWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkWithProrationConfig{additionalProperties=$additionalProperties}" - } - /** The cadence to bill for this price on. */ class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -32446,111 +17729,13 @@ private constructor( */ fun known(): Known = when (this) { - ANNUAL -> Known.ANNUAL - SEMI_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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val BULK_WITH_PRORATION = of("bulk_with_proration") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK_WITH_PRORATION - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK_WITH_PRORATION, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK_WITH_PRORATION -> Value.BULK_WITH_PRORATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - BULK_WITH_PRORATION -> Known.BULK_WITH_PRORATION - else -> throw OrbInvalidDataException("Unknown ModelType: $value") + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") } /** @@ -32572,7 +17757,7 @@ private constructor( return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -32580,493 +17765,103 @@ private constructor( override fun toString() = value.toString() } - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { - fun toBuilder() = Builder().from(this) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { + @JvmField + val GROUPED_WITH_PRORATED_MINIMUM = of("grouped_with_prorated_minimum") - @JvmStatic fun builder() = Builder() + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) + /** An enum containing [ModelType]'s known values. */ + enum class Known { + GROUPED_WITH_PRORATED_MINIMUM } - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GROUPED_WITH_PRORATED_MINIMUM, /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method 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 [ModelType] was instantiated with an unknown + * value. */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + _UNKNOWN, + } - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GROUPED_WITH_PRORATED_MINIMUM -> Value.GROUPED_WITH_PRORATED_MINIMUM + else -> Value._UNKNOWN } - override fun hashCode() = value.hashCode() + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + GROUPED_WITH_PRORATED_MINIMUM -> Known.GROUPED_WITH_PRORATED_MINIMUM + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } - override fun toString() = value.toString() - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if 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 } - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } /** @@ -33100,6 +17895,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } @@ -33160,29 +17956,30 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanBulkWithProrationPrice && bulkWithProrationConfig == other.bulkWithProrationConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NewPlanGroupedWithProratedMinimumPrice && cadence == other.cadence && groupedWithProratedMinimumConfig == other.groupedWithProratedMinimumConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bulkWithProrationConfig, cadence, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(cadence, groupedWithProratedMinimumConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanBulkWithProrationPrice{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewPlanGroupedWithProratedMinimumPrice{cadence=$cadence, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } @NoAutoDetect - class NewPlanGroupedTieredPackagePrice + class NewPlanGroupedWithMeteredMinimumPrice @JsonCreator private constructor( @JsonProperty("cadence") @ExcludeMissing private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_tiered_package_config") + @JsonProperty("grouped_with_metered_minimum_config") @ExcludeMissing - private val groupedTieredPackageConfig: JsonField = + private val groupedWithMeteredMinimumConfig: + JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing @@ -33201,7 +17998,7 @@ private constructor( private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") @ExcludeMissing - private val billingCycleConfiguration: JsonField = + private val billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing @@ -33220,7 +18017,7 @@ private constructor( private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = + private val invoicingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing @@ -33232,8 +18029,8 @@ private constructor( /** The cadence to bill for this price on. */ fun cadence(): Cadence = cadence.getRequired("cadence") - fun groupedTieredPackageConfig(): GroupedTieredPackageConfig = - groupedTieredPackageConfig.getRequired("grouped_tiered_package_config") + fun groupedWithMeteredMinimumConfig(): CustomRatingFunctionConfigModel = + groupedWithMeteredMinimumConfig.getRequired("grouped_with_metered_minimum_config") /** The id of the item the price will be associated with. */ fun itemId(): String = itemId.getRequired("item_id") @@ -33259,7 +18056,7 @@ private constructor( /** * For custom cadence: specifies the duration of the billing period in days or months. */ - fun billingCycleConfiguration(): Optional = + fun billingCycleConfiguration(): Optional = Optional.ofNullable( billingCycleConfiguration.getNullable("billing_cycle_configuration") ) @@ -33292,7 +18089,7 @@ private constructor( * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ - fun invoicingCycleConfiguration(): Optional = + fun invoicingCycleConfiguration(): Optional = Optional.ofNullable( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") ) @@ -33308,10 +18105,10 @@ private constructor( /** The cadence to bill for this price on. */ @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - @JsonProperty("grouped_tiered_package_config") + @JsonProperty("grouped_with_metered_minimum_config") @ExcludeMissing - fun _groupedTieredPackageConfig(): JsonField = - groupedTieredPackageConfig + fun _groupedWithMeteredMinimumConfig(): JsonField = + groupedWithMeteredMinimumConfig /** The id of the item the price will be associated with. */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId @@ -33343,7 +18140,7 @@ private constructor( */ @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = + fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @@ -33380,7 +18177,7 @@ private constructor( */ @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = + fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration /** @@ -33398,13 +18195,13 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPlanGroupedTieredPackagePrice = apply { + fun validate(): NewPlanGroupedWithMeteredMinimumPrice = apply { if (validated) { return@apply } cadence() - groupedTieredPackageConfig().validate() + groupedWithMeteredMinimumConfig().validate() itemId() modelType() name() @@ -33425,56 +18222,72 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [NewPlanGroupedWithMeteredMinimumPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .groupedWithMeteredMinimumConfig() + * .itemId() + * .modelType() + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewPlanGroupedTieredPackagePrice]. */ + /** A builder for [NewPlanGroupedWithMeteredMinimumPrice]. */ class Builder internal constructor() { private var cadence: JsonField? = null - private var groupedTieredPackageConfig: JsonField? = + private var groupedWithMeteredMinimumConfig: + JsonField? = null private var itemId: JsonField? = null private var modelType: JsonField? = null private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = + private var billingCycleConfiguration: + JsonField = JsonMissing.of() private var conversionRate: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() private var externalPriceId: JsonField = JsonMissing.of() private var fixedPriceQuantity: JsonField = JsonMissing.of() private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = + private var invoicingCycleConfiguration: + JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from( - newPlanGroupedTieredPackagePrice: NewPlanGroupedTieredPackagePrice + newPlanGroupedWithMeteredMinimumPrice: NewPlanGroupedWithMeteredMinimumPrice ) = apply { - cadence = newPlanGroupedTieredPackagePrice.cadence - groupedTieredPackageConfig = - newPlanGroupedTieredPackagePrice.groupedTieredPackageConfig - itemId = newPlanGroupedTieredPackagePrice.itemId - modelType = newPlanGroupedTieredPackagePrice.modelType - name = newPlanGroupedTieredPackagePrice.name - billableMetricId = newPlanGroupedTieredPackagePrice.billableMetricId - billedInAdvance = newPlanGroupedTieredPackagePrice.billedInAdvance + cadence = newPlanGroupedWithMeteredMinimumPrice.cadence + groupedWithMeteredMinimumConfig = + newPlanGroupedWithMeteredMinimumPrice.groupedWithMeteredMinimumConfig + itemId = newPlanGroupedWithMeteredMinimumPrice.itemId + modelType = newPlanGroupedWithMeteredMinimumPrice.modelType + name = newPlanGroupedWithMeteredMinimumPrice.name + billableMetricId = newPlanGroupedWithMeteredMinimumPrice.billableMetricId + billedInAdvance = newPlanGroupedWithMeteredMinimumPrice.billedInAdvance billingCycleConfiguration = - newPlanGroupedTieredPackagePrice.billingCycleConfiguration - conversionRate = newPlanGroupedTieredPackagePrice.conversionRate - currency = newPlanGroupedTieredPackagePrice.currency - externalPriceId = newPlanGroupedTieredPackagePrice.externalPriceId - fixedPriceQuantity = newPlanGroupedTieredPackagePrice.fixedPriceQuantity - invoiceGroupingKey = newPlanGroupedTieredPackagePrice.invoiceGroupingKey + newPlanGroupedWithMeteredMinimumPrice.billingCycleConfiguration + conversionRate = newPlanGroupedWithMeteredMinimumPrice.conversionRate + currency = newPlanGroupedWithMeteredMinimumPrice.currency + externalPriceId = newPlanGroupedWithMeteredMinimumPrice.externalPriceId + fixedPriceQuantity = newPlanGroupedWithMeteredMinimumPrice.fixedPriceQuantity + invoiceGroupingKey = newPlanGroupedWithMeteredMinimumPrice.invoiceGroupingKey invoicingCycleConfiguration = - newPlanGroupedTieredPackagePrice.invoicingCycleConfiguration - metadata = newPlanGroupedTieredPackagePrice.metadata + newPlanGroupedWithMeteredMinimumPrice.invoicingCycleConfiguration + metadata = newPlanGroupedWithMeteredMinimumPrice.metadata additionalProperties = - newPlanGroupedTieredPackagePrice.additionalProperties.toMutableMap() + newPlanGroupedWithMeteredMinimumPrice.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -33483,13 +18296,13 @@ private constructor( /** The cadence to bill for this price on. */ fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun groupedTieredPackageConfig( - groupedTieredPackageConfig: GroupedTieredPackageConfig - ) = groupedTieredPackageConfig(JsonField.of(groupedTieredPackageConfig)) + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: CustomRatingFunctionConfigModel + ) = groupedWithMeteredMinimumConfig(JsonField.of(groupedWithMeteredMinimumConfig)) - fun groupedTieredPackageConfig( - groupedTieredPackageConfig: JsonField - ) = apply { this.groupedTieredPackageConfig = groupedTieredPackageConfig } + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: JsonField + ) = apply { this.groupedWithMeteredMinimumConfig = groupedWithMeteredMinimumConfig } /** The id of the item the price will be associated with. */ fun itemId(itemId: String) = itemId(JsonField.of(itemId)) @@ -33566,7 +18379,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? + billingCycleConfiguration: NewBillingCycleConfigurationModel? ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** @@ -33574,7 +18387,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: Optional + billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) /** @@ -33582,7 +18395,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: JsonField + billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } /** The per unit conversion rate of the price currency to the invoicing currency. */ @@ -33682,7 +18495,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? + invoicingCycleConfiguration: NewBillingCycleConfigurationModel? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** @@ -33690,7 +18503,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional + invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) /** @@ -33698,7 +18511,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField + invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } /** @@ -33744,10 +18557,13 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): NewPlanGroupedTieredPackagePrice = - NewPlanGroupedTieredPackagePrice( + fun build(): NewPlanGroupedWithMeteredMinimumPrice = + NewPlanGroupedWithMeteredMinimumPrice( checkRequired("cadence", cadence), - checkRequired("groupedTieredPackageConfig", groupedTieredPackageConfig), + checkRequired( + "groupedWithMeteredMinimumConfig", + groupedWithMeteredMinimumConfig, + ), checkRequired("itemId", itemId), checkRequired("modelType", modelType), checkRequired("name", name), @@ -33765,8 +18581,136 @@ private constructor( ) } - /** The cadence to bill for this price on. */ - class Cadence @JsonCreator private constructor(private val value: JsonField) : + /** 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") + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -33781,49 +18725,29 @@ private constructor( 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") + @JvmField val GROUPED_WITH_METERED_MINIMUM = of("grouped_with_metered_minimum") - @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } - /** An enum containing [Cadence]'s known values. */ + /** An enum containing [ModelType]'s known values. */ enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, + GROUPED_WITH_METERED_MINIMUM } /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [ModelType]'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 [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 { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, + GROUPED_WITH_METERED_MINIMUM, /** - * An enum member indicating that [Cadence] was instantiated with an unknown + * An enum member indicating that [ModelType] was instantiated with an unknown * value. */ _UNKNOWN, @@ -33838,12 +18762,7 @@ private constructor( */ fun value(): Value = when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM + GROUPED_WITH_METERED_MINIMUM -> Value.GROUPED_WITH_METERED_MINIMUM else -> Value._UNKNOWN } @@ -33858,13 +18777,8 @@ private constructor( */ fun known(): Known = when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") + GROUPED_WITH_METERED_MINIMUM -> Known.GROUPED_WITH_METERED_MINIMUM + else -> throw OrbInvalidDataException("Unknown ModelType: $value") } /** @@ -33886,7 +18800,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -33894,8 +18808,13 @@ private constructor( 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`. + */ @NoAutoDetect - class GroupedTieredPackageConfig + class Metadata @JsonCreator private constructor( @JsonAnySetter @@ -33908,7 +18827,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedTieredPackageConfig = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } @@ -33920,650 +18839,913 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedTieredPackageConfig]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(groupedTieredPackageConfig: GroupedTieredPackageConfig) = - apply { - additionalProperties = - groupedTieredPackageConfig.additionalProperties.toMutableMap() - } + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewPlanGroupedWithMeteredMinimumPrice && cadence == other.cadence && groupedWithMeteredMinimumConfig == other.groupedWithMeteredMinimumConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, groupedWithMeteredMinimumConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewPlanGroupedWithMeteredMinimumPrice{cadence=$cadence, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewPlanMatrixWithDisplayNamePrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + private val matrixWithDisplayNameConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun matrixWithDisplayNameConfig(): CustomRatingFunctionConfigModel = + matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_config") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + fun _matrixWithDisplayNameConfig(): JsonField = + matrixWithDisplayNameConfig - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - fun build(): GroupedTieredPackageConfig = - GroupedTieredPackageConfig(additionalProperties.toImmutable()) - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - return /* spotless:off */ other is GroupedTieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - override fun hashCode(): Int = hashCode + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - override fun toString() = - "GroupedTieredPackageConfig{additionalProperties=$additionalProperties}" - } + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - companion object { + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - @JvmField val GROUPED_TIERED_PACKAGE = of("grouped_tiered_package") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } + private var validated: Boolean = false - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_TIERED_PACKAGE + fun validate(): NewPlanMatrixWithDisplayNamePrice = apply { + if (validated) { + return@apply } - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GROUPED_TIERED_PACKAGE, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + cadence() + itemId() + matrixWithDisplayNameConfig().validate() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + 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) { - GROUPED_TIERED_PACKAGE -> Value.GROUPED_TIERED_PACKAGE - else -> Value._UNKNOWN - } + fun toBuilder() = Builder().from(this) - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - GROUPED_TIERED_PACKAGE -> Known.GROUPED_TIERED_PACKAGE - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } + companion object { /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. + * Returns a mutable builder for constructing an instance of + * [NewPlanMatrixWithDisplayNamePrice]. * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .matrixWithDisplayNameConfig() + * .modelType() + * .name() + * ``` */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } + @JvmStatic fun builder() = Builder() + } - override fun hashCode() = value.hashCode() + /** A builder for [NewPlanMatrixWithDisplayNamePrice]. */ + class Builder internal constructor() { - override fun toString() = value.toString() - } + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var matrixWithDisplayNameConfig: + JsonField? = + null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: + JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + @JvmSynthetic + internal fun from( + newPlanMatrixWithDisplayNamePrice: NewPlanMatrixWithDisplayNamePrice + ) = apply { + cadence = newPlanMatrixWithDisplayNamePrice.cadence + itemId = newPlanMatrixWithDisplayNamePrice.itemId + matrixWithDisplayNameConfig = + newPlanMatrixWithDisplayNamePrice.matrixWithDisplayNameConfig + modelType = newPlanMatrixWithDisplayNamePrice.modelType + name = newPlanMatrixWithDisplayNamePrice.name + billableMetricId = newPlanMatrixWithDisplayNamePrice.billableMetricId + billedInAdvance = newPlanMatrixWithDisplayNamePrice.billedInAdvance + billingCycleConfiguration = + newPlanMatrixWithDisplayNamePrice.billingCycleConfiguration + conversionRate = newPlanMatrixWithDisplayNamePrice.conversionRate + currency = newPlanMatrixWithDisplayNamePrice.currency + externalPriceId = newPlanMatrixWithDisplayNamePrice.externalPriceId + fixedPriceQuantity = newPlanMatrixWithDisplayNamePrice.fixedPriceQuantity + invoiceGroupingKey = newPlanMatrixWithDisplayNamePrice.invoiceGroupingKey + invoicingCycleConfiguration = + newPlanMatrixWithDisplayNamePrice.invoicingCycleConfiguration + metadata = newPlanMatrixWithDisplayNamePrice.metadata + additionalProperties = + newPlanMatrixWithDisplayNamePrice.additionalProperties.toMutableMap() + } - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: CustomRatingFunctionConfigModel + ) = matrixWithDisplayNameConfig(JsonField.of(matrixWithDisplayNameConfig)) - private var validated: Boolean = false + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: JsonField + ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - duration() - durationUnit() - validated = true + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType } - fun toBuilder() = Builder().from(this) + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - companion object { + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } - @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 [BillingCycleConfiguration]. */ - class Builder internal constructor() { + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.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)) - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) + /** + * If 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(billedInAdvance as Boolean?) - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - 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: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - 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: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - 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(conversionRate as Double?) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) - fun build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - 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)) - @JvmField val DAY = of("day") + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) - @JvmField val MONTH = of("month") + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.MONTH - else -> Value._UNKNOWN - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - override fun hashCode() = value.hashCode() + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - override fun toString() = value.toString() + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) - override fun hashCode(): Int = hashCode + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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)) - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - private var validated: Boolean = false + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } + fun build(): NewPlanMatrixWithDisplayNamePrice = + NewPlanMatrixWithDisplayNamePrice( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("matrixWithDisplayNameConfig", matrixWithDisplayNameConfig), + checkRequired("modelType", modelType), + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + currency, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) + } - duration() - durationUnit() - validated = true - } + /** The cadence to bill for this price on. */ + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { - fun toBuilder() = Builder().from(this) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { - @JvmStatic fun builder() = Builder() - } + @JvmField val ANNUAL = of("annual") - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { + @JvmField val SEMI_ANNUAL = of("semi_annual") - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + @JvmField val MONTHLY = of("monthly") - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } + @JvmField val QUARTERLY = of("quarterly") - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) + @JvmField val ONE_TIME = of("one_time") - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } + @JvmField val CUSTOM = of("custom") - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OrbInvalidDataException("Value is not a String") } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - fun build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ } - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { + override fun hashCode() = value.hashCode() - @JvmField val DAY = of("day") + override fun toString() = value.toString() + } - @JvmField val MONTH = of("month") + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(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 - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } + companion object { - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + @JvmField val MATRIX_WITH_DISPLAY_NAME = of("matrix_with_display_name") - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.MONTH - else -> Value._UNKNOWN - } + @JvmStatic fun of(value: String) = ModelType(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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } + /** An enum containing [ModelType]'s known values. */ + enum class Known { + MATRIX_WITH_DISPLAY_NAME + } + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MATRIX_WITH_DISPLAY_NAME, /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method 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 [ModelType] was instantiated with an unknown + * value. */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } + _UNKNOWN, + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return 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) { + MATRIX_WITH_DISPLAY_NAME -> Value.MATRIX_WITH_DISPLAY_NAME + else -> Value._UNKNOWN + } - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MATRIX_WITH_DISPLAY_NAME -> Known.MATRIX_WITH_DISPLAY_NAME + else -> throw OrbInvalidDataException("Unknown ModelType: $value") } - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if 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 } - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } /** @@ -34597,6 +19779,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } @@ -34657,33 +19840,33 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanGroupedTieredPackagePrice && cadence == other.cadence && groupedTieredPackageConfig == other.groupedTieredPackageConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NewPlanMatrixWithDisplayNamePrice && cadence == other.cadence && itemId == other.itemId && matrixWithDisplayNameConfig == other.matrixWithDisplayNameConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, groupedTieredPackageConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(cadence, itemId, matrixWithDisplayNameConfig, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanGroupedTieredPackagePrice{cadence=$cadence, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewPlanMatrixWithDisplayNamePrice{cadence=$cadence, itemId=$itemId, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } @NoAutoDetect - class NewPlanMaxGroupTieredPackagePrice + class NewPlanBulkWithProrationPrice @JsonCreator private constructor( + @JsonProperty("bulk_with_proration_config") + @ExcludeMissing + private val bulkWithProrationConfig: JsonField = + JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing private val cadence: JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("max_group_tiered_package_config") - @ExcludeMissing - private val maxGroupTieredPackageConfig: JsonField = - JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing private val modelType: JsonField = JsonMissing.of(), @@ -34698,7 +19881,7 @@ private constructor( private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") @ExcludeMissing - private val billingCycleConfiguration: JsonField = + private val billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing @@ -34717,7 +19900,7 @@ private constructor( private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = + private val invoicingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing @@ -34726,15 +19909,15 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { + fun bulkWithProrationConfig(): CustomRatingFunctionConfigModel = + bulkWithProrationConfig.getRequired("bulk_with_proration_config") + /** The cadence to bill for this price on. */ fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the price will be associated with. */ fun itemId(): String = itemId.getRequired("item_id") - fun maxGroupTieredPackageConfig(): MaxGroupTieredPackageConfig = - maxGroupTieredPackageConfig.getRequired("max_group_tiered_package_config") - fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ @@ -34756,7 +19939,7 @@ private constructor( /** * For custom cadence: specifies the duration of the billing period in days or months. */ - fun billingCycleConfiguration(): Optional = + fun billingCycleConfiguration(): Optional = Optional.ofNullable( billingCycleConfiguration.getNullable("billing_cycle_configuration") ) @@ -34789,7 +19972,7 @@ private constructor( * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ - fun invoicingCycleConfiguration(): Optional = + fun invoicingCycleConfiguration(): Optional = Optional.ofNullable( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") ) @@ -34802,17 +19985,17 @@ private constructor( fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + @JsonProperty("bulk_with_proration_config") + @ExcludeMissing + fun _bulkWithProrationConfig(): JsonField = + bulkWithProrationConfig + /** The cadence to bill for this price on. */ @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence /** The id of the item the price will be associated with. */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("max_group_tiered_package_config") - @ExcludeMissing - fun _maxGroupTieredPackageConfig(): JsonField = - maxGroupTieredPackageConfig - @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonField = modelType @@ -34840,7 +20023,7 @@ private constructor( */ @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = + fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @@ -34877,7 +20060,7 @@ private constructor( */ @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = + fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration /** @@ -34895,14 +20078,14 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPlanMaxGroupTieredPackagePrice = apply { + fun validate(): NewPlanBulkWithProrationPrice = apply { if (validated) { return@apply } + bulkWithProrationConfig().validate() cadence() itemId() - maxGroupTieredPackageConfig().validate() modelType() name() billableMetricId() @@ -34922,57 +20105,79 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [NewPlanBulkWithProrationPrice]. + * + * The following fields are required: + * ```java + * .bulkWithProrationConfig() + * .cadence() + * .itemId() + * .modelType() + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewPlanMaxGroupTieredPackagePrice]. */ + /** A builder for [NewPlanBulkWithProrationPrice]. */ class Builder internal constructor() { + private var bulkWithProrationConfig: JsonField? = + null private var cadence: JsonField? = null private var itemId: JsonField? = null - private var maxGroupTieredPackageConfig: JsonField? = - null private var modelType: JsonField? = null private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = + private var billingCycleConfiguration: + JsonField = JsonMissing.of() private var conversionRate: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() private var externalPriceId: JsonField = JsonMissing.of() private var fixedPriceQuantity: JsonField = JsonMissing.of() private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = + private var invoicingCycleConfiguration: + JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newPlanMaxGroupTieredPackagePrice: NewPlanMaxGroupTieredPackagePrice - ) = apply { - cadence = newPlanMaxGroupTieredPackagePrice.cadence - itemId = newPlanMaxGroupTieredPackagePrice.itemId - maxGroupTieredPackageConfig = - newPlanMaxGroupTieredPackagePrice.maxGroupTieredPackageConfig - modelType = newPlanMaxGroupTieredPackagePrice.modelType - name = newPlanMaxGroupTieredPackagePrice.name - billableMetricId = newPlanMaxGroupTieredPackagePrice.billableMetricId - billedInAdvance = newPlanMaxGroupTieredPackagePrice.billedInAdvance - billingCycleConfiguration = - newPlanMaxGroupTieredPackagePrice.billingCycleConfiguration - conversionRate = newPlanMaxGroupTieredPackagePrice.conversionRate - currency = newPlanMaxGroupTieredPackagePrice.currency - externalPriceId = newPlanMaxGroupTieredPackagePrice.externalPriceId - fixedPriceQuantity = newPlanMaxGroupTieredPackagePrice.fixedPriceQuantity - invoiceGroupingKey = newPlanMaxGroupTieredPackagePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newPlanMaxGroupTieredPackagePrice.invoicingCycleConfiguration - metadata = newPlanMaxGroupTieredPackagePrice.metadata - additionalProperties = - newPlanMaxGroupTieredPackagePrice.additionalProperties.toMutableMap() - } + internal fun from(newPlanBulkWithProrationPrice: NewPlanBulkWithProrationPrice) = + apply { + bulkWithProrationConfig = + newPlanBulkWithProrationPrice.bulkWithProrationConfig + cadence = newPlanBulkWithProrationPrice.cadence + itemId = newPlanBulkWithProrationPrice.itemId + modelType = newPlanBulkWithProrationPrice.modelType + name = newPlanBulkWithProrationPrice.name + billableMetricId = newPlanBulkWithProrationPrice.billableMetricId + billedInAdvance = newPlanBulkWithProrationPrice.billedInAdvance + billingCycleConfiguration = + newPlanBulkWithProrationPrice.billingCycleConfiguration + conversionRate = newPlanBulkWithProrationPrice.conversionRate + currency = newPlanBulkWithProrationPrice.currency + externalPriceId = newPlanBulkWithProrationPrice.externalPriceId + fixedPriceQuantity = newPlanBulkWithProrationPrice.fixedPriceQuantity + invoiceGroupingKey = newPlanBulkWithProrationPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newPlanBulkWithProrationPrice.invoicingCycleConfiguration + metadata = newPlanBulkWithProrationPrice.metadata + additionalProperties = + newPlanBulkWithProrationPrice.additionalProperties.toMutableMap() + } + + fun bulkWithProrationConfig( + bulkWithProrationConfig: CustomRatingFunctionConfigModel + ) = bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) + + fun bulkWithProrationConfig( + bulkWithProrationConfig: JsonField + ) = apply { this.bulkWithProrationConfig = bulkWithProrationConfig } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -34986,14 +20191,6 @@ private constructor( /** The id of the item the price will be associated with. */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun maxGroupTieredPackageConfig( - maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig - ) = maxGroupTieredPackageConfig(JsonField.of(maxGroupTieredPackageConfig)) - - fun maxGroupTieredPackageConfig( - maxGroupTieredPackageConfig: JsonField - ) = apply { this.maxGroupTieredPackageConfig = maxGroupTieredPackageConfig } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) fun modelType(modelType: JsonField) = apply { @@ -35063,7 +20260,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? + billingCycleConfiguration: NewBillingCycleConfigurationModel? ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** @@ -35071,7 +20268,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: Optional + billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) /** @@ -35079,7 +20276,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: JsonField + billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } /** The per unit conversion rate of the price currency to the invoicing currency. */ @@ -35179,7 +20376,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? + invoicingCycleConfiguration: NewBillingCycleConfigurationModel? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** @@ -35187,7 +20384,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional + invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) /** @@ -35195,7 +20392,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField + invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } /** @@ -35241,11 +20438,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): NewPlanMaxGroupTieredPackagePrice = - NewPlanMaxGroupTieredPackagePrice( + fun build(): NewPlanBulkWithProrationPrice = + NewPlanBulkWithProrationPrice( + checkRequired("bulkWithProrationConfig", bulkWithProrationConfig), checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("maxGroupTieredPackageConfig", maxGroupTieredPackageConfig), checkRequired("modelType", modelType), checkRequired("name", name), billableMetricId, @@ -35262,8 +20459,136 @@ private constructor( ) } - /** The cadence to bill for this price on. */ - class Cadence @JsonCreator private constructor(private val value: JsonField) : + /** 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") + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -35278,49 +20603,29 @@ private constructor( 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") + @JvmField val BULK_WITH_PRORATION = of("bulk_with_proration") - @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } - /** An enum containing [Cadence]'s known values. */ + /** An enum containing [ModelType]'s known values. */ enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, + BULK_WITH_PRORATION } /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [ModelType]'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 [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 { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, + BULK_WITH_PRORATION, /** - * An enum member indicating that [Cadence] was instantiated with an unknown + * An enum member indicating that [ModelType] was instantiated with an unknown * value. */ _UNKNOWN, @@ -35335,12 +20640,7 @@ private constructor( */ fun value(): Value = when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM + BULK_WITH_PRORATION -> Value.BULK_WITH_PRORATION else -> Value._UNKNOWN } @@ -35355,13 +20655,8 @@ private constructor( */ fun known(): Known = when (this) { - ANNUAL -> Known.ANNUAL - SEMI_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_PRORATION -> Known.BULK_WITH_PRORATION + else -> throw OrbInvalidDataException("Unknown ModelType: $value") } /** @@ -35383,7 +20678,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -35391,8 +20686,13 @@ private constructor( 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`. + */ @NoAutoDetect - class MaxGroupTieredPackageConfig + class Metadata @JsonCreator private constructor( @JsonAnySetter @@ -35405,7 +20705,7 @@ private constructor( private var validated: Boolean = false - fun validate(): MaxGroupTieredPackageConfig = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } @@ -35417,650 +20717,913 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [MaxGroupTieredPackageConfig]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { - private var additionalProperties: MutableMap = mutableMapOf() + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewPlanBulkWithProrationPrice && bulkWithProrationConfig == other.bulkWithProrationConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(bulkWithProrationConfig, cadence, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewPlanBulkWithProrationPrice{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewPlanGroupedTieredPackagePrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_tiered_package_config") + @ExcludeMissing + private val groupedTieredPackageConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun groupedTieredPackageConfig(): CustomRatingFunctionConfigModel = + groupedTieredPackageConfig.getRequired("grouped_tiered_package_config") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - @JvmSynthetic - internal fun from(maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig) = - apply { - additionalProperties = - maxGroupTieredPackageConfig.additionalProperties.toMutableMap() - } + @JsonProperty("grouped_tiered_package_config") + @ExcludeMissing + fun _groupedTieredPackageConfig(): JsonField = + groupedTieredPackageConfig - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = 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. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - fun build(): MaxGroupTieredPackageConfig = - MaxGroupTieredPackageConfig(additionalProperties.toImmutable()) - } + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - return /* spotless:off */ other is MaxGroupTieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - override fun hashCode(): Int = hashCode + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - override fun toString() = - "MaxGroupTieredPackageConfig{additionalProperties=$additionalProperties}" - } + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + 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 + /** + * User-specified key/value pairs for the resource. 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("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - companion object { + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - @JvmField val MAX_GROUP_TIERED_PACKAGE = of("max_group_tiered_package") + private var validated: Boolean = false - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + fun validate(): NewPlanGroupedTieredPackagePrice = apply { + if (validated) { + return@apply } - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MAX_GROUP_TIERED_PACKAGE - } + cadence() + groupedTieredPackageConfig().validate() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAX_GROUP_TIERED_PACKAGE, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + fun toBuilder() = Builder().from(this) - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAX_GROUP_TIERED_PACKAGE -> Value.MAX_GROUP_TIERED_PACKAGE - else -> Value._UNKNOWN - } + companion object { /** - * Returns an enum member corresponding to this class instance's value. - * - * 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 a mutable builder for constructing an instance of + * [NewPlanGroupedTieredPackagePrice]. * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. + * The following fields are required: + * ```java + * .cadence() + * .groupedTieredPackageConfig() + * .itemId() + * .modelType() + * .name() + * ``` */ - fun known(): Known = - when (this) { - MAX_GROUP_TIERED_PACKAGE -> Known.MAX_GROUP_TIERED_PACKAGE - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } + @JvmStatic fun builder() = Builder() + } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } + /** A builder for [NewPlanGroupedTieredPackagePrice]. */ + class Builder internal constructor() { - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var cadence: JsonField? = null + private var groupedTieredPackageConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: + JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + @JvmSynthetic + internal fun from( + newPlanGroupedTieredPackagePrice: NewPlanGroupedTieredPackagePrice + ) = apply { + cadence = newPlanGroupedTieredPackagePrice.cadence + groupedTieredPackageConfig = + newPlanGroupedTieredPackagePrice.groupedTieredPackageConfig + itemId = newPlanGroupedTieredPackagePrice.itemId + modelType = newPlanGroupedTieredPackagePrice.modelType + name = newPlanGroupedTieredPackagePrice.name + billableMetricId = newPlanGroupedTieredPackagePrice.billableMetricId + billedInAdvance = newPlanGroupedTieredPackagePrice.billedInAdvance + billingCycleConfiguration = + newPlanGroupedTieredPackagePrice.billingCycleConfiguration + conversionRate = newPlanGroupedTieredPackagePrice.conversionRate + currency = newPlanGroupedTieredPackagePrice.currency + externalPriceId = newPlanGroupedTieredPackagePrice.externalPriceId + fixedPriceQuantity = newPlanGroupedTieredPackagePrice.fixedPriceQuantity + invoiceGroupingKey = newPlanGroupedTieredPackagePrice.invoiceGroupingKey + invoicingCycleConfiguration = + newPlanGroupedTieredPackagePrice.invoicingCycleConfiguration + metadata = newPlanGroupedTieredPackagePrice.metadata + additionalProperties = + newPlanGroupedTieredPackagePrice.additionalProperties.toMutableMap() } - override fun hashCode() = value.hashCode() + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun groupedTieredPackageConfig( + groupedTieredPackageConfig: CustomRatingFunctionConfigModel + ) = groupedTieredPackageConfig(JsonField.of(groupedTieredPackageConfig)) - override fun toString() = value.toString() - } + fun groupedTieredPackageConfig( + groupedTieredPackageConfig: JsonField + ) = apply { this.groupedTieredPackageConfig = groupedTieredPackageConfig } - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } - private var validated: Boolean = false + /** + * The 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 validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) - duration() - durationUnit() - validated = true + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId } - fun toBuilder() = Builder().from(this) + /** + * If 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)) - 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(billedInAdvance as Boolean?) - @JvmStatic fun builder() = Builder() + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance } - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) - fun build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId } - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - companion object { + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - @JvmField val DAY = of("day") + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - @JvmField val MONTH = of("month") + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.MONTH - else -> Value._UNKNOWN - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the 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 - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - 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 /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + fun build(): NewPlanGroupedTieredPackagePrice = + NewPlanGroupedTieredPackagePrice( + checkRequired("cadence", cadence), + checkRequired("groupedTieredPackageConfig", groupedTieredPackageConfig), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + currency, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) } - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + /** The cadence to bill for this price on. */ + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the 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 unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit + companion object { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + @JvmField val ANNUAL = of("annual") - private var validated: Boolean = false + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } + @JvmField val MONTHLY = of("monthly") - duration() - durationUnit() - validated = true - } + @JvmField val QUARTERLY = of("quarterly") - fun toBuilder() = Builder().from(this) + @JvmField val ONE_TIME = of("one_time") - companion object { + @JvmField val CUSTOM = of("custom") - @JvmStatic fun builder() = Builder() + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) } - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN } - 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) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - fun build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ } - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { + override fun hashCode() = value.hashCode() - @JvmField val DAY = of("day") + override fun toString() = value.toString() + } - @JvmField val MONTH = of("month") + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(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 - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } + companion object { - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + @JvmField val GROUPED_TIERED_PACKAGE = of("grouped_tiered_package") - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.MONTH - else -> Value._UNKNOWN - } + @JvmStatic fun of(value: String) = ModelType(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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } + /** An enum containing [ModelType]'s known values. */ + enum class Known { + GROUPED_TIERED_PACKAGE + } + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GROUPED_TIERED_PACKAGE, /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method 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 [ModelType] was instantiated with an unknown + * value. */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + _UNKNOWN, + } - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GROUPED_TIERED_PACKAGE -> Value.GROUPED_TIERED_PACKAGE + else -> Value._UNKNOWN } - override fun hashCode() = value.hashCode() + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + GROUPED_TIERED_PACKAGE -> Known.GROUPED_TIERED_PACKAGE + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } - override fun toString() = value.toString() - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if 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 } - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } /** @@ -36094,6 +21657,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } @@ -36154,21 +21718,21 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanMaxGroupTieredPackagePrice && cadence == other.cadence && itemId == other.itemId && maxGroupTieredPackageConfig == other.maxGroupTieredPackageConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NewPlanGroupedTieredPackagePrice && cadence == other.cadence && groupedTieredPackageConfig == other.groupedTieredPackageConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, maxGroupTieredPackageConfig, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(cadence, groupedTieredPackageConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanMaxGroupTieredPackagePrice{cadence=$cadence, itemId=$itemId, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "NewPlanGroupedTieredPackagePrice{cadence=$cadence, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } @NoAutoDetect - class NewPlanScalableMatrixWithUnitPricingPrice + class NewPlanMaxGroupTieredPackagePrice @JsonCreator private constructor( @JsonProperty("cadence") @@ -36177,17 +21741,16 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("max_group_tiered_package_config") + @ExcludeMissing + private val maxGroupTieredPackageConfig: JsonField = + JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing private val modelType: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("scalable_matrix_with_unit_pricing_config") - @ExcludeMissing - private val scalableMatrixWithUnitPricingConfig: - JsonField = - JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing private val billableMetricId: JsonField = JsonMissing.of(), @@ -36196,7 +21759,7 @@ private constructor( private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") @ExcludeMissing - private val billingCycleConfiguration: JsonField = + private val billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing @@ -36215,7 +21778,7 @@ private constructor( private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = + private val invoicingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing @@ -36230,16 +21793,14 @@ private constructor( /** The id of the item the price will be associated with. */ fun itemId(): String = itemId.getRequired("item_id") + fun maxGroupTieredPackageConfig(): CustomRatingFunctionConfigModel = + maxGroupTieredPackageConfig.getRequired("max_group_tiered_package_config") + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ fun name(): String = name.getRequired("name") - fun scalableMatrixWithUnitPricingConfig(): ScalableMatrixWithUnitPricingConfig = - scalableMatrixWithUnitPricingConfig.getRequired( - "scalable_matrix_with_unit_pricing_config" - ) - /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ @@ -36256,7 +21817,7 @@ private constructor( /** * For custom cadence: specifies the duration of the billing period in days or months. */ - fun billingCycleConfiguration(): Optional = + fun billingCycleConfiguration(): Optional = Optional.ofNullable( billingCycleConfiguration.getNullable("billing_cycle_configuration") ) @@ -36289,7 +21850,7 @@ private constructor( * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ - fun invoicingCycleConfiguration(): Optional = + fun invoicingCycleConfiguration(): Optional = Optional.ofNullable( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") ) @@ -36308,6 +21869,11 @@ private constructor( /** The id of the item the price will be associated with. */ @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + @JsonProperty("max_group_tiered_package_config") + @ExcludeMissing + fun _maxGroupTieredPackageConfig(): JsonField = + maxGroupTieredPackageConfig + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonField = modelType @@ -36315,11 +21881,6 @@ private constructor( /** The name of the price. */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("scalable_matrix_with_unit_pricing_config") - @ExcludeMissing - fun _scalableMatrixWithUnitPricingConfig(): - JsonField = scalableMatrixWithUnitPricingConfig - /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ @@ -36340,7 +21901,7 @@ private constructor( */ @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = + fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @@ -36377,7 +21938,7 @@ private constructor( */ @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = + fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration /** @@ -36395,16 +21956,16 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPlanScalableMatrixWithUnitPricingPrice = apply { + fun validate(): NewPlanMaxGroupTieredPackagePrice = apply { if (validated) { return@apply } cadence() itemId() + maxGroupTieredPackageConfig().validate() modelType() name() - scalableMatrixWithUnitPricingConfig().validate() billableMetricId() billedInAdvance() billingCycleConfiguration().ifPresent { it.validate() } @@ -36422,62 +21983,72 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [NewPlanMaxGroupTieredPackagePrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .maxGroupTieredPackageConfig() + * .modelType() + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewPlanScalableMatrixWithUnitPricingPrice]. */ + /** A builder for [NewPlanMaxGroupTieredPackagePrice]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null + private var maxGroupTieredPackageConfig: + JsonField? = + null private var modelType: JsonField? = null private var name: JsonField? = null - private var scalableMatrixWithUnitPricingConfig: - JsonField? = - null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = + private var billingCycleConfiguration: + JsonField = JsonMissing.of() private var conversionRate: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() private var externalPriceId: JsonField = JsonMissing.of() private var fixedPriceQuantity: JsonField = JsonMissing.of() private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = + private var invoicingCycleConfiguration: + JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from( - newPlanScalableMatrixWithUnitPricingPrice: - NewPlanScalableMatrixWithUnitPricingPrice + newPlanMaxGroupTieredPackagePrice: NewPlanMaxGroupTieredPackagePrice ) = apply { - cadence = newPlanScalableMatrixWithUnitPricingPrice.cadence - itemId = newPlanScalableMatrixWithUnitPricingPrice.itemId - modelType = newPlanScalableMatrixWithUnitPricingPrice.modelType - name = newPlanScalableMatrixWithUnitPricingPrice.name - scalableMatrixWithUnitPricingConfig = - newPlanScalableMatrixWithUnitPricingPrice - .scalableMatrixWithUnitPricingConfig - billableMetricId = newPlanScalableMatrixWithUnitPricingPrice.billableMetricId - billedInAdvance = newPlanScalableMatrixWithUnitPricingPrice.billedInAdvance + cadence = newPlanMaxGroupTieredPackagePrice.cadence + itemId = newPlanMaxGroupTieredPackagePrice.itemId + maxGroupTieredPackageConfig = + newPlanMaxGroupTieredPackagePrice.maxGroupTieredPackageConfig + modelType = newPlanMaxGroupTieredPackagePrice.modelType + name = newPlanMaxGroupTieredPackagePrice.name + billableMetricId = newPlanMaxGroupTieredPackagePrice.billableMetricId + billedInAdvance = newPlanMaxGroupTieredPackagePrice.billedInAdvance billingCycleConfiguration = - newPlanScalableMatrixWithUnitPricingPrice.billingCycleConfiguration - conversionRate = newPlanScalableMatrixWithUnitPricingPrice.conversionRate - currency = newPlanScalableMatrixWithUnitPricingPrice.currency - externalPriceId = newPlanScalableMatrixWithUnitPricingPrice.externalPriceId - fixedPriceQuantity = - newPlanScalableMatrixWithUnitPricingPrice.fixedPriceQuantity - invoiceGroupingKey = - newPlanScalableMatrixWithUnitPricingPrice.invoiceGroupingKey + newPlanMaxGroupTieredPackagePrice.billingCycleConfiguration + conversionRate = newPlanMaxGroupTieredPackagePrice.conversionRate + currency = newPlanMaxGroupTieredPackagePrice.currency + externalPriceId = newPlanMaxGroupTieredPackagePrice.externalPriceId + fixedPriceQuantity = newPlanMaxGroupTieredPackagePrice.fixedPriceQuantity + invoiceGroupingKey = newPlanMaxGroupTieredPackagePrice.invoiceGroupingKey invoicingCycleConfiguration = - newPlanScalableMatrixWithUnitPricingPrice.invoicingCycleConfiguration - metadata = newPlanScalableMatrixWithUnitPricingPrice.metadata + newPlanMaxGroupTieredPackagePrice.invoicingCycleConfiguration + metadata = newPlanMaxGroupTieredPackagePrice.metadata additionalProperties = - newPlanScalableMatrixWithUnitPricingPrice.additionalProperties - .toMutableMap() + newPlanMaxGroupTieredPackagePrice.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -36492,6 +22063,14 @@ private constructor( /** The id of the item the price will be associated with. */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + fun maxGroupTieredPackageConfig( + maxGroupTieredPackageConfig: CustomRatingFunctionConfigModel + ) = maxGroupTieredPackageConfig(JsonField.of(maxGroupTieredPackageConfig)) + + fun maxGroupTieredPackageConfig( + maxGroupTieredPackageConfig: JsonField + ) = apply { this.maxGroupTieredPackageConfig = maxGroupTieredPackageConfig } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) fun modelType(modelType: JsonField) = apply { @@ -36504,20 +22083,6 @@ private constructor( /** The name of the price. */ fun name(name: JsonField) = apply { this.name = name } - fun scalableMatrixWithUnitPricingConfig( - scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig - ) = - scalableMatrixWithUnitPricingConfig( - JsonField.of(scalableMatrixWithUnitPricingConfig) - ) - - fun scalableMatrixWithUnitPricingConfig( - scalableMatrixWithUnitPricingConfig: - JsonField - ) = apply { - this.scalableMatrixWithUnitPricingConfig = scalableMatrixWithUnitPricingConfig - } - /** * The id of the billable metric for the price. Only needed if the price is * usage-based. @@ -36575,7 +22140,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? + billingCycleConfiguration: NewBillingCycleConfigurationModel? ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** @@ -36583,7 +22148,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: Optional + billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) /** @@ -36591,7 +22156,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: JsonField + billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } /** The per unit conversion rate of the price currency to the invoicing currency. */ @@ -36691,7 +22256,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? + invoicingCycleConfiguration: NewBillingCycleConfigurationModel? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** @@ -36699,7 +22264,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional + invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) /** @@ -36707,7 +22272,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField + invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } /** @@ -36753,16 +22318,13 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): NewPlanScalableMatrixWithUnitPricingPrice = - NewPlanScalableMatrixWithUnitPricingPrice( + fun build(): NewPlanMaxGroupTieredPackagePrice = + NewPlanMaxGroupTieredPackagePrice( checkRequired("cadence", cadence), checkRequired("itemId", itemId), + checkRequired("maxGroupTieredPackageConfig", maxGroupTieredPackageConfig), checkRequired("modelType", modelType), checkRequired("name", name), - checkRequired( - "scalableMatrixWithUnitPricingConfig", - scalableMatrixWithUnitPricingConfig, - ), billableMetricId, billedInAdvance, billingCycleConfiguration, @@ -36777,8 +22339,136 @@ private constructor( ) } - /** The cadence to bill for this price on. */ - class Cadence @JsonCreator private constructor(private val value: JsonField) : + /** 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") + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -36793,49 +22483,29 @@ private constructor( 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") + @JvmField val MAX_GROUP_TIERED_PACKAGE = of("max_group_tiered_package") - @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } - /** An enum containing [Cadence]'s known values. */ + /** An enum containing [ModelType]'s known values. */ enum class Known { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, + MAX_GROUP_TIERED_PACKAGE } /** - * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [ModelType]'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 [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 { - ANNUAL, - SEMI_ANNUAL, - MONTHLY, - QUARTERLY, - ONE_TIME, - CUSTOM, + MAX_GROUP_TIERED_PACKAGE, /** - * An enum member indicating that [Cadence] was instantiated with an unknown + * An enum member indicating that [ModelType] was instantiated with an unknown * value. */ _UNKNOWN, @@ -36850,12 +22520,7 @@ private constructor( */ fun value(): Value = when (this) { - ANNUAL -> Value.ANNUAL - SEMI_ANNUAL -> Value.SEMI_ANNUAL - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - ONE_TIME -> Value.ONE_TIME - CUSTOM -> Value.CUSTOM + MAX_GROUP_TIERED_PACKAGE -> Value.MAX_GROUP_TIERED_PACKAGE else -> Value._UNKNOWN } @@ -36870,13 +22535,8 @@ private constructor( */ fun known(): Known = when (this) { - ANNUAL -> Known.ANNUAL - SEMI_ANNUAL -> Known.SEMI_ANNUAL - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - ONE_TIME -> Known.ONE_TIME - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") + MAX_GROUP_TIERED_PACKAGE -> Known.MAX_GROUP_TIERED_PACKAGE + else -> throw OrbInvalidDataException("Unknown ModelType: $value") } /** @@ -36898,7 +22558,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -36906,678 +22566,961 @@ private constructor( override fun toString() = value.toString() } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewPlanMaxGroupTieredPackagePrice && cadence == other.cadence && itemId == other.itemId && maxGroupTieredPackageConfig == other.maxGroupTieredPackageConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, itemId, maxGroupTieredPackageConfig, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewPlanMaxGroupTieredPackagePrice{cadence=$cadence, itemId=$itemId, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewPlanScalableMatrixWithUnitPricingPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("scalable_matrix_with_unit_pricing_config") + @ExcludeMissing + private val scalableMatrixWithUnitPricingConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the price will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun scalableMatrixWithUnitPricingConfig(): CustomRatingFunctionConfigModel = + scalableMatrixWithUnitPricingConfig.getRequired( + "scalable_matrix_with_unit_pricing_config" + ) + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_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 + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) - companion object { + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - @JvmField - val SCALABLE_MATRIX_WITH_UNIT_PRICING = of("scalable_matrix_with_unit_pricing") + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - /** An enum containing [ModelType]'s known values. */ - enum class Known { - SCALABLE_MATRIX_WITH_UNIT_PRICING - } + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - SCALABLE_MATRIX_WITH_UNIT_PRICING, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - SCALABLE_MATRIX_WITH_UNIT_PRICING -> Value.SCALABLE_MATRIX_WITH_UNIT_PRICING - else -> Value._UNKNOWN - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_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) { - SCALABLE_MATRIX_WITH_UNIT_PRICING -> Known.SCALABLE_MATRIX_WITH_UNIT_PRICING - else -> throw OrbInvalidDataException("Unknown ModelType: $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(): Optional = + Optional.ofNullable(metadata.getNullable("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") - } + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** The id of the item the price will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - override fun hashCode() = value.hashCode() + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - override fun toString() = value.toString() - } + @JsonProperty("scalable_matrix_with_unit_pricing_config") + @ExcludeMissing + fun _scalableMatrixWithUnitPricingConfig(): JsonField = + scalableMatrixWithUnitPricingConfig - @NoAutoDetect - class ScalableMatrixWithUnitPricingConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = 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. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance - private var validated: Boolean = false + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - fun validate(): ScalableMatrixWithUnitPricingConfig = apply { - if (validated) { - return@apply - } + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - validated = true - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - fun toBuilder() = Builder().from(this) + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - companion object { + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - @JvmStatic fun builder() = Builder() - } + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - /** A builder for [ScalableMatrixWithUnitPricingConfig]. */ - 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. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - 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`. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata - @JvmSynthetic - internal fun from( - scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig - ) = apply { - additionalProperties = - scalableMatrixWithUnitPricingConfig.additionalProperties.toMutableMap() - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + private var validated: Boolean = false - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun validate(): NewPlanScalableMatrixWithUnitPricingPrice = apply { + if (validated) { + return@apply + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + cadence() + itemId() + modelType() + name() + scalableMatrixWithUnitPricingConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().ifPresent { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + validated = true + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun toBuilder() = Builder().from(this) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + companion object { - fun build(): ScalableMatrixWithUnitPricingConfig = - ScalableMatrixWithUnitPricingConfig(additionalProperties.toImmutable()) - } + /** + * Returns a mutable builder for constructing an instance of + * [NewPlanScalableMatrixWithUnitPricingPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .modelType() + * .name() + * .scalableMatrixWithUnitPricingConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** A builder for [NewPlanScalableMatrixWithUnitPricingPrice]. */ + class Builder internal constructor() { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var scalableMatrixWithUnitPricingConfig: + JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: + JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - return /* spotless:off */ other is ScalableMatrixWithUnitPricingConfig && additionalProperties == other.additionalProperties /* spotless:on */ + @JvmSynthetic + internal fun from( + newPlanScalableMatrixWithUnitPricingPrice: + NewPlanScalableMatrixWithUnitPricingPrice + ) = apply { + cadence = newPlanScalableMatrixWithUnitPricingPrice.cadence + itemId = newPlanScalableMatrixWithUnitPricingPrice.itemId + modelType = newPlanScalableMatrixWithUnitPricingPrice.modelType + name = newPlanScalableMatrixWithUnitPricingPrice.name + scalableMatrixWithUnitPricingConfig = + newPlanScalableMatrixWithUnitPricingPrice + .scalableMatrixWithUnitPricingConfig + billableMetricId = newPlanScalableMatrixWithUnitPricingPrice.billableMetricId + billedInAdvance = newPlanScalableMatrixWithUnitPricingPrice.billedInAdvance + billingCycleConfiguration = + newPlanScalableMatrixWithUnitPricingPrice.billingCycleConfiguration + conversionRate = newPlanScalableMatrixWithUnitPricingPrice.conversionRate + currency = newPlanScalableMatrixWithUnitPricingPrice.currency + externalPriceId = newPlanScalableMatrixWithUnitPricingPrice.externalPriceId + fixedPriceQuantity = + newPlanScalableMatrixWithUnitPricingPrice.fixedPriceQuantity + invoiceGroupingKey = + newPlanScalableMatrixWithUnitPricingPrice.invoiceGroupingKey + invoicingCycleConfiguration = + newPlanScalableMatrixWithUnitPricingPrice.invoicingCycleConfiguration + metadata = newPlanScalableMatrixWithUnitPricingPrice.metadata + additionalProperties = + newPlanScalableMatrixWithUnitPricingPrice.additionalProperties + .toMutableMap() } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - override fun hashCode(): Int = hashCode + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - override fun toString() = - "ScalableMatrixWithUnitPricingConfig{additionalProperties=$additionalProperties}" - } + /** The id of the item the price will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + /** The id of the item the price will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun scalableMatrixWithUnitPricingConfig( + scalableMatrixWithUnitPricingConfig: CustomRatingFunctionConfigModel + ) = + scalableMatrixWithUnitPricingConfig( + JsonField.of(scalableMatrixWithUnitPricingConfig) + ) - private var validated: Boolean = false + fun scalableMatrixWithUnitPricingConfig( + scalableMatrixWithUnitPricingConfig: JsonField + ) = apply { + this.scalableMatrixWithUnitPricingConfig = scalableMatrixWithUnitPricingConfig + } - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) - duration() - durationUnit() - validated = true + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: Optional) = + billableMetricId(billableMetricId.orElse(null)) + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId } - fun toBuilder() = Builder().from(this) + /** + * If 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)) - 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(billedInAdvance as Boolean?) - @JvmStatic fun builder() = Builder() + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If 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: JsonField) = apply { + this.billedInAdvance = billedInAdvance } - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: Optional + ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: Double) = + conversionRate(conversionRate as Double?) - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: Optional) = currency(currency.orElse(null)) - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) - fun build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId } - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - companion object { + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - @JvmField val DAY = of("day") + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - @JvmField val MONTH = of("month") + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: Optional) = + invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: NewBillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.MONTH - else -> Value._UNKNOWN - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the 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 - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - 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 /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + fun build(): NewPlanScalableMatrixWithUnitPricingPrice = + NewPlanScalableMatrixWithUnitPricingPrice( + checkRequired("cadence", cadence), + checkRequired("itemId", itemId), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired( + "scalableMatrixWithUnitPricingConfig", + scalableMatrixWithUnitPricingConfig, + ), + billableMetricId, + billedInAdvance, + billingCycleConfiguration, + conversionRate, + currency, + externalPriceId, + fixedPriceQuantity, + invoiceGroupingKey, + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) } - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + /** The cadence to bill for this price on. */ + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the 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 unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit + companion object { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + @JvmField val ANNUAL = of("annual") - private var validated: Boolean = false + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } + @JvmField val MONTHLY = of("monthly") - duration() - durationUnit() - validated = true - } + @JvmField val QUARTERLY = of("quarterly") - fun toBuilder() = Builder().from(this) + @JvmField val ONE_TIME = of("one_time") - companion object { + @JvmField val CUSTOM = of("custom") - @JvmStatic fun builder() = Builder() + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) } - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + } - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN } - 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) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - fun build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ } - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { + override fun hashCode() = value.hashCode() - @JvmField val DAY = of("day") + override fun toString() = value.toString() + } - @JvmField val MONTH = of("month") + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(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 - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } + companion object { - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + @JvmField + val SCALABLE_MATRIX_WITH_UNIT_PRICING = of("scalable_matrix_with_unit_pricing") - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.MONTH - else -> Value._UNKNOWN - } + @JvmStatic fun of(value: String) = ModelType(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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } + /** An enum containing [ModelType]'s known values. */ + enum class Known { + SCALABLE_MATRIX_WITH_UNIT_PRICING + } + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SCALABLE_MATRIX_WITH_UNIT_PRICING, /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method 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 [ModelType] was instantiated with an unknown + * value. */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + _UNKNOWN, + } - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SCALABLE_MATRIX_WITH_UNIT_PRICING -> Value.SCALABLE_MATRIX_WITH_UNIT_PRICING + else -> Value._UNKNOWN } - override fun hashCode() = value.hashCode() + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SCALABLE_MATRIX_WITH_UNIT_PRICING -> Known.SCALABLE_MATRIX_WITH_UNIT_PRICING + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } - override fun toString() = value.toString() - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if 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 } - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } /** @@ -37611,6 +23554,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } @@ -37703,7 +23647,7 @@ private constructor( @JsonProperty("scalable_matrix_with_tiered_pricing_config") @ExcludeMissing private val scalableMatrixWithTieredPricingConfig: - JsonField = + JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing @@ -37713,7 +23657,7 @@ private constructor( private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") @ExcludeMissing - private val billingCycleConfiguration: JsonField = + private val billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing @@ -37732,7 +23676,7 @@ private constructor( private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = + private val invoicingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing @@ -37752,7 +23696,7 @@ private constructor( /** The name of the price. */ fun name(): String = name.getRequired("name") - fun scalableMatrixWithTieredPricingConfig(): ScalableMatrixWithTieredPricingConfig = + fun scalableMatrixWithTieredPricingConfig(): CustomRatingFunctionConfigModel = scalableMatrixWithTieredPricingConfig.getRequired( "scalable_matrix_with_tiered_pricing_config" ) @@ -37773,7 +23717,7 @@ private constructor( /** * For custom cadence: specifies the duration of the billing period in days or months. */ - fun billingCycleConfiguration(): Optional = + fun billingCycleConfiguration(): Optional = Optional.ofNullable( billingCycleConfiguration.getNullable("billing_cycle_configuration") ) @@ -37806,7 +23750,7 @@ private constructor( * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ - fun invoicingCycleConfiguration(): Optional = + fun invoicingCycleConfiguration(): Optional = Optional.ofNullable( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") ) @@ -37835,8 +23779,7 @@ private constructor( @JsonProperty("scalable_matrix_with_tiered_pricing_config") @ExcludeMissing fun _scalableMatrixWithTieredPricingConfig(): - JsonField = - scalableMatrixWithTieredPricingConfig + JsonField = scalableMatrixWithTieredPricingConfig /** * The id of the billable metric for the price. Only needed if the price is usage-based. @@ -37858,7 +23801,7 @@ private constructor( */ @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = + fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @@ -37895,7 +23838,7 @@ private constructor( */ @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = + fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration /** @@ -37940,6 +23883,19 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [NewPlanScalableMatrixWithTieredPricingPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .itemId() + * .modelType() + * .name() + * .scalableMatrixWithTieredPricingConfig() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -37951,18 +23907,20 @@ private constructor( private var modelType: JsonField? = null private var name: JsonField? = null private var scalableMatrixWithTieredPricingConfig: - JsonField? = + JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = + private var billingCycleConfiguration: + JsonField = JsonMissing.of() private var conversionRate: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() private var externalPriceId: JsonField = JsonMissing.of() private var fixedPriceQuantity: JsonField = JsonMissing.of() private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = + private var invoicingCycleConfiguration: + JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -38023,7 +23981,7 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } fun scalableMatrixWithTieredPricingConfig( - scalableMatrixWithTieredPricingConfig: ScalableMatrixWithTieredPricingConfig + scalableMatrixWithTieredPricingConfig: CustomRatingFunctionConfigModel ) = scalableMatrixWithTieredPricingConfig( JsonField.of(scalableMatrixWithTieredPricingConfig) @@ -38031,7 +23989,7 @@ private constructor( fun scalableMatrixWithTieredPricingConfig( scalableMatrixWithTieredPricingConfig: - JsonField + JsonField ) = apply { this.scalableMatrixWithTieredPricingConfig = scalableMatrixWithTieredPricingConfig @@ -38094,7 +24052,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? + billingCycleConfiguration: NewBillingCycleConfigurationModel? ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** @@ -38102,7 +24060,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: Optional + billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) /** @@ -38110,7 +24068,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: JsonField + billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } /** The per unit conversion rate of the price currency to the invoicing currency. */ @@ -38210,7 +24168,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? + invoicingCycleConfiguration: NewBillingCycleConfigurationModel? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** @@ -38218,7 +24176,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional + invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) /** @@ -38226,7 +24184,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField + invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } /** @@ -38290,142 +24248,14 @@ private constructor( externalPriceId, fixedPriceQuantity, invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() + invoicingCycleConfiguration, + metadata, + additionalProperties.toImmutable(), + ) } - class ModelType @JsonCreator private constructor(private val value: JsonField) : + /** The cadence to bill for this price on. */ + class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -38440,31 +24270,49 @@ private constructor( companion object { - @JvmField - val SCALABLE_MATRIX_WITH_TIERED_PRICING = - of("scalable_matrix_with_tiered_pricing") + @JvmField val ANNUAL = of("annual") - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + @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 [ModelType]'s known values. */ + /** An enum containing [Cadence]'s known values. */ enum class Known { - SCALABLE_MATRIX_WITH_TIERED_PRICING + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, } /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. * - * An instance of [ModelType] can contain an unknown value in a couple of cases: + * An instance of [Cadence] can contain an unknown value in a couple of cases: * - It was deserialized from data that doesn't match any known member. For example, * if the SDK is on an older version than the API, then the API may respond with * new members that the SDK is unaware of. * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - SCALABLE_MATRIX_WITH_TIERED_PRICING, + ANNUAL, + SEMI_ANNUAL, + MONTHLY, + QUARTERLY, + ONE_TIME, + CUSTOM, /** - * An enum member indicating that [ModelType] was instantiated with an unknown + * An enum member indicating that [Cadence] was instantiated with an unknown * value. */ _UNKNOWN, @@ -38479,8 +24327,12 @@ private constructor( */ fun value(): Value = when (this) { - SCALABLE_MATRIX_WITH_TIERED_PRICING -> - Value.SCALABLE_MATRIX_WITH_TIERED_PRICING + ANNUAL -> Value.ANNUAL + SEMI_ANNUAL -> Value.SEMI_ANNUAL + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + ONE_TIME -> Value.ONE_TIME + CUSTOM -> Value.CUSTOM else -> Value._UNKNOWN } @@ -38495,9 +24347,13 @@ private constructor( */ fun known(): Known = when (this) { - SCALABLE_MATRIX_WITH_TIERED_PRICING -> - Known.SCALABLE_MATRIX_WITH_TIERED_PRICING - else -> throw OrbInvalidDataException("Unknown ModelType: $value") + ANNUAL -> Known.ANNUAL + SEMI_ANNUAL -> Known.SEMI_ANNUAL + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + ONE_TIME -> Known.ONE_TIME + CUSTOM -> Known.CUSTOM + else -> throw OrbInvalidDataException("Unknown Cadence: $value") } /** @@ -38511,596 +24367,122 @@ private constructor( */ fun asString(): String = _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class ScalableMatrixWithTieredPricingConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): ScalableMatrixWithTieredPricingConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ScalableMatrixWithTieredPricingConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - scalableMatrixWithTieredPricingConfig: ScalableMatrixWithTieredPricingConfig - ) = apply { - additionalProperties = - scalableMatrixWithTieredPricingConfig.additionalProperties - .toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): ScalableMatrixWithTieredPricingConfig = - ScalableMatrixWithTieredPricingConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ScalableMatrixWithTieredPricingConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ScalableMatrixWithTieredPricingConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ + OrbInvalidDataException("Value is not a String") } - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { - fun toBuilder() = Builder().from(this) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JvmField + val SCALABLE_MATRIX_WITH_TIERED_PRICING = + of("scalable_matrix_with_tiered_pricing") - fun build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** An enum containing [ModelType]'s known values. */ + enum class Known { + SCALABLE_MATRIX_WITH_TIERED_PRICING + } + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SCALABLE_MATRIX_WITH_TIERED_PRICING, /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } + _UNKNOWN, + } - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SCALABLE_MATRIX_WITH_TIERED_PRICING -> + Value.SCALABLE_MATRIX_WITH_TIERED_PRICING + else -> Value._UNKNOWN } - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SCALABLE_MATRIX_WITH_TIERED_PRICING -> + Known.SCALABLE_MATRIX_WITH_TIERED_PRICING + else -> throw OrbInvalidDataException("Unknown ModelType: $value") } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if 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 hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } /** @@ -39134,6 +24516,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } @@ -39216,7 +24599,7 @@ private constructor( private val cadence: JsonField = JsonMissing.of(), @JsonProperty("cumulative_grouped_bulk_config") @ExcludeMissing - private val cumulativeGroupedBulkConfig: JsonField = + private val cumulativeGroupedBulkConfig: JsonField = JsonMissing.of(), @JsonProperty("item_id") @ExcludeMissing @@ -39235,7 +24618,7 @@ private constructor( private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") @ExcludeMissing - private val billingCycleConfiguration: JsonField = + private val billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("conversion_rate") @ExcludeMissing @@ -39254,7 +24637,7 @@ private constructor( private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = + private val invoicingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing @@ -39266,7 +24649,7 @@ private constructor( /** The cadence to bill for this price on. */ fun cadence(): Cadence = cadence.getRequired("cadence") - fun cumulativeGroupedBulkConfig(): CumulativeGroupedBulkConfig = + fun cumulativeGroupedBulkConfig(): CustomRatingFunctionConfigModel = cumulativeGroupedBulkConfig.getRequired("cumulative_grouped_bulk_config") /** The id of the item the price will be associated with. */ @@ -39293,7 +24676,7 @@ private constructor( /** * For custom cadence: specifies the duration of the billing period in days or months. */ - fun billingCycleConfiguration(): Optional = + fun billingCycleConfiguration(): Optional = Optional.ofNullable( billingCycleConfiguration.getNullable("billing_cycle_configuration") ) @@ -39326,7 +24709,7 @@ private constructor( * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ - fun invoicingCycleConfiguration(): Optional = + fun invoicingCycleConfiguration(): Optional = Optional.ofNullable( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") ) @@ -39344,7 +24727,7 @@ private constructor( @JsonProperty("cumulative_grouped_bulk_config") @ExcludeMissing - fun _cumulativeGroupedBulkConfig(): JsonField = + fun _cumulativeGroupedBulkConfig(): JsonField = cumulativeGroupedBulkConfig /** The id of the item the price will be associated with. */ @@ -39377,7 +24760,7 @@ private constructor( */ @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = + fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @@ -39414,7 +24797,7 @@ private constructor( */ @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = + fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration /** @@ -39459,6 +24842,19 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [NewPlanCumulativeGroupedBulkPrice]. + * + * The following fields are required: + * ```java + * .cadence() + * .cumulativeGroupedBulkConfig() + * .itemId() + * .modelType() + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -39466,21 +24862,24 @@ private constructor( class Builder internal constructor() { private var cadence: JsonField? = null - private var cumulativeGroupedBulkConfig: JsonField? = + private var cumulativeGroupedBulkConfig: + JsonField? = null private var itemId: JsonField? = null private var modelType: JsonField? = null private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = + private var billingCycleConfiguration: + JsonField = JsonMissing.of() private var conversionRate: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() private var externalPriceId: JsonField = JsonMissing.of() private var fixedPriceQuantity: JsonField = JsonMissing.of() private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = + private var invoicingCycleConfiguration: + JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -39518,11 +24917,11 @@ private constructor( fun cadence(cadence: JsonField) = apply { this.cadence = cadence } fun cumulativeGroupedBulkConfig( - cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig + cumulativeGroupedBulkConfig: CustomRatingFunctionConfigModel ) = cumulativeGroupedBulkConfig(JsonField.of(cumulativeGroupedBulkConfig)) fun cumulativeGroupedBulkConfig( - cumulativeGroupedBulkConfig: JsonField + cumulativeGroupedBulkConfig: JsonField ) = apply { this.cumulativeGroupedBulkConfig = cumulativeGroupedBulkConfig } /** The id of the item the price will be associated with. */ @@ -39600,7 +24999,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? + billingCycleConfiguration: NewBillingCycleConfigurationModel? ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** @@ -39608,7 +25007,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: Optional + billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) /** @@ -39616,7 +25015,7 @@ private constructor( * months. */ fun billingCycleConfiguration( - billingCycleConfiguration: JsonField + billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } /** The per unit conversion rate of the price currency to the invoicing currency. */ @@ -39716,7 +25115,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? + invoicingCycleConfiguration: NewBillingCycleConfigurationModel? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** @@ -39724,7 +25123,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional + invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) /** @@ -39732,7 +25131,7 @@ private constructor( * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField + invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } /** @@ -39912,105 +25311,20 @@ private constructor( */ fun asString(): String = _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class CumulativeGroupedBulkConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CumulativeGroupedBulkConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CumulativeGroupedBulkConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig) = - apply { - additionalProperties = - cumulativeGroupedBulkConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + OrbInvalidDataException("Value is not a String") } - fun build(): CumulativeGroupedBulkConfig = - CumulativeGroupedBulkConfig(additionalProperties.toImmutable()) - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is CumulativeGroupedBulkConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "CumulativeGroupedBulkConfig{additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } class ModelType @JsonCreator private constructor(private val value: JsonField) : @@ -40111,495 +25425,6 @@ private constructor( override fun toString() = value.toString() } - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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 @@ -40631,6 +25456,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } @@ -40736,6 +25562,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdFetchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdFetchParams.kt index f78a7bafa..b2609f9c8 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdFetchParams.kt @@ -53,6 +53,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [PlanExternalPlanIdFetchParams]. + * + * The following fields are required: + * ```java + * .externalPlanId() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 14a1210bd..ff848f7d7 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 @@ -2,23 +2,13 @@ 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.NoAutoDetect 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.immutableEmptyMap -import com.withorb.api.core.toImmutable import java.util.Objects -import java.util.Optional /** * This endpoint can be used to update the `external_plan_id`, and `metadata` of an existing plan. @@ -28,46 +18,22 @@ import java.util.Optional class PlanExternalPlanIdUpdateParams private constructor( private val otherExternalPlanId: String, - private val body: Body, + private val editPlanModel: EditPlanModel, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { fun otherExternalPlanId(): String = otherExternalPlanId - /** - * An optional user-defined ID for this plan resource, used throughout the system as an alias - * for this Plan. Use this field to identify a plan by an existing identifier in your system. - */ - fun externalPlanId(): Optional = body.externalPlanId() - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - */ - fun metadata(): Optional = body.metadata() - - /** - * An optional user-defined ID for this plan resource, used throughout the system as an alias - * for this Plan. Use this field to identify a plan by an existing identifier in your system. - */ - fun _externalPlanId(): JsonField = body._externalPlanId() - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - */ - fun _metadata(): JsonField = body._metadata() - - fun _additionalBodyProperties(): Map = body._additionalProperties() + fun editPlanModel(): EditPlanModel = editPlanModel + + fun _additionalBodyProperties(): Map = editPlanModel._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): EditPlanModel = editPlanModel override fun _headers(): Headers = additionalHeaders @@ -80,178 +46,20 @@ private constructor( } } - @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("external_plan_id") - @ExcludeMissing - private val externalPlanId: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * An optional user-defined ID for this plan resource, used throughout the system as an - * alias for this Plan. Use this field to identify a plan by an existing identifier in your - * system. - */ - fun externalPlanId(): Optional = - Optional.ofNullable(externalPlanId.getNullable("external_plan_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`. - */ - fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * 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. - */ - @JsonProperty("external_plan_id") - @ExcludeMissing - fun _externalPlanId(): JsonField = externalPlanId - - /** - * User-specified key/value pairs for the resource. 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - externalPlanId() - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var externalPlanId: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - externalPlanId = body.externalPlanId - metadata = body.metadata - additionalProperties = body.additionalProperties.toMutableMap() - } - - /** - * An optional user-defined ID for this plan resource, used throughout the system as an - * alias for this Plan. Use this field to identify a plan by an existing identifier in - * your system. - */ - fun externalPlanId(externalPlanId: String?) = - externalPlanId(JsonField.ofNullable(externalPlanId)) - - /** - * An optional user-defined ID for this plan resource, used throughout the system as an - * alias for this Plan. Use this field to identify a plan by an existing identifier in - * your system. - */ - fun externalPlanId(externalPlanId: Optional) = - externalPlanId(externalPlanId.orElse(null)) - - /** - * An optional user-defined ID for this plan resource, used throughout the system as an - * alias for this Plan. Use this field to identify a plan by an existing identifier in - * your system. - */ - fun externalPlanId(externalPlanId: JsonField) = apply { - this.externalPlanId = externalPlanId - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): Body = Body(externalPlanId, metadata, additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Body && externalPlanId == other.externalPlanId && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(externalPlanId, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{externalPlanId=$externalPlanId, metadata=$metadata, additionalProperties=$additionalProperties}" - } - fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of + * [PlanExternalPlanIdUpdateParams]. + * + * The following fields are required: + * ```java + * .otherExternalPlanId() + * .editPlanModel() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -260,14 +68,14 @@ private constructor( class Builder internal constructor() { private var otherExternalPlanId: String? = null - private var body: Body.Builder = Body.builder() + private var editPlanModel: EditPlanModel? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(planExternalPlanIdUpdateParams: PlanExternalPlanIdUpdateParams) = apply { otherExternalPlanId = planExternalPlanIdUpdateParams.otherExternalPlanId - body = planExternalPlanIdUpdateParams.body.toBuilder() + editPlanModel = planExternalPlanIdUpdateParams.editPlanModel additionalHeaders = planExternalPlanIdUpdateParams.additionalHeaders.toBuilder() additionalQueryParams = planExternalPlanIdUpdateParams.additionalQueryParams.toBuilder() } @@ -276,68 +84,8 @@ private constructor( this.otherExternalPlanId = otherExternalPlanId } - /** - * An optional user-defined ID for this plan resource, used throughout the system as an - * alias for this Plan. Use this field to identify a plan by an existing identifier in your - * system. - */ - fun externalPlanId(externalPlanId: String?) = apply { body.externalPlanId(externalPlanId) } - - /** - * An optional user-defined ID for this plan resource, used throughout the system as an - * alias for this Plan. Use this field to identify a plan by an existing identifier in your - * system. - */ - fun externalPlanId(externalPlanId: Optional) = - externalPlanId(externalPlanId.orElse(null)) - - /** - * An optional user-defined ID for this plan resource, used throughout the system as an - * alias for this Plan. Use this field to identify a plan by an existing identifier in your - * system. - */ - fun externalPlanId(externalPlanId: JsonField) = apply { - body.externalPlanId(externalPlanId) - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by setting - * `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by setting - * `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: JsonField) = apply { body.metadata(metadata) } - - 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 editPlanModel(editPlanModel: EditPlanModel) = apply { + this.editPlanModel = editPlanModel } fun additionalHeaders(additionalHeaders: Headers) = apply { @@ -441,105 +189,22 @@ private constructor( fun build(): PlanExternalPlanIdUpdateParams = PlanExternalPlanIdUpdateParams( checkRequired("otherExternalPlanId", otherExternalPlanId), - body.build(), + checkRequired("editPlanModel", editPlanModel), additionalHeaders.build(), additionalQueryParams.build(), ) } - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanExternalPlanIdUpdateParams && otherExternalPlanId == other.otherExternalPlanId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is PlanExternalPlanIdUpdateParams && otherExternalPlanId == other.otherExternalPlanId && editPlanModel == other.editPlanModel && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(otherExternalPlanId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(otherExternalPlanId, editPlanModel, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "PlanExternalPlanIdUpdateParams{otherExternalPlanId=$otherExternalPlanId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "PlanExternalPlanIdUpdateParams{otherExternalPlanId=$otherExternalPlanId, editPlanModel=$editPlanModel, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanFetchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanFetchParams.kt index e4699c4ea..12e48fc22 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanFetchParams.kt @@ -54,6 +54,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [PlanFetchParams]. + * + * The following fields are required: + * ```java + * .planId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListPage.kt index 470736525..43988d7f4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListPage.kt @@ -34,7 +34,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -89,20 +89,20 @@ private constructor( class Response @JsonCreator constructor( - @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), + @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = Optional.ofNullable(data) + fun _data(): Optional>> = Optional.ofNullable(data) @JsonProperty("pagination_metadata") fun _paginationMetadata(): Optional> = @@ -141,12 +141,13 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [PlanListPage]. */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -157,9 +158,9 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { this.data = data } fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) @@ -176,9 +177,9 @@ private constructor( } } - class AutoPager(private val firstPage: PlanListPage) : Iterable { + class AutoPager(private val firstPage: PlanListPage) : Iterable { - override fun iterator(): Iterator = iterator { + override fun iterator(): Iterator = iterator { var page = firstPage var index = 0 while (true) { @@ -190,7 +191,7 @@ private constructor( } } - fun stream(): Stream { + fun stream(): Stream { return StreamSupport.stream(spliterator(), false) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListPageAsync.kt index 422e21325..aadc8d4c3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListPageAsync.kt @@ -35,7 +35,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -92,20 +92,20 @@ private constructor( class Response @JsonCreator constructor( - @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), + @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = Optional.ofNullable(data) + fun _data(): Optional>> = Optional.ofNullable(data) @JsonProperty("pagination_metadata") fun _paginationMetadata(): Optional> = @@ -144,12 +144,13 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [PlanListPageAsync]. */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -160,9 +161,9 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { this.data = data } fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) @@ -181,9 +182,9 @@ private constructor( class AutoPager(private val firstPage: PlanListPageAsync) { - fun forEach(action: Predicate, executor: Executor): CompletableFuture { + fun forEach(action: Predicate, executor: Executor): CompletableFuture { fun CompletableFuture>.forEach( - action: (Plan) -> Boolean, + action: (PlanModel) -> Boolean, executor: Executor, ): CompletableFuture = thenComposeAsync( @@ -199,8 +200,8 @@ private constructor( .forEach(action::test, executor) } - fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() + fun toList(executor: Executor): CompletableFuture> { + val values = mutableListOf() return forEach(values::add, executor).thenApply { values } } } 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 8cb3f7cb4..7c24853af 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 @@ -99,6 +99,7 @@ private constructor( @JvmStatic fun none(): PlanListParams = builder().build() + /** Returns a mutable builder for constructing an instance of [PlanListParams]. */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanMinifiedModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanMinifiedModel.kt new file mode 100644 index 000000000..6d8f1fa64 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanMinifiedModel.kt @@ -0,0 +1,186 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class PlanMinifiedModel +@JsonCreator +private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("external_plan_id") + @ExcludeMissing + private val externalPlanId: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun id(): Optional = Optional.ofNullable(id.getNullable("id")) + + /** + * An optional user-defined ID for this plan resource, used throughout the system as an alias + * for this Plan. Use this field to identify a plan by an existing identifier in your system. + */ + fun externalPlanId(): Optional = + Optional.ofNullable(externalPlanId.getNullable("external_plan_id")) + + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * An optional user-defined ID for this plan resource, used throughout the system as an alias + * for this Plan. Use this field to identify a plan by an existing identifier in your system. + */ + @JsonProperty("external_plan_id") + @ExcludeMissing + fun _externalPlanId(): JsonField = externalPlanId + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): PlanMinifiedModel = apply { + if (validated) { + return@apply + } + + id() + externalPlanId() + name() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PlanMinifiedModel]. + * + * The following fields are required: + * ```java + * .id() + * .externalPlanId() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PlanMinifiedModel]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var externalPlanId: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(planMinifiedModel: PlanMinifiedModel) = apply { + id = planMinifiedModel.id + externalPlanId = planMinifiedModel.externalPlanId + name = planMinifiedModel.name + additionalProperties = planMinifiedModel.additionalProperties.toMutableMap() + } + + fun id(id: String?) = id(JsonField.ofNullable(id)) + + fun id(id: Optional) = id(id.orElse(null)) + + fun id(id: JsonField) = apply { this.id = id } + + /** + * An optional user-defined ID for this plan resource, used throughout the system as an + * alias for this Plan. Use this field to identify a plan by an existing identifier in your + * system. + */ + fun externalPlanId(externalPlanId: String?) = + externalPlanId(JsonField.ofNullable(externalPlanId)) + + /** + * An optional user-defined ID for this plan resource, used throughout the system as an + * alias for this Plan. Use this field to identify a plan by an existing identifier in your + * system. + */ + fun externalPlanId(externalPlanId: Optional) = + externalPlanId(externalPlanId.orElse(null)) + + /** + * An optional user-defined ID for this plan resource, used throughout the system as an + * alias for this Plan. Use this field to identify a plan by an existing identifier in your + * system. + */ + fun externalPlanId(externalPlanId: JsonField) = apply { + this.externalPlanId = externalPlanId + } + + fun name(name: String?) = name(JsonField.ofNullable(name)) + + fun name(name: Optional) = name(name.orElse(null)) + + 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) + } + + fun build(): PlanMinifiedModel = + PlanMinifiedModel( + checkRequired("id", id), + checkRequired("externalPlanId", externalPlanId), + checkRequired("name", name), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PlanMinifiedModel && id == other.id && externalPlanId == other.externalPlanId && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, externalPlanId, name, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PlanMinifiedModel{id=$id, externalPlanId=$externalPlanId, name=$name, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanModel.kt new file mode 100644 index 000000000..e29934d7f --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanModel.kt @@ -0,0 +1,2083 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +/** + * 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). + */ +@NoAutoDetect +class PlanModel +@JsonCreator +private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("adjustments") + @ExcludeMissing + private val adjustments: JsonField> = JsonMissing.of(), + @JsonProperty("base_plan") + @ExcludeMissing + private val basePlan: JsonField = JsonMissing.of(), + @JsonProperty("base_plan_id") + @ExcludeMissing + private val basePlanId: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("default_invoice_memo") + @ExcludeMissing + private val defaultInvoiceMemo: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_plan_id") + @ExcludeMissing + private val externalPlanId: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_currency") + @ExcludeMissing + private val invoicingCurrency: JsonField = JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("net_terms") + @ExcludeMissing + private val netTerms: JsonField = JsonMissing.of(), + @JsonProperty("plan_phases") + @ExcludeMissing + private val planPhases: JsonField> = JsonMissing.of(), + @JsonProperty("prices") + @ExcludeMissing + private val prices: JsonField> = JsonMissing.of(), + @JsonProperty("product") + @ExcludeMissing + private val product: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + private val status: JsonField = JsonMissing.of(), + @JsonProperty("trial_config") + @ExcludeMissing + private val trialConfig: JsonField = JsonMissing.of(), + @JsonProperty("version") + @ExcludeMissing + private val version: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun id(): String = id.getRequired("id") + + /** + * Adjustments for this plan. If the plan has phases, this includes adjustments across all + * phases of the plan. + */ + fun adjustments(): List = adjustments.getRequired("adjustments") + + fun basePlan(): Optional = + Optional.ofNullable(basePlan.getNullable("base_plan")) + + /** + * The parent plan id if the given plan was created by overriding one or more of the parent's + * prices + */ + fun basePlanId(): Optional = Optional.ofNullable(basePlanId.getNullable("base_plan_id")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** An ISO 4217 currency string or custom pricing unit (`credits`) for this plan's prices. */ + @Deprecated("deprecated") fun currency(): String = currency.getRequired("currency") + + /** + * The default memo text on the invoices corresponding to subscriptions on this plan. Note that + * each subscription may configure its own memo. + */ + fun defaultInvoiceMemo(): Optional = + Optional.ofNullable(defaultInvoiceMemo.getNullable("default_invoice_memo")) + + fun description(): String = description.getRequired("description") + + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) + + /** + * An optional user-defined ID for this plan resource, used throughout the system as an alias + * for this Plan. Use this field to identify a plan by an existing identifier in your system. + */ + fun externalPlanId(): Optional = + Optional.ofNullable(externalPlanId.getNullable("external_plan_id")) + + /** + * An ISO 4217 currency string for which this plan is billed in. Matches `currency` unless + * `currency` is a custom pricing unit. + */ + fun invoicingCurrency(): String = invoicingCurrency.getRequired("invoicing_currency") + + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an empty + * dictionary. Individual keys can be removed by setting the value to `null`, and the entire + * metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + fun name(): String = name.getRequired("name") + + /** + * Determines the difference between the invoice issue date and the due date. A value of "0" + * here signifies that invoices are due on issue, whereas a value of "30" means that the + * customer has a month to pay the invoice before its overdue. Note that individual + * subscriptions or invoices may set a different net terms configuration. + */ + fun netTerms(): Optional = Optional.ofNullable(netTerms.getNullable("net_terms")) + + fun planPhases(): Optional> = + Optional.ofNullable(planPhases.getNullable("plan_phases")) + + /** + * Prices for this plan. If the plan has phases, this includes prices across all phases of the + * plan. + */ + fun prices(): List = prices.getRequired("prices") + + fun product(): Product = product.getRequired("product") + + fun status(): Status = status.getRequired("status") + + fun trialConfig(): TrialConfig = trialConfig.getRequired("trial_config") + + fun version(): Long = version.getRequired("version") + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Adjustments for this plan. If the plan has phases, this includes adjustments across all + * phases of the plan. + */ + @JsonProperty("adjustments") + @ExcludeMissing + fun _adjustments(): JsonField> = adjustments + + @JsonProperty("base_plan") + @ExcludeMissing + fun _basePlan(): JsonField = basePlan + + /** + * The parent plan id if the given plan was created by overriding one or more of the parent's + * prices + */ + @JsonProperty("base_plan_id") @ExcludeMissing fun _basePlanId(): JsonField = basePlanId + + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** An ISO 4217 currency string or custom pricing unit (`credits`) for this plan's prices. */ + @Deprecated("deprecated") + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * The default memo text on the invoices corresponding to subscriptions on this plan. Note that + * each subscription may configure its own memo. + */ + @JsonProperty("default_invoice_memo") + @ExcludeMissing + fun _defaultInvoiceMemo(): JsonField = defaultInvoiceMemo + + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount + + /** + * 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. + */ + @JsonProperty("external_plan_id") + @ExcludeMissing + fun _externalPlanId(): JsonField = externalPlanId + + /** + * An ISO 4217 currency string for which this plan is billed in. Matches `currency` unless + * `currency` is a custom pricing unit. + */ + @JsonProperty("invoicing_currency") + @ExcludeMissing + fun _invoicingCurrency(): JsonField = invoicingCurrency + + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Determines the difference between the invoice issue date and the due date. A value of "0" + * here signifies that invoices are due on issue, whereas a value of "30" means that the + * customer has a month to pay the invoice before its overdue. Note that individual + * subscriptions or invoices may set a different net terms configuration. + */ + @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms + + @JsonProperty("plan_phases") + @ExcludeMissing + fun _planPhases(): JsonField> = planPhases + + /** + * Prices for this plan. If the plan has phases, this includes prices across all phases of the + * plan. + */ + @JsonProperty("prices") @ExcludeMissing fun _prices(): JsonField> = prices + + @JsonProperty("product") @ExcludeMissing fun _product(): JsonField = product + + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + @JsonProperty("trial_config") + @ExcludeMissing + fun _trialConfig(): JsonField = trialConfig + + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): PlanModel = apply { + if (validated) { + return@apply + } + + id() + adjustments().forEach { it.validate() } + basePlan().ifPresent { it.validate() } + basePlanId() + createdAt() + currency() + defaultInvoiceMemo() + description() + discount().ifPresent { it.validate() } + externalPlanId() + invoicingCurrency() + maximum().ifPresent { it.validate() } + maximumAmount() + metadata().validate() + minimum().ifPresent { it.validate() } + minimumAmount() + name() + netTerms() + planPhases().ifPresent { it.forEach { it.validate() } } + prices().forEach { it.validate() } + product().validate() + status() + trialConfig().validate() + version() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PlanModel]. + * + * The following fields are required: + * ```java + * .id() + * .adjustments() + * .basePlan() + * .basePlanId() + * .createdAt() + * .currency() + * .defaultInvoiceMemo() + * .description() + * .discount() + * .externalPlanId() + * .invoicingCurrency() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .name() + * .netTerms() + * .planPhases() + * .prices() + * .product() + * .status() + * .trialConfig() + * .version() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PlanModel]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var adjustments: JsonField>? = null + private var basePlan: JsonField? = null + private var basePlanId: JsonField? = null + private var createdAt: JsonField? = null + private var currency: JsonField? = null + private var defaultInvoiceMemo: JsonField? = null + private var description: JsonField? = null + private var discount: JsonField? = null + private var externalPlanId: JsonField? = null + private var invoicingCurrency: 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 name: JsonField? = null + private var netTerms: JsonField? = null + private var planPhases: JsonField>? = null + private var prices: JsonField>? = null + private var product: JsonField? = null + private var status: JsonField? = null + private var trialConfig: JsonField? = null + private var version: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(planModel: PlanModel) = apply { + id = planModel.id + adjustments = planModel.adjustments.map { it.toMutableList() } + basePlan = planModel.basePlan + basePlanId = planModel.basePlanId + createdAt = planModel.createdAt + currency = planModel.currency + defaultInvoiceMemo = planModel.defaultInvoiceMemo + description = planModel.description + discount = planModel.discount + externalPlanId = planModel.externalPlanId + invoicingCurrency = planModel.invoicingCurrency + maximum = planModel.maximum + maximumAmount = planModel.maximumAmount + metadata = planModel.metadata + minimum = planModel.minimum + minimumAmount = planModel.minimumAmount + name = planModel.name + netTerms = planModel.netTerms + planPhases = planModel.planPhases.map { it.toMutableList() } + prices = planModel.prices.map { it.toMutableList() } + product = planModel.product + status = planModel.status + trialConfig = planModel.trialConfig + version = planModel.version + additionalProperties = planModel.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + /** + * Adjustments for this plan. If the plan has phases, this includes adjustments across all + * phases of the plan. + */ + fun adjustments(adjustments: List) = adjustments(JsonField.of(adjustments)) + + /** + * Adjustments for this plan. If the plan has phases, this includes adjustments across all + * phases of the plan. + */ + fun adjustments(adjustments: JsonField>) = apply { + this.adjustments = adjustments.map { it.toMutableList() } + } + + /** + * Adjustments for this plan. If the plan has phases, this includes adjustments across all + * phases of the plan. + */ + fun addAdjustment(adjustment: AdjustmentModel) = apply { + adjustments = + (adjustments ?: JsonField.of(mutableListOf())).also { + checkKnown("adjustments", it).add(adjustment) + } + } + + /** + * Adjustments for this plan. If the plan has phases, this includes adjustments across all + * phases of the plan. + */ + fun addAdjustment( + planPhaseUsageDiscountAdjustment: AdjustmentModel.PlanPhaseUsageDiscountAdjustment + ) = + addAdjustment( + AdjustmentModel.ofPlanPhaseUsageDiscountAdjustment(planPhaseUsageDiscountAdjustment) + ) + + /** + * Adjustments for this plan. If the plan has phases, this includes adjustments across all + * phases of the plan. + */ + fun addAdjustment( + planPhaseAmountDiscountAdjustment: AdjustmentModel.PlanPhaseAmountDiscountAdjustment + ) = + addAdjustment( + AdjustmentModel.ofPlanPhaseAmountDiscountAdjustment( + planPhaseAmountDiscountAdjustment + ) + ) + + /** + * Adjustments for this plan. If the plan has phases, this includes adjustments across all + * phases of the plan. + */ + fun addAdjustment( + planPhasePercentageDiscountAdjustment: + AdjustmentModel.PlanPhasePercentageDiscountAdjustment + ) = + addAdjustment( + AdjustmentModel.ofPlanPhasePercentageDiscountAdjustment( + planPhasePercentageDiscountAdjustment + ) + ) + + /** + * Adjustments for this plan. If the plan has phases, this includes adjustments across all + * phases of the plan. + */ + fun addAdjustment(planPhaseMinimumAdjustment: AdjustmentModel.PlanPhaseMinimumAdjustment) = + addAdjustment(AdjustmentModel.ofPlanPhaseMinimumAdjustment(planPhaseMinimumAdjustment)) + + /** + * Adjustments for this plan. If the plan has phases, this includes adjustments across all + * phases of the plan. + */ + fun addAdjustment(planPhaseMaximumAdjustment: AdjustmentModel.PlanPhaseMaximumAdjustment) = + addAdjustment(AdjustmentModel.ofPlanPhaseMaximumAdjustment(planPhaseMaximumAdjustment)) + + fun basePlan(basePlan: PlanMinifiedModel?) = basePlan(JsonField.ofNullable(basePlan)) + + fun basePlan(basePlan: Optional) = basePlan(basePlan.orElse(null)) + + fun basePlan(basePlan: JsonField) = apply { this.basePlan = basePlan } + + /** + * The parent plan id if the given plan was created by overriding one or more of the + * parent's prices + */ + fun basePlanId(basePlanId: String?) = basePlanId(JsonField.ofNullable(basePlanId)) + + /** + * The parent plan id if the given plan was created by overriding one or more of the + * parent's prices + */ + fun basePlanId(basePlanId: Optional) = basePlanId(basePlanId.orElse(null)) + + /** + * The parent plan id if the given plan was created by overriding one or more of the + * parent's prices + */ + fun basePlanId(basePlanId: JsonField) = apply { this.basePlanId = basePlanId } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + /** + * An ISO 4217 currency string or custom pricing unit (`credits`) for this plan's prices. + */ + @Deprecated("deprecated") fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * An ISO 4217 currency string or custom pricing unit (`credits`) for this plan's prices. + */ + @Deprecated("deprecated") + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** + * The default memo text on the invoices corresponding to subscriptions on this plan. Note + * that each subscription may configure its own memo. + */ + fun defaultInvoiceMemo(defaultInvoiceMemo: String?) = + defaultInvoiceMemo(JsonField.ofNullable(defaultInvoiceMemo)) + + /** + * The default memo text on the invoices corresponding to subscriptions on this plan. Note + * that each subscription may configure its own memo. + */ + fun defaultInvoiceMemo(defaultInvoiceMemo: Optional) = + defaultInvoiceMemo(defaultInvoiceMemo.orElse(null)) + + /** + * The default memo text on the invoices corresponding to subscriptions on this plan. Note + * that each subscription may configure its own memo. + */ + fun defaultInvoiceMemo(defaultInvoiceMemo: JsonField) = apply { + this.defaultInvoiceMemo = defaultInvoiceMemo + } + + fun description(description: String) = description(JsonField.of(description)) + + fun description(description: JsonField) = apply { this.description = description } + + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) + + fun discount(discount: JsonField) = apply { this.discount = discount } + + fun discount(percentage: PercentageDiscount) = discount(Discount.ofPercentage(percentage)) + + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) + + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) + + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + /** + * An optional user-defined ID for this plan resource, used throughout the system as an + * alias for this Plan. Use this field to identify a plan by an existing identifier in your + * system. + */ + fun externalPlanId(externalPlanId: String?) = + externalPlanId(JsonField.ofNullable(externalPlanId)) + + /** + * An optional user-defined ID for this plan resource, used throughout the system as an + * alias for this Plan. Use this field to identify a plan by an existing identifier in your + * system. + */ + fun externalPlanId(externalPlanId: Optional) = + externalPlanId(externalPlanId.orElse(null)) + + /** + * An optional user-defined ID for this plan resource, used throughout the system as an + * alias for this Plan. Use this field to identify a plan by an existing identifier in your + * system. + */ + fun externalPlanId(externalPlanId: JsonField) = apply { + this.externalPlanId = externalPlanId + } + + /** + * An ISO 4217 currency string for which this plan is billed in. Matches `currency` unless + * `currency` is a custom pricing unit. + */ + fun invoicingCurrency(invoicingCurrency: String) = + invoicingCurrency(JsonField.of(invoicingCurrency)) + + /** + * An ISO 4217 currency string for which this plan is billed in. Matches `currency` unless + * `currency` is a custom pricing unit. + */ + fun invoicingCurrency(invoicingCurrency: JsonField) = apply { + this.invoicingCurrency = invoicingCurrency + } + + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) + + 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)) + + /** + * 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: JsonField) = apply { this.metadata = metadata } + + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun name(name: String) = name(JsonField.of(name)) + + fun name(name: JsonField) = apply { this.name = name } + + /** + * Determines the difference between the invoice issue date and the due date. A value of "0" + * here signifies that invoices are due on issue, whereas a value of "30" means that the + * customer has a month to pay the invoice before its overdue. Note that individual + * subscriptions or invoices may set a different net terms configuration. + */ + fun netTerms(netTerms: Long?) = netTerms(JsonField.ofNullable(netTerms)) + + /** + * Determines the difference between the invoice issue date and the due date. A value of "0" + * here signifies that invoices are due on issue, whereas a value of "30" means that the + * customer has a month to pay the invoice before its overdue. Note that individual + * subscriptions or invoices may set a different net terms configuration. + */ + fun netTerms(netTerms: Long) = netTerms(netTerms as Long?) + + /** + * Determines the difference between the invoice issue date and the due date. A value of "0" + * here signifies that invoices are due on issue, whereas a value of "30" means that the + * customer has a month to pay the invoice before its overdue. Note that individual + * subscriptions or invoices may set a different net terms configuration. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun netTerms(netTerms: Optional) = netTerms(netTerms.orElse(null) as Long?) + + /** + * Determines the difference between the invoice issue date and the due date. A value of "0" + * here signifies that invoices are due on issue, whereas a value of "30" means that the + * customer has a month to pay the invoice before its overdue. Note that individual + * subscriptions or invoices may set a different net terms configuration. + */ + fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } + + fun planPhases(planPhases: List?) = planPhases(JsonField.ofNullable(planPhases)) + + fun planPhases(planPhases: Optional>) = planPhases(planPhases.orElse(null)) + + fun planPhases(planPhases: JsonField>) = apply { + this.planPhases = planPhases.map { it.toMutableList() } + } + + fun addPlanPhase(planPhase: PlanPhase) = apply { + planPhases = + (planPhases ?: JsonField.of(mutableListOf())).also { + checkKnown("planPhases", it).add(planPhase) + } + } + + /** + * Prices for this plan. If the plan has phases, this includes prices across all phases of + * the plan. + */ + fun prices(prices: List) = prices(JsonField.of(prices)) + + /** + * Prices for this plan. If the plan has phases, this includes prices across all phases of + * the plan. + */ + fun prices(prices: JsonField>) = apply { + this.prices = prices.map { it.toMutableList() } + } + + /** + * Prices for this plan. If the plan has phases, this includes prices across all phases of + * the plan. + */ + fun addPrice(price: PriceModel) = apply { + prices = + (prices ?: JsonField.of(mutableListOf())).also { + checkKnown("prices", it).add(price) + } + } + + /** + * Prices for this plan. If the plan has phases, this includes prices across all phases of + * the plan. + */ + fun addPrice(unitPrice: PriceModel.UnitPrice) = addPrice(PriceModel.ofUnitPrice(unitPrice)) + + /** + * Prices for this plan. If the plan has phases, this includes prices across all phases of + * the plan. + */ + fun addPrice(packagePrice: PriceModel.PackagePrice) = + addPrice(PriceModel.ofPackagePrice(packagePrice)) + + /** + * Prices for this plan. If the plan has phases, this includes prices across all phases of + * the plan. + */ + fun addPrice(matrixPrice: PriceModel.MatrixPrice) = + addPrice(PriceModel.ofMatrixPrice(matrixPrice)) + + /** + * Prices for this plan. If the plan has phases, this includes prices across all phases of + * the plan. + */ + fun addPrice(tieredPrice: PriceModel.TieredPrice) = + addPrice(PriceModel.ofTieredPrice(tieredPrice)) + + /** + * Prices for this plan. If the plan has phases, this includes prices across all phases of + * the plan. + */ + fun addPrice(tieredBpsPrice: PriceModel.TieredBpsPrice) = + addPrice(PriceModel.ofTieredBpsPrice(tieredBpsPrice)) + + /** + * Prices for this plan. If the plan has phases, this includes prices across all phases of + * the plan. + */ + fun addPrice(bpsPrice: PriceModel.BpsPrice) = addPrice(PriceModel.ofBpsPrice(bpsPrice)) + + /** + * Prices for this plan. If the plan has phases, this includes prices across all phases of + * the plan. + */ + fun addPrice(bulkBpsPrice: PriceModel.BulkBpsPrice) = + addPrice(PriceModel.ofBulkBpsPrice(bulkBpsPrice)) + + /** + * Prices for this plan. If the plan has phases, this includes prices across all phases of + * the plan. + */ + fun addPrice(bulkPrice: PriceModel.BulkPrice) = addPrice(PriceModel.ofBulkPrice(bulkPrice)) + + /** + * Prices for this plan. If the plan has phases, this includes prices across all phases of + * the plan. + */ + fun addPrice(thresholdTotalAmountPrice: PriceModel.ThresholdTotalAmountPrice) = + addPrice(PriceModel.ofThresholdTotalAmountPrice(thresholdTotalAmountPrice)) + + /** + * Prices for this plan. If the plan has phases, this includes prices across all phases of + * the plan. + */ + fun addPrice(tieredPackagePrice: PriceModel.TieredPackagePrice) = + addPrice(PriceModel.ofTieredPackagePrice(tieredPackagePrice)) + + /** + * Prices for this plan. If the plan has phases, this includes prices across all phases of + * the plan. + */ + fun addPrice(groupedTieredPrice: PriceModel.GroupedTieredPrice) = + addPrice(PriceModel.ofGroupedTieredPrice(groupedTieredPrice)) + + /** + * Prices for this plan. If the plan has phases, this includes prices across all phases of + * the plan. + */ + fun addPrice(tieredWithMinimumPrice: PriceModel.TieredWithMinimumPrice) = + addPrice(PriceModel.ofTieredWithMinimumPrice(tieredWithMinimumPrice)) + + /** + * Prices for this plan. If the plan has phases, this includes prices across all phases of + * the plan. + */ + fun addPrice(tieredPackageWithMinimumPrice: PriceModel.TieredPackageWithMinimumPrice) = + addPrice(PriceModel.ofTieredPackageWithMinimumPrice(tieredPackageWithMinimumPrice)) + + /** + * Prices for this plan. If the plan has phases, this includes prices across all phases of + * the plan. + */ + fun addPrice(packageWithAllocationPrice: PriceModel.PackageWithAllocationPrice) = + addPrice(PriceModel.ofPackageWithAllocationPrice(packageWithAllocationPrice)) + + /** + * Prices for this plan. If the plan has phases, this includes prices across all phases of + * the plan. + */ + fun addPrice(unitWithPercentPrice: PriceModel.UnitWithPercentPrice) = + addPrice(PriceModel.ofUnitWithPercentPrice(unitWithPercentPrice)) + + /** + * Prices for this plan. If the plan has phases, this includes prices across all phases of + * the plan. + */ + fun addPrice(matrixWithAllocationPrice: PriceModel.MatrixWithAllocationPrice) = + addPrice(PriceModel.ofMatrixWithAllocationPrice(matrixWithAllocationPrice)) + + /** + * Prices for this plan. If the plan has phases, this includes prices across all phases of + * the plan. + */ + fun addPrice(tieredWithProrationPrice: PriceModel.TieredWithProrationPrice) = + addPrice(PriceModel.ofTieredWithProrationPrice(tieredWithProrationPrice)) + + /** + * Prices for this plan. If the plan has phases, this includes prices across all phases of + * the plan. + */ + fun addPrice(unitWithProrationPrice: PriceModel.UnitWithProrationPrice) = + addPrice(PriceModel.ofUnitWithProrationPrice(unitWithProrationPrice)) + + /** + * Prices for this plan. If the plan has phases, this includes prices across all phases of + * the plan. + */ + fun addPrice(groupedAllocationPrice: PriceModel.GroupedAllocationPrice) = + addPrice(PriceModel.ofGroupedAllocationPrice(groupedAllocationPrice)) + + /** + * Prices for this plan. If the plan has phases, this includes prices across all phases of + * the plan. + */ + fun addPrice(groupedWithProratedMinimumPrice: PriceModel.GroupedWithProratedMinimumPrice) = + addPrice(PriceModel.ofGroupedWithProratedMinimumPrice(groupedWithProratedMinimumPrice)) + + /** + * Prices for this plan. If the plan has phases, this includes prices across all phases of + * the plan. + */ + fun addPrice(groupedWithMeteredMinimumPrice: PriceModel.GroupedWithMeteredMinimumPrice) = + addPrice(PriceModel.ofGroupedWithMeteredMinimumPrice(groupedWithMeteredMinimumPrice)) + + /** + * Prices for this plan. If the plan has phases, this includes prices across all phases of + * the plan. + */ + fun addPrice(matrixWithDisplayNamePrice: PriceModel.MatrixWithDisplayNamePrice) = + addPrice(PriceModel.ofMatrixWithDisplayNamePrice(matrixWithDisplayNamePrice)) + + /** + * Prices for this plan. If the plan has phases, this includes prices across all phases of + * the plan. + */ + fun addPrice(bulkWithProrationPrice: PriceModel.BulkWithProrationPrice) = + addPrice(PriceModel.ofBulkWithProrationPrice(bulkWithProrationPrice)) + + /** + * Prices for this plan. If the plan has phases, this includes prices across all phases of + * the plan. + */ + fun addPrice(groupedTieredPackagePrice: PriceModel.GroupedTieredPackagePrice) = + addPrice(PriceModel.ofGroupedTieredPackagePrice(groupedTieredPackagePrice)) + + /** + * Prices for this plan. If the plan has phases, this includes prices across all phases of + * the plan. + */ + fun addPrice(maxGroupTieredPackagePrice: PriceModel.MaxGroupTieredPackagePrice) = + addPrice(PriceModel.ofMaxGroupTieredPackagePrice(maxGroupTieredPackagePrice)) + + /** + * Prices for this plan. If the plan has phases, this includes prices across all phases of + * the plan. + */ + fun addPrice( + scalableMatrixWithUnitPricingPrice: PriceModel.ScalableMatrixWithUnitPricingPrice + ) = + addPrice( + PriceModel.ofScalableMatrixWithUnitPricingPrice(scalableMatrixWithUnitPricingPrice) + ) + + /** + * Prices for this plan. If the plan has phases, this includes prices across all phases of + * the plan. + */ + fun addPrice( + scalableMatrixWithTieredPricingPrice: PriceModel.ScalableMatrixWithTieredPricingPrice + ) = + addPrice( + PriceModel.ofScalableMatrixWithTieredPricingPrice( + scalableMatrixWithTieredPricingPrice + ) + ) + + /** + * Prices for this plan. If the plan has phases, this includes prices across all phases of + * the plan. + */ + fun addPrice(cumulativeGroupedBulkPrice: PriceModel.CumulativeGroupedBulkPrice) = + addPrice(PriceModel.ofCumulativeGroupedBulkPrice(cumulativeGroupedBulkPrice)) + + fun product(product: Product) = product(JsonField.of(product)) + + fun product(product: JsonField) = apply { this.product = product } + + fun status(status: Status) = status(JsonField.of(status)) + + fun status(status: JsonField) = apply { this.status = status } + + fun trialConfig(trialConfig: TrialConfig) = trialConfig(JsonField.of(trialConfig)) + + fun trialConfig(trialConfig: JsonField) = apply { + this.trialConfig = trialConfig + } + + fun version(version: Long) = version(JsonField.of(version)) + + fun version(version: JsonField) = apply { this.version = version } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): PlanModel = + PlanModel( + checkRequired("id", id), + checkRequired("adjustments", adjustments).map { it.toImmutable() }, + checkRequired("basePlan", basePlan), + checkRequired("basePlanId", basePlanId), + checkRequired("createdAt", createdAt), + checkRequired("currency", currency), + checkRequired("defaultInvoiceMemo", defaultInvoiceMemo), + checkRequired("description", description), + checkRequired("discount", discount), + checkRequired("externalPlanId", externalPlanId), + checkRequired("invoicingCurrency", invoicingCurrency), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("name", name), + checkRequired("netTerms", netTerms), + checkRequired("planPhases", planPhases).map { it.toImmutable() }, + checkRequired("prices", prices).map { it.toImmutable() }, + checkRequired("product", product), + checkRequired("status", status), + checkRequired("trialConfig", trialConfig), + checkRequired("version", version), + additionalProperties.toImmutable(), + ) + } + + /** + * 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`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class PlanPhase + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("order") + @ExcludeMissing + private val order: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) + + /** + * How many terms of length `duration_unit` this phase is active for. If null, this phase is + * evergreen and active indefinitely + */ + fun duration(): Optional = Optional.ofNullable(duration.getNullable("duration")) + + fun durationUnit(): Optional = + Optional.ofNullable(durationUnit.getNullable("duration_unit")) + + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + fun name(): String = name.getRequired("name") + + /** Determines the ordering of the phase in a plan's lifecycle. 1 = first phase. */ + fun order(): Long = order.getRequired("order") + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount + + /** + * How many terms of length `duration_unit` this phase is active for. If null, this phase is + * evergreen and active indefinitely + */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit + + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount + + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** Determines the ordering of the phase in a plan's lifecycle. 1 = first phase. */ + @JsonProperty("order") @ExcludeMissing fun _order(): JsonField = order + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): PlanPhase = apply { + if (validated) { + return@apply + } + + id() + description() + discount().ifPresent { it.validate() } + duration() + durationUnit() + maximum().ifPresent { it.validate() } + maximumAmount() + minimum().ifPresent { it.validate() } + minimumAmount() + name() + order() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PlanPhase]. + * + * The following fields are required: + * ```java + * .id() + * .description() + * .discount() + * .duration() + * .durationUnit() + * .maximum() + * .maximumAmount() + * .minimum() + * .minimumAmount() + * .name() + * .order() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PlanPhase]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var description: JsonField? = null + private var discount: JsonField? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var name: JsonField? = null + private var order: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(planPhase: PlanPhase) = apply { + id = planPhase.id + description = planPhase.description + discount = planPhase.discount + duration = planPhase.duration + durationUnit = planPhase.durationUnit + maximum = planPhase.maximum + maximumAmount = planPhase.maximumAmount + minimum = planPhase.minimum + minimumAmount = planPhase.minimumAmount + name = planPhase.name + order = planPhase.order + additionalProperties = planPhase.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + fun description(description: Optional) = description(description.orElse(null)) + + fun description(description: JsonField) = apply { + this.description = description + } + + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) + + fun discount(discount: JsonField) = apply { this.discount = discount } + + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) + + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) + + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) + + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + /** + * How many terms of length `duration_unit` this phase is active for. If null, this + * phase is evergreen and active indefinitely + */ + fun duration(duration: Long?) = duration(JsonField.ofNullable(duration)) + + /** + * How many terms of length `duration_unit` this phase is active for. If null, this + * phase is evergreen and active indefinitely + */ + fun duration(duration: Long) = duration(duration as Long?) + + /** + * How many terms of length `duration_unit` this phase is active for. If null, this + * phase is evergreen and active indefinitely + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun duration(duration: Optional) = duration(duration.orElse(null) as Long?) + + /** + * How many terms of length `duration_unit` this phase is active for. If null, this + * phase is evergreen and active indefinitely + */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + fun durationUnit(durationUnit: DurationUnit?) = + durationUnit(JsonField.ofNullable(durationUnit)) + + fun durationUnit(durationUnit: Optional) = + durationUnit(durationUnit.orElse(null)) + + fun durationUnit(durationUnit: JsonField) = apply { + this.durationUnit = durationUnit + } + + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) + + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun name(name: String) = name(JsonField.of(name)) + + fun name(name: JsonField) = apply { this.name = name } + + /** Determines the ordering of the phase in a plan's lifecycle. 1 = first phase. */ + fun order(order: Long) = order(JsonField.of(order)) + + /** Determines the ordering of the phase in a plan's lifecycle. 1 = first phase. */ + fun order(order: JsonField) = apply { this.order = order } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): PlanPhase = + PlanPhase( + checkRequired("id", id), + checkRequired("description", description), + checkRequired("discount", discount), + checkRequired("duration", duration), + checkRequired("durationUnit", durationUnit), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("name", name), + checkRequired("order", order), + additionalProperties.toImmutable(), + ) + } + + class DurationUnit @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val DAILY = of("daily") + + @JvmField val MONTHLY = of("monthly") + + @JvmField val QUARTERLY = of("quarterly") + + @JvmField val SEMI_ANNUAL = of("semi_annual") + + @JvmField val ANNUAL = of("annual") + + @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) + } + + /** An enum containing [DurationUnit]'s known values. */ + enum class Known { + DAILY, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + } + + /** + * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [DurationUnit] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + DAILY, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + /** + * An enum member indicating that [DurationUnit] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + DAILY -> Value.DAILY + MONTHLY -> Value.MONTHLY + QUARTERLY -> Value.QUARTERLY + SEMI_ANNUAL -> Value.SEMI_ANNUAL + ANNUAL -> Value.ANNUAL + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + DAILY -> Known.DAILY + MONTHLY -> Known.MONTHLY + QUARTERLY -> Known.QUARTERLY + SEMI_ANNUAL -> Known.SEMI_ANNUAL + ANNUAL -> Known.ANNUAL + else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if 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 + } + + return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PlanPhase && id == other.id && description == other.description && discount == other.discount && duration == other.duration && durationUnit == other.durationUnit && maximum == other.maximum && maximumAmount == other.maximumAmount && minimum == other.minimum && minimumAmount == other.minimumAmount && name == other.name && order == other.order && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, description, discount, duration, durationUnit, maximum, maximumAmount, minimum, minimumAmount, name, order, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PlanPhase{id=$id, description=$description, discount=$discount, duration=$duration, durationUnit=$durationUnit, maximum=$maximum, maximumAmount=$maximumAmount, minimum=$minimum, minimumAmount=$minimumAmount, name=$name, order=$order, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class Product + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + fun name(): String = name.getRequired("name") + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Product = apply { + if (validated) { + return@apply + } + + id() + createdAt() + name() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Product]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Product]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var createdAt: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(product: Product) = apply { + id = product.id + createdAt = product.createdAt + name = product.name + additionalProperties = product.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun name(name: String) = name(JsonField.of(name)) + + 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) + } + + fun build(): Product = + Product( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("name", name), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Product && id == other.id && createdAt == other.createdAt && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, createdAt, name, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Product{id=$id, createdAt=$createdAt, name=$name, 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 ARCHIVED = of("archived") + + @JvmField val DRAFT = of("draft") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + ARCHIVED, + 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 { + ACTIVE, + ARCHIVED, + 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) { + ACTIVE -> Value.ACTIVE + ARCHIVED -> Value.ARCHIVED + 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) { + ACTIVE -> Known.ACTIVE + ARCHIVED -> Known.ARCHIVED + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + @NoAutoDetect + class TrialConfig + @JsonCreator + private constructor( + @JsonProperty("trial_period") + @ExcludeMissing + private val trialPeriod: JsonField = JsonMissing.of(), + @JsonProperty("trial_period_unit") + @ExcludeMissing + private val trialPeriodUnit: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun trialPeriod(): Optional = + Optional.ofNullable(trialPeriod.getNullable("trial_period")) + + fun trialPeriodUnit(): TrialPeriodUnit = trialPeriodUnit.getRequired("trial_period_unit") + + @JsonProperty("trial_period") + @ExcludeMissing + fun _trialPeriod(): JsonField = trialPeriod + + @JsonProperty("trial_period_unit") + @ExcludeMissing + fun _trialPeriodUnit(): JsonField = trialPeriodUnit + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): TrialConfig = apply { + if (validated) { + return@apply + } + + trialPeriod() + trialPeriodUnit() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TrialConfig]. + * + * The following fields are required: + * ```java + * .trialPeriod() + * .trialPeriodUnit() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TrialConfig]. */ + class Builder internal constructor() { + + private var trialPeriod: JsonField? = null + private var trialPeriodUnit: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(trialConfig: TrialConfig) = apply { + trialPeriod = trialConfig.trialPeriod + trialPeriodUnit = trialConfig.trialPeriodUnit + additionalProperties = trialConfig.additionalProperties.toMutableMap() + } + + fun trialPeriod(trialPeriod: Long?) = trialPeriod(JsonField.ofNullable(trialPeriod)) + + fun trialPeriod(trialPeriod: Long) = trialPeriod(trialPeriod as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun trialPeriod(trialPeriod: Optional) = + trialPeriod(trialPeriod.orElse(null) as Long?) + + fun trialPeriod(trialPeriod: JsonField) = apply { this.trialPeriod = trialPeriod } + + fun trialPeriodUnit(trialPeriodUnit: TrialPeriodUnit) = + trialPeriodUnit(JsonField.of(trialPeriodUnit)) + + fun trialPeriodUnit(trialPeriodUnit: JsonField) = apply { + this.trialPeriodUnit = trialPeriodUnit + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): TrialConfig = + TrialConfig( + checkRequired("trialPeriod", trialPeriod), + checkRequired("trialPeriodUnit", trialPeriodUnit), + additionalProperties.toImmutable(), + ) + } + + class TrialPeriodUnit + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val DAYS = of("days") + + @JvmStatic fun of(value: String) = TrialPeriodUnit(JsonField.of(value)) + } + + /** An enum containing [TrialPeriodUnit]'s known values. */ + enum class Known { + DAYS + } + + /** + * An enum containing [TrialPeriodUnit]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TrialPeriodUnit] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + DAYS, + /** + * An enum member indicating that [TrialPeriodUnit] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + DAYS -> Value.DAYS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + DAYS -> Known.DAYS + else -> throw OrbInvalidDataException("Unknown TrialPeriodUnit: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if 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 + } + + return /* spotless:off */ other is TrialPeriodUnit && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TrialConfig && trialPeriod == other.trialPeriod && trialPeriodUnit == other.trialPeriodUnit && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(trialPeriod, trialPeriodUnit, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TrialConfig{trialPeriod=$trialPeriod, trialPeriodUnit=$trialPeriodUnit, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PlanModel && id == other.id && adjustments == other.adjustments && basePlan == other.basePlan && basePlanId == other.basePlanId && createdAt == other.createdAt && currency == other.currency && defaultInvoiceMemo == other.defaultInvoiceMemo && description == other.description && discount == other.discount && externalPlanId == other.externalPlanId && invoicingCurrency == other.invoicingCurrency && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && name == other.name && netTerms == other.netTerms && planPhases == other.planPhases && prices == other.prices && product == other.product && status == other.status && trialConfig == other.trialConfig && version == other.version && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, adjustments, basePlan, basePlanId, createdAt, currency, defaultInvoiceMemo, description, discount, externalPlanId, invoicingCurrency, maximum, maximumAmount, metadata, minimum, minimumAmount, name, netTerms, planPhases, prices, product, status, trialConfig, version, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PlanModel{id=$id, adjustments=$adjustments, basePlan=$basePlan, basePlanId=$basePlanId, createdAt=$createdAt, currency=$currency, defaultInvoiceMemo=$defaultInvoiceMemo, description=$description, discount=$discount, externalPlanId=$externalPlanId, invoicingCurrency=$invoicingCurrency, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, name=$name, netTerms=$netTerms, planPhases=$planPhases, prices=$prices, product=$product, status=$status, trialConfig=$trialConfig, version=$version, additionalProperties=$additionalProperties}" +} diff --git a/orb-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 efc138f9b..9c55ac39e 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 @@ -2,23 +2,13 @@ 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.NoAutoDetect 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.immutableEmptyMap -import com.withorb.api.core.toImmutable import java.util.Objects -import java.util.Optional /** * This endpoint can be used to update the `external_plan_id`, and `metadata` of an existing plan. @@ -28,46 +18,22 @@ import java.util.Optional class PlanUpdateParams private constructor( private val planId: String, - private val body: Body, + private val editPlanModel: EditPlanModel, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { fun planId(): String = planId - /** - * An optional user-defined ID for this plan resource, used throughout the system as an alias - * for this Plan. Use this field to identify a plan by an existing identifier in your system. - */ - fun externalPlanId(): Optional = body.externalPlanId() - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - */ - fun metadata(): Optional = body.metadata() - - /** - * An optional user-defined ID for this plan resource, used throughout the system as an alias - * for this Plan. Use this field to identify a plan by an existing identifier in your system. - */ - fun _externalPlanId(): JsonField = body._externalPlanId() - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - */ - fun _metadata(): JsonField = body._metadata() - - fun _additionalBodyProperties(): Map = body._additionalProperties() + fun editPlanModel(): EditPlanModel = editPlanModel + + fun _additionalBodyProperties(): Map = editPlanModel._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): EditPlanModel = editPlanModel override fun _headers(): Headers = additionalHeaders @@ -80,178 +46,19 @@ private constructor( } } - @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("external_plan_id") - @ExcludeMissing - private val externalPlanId: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * An optional user-defined ID for this plan resource, used throughout the system as an - * alias for this Plan. Use this field to identify a plan by an existing identifier in your - * system. - */ - fun externalPlanId(): Optional = - Optional.ofNullable(externalPlanId.getNullable("external_plan_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`. - */ - fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * 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. - */ - @JsonProperty("external_plan_id") - @ExcludeMissing - fun _externalPlanId(): JsonField = externalPlanId - - /** - * User-specified key/value pairs for the resource. 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - externalPlanId() - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var externalPlanId: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - externalPlanId = body.externalPlanId - metadata = body.metadata - additionalProperties = body.additionalProperties.toMutableMap() - } - - /** - * An optional user-defined ID for this plan resource, used throughout the system as an - * alias for this Plan. Use this field to identify a plan by an existing identifier in - * your system. - */ - fun externalPlanId(externalPlanId: String?) = - externalPlanId(JsonField.ofNullable(externalPlanId)) - - /** - * An optional user-defined ID for this plan resource, used throughout the system as an - * alias for this Plan. Use this field to identify a plan by an existing identifier in - * your system. - */ - fun externalPlanId(externalPlanId: Optional) = - externalPlanId(externalPlanId.orElse(null)) - - /** - * An optional user-defined ID for this plan resource, used throughout the system as an - * alias for this Plan. Use this field to identify a plan by an existing identifier in - * your system. - */ - fun externalPlanId(externalPlanId: JsonField) = apply { - this.externalPlanId = externalPlanId - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): Body = Body(externalPlanId, metadata, additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Body && externalPlanId == other.externalPlanId && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(externalPlanId, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{externalPlanId=$externalPlanId, metadata=$metadata, additionalProperties=$additionalProperties}" - } - fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of [PlanUpdateParams]. + * + * The following fields are required: + * ```java + * .planId() + * .editPlanModel() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -260,82 +67,22 @@ private constructor( class Builder internal constructor() { private var planId: String? = null - private var body: Body.Builder = Body.builder() + private var editPlanModel: EditPlanModel? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(planUpdateParams: PlanUpdateParams) = apply { planId = planUpdateParams.planId - body = planUpdateParams.body.toBuilder() + editPlanModel = planUpdateParams.editPlanModel additionalHeaders = planUpdateParams.additionalHeaders.toBuilder() additionalQueryParams = planUpdateParams.additionalQueryParams.toBuilder() } fun planId(planId: String) = apply { this.planId = planId } - /** - * An optional user-defined ID for this plan resource, used throughout the system as an - * alias for this Plan. Use this field to identify a plan by an existing identifier in your - * system. - */ - fun externalPlanId(externalPlanId: String?) = apply { body.externalPlanId(externalPlanId) } - - /** - * An optional user-defined ID for this plan resource, used throughout the system as an - * alias for this Plan. Use this field to identify a plan by an existing identifier in your - * system. - */ - fun externalPlanId(externalPlanId: Optional) = - externalPlanId(externalPlanId.orElse(null)) - - /** - * An optional user-defined ID for this plan resource, used throughout the system as an - * alias for this Plan. Use this field to identify a plan by an existing identifier in your - * system. - */ - fun externalPlanId(externalPlanId: JsonField) = apply { - body.externalPlanId(externalPlanId) - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by setting - * `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by setting - * `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: JsonField) = apply { body.metadata(metadata) } - - 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 editPlanModel(editPlanModel: EditPlanModel) = apply { + this.editPlanModel = editPlanModel } fun additionalHeaders(additionalHeaders: Headers) = apply { @@ -439,105 +186,22 @@ private constructor( fun build(): PlanUpdateParams = PlanUpdateParams( checkRequired("planId", planId), - body.build(), + checkRequired("editPlanModel", editPlanModel), additionalHeaders.build(), additionalQueryParams.build(), ) } - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanUpdateParams && planId == other.planId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is PlanUpdateParams && planId == other.planId && editPlanModel == other.editPlanModel && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(planId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(planId, editPlanModel, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "PlanUpdateParams{planId=$planId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "PlanUpdateParams{planId=$planId, editPlanModel=$editPlanModel, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } 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 2495518f5..f3f7b76c0 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 @@ -980,10 +980,10 @@ private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("billable_metric") @ExcludeMissing - private val billableMetric: JsonField = JsonMissing.of(), + private val billableMetric: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") @ExcludeMissing - private val billingCycleConfiguration: JsonField = + private val billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing @@ -996,7 +996,7 @@ private constructor( private val createdAt: JsonField = JsonMissing.of(), @JsonProperty("credit_allocation") @ExcludeMissing - private val creditAllocation: JsonField = JsonMissing.of(), + private val creditAllocation: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing private val currency: JsonField = JsonMissing.of(), @@ -1011,12 +1011,14 @@ private constructor( private val fixedPriceQuantity: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = + private val invoicingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("item") @ExcludeMissing private val item: JsonField = JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), @JsonProperty("maximum") @ExcludeMissing - private val maximum: JsonField = JsonMissing.of(), + private val maximum: JsonField = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing private val maximumAmount: JsonField = JsonMissing.of(), @@ -1025,7 +1027,7 @@ private constructor( private val metadata: JsonField = JsonMissing.of(), @JsonProperty("minimum") @ExcludeMissing - private val minimum: JsonField = JsonMissing.of(), + private val minimum: JsonField = JsonMissing.of(), @JsonProperty("minimum_amount") @ExcludeMissing private val minimumAmount: JsonField = JsonMissing.of(), @@ -1043,10 +1045,10 @@ private constructor( private val priceType: JsonField = JsonMissing.of(), @JsonProperty("unit_config") @ExcludeMissing - private val unitConfig: JsonField = JsonMissing.of(), + private val unitConfig: JsonField = JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing - private val dimensionalPriceConfiguration: JsonField = + private val dimensionalPriceConfiguration: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), @@ -1054,10 +1056,10 @@ private constructor( fun id(): String = id.getRequired("id") - fun billableMetric(): Optional = + fun billableMetric(): Optional = Optional.ofNullable(billableMetric.getNullable("billable_metric")) - fun billingCycleConfiguration(): BillingCycleConfiguration = + fun billingCycleConfiguration(): BillingCycleConfigurationModel = billingCycleConfiguration.getRequired("billing_cycle_configuration") fun cadence(): Cadence = cadence.getRequired("cadence") @@ -1067,7 +1069,7 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - fun creditAllocation(): Optional = + fun creditAllocation(): Optional = Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) fun currency(): String = currency.getRequired("currency") @@ -1080,14 +1082,14 @@ private constructor( fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - fun invoicingCycleConfiguration(): Optional = + fun invoicingCycleConfiguration(): Optional = Optional.ofNullable( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") ) - fun item(): Item = item.getRequired("item") + fun item(): ItemSlimModel = item.getRequired("item") - fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) @@ -1099,7 +1101,7 @@ private constructor( */ fun metadata(): Metadata = metadata.getRequired("metadata") - fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) fun minimumAmount(): Optional = Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) @@ -1113,9 +1115,9 @@ private constructor( fun priceType(): PriceType = priceType.getRequired("price_type") - fun unitConfig(): UnitConfig = unitConfig.getRequired("unit_config") + fun unitConfig(): UnitConfigModel = unitConfig.getRequired("unit_config") - fun dimensionalPriceConfiguration(): Optional = + fun dimensionalPriceConfiguration(): Optional = Optional.ofNullable( dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") ) @@ -1124,11 +1126,11 @@ private constructor( @JsonProperty("billable_metric") @ExcludeMissing - fun _billableMetric(): JsonField = billableMetric + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = + fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence @@ -1143,7 +1145,7 @@ private constructor( @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation(): JsonField = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @@ -1159,12 +1161,12 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = + fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum @JsonProperty("maximum_amount") @ExcludeMissing @@ -1177,7 +1179,7 @@ private constructor( */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum @JsonProperty("minimum_amount") @ExcludeMissing @@ -1199,11 +1201,11 @@ private constructor( @JsonProperty("unit_config") @ExcludeMissing - fun _unitConfig(): JsonField = unitConfig + fun _unitConfig(): JsonField = unitConfig @JsonProperty("dimensional_price_configuration") @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = + fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration @JsonAnyGetter @@ -1248,6 +1250,36 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [UnitPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * .unitConfig() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1255,29 +1287,31 @@ private constructor( class Builder internal constructor() { private var id: JsonField? = null - private var billableMetric: JsonField? = null - private var billingCycleConfiguration: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null private var cadence: JsonField? = null private var conversionRate: JsonField? = null private var createdAt: JsonField? = null - private var creditAllocation: 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 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 minimum: JsonField? = null private var minimumAmount: JsonField? = null private var modelType: JsonField? = null private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null - private var unitConfig: JsonField? = null - private var dimensionalPriceConfiguration: JsonField = + private var unitConfig: JsonField? = null + private var dimensionalPriceConfiguration: + JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1314,21 +1348,22 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric?) = + fun billableMetric(billableMetric: BillableMetricTinyModel?) = billableMetric(JsonField.ofNullable(billableMetric)) - fun billableMetric(billableMetric: Optional) = + fun billableMetric(billableMetric: Optional) = billableMetric(billableMetric.orElse(null)) - fun billableMetric(billableMetric: JsonField) = apply { + fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric } - fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = - billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) fun billingCycleConfiguration( - billingCycleConfiguration: JsonField + billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -1354,13 +1389,13 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation?) = + fun creditAllocation(creditAllocation: AllocationModel?) = creditAllocation(JsonField.ofNullable(creditAllocation)) - fun creditAllocation(creditAllocation: Optional) = + fun creditAllocation(creditAllocation: Optional) = creditAllocation(creditAllocation.orElse(null)) - fun creditAllocation(creditAllocation: JsonField) = apply { + fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation } @@ -1416,26 +1451,26 @@ private constructor( } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? + invoicingCycleConfiguration: BillingCycleConfigurationModel? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional + invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField + invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun item(item: Item) = item(JsonField.of(item)) + fun item(item: ItemSlimModel) = item(JsonField.of(item)) - fun item(item: JsonField) = apply { this.item = item } + fun item(item: JsonField) = apply { this.item = item } - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) - fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } fun maximumAmount(maximumAmount: String?) = maximumAmount(JsonField.ofNullable(maximumAmount)) @@ -1461,11 +1496,11 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) - fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } fun minimumAmount(minimumAmount: String?) = minimumAmount(JsonField.ofNullable(minimumAmount)) @@ -1502,22 +1537,22 @@ private constructor( fun priceType(priceType: JsonField) = apply { this.priceType = priceType } - fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) + fun unitConfig(unitConfig: UnitConfigModel) = unitConfig(JsonField.of(unitConfig)) - fun unitConfig(unitConfig: JsonField) = apply { + fun unitConfig(unitConfig: JsonField) = apply { this.unitConfig = unitConfig } fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: DimensionalPriceConfiguration? + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional + dimensionalPriceConfiguration: Optional ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField + dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } fun additionalProperties(additionalProperties: Map) = apply { @@ -1569,330 +1604,6 @@ private constructor( ) } - @NoAutoDetect - class BillableMetric - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillableMetric = apply { - if (validated) { - return@apply - } - - id() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillableMetric]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billableMetric: BillableMetric) = apply { - id = billableMetric.id - additionalProperties = billableMetric.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - 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) - } - - fun build(): BillableMetric = - BillableMetric(checkRequired("id", id), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillableMetric && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillableMetric{id=$id, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - class Cadence @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2018,43 +1729,30 @@ private constructor( override fun toString() = value.toString() } + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ @NoAutoDetect - class CreditAllocation + class Metadata @JsonCreator private constructor( - @JsonProperty("allows_rollover") - @ExcludeMissing - private val allowsRollover: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { - fun allowsRollover(): Boolean = allowsRollover.getRequired("allows_rollover") - - fun currency(): String = currency.getRequired("currency") - - @JsonProperty("allows_rollover") - @ExcludeMissing - fun _allowsRollover(): JsonField = allowsRollover - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties private var validated: Boolean = false - fun validate(): CreditAllocation = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } - allowsRollover() - currency() validated = true } @@ -2062,34 +1760,20 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [CreditAllocation]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { - private var allowsRollover: JsonField? = null - private var currency: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(creditAllocation: CreditAllocation) = apply { - allowsRollover = creditAllocation.allowsRollover - currency = creditAllocation.currency - additionalProperties = creditAllocation.additionalProperties.toMutableMap() - } - - fun allowsRollover(allowsRollover: Boolean) = - allowsRollover(JsonField.of(allowsRollover)) - - fun allowsRollover(allowsRollover: JsonField) = apply { - this.allowsRollover = allowsRollover + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -2112,12 +1796,7 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): CreditAllocation = - CreditAllocation( - checkRequired("allowsRollover", allowsRollover), - checkRequired("currency", currency), - additionalProperties.toImmutable(), - ) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -2125,25653 +1804,1015 @@ private constructor( return true } - return /* spotless:off */ other is CreditAllocation && allowsRollover == other.allowsRollover && currency == other.currency && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allowsRollover, currency, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode - override fun toString() = - "CreditAllocation{allowsRollover=$allowsRollover, currency=$currency, additionalProperties=$additionalProperties}" + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - private var validated: Boolean = false + companion object { - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } + @JvmField val UNIT = of("unit") - duration() - durationUnit() - validated = true + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() + /** An enum containing [ModelType]'s known values. */ + enum class Known { + UNIT } - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } + /** + * 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 additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + UNIT -> Value.UNIT + else -> Value._UNKNOWN } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + UNIT -> Known.UNIT + else -> throw OrbInvalidDataException("Unknown ModelType: $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) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - fun build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ } - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the 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() = value.hashCode() - companion object { + override fun toString() = value.toString() + } - @JvmField val DAY = of("day") + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { - @JvmField val MONTH = of("month") + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } + companion object { - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } + @JvmField val USAGE_PRICE = of("usage_price") - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + @JvmField val FIXED_PRICE = of("fixed_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) { - DAY -> Value.DAY - MONTH -> Value.MONTH - 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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + } + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + _UNKNOWN, + } - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN } - override fun hashCode() = value.hashCode() + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } - override fun toString() = value.toString() - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if 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 } - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } - @NoAutoDetect - class Item - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun name(): String = name.getRequired("name") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Item = apply { - if (validated) { - return@apply - } - - id() - name() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** A builder for [Item]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(item: Item) = apply { - id = item.id - name = item.name - additionalProperties = item.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun name(name: String) = name(JsonField.of(name)) + return /* spotless:off */ other is UnitPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && unitConfig == other.unitConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + } - fun name(name: JsonField) = apply { this.name = name } + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, unitConfig, dimensionalPriceConfiguration, additionalProperties) } + /* spotless:on */ - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + override fun hashCode(): Int = hashCode - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + override fun toString() = + "UnitPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, unitConfig=$unitConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } - fun 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 build(): Item = - Item( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Item && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Item{id=$id, name=$name, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Maximum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Maximum amount applied */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Maximum amount applied */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Maximum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - maximumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Maximum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = maximum.maximumAmount - additionalProperties = maximum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) + @NoAutoDetect + class PackagePrice + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + private val billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + private val creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("package_config") + @ExcludeMissing + private val packageConfig: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + private val dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } + fun id(): String = id.getRequired("id") - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } + fun billableMetric(): Optional = + Optional.ofNullable(billableMetric.getNullable("billable_metric")) - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) + fun billingCycleConfiguration(): BillingCycleConfigurationModel = + billingCycleConfiguration.getRequired("billing_cycle_configuration") - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } + fun cadence(): Cadence = cadence.getRequired("cadence") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun creditAllocation(): Optional = + Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun currency(): String = currency.getRequired("currency") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) - fun build(): Maximum = - Maximum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("maximumAmount", maximumAmount), - additionalProperties.toImmutable(), - ) - } + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - return /* spotless:off */ other is Maximum && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, maximumAmount, additionalProperties) } - /* spotless:on */ + fun item(): ItemSlimModel = item.getRequired("item") - override fun hashCode(): Int = hashCode + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) - override fun toString() = - "Maximum{appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, additionalProperties=$additionalProperties}" - } + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Minimum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Minimum amount applied */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Minimum amount applied */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Minimum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - minimumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Minimum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var minimumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } - minimumAmount = minimum.minimumAmount - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } + fun metadata(): Metadata = metadata.getRequired("metadata") - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } + fun modelType(): ModelType = modelType.getRequired("model_type") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun name(): String = name.getRequired("name") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun packageConfig(): PackageConfigModel = packageConfig.getRequired("package_config") - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun priceType(): PriceType = priceType.getRequired("price_type") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun dimensionalPriceConfiguration(): Optional = + Optional.ofNullable( + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + ) - fun build(): Minimum = - Minimum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("minimumAmount", minimumAmount), - additionalProperties.toImmutable(), - ) - } + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric - return /* spotless:off */ other is Minimum && appliesToPriceIds == other.appliesToPriceIds && minimumAmount == other.minimumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, minimumAmount, additionalProperties) } - /* spotless:on */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - override fun hashCode(): Int = hashCode + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - override fun toString() = - "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" - } + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - companion object { + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - @JvmField val UNIT = of("unit") + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - /** An enum containing [ModelType]'s known values. */ - enum class Known { - UNIT - } + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - /** - * 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, - } + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 - } + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to 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") - } + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + /** + * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - override fun hashCode() = value.hashCode() + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - override fun toString() = value.toString() - } + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - class PriceType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE_PRICE = of("usage_price") - - @JvmField val FIXED_PRICE = of("fixed_price") - - @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) - } - - /** An enum containing [PriceType]'s known values. */ - enum class Known { - USAGE_PRICE, - FIXED_PRICE, - } - - /** - * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [PriceType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_PRICE, - FIXED_PRICE, - /** - * An enum member indicating that [PriceType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_PRICE -> Value.USAGE_PRICE - FIXED_PRICE -> Value.FIXED_PRICE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE_PRICE -> Known.USAGE_PRICE - FIXED_PRICE -> Known.FIXED_PRICE - else -> throw OrbInvalidDataException("Unknown PriceType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class UnitConfig - @JsonCreator - private constructor( - @JsonProperty("unit_amount") - @ExcludeMissing - private val unitAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Rate per unit of usage */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** Rate per unit of usage */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): UnitConfig = apply { - if (validated) { - return@apply - } - - unitAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnitConfig]. */ - class Builder internal constructor() { - - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unitConfig: UnitConfig) = apply { - unitAmount = unitConfig.unitAmount - additionalProperties = unitConfig.additionalProperties.toMutableMap() - } - - /** Rate per unit of usage */ - fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - - /** Rate per unit of usage */ - 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 build(): UnitConfig = - UnitConfig( - checkRequired("unitAmount", unitAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UnitConfig && unitAmount == other.unitAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(unitAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnitConfig{unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class DimensionalPriceConfiguration - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - private val dimensionalPriceGroupId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun dimensionValues(): List = dimensionValues.getRequired("dimension_values") - - fun dimensionalPriceGroupId(): String = - dimensionalPriceGroupId.getRequired("dimensional_price_group_id") - - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - fun _dimensionalPriceGroupId(): JsonField = dimensionalPriceGroupId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): DimensionalPriceConfiguration = apply { - if (validated) { - return@apply - } - - dimensionValues() - dimensionalPriceGroupId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DimensionalPriceConfiguration]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var dimensionalPriceGroupId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(dimensionalPriceConfiguration: DimensionalPriceConfiguration) = - apply { - dimensionValues = - dimensionalPriceConfiguration.dimensionValues.map { it.toMutableList() } - dimensionalPriceGroupId = - dimensionalPriceConfiguration.dimensionalPriceGroupId - additionalProperties = - dimensionalPriceConfiguration.additionalProperties.toMutableMap() - } - - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: String) = - dimensionalPriceGroupId(JsonField.of(dimensionalPriceGroupId)) - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: JsonField) = apply { - this.dimensionalPriceGroupId = dimensionalPriceGroupId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): DimensionalPriceConfiguration = - DimensionalPriceConfiguration( - checkRequired("dimensionValues", dimensionValues).map { it.toImmutable() }, - checkRequired("dimensionalPriceGroupId", dimensionalPriceGroupId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DimensionalPriceConfiguration && dimensionValues == other.dimensionValues && dimensionalPriceGroupId == other.dimensionalPriceGroupId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, dimensionalPriceGroupId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DimensionalPriceConfiguration{dimensionValues=$dimensionValues, dimensionalPriceGroupId=$dimensionalPriceGroupId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UnitPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && unitConfig == other.unitConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, unitConfig, dimensionalPriceConfiguration, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnitPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, unitConfig=$unitConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PackagePrice - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric") - @ExcludeMissing - private val billableMetric: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("credit_allocation") - @ExcludeMissing - private val creditAllocation: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("discount") - @ExcludeMissing - private val discount: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("item") @ExcludeMissing private val item: JsonField = JsonMissing.of(), - @JsonProperty("maximum") - @ExcludeMissing - private val maximum: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("minimum") - @ExcludeMissing - private val minimum: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("package_config") - @ExcludeMissing - private val packageConfig: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("price_type") - @ExcludeMissing - private val priceType: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - private val dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun billableMetric(): Optional = - Optional.ofNullable(billableMetric.getNullable("billable_metric")) - - fun billingCycleConfiguration(): BillingCycleConfiguration = - billingCycleConfiguration.getRequired("billing_cycle_configuration") - - fun cadence(): Cadence = cadence.getRequired("cadence") - - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - fun creditAllocation(): Optional = - Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) - - fun currency(): String = currency.getRequired("currency") - - fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) - - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - fun item(): Item = item.getRequired("item") - - fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) - - fun maximumAmount(): Optional = - Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - fun metadata(): Metadata = metadata.getRequired("metadata") - - fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) - - fun minimumAmount(): Optional = - Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) - - fun modelType(): ModelType = modelType.getRequired("model_type") - - fun name(): String = name.getRequired("name") - - fun packageConfig(): PackageConfig = packageConfig.getRequired("package_config") - - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - fun priceType(): PriceType = priceType.getRequired("price_type") - - fun dimensionalPriceConfiguration(): Optional = - Optional.ofNullable( - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - ) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("billable_metric") - @ExcludeMissing - fun _billableMetric(): JsonField = billableMetric - - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - @JsonProperty("credit_allocation") - @ExcludeMissing - fun _creditAllocation(): JsonField = creditAllocation - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - - @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = 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`. - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("package_config") - @ExcludeMissing - fun _packageConfig(): JsonField = packageConfig + @JsonProperty("package_config") + @ExcludeMissing + fun _packageConfig(): JsonField = packageConfig @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - @JsonProperty("price_type") - @ExcludeMissing - fun _priceType(): JsonField = priceType - - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PackagePrice = apply { - if (validated) { - return@apply - } - - id() - billableMetric().ifPresent { it.validate() } - billingCycleConfiguration().validate() - cadence() - conversionRate() - 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() - name() - packageConfig().validate() - planPhaseOrder() - priceType() - dimensionalPriceConfiguration().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PackagePrice]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var billableMetric: JsonField? = null - private var billingCycleConfiguration: JsonField? = null - private var cadence: JsonField? = null - private var conversionRate: JsonField? = null - private var 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: JsonField? = null - private var name: JsonField? = null - private var packageConfig: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var priceType: JsonField? = null - private var dimensionalPriceConfiguration: JsonField = - JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(packagePrice: PackagePrice) = apply { - id = packagePrice.id - billableMetric = packagePrice.billableMetric - billingCycleConfiguration = packagePrice.billingCycleConfiguration - cadence = packagePrice.cadence - conversionRate = packagePrice.conversionRate - createdAt = packagePrice.createdAt - creditAllocation = packagePrice.creditAllocation - currency = packagePrice.currency - discount = packagePrice.discount - externalPriceId = packagePrice.externalPriceId - fixedPriceQuantity = packagePrice.fixedPriceQuantity - invoicingCycleConfiguration = packagePrice.invoicingCycleConfiguration - item = packagePrice.item - maximum = packagePrice.maximum - maximumAmount = packagePrice.maximumAmount - metadata = packagePrice.metadata - minimum = packagePrice.minimum - minimumAmount = packagePrice.minimumAmount - modelType = packagePrice.modelType - name = packagePrice.name - packageConfig = packagePrice.packageConfig - planPhaseOrder = packagePrice.planPhaseOrder - priceType = packagePrice.priceType - dimensionalPriceConfiguration = packagePrice.dimensionalPriceConfiguration - additionalProperties = packagePrice.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun billableMetric(billableMetric: BillableMetric?) = - billableMetric(JsonField.ofNullable(billableMetric)) - - fun billableMetric(billableMetric: Optional) = - billableMetric(billableMetric.orElse(null)) - - fun billableMetric(billableMetric: JsonField) = apply { - this.billableMetric = billableMetric - } - - fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = - billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) - - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) - - fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { - this.createdAt = createdAt - } - - fun creditAllocation(creditAllocation: CreditAllocation?) = - creditAllocation(JsonField.ofNullable(creditAllocation)) - - fun creditAllocation(creditAllocation: Optional) = - creditAllocation(creditAllocation.orElse(null)) - - fun creditAllocation(creditAllocation: JsonField) = apply { - this.creditAllocation = creditAllocation - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) - - fun discount(discount: Optional) = discount(discount.orElse(null)) - - fun discount(discount: JsonField) = apply { this.discount = discount } - - fun discount(percentage: PercentageDiscount) = - discount(Discount.ofPercentage(percentage)) - - fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) - - fun trialDiscount(appliesToPriceIds: List) = - discount( - TrialDiscount.builder() - .discountType(TrialDiscount.DiscountType.TRIAL) - .appliesToPriceIds(appliesToPriceIds) - .build() - ) - - fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) - - fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) - - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } - - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } - - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) - - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - fun item(item: Item) = item(JsonField.of(item)) - - fun item(item: JsonField) = apply { this.item = item } - - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) - - fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.orElse(null)) - - 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) - - fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) - - fun minimumAmount(minimumAmount: Optional) = - minimumAmount(minimumAmount.orElse(null)) - - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } - - fun name(name: String) = name(JsonField.of(name)) - - fun name(name: JsonField) = apply { this.name = name } - - fun packageConfig(packageConfig: PackageConfig) = - packageConfig(JsonField.of(packageConfig)) - - fun packageConfig(packageConfig: JsonField) = apply { - this.packageConfig = packageConfig - } - - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) - - fun priceType(priceType: JsonField) = apply { this.priceType = priceType } - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: DimensionalPriceConfiguration? - ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional - ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): PackagePrice = - PackagePrice( - checkRequired("id", id), - checkRequired("billableMetric", billableMetric), - checkRequired("billingCycleConfiguration", billingCycleConfiguration), - checkRequired("cadence", cadence), - checkRequired("conversionRate", conversionRate), - checkRequired("createdAt", createdAt), - checkRequired("creditAllocation", creditAllocation), - checkRequired("currency", currency), - checkRequired("discount", discount), - checkRequired("externalPriceId", externalPriceId), - checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), - checkRequired("item", item), - checkRequired("maximum", maximum), - checkRequired("maximumAmount", maximumAmount), - checkRequired("metadata", metadata), - checkRequired("minimum", minimum), - checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("packageConfig", packageConfig), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("priceType", priceType), - dimensionalPriceConfiguration, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BillableMetric - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillableMetric = apply { - if (validated) { - return@apply - } - - id() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillableMetric]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billableMetric: BillableMetric) = apply { - id = billableMetric.id - additionalProperties = billableMetric.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - 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) - } - - fun build(): BillableMetric = - BillableMetric(checkRequired("id", id), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillableMetric && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillableMetric{id=$id, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class CreditAllocation - @JsonCreator - private constructor( - @JsonProperty("allows_rollover") - @ExcludeMissing - private val allowsRollover: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun allowsRollover(): Boolean = allowsRollover.getRequired("allows_rollover") - - fun currency(): String = currency.getRequired("currency") - - @JsonProperty("allows_rollover") - @ExcludeMissing - fun _allowsRollover(): JsonField = allowsRollover - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditAllocation = apply { - if (validated) { - return@apply - } - - allowsRollover() - currency() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditAllocation]. */ - class Builder internal constructor() { - - private var allowsRollover: JsonField? = null - private var currency: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditAllocation: CreditAllocation) = apply { - allowsRollover = creditAllocation.allowsRollover - currency = creditAllocation.currency - additionalProperties = creditAllocation.additionalProperties.toMutableMap() - } - - fun allowsRollover(allowsRollover: Boolean) = - allowsRollover(JsonField.of(allowsRollover)) - - fun allowsRollover(allowsRollover: JsonField) = apply { - this.allowsRollover = allowsRollover - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditAllocation = - CreditAllocation( - checkRequired("allowsRollover", allowsRollover), - checkRequired("currency", currency), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditAllocation && allowsRollover == other.allowsRollover && currency == other.currency && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allowsRollover, currency, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditAllocation{allowsRollover=$allowsRollover, currency=$currency, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Item - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun name(): String = name.getRequired("name") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Item = apply { - if (validated) { - return@apply - } - - id() - name() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Item]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(item: Item) = apply { - id = item.id - name = item.name - additionalProperties = item.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun name(name: String) = name(JsonField.of(name)) - - 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) - } - - fun build(): Item = - Item( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Item && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Item{id=$id, name=$name, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Maximum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Maximum amount applied */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Maximum amount applied */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Maximum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - maximumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Maximum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = maximum.maximumAmount - additionalProperties = maximum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Maximum = - Maximum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("maximumAmount", maximumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Maximum && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, maximumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Maximum{appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Minimum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Minimum amount applied */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Minimum amount applied */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Minimum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - minimumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Minimum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var minimumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } - minimumAmount = minimum.minimumAmount - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Minimum = - Minimum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("minimumAmount", minimumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Minimum && appliesToPriceIds == other.appliesToPriceIds && minimumAmount == other.minimumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, minimumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val PACKAGE = of("package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - PACKAGE - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PACKAGE, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PACKAGE -> Value.PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PACKAGE -> Known.PACKAGE - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class PackageConfig - @JsonCreator - private constructor( - @JsonProperty("package_amount") - @ExcludeMissing - private val packageAmount: JsonField = JsonMissing.of(), - @JsonProperty("package_size") - @ExcludeMissing - private val packageSize: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** A currency amount to rate usage by */ - fun packageAmount(): String = packageAmount.getRequired("package_amount") - - /** - * An integer amount to represent package size. For example, 1000 here would divide - * usage by 1000 before multiplying by package_amount in rating - */ - fun packageSize(): Long = packageSize.getRequired("package_size") - - /** A currency amount to rate usage by */ - @JsonProperty("package_amount") - @ExcludeMissing - fun _packageAmount(): JsonField = packageAmount - - /** - * An integer amount to represent package size. For example, 1000 here would divide - * usage by 1000 before multiplying by package_amount in rating - */ - @JsonProperty("package_size") - @ExcludeMissing - fun _packageSize(): JsonField = packageSize - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PackageConfig = apply { - if (validated) { - return@apply - } - - packageAmount() - packageSize() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PackageConfig]. */ - class Builder internal constructor() { - - private var packageAmount: JsonField? = null - private var packageSize: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(packageConfig: PackageConfig) = apply { - packageAmount = packageConfig.packageAmount - packageSize = packageConfig.packageSize - additionalProperties = packageConfig.additionalProperties.toMutableMap() - } - - /** A currency amount to rate usage by */ - fun packageAmount(packageAmount: String) = - packageAmount(JsonField.of(packageAmount)) - - /** A currency amount to rate usage by */ - fun packageAmount(packageAmount: JsonField) = apply { - this.packageAmount = packageAmount - } - - /** - * An integer amount to represent package size. For example, 1000 here would divide - * usage by 1000 before multiplying by package_amount in rating - */ - fun packageSize(packageSize: Long) = packageSize(JsonField.of(packageSize)) - - /** - * An integer amount to represent package size. For example, 1000 here would divide - * usage by 1000 before multiplying by package_amount in rating - */ - fun packageSize(packageSize: JsonField) = apply { - this.packageSize = packageSize - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PackageConfig = - PackageConfig( - checkRequired("packageAmount", packageAmount), - checkRequired("packageSize", packageSize), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PackageConfig && packageAmount == other.packageAmount && packageSize == other.packageSize && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(packageAmount, packageSize, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PackageConfig{packageAmount=$packageAmount, packageSize=$packageSize, 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") - - @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) - } - - /** An enum containing [PriceType]'s known values. */ - enum class Known { - USAGE_PRICE, - FIXED_PRICE, - } - - /** - * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [PriceType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_PRICE, - FIXED_PRICE, - /** - * An enum member indicating that [PriceType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_PRICE -> Value.USAGE_PRICE - FIXED_PRICE -> Value.FIXED_PRICE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE_PRICE -> Known.USAGE_PRICE - FIXED_PRICE -> Known.FIXED_PRICE - else -> throw OrbInvalidDataException("Unknown PriceType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class DimensionalPriceConfiguration - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - private val dimensionalPriceGroupId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun dimensionValues(): List = dimensionValues.getRequired("dimension_values") - - fun dimensionalPriceGroupId(): String = - dimensionalPriceGroupId.getRequired("dimensional_price_group_id") - - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - fun _dimensionalPriceGroupId(): JsonField = dimensionalPriceGroupId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): DimensionalPriceConfiguration = apply { - if (validated) { - return@apply - } - - dimensionValues() - dimensionalPriceGroupId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DimensionalPriceConfiguration]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var dimensionalPriceGroupId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(dimensionalPriceConfiguration: DimensionalPriceConfiguration) = - apply { - dimensionValues = - dimensionalPriceConfiguration.dimensionValues.map { it.toMutableList() } - dimensionalPriceGroupId = - dimensionalPriceConfiguration.dimensionalPriceGroupId - additionalProperties = - dimensionalPriceConfiguration.additionalProperties.toMutableMap() - } - - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: String) = - dimensionalPriceGroupId(JsonField.of(dimensionalPriceGroupId)) - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: JsonField) = apply { - this.dimensionalPriceGroupId = dimensionalPriceGroupId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): DimensionalPriceConfiguration = - DimensionalPriceConfiguration( - checkRequired("dimensionValues", dimensionValues).map { it.toImmutable() }, - checkRequired("dimensionalPriceGroupId", dimensionalPriceGroupId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DimensionalPriceConfiguration && dimensionValues == other.dimensionValues && dimensionalPriceGroupId == other.dimensionalPriceGroupId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, dimensionalPriceGroupId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DimensionalPriceConfiguration{dimensionValues=$dimensionValues, dimensionalPriceGroupId=$dimensionalPriceGroupId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PackagePrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && packageConfig == other.packageConfig && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, packageConfig, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PackagePrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, packageConfig=$packageConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class MatrixPrice - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric") - @ExcludeMissing - private val billableMetric: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("credit_allocation") - @ExcludeMissing - private val creditAllocation: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("discount") - @ExcludeMissing - private val discount: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("item") @ExcludeMissing private val item: JsonField = JsonMissing.of(), - @JsonProperty("matrix_config") - @ExcludeMissing - private val matrixConfig: JsonField = JsonMissing.of(), - @JsonProperty("maximum") - @ExcludeMissing - private val maximum: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("minimum") - @ExcludeMissing - private val minimum: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("price_type") - @ExcludeMissing - private val priceType: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - private val dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun billableMetric(): Optional = - Optional.ofNullable(billableMetric.getNullable("billable_metric")) - - fun billingCycleConfiguration(): BillingCycleConfiguration = - billingCycleConfiguration.getRequired("billing_cycle_configuration") - - fun cadence(): Cadence = cadence.getRequired("cadence") - - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - fun creditAllocation(): Optional = - Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) - - fun currency(): String = currency.getRequired("currency") - - fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) - - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - fun item(): Item = item.getRequired("item") - - fun matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_config") - - fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) - - fun maximumAmount(): Optional = - Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - fun metadata(): Metadata = metadata.getRequired("metadata") - - fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) - - fun minimumAmount(): Optional = - Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) - - fun modelType(): ModelType = modelType.getRequired("model_type") - - fun name(): String = name.getRequired("name") - - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - fun priceType(): PriceType = priceType.getRequired("price_type") - - fun dimensionalPriceConfiguration(): Optional = - Optional.ofNullable( - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - ) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("billable_metric") - @ExcludeMissing - fun _billableMetric(): JsonField = billableMetric - - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - @JsonProperty("credit_allocation") - @ExcludeMissing - fun _creditAllocation(): JsonField = creditAllocation - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - - @JsonProperty("matrix_config") - @ExcludeMissing - fun _matrixConfig(): JsonField = matrixConfig - - @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = 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`. - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - @JsonProperty("price_type") - @ExcludeMissing - fun _priceType(): JsonField = priceType - - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MatrixPrice = apply { - if (validated) { - return@apply - } - - id() - billableMetric().ifPresent { it.validate() } - billingCycleConfiguration().validate() - cadence() - conversionRate() - createdAt() - creditAllocation().ifPresent { it.validate() } - currency() - discount().ifPresent { it.validate() } - externalPriceId() - fixedPriceQuantity() - invoicingCycleConfiguration().ifPresent { it.validate() } - item().validate() - matrixConfig().validate() - maximum().ifPresent { it.validate() } - maximumAmount() - metadata().validate() - minimum().ifPresent { it.validate() } - minimumAmount() - modelType() - name() - planPhaseOrder() - priceType() - dimensionalPriceConfiguration().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MatrixPrice]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var billableMetric: JsonField? = null - private var billingCycleConfiguration: JsonField? = null - private var cadence: JsonField? = null - private var conversionRate: JsonField? = null - private var 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 matrixConfig: JsonField? = null - private var maximum: JsonField? = null - private var maximumAmount: JsonField? = null - private var metadata: JsonField? = null - private var minimum: JsonField? = null - private var minimumAmount: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var priceType: JsonField? = null - private var dimensionalPriceConfiguration: JsonField = - JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(matrixPrice: MatrixPrice) = apply { - id = matrixPrice.id - billableMetric = matrixPrice.billableMetric - billingCycleConfiguration = matrixPrice.billingCycleConfiguration - cadence = matrixPrice.cadence - conversionRate = matrixPrice.conversionRate - createdAt = matrixPrice.createdAt - creditAllocation = matrixPrice.creditAllocation - currency = matrixPrice.currency - discount = matrixPrice.discount - externalPriceId = matrixPrice.externalPriceId - fixedPriceQuantity = matrixPrice.fixedPriceQuantity - invoicingCycleConfiguration = matrixPrice.invoicingCycleConfiguration - item = matrixPrice.item - matrixConfig = matrixPrice.matrixConfig - maximum = matrixPrice.maximum - maximumAmount = matrixPrice.maximumAmount - metadata = matrixPrice.metadata - minimum = matrixPrice.minimum - minimumAmount = matrixPrice.minimumAmount - modelType = matrixPrice.modelType - name = matrixPrice.name - planPhaseOrder = matrixPrice.planPhaseOrder - priceType = matrixPrice.priceType - dimensionalPriceConfiguration = matrixPrice.dimensionalPriceConfiguration - additionalProperties = matrixPrice.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun billableMetric(billableMetric: BillableMetric?) = - billableMetric(JsonField.ofNullable(billableMetric)) - - fun billableMetric(billableMetric: Optional) = - billableMetric(billableMetric.orElse(null)) - - fun billableMetric(billableMetric: JsonField) = apply { - this.billableMetric = billableMetric - } - - fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = - billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) - - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) - - fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { - this.createdAt = createdAt - } - - fun creditAllocation(creditAllocation: CreditAllocation?) = - creditAllocation(JsonField.ofNullable(creditAllocation)) - - fun creditAllocation(creditAllocation: Optional) = - creditAllocation(creditAllocation.orElse(null)) - - fun creditAllocation(creditAllocation: JsonField) = apply { - this.creditAllocation = creditAllocation - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) - - fun discount(discount: Optional) = discount(discount.orElse(null)) - - fun discount(discount: JsonField) = apply { this.discount = discount } - - fun discount(percentage: PercentageDiscount) = - discount(Discount.ofPercentage(percentage)) - - fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) - - fun trialDiscount(appliesToPriceIds: List) = - discount( - TrialDiscount.builder() - .discountType(TrialDiscount.DiscountType.TRIAL) - .appliesToPriceIds(appliesToPriceIds) - .build() - ) - - fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) - - fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) - - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } - - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } - - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) - - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - fun item(item: Item) = item(JsonField.of(item)) - - fun item(item: JsonField) = apply { this.item = item } - - fun matrixConfig(matrixConfig: MatrixConfig) = matrixConfig(JsonField.of(matrixConfig)) - - fun matrixConfig(matrixConfig: JsonField) = apply { - this.matrixConfig = matrixConfig - } - - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) - - fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.orElse(null)) - - 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) - - fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) - - fun minimumAmount(minimumAmount: Optional) = - minimumAmount(minimumAmount.orElse(null)) - - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } - - fun name(name: String) = name(JsonField.of(name)) - - fun name(name: JsonField) = apply { this.name = name } - - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) - - fun priceType(priceType: JsonField) = apply { this.priceType = priceType } - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: DimensionalPriceConfiguration? - ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional - ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): MatrixPrice = - MatrixPrice( - checkRequired("id", id), - checkRequired("billableMetric", billableMetric), - checkRequired("billingCycleConfiguration", billingCycleConfiguration), - checkRequired("cadence", cadence), - checkRequired("conversionRate", conversionRate), - 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("matrixConfig", matrixConfig), - checkRequired("maximum", maximum), - checkRequired("maximumAmount", maximumAmount), - checkRequired("metadata", metadata), - checkRequired("minimum", minimum), - checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("priceType", priceType), - dimensionalPriceConfiguration, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BillableMetric - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillableMetric = apply { - if (validated) { - return@apply - } - - id() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillableMetric]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billableMetric: BillableMetric) = apply { - id = billableMetric.id - additionalProperties = billableMetric.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - 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) - } - - fun build(): BillableMetric = - BillableMetric(checkRequired("id", id), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillableMetric && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillableMetric{id=$id, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class CreditAllocation - @JsonCreator - private constructor( - @JsonProperty("allows_rollover") - @ExcludeMissing - private val allowsRollover: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun allowsRollover(): Boolean = allowsRollover.getRequired("allows_rollover") - - fun currency(): String = currency.getRequired("currency") - - @JsonProperty("allows_rollover") - @ExcludeMissing - fun _allowsRollover(): JsonField = allowsRollover - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditAllocation = apply { - if (validated) { - return@apply - } - - allowsRollover() - currency() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditAllocation]. */ - class Builder internal constructor() { - - private var allowsRollover: JsonField? = null - private var currency: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditAllocation: CreditAllocation) = apply { - allowsRollover = creditAllocation.allowsRollover - currency = creditAllocation.currency - additionalProperties = creditAllocation.additionalProperties.toMutableMap() - } - - fun allowsRollover(allowsRollover: Boolean) = - allowsRollover(JsonField.of(allowsRollover)) - - fun allowsRollover(allowsRollover: JsonField) = apply { - this.allowsRollover = allowsRollover - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditAllocation = - CreditAllocation( - checkRequired("allowsRollover", allowsRollover), - checkRequired("currency", currency), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditAllocation && allowsRollover == other.allowsRollover && currency == other.currency && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allowsRollover, currency, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditAllocation{allowsRollover=$allowsRollover, currency=$currency, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Item - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun name(): String = name.getRequired("name") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Item = apply { - if (validated) { - return@apply - } - - id() - name() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Item]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(item: Item) = apply { - id = item.id - name = item.name - additionalProperties = item.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun name(name: String) = name(JsonField.of(name)) - - 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) - } - - fun build(): Item = - Item( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Item && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Item{id=$id, name=$name, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class MatrixConfig - @JsonCreator - private constructor( - @JsonProperty("default_unit_amount") - @ExcludeMissing - private val defaultUnitAmount: JsonField = JsonMissing.of(), - @JsonProperty("dimensions") - @ExcludeMissing - private val dimensions: JsonField> = JsonMissing.of(), - @JsonProperty("matrix_values") - @ExcludeMissing - private val matrixValues: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Default per unit rate for any usage not bucketed into a specified matrix_value */ - fun defaultUnitAmount(): String = defaultUnitAmount.getRequired("default_unit_amount") - - /** One or two event property values to evaluate matrix groups by */ - fun dimensions(): List = dimensions.getRequired("dimensions") - - /** Matrix values for specified matrix grouping keys */ - fun matrixValues(): List = matrixValues.getRequired("matrix_values") - - /** Default per unit rate for any usage not bucketed into a specified matrix_value */ - @JsonProperty("default_unit_amount") - @ExcludeMissing - fun _defaultUnitAmount(): JsonField = defaultUnitAmount - - /** One or two event property values to evaluate matrix groups by */ - @JsonProperty("dimensions") - @ExcludeMissing - fun _dimensions(): JsonField> = dimensions - - /** Matrix values for specified matrix grouping keys */ - @JsonProperty("matrix_values") - @ExcludeMissing - fun _matrixValues(): JsonField> = matrixValues - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MatrixConfig = apply { - if (validated) { - return@apply - } - - defaultUnitAmount() - dimensions() - matrixValues().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MatrixConfig]. */ - class Builder internal constructor() { - - private var defaultUnitAmount: JsonField? = null - private var dimensions: JsonField>? = null - private var matrixValues: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(matrixConfig: MatrixConfig) = apply { - defaultUnitAmount = matrixConfig.defaultUnitAmount - dimensions = matrixConfig.dimensions.map { it.toMutableList() } - matrixValues = matrixConfig.matrixValues.map { it.toMutableList() } - additionalProperties = matrixConfig.additionalProperties.toMutableMap() - } - - /** - * Default per unit rate for any usage not bucketed into a specified matrix_value - */ - fun defaultUnitAmount(defaultUnitAmount: String) = - defaultUnitAmount(JsonField.of(defaultUnitAmount)) - - /** - * Default per unit rate for any usage not bucketed into a specified matrix_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)) - - /** One or two event property values to evaluate matrix groups by */ - fun dimensions(dimensions: JsonField>) = apply { - this.dimensions = dimensions.map { it.toMutableList() } - } - - /** One or two event property values to evaluate matrix groups by */ - fun addDimension(dimension: String) = apply { - dimensions = - (dimensions ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimension) - } - } - - /** Matrix values for specified matrix grouping keys */ - fun matrixValues(matrixValues: List) = - matrixValues(JsonField.of(matrixValues)) - - /** Matrix values for specified matrix grouping keys */ - fun matrixValues(matrixValues: JsonField>) = apply { - this.matrixValues = matrixValues.map { it.toMutableList() } - } - - /** Matrix values for specified matrix grouping keys */ - fun addMatrixValue(matrixValue: MatrixValue) = apply { - matrixValues = - (matrixValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): MatrixConfig = - MatrixConfig( - checkRequired("defaultUnitAmount", defaultUnitAmount), - checkRequired("dimensions", dimensions).map { it.toImmutable() }, - checkRequired("matrixValues", matrixValues).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class MatrixValue - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - private val unitAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * One or two matrix keys to filter usage to this Matrix value by. For example, - * ["region", "tier"] could be used to filter cloud usage by a cloud region and an - * instance tier. - */ - fun dimensionValues(): List = - dimensionValues.getRequired("dimension_values") - - /** Unit price for the specified dimension_values */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** - * One or two matrix keys to filter usage to this Matrix value by. For example, - * ["region", "tier"] could be used to filter cloud usage by a cloud region and an - * instance tier. - */ - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - /** Unit price for the specified dimension_values */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MatrixValue = apply { - if (validated) { - return@apply - } - - dimensionValues() - unitAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MatrixValue]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(matrixValue: MatrixValue) = apply { - dimensionValues = matrixValue.dimensionValues.map { it.toMutableList() } - unitAmount = matrixValue.unitAmount - additionalProperties = matrixValue.additionalProperties.toMutableMap() - } - - /** - * One or two matrix keys to filter usage to this Matrix value by. For example, - * ["region", "tier"] could be used to filter cloud usage by a cloud region and - * an instance tier. - */ - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - /** - * One or two matrix keys to filter usage to this Matrix value by. For example, - * ["region", "tier"] could be used to filter cloud usage by a cloud region and - * an instance tier. - */ - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - /** - * One or two matrix keys to filter usage to this Matrix value by. For example, - * ["region", "tier"] could be used to filter cloud usage by a cloud region and - * an instance tier. - */ - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - /** Unit price for the specified dimension_values */ - fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - - /** Unit price for the specified dimension_values */ - 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 build(): MatrixValue = - MatrixValue( - checkRequired("dimensionValues", dimensionValues).map { - it.toImmutable() - }, - checkRequired("unitAmount", unitAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MatrixValue && dimensionValues == other.dimensionValues && unitAmount == other.unitAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, unitAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MatrixValue{dimensionValues=$dimensionValues, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MatrixConfig && defaultUnitAmount == other.defaultUnitAmount && dimensions == other.dimensions && matrixValues == other.matrixValues && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(defaultUnitAmount, dimensions, matrixValues, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MatrixConfig{defaultUnitAmount=$defaultUnitAmount, dimensions=$dimensions, matrixValues=$matrixValues, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Maximum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Maximum amount applied */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Maximum amount applied */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Maximum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - maximumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Maximum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = maximum.maximumAmount - additionalProperties = maximum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Maximum = - Maximum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("maximumAmount", maximumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Maximum && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, maximumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Maximum{appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Minimum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Minimum amount applied */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Minimum amount applied */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Minimum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - minimumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Minimum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var minimumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } - minimumAmount = minimum.minimumAmount - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Minimum = - Minimum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("minimumAmount", minimumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Minimum && appliesToPriceIds == other.appliesToPriceIds && minimumAmount == other.minimumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, minimumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val MATRIX = of("matrix") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MATRIX - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MATRIX, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MATRIX -> Value.MATRIX - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - MATRIX -> Known.MATRIX - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class PriceType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE_PRICE = of("usage_price") - - @JvmField val FIXED_PRICE = of("fixed_price") - - @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) - } - - /** An enum containing [PriceType]'s known values. */ - enum class Known { - USAGE_PRICE, - FIXED_PRICE, - } - - /** - * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [PriceType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_PRICE, - FIXED_PRICE, - /** - * An enum member indicating that [PriceType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_PRICE -> Value.USAGE_PRICE - FIXED_PRICE -> Value.FIXED_PRICE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE_PRICE -> Known.USAGE_PRICE - FIXED_PRICE -> Known.FIXED_PRICE - else -> throw OrbInvalidDataException("Unknown PriceType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class DimensionalPriceConfiguration - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - private val dimensionalPriceGroupId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun dimensionValues(): List = dimensionValues.getRequired("dimension_values") - - fun dimensionalPriceGroupId(): String = - dimensionalPriceGroupId.getRequired("dimensional_price_group_id") - - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - fun _dimensionalPriceGroupId(): JsonField = dimensionalPriceGroupId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): DimensionalPriceConfiguration = apply { - if (validated) { - return@apply - } - - dimensionValues() - dimensionalPriceGroupId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DimensionalPriceConfiguration]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var dimensionalPriceGroupId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(dimensionalPriceConfiguration: DimensionalPriceConfiguration) = - apply { - dimensionValues = - dimensionalPriceConfiguration.dimensionValues.map { it.toMutableList() } - dimensionalPriceGroupId = - dimensionalPriceConfiguration.dimensionalPriceGroupId - additionalProperties = - dimensionalPriceConfiguration.additionalProperties.toMutableMap() - } - - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: String) = - dimensionalPriceGroupId(JsonField.of(dimensionalPriceGroupId)) - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: JsonField) = apply { - this.dimensionalPriceGroupId = dimensionalPriceGroupId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): DimensionalPriceConfiguration = - DimensionalPriceConfiguration( - checkRequired("dimensionValues", dimensionValues).map { it.toImmutable() }, - checkRequired("dimensionalPriceGroupId", dimensionalPriceGroupId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DimensionalPriceConfiguration && dimensionValues == other.dimensionValues && dimensionalPriceGroupId == other.dimensionalPriceGroupId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, dimensionalPriceGroupId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DimensionalPriceConfiguration{dimensionValues=$dimensionValues, dimensionalPriceGroupId=$dimensionalPriceGroupId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MatrixPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && matrixConfig == other.matrixConfig && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, matrixConfig, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MatrixPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixConfig=$matrixConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class TieredPrice - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric") - @ExcludeMissing - private val billableMetric: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("credit_allocation") - @ExcludeMissing - private val creditAllocation: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("discount") - @ExcludeMissing - private val discount: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("item") @ExcludeMissing private val item: JsonField = JsonMissing.of(), - @JsonProperty("maximum") - @ExcludeMissing - private val maximum: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("minimum") - @ExcludeMissing - private val minimum: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("price_type") - @ExcludeMissing - private val priceType: JsonField = JsonMissing.of(), - @JsonProperty("tiered_config") - @ExcludeMissing - private val tieredConfig: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - private val dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun billableMetric(): Optional = - Optional.ofNullable(billableMetric.getNullable("billable_metric")) - - fun billingCycleConfiguration(): BillingCycleConfiguration = - billingCycleConfiguration.getRequired("billing_cycle_configuration") - - fun cadence(): Cadence = cadence.getRequired("cadence") - - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - fun creditAllocation(): Optional = - Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) - - fun currency(): String = currency.getRequired("currency") - - fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) - - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - fun item(): Item = item.getRequired("item") - - fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) - - fun maximumAmount(): Optional = - Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - fun metadata(): Metadata = metadata.getRequired("metadata") - - fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) - - fun minimumAmount(): Optional = - Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) - - fun modelType(): ModelType = modelType.getRequired("model_type") - - fun name(): String = name.getRequired("name") - - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - fun priceType(): PriceType = priceType.getRequired("price_type") - - fun tieredConfig(): TieredConfig = tieredConfig.getRequired("tiered_config") - - fun dimensionalPriceConfiguration(): Optional = - Optional.ofNullable( - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - ) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("billable_metric") - @ExcludeMissing - fun _billableMetric(): JsonField = billableMetric - - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - @JsonProperty("credit_allocation") - @ExcludeMissing - fun _creditAllocation(): JsonField = creditAllocation - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - - @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = 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`. - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - @JsonProperty("price_type") - @ExcludeMissing - fun _priceType(): JsonField = priceType - - @JsonProperty("tiered_config") - @ExcludeMissing - fun _tieredConfig(): JsonField = tieredConfig - - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredPrice = apply { - if (validated) { - return@apply - } - - id() - billableMetric().ifPresent { it.validate() } - billingCycleConfiguration().validate() - cadence() - conversionRate() - 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() - name() - planPhaseOrder() - priceType() - tieredConfig().validate() - dimensionalPriceConfiguration().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredPrice]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var billableMetric: JsonField? = null - private var billingCycleConfiguration: JsonField? = null - private var cadence: JsonField? = null - private var conversionRate: JsonField? = null - private var 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: JsonField? = null - private var name: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var priceType: JsonField? = null - private var tieredConfig: JsonField? = null - private var dimensionalPriceConfiguration: JsonField = - JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tieredPrice: TieredPrice) = apply { - id = tieredPrice.id - billableMetric = tieredPrice.billableMetric - billingCycleConfiguration = tieredPrice.billingCycleConfiguration - cadence = tieredPrice.cadence - conversionRate = tieredPrice.conversionRate - createdAt = tieredPrice.createdAt - creditAllocation = tieredPrice.creditAllocation - currency = tieredPrice.currency - discount = tieredPrice.discount - externalPriceId = tieredPrice.externalPriceId - fixedPriceQuantity = tieredPrice.fixedPriceQuantity - invoicingCycleConfiguration = tieredPrice.invoicingCycleConfiguration - item = tieredPrice.item - maximum = tieredPrice.maximum - maximumAmount = tieredPrice.maximumAmount - metadata = tieredPrice.metadata - minimum = tieredPrice.minimum - minimumAmount = tieredPrice.minimumAmount - modelType = tieredPrice.modelType - name = tieredPrice.name - planPhaseOrder = tieredPrice.planPhaseOrder - priceType = tieredPrice.priceType - tieredConfig = tieredPrice.tieredConfig - dimensionalPriceConfiguration = tieredPrice.dimensionalPriceConfiguration - additionalProperties = tieredPrice.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun billableMetric(billableMetric: BillableMetric?) = - billableMetric(JsonField.ofNullable(billableMetric)) - - fun billableMetric(billableMetric: Optional) = - billableMetric(billableMetric.orElse(null)) - - fun billableMetric(billableMetric: JsonField) = apply { - this.billableMetric = billableMetric - } - - fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = - billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) - - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) - - fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { - this.createdAt = createdAt - } - - fun creditAllocation(creditAllocation: CreditAllocation?) = - creditAllocation(JsonField.ofNullable(creditAllocation)) - - fun creditAllocation(creditAllocation: Optional) = - creditAllocation(creditAllocation.orElse(null)) - - fun creditAllocation(creditAllocation: JsonField) = apply { - this.creditAllocation = creditAllocation - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) - - fun discount(discount: Optional) = discount(discount.orElse(null)) - - fun discount(discount: JsonField) = apply { this.discount = discount } - - fun discount(percentage: PercentageDiscount) = - discount(Discount.ofPercentage(percentage)) - - fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) - - fun trialDiscount(appliesToPriceIds: List) = - discount( - TrialDiscount.builder() - .discountType(TrialDiscount.DiscountType.TRIAL) - .appliesToPriceIds(appliesToPriceIds) - .build() - ) - - fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) - - fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) - - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } - - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } - - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) - - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - fun item(item: Item) = item(JsonField.of(item)) - - fun item(item: JsonField) = apply { this.item = item } - - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) - - fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.orElse(null)) - - 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) - - fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) - - fun minimumAmount(minimumAmount: Optional) = - minimumAmount(minimumAmount.orElse(null)) - - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } - - fun name(name: String) = name(JsonField.of(name)) - - fun name(name: JsonField) = apply { this.name = name } - - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) - - fun priceType(priceType: JsonField) = apply { this.priceType = priceType } - - fun tieredConfig(tieredConfig: TieredConfig) = tieredConfig(JsonField.of(tieredConfig)) - - fun tieredConfig(tieredConfig: JsonField) = apply { - this.tieredConfig = tieredConfig - } - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: DimensionalPriceConfiguration? - ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional - ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): TieredPrice = - TieredPrice( - checkRequired("id", id), - checkRequired("billableMetric", billableMetric), - checkRequired("billingCycleConfiguration", billingCycleConfiguration), - checkRequired("cadence", cadence), - checkRequired("conversionRate", conversionRate), - checkRequired("createdAt", createdAt), - checkRequired("creditAllocation", creditAllocation), - checkRequired("currency", currency), - checkRequired("discount", discount), - checkRequired("externalPriceId", externalPriceId), - checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), - checkRequired("item", item), - checkRequired("maximum", maximum), - checkRequired("maximumAmount", maximumAmount), - checkRequired("metadata", metadata), - checkRequired("minimum", minimum), - checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("priceType", priceType), - checkRequired("tieredConfig", tieredConfig), - dimensionalPriceConfiguration, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BillableMetric - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillableMetric = apply { - if (validated) { - return@apply - } - - id() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillableMetric]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billableMetric: BillableMetric) = apply { - id = billableMetric.id - additionalProperties = billableMetric.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - 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) - } - - fun build(): BillableMetric = - BillableMetric(checkRequired("id", id), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillableMetric && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillableMetric{id=$id, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class CreditAllocation - @JsonCreator - private constructor( - @JsonProperty("allows_rollover") - @ExcludeMissing - private val allowsRollover: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun allowsRollover(): Boolean = allowsRollover.getRequired("allows_rollover") - - fun currency(): String = currency.getRequired("currency") - - @JsonProperty("allows_rollover") - @ExcludeMissing - fun _allowsRollover(): JsonField = allowsRollover - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditAllocation = apply { - if (validated) { - return@apply - } - - allowsRollover() - currency() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditAllocation]. */ - class Builder internal constructor() { - - private var allowsRollover: JsonField? = null - private var currency: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditAllocation: CreditAllocation) = apply { - allowsRollover = creditAllocation.allowsRollover - currency = creditAllocation.currency - additionalProperties = creditAllocation.additionalProperties.toMutableMap() - } - - fun allowsRollover(allowsRollover: Boolean) = - allowsRollover(JsonField.of(allowsRollover)) - - fun allowsRollover(allowsRollover: JsonField) = apply { - this.allowsRollover = allowsRollover - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditAllocation = - CreditAllocation( - checkRequired("allowsRollover", allowsRollover), - checkRequired("currency", currency), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditAllocation && allowsRollover == other.allowsRollover && currency == other.currency && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allowsRollover, currency, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditAllocation{allowsRollover=$allowsRollover, currency=$currency, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Item - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun name(): String = name.getRequired("name") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Item = apply { - if (validated) { - return@apply - } - - id() - name() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Item]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(item: Item) = apply { - id = item.id - name = item.name - additionalProperties = item.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun name(name: String) = name(JsonField.of(name)) - - 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) - } - - fun build(): Item = - Item( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Item && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Item{id=$id, name=$name, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Maximum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Maximum amount applied */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Maximum amount applied */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Maximum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - maximumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Maximum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = maximum.maximumAmount - additionalProperties = maximum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Maximum = - Maximum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("maximumAmount", maximumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Maximum && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, maximumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Maximum{appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Minimum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Minimum amount applied */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Minimum amount applied */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Minimum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - minimumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Minimum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var minimumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } - minimumAmount = minimum.minimumAmount - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Minimum = - Minimum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("minimumAmount", minimumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Minimum && appliesToPriceIds == other.appliesToPriceIds && minimumAmount == other.minimumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, minimumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED = of("tiered") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED -> Value.TIERED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - TIERED -> Known.TIERED - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class PriceType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE_PRICE = of("usage_price") - - @JvmField val FIXED_PRICE = of("fixed_price") - - @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) - } - - /** An enum containing [PriceType]'s known values. */ - enum class Known { - USAGE_PRICE, - FIXED_PRICE, - } - - /** - * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [PriceType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_PRICE, - FIXED_PRICE, - /** - * An enum member indicating that [PriceType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_PRICE -> Value.USAGE_PRICE - FIXED_PRICE -> Value.FIXED_PRICE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE_PRICE -> Known.USAGE_PRICE - FIXED_PRICE -> Known.FIXED_PRICE - else -> throw OrbInvalidDataException("Unknown PriceType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TieredConfig - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - private val tiers: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Tiers for rating based on total usage quantities into the specified tier */ - fun tiers(): List = tiers.getRequired("tiers") - - /** Tiers for rating based on total usage quantities into the specified tier */ - @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredConfig = apply { - if (validated) { - return@apply - } - - tiers().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tieredConfig: TieredConfig) = apply { - tiers = tieredConfig.tiers.map { it.toMutableList() } - additionalProperties = tieredConfig.additionalProperties.toMutableMap() - } - - /** Tiers for rating based on total usage quantities into the specified tier */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - - /** Tiers for rating based on total usage quantities into the specified tier */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** Tiers for rating based on total usage quantities into the specified tier */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): TieredConfig = - TieredConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Tier - @JsonCreator - private constructor( - @JsonProperty("first_unit") - @ExcludeMissing - private val firstUnit: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - private val unitAmount: JsonField = JsonMissing.of(), - @JsonProperty("last_unit") - @ExcludeMissing - private val lastUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Inclusive tier starting value */ - fun firstUnit(): Double = firstUnit.getRequired("first_unit") - - /** Amount per unit */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** Exclusive tier ending value. If null, this is treated as the last tier */ - fun lastUnit(): Optional = - Optional.ofNullable(lastUnit.getNullable("last_unit")) - - /** Inclusive tier starting value */ - @JsonProperty("first_unit") - @ExcludeMissing - fun _firstUnit(): JsonField = firstUnit - - /** Amount per unit */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - /** Exclusive tier ending value. If null, this is treated as the last tier */ - @JsonProperty("last_unit") - @ExcludeMissing - fun _lastUnit(): JsonField = lastUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - firstUnit() - unitAmount() - lastUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var firstUnit: JsonField? = null - private var unitAmount: JsonField? = null - private var lastUnit: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - firstUnit = tier.firstUnit - unitAmount = tier.unitAmount - lastUnit = tier.lastUnit - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Inclusive tier starting value */ - fun firstUnit(firstUnit: Double) = firstUnit(JsonField.of(firstUnit)) - - /** Inclusive tier starting value */ - fun firstUnit(firstUnit: JsonField) = apply { - this.firstUnit = firstUnit - } - - /** Amount per unit */ - fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - - /** Amount per unit */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - /** Exclusive tier ending value. If null, this is treated as the last tier */ - fun lastUnit(lastUnit: Double?) = lastUnit(JsonField.ofNullable(lastUnit)) - - /** Exclusive tier ending value. If null, this is treated as the last tier */ - fun lastUnit(lastUnit: Double) = lastUnit(lastUnit as Double?) - - /** Exclusive tier ending value. If null, this is treated as the last tier */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun lastUnit(lastUnit: Optional) = - lastUnit(lastUnit.orElse(null) as Double?) - - /** Exclusive tier ending value. If null, this is treated as the last tier */ - fun lastUnit(lastUnit: JsonField) = apply { this.lastUnit = lastUnit } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Tier = - Tier( - checkRequired("firstUnit", firstUnit), - checkRequired("unitAmount", unitAmount), - lastUnit, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tier && firstUnit == other.firstUnit && unitAmount == other.unitAmount && lastUnit == other.lastUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(firstUnit, unitAmount, lastUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{firstUnit=$firstUnit, unitAmount=$unitAmount, lastUnit=$lastUnit, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredConfig && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredConfig{tiers=$tiers, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class DimensionalPriceConfiguration - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - private val dimensionalPriceGroupId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun dimensionValues(): List = dimensionValues.getRequired("dimension_values") - - fun dimensionalPriceGroupId(): String = - dimensionalPriceGroupId.getRequired("dimensional_price_group_id") - - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - fun _dimensionalPriceGroupId(): JsonField = dimensionalPriceGroupId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): DimensionalPriceConfiguration = apply { - if (validated) { - return@apply - } - - dimensionValues() - dimensionalPriceGroupId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DimensionalPriceConfiguration]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var dimensionalPriceGroupId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(dimensionalPriceConfiguration: DimensionalPriceConfiguration) = - apply { - dimensionValues = - dimensionalPriceConfiguration.dimensionValues.map { it.toMutableList() } - dimensionalPriceGroupId = - dimensionalPriceConfiguration.dimensionalPriceGroupId - additionalProperties = - dimensionalPriceConfiguration.additionalProperties.toMutableMap() - } - - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: String) = - dimensionalPriceGroupId(JsonField.of(dimensionalPriceGroupId)) - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: JsonField) = apply { - this.dimensionalPriceGroupId = dimensionalPriceGroupId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): DimensionalPriceConfiguration = - DimensionalPriceConfiguration( - checkRequired("dimensionValues", dimensionValues).map { it.toImmutable() }, - checkRequired("dimensionalPriceGroupId", dimensionalPriceGroupId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DimensionalPriceConfiguration && dimensionValues == other.dimensionValues && dimensionalPriceGroupId == other.dimensionalPriceGroupId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, dimensionalPriceGroupId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DimensionalPriceConfiguration{dimensionValues=$dimensionValues, dimensionalPriceGroupId=$dimensionalPriceGroupId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && tieredConfig == other.tieredConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, tieredConfig, dimensionalPriceConfiguration, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, tieredConfig=$tieredConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class TieredBpsPrice - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric") - @ExcludeMissing - private val billableMetric: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("credit_allocation") - @ExcludeMissing - private val creditAllocation: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("discount") - @ExcludeMissing - private val discount: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("item") @ExcludeMissing private val item: JsonField = JsonMissing.of(), - @JsonProperty("maximum") - @ExcludeMissing - private val maximum: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("minimum") - @ExcludeMissing - private val minimum: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("price_type") - @ExcludeMissing - private val priceType: JsonField = JsonMissing.of(), - @JsonProperty("tiered_bps_config") - @ExcludeMissing - private val tieredBpsConfig: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - private val dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun billableMetric(): Optional = - Optional.ofNullable(billableMetric.getNullable("billable_metric")) - - fun billingCycleConfiguration(): BillingCycleConfiguration = - billingCycleConfiguration.getRequired("billing_cycle_configuration") - - fun cadence(): Cadence = cadence.getRequired("cadence") - - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - fun creditAllocation(): Optional = - Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) - - fun currency(): String = currency.getRequired("currency") - - fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) - - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - fun item(): Item = item.getRequired("item") - - fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) - - fun maximumAmount(): Optional = - Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - fun metadata(): Metadata = metadata.getRequired("metadata") - - fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) - - fun minimumAmount(): Optional = - Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) - - fun modelType(): ModelType = modelType.getRequired("model_type") - - fun name(): String = name.getRequired("name") - - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - fun priceType(): PriceType = priceType.getRequired("price_type") - - fun tieredBpsConfig(): TieredBpsConfig = tieredBpsConfig.getRequired("tiered_bps_config") - - fun dimensionalPriceConfiguration(): Optional = - Optional.ofNullable( - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - ) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("billable_metric") - @ExcludeMissing - fun _billableMetric(): JsonField = billableMetric - - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - @JsonProperty("credit_allocation") - @ExcludeMissing - fun _creditAllocation(): JsonField = creditAllocation - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - - @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = 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`. - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - @JsonProperty("price_type") - @ExcludeMissing - fun _priceType(): JsonField = priceType - - @JsonProperty("tiered_bps_config") - @ExcludeMissing - fun _tieredBpsConfig(): JsonField = tieredBpsConfig - - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredBpsPrice = apply { - if (validated) { - return@apply - } - - id() - billableMetric().ifPresent { it.validate() } - billingCycleConfiguration().validate() - cadence() - conversionRate() - 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() - name() - planPhaseOrder() - priceType() - tieredBpsConfig().validate() - dimensionalPriceConfiguration().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredBpsPrice]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var billableMetric: JsonField? = null - private var billingCycleConfiguration: JsonField? = null - private var cadence: JsonField? = null - private var conversionRate: JsonField? = null - private var 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: JsonField? = null - private var name: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var priceType: JsonField? = null - private var tieredBpsConfig: JsonField? = null - private var dimensionalPriceConfiguration: JsonField = - JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tieredBpsPrice: TieredBpsPrice) = apply { - id = tieredBpsPrice.id - billableMetric = tieredBpsPrice.billableMetric - billingCycleConfiguration = tieredBpsPrice.billingCycleConfiguration - cadence = tieredBpsPrice.cadence - conversionRate = tieredBpsPrice.conversionRate - createdAt = tieredBpsPrice.createdAt - creditAllocation = tieredBpsPrice.creditAllocation - currency = tieredBpsPrice.currency - discount = tieredBpsPrice.discount - externalPriceId = tieredBpsPrice.externalPriceId - fixedPriceQuantity = tieredBpsPrice.fixedPriceQuantity - invoicingCycleConfiguration = tieredBpsPrice.invoicingCycleConfiguration - item = tieredBpsPrice.item - maximum = tieredBpsPrice.maximum - maximumAmount = tieredBpsPrice.maximumAmount - metadata = tieredBpsPrice.metadata - minimum = tieredBpsPrice.minimum - minimumAmount = tieredBpsPrice.minimumAmount - modelType = tieredBpsPrice.modelType - name = tieredBpsPrice.name - planPhaseOrder = tieredBpsPrice.planPhaseOrder - priceType = tieredBpsPrice.priceType - tieredBpsConfig = tieredBpsPrice.tieredBpsConfig - dimensionalPriceConfiguration = tieredBpsPrice.dimensionalPriceConfiguration - additionalProperties = tieredBpsPrice.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun billableMetric(billableMetric: BillableMetric?) = - billableMetric(JsonField.ofNullable(billableMetric)) - - fun billableMetric(billableMetric: Optional) = - billableMetric(billableMetric.orElse(null)) - - fun billableMetric(billableMetric: JsonField) = apply { - this.billableMetric = billableMetric - } - - fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = - billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) - - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) - - fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { - this.createdAt = createdAt - } - - fun creditAllocation(creditAllocation: CreditAllocation?) = - creditAllocation(JsonField.ofNullable(creditAllocation)) - - fun creditAllocation(creditAllocation: Optional) = - creditAllocation(creditAllocation.orElse(null)) - - fun creditAllocation(creditAllocation: JsonField) = apply { - this.creditAllocation = creditAllocation - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) - - fun discount(discount: Optional) = discount(discount.orElse(null)) - - fun discount(discount: JsonField) = apply { this.discount = discount } - - fun discount(percentage: PercentageDiscount) = - discount(Discount.ofPercentage(percentage)) - - fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) - - fun trialDiscount(appliesToPriceIds: List) = - discount( - TrialDiscount.builder() - .discountType(TrialDiscount.DiscountType.TRIAL) - .appliesToPriceIds(appliesToPriceIds) - .build() - ) - - fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) - - fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) - - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } - - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } - - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) - - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - fun item(item: Item) = item(JsonField.of(item)) - - fun item(item: JsonField) = apply { this.item = item } - - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) - - fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.orElse(null)) - - 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) - - fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) - - fun minimumAmount(minimumAmount: Optional) = - minimumAmount(minimumAmount.orElse(null)) - - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } - - fun name(name: String) = name(JsonField.of(name)) - - fun name(name: JsonField) = apply { this.name = name } - - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) - - fun priceType(priceType: JsonField) = apply { this.priceType = priceType } - - fun tieredBpsConfig(tieredBpsConfig: TieredBpsConfig) = - tieredBpsConfig(JsonField.of(tieredBpsConfig)) - - fun tieredBpsConfig(tieredBpsConfig: JsonField) = apply { - this.tieredBpsConfig = tieredBpsConfig - } - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: DimensionalPriceConfiguration? - ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional - ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): TieredBpsPrice = - TieredBpsPrice( - checkRequired("id", id), - checkRequired("billableMetric", billableMetric), - checkRequired("billingCycleConfiguration", billingCycleConfiguration), - checkRequired("cadence", cadence), - checkRequired("conversionRate", conversionRate), - checkRequired("createdAt", createdAt), - checkRequired("creditAllocation", creditAllocation), - checkRequired("currency", currency), - checkRequired("discount", discount), - checkRequired("externalPriceId", externalPriceId), - checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), - checkRequired("item", item), - checkRequired("maximum", maximum), - checkRequired("maximumAmount", maximumAmount), - checkRequired("metadata", metadata), - checkRequired("minimum", minimum), - checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("priceType", priceType), - checkRequired("tieredBpsConfig", tieredBpsConfig), - dimensionalPriceConfiguration, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BillableMetric - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillableMetric = apply { - if (validated) { - return@apply - } - - id() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillableMetric]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billableMetric: BillableMetric) = apply { - id = billableMetric.id - additionalProperties = billableMetric.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - 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) - } - - fun build(): BillableMetric = - BillableMetric(checkRequired("id", id), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillableMetric && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillableMetric{id=$id, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class CreditAllocation - @JsonCreator - private constructor( - @JsonProperty("allows_rollover") - @ExcludeMissing - private val allowsRollover: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun allowsRollover(): Boolean = allowsRollover.getRequired("allows_rollover") - - fun currency(): String = currency.getRequired("currency") - - @JsonProperty("allows_rollover") - @ExcludeMissing - fun _allowsRollover(): JsonField = allowsRollover - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditAllocation = apply { - if (validated) { - return@apply - } - - allowsRollover() - currency() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditAllocation]. */ - class Builder internal constructor() { - - private var allowsRollover: JsonField? = null - private var currency: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditAllocation: CreditAllocation) = apply { - allowsRollover = creditAllocation.allowsRollover - currency = creditAllocation.currency - additionalProperties = creditAllocation.additionalProperties.toMutableMap() - } - - fun allowsRollover(allowsRollover: Boolean) = - allowsRollover(JsonField.of(allowsRollover)) - - fun allowsRollover(allowsRollover: JsonField) = apply { - this.allowsRollover = allowsRollover - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditAllocation = - CreditAllocation( - checkRequired("allowsRollover", allowsRollover), - checkRequired("currency", currency), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditAllocation && allowsRollover == other.allowsRollover && currency == other.currency && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allowsRollover, currency, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditAllocation{allowsRollover=$allowsRollover, currency=$currency, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Item - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun name(): String = name.getRequired("name") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Item = apply { - if (validated) { - return@apply - } - - id() - name() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Item]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(item: Item) = apply { - id = item.id - name = item.name - additionalProperties = item.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun name(name: String) = name(JsonField.of(name)) - - 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) - } - - fun build(): Item = - Item( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Item && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Item{id=$id, name=$name, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Maximum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Maximum amount applied */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Maximum amount applied */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Maximum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - maximumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Maximum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = maximum.maximumAmount - additionalProperties = maximum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Maximum = - Maximum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("maximumAmount", maximumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Maximum && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, maximumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Maximum{appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Minimum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Minimum amount applied */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Minimum amount applied */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Minimum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - minimumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Minimum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var minimumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } - minimumAmount = minimum.minimumAmount - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Minimum = - Minimum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("minimumAmount", minimumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Minimum && appliesToPriceIds == other.appliesToPriceIds && minimumAmount == other.minimumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, minimumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED_BPS = of("tiered_bps") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_BPS -> Value.TIERED_BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - TIERED_BPS -> Known.TIERED_BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class PriceType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE_PRICE = of("usage_price") - - @JvmField val FIXED_PRICE = of("fixed_price") - - @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) - } - - /** An enum containing [PriceType]'s known values. */ - enum class Known { - USAGE_PRICE, - FIXED_PRICE, - } - - /** - * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [PriceType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_PRICE, - FIXED_PRICE, - /** - * An enum member indicating that [PriceType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_PRICE -> Value.USAGE_PRICE - FIXED_PRICE -> Value.FIXED_PRICE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE_PRICE -> Known.USAGE_PRICE - FIXED_PRICE -> Known.FIXED_PRICE - else -> throw OrbInvalidDataException("Unknown PriceType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TieredBpsConfig - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - private val tiers: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into specified tiers - */ - fun tiers(): List = tiers.getRequired("tiers") - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into specified tiers - */ - @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredBpsConfig = apply { - if (validated) { - return@apply - } - - tiers().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredBpsConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tieredBpsConfig: TieredBpsConfig) = apply { - tiers = tieredBpsConfig.tiers.map { it.toMutableList() } - additionalProperties = tieredBpsConfig.additionalProperties.toMutableMap() - } - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into specified - * tiers - */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into specified - * tiers - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into specified - * tiers - */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): TieredBpsConfig = - TieredBpsConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Tier - @JsonCreator - private constructor( - @JsonProperty("bps") - @ExcludeMissing - private val bps: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_maximum") - @ExcludeMissing - private val perUnitMaximum: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Per-event basis point rate */ - fun bps(): Double = bps.getRequired("bps") - - /** Inclusive tier starting value */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** Exclusive tier ending value */ - fun maximumAmount(): Optional = - Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - - /** Per unit maximum to charge */ - fun perUnitMaximum(): Optional = - Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) - - /** Per-event basis point rate */ - @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps - - /** Inclusive tier starting value */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** Exclusive tier ending value */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** Per unit maximum to charge */ - @JsonProperty("per_unit_maximum") - @ExcludeMissing - fun _perUnitMaximum(): JsonField = perUnitMaximum - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - bps() - minimumAmount() - maximumAmount() - perUnitMaximum() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var bps: JsonField? = null - private var minimumAmount: JsonField? = null - private var maximumAmount: JsonField = JsonMissing.of() - private var perUnitMaximum: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - bps = tier.bps - minimumAmount = tier.minimumAmount - maximumAmount = tier.maximumAmount - perUnitMaximum = tier.perUnitMaximum - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Per-event basis point rate */ - fun bps(bps: Double) = bps(JsonField.of(bps)) - - /** Per-event basis point rate */ - fun bps(bps: JsonField) = apply { this.bps = bps } - - /** Inclusive tier starting value */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** Inclusive tier starting value */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** Exclusive tier ending value */ - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - /** Exclusive tier ending value */ - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.orElse(null)) - - /** Exclusive tier ending value */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** Per unit maximum to charge */ - fun perUnitMaximum(perUnitMaximum: String?) = - perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) - - /** Per unit maximum to charge */ - fun perUnitMaximum(perUnitMaximum: Optional) = - perUnitMaximum(perUnitMaximum.orElse(null)) - - /** Per unit maximum to charge */ - fun perUnitMaximum(perUnitMaximum: JsonField) = apply { - this.perUnitMaximum = perUnitMaximum - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): Tier = - Tier( - checkRequired("bps", bps), - checkRequired("minimumAmount", minimumAmount), - maximumAmount, - perUnitMaximum, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tier && bps == other.bps && minimumAmount == other.minimumAmount && maximumAmount == other.maximumAmount && perUnitMaximum == other.perUnitMaximum && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bps, minimumAmount, maximumAmount, perUnitMaximum, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{bps=$bps, minimumAmount=$minimumAmount, maximumAmount=$maximumAmount, perUnitMaximum=$perUnitMaximum, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredBpsConfig && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredBpsConfig{tiers=$tiers, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class DimensionalPriceConfiguration - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - private val dimensionalPriceGroupId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun dimensionValues(): List = dimensionValues.getRequired("dimension_values") - - fun dimensionalPriceGroupId(): String = - dimensionalPriceGroupId.getRequired("dimensional_price_group_id") - - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - fun _dimensionalPriceGroupId(): JsonField = dimensionalPriceGroupId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): DimensionalPriceConfiguration = apply { - if (validated) { - return@apply - } - - dimensionValues() - dimensionalPriceGroupId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DimensionalPriceConfiguration]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var dimensionalPriceGroupId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(dimensionalPriceConfiguration: DimensionalPriceConfiguration) = - apply { - dimensionValues = - dimensionalPriceConfiguration.dimensionValues.map { it.toMutableList() } - dimensionalPriceGroupId = - dimensionalPriceConfiguration.dimensionalPriceGroupId - additionalProperties = - dimensionalPriceConfiguration.additionalProperties.toMutableMap() - } - - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: String) = - dimensionalPriceGroupId(JsonField.of(dimensionalPriceGroupId)) - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: JsonField) = apply { - this.dimensionalPriceGroupId = dimensionalPriceGroupId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): DimensionalPriceConfiguration = - DimensionalPriceConfiguration( - checkRequired("dimensionValues", dimensionValues).map { it.toImmutable() }, - checkRequired("dimensionalPriceGroupId", dimensionalPriceGroupId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DimensionalPriceConfiguration && dimensionValues == other.dimensionValues && dimensionalPriceGroupId == other.dimensionalPriceGroupId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, dimensionalPriceGroupId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DimensionalPriceConfiguration{dimensionValues=$dimensionValues, dimensionalPriceGroupId=$dimensionalPriceGroupId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredBpsPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && tieredBpsConfig == other.tieredBpsConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, tieredBpsConfig, dimensionalPriceConfiguration, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredBpsPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, tieredBpsConfig=$tieredBpsConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BpsPrice - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric") - @ExcludeMissing - private val billableMetric: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("bps_config") - @ExcludeMissing - private val bpsConfig: JsonField = JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("credit_allocation") - @ExcludeMissing - private val creditAllocation: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("discount") - @ExcludeMissing - private val discount: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("item") @ExcludeMissing private val item: JsonField = JsonMissing.of(), - @JsonProperty("maximum") - @ExcludeMissing - private val maximum: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("minimum") - @ExcludeMissing - private val minimum: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("price_type") - @ExcludeMissing - private val priceType: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - private val dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun billableMetric(): Optional = - Optional.ofNullable(billableMetric.getNullable("billable_metric")) - - fun billingCycleConfiguration(): BillingCycleConfiguration = - billingCycleConfiguration.getRequired("billing_cycle_configuration") - - fun bpsConfig(): BpsConfig = bpsConfig.getRequired("bps_config") - - fun cadence(): Cadence = cadence.getRequired("cadence") - - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - fun creditAllocation(): Optional = - Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) - - fun currency(): String = currency.getRequired("currency") - - fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) - - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - fun item(): Item = item.getRequired("item") - - fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) - - fun maximumAmount(): Optional = - Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - fun metadata(): Metadata = metadata.getRequired("metadata") - - fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) - - fun minimumAmount(): Optional = - Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) - - fun modelType(): ModelType = modelType.getRequired("model_type") - - fun name(): String = name.getRequired("name") - - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - fun priceType(): PriceType = priceType.getRequired("price_type") - - fun dimensionalPriceConfiguration(): Optional = - Optional.ofNullable( - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - ) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("billable_metric") - @ExcludeMissing - fun _billableMetric(): JsonField = billableMetric - - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - @JsonProperty("bps_config") - @ExcludeMissing - fun _bpsConfig(): JsonField = bpsConfig - - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - @JsonProperty("credit_allocation") - @ExcludeMissing - fun _creditAllocation(): JsonField = creditAllocation - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - - @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = 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`. - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - @JsonProperty("price_type") - @ExcludeMissing - fun _priceType(): JsonField = priceType - - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BpsPrice = apply { - if (validated) { - return@apply - } - - id() - billableMetric().ifPresent { it.validate() } - billingCycleConfiguration().validate() - bpsConfig().validate() - cadence() - conversionRate() - 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() - name() - planPhaseOrder() - priceType() - dimensionalPriceConfiguration().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BpsPrice]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var billableMetric: JsonField? = null - private var billingCycleConfiguration: JsonField? = null - private var bpsConfig: JsonField? = null - private var cadence: JsonField? = null - private var conversionRate: 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: JsonField? = null - private var name: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var priceType: JsonField? = null - private var dimensionalPriceConfiguration: JsonField = - JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(bpsPrice: BpsPrice) = apply { - id = bpsPrice.id - billableMetric = bpsPrice.billableMetric - billingCycleConfiguration = bpsPrice.billingCycleConfiguration - bpsConfig = bpsPrice.bpsConfig - cadence = bpsPrice.cadence - conversionRate = bpsPrice.conversionRate - createdAt = bpsPrice.createdAt - creditAllocation = bpsPrice.creditAllocation - currency = bpsPrice.currency - discount = bpsPrice.discount - externalPriceId = bpsPrice.externalPriceId - fixedPriceQuantity = bpsPrice.fixedPriceQuantity - invoicingCycleConfiguration = bpsPrice.invoicingCycleConfiguration - item = bpsPrice.item - maximum = bpsPrice.maximum - maximumAmount = bpsPrice.maximumAmount - metadata = bpsPrice.metadata - minimum = bpsPrice.minimum - minimumAmount = bpsPrice.minimumAmount - modelType = bpsPrice.modelType - name = bpsPrice.name - planPhaseOrder = bpsPrice.planPhaseOrder - priceType = bpsPrice.priceType - dimensionalPriceConfiguration = bpsPrice.dimensionalPriceConfiguration - additionalProperties = bpsPrice.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun billableMetric(billableMetric: BillableMetric?) = - billableMetric(JsonField.ofNullable(billableMetric)) - - fun billableMetric(billableMetric: Optional) = - billableMetric(billableMetric.orElse(null)) - - fun billableMetric(billableMetric: JsonField) = apply { - this.billableMetric = billableMetric - } - - fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = - billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) - - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - - fun bpsConfig(bpsConfig: BpsConfig) = bpsConfig(JsonField.of(bpsConfig)) - - fun bpsConfig(bpsConfig: JsonField) = apply { this.bpsConfig = bpsConfig } - - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) - - fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { - this.createdAt = createdAt - } - - fun creditAllocation(creditAllocation: CreditAllocation?) = - creditAllocation(JsonField.ofNullable(creditAllocation)) - - fun creditAllocation(creditAllocation: Optional) = - creditAllocation(creditAllocation.orElse(null)) - - fun creditAllocation(creditAllocation: JsonField) = apply { - this.creditAllocation = creditAllocation - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) - - fun discount(discount: Optional) = discount(discount.orElse(null)) - - fun discount(discount: JsonField) = apply { this.discount = discount } - - fun discount(percentage: PercentageDiscount) = - discount(Discount.ofPercentage(percentage)) - - fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) - - fun trialDiscount(appliesToPriceIds: List) = - discount( - TrialDiscount.builder() - .discountType(TrialDiscount.DiscountType.TRIAL) - .appliesToPriceIds(appliesToPriceIds) - .build() - ) - - fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) - - fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) - - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } - - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } - - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) - - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - fun item(item: Item) = item(JsonField.of(item)) - - fun item(item: JsonField) = apply { this.item = item } - - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) - - fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.orElse(null)) - - 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) - - fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) - - fun minimumAmount(minimumAmount: Optional) = - minimumAmount(minimumAmount.orElse(null)) - - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } - - fun name(name: String) = name(JsonField.of(name)) - - fun name(name: JsonField) = apply { this.name = name } - - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) - - fun priceType(priceType: JsonField) = apply { this.priceType = priceType } - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: DimensionalPriceConfiguration? - ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional - ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): BpsPrice = - BpsPrice( - checkRequired("id", id), - checkRequired("billableMetric", billableMetric), - checkRequired("billingCycleConfiguration", billingCycleConfiguration), - checkRequired("bpsConfig", bpsConfig), - checkRequired("cadence", cadence), - checkRequired("conversionRate", conversionRate), - checkRequired("createdAt", createdAt), - checkRequired("creditAllocation", creditAllocation), - checkRequired("currency", currency), - checkRequired("discount", discount), - checkRequired("externalPriceId", externalPriceId), - checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), - checkRequired("item", item), - checkRequired("maximum", maximum), - checkRequired("maximumAmount", maximumAmount), - checkRequired("metadata", metadata), - checkRequired("minimum", minimum), - checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("priceType", priceType), - dimensionalPriceConfiguration, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BillableMetric - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillableMetric = apply { - if (validated) { - return@apply - } - - id() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillableMetric]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billableMetric: BillableMetric) = apply { - id = billableMetric.id - additionalProperties = billableMetric.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - 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) - } - - fun build(): BillableMetric = - BillableMetric(checkRequired("id", id), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillableMetric && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillableMetric{id=$id, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BpsConfig - @JsonCreator - private constructor( - @JsonProperty("bps") - @ExcludeMissing - private val bps: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_maximum") - @ExcludeMissing - private val perUnitMaximum: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Basis point take rate per event */ - fun bps(): Double = bps.getRequired("bps") - - /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(): Optional = - Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) - - /** Basis point take rate per event */ - @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps - - /** Optional currency amount maximum to cap spend per event */ - @JsonProperty("per_unit_maximum") - @ExcludeMissing - fun _perUnitMaximum(): JsonField = perUnitMaximum - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BpsConfig = apply { - if (validated) { - return@apply - } - - bps() - perUnitMaximum() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BpsConfig]. */ - class Builder internal constructor() { - - private var bps: JsonField? = null - private var perUnitMaximum: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(bpsConfig: BpsConfig) = apply { - bps = bpsConfig.bps - perUnitMaximum = bpsConfig.perUnitMaximum - additionalProperties = bpsConfig.additionalProperties.toMutableMap() - } - - /** Basis point take rate per event */ - fun bps(bps: Double) = bps(JsonField.of(bps)) - - /** Basis point take rate per event */ - fun bps(bps: JsonField) = apply { this.bps = bps } - - /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(perUnitMaximum: String?) = - perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) - - /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(perUnitMaximum: Optional) = - perUnitMaximum(perUnitMaximum.orElse(null)) - - /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(perUnitMaximum: JsonField) = apply { - this.perUnitMaximum = perUnitMaximum - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): BpsConfig = - BpsConfig( - checkRequired("bps", bps), - perUnitMaximum, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BpsConfig && bps == other.bps && perUnitMaximum == other.perUnitMaximum && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bps, perUnitMaximum, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BpsConfig{bps=$bps, perUnitMaximum=$perUnitMaximum, additionalProperties=$additionalProperties}" - } - - 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class CreditAllocation - @JsonCreator - private constructor( - @JsonProperty("allows_rollover") - @ExcludeMissing - private val allowsRollover: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun allowsRollover(): Boolean = allowsRollover.getRequired("allows_rollover") - - fun currency(): String = currency.getRequired("currency") - - @JsonProperty("allows_rollover") - @ExcludeMissing - fun _allowsRollover(): JsonField = allowsRollover - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditAllocation = apply { - if (validated) { - return@apply - } - - allowsRollover() - currency() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditAllocation]. */ - class Builder internal constructor() { - - private var allowsRollover: JsonField? = null - private var currency: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditAllocation: CreditAllocation) = apply { - allowsRollover = creditAllocation.allowsRollover - currency = creditAllocation.currency - additionalProperties = creditAllocation.additionalProperties.toMutableMap() - } - - fun allowsRollover(allowsRollover: Boolean) = - allowsRollover(JsonField.of(allowsRollover)) - - fun allowsRollover(allowsRollover: JsonField) = apply { - this.allowsRollover = allowsRollover - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditAllocation = - CreditAllocation( - checkRequired("allowsRollover", allowsRollover), - checkRequired("currency", currency), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditAllocation && allowsRollover == other.allowsRollover && currency == other.currency && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allowsRollover, currency, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditAllocation{allowsRollover=$allowsRollover, currency=$currency, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Item - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun name(): String = name.getRequired("name") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Item = apply { - if (validated) { - return@apply - } - - id() - name() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Item]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(item: Item) = apply { - id = item.id - name = item.name - additionalProperties = item.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun name(name: String) = name(JsonField.of(name)) - - 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) - } - - fun build(): Item = - Item( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Item && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Item{id=$id, name=$name, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Maximum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Maximum amount applied */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Maximum amount applied */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Maximum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - maximumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Maximum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = maximum.maximumAmount - additionalProperties = maximum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Maximum = - Maximum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("maximumAmount", maximumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Maximum && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, maximumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Maximum{appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Minimum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Minimum amount applied */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Minimum amount applied */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Minimum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - minimumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Minimum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var minimumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } - minimumAmount = minimum.minimumAmount - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Minimum = - Minimum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("minimumAmount", minimumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Minimum && appliesToPriceIds == other.appliesToPriceIds && minimumAmount == other.minimumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, minimumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val BPS = of("bps") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BPS -> Value.BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - BPS -> Known.BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class PriceType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE_PRICE = of("usage_price") - - @JvmField val FIXED_PRICE = of("fixed_price") - - @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) - } - - /** An enum containing [PriceType]'s known values. */ - enum class Known { - USAGE_PRICE, - FIXED_PRICE, - } - - /** - * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [PriceType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_PRICE, - FIXED_PRICE, - /** - * An enum member indicating that [PriceType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_PRICE -> Value.USAGE_PRICE - FIXED_PRICE -> Value.FIXED_PRICE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE_PRICE -> Known.USAGE_PRICE - FIXED_PRICE -> Known.FIXED_PRICE - else -> throw OrbInvalidDataException("Unknown PriceType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class DimensionalPriceConfiguration - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - private val dimensionalPriceGroupId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun dimensionValues(): List = dimensionValues.getRequired("dimension_values") - - fun dimensionalPriceGroupId(): String = - dimensionalPriceGroupId.getRequired("dimensional_price_group_id") - - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - fun _dimensionalPriceGroupId(): JsonField = dimensionalPriceGroupId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): DimensionalPriceConfiguration = apply { - if (validated) { - return@apply - } - - dimensionValues() - dimensionalPriceGroupId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DimensionalPriceConfiguration]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var dimensionalPriceGroupId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(dimensionalPriceConfiguration: DimensionalPriceConfiguration) = - apply { - dimensionValues = - dimensionalPriceConfiguration.dimensionValues.map { it.toMutableList() } - dimensionalPriceGroupId = - dimensionalPriceConfiguration.dimensionalPriceGroupId - additionalProperties = - dimensionalPriceConfiguration.additionalProperties.toMutableMap() - } - - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: String) = - dimensionalPriceGroupId(JsonField.of(dimensionalPriceGroupId)) - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: JsonField) = apply { - this.dimensionalPriceGroupId = dimensionalPriceGroupId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): DimensionalPriceConfiguration = - DimensionalPriceConfiguration( - checkRequired("dimensionValues", dimensionValues).map { it.toImmutable() }, - checkRequired("dimensionalPriceGroupId", dimensionalPriceGroupId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DimensionalPriceConfiguration && dimensionValues == other.dimensionValues && dimensionalPriceGroupId == other.dimensionalPriceGroupId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, dimensionalPriceGroupId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DimensionalPriceConfiguration{dimensionValues=$dimensionValues, dimensionalPriceGroupId=$dimensionalPriceGroupId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BpsPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && bpsConfig == other.bpsConfig && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, bpsConfig, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BpsPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, bpsConfig=$bpsConfig, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BulkBpsPrice - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric") - @ExcludeMissing - private val billableMetric: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("bulk_bps_config") - @ExcludeMissing - private val bulkBpsConfig: JsonField = JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("credit_allocation") - @ExcludeMissing - private val creditAllocation: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("discount") - @ExcludeMissing - private val discount: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("item") @ExcludeMissing private val item: JsonField = JsonMissing.of(), - @JsonProperty("maximum") - @ExcludeMissing - private val maximum: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("minimum") - @ExcludeMissing - private val minimum: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("price_type") - @ExcludeMissing - private val priceType: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - private val dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun billableMetric(): Optional = - Optional.ofNullable(billableMetric.getNullable("billable_metric")) - - fun billingCycleConfiguration(): BillingCycleConfiguration = - billingCycleConfiguration.getRequired("billing_cycle_configuration") - - fun bulkBpsConfig(): BulkBpsConfig = bulkBpsConfig.getRequired("bulk_bps_config") - - fun cadence(): Cadence = cadence.getRequired("cadence") - - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - fun creditAllocation(): Optional = - Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) - - fun currency(): String = currency.getRequired("currency") - - fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) - - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - fun item(): Item = item.getRequired("item") - - fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) - - fun maximumAmount(): Optional = - Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - fun metadata(): Metadata = metadata.getRequired("metadata") - - fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) - - fun minimumAmount(): Optional = - Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) - - fun modelType(): ModelType = modelType.getRequired("model_type") - - fun name(): String = name.getRequired("name") - - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - fun priceType(): PriceType = priceType.getRequired("price_type") - - fun dimensionalPriceConfiguration(): Optional = - Optional.ofNullable( - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - ) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("billable_metric") - @ExcludeMissing - fun _billableMetric(): JsonField = billableMetric - - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - @JsonProperty("bulk_bps_config") - @ExcludeMissing - fun _bulkBpsConfig(): JsonField = bulkBpsConfig - - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - @JsonProperty("credit_allocation") - @ExcludeMissing - fun _creditAllocation(): JsonField = creditAllocation - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - - @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = 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`. - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - @JsonProperty("price_type") - @ExcludeMissing - fun _priceType(): JsonField = priceType - - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BulkBpsPrice = apply { - if (validated) { - return@apply - } - - id() - billableMetric().ifPresent { it.validate() } - billingCycleConfiguration().validate() - bulkBpsConfig().validate() - cadence() - conversionRate() - 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() - name() - planPhaseOrder() - priceType() - dimensionalPriceConfiguration().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkBpsPrice]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var billableMetric: JsonField? = null - private var billingCycleConfiguration: JsonField? = null - private var bulkBpsConfig: JsonField? = null - private var cadence: JsonField? = null - private var conversionRate: 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: JsonField? = null - private var name: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var priceType: JsonField? = null - private var dimensionalPriceConfiguration: JsonField = - JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(bulkBpsPrice: BulkBpsPrice) = apply { - id = bulkBpsPrice.id - billableMetric = bulkBpsPrice.billableMetric - billingCycleConfiguration = bulkBpsPrice.billingCycleConfiguration - bulkBpsConfig = bulkBpsPrice.bulkBpsConfig - cadence = bulkBpsPrice.cadence - conversionRate = bulkBpsPrice.conversionRate - createdAt = bulkBpsPrice.createdAt - creditAllocation = bulkBpsPrice.creditAllocation - currency = bulkBpsPrice.currency - discount = bulkBpsPrice.discount - externalPriceId = bulkBpsPrice.externalPriceId - fixedPriceQuantity = bulkBpsPrice.fixedPriceQuantity - invoicingCycleConfiguration = bulkBpsPrice.invoicingCycleConfiguration - item = bulkBpsPrice.item - maximum = bulkBpsPrice.maximum - maximumAmount = bulkBpsPrice.maximumAmount - metadata = bulkBpsPrice.metadata - minimum = bulkBpsPrice.minimum - minimumAmount = bulkBpsPrice.minimumAmount - modelType = bulkBpsPrice.modelType - name = bulkBpsPrice.name - planPhaseOrder = bulkBpsPrice.planPhaseOrder - priceType = bulkBpsPrice.priceType - dimensionalPriceConfiguration = bulkBpsPrice.dimensionalPriceConfiguration - additionalProperties = bulkBpsPrice.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun billableMetric(billableMetric: BillableMetric?) = - billableMetric(JsonField.ofNullable(billableMetric)) - - fun billableMetric(billableMetric: Optional) = - billableMetric(billableMetric.orElse(null)) - - fun billableMetric(billableMetric: JsonField) = apply { - this.billableMetric = billableMetric - } - - fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = - billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) - - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - - fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfig) = - bulkBpsConfig(JsonField.of(bulkBpsConfig)) - - fun bulkBpsConfig(bulkBpsConfig: JsonField) = apply { - this.bulkBpsConfig = bulkBpsConfig - } - - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) - - fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { - this.createdAt = createdAt - } - - fun creditAllocation(creditAllocation: CreditAllocation?) = - creditAllocation(JsonField.ofNullable(creditAllocation)) - - fun creditAllocation(creditAllocation: Optional) = - creditAllocation(creditAllocation.orElse(null)) - - fun creditAllocation(creditAllocation: JsonField) = apply { - this.creditAllocation = creditAllocation - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) - - fun discount(discount: Optional) = discount(discount.orElse(null)) - - fun discount(discount: JsonField) = apply { this.discount = discount } - - fun discount(percentage: PercentageDiscount) = - discount(Discount.ofPercentage(percentage)) - - fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) - - fun trialDiscount(appliesToPriceIds: List) = - discount( - TrialDiscount.builder() - .discountType(TrialDiscount.DiscountType.TRIAL) - .appliesToPriceIds(appliesToPriceIds) - .build() - ) - - fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) - - fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) - - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } - - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } - - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) - - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - fun item(item: Item) = item(JsonField.of(item)) - - fun item(item: JsonField) = apply { this.item = item } - - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) - - fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.orElse(null)) - - 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) - - fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) - - fun minimumAmount(minimumAmount: Optional) = - minimumAmount(minimumAmount.orElse(null)) - - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } - - fun name(name: String) = name(JsonField.of(name)) - - fun name(name: JsonField) = apply { this.name = name } - - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) - - fun priceType(priceType: JsonField) = apply { this.priceType = priceType } - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: DimensionalPriceConfiguration? - ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional - ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): BulkBpsPrice = - BulkBpsPrice( - checkRequired("id", id), - checkRequired("billableMetric", billableMetric), - checkRequired("billingCycleConfiguration", billingCycleConfiguration), - checkRequired("bulkBpsConfig", bulkBpsConfig), - checkRequired("cadence", cadence), - checkRequired("conversionRate", conversionRate), - checkRequired("createdAt", createdAt), - checkRequired("creditAllocation", creditAllocation), - checkRequired("currency", currency), - checkRequired("discount", discount), - checkRequired("externalPriceId", externalPriceId), - checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), - checkRequired("item", item), - checkRequired("maximum", maximum), - checkRequired("maximumAmount", maximumAmount), - checkRequired("metadata", metadata), - checkRequired("minimum", minimum), - checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("priceType", priceType), - dimensionalPriceConfiguration, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BillableMetric - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillableMetric = apply { - if (validated) { - return@apply - } - - id() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillableMetric]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billableMetric: BillableMetric) = apply { - id = billableMetric.id - additionalProperties = billableMetric.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - 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) - } - - fun build(): BillableMetric = - BillableMetric(checkRequired("id", id), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillableMetric && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillableMetric{id=$id, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BulkBpsConfig - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - private val tiers: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a single tier - * based on total volume - */ - fun tiers(): List = tiers.getRequired("tiers") - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a single tier - * based on total volume - */ - @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BulkBpsConfig = apply { - if (validated) { - return@apply - } - - tiers().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkBpsConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(bulkBpsConfig: BulkBpsConfig) = apply { - tiers = bulkBpsConfig.tiers.map { it.toMutableList() } - additionalProperties = bulkBpsConfig.additionalProperties.toMutableMap() - } - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a single tier - * based on total volume - */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a single tier - * based on total volume - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a single tier - * based on total volume - */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): BulkBpsConfig = - BulkBpsConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Tier - @JsonCreator - private constructor( - @JsonProperty("bps") - @ExcludeMissing - private val bps: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_maximum") - @ExcludeMissing - private val perUnitMaximum: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Basis points to rate on */ - fun bps(): Double = bps.getRequired("bps") - - /** Upper bound for tier */ - fun maximumAmount(): Optional = - Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(): Optional = - Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) - - /** Basis points to rate on */ - @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps - - /** Upper bound for tier */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** The maximum amount to charge for any one event */ - @JsonProperty("per_unit_maximum") - @ExcludeMissing - fun _perUnitMaximum(): JsonField = perUnitMaximum - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - bps() - maximumAmount() - perUnitMaximum() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var bps: JsonField? = null - private var maximumAmount: JsonField = JsonMissing.of() - private var perUnitMaximum: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - bps = tier.bps - maximumAmount = tier.maximumAmount - perUnitMaximum = tier.perUnitMaximum - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Basis points to rate on */ - fun bps(bps: Double) = bps(JsonField.of(bps)) - - /** Basis points to rate on */ - fun bps(bps: JsonField) = apply { this.bps = bps } - - /** Upper bound for tier */ - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - /** Upper bound for tier */ - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.orElse(null)) - - /** Upper bound for tier */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(perUnitMaximum: String?) = - perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) - - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(perUnitMaximum: Optional) = - perUnitMaximum(perUnitMaximum.orElse(null)) - - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(perUnitMaximum: JsonField) = apply { - this.perUnitMaximum = perUnitMaximum - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): Tier = - Tier( - checkRequired("bps", bps), - maximumAmount, - perUnitMaximum, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tier && bps == other.bps && maximumAmount == other.maximumAmount && perUnitMaximum == other.perUnitMaximum && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bps, maximumAmount, perUnitMaximum, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{bps=$bps, maximumAmount=$maximumAmount, perUnitMaximum=$perUnitMaximum, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BulkBpsConfig && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkBpsConfig{tiers=$tiers, additionalProperties=$additionalProperties}" - } - - 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class CreditAllocation - @JsonCreator - private constructor( - @JsonProperty("allows_rollover") - @ExcludeMissing - private val allowsRollover: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun allowsRollover(): Boolean = allowsRollover.getRequired("allows_rollover") - - fun currency(): String = currency.getRequired("currency") - - @JsonProperty("allows_rollover") - @ExcludeMissing - fun _allowsRollover(): JsonField = allowsRollover - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditAllocation = apply { - if (validated) { - return@apply - } - - allowsRollover() - currency() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditAllocation]. */ - class Builder internal constructor() { - - private var allowsRollover: JsonField? = null - private var currency: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditAllocation: CreditAllocation) = apply { - allowsRollover = creditAllocation.allowsRollover - currency = creditAllocation.currency - additionalProperties = creditAllocation.additionalProperties.toMutableMap() - } - - fun allowsRollover(allowsRollover: Boolean) = - allowsRollover(JsonField.of(allowsRollover)) - - fun allowsRollover(allowsRollover: JsonField) = apply { - this.allowsRollover = allowsRollover - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditAllocation = - CreditAllocation( - checkRequired("allowsRollover", allowsRollover), - checkRequired("currency", currency), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditAllocation && allowsRollover == other.allowsRollover && currency == other.currency && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allowsRollover, currency, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditAllocation{allowsRollover=$allowsRollover, currency=$currency, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Item - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun name(): String = name.getRequired("name") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Item = apply { - if (validated) { - return@apply - } - - id() - name() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Item]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(item: Item) = apply { - id = item.id - name = item.name - additionalProperties = item.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun name(name: String) = name(JsonField.of(name)) - - 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) - } - - fun build(): Item = - Item( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Item && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Item{id=$id, name=$name, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Maximum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Maximum amount applied */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Maximum amount applied */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Maximum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - maximumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Maximum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = maximum.maximumAmount - additionalProperties = maximum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Maximum = - Maximum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("maximumAmount", maximumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Maximum && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, maximumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Maximum{appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Minimum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Minimum amount applied */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Minimum amount applied */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Minimum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - minimumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Minimum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var minimumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } - minimumAmount = minimum.minimumAmount - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Minimum = - Minimum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("minimumAmount", minimumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Minimum && appliesToPriceIds == other.appliesToPriceIds && minimumAmount == other.minimumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, minimumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val BULK_BPS = of("bulk_bps") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK_BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK_BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK_BPS -> Value.BULK_BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - BULK_BPS -> Known.BULK_BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class PriceType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE_PRICE = of("usage_price") - - @JvmField val FIXED_PRICE = of("fixed_price") - - @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) - } - - /** An enum containing [PriceType]'s known values. */ - enum class Known { - USAGE_PRICE, - FIXED_PRICE, - } - - /** - * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [PriceType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_PRICE, - FIXED_PRICE, - /** - * An enum member indicating that [PriceType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_PRICE -> Value.USAGE_PRICE - FIXED_PRICE -> Value.FIXED_PRICE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE_PRICE -> Known.USAGE_PRICE - FIXED_PRICE -> Known.FIXED_PRICE - else -> throw OrbInvalidDataException("Unknown PriceType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class DimensionalPriceConfiguration - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - private val dimensionalPriceGroupId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun dimensionValues(): List = dimensionValues.getRequired("dimension_values") - - fun dimensionalPriceGroupId(): String = - dimensionalPriceGroupId.getRequired("dimensional_price_group_id") - - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - fun _dimensionalPriceGroupId(): JsonField = dimensionalPriceGroupId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): DimensionalPriceConfiguration = apply { - if (validated) { - return@apply - } - - dimensionValues() - dimensionalPriceGroupId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DimensionalPriceConfiguration]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var dimensionalPriceGroupId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(dimensionalPriceConfiguration: DimensionalPriceConfiguration) = - apply { - dimensionValues = - dimensionalPriceConfiguration.dimensionValues.map { it.toMutableList() } - dimensionalPriceGroupId = - dimensionalPriceConfiguration.dimensionalPriceGroupId - additionalProperties = - dimensionalPriceConfiguration.additionalProperties.toMutableMap() - } - - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: String) = - dimensionalPriceGroupId(JsonField.of(dimensionalPriceGroupId)) - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: JsonField) = apply { - this.dimensionalPriceGroupId = dimensionalPriceGroupId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): DimensionalPriceConfiguration = - DimensionalPriceConfiguration( - checkRequired("dimensionValues", dimensionValues).map { it.toImmutable() }, - checkRequired("dimensionalPriceGroupId", dimensionalPriceGroupId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DimensionalPriceConfiguration && dimensionValues == other.dimensionValues && dimensionalPriceGroupId == other.dimensionalPriceGroupId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, dimensionalPriceGroupId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DimensionalPriceConfiguration{dimensionValues=$dimensionValues, dimensionalPriceGroupId=$dimensionalPriceGroupId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BulkBpsPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && bulkBpsConfig == other.bulkBpsConfig && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, bulkBpsConfig, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkBpsPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, bulkBpsConfig=$bulkBpsConfig, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BulkPrice - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric") - @ExcludeMissing - private val billableMetric: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("bulk_config") - @ExcludeMissing - private val bulkConfig: JsonField = JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("credit_allocation") - @ExcludeMissing - private val creditAllocation: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("discount") - @ExcludeMissing - private val discount: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("item") @ExcludeMissing private val item: JsonField = JsonMissing.of(), - @JsonProperty("maximum") - @ExcludeMissing - private val maximum: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("minimum") - @ExcludeMissing - private val minimum: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("price_type") - @ExcludeMissing - private val priceType: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - private val dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun billableMetric(): Optional = - Optional.ofNullable(billableMetric.getNullable("billable_metric")) - - fun billingCycleConfiguration(): BillingCycleConfiguration = - billingCycleConfiguration.getRequired("billing_cycle_configuration") - - fun bulkConfig(): BulkConfig = bulkConfig.getRequired("bulk_config") - - fun cadence(): Cadence = cadence.getRequired("cadence") - - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - fun creditAllocation(): Optional = - Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) - - fun currency(): String = currency.getRequired("currency") - - fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) - - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - fun item(): Item = item.getRequired("item") - - fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) - - fun maximumAmount(): Optional = - Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - fun metadata(): Metadata = metadata.getRequired("metadata") - - fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) - - fun minimumAmount(): Optional = - Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) - - fun modelType(): ModelType = modelType.getRequired("model_type") - - fun name(): String = name.getRequired("name") - - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - fun priceType(): PriceType = priceType.getRequired("price_type") - - fun dimensionalPriceConfiguration(): Optional = - Optional.ofNullable( - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - ) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("billable_metric") - @ExcludeMissing - fun _billableMetric(): JsonField = billableMetric - - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - @JsonProperty("bulk_config") - @ExcludeMissing - fun _bulkConfig(): JsonField = bulkConfig - - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - @JsonProperty("credit_allocation") - @ExcludeMissing - fun _creditAllocation(): JsonField = creditAllocation - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - - @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = 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`. - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - @JsonProperty("price_type") - @ExcludeMissing - fun _priceType(): JsonField = priceType - - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BulkPrice = apply { - if (validated) { - return@apply - } - - id() - billableMetric().ifPresent { it.validate() } - billingCycleConfiguration().validate() - bulkConfig().validate() - cadence() - conversionRate() - 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() - name() - planPhaseOrder() - priceType() - dimensionalPriceConfiguration().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkPrice]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var billableMetric: JsonField? = null - private var billingCycleConfiguration: JsonField? = null - private var bulkConfig: JsonField? = null - private var cadence: JsonField? = null - private var conversionRate: 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: JsonField? = null - private var name: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var priceType: JsonField? = null - private var dimensionalPriceConfiguration: JsonField = - JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(bulkPrice: BulkPrice) = apply { - id = bulkPrice.id - billableMetric = bulkPrice.billableMetric - billingCycleConfiguration = bulkPrice.billingCycleConfiguration - bulkConfig = bulkPrice.bulkConfig - cadence = bulkPrice.cadence - conversionRate = bulkPrice.conversionRate - createdAt = bulkPrice.createdAt - creditAllocation = bulkPrice.creditAllocation - currency = bulkPrice.currency - discount = bulkPrice.discount - externalPriceId = bulkPrice.externalPriceId - fixedPriceQuantity = bulkPrice.fixedPriceQuantity - invoicingCycleConfiguration = bulkPrice.invoicingCycleConfiguration - item = bulkPrice.item - maximum = bulkPrice.maximum - maximumAmount = bulkPrice.maximumAmount - metadata = bulkPrice.metadata - minimum = bulkPrice.minimum - minimumAmount = bulkPrice.minimumAmount - modelType = bulkPrice.modelType - name = bulkPrice.name - planPhaseOrder = bulkPrice.planPhaseOrder - priceType = bulkPrice.priceType - dimensionalPriceConfiguration = bulkPrice.dimensionalPriceConfiguration - additionalProperties = bulkPrice.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun billableMetric(billableMetric: BillableMetric?) = - billableMetric(JsonField.ofNullable(billableMetric)) - - fun billableMetric(billableMetric: Optional) = - billableMetric(billableMetric.orElse(null)) - - fun billableMetric(billableMetric: JsonField) = apply { - this.billableMetric = billableMetric - } - - fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = - billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) - - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - - fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) - - fun bulkConfig(bulkConfig: JsonField) = apply { - this.bulkConfig = bulkConfig - } - - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) - - fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { - this.createdAt = createdAt - } - - fun creditAllocation(creditAllocation: CreditAllocation?) = - creditAllocation(JsonField.ofNullable(creditAllocation)) - - fun creditAllocation(creditAllocation: Optional) = - creditAllocation(creditAllocation.orElse(null)) - - fun creditAllocation(creditAllocation: JsonField) = apply { - this.creditAllocation = creditAllocation - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) - - fun discount(discount: Optional) = discount(discount.orElse(null)) - - fun discount(discount: JsonField) = apply { this.discount = discount } - - fun discount(percentage: PercentageDiscount) = - discount(Discount.ofPercentage(percentage)) - - fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) - - fun trialDiscount(appliesToPriceIds: List) = - discount( - TrialDiscount.builder() - .discountType(TrialDiscount.DiscountType.TRIAL) - .appliesToPriceIds(appliesToPriceIds) - .build() - ) - - fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) - - fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) - - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } - - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } - - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) - - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - fun item(item: Item) = item(JsonField.of(item)) - - fun item(item: JsonField) = apply { this.item = item } - - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) - - fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.orElse(null)) - - 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) - - fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) - - fun minimumAmount(minimumAmount: Optional) = - minimumAmount(minimumAmount.orElse(null)) - - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } - - fun name(name: String) = name(JsonField.of(name)) - - fun name(name: JsonField) = apply { this.name = name } - - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) - - fun priceType(priceType: JsonField) = apply { this.priceType = priceType } - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: DimensionalPriceConfiguration? - ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional - ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): BulkPrice = - BulkPrice( - checkRequired("id", id), - checkRequired("billableMetric", billableMetric), - checkRequired("billingCycleConfiguration", billingCycleConfiguration), - checkRequired("bulkConfig", bulkConfig), - checkRequired("cadence", cadence), - checkRequired("conversionRate", conversionRate), - checkRequired("createdAt", createdAt), - checkRequired("creditAllocation", creditAllocation), - checkRequired("currency", currency), - checkRequired("discount", discount), - checkRequired("externalPriceId", externalPriceId), - checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), - checkRequired("item", item), - checkRequired("maximum", maximum), - checkRequired("maximumAmount", maximumAmount), - checkRequired("metadata", metadata), - checkRequired("minimum", minimum), - checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("priceType", priceType), - dimensionalPriceConfiguration, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BillableMetric - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillableMetric = apply { - if (validated) { - return@apply - } - - id() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillableMetric]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billableMetric: BillableMetric) = apply { - id = billableMetric.id - additionalProperties = billableMetric.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - 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) - } - - fun build(): BillableMetric = - BillableMetric(checkRequired("id", id), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillableMetric && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillableMetric{id=$id, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BulkConfig - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - private val tiers: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Bulk tiers for rating based on total usage volume */ - fun tiers(): List = tiers.getRequired("tiers") - - /** Bulk tiers for rating based on total usage volume */ - @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BulkConfig = apply { - if (validated) { - return@apply - } - - tiers().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(bulkConfig: BulkConfig) = apply { - tiers = bulkConfig.tiers.map { it.toMutableList() } - additionalProperties = bulkConfig.additionalProperties.toMutableMap() - } - - /** Bulk tiers for rating based on total usage volume */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - - /** Bulk tiers for rating based on total usage volume */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** Bulk tiers for rating based on total usage volume */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): BulkConfig = - BulkConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Tier - @JsonCreator - private constructor( - @JsonProperty("unit_amount") - @ExcludeMissing - private val unitAmount: JsonField = JsonMissing.of(), - @JsonProperty("maximum_units") - @ExcludeMissing - private val maximumUnits: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Amount per unit */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** Upper bound for this tier */ - fun maximumUnits(): Optional = - Optional.ofNullable(maximumUnits.getNullable("maximum_units")) - - /** Amount per unit */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - /** Upper bound for this tier */ - @JsonProperty("maximum_units") - @ExcludeMissing - fun _maximumUnits(): JsonField = maximumUnits - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - unitAmount() - maximumUnits() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var unitAmount: JsonField? = null - private var maximumUnits: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - unitAmount = tier.unitAmount - maximumUnits = tier.maximumUnits - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Amount per unit */ - fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - - /** Amount per unit */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - /** Upper bound for this tier */ - fun maximumUnits(maximumUnits: Double?) = - maximumUnits(JsonField.ofNullable(maximumUnits)) - - /** Upper bound for this tier */ - fun maximumUnits(maximumUnits: Double) = maximumUnits(maximumUnits as Double?) - - /** Upper bound for this tier */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun maximumUnits(maximumUnits: Optional) = - maximumUnits(maximumUnits.orElse(null) as Double?) - - /** Upper bound for this tier */ - fun maximumUnits(maximumUnits: JsonField) = apply { - this.maximumUnits = maximumUnits - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Tier = - Tier( - checkRequired("unitAmount", unitAmount), - maximumUnits, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tier && unitAmount == other.unitAmount && maximumUnits == other.maximumUnits && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(unitAmount, maximumUnits, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{unitAmount=$unitAmount, maximumUnits=$maximumUnits, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BulkConfig && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkConfig{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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class CreditAllocation - @JsonCreator - private constructor( - @JsonProperty("allows_rollover") - @ExcludeMissing - private val allowsRollover: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun allowsRollover(): Boolean = allowsRollover.getRequired("allows_rollover") - - fun currency(): String = currency.getRequired("currency") - - @JsonProperty("allows_rollover") - @ExcludeMissing - fun _allowsRollover(): JsonField = allowsRollover - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditAllocation = apply { - if (validated) { - return@apply - } - - allowsRollover() - currency() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditAllocation]. */ - class Builder internal constructor() { - - private var allowsRollover: JsonField? = null - private var currency: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditAllocation: CreditAllocation) = apply { - allowsRollover = creditAllocation.allowsRollover - currency = creditAllocation.currency - additionalProperties = creditAllocation.additionalProperties.toMutableMap() - } - - fun allowsRollover(allowsRollover: Boolean) = - allowsRollover(JsonField.of(allowsRollover)) - - fun allowsRollover(allowsRollover: JsonField) = apply { - this.allowsRollover = allowsRollover - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditAllocation = - CreditAllocation( - checkRequired("allowsRollover", allowsRollover), - checkRequired("currency", currency), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditAllocation && allowsRollover == other.allowsRollover && currency == other.currency && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allowsRollover, currency, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditAllocation{allowsRollover=$allowsRollover, currency=$currency, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Item - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun name(): String = name.getRequired("name") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Item = apply { - if (validated) { - return@apply - } - - id() - name() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Item]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(item: Item) = apply { - id = item.id - name = item.name - additionalProperties = item.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun name(name: String) = name(JsonField.of(name)) - - 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) - } - - fun build(): Item = - Item( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Item && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Item{id=$id, name=$name, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Maximum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Maximum amount applied */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Maximum amount applied */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Maximum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - maximumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Maximum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = maximum.maximumAmount - additionalProperties = maximum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Maximum = - Maximum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("maximumAmount", maximumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Maximum && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, maximumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Maximum{appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Minimum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Minimum amount applied */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Minimum amount applied */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Minimum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - minimumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Minimum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var minimumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } - minimumAmount = minimum.minimumAmount - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Minimum = - Minimum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("minimumAmount", minimumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Minimum && appliesToPriceIds == other.appliesToPriceIds && minimumAmount == other.minimumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, minimumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val BULK = of("bulk") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK -> Value.BULK - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - BULK -> Known.BULK - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class PriceType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE_PRICE = of("usage_price") - - @JvmField val FIXED_PRICE = of("fixed_price") - - @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) - } - - /** An enum containing [PriceType]'s known values. */ - enum class Known { - USAGE_PRICE, - FIXED_PRICE, - } - - /** - * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [PriceType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_PRICE, - FIXED_PRICE, - /** - * An enum member indicating that [PriceType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_PRICE -> Value.USAGE_PRICE - FIXED_PRICE -> Value.FIXED_PRICE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE_PRICE -> Known.USAGE_PRICE - FIXED_PRICE -> Known.FIXED_PRICE - else -> throw OrbInvalidDataException("Unknown PriceType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class DimensionalPriceConfiguration - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - private val dimensionalPriceGroupId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun dimensionValues(): List = dimensionValues.getRequired("dimension_values") - - fun dimensionalPriceGroupId(): String = - dimensionalPriceGroupId.getRequired("dimensional_price_group_id") - - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - fun _dimensionalPriceGroupId(): JsonField = dimensionalPriceGroupId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): DimensionalPriceConfiguration = apply { - if (validated) { - return@apply - } - - dimensionValues() - dimensionalPriceGroupId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DimensionalPriceConfiguration]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var dimensionalPriceGroupId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(dimensionalPriceConfiguration: DimensionalPriceConfiguration) = - apply { - dimensionValues = - dimensionalPriceConfiguration.dimensionValues.map { it.toMutableList() } - dimensionalPriceGroupId = - dimensionalPriceConfiguration.dimensionalPriceGroupId - additionalProperties = - dimensionalPriceConfiguration.additionalProperties.toMutableMap() - } - - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: String) = - dimensionalPriceGroupId(JsonField.of(dimensionalPriceGroupId)) - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: JsonField) = apply { - this.dimensionalPriceGroupId = dimensionalPriceGroupId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): DimensionalPriceConfiguration = - DimensionalPriceConfiguration( - checkRequired("dimensionValues", dimensionValues).map { it.toImmutable() }, - checkRequired("dimensionalPriceGroupId", dimensionalPriceGroupId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DimensionalPriceConfiguration && dimensionValues == other.dimensionValues && dimensionalPriceGroupId == other.dimensionalPriceGroupId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, dimensionalPriceGroupId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DimensionalPriceConfiguration{dimensionValues=$dimensionValues, dimensionalPriceGroupId=$dimensionalPriceGroupId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BulkPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && bulkConfig == other.bulkConfig && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, bulkConfig, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, bulkConfig=$bulkConfig, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class ThresholdTotalAmountPrice - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric") - @ExcludeMissing - private val billableMetric: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("credit_allocation") - @ExcludeMissing - private val creditAllocation: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("discount") - @ExcludeMissing - private val discount: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("item") @ExcludeMissing private val item: JsonField = JsonMissing.of(), - @JsonProperty("maximum") - @ExcludeMissing - private val maximum: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("minimum") - @ExcludeMissing - private val minimum: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("price_type") - @ExcludeMissing - private val priceType: JsonField = JsonMissing.of(), - @JsonProperty("threshold_total_amount_config") - @ExcludeMissing - private val thresholdTotalAmountConfig: JsonField = - JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - private val dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun billableMetric(): Optional = - Optional.ofNullable(billableMetric.getNullable("billable_metric")) - - fun billingCycleConfiguration(): BillingCycleConfiguration = - billingCycleConfiguration.getRequired("billing_cycle_configuration") - - fun cadence(): Cadence = cadence.getRequired("cadence") - - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - fun creditAllocation(): Optional = - Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) - - fun currency(): String = currency.getRequired("currency") - - fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) - - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - fun item(): Item = item.getRequired("item") - - fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) - - fun maximumAmount(): Optional = - Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - fun metadata(): Metadata = metadata.getRequired("metadata") - - fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) - - fun minimumAmount(): Optional = - Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) - - fun modelType(): ModelType = modelType.getRequired("model_type") - - fun name(): String = name.getRequired("name") - - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - fun priceType(): PriceType = priceType.getRequired("price_type") - - fun thresholdTotalAmountConfig(): ThresholdTotalAmountConfig = - thresholdTotalAmountConfig.getRequired("threshold_total_amount_config") - - fun dimensionalPriceConfiguration(): Optional = - Optional.ofNullable( - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - ) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("billable_metric") - @ExcludeMissing - fun _billableMetric(): JsonField = billableMetric - - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - @JsonProperty("credit_allocation") - @ExcludeMissing - fun _creditAllocation(): JsonField = creditAllocation - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - - @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = 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`. - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - @JsonProperty("price_type") - @ExcludeMissing - fun _priceType(): JsonField = priceType - - @JsonProperty("threshold_total_amount_config") - @ExcludeMissing - fun _thresholdTotalAmountConfig(): JsonField = - thresholdTotalAmountConfig - - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): ThresholdTotalAmountPrice = apply { - if (validated) { - return@apply - } - - id() - billableMetric().ifPresent { it.validate() } - billingCycleConfiguration().validate() - cadence() - conversionRate() - 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() - name() - planPhaseOrder() - priceType() - thresholdTotalAmountConfig().validate() - dimensionalPriceConfiguration().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ThresholdTotalAmountPrice]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var billableMetric: JsonField? = null - private var billingCycleConfiguration: JsonField? = null - private var cadence: JsonField? = null - private var conversionRate: JsonField? = null - private var 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: JsonField? = null - private var name: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var priceType: JsonField? = null - private var thresholdTotalAmountConfig: JsonField? = null - private var dimensionalPriceConfiguration: JsonField = - JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(thresholdTotalAmountPrice: ThresholdTotalAmountPrice) = apply { - id = thresholdTotalAmountPrice.id - billableMetric = thresholdTotalAmountPrice.billableMetric - billingCycleConfiguration = thresholdTotalAmountPrice.billingCycleConfiguration - cadence = thresholdTotalAmountPrice.cadence - conversionRate = thresholdTotalAmountPrice.conversionRate - createdAt = thresholdTotalAmountPrice.createdAt - creditAllocation = thresholdTotalAmountPrice.creditAllocation - currency = thresholdTotalAmountPrice.currency - discount = thresholdTotalAmountPrice.discount - externalPriceId = thresholdTotalAmountPrice.externalPriceId - fixedPriceQuantity = thresholdTotalAmountPrice.fixedPriceQuantity - invoicingCycleConfiguration = thresholdTotalAmountPrice.invoicingCycleConfiguration - item = thresholdTotalAmountPrice.item - maximum = thresholdTotalAmountPrice.maximum - maximumAmount = thresholdTotalAmountPrice.maximumAmount - metadata = thresholdTotalAmountPrice.metadata - minimum = thresholdTotalAmountPrice.minimum - minimumAmount = thresholdTotalAmountPrice.minimumAmount - modelType = thresholdTotalAmountPrice.modelType - name = thresholdTotalAmountPrice.name - planPhaseOrder = thresholdTotalAmountPrice.planPhaseOrder - priceType = thresholdTotalAmountPrice.priceType - thresholdTotalAmountConfig = thresholdTotalAmountPrice.thresholdTotalAmountConfig - dimensionalPriceConfiguration = - thresholdTotalAmountPrice.dimensionalPriceConfiguration - additionalProperties = thresholdTotalAmountPrice.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun billableMetric(billableMetric: BillableMetric?) = - billableMetric(JsonField.ofNullable(billableMetric)) - - fun billableMetric(billableMetric: Optional) = - billableMetric(billableMetric.orElse(null)) - - fun billableMetric(billableMetric: JsonField) = apply { - this.billableMetric = billableMetric - } - - fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = - billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) - - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) - - fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { - this.createdAt = createdAt - } - - fun creditAllocation(creditAllocation: CreditAllocation?) = - creditAllocation(JsonField.ofNullable(creditAllocation)) - - fun creditAllocation(creditAllocation: Optional) = - creditAllocation(creditAllocation.orElse(null)) - - fun creditAllocation(creditAllocation: JsonField) = apply { - this.creditAllocation = creditAllocation - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) - - fun discount(discount: Optional) = discount(discount.orElse(null)) - - fun discount(discount: JsonField) = apply { this.discount = discount } - - fun discount(percentage: PercentageDiscount) = - discount(Discount.ofPercentage(percentage)) - - fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) - - fun trialDiscount(appliesToPriceIds: List) = - discount( - TrialDiscount.builder() - .discountType(TrialDiscount.DiscountType.TRIAL) - .appliesToPriceIds(appliesToPriceIds) - .build() - ) - - fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) - - fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) - - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } - - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } - - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) - - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - fun item(item: Item) = item(JsonField.of(item)) - - fun item(item: JsonField) = apply { this.item = item } - - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) - - fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.orElse(null)) - - 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) - - fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) - - fun minimumAmount(minimumAmount: Optional) = - minimumAmount(minimumAmount.orElse(null)) - - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } - - fun name(name: String) = name(JsonField.of(name)) - - fun name(name: JsonField) = apply { this.name = name } - - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) - - fun priceType(priceType: JsonField) = apply { this.priceType = priceType } - - fun thresholdTotalAmountConfig(thresholdTotalAmountConfig: ThresholdTotalAmountConfig) = - thresholdTotalAmountConfig(JsonField.of(thresholdTotalAmountConfig)) - - fun thresholdTotalAmountConfig( - thresholdTotalAmountConfig: JsonField - ) = apply { this.thresholdTotalAmountConfig = thresholdTotalAmountConfig } - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: DimensionalPriceConfiguration? - ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional - ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): ThresholdTotalAmountPrice = - ThresholdTotalAmountPrice( - checkRequired("id", id), - checkRequired("billableMetric", billableMetric), - checkRequired("billingCycleConfiguration", billingCycleConfiguration), - checkRequired("cadence", cadence), - checkRequired("conversionRate", conversionRate), - checkRequired("createdAt", createdAt), - checkRequired("creditAllocation", creditAllocation), - checkRequired("currency", currency), - checkRequired("discount", discount), - checkRequired("externalPriceId", externalPriceId), - checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), - checkRequired("item", item), - checkRequired("maximum", maximum), - checkRequired("maximumAmount", maximumAmount), - checkRequired("metadata", metadata), - checkRequired("minimum", minimum), - checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("priceType", priceType), - checkRequired("thresholdTotalAmountConfig", thresholdTotalAmountConfig), - dimensionalPriceConfiguration, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BillableMetric - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillableMetric = apply { - if (validated) { - return@apply - } - - id() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillableMetric]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billableMetric: BillableMetric) = apply { - id = billableMetric.id - additionalProperties = billableMetric.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - 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) - } - - fun build(): BillableMetric = - BillableMetric(checkRequired("id", id), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillableMetric && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillableMetric{id=$id, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class CreditAllocation - @JsonCreator - private constructor( - @JsonProperty("allows_rollover") - @ExcludeMissing - private val allowsRollover: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun allowsRollover(): Boolean = allowsRollover.getRequired("allows_rollover") - - fun currency(): String = currency.getRequired("currency") - - @JsonProperty("allows_rollover") - @ExcludeMissing - fun _allowsRollover(): JsonField = allowsRollover - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditAllocation = apply { - if (validated) { - return@apply - } - - allowsRollover() - currency() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditAllocation]. */ - class Builder internal constructor() { - - private var allowsRollover: JsonField? = null - private var currency: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditAllocation: CreditAllocation) = apply { - allowsRollover = creditAllocation.allowsRollover - currency = creditAllocation.currency - additionalProperties = creditAllocation.additionalProperties.toMutableMap() - } - - fun allowsRollover(allowsRollover: Boolean) = - allowsRollover(JsonField.of(allowsRollover)) - - fun allowsRollover(allowsRollover: JsonField) = apply { - this.allowsRollover = allowsRollover - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditAllocation = - CreditAllocation( - checkRequired("allowsRollover", allowsRollover), - checkRequired("currency", currency), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditAllocation && allowsRollover == other.allowsRollover && currency == other.currency && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allowsRollover, currency, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditAllocation{allowsRollover=$allowsRollover, currency=$currency, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Item - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun name(): String = name.getRequired("name") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Item = apply { - if (validated) { - return@apply - } - - id() - name() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Item]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(item: Item) = apply { - id = item.id - name = item.name - additionalProperties = item.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun name(name: String) = name(JsonField.of(name)) - - 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) - } - - fun build(): Item = - Item( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Item && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Item{id=$id, name=$name, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Maximum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Maximum amount applied */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Maximum amount applied */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Maximum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - maximumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Maximum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = maximum.maximumAmount - additionalProperties = maximum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Maximum = - Maximum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("maximumAmount", maximumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Maximum && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, maximumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Maximum{appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Minimum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Minimum amount applied */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Minimum amount applied */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Minimum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - minimumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Minimum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var minimumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } - minimumAmount = minimum.minimumAmount - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Minimum = - Minimum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("minimumAmount", minimumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Minimum && appliesToPriceIds == other.appliesToPriceIds && minimumAmount == other.minimumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, minimumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val THRESHOLD_TOTAL_AMOUNT = of("threshold_total_amount") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - THRESHOLD_TOTAL_AMOUNT - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - THRESHOLD_TOTAL_AMOUNT, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - THRESHOLD_TOTAL_AMOUNT -> Value.THRESHOLD_TOTAL_AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - THRESHOLD_TOTAL_AMOUNT -> Known.THRESHOLD_TOTAL_AMOUNT - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class PriceType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE_PRICE = of("usage_price") - - @JvmField val FIXED_PRICE = of("fixed_price") - - @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) - } - - /** An enum containing [PriceType]'s known values. */ - enum class Known { - USAGE_PRICE, - FIXED_PRICE, - } - - /** - * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [PriceType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_PRICE, - FIXED_PRICE, - /** - * An enum member indicating that [PriceType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_PRICE -> Value.USAGE_PRICE - FIXED_PRICE -> Value.FIXED_PRICE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE_PRICE -> Known.USAGE_PRICE - FIXED_PRICE -> Known.FIXED_PRICE - else -> throw OrbInvalidDataException("Unknown PriceType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class ThresholdTotalAmountConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): ThresholdTotalAmountConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ThresholdTotalAmountConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(thresholdTotalAmountConfig: ThresholdTotalAmountConfig) = apply { - additionalProperties = - thresholdTotalAmountConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): ThresholdTotalAmountConfig = - ThresholdTotalAmountConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ThresholdTotalAmountConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ThresholdTotalAmountConfig{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class DimensionalPriceConfiguration - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - private val dimensionalPriceGroupId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun dimensionValues(): List = dimensionValues.getRequired("dimension_values") - - fun dimensionalPriceGroupId(): String = - dimensionalPriceGroupId.getRequired("dimensional_price_group_id") - - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - fun _dimensionalPriceGroupId(): JsonField = dimensionalPriceGroupId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): DimensionalPriceConfiguration = apply { - if (validated) { - return@apply - } - - dimensionValues() - dimensionalPriceGroupId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DimensionalPriceConfiguration]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var dimensionalPriceGroupId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(dimensionalPriceConfiguration: DimensionalPriceConfiguration) = - apply { - dimensionValues = - dimensionalPriceConfiguration.dimensionValues.map { it.toMutableList() } - dimensionalPriceGroupId = - dimensionalPriceConfiguration.dimensionalPriceGroupId - additionalProperties = - dimensionalPriceConfiguration.additionalProperties.toMutableMap() - } - - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: String) = - dimensionalPriceGroupId(JsonField.of(dimensionalPriceGroupId)) - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: JsonField) = apply { - this.dimensionalPriceGroupId = dimensionalPriceGroupId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): DimensionalPriceConfiguration = - DimensionalPriceConfiguration( - checkRequired("dimensionValues", dimensionValues).map { it.toImmutable() }, - checkRequired("dimensionalPriceGroupId", dimensionalPriceGroupId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DimensionalPriceConfiguration && dimensionValues == other.dimensionValues && dimensionalPriceGroupId == other.dimensionalPriceGroupId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, dimensionalPriceGroupId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DimensionalPriceConfiguration{dimensionValues=$dimensionValues, dimensionalPriceGroupId=$dimensionalPriceGroupId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ThresholdTotalAmountPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, thresholdTotalAmountConfig, dimensionalPriceConfiguration, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ThresholdTotalAmountPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class TieredPackagePrice - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric") - @ExcludeMissing - private val billableMetric: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("credit_allocation") - @ExcludeMissing - private val creditAllocation: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("discount") - @ExcludeMissing - private val discount: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("item") @ExcludeMissing private val item: JsonField = JsonMissing.of(), - @JsonProperty("maximum") - @ExcludeMissing - private val maximum: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("minimum") - @ExcludeMissing - private val minimum: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("price_type") - @ExcludeMissing - private val priceType: JsonField = JsonMissing.of(), - @JsonProperty("tiered_package_config") - @ExcludeMissing - private val tieredPackageConfig: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - private val dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun billableMetric(): Optional = - Optional.ofNullable(billableMetric.getNullable("billable_metric")) - - fun billingCycleConfiguration(): BillingCycleConfiguration = - billingCycleConfiguration.getRequired("billing_cycle_configuration") - - fun cadence(): Cadence = cadence.getRequired("cadence") - - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - fun creditAllocation(): Optional = - Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) - - fun currency(): String = currency.getRequired("currency") - - fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) - - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - fun item(): Item = item.getRequired("item") - - fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) - - fun maximumAmount(): Optional = - Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - fun metadata(): Metadata = metadata.getRequired("metadata") - - fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) - - fun minimumAmount(): Optional = - Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) - - fun modelType(): ModelType = modelType.getRequired("model_type") - - fun name(): String = name.getRequired("name") - - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - fun priceType(): PriceType = priceType.getRequired("price_type") - - fun tieredPackageConfig(): TieredPackageConfig = - tieredPackageConfig.getRequired("tiered_package_config") - - fun dimensionalPriceConfiguration(): Optional = - Optional.ofNullable( - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - ) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("billable_metric") - @ExcludeMissing - fun _billableMetric(): JsonField = billableMetric - - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - @JsonProperty("credit_allocation") - @ExcludeMissing - fun _creditAllocation(): JsonField = creditAllocation - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - - @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = 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`. - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - @JsonProperty("price_type") - @ExcludeMissing - fun _priceType(): JsonField = priceType - - @JsonProperty("tiered_package_config") - @ExcludeMissing - fun _tieredPackageConfig(): JsonField = tieredPackageConfig - - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredPackagePrice = apply { - if (validated) { - return@apply - } - - id() - billableMetric().ifPresent { it.validate() } - billingCycleConfiguration().validate() - cadence() - conversionRate() - 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() - name() - planPhaseOrder() - priceType() - tieredPackageConfig().validate() - dimensionalPriceConfiguration().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredPackagePrice]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var billableMetric: JsonField? = null - private var billingCycleConfiguration: JsonField? = null - private var cadence: JsonField? = null - private var conversionRate: JsonField? = null - private var 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: JsonField? = null - private var name: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var priceType: JsonField? = null - private var tieredPackageConfig: JsonField? = null - private var dimensionalPriceConfiguration: JsonField = - JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tieredPackagePrice: TieredPackagePrice) = apply { - id = tieredPackagePrice.id - billableMetric = tieredPackagePrice.billableMetric - billingCycleConfiguration = tieredPackagePrice.billingCycleConfiguration - cadence = tieredPackagePrice.cadence - conversionRate = tieredPackagePrice.conversionRate - createdAt = tieredPackagePrice.createdAt - creditAllocation = tieredPackagePrice.creditAllocation - currency = tieredPackagePrice.currency - discount = tieredPackagePrice.discount - externalPriceId = tieredPackagePrice.externalPriceId - fixedPriceQuantity = tieredPackagePrice.fixedPriceQuantity - invoicingCycleConfiguration = tieredPackagePrice.invoicingCycleConfiguration - item = tieredPackagePrice.item - maximum = tieredPackagePrice.maximum - maximumAmount = tieredPackagePrice.maximumAmount - metadata = tieredPackagePrice.metadata - minimum = tieredPackagePrice.minimum - minimumAmount = tieredPackagePrice.minimumAmount - modelType = tieredPackagePrice.modelType - name = tieredPackagePrice.name - planPhaseOrder = tieredPackagePrice.planPhaseOrder - priceType = tieredPackagePrice.priceType - tieredPackageConfig = tieredPackagePrice.tieredPackageConfig - dimensionalPriceConfiguration = tieredPackagePrice.dimensionalPriceConfiguration - additionalProperties = tieredPackagePrice.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun billableMetric(billableMetric: BillableMetric?) = - billableMetric(JsonField.ofNullable(billableMetric)) - - fun billableMetric(billableMetric: Optional) = - billableMetric(billableMetric.orElse(null)) - - fun billableMetric(billableMetric: JsonField) = apply { - this.billableMetric = billableMetric - } - - fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = - billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) - - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) - - fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { - this.createdAt = createdAt - } - - fun creditAllocation(creditAllocation: CreditAllocation?) = - creditAllocation(JsonField.ofNullable(creditAllocation)) - - fun creditAllocation(creditAllocation: Optional) = - creditAllocation(creditAllocation.orElse(null)) - - fun creditAllocation(creditAllocation: JsonField) = apply { - this.creditAllocation = creditAllocation - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) - - fun discount(discount: Optional) = discount(discount.orElse(null)) - - fun discount(discount: JsonField) = apply { this.discount = discount } - - fun discount(percentage: PercentageDiscount) = - discount(Discount.ofPercentage(percentage)) - - fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) - - fun trialDiscount(appliesToPriceIds: List) = - discount( - TrialDiscount.builder() - .discountType(TrialDiscount.DiscountType.TRIAL) - .appliesToPriceIds(appliesToPriceIds) - .build() - ) - - fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) - - fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) - - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } - - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } - - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) - - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - fun item(item: Item) = item(JsonField.of(item)) - - fun item(item: JsonField) = apply { this.item = item } - - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) - - fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.orElse(null)) - - 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) - - fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) - - fun minimumAmount(minimumAmount: Optional) = - minimumAmount(minimumAmount.orElse(null)) - - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } - - fun name(name: String) = name(JsonField.of(name)) - - fun name(name: JsonField) = apply { this.name = name } - - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) - - fun priceType(priceType: JsonField) = apply { this.priceType = priceType } - - fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = - tieredPackageConfig(JsonField.of(tieredPackageConfig)) - - fun tieredPackageConfig(tieredPackageConfig: JsonField) = apply { - this.tieredPackageConfig = tieredPackageConfig - } - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: DimensionalPriceConfiguration? - ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional - ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): TieredPackagePrice = - TieredPackagePrice( - checkRequired("id", id), - checkRequired("billableMetric", billableMetric), - checkRequired("billingCycleConfiguration", billingCycleConfiguration), - checkRequired("cadence", cadence), - checkRequired("conversionRate", conversionRate), - checkRequired("createdAt", createdAt), - checkRequired("creditAllocation", creditAllocation), - checkRequired("currency", currency), - checkRequired("discount", discount), - checkRequired("externalPriceId", externalPriceId), - checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), - checkRequired("item", item), - checkRequired("maximum", maximum), - checkRequired("maximumAmount", maximumAmount), - checkRequired("metadata", metadata), - checkRequired("minimum", minimum), - checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("priceType", priceType), - checkRequired("tieredPackageConfig", tieredPackageConfig), - dimensionalPriceConfiguration, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BillableMetric - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillableMetric = apply { - if (validated) { - return@apply - } - - id() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillableMetric]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billableMetric: BillableMetric) = apply { - id = billableMetric.id - additionalProperties = billableMetric.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - 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) - } - - fun build(): BillableMetric = - BillableMetric(checkRequired("id", id), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillableMetric && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillableMetric{id=$id, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class CreditAllocation - @JsonCreator - private constructor( - @JsonProperty("allows_rollover") - @ExcludeMissing - private val allowsRollover: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun allowsRollover(): Boolean = allowsRollover.getRequired("allows_rollover") - - fun currency(): String = currency.getRequired("currency") - - @JsonProperty("allows_rollover") - @ExcludeMissing - fun _allowsRollover(): JsonField = allowsRollover - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditAllocation = apply { - if (validated) { - return@apply - } - - allowsRollover() - currency() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditAllocation]. */ - class Builder internal constructor() { - - private var allowsRollover: JsonField? = null - private var currency: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditAllocation: CreditAllocation) = apply { - allowsRollover = creditAllocation.allowsRollover - currency = creditAllocation.currency - additionalProperties = creditAllocation.additionalProperties.toMutableMap() - } - - fun allowsRollover(allowsRollover: Boolean) = - allowsRollover(JsonField.of(allowsRollover)) - - fun allowsRollover(allowsRollover: JsonField) = apply { - this.allowsRollover = allowsRollover - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditAllocation = - CreditAllocation( - checkRequired("allowsRollover", allowsRollover), - checkRequired("currency", currency), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditAllocation && allowsRollover == other.allowsRollover && currency == other.currency && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allowsRollover, currency, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditAllocation{allowsRollover=$allowsRollover, currency=$currency, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Item - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun name(): String = name.getRequired("name") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Item = apply { - if (validated) { - return@apply - } - - id() - name() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Item]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(item: Item) = apply { - id = item.id - name = item.name - additionalProperties = item.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun name(name: String) = name(JsonField.of(name)) - - 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) - } - - fun build(): Item = - Item( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Item && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Item{id=$id, name=$name, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Maximum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Maximum amount applied */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Maximum amount applied */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Maximum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - maximumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Maximum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = maximum.maximumAmount - additionalProperties = maximum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Maximum = - Maximum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("maximumAmount", maximumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Maximum && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, maximumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Maximum{appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Minimum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Minimum amount applied */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Minimum amount applied */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Minimum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - minimumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Minimum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var minimumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } - minimumAmount = minimum.minimumAmount - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Minimum = - Minimum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("minimumAmount", minimumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Minimum && appliesToPriceIds == other.appliesToPriceIds && minimumAmount == other.minimumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, minimumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED_PACKAGE = of("tiered_package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_PACKAGE - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_PACKAGE, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_PACKAGE -> Value.TIERED_PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - TIERED_PACKAGE -> Known.TIERED_PACKAGE - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class PriceType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE_PRICE = of("usage_price") - - @JvmField val FIXED_PRICE = of("fixed_price") - - @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) - } - - /** An enum containing [PriceType]'s known values. */ - enum class Known { - USAGE_PRICE, - FIXED_PRICE, - } - - /** - * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [PriceType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_PRICE, - FIXED_PRICE, - /** - * An enum member indicating that [PriceType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_PRICE -> Value.USAGE_PRICE - FIXED_PRICE -> Value.FIXED_PRICE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE_PRICE -> Known.USAGE_PRICE - FIXED_PRICE -> Known.FIXED_PRICE - else -> throw OrbInvalidDataException("Unknown PriceType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TieredPackageConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredPackageConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredPackageConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tieredPackageConfig: TieredPackageConfig) = apply { - additionalProperties = tieredPackageConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): TieredPackageConfig = - TieredPackageConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredPackageConfig{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class DimensionalPriceConfiguration - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - private val dimensionalPriceGroupId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun dimensionValues(): List = dimensionValues.getRequired("dimension_values") - - fun dimensionalPriceGroupId(): String = - dimensionalPriceGroupId.getRequired("dimensional_price_group_id") - - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - fun _dimensionalPriceGroupId(): JsonField = dimensionalPriceGroupId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): DimensionalPriceConfiguration = apply { - if (validated) { - return@apply - } - - dimensionValues() - dimensionalPriceGroupId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DimensionalPriceConfiguration]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var dimensionalPriceGroupId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(dimensionalPriceConfiguration: DimensionalPriceConfiguration) = - apply { - dimensionValues = - dimensionalPriceConfiguration.dimensionValues.map { it.toMutableList() } - dimensionalPriceGroupId = - dimensionalPriceConfiguration.dimensionalPriceGroupId - additionalProperties = - dimensionalPriceConfiguration.additionalProperties.toMutableMap() - } - - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: String) = - dimensionalPriceGroupId(JsonField.of(dimensionalPriceGroupId)) - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: JsonField) = apply { - this.dimensionalPriceGroupId = dimensionalPriceGroupId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): DimensionalPriceConfiguration = - DimensionalPriceConfiguration( - checkRequired("dimensionValues", dimensionValues).map { it.toImmutable() }, - checkRequired("dimensionalPriceGroupId", dimensionalPriceGroupId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DimensionalPriceConfiguration && dimensionValues == other.dimensionValues && dimensionalPriceGroupId == other.dimensionalPriceGroupId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, dimensionalPriceGroupId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DimensionalPriceConfiguration{dimensionValues=$dimensionValues, dimensionalPriceGroupId=$dimensionalPriceGroupId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredPackagePrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && tieredPackageConfig == other.tieredPackageConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, tieredPackageConfig, dimensionalPriceConfiguration, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredPackagePrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, tieredPackageConfig=$tieredPackageConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class GroupedTieredPrice - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric") - @ExcludeMissing - private val billableMetric: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("credit_allocation") - @ExcludeMissing - private val creditAllocation: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("discount") - @ExcludeMissing - private val discount: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("grouped_tiered_config") - @ExcludeMissing - private val groupedTieredConfig: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("item") @ExcludeMissing private val item: JsonField = JsonMissing.of(), - @JsonProperty("maximum") - @ExcludeMissing - private val maximum: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("minimum") - @ExcludeMissing - private val minimum: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("price_type") - @ExcludeMissing - private val priceType: JsonField = JsonMissing.of(), - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - private val dimensionalPriceConfiguration: JsonField = - JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun billableMetric(): Optional = - Optional.ofNullable(billableMetric.getNullable("billable_metric")) - - fun billingCycleConfiguration(): BillingCycleConfiguration = - billingCycleConfiguration.getRequired("billing_cycle_configuration") - - fun cadence(): Cadence = cadence.getRequired("cadence") - - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - fun creditAllocation(): Optional = - Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) - - fun currency(): String = currency.getRequired("currency") - - fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) - - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - fun groupedTieredConfig(): GroupedTieredConfig = - groupedTieredConfig.getRequired("grouped_tiered_config") - - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - fun item(): Item = item.getRequired("item") - - fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) - - fun maximumAmount(): Optional = - Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - fun metadata(): Metadata = metadata.getRequired("metadata") - - fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) - - fun minimumAmount(): Optional = - Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) - - fun modelType(): ModelType = modelType.getRequired("model_type") - - fun name(): String = name.getRequired("name") - - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - fun priceType(): PriceType = priceType.getRequired("price_type") - - fun dimensionalPriceConfiguration(): Optional = - Optional.ofNullable( - dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") - ) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("billable_metric") - @ExcludeMissing - fun _billableMetric(): JsonField = billableMetric - - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - @JsonProperty("credit_allocation") - @ExcludeMissing - fun _creditAllocation(): JsonField = creditAllocation - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - @JsonProperty("grouped_tiered_config") - @ExcludeMissing - fun _groupedTieredConfig(): JsonField = groupedTieredConfig - - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - - @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = 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`. - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - @JsonProperty("price_type") - @ExcludeMissing - fun _priceType(): JsonField = priceType - - @JsonProperty("dimensional_price_configuration") - @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = - dimensionalPriceConfiguration - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): GroupedTieredPrice = apply { - if (validated) { - return@apply - } - - id() - billableMetric().ifPresent { it.validate() } - billingCycleConfiguration().validate() - cadence() - conversionRate() - createdAt() - creditAllocation().ifPresent { it.validate() } - currency() - discount().ifPresent { it.validate() } - externalPriceId() - fixedPriceQuantity() - groupedTieredConfig().validate() - invoicingCycleConfiguration().ifPresent { it.validate() } - item().validate() - maximum().ifPresent { it.validate() } - maximumAmount() - metadata().validate() - minimum().ifPresent { it.validate() } - minimumAmount() - modelType() - name() - planPhaseOrder() - priceType() - dimensionalPriceConfiguration().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [GroupedTieredPrice]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var billableMetric: JsonField? = null - private var billingCycleConfiguration: JsonField? = null - private var cadence: JsonField? = null - private var conversionRate: JsonField? = null - private var 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 groupedTieredConfig: 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: JsonField? = null - private var name: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var priceType: JsonField? = null - private var dimensionalPriceConfiguration: JsonField = - JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(groupedTieredPrice: GroupedTieredPrice) = apply { - id = groupedTieredPrice.id - billableMetric = groupedTieredPrice.billableMetric - billingCycleConfiguration = groupedTieredPrice.billingCycleConfiguration - cadence = groupedTieredPrice.cadence - conversionRate = groupedTieredPrice.conversionRate - createdAt = groupedTieredPrice.createdAt - creditAllocation = groupedTieredPrice.creditAllocation - currency = groupedTieredPrice.currency - discount = groupedTieredPrice.discount - externalPriceId = groupedTieredPrice.externalPriceId - fixedPriceQuantity = groupedTieredPrice.fixedPriceQuantity - groupedTieredConfig = groupedTieredPrice.groupedTieredConfig - invoicingCycleConfiguration = groupedTieredPrice.invoicingCycleConfiguration - item = groupedTieredPrice.item - maximum = groupedTieredPrice.maximum - maximumAmount = groupedTieredPrice.maximumAmount - metadata = groupedTieredPrice.metadata - minimum = groupedTieredPrice.minimum - minimumAmount = groupedTieredPrice.minimumAmount - modelType = groupedTieredPrice.modelType - name = groupedTieredPrice.name - planPhaseOrder = groupedTieredPrice.planPhaseOrder - priceType = groupedTieredPrice.priceType - dimensionalPriceConfiguration = groupedTieredPrice.dimensionalPriceConfiguration - additionalProperties = groupedTieredPrice.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun billableMetric(billableMetric: BillableMetric?) = - billableMetric(JsonField.ofNullable(billableMetric)) - - fun billableMetric(billableMetric: Optional) = - billableMetric(billableMetric.orElse(null)) - - fun billableMetric(billableMetric: JsonField) = apply { - this.billableMetric = billableMetric - } - - fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = - billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) - - fun billingCycleConfiguration( - billingCycleConfiguration: JsonField - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - fun conversionRate(conversionRate: Double?) = - conversionRate(JsonField.ofNullable(conversionRate)) - - fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { - this.createdAt = createdAt - } - - fun creditAllocation(creditAllocation: CreditAllocation?) = - creditAllocation(JsonField.ofNullable(creditAllocation)) - - fun creditAllocation(creditAllocation: Optional) = - creditAllocation(creditAllocation.orElse(null)) - - fun creditAllocation(creditAllocation: JsonField) = apply { - this.creditAllocation = creditAllocation - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) - - fun discount(discount: Optional) = discount(discount.orElse(null)) - - fun discount(discount: JsonField) = apply { this.discount = discount } - - fun discount(percentage: PercentageDiscount) = - discount(Discount.ofPercentage(percentage)) - - fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) - - fun trialDiscount(appliesToPriceIds: List) = - discount( - TrialDiscount.builder() - .discountType(TrialDiscount.DiscountType.TRIAL) - .appliesToPriceIds(appliesToPriceIds) - .build() - ) - - fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) - - fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) - - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } - - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = - fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } - - fun groupedTieredConfig(groupedTieredConfig: GroupedTieredConfig) = - groupedTieredConfig(JsonField.of(groupedTieredConfig)) - - fun groupedTieredConfig(groupedTieredConfig: JsonField) = apply { - this.groupedTieredConfig = groupedTieredConfig - } - - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) - - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - fun item(item: Item) = item(JsonField.of(item)) - - fun item(item: JsonField) = apply { this.item = item } - - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) - - fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.orElse(null)) - - 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) - - fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) - - fun minimumAmount(minimumAmount: Optional) = - minimumAmount(minimumAmount.orElse(null)) - - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } - - fun name(name: String) = name(JsonField.of(name)) - - fun name(name: JsonField) = apply { this.name = name } - - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) - - fun priceType(priceType: JsonField) = apply { this.priceType = priceType } - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: DimensionalPriceConfiguration? - ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional - ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): GroupedTieredPrice = - GroupedTieredPrice( - checkRequired("id", id), - checkRequired("billableMetric", billableMetric), - checkRequired("billingCycleConfiguration", billingCycleConfiguration), - checkRequired("cadence", cadence), - checkRequired("conversionRate", conversionRate), - checkRequired("createdAt", createdAt), - checkRequired("creditAllocation", creditAllocation), - checkRequired("currency", currency), - checkRequired("discount", discount), - checkRequired("externalPriceId", externalPriceId), - checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired("groupedTieredConfig", groupedTieredConfig), - checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), - checkRequired("item", item), - checkRequired("maximum", maximum), - checkRequired("maximumAmount", maximumAmount), - checkRequired("metadata", metadata), - checkRequired("minimum", minimum), - checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("priceType", priceType), - dimensionalPriceConfiguration, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BillableMetric - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillableMetric = apply { - if (validated) { - return@apply - } - - id() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillableMetric]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billableMetric: BillableMetric) = apply { - id = billableMetric.id - additionalProperties = billableMetric.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - 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) - } - - fun build(): BillableMetric = - BillableMetric(checkRequired("id", id), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillableMetric && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillableMetric{id=$id, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class CreditAllocation - @JsonCreator - private constructor( - @JsonProperty("allows_rollover") - @ExcludeMissing - private val allowsRollover: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun allowsRollover(): Boolean = allowsRollover.getRequired("allows_rollover") - - fun currency(): String = currency.getRequired("currency") - - @JsonProperty("allows_rollover") - @ExcludeMissing - fun _allowsRollover(): JsonField = allowsRollover - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditAllocation = apply { - if (validated) { - return@apply - } - - allowsRollover() - currency() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditAllocation]. */ - class Builder internal constructor() { - - private var allowsRollover: JsonField? = null - private var currency: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditAllocation: CreditAllocation) = apply { - allowsRollover = creditAllocation.allowsRollover - currency = creditAllocation.currency - additionalProperties = creditAllocation.additionalProperties.toMutableMap() - } - - fun allowsRollover(allowsRollover: Boolean) = - allowsRollover(JsonField.of(allowsRollover)) - - fun allowsRollover(allowsRollover: JsonField) = apply { - this.allowsRollover = allowsRollover - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditAllocation = - CreditAllocation( - checkRequired("allowsRollover", allowsRollover), - checkRequired("currency", currency), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditAllocation && allowsRollover == other.allowsRollover && currency == other.currency && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allowsRollover, currency, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditAllocation{allowsRollover=$allowsRollover, currency=$currency, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class GroupedTieredConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): GroupedTieredConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [GroupedTieredConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(groupedTieredConfig: GroupedTieredConfig) = apply { - additionalProperties = groupedTieredConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): GroupedTieredConfig = - GroupedTieredConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GroupedTieredConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedTieredConfig{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } + fun _planPhaseOrder(): JsonField = planPhaseOrder - fun duration(duration: Long) = duration(JsonField.of(duration)) + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType - fun duration(duration: JsonField) = apply { this.duration = duration } + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } + private var validated: Boolean = false - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun validate(): PackagePrice = apply { + if (validated) { + return@apply + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + cadence() + conversionRate() + 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() + name() + packageConfig().validate() + planPhaseOrder() + priceType() + dimensionalPriceConfiguration().ifPresent { it.validate() } + validated = true + } - 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 [PackagePrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .packageConfig() + * .planPhaseOrder() + * .priceType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } + /** A builder for [PackagePrice]. */ + class Builder internal constructor() { - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var 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: JsonField? = null + private var name: JsonField? = null + private var packageConfig: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = 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 + @JvmSynthetic + internal fun from(packagePrice: PackagePrice) = apply { + id = packagePrice.id + billableMetric = packagePrice.billableMetric + billingCycleConfiguration = packagePrice.billingCycleConfiguration + cadence = packagePrice.cadence + conversionRate = packagePrice.conversionRate + createdAt = packagePrice.createdAt + creditAllocation = packagePrice.creditAllocation + currency = packagePrice.currency + discount = packagePrice.discount + externalPriceId = packagePrice.externalPriceId + fixedPriceQuantity = packagePrice.fixedPriceQuantity + invoicingCycleConfiguration = packagePrice.invoicingCycleConfiguration + item = packagePrice.item + maximum = packagePrice.maximum + maximumAmount = packagePrice.maximumAmount + metadata = packagePrice.metadata + minimum = packagePrice.minimum + minimumAmount = packagePrice.minimumAmount + modelType = packagePrice.modelType + name = packagePrice.name + packageConfig = packagePrice.packageConfig + planPhaseOrder = packagePrice.planPhaseOrder + priceType = packagePrice.priceType + dimensionalPriceConfiguration = packagePrice.dimensionalPriceConfiguration + additionalProperties = packagePrice.additionalProperties.toMutableMap() + } - companion object { + fun id(id: String) = id(JsonField.of(id)) - @JvmField val DAY = of("day") + fun id(id: JsonField) = apply { this.id = id } - @JvmField val MONTH = of("month") + fun billableMetric(billableMetric: BillableMetricTinyModel?) = + billableMetric(JsonField.ofNullable(billableMetric)) - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.MONTH - else -> Value._UNKNOWN - } + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = 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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 cadence(cadence: JsonField) = apply { this.cadence = cadence } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) - override fun hashCode() = value.hashCode() + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) - override fun toString() = value.toString() + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ + fun creditAllocation(creditAllocation: AllocationModel?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) - override fun hashCode(): Int = hashCode + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } - @NoAutoDetect - class Item - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + fun currency(currency: String) = currency(JsonField.of(currency)) - fun id(): String = id.getRequired("id") + fun currency(currency: JsonField) = apply { this.currency = currency } - fun name(): String = name.getRequired("name") + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + fun discount(discount: Optional) = discount(discount.orElse(null)) - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + fun discount(discount: JsonField) = apply { this.discount = discount } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) - private var validated: Boolean = false + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) - fun validate(): Item = apply { - if (validated) { - return@apply - } + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) - id() - name() - validated = true - } + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) - fun toBuilder() = Builder().from(this) + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) - companion object { + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - @JvmStatic fun builder() = Builder() + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId } - /** A builder for [Item]. */ - class Builder internal constructor() { + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - @JvmSynthetic - internal fun from(item: Item) = apply { - id = item.id - name = item.name - additionalProperties = item.additionalProperties.toMutableMap() - } + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - fun id(id: String) = id(JsonField.of(id)) + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - fun id(id: JsonField) = apply { this.id = id } + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - fun name(name: String) = name(JsonField.of(name)) + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) - fun name(name: JsonField) = apply { this.name = name } + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun item(item: ItemSlimModel) = item(JsonField.of(item)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun item(item: JsonField) = apply { this.item = item } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - fun build(): Item = - Item( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toImmutable(), - ) - } + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) - return /* spotless:off */ other is Item && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Item{id=$id, name=$name, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Maximum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. + * 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 appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Maximum amount applied */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. + * 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("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - /** Maximum amount applied */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - private var validated: Boolean = false + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - fun validate(): Maximum = apply { - if (validated) { - return@apply - } + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) - appliesToPriceIds() - maximumAmount() - validated = true - } + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) - fun toBuilder() = Builder().from(this) + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } - companion object { + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - @JvmStatic fun builder() = Builder() - } + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } - /** A builder for [Maximum]. */ - class Builder internal constructor() { + fun name(name: String) = name(JsonField.of(name)) - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun name(name: JsonField) = apply { this.name = name } - @JvmSynthetic - internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = maximum.maximumAmount - additionalProperties = maximum.additionalProperties.toMutableMap() - } + fun packageConfig(packageConfig: PackageConfigModel) = + packageConfig(JsonField.of(packageConfig)) - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) + fun packageConfig(packageConfig: JsonField) = apply { + this.packageConfig = packageConfig + } - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - fun build(): Maximum = - Maximum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("maximumAmount", maximumAmount), - additionalProperties.toImmutable(), - ) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - return /* spotless:off */ other is Maximum && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && additionalProperties == other.additionalProperties /* spotless:on */ + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, maximumAmount, additionalProperties) } - /* spotless:on */ + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - override fun hashCode(): Int = hashCode + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun toString() = - "Maximum{appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, additionalProperties=$additionalProperties}" + fun build(): PackagePrice = + PackagePrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("packageConfig", packageConfig), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) } - /** - * 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - validated = true - } + companion object { - fun toBuilder() = Builder().from(this) + @JvmField val ONE_TIME = of("one_time") - companion object { + @JvmField val MONTHLY = of("monthly") - @JvmStatic fun builder() = Builder() - } + @JvmField val QUARTERLY = of("quarterly") - /** A builder for [Metadata]. */ - class Builder internal constructor() { + @JvmField val SEMI_ANNUAL = of("semi_annual") - private var additionalProperties: MutableMap = mutableMapOf() + @JvmField val ANNUAL = of("annual") - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + @JvmField val CUSTOM = of("custom") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown value. + */ + _UNKNOWN, + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + 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 removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + 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 build(): Metadata = Metadata(additionalProperties.toImmutable()) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ @NoAutoDetect - class Minimum + class Metadata @JsonCreator private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Minimum amount applied */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Minimum amount applied */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties private var validated: Boolean = false - fun validate(): Minimum = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } - appliesToPriceIds() - minimumAmount() validated = true } @@ -27779,62 +2820,18 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [Minimum]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { - private var appliesToPriceIds: JsonField>? = null - private var minimumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } - minimumAmount = minimum.minimumAmount - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -27859,14 +2856,7 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): Minimum = - Minimum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("minimumAmount", minimumAmount), - additionalProperties.toImmutable(), - ) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -27874,17 +2864,16 @@ private constructor( return true } - return /* spotless:off */ other is Minimum && appliesToPriceIds == other.appliesToPriceIds && minimumAmount == other.minimumAmount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, minimumAmount, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode - override fun toString() = - "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } class ModelType @JsonCreator private constructor(private val value: JsonField) : @@ -27902,14 +2891,14 @@ private constructor( companion object { - @JvmField val GROUPED_TIERED = of("grouped_tiered") + @JvmField val PACKAGE = of("package") @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } /** An enum containing [ModelType]'s known values. */ enum class Known { - GROUPED_TIERED + PACKAGE } /** @@ -27922,7 +2911,7 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - GROUPED_TIERED, + PACKAGE, /** * An enum member indicating that [ModelType] was instantiated with an unknown * value. @@ -27939,7 +2928,7 @@ private constructor( */ fun value(): Value = when (this) { - GROUPED_TIERED -> Value.GROUPED_TIERED + PACKAGE -> Value.PACKAGE else -> Value._UNKNOWN } @@ -27954,7 +2943,7 @@ private constructor( */ fun known(): Known = when (this) { - GROUPED_TIERED -> Known.GROUPED_TIERED + PACKAGE -> Known.PACKAGE else -> throw OrbInvalidDataException("Unknown ModelType: $value") } @@ -28085,178 +3074,35 @@ private constructor( override fun toString() = value.toString() } - @NoAutoDetect - class DimensionalPriceConfiguration - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - private val dimensionalPriceGroupId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun dimensionValues(): List = dimensionValues.getRequired("dimension_values") - - fun dimensionalPriceGroupId(): String = - dimensionalPriceGroupId.getRequired("dimensional_price_group_id") - - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - fun _dimensionalPriceGroupId(): JsonField = dimensionalPriceGroupId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): DimensionalPriceConfiguration = apply { - if (validated) { - return@apply - } - - dimensionValues() - dimensionalPriceGroupId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DimensionalPriceConfiguration]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var dimensionalPriceGroupId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(dimensionalPriceConfiguration: DimensionalPriceConfiguration) = - apply { - dimensionValues = - dimensionalPriceConfiguration.dimensionValues.map { it.toMutableList() } - dimensionalPriceGroupId = - dimensionalPriceConfiguration.dimensionalPriceGroupId - additionalProperties = - dimensionalPriceConfiguration.additionalProperties.toMutableMap() - } - - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: String) = - dimensionalPriceGroupId(JsonField.of(dimensionalPriceGroupId)) - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: JsonField) = apply { - this.dimensionalPriceGroupId = dimensionalPriceGroupId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): DimensionalPriceConfiguration = - DimensionalPriceConfiguration( - checkRequired("dimensionValues", dimensionValues).map { it.toImmutable() }, - checkRequired("dimensionalPriceGroupId", dimensionalPriceGroupId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DimensionalPriceConfiguration && dimensionValues == other.dimensionValues && dimensionalPriceGroupId == other.dimensionalPriceGroupId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, dimensionalPriceGroupId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DimensionalPriceConfiguration{dimensionValues=$dimensionValues, dimensionalPriceGroupId=$dimensionalPriceGroupId, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is GroupedTieredPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && groupedTieredConfig == other.groupedTieredConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PackagePrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && packageConfig == other.packageConfig && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, groupedTieredConfig, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, packageConfig, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "GroupedTieredPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedTieredConfig=$groupedTieredConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "PackagePrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, packageConfig=$packageConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } @NoAutoDetect - class TieredWithMinimumPrice + class MatrixPrice @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("billable_metric") @ExcludeMissing - private val billableMetric: JsonField = JsonMissing.of(), + private val billableMetric: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") @ExcludeMissing - private val billingCycleConfiguration: JsonField = + private val billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing @@ -28269,7 +3115,7 @@ private constructor( private val createdAt: JsonField = JsonMissing.of(), @JsonProperty("credit_allocation") @ExcludeMissing - private val creditAllocation: JsonField = JsonMissing.of(), + private val creditAllocation: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing private val currency: JsonField = JsonMissing.of(), @@ -28284,12 +3130,17 @@ private constructor( private val fixedPriceQuantity: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = + private val invoicingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("item") @ExcludeMissing private val item: JsonField = JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("matrix_config") + @ExcludeMissing + private val matrixConfig: JsonField = JsonMissing.of(), @JsonProperty("maximum") @ExcludeMissing - private val maximum: JsonField = JsonMissing.of(), + private val maximum: JsonField = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing private val maximumAmount: JsonField = JsonMissing.of(), @@ -28298,7 +3149,7 @@ private constructor( private val metadata: JsonField = JsonMissing.of(), @JsonProperty("minimum") @ExcludeMissing - private val minimum: JsonField = JsonMissing.of(), + private val minimum: JsonField = JsonMissing.of(), @JsonProperty("minimum_amount") @ExcludeMissing private val minimumAmount: JsonField = JsonMissing.of(), @@ -28314,12 +3165,9 @@ private constructor( @JsonProperty("price_type") @ExcludeMissing private val priceType: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_minimum_config") - @ExcludeMissing - private val tieredWithMinimumConfig: JsonField = JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing - private val dimensionalPriceConfiguration: JsonField = + private val dimensionalPriceConfiguration: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), @@ -28327,10 +3175,10 @@ private constructor( fun id(): String = id.getRequired("id") - fun billableMetric(): Optional = + fun billableMetric(): Optional = Optional.ofNullable(billableMetric.getNullable("billable_metric")) - fun billingCycleConfiguration(): BillingCycleConfiguration = + fun billingCycleConfiguration(): BillingCycleConfigurationModel = billingCycleConfiguration.getRequired("billing_cycle_configuration") fun cadence(): Cadence = cadence.getRequired("cadence") @@ -28340,7 +3188,7 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - fun creditAllocation(): Optional = + fun creditAllocation(): Optional = Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) fun currency(): String = currency.getRequired("currency") @@ -28353,14 +3201,16 @@ private constructor( fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - fun invoicingCycleConfiguration(): Optional = + fun invoicingCycleConfiguration(): Optional = Optional.ofNullable( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") ) - fun item(): Item = item.getRequired("item") + fun item(): ItemSlimModel = item.getRequired("item") - fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + fun matrixConfig(): MatrixConfigModel = matrixConfig.getRequired("matrix_config") + + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) @@ -28372,7 +3222,7 @@ private constructor( */ fun metadata(): Metadata = metadata.getRequired("metadata") - fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) fun minimumAmount(): Optional = Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) @@ -28386,10 +3236,7 @@ private constructor( fun priceType(): PriceType = priceType.getRequired("price_type") - fun tieredWithMinimumConfig(): TieredWithMinimumConfig = - tieredWithMinimumConfig.getRequired("tiered_with_minimum_config") - - fun dimensionalPriceConfiguration(): Optional = + fun dimensionalPriceConfiguration(): Optional = Optional.ofNullable( dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") ) @@ -28398,11 +3245,11 @@ private constructor( @JsonProperty("billable_metric") @ExcludeMissing - fun _billableMetric(): JsonField = billableMetric + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = + fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence @@ -28417,7 +3264,7 @@ private constructor( @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation(): JsonField = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @@ -28433,12 +3280,16 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = + fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + @JsonProperty("matrix_config") + @ExcludeMissing + fun _matrixConfig(): JsonField = matrixConfig - @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum @JsonProperty("maximum_amount") @ExcludeMissing @@ -28451,7 +3302,7 @@ private constructor( */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum @JsonProperty("minimum_amount") @ExcludeMissing @@ -28471,13 +3322,9 @@ private constructor( @ExcludeMissing fun _priceType(): JsonField = priceType - @JsonProperty("tiered_with_minimum_config") - @ExcludeMissing - fun _tieredWithMinimumConfig(): JsonField = tieredWithMinimumConfig - @JsonProperty("dimensional_price_configuration") @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = + fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration @JsonAnyGetter @@ -28486,7 +3333,7 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithMinimumPrice = apply { + fun validate(): MatrixPrice = apply { if (validated) { return@apply } @@ -28504,6 +3351,7 @@ private constructor( fixedPriceQuantity() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() + matrixConfig().validate() maximum().ifPresent { it.validate() } maximumAmount() metadata().validate() @@ -28513,7 +3361,6 @@ private constructor( name() planPhaseOrder() priceType() - tieredWithMinimumConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } validated = true } @@ -28522,87 +3369,120 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [MatrixPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .matrixConfig() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [TieredWithMinimumPrice]. */ + /** A builder for [MatrixPrice]. */ class Builder internal constructor() { private var id: JsonField? = null - private var billableMetric: JsonField? = null - private var billingCycleConfiguration: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null private var cadence: JsonField? = null private var conversionRate: JsonField? = null private var createdAt: JsonField? = null - private var creditAllocation: 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 invoicingCycleConfiguration: JsonField? = + null + private var item: JsonField? = null + private var matrixConfig: JsonField? = null + private var maximum: JsonField? = null private var maximumAmount: JsonField? = null private var metadata: JsonField? = null - private var minimum: JsonField? = null + private var minimum: JsonField? = null private var minimumAmount: JsonField? = null private var modelType: JsonField? = null private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null - private var tieredWithMinimumConfig: JsonField? = null - private var dimensionalPriceConfiguration: JsonField = + private var dimensionalPriceConfiguration: + JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredWithMinimumPrice: TieredWithMinimumPrice) = apply { - id = tieredWithMinimumPrice.id - billableMetric = tieredWithMinimumPrice.billableMetric - billingCycleConfiguration = tieredWithMinimumPrice.billingCycleConfiguration - cadence = tieredWithMinimumPrice.cadence - conversionRate = tieredWithMinimumPrice.conversionRate - createdAt = tieredWithMinimumPrice.createdAt - creditAllocation = tieredWithMinimumPrice.creditAllocation - currency = tieredWithMinimumPrice.currency - discount = tieredWithMinimumPrice.discount - externalPriceId = tieredWithMinimumPrice.externalPriceId - fixedPriceQuantity = tieredWithMinimumPrice.fixedPriceQuantity - invoicingCycleConfiguration = tieredWithMinimumPrice.invoicingCycleConfiguration - item = tieredWithMinimumPrice.item - maximum = tieredWithMinimumPrice.maximum - maximumAmount = tieredWithMinimumPrice.maximumAmount - metadata = tieredWithMinimumPrice.metadata - minimum = tieredWithMinimumPrice.minimum - minimumAmount = tieredWithMinimumPrice.minimumAmount - modelType = tieredWithMinimumPrice.modelType - name = tieredWithMinimumPrice.name - planPhaseOrder = tieredWithMinimumPrice.planPhaseOrder - priceType = tieredWithMinimumPrice.priceType - tieredWithMinimumConfig = tieredWithMinimumPrice.tieredWithMinimumConfig - dimensionalPriceConfiguration = tieredWithMinimumPrice.dimensionalPriceConfiguration - additionalProperties = tieredWithMinimumPrice.additionalProperties.toMutableMap() + internal fun from(matrixPrice: MatrixPrice) = apply { + id = matrixPrice.id + billableMetric = matrixPrice.billableMetric + billingCycleConfiguration = matrixPrice.billingCycleConfiguration + cadence = matrixPrice.cadence + conversionRate = matrixPrice.conversionRate + createdAt = matrixPrice.createdAt + creditAllocation = matrixPrice.creditAllocation + currency = matrixPrice.currency + discount = matrixPrice.discount + externalPriceId = matrixPrice.externalPriceId + fixedPriceQuantity = matrixPrice.fixedPriceQuantity + invoicingCycleConfiguration = matrixPrice.invoicingCycleConfiguration + item = matrixPrice.item + matrixConfig = matrixPrice.matrixConfig + maximum = matrixPrice.maximum + maximumAmount = matrixPrice.maximumAmount + metadata = matrixPrice.metadata + minimum = matrixPrice.minimum + minimumAmount = matrixPrice.minimumAmount + modelType = matrixPrice.modelType + name = matrixPrice.name + planPhaseOrder = matrixPrice.planPhaseOrder + priceType = matrixPrice.priceType + dimensionalPriceConfiguration = matrixPrice.dimensionalPriceConfiguration + additionalProperties = matrixPrice.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric?) = + fun billableMetric(billableMetric: BillableMetricTinyModel?) = billableMetric(JsonField.ofNullable(billableMetric)) - fun billableMetric(billableMetric: Optional) = + fun billableMetric(billableMetric: Optional) = billableMetric(billableMetric.orElse(null)) - fun billableMetric(billableMetric: JsonField) = apply { + fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric } - fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = - billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) fun billingCycleConfiguration( - billingCycleConfiguration: JsonField + billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -28628,13 +3508,13 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation?) = + fun creditAllocation(creditAllocation: AllocationModel?) = creditAllocation(JsonField.ofNullable(creditAllocation)) - fun creditAllocation(creditAllocation: Optional) = + fun creditAllocation(creditAllocation: Optional) = creditAllocation(creditAllocation.orElse(null)) - fun creditAllocation(creditAllocation: JsonField) = apply { + fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation } @@ -28690,26 +3570,33 @@ private constructor( } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? + invoicingCycleConfiguration: BillingCycleConfigurationModel? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional + invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField + invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun item(item: Item) = item(JsonField.of(item)) + fun item(item: ItemSlimModel) = item(JsonField.of(item)) + + fun item(item: JsonField) = apply { this.item = item } - fun item(item: JsonField) = apply { this.item = item } + fun matrixConfig(matrixConfig: MatrixConfigModel) = + matrixConfig(JsonField.of(matrixConfig)) - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + fun matrixConfig(matrixConfig: JsonField) = apply { + this.matrixConfig = matrixConfig + } - fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } fun maximumAmount(maximumAmount: String?) = maximumAmount(JsonField.ofNullable(maximumAmount)) @@ -28735,11 +3622,11 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) - fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } fun minimumAmount(minimumAmount: String?) = minimumAmount(JsonField.ofNullable(minimumAmount)) @@ -28776,23 +3663,16 @@ private constructor( fun priceType(priceType: JsonField) = apply { this.priceType = priceType } - fun tieredWithMinimumConfig(tieredWithMinimumConfig: TieredWithMinimumConfig) = - tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) - - fun tieredWithMinimumConfig( - tieredWithMinimumConfig: JsonField - ) = apply { this.tieredWithMinimumConfig = tieredWithMinimumConfig } - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: DimensionalPriceConfiguration? + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional + dimensionalPriceConfiguration: Optional ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField + dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } fun additionalProperties(additionalProperties: Map) = apply { @@ -28800,372 +3680,48 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): TieredWithMinimumPrice = - TieredWithMinimumPrice( - checkRequired("id", id), - checkRequired("billableMetric", billableMetric), - checkRequired("billingCycleConfiguration", billingCycleConfiguration), - checkRequired("cadence", cadence), - checkRequired("conversionRate", conversionRate), - checkRequired("createdAt", createdAt), - checkRequired("creditAllocation", creditAllocation), - checkRequired("currency", currency), - checkRequired("discount", discount), - checkRequired("externalPriceId", externalPriceId), - checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), - checkRequired("item", item), - checkRequired("maximum", maximum), - checkRequired("maximumAmount", maximumAmount), - checkRequired("metadata", metadata), - checkRequired("minimum", minimum), - checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("priceType", priceType), - checkRequired("tieredWithMinimumConfig", tieredWithMinimumConfig), - dimensionalPriceConfiguration, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BillableMetric - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillableMetric = apply { - if (validated) { - return@apply - } - - id() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillableMetric]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billableMetric: BillableMetric) = apply { - id = billableMetric.id - additionalProperties = billableMetric.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - 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) - } - - fun build(): BillableMetric = - BillableMetric(checkRequired("id", id), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillableMetric && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillableMetric{id=$id, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - override fun hashCode(): Int = hashCode + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + fun build(): MatrixPrice = + MatrixPrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + 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("matrixConfig", matrixConfig), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) } class Cadence @JsonCreator private constructor(private val value: JsonField) : @@ -29293,634 +3849,6 @@ private constructor( override fun toString() = value.toString() } - @NoAutoDetect - class CreditAllocation - @JsonCreator - private constructor( - @JsonProperty("allows_rollover") - @ExcludeMissing - private val allowsRollover: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun allowsRollover(): Boolean = allowsRollover.getRequired("allows_rollover") - - fun currency(): String = currency.getRequired("currency") - - @JsonProperty("allows_rollover") - @ExcludeMissing - fun _allowsRollover(): JsonField = allowsRollover - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditAllocation = apply { - if (validated) { - return@apply - } - - allowsRollover() - currency() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditAllocation]. */ - class Builder internal constructor() { - - private var allowsRollover: JsonField? = null - private var currency: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditAllocation: CreditAllocation) = apply { - allowsRollover = creditAllocation.allowsRollover - currency = creditAllocation.currency - additionalProperties = creditAllocation.additionalProperties.toMutableMap() - } - - fun allowsRollover(allowsRollover: Boolean) = - allowsRollover(JsonField.of(allowsRollover)) - - fun allowsRollover(allowsRollover: JsonField) = apply { - this.allowsRollover = allowsRollover - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditAllocation = - CreditAllocation( - checkRequired("allowsRollover", allowsRollover), - checkRequired("currency", currency), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditAllocation && allowsRollover == other.allowsRollover && currency == other.currency && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allowsRollover, currency, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditAllocation{allowsRollover=$allowsRollover, currency=$currency, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Item - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun name(): String = name.getRequired("name") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Item = apply { - if (validated) { - return@apply - } - - id() - name() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Item]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(item: Item) = apply { - id = item.id - name = item.name - additionalProperties = item.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun name(name: String) = name(JsonField.of(name)) - - 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) - } - - fun build(): Item = - Item( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Item && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Item{id=$id, name=$name, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Maximum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Maximum amount applied */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Maximum amount applied */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Maximum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - maximumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Maximum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = maximum.maximumAmount - additionalProperties = maximum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Maximum = - Maximum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("maximumAmount", maximumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Maximum && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, maximumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Maximum{appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, 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 @@ -29932,117 +3860,7 @@ private constructor( private constructor( @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Minimum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Minimum amount applied */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Minimum amount applied */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount + ) { @JsonAnyGetter @ExcludeMissing @@ -30050,13 +3868,11 @@ private constructor( private var validated: Boolean = false - fun validate(): Minimum = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } - appliesToPriceIds() - minimumAmount() validated = true } @@ -30064,62 +3880,18 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [Minimum]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { - private var appliesToPriceIds: JsonField>? = null - private var minimumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } - minimumAmount = minimum.minimumAmount - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -30144,14 +3916,7 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): Minimum = - Minimum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("minimumAmount", minimumAmount), - additionalProperties.toImmutable(), - ) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -30159,17 +3924,16 @@ private constructor( return true } - return /* spotless:off */ other is Minimum && appliesToPriceIds == other.appliesToPriceIds && minimumAmount == other.minimumAmount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, minimumAmount, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode - override fun toString() = - "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } class ModelType @JsonCreator private constructor(private val value: JsonField) : @@ -30187,14 +3951,14 @@ private constructor( companion object { - @JvmField val TIERED_WITH_MINIMUM = of("tiered_with_minimum") + @JvmField val MATRIX = of("matrix") @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } /** An enum containing [ModelType]'s known values. */ enum class Known { - TIERED_WITH_MINIMUM + MATRIX } /** @@ -30207,7 +3971,7 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - TIERED_WITH_MINIMUM, + MATRIX, /** * An enum member indicating that [ModelType] was instantiated with an unknown * value. @@ -30224,7 +3988,7 @@ private constructor( */ fun value(): Value = when (this) { - TIERED_WITH_MINIMUM -> Value.TIERED_WITH_MINIMUM + MATRIX -> Value.MATRIX else -> Value._UNKNOWN } @@ -30239,7 +4003,7 @@ private constructor( */ fun known(): Known = when (this) { - TIERED_WITH_MINIMUM -> Known.TIERED_WITH_MINIMUM + MATRIX -> Known.MATRIX else -> throw OrbInvalidDataException("Unknown ModelType: $value") } @@ -30370,262 +4134,35 @@ private constructor( override fun toString() = value.toString() } - @NoAutoDetect - class TieredWithMinimumConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredWithMinimumConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredWithMinimumConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tieredWithMinimumConfig: TieredWithMinimumConfig) = apply { - additionalProperties = - tieredWithMinimumConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): TieredWithMinimumConfig = - TieredWithMinimumConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredWithMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredWithMinimumConfig{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class DimensionalPriceConfiguration - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - private val dimensionalPriceGroupId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun dimensionValues(): List = dimensionValues.getRequired("dimension_values") - - fun dimensionalPriceGroupId(): String = - dimensionalPriceGroupId.getRequired("dimensional_price_group_id") - - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - fun _dimensionalPriceGroupId(): JsonField = dimensionalPriceGroupId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): DimensionalPriceConfiguration = apply { - if (validated) { - return@apply - } - - dimensionValues() - dimensionalPriceGroupId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DimensionalPriceConfiguration]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var dimensionalPriceGroupId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(dimensionalPriceConfiguration: DimensionalPriceConfiguration) = - apply { - dimensionValues = - dimensionalPriceConfiguration.dimensionValues.map { it.toMutableList() } - dimensionalPriceGroupId = - dimensionalPriceConfiguration.dimensionalPriceGroupId - additionalProperties = - dimensionalPriceConfiguration.additionalProperties.toMutableMap() - } - - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: String) = - dimensionalPriceGroupId(JsonField.of(dimensionalPriceGroupId)) - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: JsonField) = apply { - this.dimensionalPriceGroupId = dimensionalPriceGroupId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): DimensionalPriceConfiguration = - DimensionalPriceConfiguration( - checkRequired("dimensionValues", dimensionValues).map { it.toImmutable() }, - checkRequired("dimensionalPriceGroupId", dimensionalPriceGroupId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DimensionalPriceConfiguration && dimensionValues == other.dimensionValues && dimensionalPriceGroupId == other.dimensionalPriceGroupId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, dimensionalPriceGroupId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DimensionalPriceConfiguration{dimensionValues=$dimensionValues, dimensionalPriceGroupId=$dimensionalPriceGroupId, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is TieredWithMinimumPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && tieredWithMinimumConfig == other.tieredWithMinimumConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MatrixPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && matrixConfig == other.matrixConfig && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, tieredWithMinimumConfig, dimensionalPriceConfiguration, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, matrixConfig, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithMinimumPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, tieredWithMinimumConfig=$tieredWithMinimumConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "MatrixPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixConfig=$matrixConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } @NoAutoDetect - class TieredPackageWithMinimumPrice + class TieredPrice @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("billable_metric") @ExcludeMissing - private val billableMetric: JsonField = JsonMissing.of(), + private val billableMetric: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") @ExcludeMissing - private val billingCycleConfiguration: JsonField = + private val billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing @@ -30638,7 +4175,7 @@ private constructor( private val createdAt: JsonField = JsonMissing.of(), @JsonProperty("credit_allocation") @ExcludeMissing - private val creditAllocation: JsonField = JsonMissing.of(), + private val creditAllocation: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing private val currency: JsonField = JsonMissing.of(), @@ -30653,12 +4190,14 @@ private constructor( private val fixedPriceQuantity: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = + private val invoicingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("item") @ExcludeMissing private val item: JsonField = JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), @JsonProperty("maximum") @ExcludeMissing - private val maximum: JsonField = JsonMissing.of(), + private val maximum: JsonField = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing private val maximumAmount: JsonField = JsonMissing.of(), @@ -30667,7 +4206,7 @@ private constructor( private val metadata: JsonField = JsonMissing.of(), @JsonProperty("minimum") @ExcludeMissing - private val minimum: JsonField = JsonMissing.of(), + private val minimum: JsonField = JsonMissing.of(), @JsonProperty("minimum_amount") @ExcludeMissing private val minimumAmount: JsonField = JsonMissing.of(), @@ -30683,13 +4222,12 @@ private constructor( @JsonProperty("price_type") @ExcludeMissing private val priceType: JsonField = JsonMissing.of(), - @JsonProperty("tiered_package_with_minimum_config") + @JsonProperty("tiered_config") @ExcludeMissing - private val tieredPackageWithMinimumConfig: JsonField = - JsonMissing.of(), + private val tieredConfig: JsonField = JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing - private val dimensionalPriceConfiguration: JsonField = + private val dimensionalPriceConfiguration: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), @@ -30697,10 +4235,10 @@ private constructor( fun id(): String = id.getRequired("id") - fun billableMetric(): Optional = + fun billableMetric(): Optional = Optional.ofNullable(billableMetric.getNullable("billable_metric")) - fun billingCycleConfiguration(): BillingCycleConfiguration = + fun billingCycleConfiguration(): BillingCycleConfigurationModel = billingCycleConfiguration.getRequired("billing_cycle_configuration") fun cadence(): Cadence = cadence.getRequired("cadence") @@ -30710,7 +4248,7 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - fun creditAllocation(): Optional = + fun creditAllocation(): Optional = Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) fun currency(): String = currency.getRequired("currency") @@ -30723,14 +4261,14 @@ private constructor( fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - fun invoicingCycleConfiguration(): Optional = + fun invoicingCycleConfiguration(): Optional = Optional.ofNullable( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") ) - fun item(): Item = item.getRequired("item") + fun item(): ItemSlimModel = item.getRequired("item") - fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) @@ -30742,7 +4280,7 @@ private constructor( */ fun metadata(): Metadata = metadata.getRequired("metadata") - fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) fun minimumAmount(): Optional = Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) @@ -30756,10 +4294,9 @@ private constructor( fun priceType(): PriceType = priceType.getRequired("price_type") - fun tieredPackageWithMinimumConfig(): TieredPackageWithMinimumConfig = - tieredPackageWithMinimumConfig.getRequired("tiered_package_with_minimum_config") + fun tieredConfig(): TieredConfigModel = tieredConfig.getRequired("tiered_config") - fun dimensionalPriceConfiguration(): Optional = + fun dimensionalPriceConfiguration(): Optional = Optional.ofNullable( dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") ) @@ -30768,11 +4305,11 @@ private constructor( @JsonProperty("billable_metric") @ExcludeMissing - fun _billableMetric(): JsonField = billableMetric + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = + fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence @@ -30787,7 +4324,7 @@ private constructor( @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation(): JsonField = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @@ -30803,12 +4340,12 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = + fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum @JsonProperty("maximum_amount") @ExcludeMissing @@ -30821,7 +4358,7 @@ private constructor( */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum @JsonProperty("minimum_amount") @ExcludeMissing @@ -30841,14 +4378,13 @@ private constructor( @ExcludeMissing fun _priceType(): JsonField = priceType - @JsonProperty("tiered_package_with_minimum_config") + @JsonProperty("tiered_config") @ExcludeMissing - fun _tieredPackageWithMinimumConfig(): JsonField = - tieredPackageWithMinimumConfig + fun _tieredConfig(): JsonField = tieredConfig @JsonProperty("dimensional_price_configuration") @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = + fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration @JsonAnyGetter @@ -30857,7 +4393,7 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredPackageWithMinimumPrice = apply { + fun validate(): TieredPrice = apply { if (validated) { return@apply } @@ -30884,7 +4420,7 @@ private constructor( name() planPhaseOrder() priceType() - tieredPackageWithMinimumConfig().validate() + tieredConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } validated = true } @@ -30893,94 +4429,120 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [TieredPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * .tieredConfig() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [TieredPackageWithMinimumPrice]. */ + /** A builder for [TieredPrice]. */ class Builder internal constructor() { private var id: JsonField? = null - private var billableMetric: JsonField? = null - private var billingCycleConfiguration: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null private var cadence: JsonField? = null private var conversionRate: JsonField? = null private var createdAt: JsonField? = null - private var creditAllocation: 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 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 minimum: JsonField? = null private var minimumAmount: JsonField? = null private var modelType: JsonField? = null private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null - private var tieredPackageWithMinimumConfig: JsonField? = - null - private var dimensionalPriceConfiguration: JsonField = + private var tieredConfig: JsonField? = null + private var dimensionalPriceConfiguration: + JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredPackageWithMinimumPrice: TieredPackageWithMinimumPrice) = - apply { - id = tieredPackageWithMinimumPrice.id - billableMetric = tieredPackageWithMinimumPrice.billableMetric - billingCycleConfiguration = - tieredPackageWithMinimumPrice.billingCycleConfiguration - cadence = tieredPackageWithMinimumPrice.cadence - conversionRate = tieredPackageWithMinimumPrice.conversionRate - createdAt = tieredPackageWithMinimumPrice.createdAt - creditAllocation = tieredPackageWithMinimumPrice.creditAllocation - currency = tieredPackageWithMinimumPrice.currency - discount = tieredPackageWithMinimumPrice.discount - externalPriceId = tieredPackageWithMinimumPrice.externalPriceId - fixedPriceQuantity = tieredPackageWithMinimumPrice.fixedPriceQuantity - invoicingCycleConfiguration = - tieredPackageWithMinimumPrice.invoicingCycleConfiguration - item = tieredPackageWithMinimumPrice.item - maximum = tieredPackageWithMinimumPrice.maximum - maximumAmount = tieredPackageWithMinimumPrice.maximumAmount - metadata = tieredPackageWithMinimumPrice.metadata - minimum = tieredPackageWithMinimumPrice.minimum - minimumAmount = tieredPackageWithMinimumPrice.minimumAmount - modelType = tieredPackageWithMinimumPrice.modelType - name = tieredPackageWithMinimumPrice.name - planPhaseOrder = tieredPackageWithMinimumPrice.planPhaseOrder - priceType = tieredPackageWithMinimumPrice.priceType - tieredPackageWithMinimumConfig = - tieredPackageWithMinimumPrice.tieredPackageWithMinimumConfig - dimensionalPriceConfiguration = - tieredPackageWithMinimumPrice.dimensionalPriceConfiguration - additionalProperties = - tieredPackageWithMinimumPrice.additionalProperties.toMutableMap() - } + internal fun from(tieredPrice: TieredPrice) = apply { + id = tieredPrice.id + billableMetric = tieredPrice.billableMetric + billingCycleConfiguration = tieredPrice.billingCycleConfiguration + cadence = tieredPrice.cadence + conversionRate = tieredPrice.conversionRate + createdAt = tieredPrice.createdAt + creditAllocation = tieredPrice.creditAllocation + currency = tieredPrice.currency + discount = tieredPrice.discount + externalPriceId = tieredPrice.externalPriceId + fixedPriceQuantity = tieredPrice.fixedPriceQuantity + invoicingCycleConfiguration = tieredPrice.invoicingCycleConfiguration + item = tieredPrice.item + maximum = tieredPrice.maximum + maximumAmount = tieredPrice.maximumAmount + metadata = tieredPrice.metadata + minimum = tieredPrice.minimum + minimumAmount = tieredPrice.minimumAmount + modelType = tieredPrice.modelType + name = tieredPrice.name + planPhaseOrder = tieredPrice.planPhaseOrder + priceType = tieredPrice.priceType + tieredConfig = tieredPrice.tieredConfig + dimensionalPriceConfiguration = tieredPrice.dimensionalPriceConfiguration + additionalProperties = tieredPrice.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric?) = + fun billableMetric(billableMetric: BillableMetricTinyModel?) = billableMetric(JsonField.ofNullable(billableMetric)) - fun billableMetric(billableMetric: Optional) = + fun billableMetric(billableMetric: Optional) = billableMetric(billableMetric.orElse(null)) - fun billableMetric(billableMetric: JsonField) = apply { + fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric } - fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = - billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) fun billingCycleConfiguration( - billingCycleConfiguration: JsonField + billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -31006,13 +4568,13 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation?) = + fun creditAllocation(creditAllocation: AllocationModel?) = creditAllocation(JsonField.ofNullable(creditAllocation)) - fun creditAllocation(creditAllocation: Optional) = + fun creditAllocation(creditAllocation: Optional) = creditAllocation(creditAllocation.orElse(null)) - fun creditAllocation(creditAllocation: JsonField) = apply { + fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation } @@ -31068,26 +4630,26 @@ private constructor( } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? + invoicingCycleConfiguration: BillingCycleConfigurationModel? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional + invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField + invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun item(item: Item) = item(JsonField.of(item)) + fun item(item: ItemSlimModel) = item(JsonField.of(item)) - fun item(item: JsonField) = apply { this.item = item } + fun item(item: JsonField) = apply { this.item = item } - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) - fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } fun maximumAmount(maximumAmount: String?) = maximumAmount(JsonField.ofNullable(maximumAmount)) @@ -31113,11 +4675,11 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) - fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } fun minimumAmount(minimumAmount: String?) = minimumAmount(JsonField.ofNullable(minimumAmount)) @@ -31154,24 +4716,23 @@ private constructor( fun priceType(priceType: JsonField) = apply { this.priceType = priceType } - fun tieredPackageWithMinimumConfig( - tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig - ) = tieredPackageWithMinimumConfig(JsonField.of(tieredPackageWithMinimumConfig)) + fun tieredConfig(tieredConfig: TieredConfigModel) = + tieredConfig(JsonField.of(tieredConfig)) - fun tieredPackageWithMinimumConfig( - tieredPackageWithMinimumConfig: JsonField - ) = apply { this.tieredPackageWithMinimumConfig = tieredPackageWithMinimumConfig } + fun tieredConfig(tieredConfig: JsonField) = apply { + this.tieredConfig = tieredConfig + } fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: DimensionalPriceConfiguration? + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional + dimensionalPriceConfiguration: Optional ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField + dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } fun additionalProperties(additionalProperties: Map) = apply { @@ -31193,358 +4754,34 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): TieredPackageWithMinimumPrice = - TieredPackageWithMinimumPrice( + fun build(): TieredPrice = + TieredPrice( checkRequired("id", id), checkRequired("billableMetric", billableMetric), - checkRequired("billingCycleConfiguration", billingCycleConfiguration), - checkRequired("cadence", cadence), - checkRequired("conversionRate", conversionRate), - checkRequired("createdAt", createdAt), - checkRequired("creditAllocation", creditAllocation), - checkRequired("currency", currency), - checkRequired("discount", discount), - checkRequired("externalPriceId", externalPriceId), - checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), - checkRequired("item", item), - checkRequired("maximum", maximum), - checkRequired("maximumAmount", maximumAmount), - checkRequired("metadata", metadata), - checkRequired("minimum", minimum), - checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("priceType", priceType), - checkRequired("tieredPackageWithMinimumConfig", tieredPackageWithMinimumConfig), - dimensionalPriceConfiguration, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BillableMetric - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillableMetric = apply { - if (validated) { - return@apply - } - - id() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillableMetric]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billableMetric: BillableMetric) = apply { - id = billableMetric.id - additionalProperties = billableMetric.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - 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) - } - - fun build(): BillableMetric = - BillableMetric(checkRequired("id", id), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillableMetric && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillableMetric{id=$id, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + checkRequired("tieredConfig", tieredConfig), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) } class Cadence @JsonCreator private constructor(private val value: JsonField) : @@ -31672,634 +4909,6 @@ private constructor( override fun toString() = value.toString() } - @NoAutoDetect - class CreditAllocation - @JsonCreator - private constructor( - @JsonProperty("allows_rollover") - @ExcludeMissing - private val allowsRollover: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun allowsRollover(): Boolean = allowsRollover.getRequired("allows_rollover") - - fun currency(): String = currency.getRequired("currency") - - @JsonProperty("allows_rollover") - @ExcludeMissing - fun _allowsRollover(): JsonField = allowsRollover - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditAllocation = apply { - if (validated) { - return@apply - } - - allowsRollover() - currency() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditAllocation]. */ - class Builder internal constructor() { - - private var allowsRollover: JsonField? = null - private var currency: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditAllocation: CreditAllocation) = apply { - allowsRollover = creditAllocation.allowsRollover - currency = creditAllocation.currency - additionalProperties = creditAllocation.additionalProperties.toMutableMap() - } - - fun allowsRollover(allowsRollover: Boolean) = - allowsRollover(JsonField.of(allowsRollover)) - - fun allowsRollover(allowsRollover: JsonField) = apply { - this.allowsRollover = allowsRollover - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditAllocation = - CreditAllocation( - checkRequired("allowsRollover", allowsRollover), - checkRequired("currency", currency), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditAllocation && allowsRollover == other.allowsRollover && currency == other.currency && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allowsRollover, currency, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditAllocation{allowsRollover=$allowsRollover, currency=$currency, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Item - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun name(): String = name.getRequired("name") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Item = apply { - if (validated) { - return@apply - } - - id() - name() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Item]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(item: Item) = apply { - id = item.id - name = item.name - additionalProperties = item.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun name(name: String) = name(JsonField.of(name)) - - 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) - } - - fun build(): Item = - Item( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Item && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Item{id=$id, name=$name, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Maximum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Maximum amount applied */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Maximum amount applied */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Maximum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - maximumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Maximum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = maximum.maximumAmount - additionalProperties = maximum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Maximum = - Maximum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("maximumAmount", maximumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Maximum && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, maximumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Maximum{appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, 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 @@ -32329,176 +4938,20 @@ private constructor( fun toBuilder() = Builder().from(this) - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Minimum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Minimum amount applied */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Minimum amount applied */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Minimum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - minimumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Minimum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var minimumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } - minimumAmount = minimum.minimumAmount - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } + companion object { - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) + private var additionalProperties: MutableMap = mutableMapOf() - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -32523,14 +4976,7 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): Minimum = - Minimum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("minimumAmount", minimumAmount), - additionalProperties.toImmutable(), - ) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -32538,17 +4984,16 @@ private constructor( return true } - return /* spotless:off */ other is Minimum && appliesToPriceIds == other.appliesToPriceIds && minimumAmount == other.minimumAmount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, minimumAmount, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode - override fun toString() = - "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } class ModelType @JsonCreator private constructor(private val value: JsonField) : @@ -32566,14 +5011,14 @@ private constructor( companion object { - @JvmField val TIERED_PACKAGE_WITH_MINIMUM = of("tiered_package_with_minimum") + @JvmField val TIERED = of("tiered") @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } /** An enum containing [ModelType]'s known values. */ enum class Known { - TIERED_PACKAGE_WITH_MINIMUM + TIERED } /** @@ -32586,7 +5031,7 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - TIERED_PACKAGE_WITH_MINIMUM, + TIERED, /** * An enum member indicating that [ModelType] was instantiated with an unknown * value. @@ -32603,7 +5048,7 @@ private constructor( */ fun value(): Value = when (this) { - TIERED_PACKAGE_WITH_MINIMUM -> Value.TIERED_PACKAGE_WITH_MINIMUM + TIERED -> Value.TIERED else -> Value._UNKNOWN } @@ -32618,7 +5063,7 @@ private constructor( */ fun known(): Known = when (this) { - TIERED_PACKAGE_WITH_MINIMUM -> Known.TIERED_PACKAGE_WITH_MINIMUM + TIERED -> Known.TIERED else -> throw OrbInvalidDataException("Unknown ModelType: $value") } @@ -32749,263 +5194,35 @@ private constructor( override fun toString() = value.toString() } - @NoAutoDetect - class TieredPackageWithMinimumConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredPackageWithMinimumConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredPackageWithMinimumConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig) = - apply { - additionalProperties = - tieredPackageWithMinimumConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): TieredPackageWithMinimumConfig = - TieredPackageWithMinimumConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredPackageWithMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredPackageWithMinimumConfig{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class DimensionalPriceConfiguration - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - private val dimensionalPriceGroupId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun dimensionValues(): List = dimensionValues.getRequired("dimension_values") - - fun dimensionalPriceGroupId(): String = - dimensionalPriceGroupId.getRequired("dimensional_price_group_id") - - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - fun _dimensionalPriceGroupId(): JsonField = dimensionalPriceGroupId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): DimensionalPriceConfiguration = apply { - if (validated) { - return@apply - } - - dimensionValues() - dimensionalPriceGroupId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DimensionalPriceConfiguration]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var dimensionalPriceGroupId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(dimensionalPriceConfiguration: DimensionalPriceConfiguration) = - apply { - dimensionValues = - dimensionalPriceConfiguration.dimensionValues.map { it.toMutableList() } - dimensionalPriceGroupId = - dimensionalPriceConfiguration.dimensionalPriceGroupId - additionalProperties = - dimensionalPriceConfiguration.additionalProperties.toMutableMap() - } - - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: String) = - dimensionalPriceGroupId(JsonField.of(dimensionalPriceGroupId)) - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: JsonField) = apply { - this.dimensionalPriceGroupId = dimensionalPriceGroupId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): DimensionalPriceConfiguration = - DimensionalPriceConfiguration( - checkRequired("dimensionValues", dimensionValues).map { it.toImmutable() }, - checkRequired("dimensionalPriceGroupId", dimensionalPriceGroupId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DimensionalPriceConfiguration && dimensionValues == other.dimensionValues && dimensionalPriceGroupId == other.dimensionalPriceGroupId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, dimensionalPriceGroupId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DimensionalPriceConfiguration{dimensionValues=$dimensionValues, dimensionalPriceGroupId=$dimensionalPriceGroupId, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is TieredPackageWithMinimumPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && tieredPackageWithMinimumConfig == other.tieredPackageWithMinimumConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && tieredConfig == other.tieredConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, tieredPackageWithMinimumConfig, dimensionalPriceConfiguration, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, tieredConfig, dimensionalPriceConfiguration, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "TieredPackageWithMinimumPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "TieredPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, tieredConfig=$tieredConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } @NoAutoDetect - class PackageWithAllocationPrice + class TieredBpsPrice @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("billable_metric") @ExcludeMissing - private val billableMetric: JsonField = JsonMissing.of(), + private val billableMetric: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") @ExcludeMissing - private val billingCycleConfiguration: JsonField = + private val billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing @@ -33018,7 +5235,7 @@ private constructor( private val createdAt: JsonField = JsonMissing.of(), @JsonProperty("credit_allocation") @ExcludeMissing - private val creditAllocation: JsonField = JsonMissing.of(), + private val creditAllocation: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing private val currency: JsonField = JsonMissing.of(), @@ -33033,12 +5250,14 @@ private constructor( private val fixedPriceQuantity: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = + private val invoicingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("item") @ExcludeMissing private val item: JsonField = JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), @JsonProperty("maximum") @ExcludeMissing - private val maximum: JsonField = JsonMissing.of(), + private val maximum: JsonField = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing private val maximumAmount: JsonField = JsonMissing.of(), @@ -33047,7 +5266,7 @@ private constructor( private val metadata: JsonField = JsonMissing.of(), @JsonProperty("minimum") @ExcludeMissing - private val minimum: JsonField = JsonMissing.of(), + private val minimum: JsonField = JsonMissing.of(), @JsonProperty("minimum_amount") @ExcludeMissing private val minimumAmount: JsonField = JsonMissing.of(), @@ -33057,19 +5276,18 @@ private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), - @JsonProperty("package_with_allocation_config") - @ExcludeMissing - private val packageWithAllocationConfig: JsonField = - JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing private val planPhaseOrder: JsonField = JsonMissing.of(), @JsonProperty("price_type") @ExcludeMissing private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("tiered_bps_config") + @ExcludeMissing + private val tieredBpsConfig: JsonField = JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing - private val dimensionalPriceConfiguration: JsonField = + private val dimensionalPriceConfiguration: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), @@ -33077,10 +5295,10 @@ private constructor( fun id(): String = id.getRequired("id") - fun billableMetric(): Optional = + fun billableMetric(): Optional = Optional.ofNullable(billableMetric.getNullable("billable_metric")) - fun billingCycleConfiguration(): BillingCycleConfiguration = + fun billingCycleConfiguration(): BillingCycleConfigurationModel = billingCycleConfiguration.getRequired("billing_cycle_configuration") fun cadence(): Cadence = cadence.getRequired("cadence") @@ -33090,7 +5308,7 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - fun creditAllocation(): Optional = + fun creditAllocation(): Optional = Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) fun currency(): String = currency.getRequired("currency") @@ -33103,14 +5321,14 @@ private constructor( fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - fun invoicingCycleConfiguration(): Optional = + fun invoicingCycleConfiguration(): Optional = Optional.ofNullable( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") ) - fun item(): Item = item.getRequired("item") + fun item(): ItemSlimModel = item.getRequired("item") - fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) @@ -33122,7 +5340,7 @@ private constructor( */ fun metadata(): Metadata = metadata.getRequired("metadata") - fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) fun minimumAmount(): Optional = Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) @@ -33131,15 +5349,15 @@ private constructor( fun name(): String = name.getRequired("name") - fun packageWithAllocationConfig(): PackageWithAllocationConfig = - packageWithAllocationConfig.getRequired("package_with_allocation_config") - fun planPhaseOrder(): Optional = Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) fun priceType(): PriceType = priceType.getRequired("price_type") - fun dimensionalPriceConfiguration(): Optional = + fun tieredBpsConfig(): TieredBpsConfigModel = + tieredBpsConfig.getRequired("tiered_bps_config") + + fun dimensionalPriceConfiguration(): Optional = Optional.ofNullable( dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") ) @@ -33148,11 +5366,11 @@ private constructor( @JsonProperty("billable_metric") @ExcludeMissing - fun _billableMetric(): JsonField = billableMetric + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = + fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence @@ -33167,7 +5385,7 @@ private constructor( @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation(): JsonField = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @@ -33183,12 +5401,12 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = + fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum @JsonProperty("maximum_amount") @ExcludeMissing @@ -33201,7 +5419,7 @@ private constructor( */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum @JsonProperty("minimum_amount") @ExcludeMissing @@ -33213,11 +5431,6 @@ private constructor( @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("package_with_allocation_config") - @ExcludeMissing - fun _packageWithAllocationConfig(): JsonField = - packageWithAllocationConfig - @JsonProperty("plan_phase_order") @ExcludeMissing fun _planPhaseOrder(): JsonField = planPhaseOrder @@ -33226,9 +5439,13 @@ private constructor( @ExcludeMissing fun _priceType(): JsonField = priceType + @JsonProperty("tiered_bps_config") + @ExcludeMissing + fun _tieredBpsConfig(): JsonField = tieredBpsConfig + @JsonProperty("dimensional_price_configuration") @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = + fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration @JsonAnyGetter @@ -33237,7 +5454,7 @@ private constructor( private var validated: Boolean = false - fun validate(): PackageWithAllocationPrice = apply { + fun validate(): TieredBpsPrice = apply { if (validated) { return@apply } @@ -33262,9 +5479,9 @@ private constructor( minimumAmount() modelType() name() - packageWithAllocationConfig().validate() planPhaseOrder() priceType() + tieredBpsConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } validated = true } @@ -33273,89 +5490,120 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [TieredBpsPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * .tieredBpsConfig() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [PackageWithAllocationPrice]. */ + /** A builder for [TieredBpsPrice]. */ class Builder internal constructor() { private var id: JsonField? = null - private var billableMetric: JsonField? = null - private var billingCycleConfiguration: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null private var cadence: JsonField? = null private var conversionRate: JsonField? = null private var createdAt: JsonField? = null - private var creditAllocation: 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 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 minimum: JsonField? = null private var minimumAmount: JsonField? = null private var modelType: JsonField? = null private var name: JsonField? = null - private var packageWithAllocationConfig: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null - private var dimensionalPriceConfiguration: JsonField = + private var tieredBpsConfig: JsonField? = null + private var dimensionalPriceConfiguration: + JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(packageWithAllocationPrice: PackageWithAllocationPrice) = apply { - id = packageWithAllocationPrice.id - billableMetric = packageWithAllocationPrice.billableMetric - billingCycleConfiguration = packageWithAllocationPrice.billingCycleConfiguration - cadence = packageWithAllocationPrice.cadence - conversionRate = packageWithAllocationPrice.conversionRate - createdAt = packageWithAllocationPrice.createdAt - creditAllocation = packageWithAllocationPrice.creditAllocation - currency = packageWithAllocationPrice.currency - discount = packageWithAllocationPrice.discount - externalPriceId = packageWithAllocationPrice.externalPriceId - fixedPriceQuantity = packageWithAllocationPrice.fixedPriceQuantity - invoicingCycleConfiguration = packageWithAllocationPrice.invoicingCycleConfiguration - item = packageWithAllocationPrice.item - maximum = packageWithAllocationPrice.maximum - maximumAmount = packageWithAllocationPrice.maximumAmount - metadata = packageWithAllocationPrice.metadata - minimum = packageWithAllocationPrice.minimum - minimumAmount = packageWithAllocationPrice.minimumAmount - modelType = packageWithAllocationPrice.modelType - name = packageWithAllocationPrice.name - packageWithAllocationConfig = packageWithAllocationPrice.packageWithAllocationConfig - planPhaseOrder = packageWithAllocationPrice.planPhaseOrder - priceType = packageWithAllocationPrice.priceType - dimensionalPriceConfiguration = - packageWithAllocationPrice.dimensionalPriceConfiguration - additionalProperties = - packageWithAllocationPrice.additionalProperties.toMutableMap() + internal fun from(tieredBpsPrice: TieredBpsPrice) = apply { + id = tieredBpsPrice.id + billableMetric = tieredBpsPrice.billableMetric + billingCycleConfiguration = tieredBpsPrice.billingCycleConfiguration + cadence = tieredBpsPrice.cadence + conversionRate = tieredBpsPrice.conversionRate + createdAt = tieredBpsPrice.createdAt + creditAllocation = tieredBpsPrice.creditAllocation + currency = tieredBpsPrice.currency + discount = tieredBpsPrice.discount + externalPriceId = tieredBpsPrice.externalPriceId + fixedPriceQuantity = tieredBpsPrice.fixedPriceQuantity + invoicingCycleConfiguration = tieredBpsPrice.invoicingCycleConfiguration + item = tieredBpsPrice.item + maximum = tieredBpsPrice.maximum + maximumAmount = tieredBpsPrice.maximumAmount + metadata = tieredBpsPrice.metadata + minimum = tieredBpsPrice.minimum + minimumAmount = tieredBpsPrice.minimumAmount + modelType = tieredBpsPrice.modelType + name = tieredBpsPrice.name + planPhaseOrder = tieredBpsPrice.planPhaseOrder + priceType = tieredBpsPrice.priceType + tieredBpsConfig = tieredBpsPrice.tieredBpsConfig + dimensionalPriceConfiguration = tieredBpsPrice.dimensionalPriceConfiguration + additionalProperties = tieredBpsPrice.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric?) = + fun billableMetric(billableMetric: BillableMetricTinyModel?) = billableMetric(JsonField.ofNullable(billableMetric)) - fun billableMetric(billableMetric: Optional) = + fun billableMetric(billableMetric: Optional) = billableMetric(billableMetric.orElse(null)) - fun billableMetric(billableMetric: JsonField) = apply { + fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric } - fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = - billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) fun billingCycleConfiguration( - billingCycleConfiguration: JsonField + billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -33381,13 +5629,13 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation?) = + fun creditAllocation(creditAllocation: AllocationModel?) = creditAllocation(JsonField.ofNullable(creditAllocation)) - fun creditAllocation(creditAllocation: Optional) = + fun creditAllocation(creditAllocation: Optional) = creditAllocation(creditAllocation.orElse(null)) - fun creditAllocation(creditAllocation: JsonField) = apply { + fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation } @@ -33443,26 +5691,26 @@ private constructor( } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? + invoicingCycleConfiguration: BillingCycleConfigurationModel? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional + invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField + invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun item(item: Item) = item(JsonField.of(item)) + fun item(item: ItemSlimModel) = item(JsonField.of(item)) - fun item(item: JsonField) = apply { this.item = item } + fun item(item: JsonField) = apply { this.item = item } - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) - fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } fun maximumAmount(maximumAmount: String?) = maximumAmount(JsonField.ofNullable(maximumAmount)) @@ -33488,11 +5736,11 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) - fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } fun minimumAmount(minimumAmount: String?) = minimumAmount(JsonField.ofNullable(minimumAmount)) @@ -33512,14 +5760,6 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } - fun packageWithAllocationConfig( - packageWithAllocationConfig: PackageWithAllocationConfig - ) = packageWithAllocationConfig(JsonField.of(packageWithAllocationConfig)) - - fun packageWithAllocationConfig( - packageWithAllocationConfig: JsonField - ) = apply { this.packageWithAllocationConfig = packageWithAllocationConfig } - fun planPhaseOrder(planPhaseOrder: Long?) = planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) @@ -33537,16 +5777,23 @@ private constructor( fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + fun tieredBpsConfig(tieredBpsConfig: TieredBpsConfigModel) = + tieredBpsConfig(JsonField.of(tieredBpsConfig)) + + fun tieredBpsConfig(tieredBpsConfig: JsonField) = apply { + this.tieredBpsConfig = tieredBpsConfig + } + fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: DimensionalPriceConfiguration? + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional + dimensionalPriceConfiguration: Optional ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField + dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } fun additionalProperties(additionalProperties: Map) = apply { @@ -33568,358 +5815,34 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): PackageWithAllocationPrice = - PackageWithAllocationPrice( - checkRequired("id", id), - checkRequired("billableMetric", billableMetric), - checkRequired("billingCycleConfiguration", billingCycleConfiguration), - checkRequired("cadence", cadence), - checkRequired("conversionRate", conversionRate), - checkRequired("createdAt", createdAt), - checkRequired("creditAllocation", creditAllocation), - checkRequired("currency", currency), - checkRequired("discount", discount), - checkRequired("externalPriceId", externalPriceId), - checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), - checkRequired("item", item), - checkRequired("maximum", maximum), - checkRequired("maximumAmount", maximumAmount), - checkRequired("metadata", metadata), - checkRequired("minimum", minimum), - checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("packageWithAllocationConfig", packageWithAllocationConfig), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("priceType", priceType), - dimensionalPriceConfiguration, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BillableMetric - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillableMetric = apply { - if (validated) { - return@apply - } - - id() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillableMetric]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billableMetric: BillableMetric) = apply { - id = billableMetric.id - additionalProperties = billableMetric.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - 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) - } - - fun build(): BillableMetric = - BillableMetric(checkRequired("id", id), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillableMetric && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillableMetric{id=$id, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + fun build(): TieredBpsPrice = + TieredBpsPrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + checkRequired("tieredBpsConfig", tieredBpsConfig), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) } class Cadence @JsonCreator private constructor(private val value: JsonField) : @@ -34047,634 +5970,6 @@ private constructor( override fun toString() = value.toString() } - @NoAutoDetect - class CreditAllocation - @JsonCreator - private constructor( - @JsonProperty("allows_rollover") - @ExcludeMissing - private val allowsRollover: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun allowsRollover(): Boolean = allowsRollover.getRequired("allows_rollover") - - fun currency(): String = currency.getRequired("currency") - - @JsonProperty("allows_rollover") - @ExcludeMissing - fun _allowsRollover(): JsonField = allowsRollover - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditAllocation = apply { - if (validated) { - return@apply - } - - allowsRollover() - currency() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditAllocation]. */ - class Builder internal constructor() { - - private var allowsRollover: JsonField? = null - private var currency: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditAllocation: CreditAllocation) = apply { - allowsRollover = creditAllocation.allowsRollover - currency = creditAllocation.currency - additionalProperties = creditAllocation.additionalProperties.toMutableMap() - } - - fun allowsRollover(allowsRollover: Boolean) = - allowsRollover(JsonField.of(allowsRollover)) - - fun allowsRollover(allowsRollover: JsonField) = apply { - this.allowsRollover = allowsRollover - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditAllocation = - CreditAllocation( - checkRequired("allowsRollover", allowsRollover), - checkRequired("currency", currency), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditAllocation && allowsRollover == other.allowsRollover && currency == other.currency && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allowsRollover, currency, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditAllocation{allowsRollover=$allowsRollover, currency=$currency, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Item - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun name(): String = name.getRequired("name") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Item = apply { - if (validated) { - return@apply - } - - id() - name() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Item]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(item: Item) = apply { - id = item.id - name = item.name - additionalProperties = item.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun name(name: String) = name(JsonField.of(name)) - - 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) - } - - fun build(): Item = - Item( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Item && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Item{id=$id, name=$name, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Maximum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Maximum amount applied */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Maximum amount applied */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Maximum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - maximumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Maximum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = maximum.maximumAmount - additionalProperties = maximum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Maximum = - Maximum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("maximumAmount", maximumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Maximum && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, maximumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Maximum{appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, 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 @@ -34704,176 +5999,20 @@ private constructor( fun toBuilder() = Builder().from(this) - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Minimum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Minimum amount applied */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Minimum amount applied */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Minimum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - minimumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Minimum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var minimumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } - minimumAmount = minimum.minimumAmount - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) + companion object { - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) + private var additionalProperties: MutableMap = mutableMapOf() - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -34898,14 +6037,7 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): Minimum = - Minimum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("minimumAmount", minimumAmount), - additionalProperties.toImmutable(), - ) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -34913,17 +6045,16 @@ private constructor( return true } - return /* spotless:off */ other is Minimum && appliesToPriceIds == other.appliesToPriceIds && minimumAmount == other.minimumAmount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, minimumAmount, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode - override fun toString() = - "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } class ModelType @JsonCreator private constructor(private val value: JsonField) : @@ -34941,14 +6072,14 @@ private constructor( companion object { - @JvmField val PACKAGE_WITH_ALLOCATION = of("package_with_allocation") + @JvmField val TIERED_BPS = of("tiered_bps") @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } /** An enum containing [ModelType]'s known values. */ enum class Known { - PACKAGE_WITH_ALLOCATION + TIERED_BPS } /** @@ -34961,7 +6092,7 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - PACKAGE_WITH_ALLOCATION, + TIERED_BPS, /** * An enum member indicating that [ModelType] was instantiated with an unknown * value. @@ -34978,7 +6109,7 @@ private constructor( */ fun value(): Value = when (this) { - PACKAGE_WITH_ALLOCATION -> Value.PACKAGE_WITH_ALLOCATION + TIERED_BPS -> Value.TIERED_BPS else -> Value._UNKNOWN } @@ -34993,7 +6124,7 @@ private constructor( */ fun known(): Known = when (this) { - PACKAGE_WITH_ALLOCATION -> Known.PACKAGE_WITH_ALLOCATION + TIERED_BPS -> Known.TIERED_BPS else -> throw OrbInvalidDataException("Unknown ModelType: $value") } @@ -35022,91 +6153,6 @@ private constructor( override fun toString() = value.toString() } - @NoAutoDetect - class PackageWithAllocationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PackageWithAllocationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PackageWithAllocationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(packageWithAllocationConfig: PackageWithAllocationConfig) = - apply { - additionalProperties = - packageWithAllocationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): PackageWithAllocationConfig = - PackageWithAllocationConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PackageWithAllocationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PackageWithAllocationConfig{additionalProperties=$additionalProperties}" - } - class PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -35209,179 +6255,39 @@ private constructor( override fun toString() = value.toString() } - @NoAutoDetect - class DimensionalPriceConfiguration - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - private val dimensionalPriceGroupId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun dimensionValues(): List = dimensionValues.getRequired("dimension_values") - - fun dimensionalPriceGroupId(): String = - dimensionalPriceGroupId.getRequired("dimensional_price_group_id") - - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - fun _dimensionalPriceGroupId(): JsonField = dimensionalPriceGroupId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): DimensionalPriceConfiguration = apply { - if (validated) { - return@apply - } - - dimensionValues() - dimensionalPriceGroupId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DimensionalPriceConfiguration]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var dimensionalPriceGroupId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(dimensionalPriceConfiguration: DimensionalPriceConfiguration) = - apply { - dimensionValues = - dimensionalPriceConfiguration.dimensionValues.map { it.toMutableList() } - dimensionalPriceGroupId = - dimensionalPriceConfiguration.dimensionalPriceGroupId - additionalProperties = - dimensionalPriceConfiguration.additionalProperties.toMutableMap() - } - - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: String) = - dimensionalPriceGroupId(JsonField.of(dimensionalPriceGroupId)) - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: JsonField) = apply { - this.dimensionalPriceGroupId = dimensionalPriceGroupId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): DimensionalPriceConfiguration = - DimensionalPriceConfiguration( - checkRequired("dimensionValues", dimensionValues).map { it.toImmutable() }, - checkRequired("dimensionalPriceGroupId", dimensionalPriceGroupId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DimensionalPriceConfiguration && dimensionValues == other.dimensionValues && dimensionalPriceGroupId == other.dimensionalPriceGroupId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, dimensionalPriceGroupId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DimensionalPriceConfiguration{dimensionValues=$dimensionValues, dimensionalPriceGroupId=$dimensionalPriceGroupId, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PackageWithAllocationPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && packageWithAllocationConfig == other.packageWithAllocationConfig && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredBpsPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && tieredBpsConfig == other.tieredBpsConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, packageWithAllocationConfig, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, tieredBpsConfig, dimensionalPriceConfiguration, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "PackageWithAllocationPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "TieredBpsPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, tieredBpsConfig=$tieredBpsConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } @NoAutoDetect - class UnitWithPercentPrice + class BpsPrice @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("billable_metric") @ExcludeMissing - private val billableMetric: JsonField = JsonMissing.of(), + private val billableMetric: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") @ExcludeMissing - private val billingCycleConfiguration: JsonField = + private val billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("bps_config") + @ExcludeMissing + private val bpsConfig: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing private val cadence: JsonField = JsonMissing.of(), @@ -35393,7 +6299,7 @@ private constructor( private val createdAt: JsonField = JsonMissing.of(), @JsonProperty("credit_allocation") @ExcludeMissing - private val creditAllocation: JsonField = JsonMissing.of(), + private val creditAllocation: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing private val currency: JsonField = JsonMissing.of(), @@ -35408,12 +6314,14 @@ private constructor( private val fixedPriceQuantity: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = + private val invoicingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("item") @ExcludeMissing private val item: JsonField = JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), @JsonProperty("maximum") @ExcludeMissing - private val maximum: JsonField = JsonMissing.of(), + private val maximum: JsonField = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing private val maximumAmount: JsonField = JsonMissing.of(), @@ -35422,7 +6330,7 @@ private constructor( private val metadata: JsonField = JsonMissing.of(), @JsonProperty("minimum") @ExcludeMissing - private val minimum: JsonField = JsonMissing.of(), + private val minimum: JsonField = JsonMissing.of(), @JsonProperty("minimum_amount") @ExcludeMissing private val minimumAmount: JsonField = JsonMissing.of(), @@ -35438,12 +6346,9 @@ private constructor( @JsonProperty("price_type") @ExcludeMissing private val priceType: JsonField = JsonMissing.of(), - @JsonProperty("unit_with_percent_config") - @ExcludeMissing - private val unitWithPercentConfig: JsonField = JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing - private val dimensionalPriceConfiguration: JsonField = + private val dimensionalPriceConfiguration: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), @@ -35451,12 +6356,14 @@ private constructor( fun id(): String = id.getRequired("id") - fun billableMetric(): Optional = + fun billableMetric(): Optional = Optional.ofNullable(billableMetric.getNullable("billable_metric")) - fun billingCycleConfiguration(): BillingCycleConfiguration = + fun billingCycleConfiguration(): BillingCycleConfigurationModel = billingCycleConfiguration.getRequired("billing_cycle_configuration") + fun bpsConfig(): BpsConfigModel = bpsConfig.getRequired("bps_config") + fun cadence(): Cadence = cadence.getRequired("cadence") fun conversionRate(): Optional = @@ -35464,7 +6371,7 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - fun creditAllocation(): Optional = + fun creditAllocation(): Optional = Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) fun currency(): String = currency.getRequired("currency") @@ -35477,14 +6384,14 @@ private constructor( fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - fun invoicingCycleConfiguration(): Optional = + fun invoicingCycleConfiguration(): Optional = Optional.ofNullable( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") ) - fun item(): Item = item.getRequired("item") + fun item(): ItemSlimModel = item.getRequired("item") - fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) @@ -35496,7 +6403,7 @@ private constructor( */ fun metadata(): Metadata = metadata.getRequired("metadata") - fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) fun minimumAmount(): Optional = Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) @@ -35510,10 +6417,7 @@ private constructor( fun priceType(): PriceType = priceType.getRequired("price_type") - fun unitWithPercentConfig(): UnitWithPercentConfig = - unitWithPercentConfig.getRequired("unit_with_percent_config") - - fun dimensionalPriceConfiguration(): Optional = + fun dimensionalPriceConfiguration(): Optional = Optional.ofNullable( dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") ) @@ -35522,13 +6426,17 @@ private constructor( @JsonProperty("billable_metric") @ExcludeMissing - fun _billableMetric(): JsonField = billableMetric + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = + fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration + @JsonProperty("bps_config") + @ExcludeMissing + fun _bpsConfig(): JsonField = bpsConfig + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence @JsonProperty("conversion_rate") @@ -35541,7 +6449,7 @@ private constructor( @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation(): JsonField = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @@ -35557,12 +6465,12 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = + fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum @JsonProperty("maximum_amount") @ExcludeMissing @@ -35575,7 +6483,7 @@ private constructor( */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum @JsonProperty("minimum_amount") @ExcludeMissing @@ -35595,13 +6503,9 @@ private constructor( @ExcludeMissing fun _priceType(): JsonField = priceType - @JsonProperty("unit_with_percent_config") - @ExcludeMissing - fun _unitWithPercentConfig(): JsonField = unitWithPercentConfig - @JsonProperty("dimensional_price_configuration") @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = + fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration @JsonAnyGetter @@ -35610,7 +6514,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UnitWithPercentPrice = apply { + fun validate(): BpsPrice = apply { if (validated) { return@apply } @@ -35618,6 +6522,7 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() + bpsConfig().validate() cadence() conversionRate() createdAt() @@ -35637,7 +6542,6 @@ private constructor( name() planPhaseOrder() priceType() - unitWithPercentConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } validated = true } @@ -35646,89 +6550,128 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [BpsPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .bpsConfig() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [UnitWithPercentPrice]. */ + /** A builder for [BpsPrice]. */ class Builder internal constructor() { private var id: JsonField? = null - private var billableMetric: JsonField? = null - private var billingCycleConfiguration: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var bpsConfig: JsonField? = null private var cadence: JsonField? = null private var conversionRate: JsonField? = null private var createdAt: JsonField? = null - private var creditAllocation: 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 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 minimum: JsonField? = null private var minimumAmount: JsonField? = null private var modelType: JsonField? = null private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null - private var unitWithPercentConfig: JsonField? = null - private var dimensionalPriceConfiguration: JsonField = + private var dimensionalPriceConfiguration: + JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unitWithPercentPrice: UnitWithPercentPrice) = apply { - id = unitWithPercentPrice.id - billableMetric = unitWithPercentPrice.billableMetric - billingCycleConfiguration = unitWithPercentPrice.billingCycleConfiguration - cadence = unitWithPercentPrice.cadence - conversionRate = unitWithPercentPrice.conversionRate - createdAt = unitWithPercentPrice.createdAt - creditAllocation = unitWithPercentPrice.creditAllocation - currency = unitWithPercentPrice.currency - discount = unitWithPercentPrice.discount - externalPriceId = unitWithPercentPrice.externalPriceId - fixedPriceQuantity = unitWithPercentPrice.fixedPriceQuantity - invoicingCycleConfiguration = unitWithPercentPrice.invoicingCycleConfiguration - item = unitWithPercentPrice.item - maximum = unitWithPercentPrice.maximum - maximumAmount = unitWithPercentPrice.maximumAmount - metadata = unitWithPercentPrice.metadata - minimum = unitWithPercentPrice.minimum - minimumAmount = unitWithPercentPrice.minimumAmount - modelType = unitWithPercentPrice.modelType - name = unitWithPercentPrice.name - planPhaseOrder = unitWithPercentPrice.planPhaseOrder - priceType = unitWithPercentPrice.priceType - unitWithPercentConfig = unitWithPercentPrice.unitWithPercentConfig - dimensionalPriceConfiguration = unitWithPercentPrice.dimensionalPriceConfiguration - additionalProperties = unitWithPercentPrice.additionalProperties.toMutableMap() + internal fun from(bpsPrice: BpsPrice) = apply { + id = bpsPrice.id + billableMetric = bpsPrice.billableMetric + billingCycleConfiguration = bpsPrice.billingCycleConfiguration + bpsConfig = bpsPrice.bpsConfig + cadence = bpsPrice.cadence + conversionRate = bpsPrice.conversionRate + createdAt = bpsPrice.createdAt + creditAllocation = bpsPrice.creditAllocation + currency = bpsPrice.currency + discount = bpsPrice.discount + externalPriceId = bpsPrice.externalPriceId + fixedPriceQuantity = bpsPrice.fixedPriceQuantity + invoicingCycleConfiguration = bpsPrice.invoicingCycleConfiguration + item = bpsPrice.item + maximum = bpsPrice.maximum + maximumAmount = bpsPrice.maximumAmount + metadata = bpsPrice.metadata + minimum = bpsPrice.minimum + minimumAmount = bpsPrice.minimumAmount + modelType = bpsPrice.modelType + name = bpsPrice.name + planPhaseOrder = bpsPrice.planPhaseOrder + priceType = bpsPrice.priceType + dimensionalPriceConfiguration = bpsPrice.dimensionalPriceConfiguration + additionalProperties = bpsPrice.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric?) = + fun billableMetric(billableMetric: BillableMetricTinyModel?) = billableMetric(JsonField.ofNullable(billableMetric)) - fun billableMetric(billableMetric: Optional) = + fun billableMetric(billableMetric: Optional) = billableMetric(billableMetric.orElse(null)) - fun billableMetric(billableMetric: JsonField) = apply { + fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric } - fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = - billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) fun billingCycleConfiguration( - billingCycleConfiguration: JsonField + billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun bpsConfig(bpsConfig: BpsConfigModel) = bpsConfig(JsonField.of(bpsConfig)) + + fun bpsConfig(bpsConfig: JsonField) = apply { + this.bpsConfig = bpsConfig + } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) fun cadence(cadence: JsonField) = apply { this.cadence = cadence } @@ -35752,13 +6695,13 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation?) = + fun creditAllocation(creditAllocation: AllocationModel?) = creditAllocation(JsonField.ofNullable(creditAllocation)) - fun creditAllocation(creditAllocation: Optional) = + fun creditAllocation(creditAllocation: Optional) = creditAllocation(creditAllocation.orElse(null)) - fun creditAllocation(creditAllocation: JsonField) = apply { + fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation } @@ -35814,26 +6757,26 @@ private constructor( } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? + invoicingCycleConfiguration: BillingCycleConfigurationModel? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional + invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField + invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun item(item: Item) = item(JsonField.of(item)) + fun item(item: ItemSlimModel) = item(JsonField.of(item)) - fun item(item: JsonField) = apply { this.item = item } + fun item(item: JsonField) = apply { this.item = item } - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) - fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } fun maximumAmount(maximumAmount: String?) = maximumAmount(JsonField.ofNullable(maximumAmount)) @@ -35859,11 +6802,11 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) - fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } fun minimumAmount(minimumAmount: String?) = minimumAmount(JsonField.ofNullable(minimumAmount)) @@ -35900,24 +6843,16 @@ private constructor( fun priceType(priceType: JsonField) = apply { this.priceType = priceType } - fun unitWithPercentConfig(unitWithPercentConfig: UnitWithPercentConfig) = - unitWithPercentConfig(JsonField.of(unitWithPercentConfig)) - - fun unitWithPercentConfig(unitWithPercentConfig: JsonField) = - apply { - this.unitWithPercentConfig = unitWithPercentConfig - } - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: DimensionalPriceConfiguration? + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional + dimensionalPriceConfiguration: Optional ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField + dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } fun additionalProperties(additionalProperties: Map) = apply { @@ -35926,371 +6861,47 @@ private constructor( } fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): UnitWithPercentPrice = - UnitWithPercentPrice( - checkRequired("id", id), - checkRequired("billableMetric", billableMetric), - checkRequired("billingCycleConfiguration", billingCycleConfiguration), - checkRequired("cadence", cadence), - checkRequired("conversionRate", conversionRate), - checkRequired("createdAt", createdAt), - checkRequired("creditAllocation", creditAllocation), - checkRequired("currency", currency), - checkRequired("discount", discount), - checkRequired("externalPriceId", externalPriceId), - checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), - checkRequired("item", item), - checkRequired("maximum", maximum), - checkRequired("maximumAmount", maximumAmount), - checkRequired("metadata", metadata), - checkRequired("minimum", minimum), - checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("priceType", priceType), - checkRequired("unitWithPercentConfig", unitWithPercentConfig), - dimensionalPriceConfiguration, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BillableMetric - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillableMetric = apply { - if (validated) { - return@apply - } - - id() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillableMetric]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billableMetric: BillableMetric) = apply { - id = billableMetric.id - additionalProperties = billableMetric.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - 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) - } - - fun build(): BillableMetric = - BillableMetric(checkRequired("id", id), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillableMetric && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillableMetric{id=$id, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + additionalProperties.put(key, value) + } - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - override fun hashCode(): Int = hashCode + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + fun build(): BpsPrice = + BpsPrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("bpsConfig", bpsConfig), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) } class Cadence @JsonCreator private constructor(private val value: JsonField) : @@ -36418,634 +7029,6 @@ private constructor( override fun toString() = value.toString() } - @NoAutoDetect - class CreditAllocation - @JsonCreator - private constructor( - @JsonProperty("allows_rollover") - @ExcludeMissing - private val allowsRollover: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun allowsRollover(): Boolean = allowsRollover.getRequired("allows_rollover") - - fun currency(): String = currency.getRequired("currency") - - @JsonProperty("allows_rollover") - @ExcludeMissing - fun _allowsRollover(): JsonField = allowsRollover - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditAllocation = apply { - if (validated) { - return@apply - } - - allowsRollover() - currency() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditAllocation]. */ - class Builder internal constructor() { - - private var allowsRollover: JsonField? = null - private var currency: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditAllocation: CreditAllocation) = apply { - allowsRollover = creditAllocation.allowsRollover - currency = creditAllocation.currency - additionalProperties = creditAllocation.additionalProperties.toMutableMap() - } - - fun allowsRollover(allowsRollover: Boolean) = - allowsRollover(JsonField.of(allowsRollover)) - - fun allowsRollover(allowsRollover: JsonField) = apply { - this.allowsRollover = allowsRollover - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditAllocation = - CreditAllocation( - checkRequired("allowsRollover", allowsRollover), - checkRequired("currency", currency), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditAllocation && allowsRollover == other.allowsRollover && currency == other.currency && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allowsRollover, currency, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditAllocation{allowsRollover=$allowsRollover, currency=$currency, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Item - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun name(): String = name.getRequired("name") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Item = apply { - if (validated) { - return@apply - } - - id() - name() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Item]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(item: Item) = apply { - id = item.id - name = item.name - additionalProperties = item.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun name(name: String) = name(JsonField.of(name)) - - 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) - } - - fun build(): Item = - Item( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Item && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Item{id=$id, name=$name, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Maximum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Maximum amount applied */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Maximum amount applied */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Maximum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - maximumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Maximum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = maximum.maximumAmount - additionalProperties = maximum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Maximum = - Maximum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("maximumAmount", maximumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Maximum && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, maximumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Maximum{appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, 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 @@ -37056,118 +7039,8 @@ private constructor( @JsonCreator private constructor( @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Minimum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Minimum amount applied */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Minimum amount applied */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount + private val additionalProperties: Map = immutableEmptyMap() + ) { @JsonAnyGetter @ExcludeMissing @@ -37175,13 +7048,11 @@ private constructor( private var validated: Boolean = false - fun validate(): Minimum = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } - appliesToPriceIds() - minimumAmount() validated = true } @@ -37189,62 +7060,18 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [Minimum]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { - private var appliesToPriceIds: JsonField>? = null - private var minimumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } - minimumAmount = minimum.minimumAmount - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -37269,14 +7096,7 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): Minimum = - Minimum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("minimumAmount", minimumAmount), - additionalProperties.toImmutable(), - ) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -37284,17 +7104,16 @@ private constructor( return true } - return /* spotless:off */ other is Minimum && appliesToPriceIds == other.appliesToPriceIds && minimumAmount == other.minimumAmount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, minimumAmount, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode - override fun toString() = - "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } class ModelType @JsonCreator private constructor(private val value: JsonField) : @@ -37312,14 +7131,14 @@ private constructor( companion object { - @JvmField val UNIT_WITH_PERCENT = of("unit_with_percent") + @JvmField val BPS = of("bps") @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } /** An enum containing [ModelType]'s known values. */ enum class Known { - UNIT_WITH_PERCENT + BPS } /** @@ -37332,7 +7151,7 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - UNIT_WITH_PERCENT, + BPS, /** * An enum member indicating that [ModelType] was instantiated with an unknown * value. @@ -37349,7 +7168,7 @@ private constructor( */ fun value(): Value = when (this) { - UNIT_WITH_PERCENT -> Value.UNIT_WITH_PERCENT + BPS -> Value.BPS else -> Value._UNKNOWN } @@ -37364,7 +7183,7 @@ private constructor( */ fun known(): Known = when (this) { - UNIT_WITH_PERCENT -> Known.UNIT_WITH_PERCENT + BPS -> Known.BPS else -> throw OrbInvalidDataException("Unknown ModelType: $value") } @@ -37495,262 +7314,39 @@ private constructor( override fun toString() = value.toString() } - @NoAutoDetect - class UnitWithPercentConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): UnitWithPercentConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnitWithPercentConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unitWithPercentConfig: UnitWithPercentConfig) = apply { - additionalProperties = unitWithPercentConfig.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) - } - - fun build(): UnitWithPercentConfig = - UnitWithPercentConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UnitWithPercentConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnitWithPercentConfig{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class DimensionalPriceConfiguration - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - private val dimensionalPriceGroupId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun dimensionValues(): List = dimensionValues.getRequired("dimension_values") - - fun dimensionalPriceGroupId(): String = - dimensionalPriceGroupId.getRequired("dimensional_price_group_id") - - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - fun _dimensionalPriceGroupId(): JsonField = dimensionalPriceGroupId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): DimensionalPriceConfiguration = apply { - if (validated) { - return@apply - } - - dimensionValues() - dimensionalPriceGroupId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DimensionalPriceConfiguration]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var dimensionalPriceGroupId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(dimensionalPriceConfiguration: DimensionalPriceConfiguration) = - apply { - dimensionValues = - dimensionalPriceConfiguration.dimensionValues.map { it.toMutableList() } - dimensionalPriceGroupId = - dimensionalPriceConfiguration.dimensionalPriceGroupId - additionalProperties = - dimensionalPriceConfiguration.additionalProperties.toMutableMap() - } - - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: String) = - dimensionalPriceGroupId(JsonField.of(dimensionalPriceGroupId)) - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: JsonField) = apply { - this.dimensionalPriceGroupId = dimensionalPriceGroupId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): DimensionalPriceConfiguration = - DimensionalPriceConfiguration( - checkRequired("dimensionValues", dimensionValues).map { it.toImmutable() }, - checkRequired("dimensionalPriceGroupId", dimensionalPriceGroupId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DimensionalPriceConfiguration && dimensionValues == other.dimensionValues && dimensionalPriceGroupId == other.dimensionalPriceGroupId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, dimensionalPriceGroupId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DimensionalPriceConfiguration{dimensionValues=$dimensionValues, dimensionalPriceGroupId=$dimensionalPriceGroupId, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is UnitWithPercentPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && unitWithPercentConfig == other.unitWithPercentConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is BpsPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && bpsConfig == other.bpsConfig && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, unitWithPercentConfig, dimensionalPriceConfiguration, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, bpsConfig, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "UnitWithPercentPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, unitWithPercentConfig=$unitWithPercentConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "BpsPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, bpsConfig=$bpsConfig, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } @NoAutoDetect - class MatrixWithAllocationPrice + class BulkBpsPrice @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("billable_metric") @ExcludeMissing - private val billableMetric: JsonField = JsonMissing.of(), + private val billableMetric: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") @ExcludeMissing - private val billingCycleConfiguration: JsonField = + private val billingCycleConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("bulk_bps_config") + @ExcludeMissing + private val bulkBpsConfig: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing private val cadence: JsonField = JsonMissing.of(), @@ -37762,7 +7358,7 @@ private constructor( private val createdAt: JsonField = JsonMissing.of(), @JsonProperty("credit_allocation") @ExcludeMissing - private val creditAllocation: JsonField = JsonMissing.of(), + private val creditAllocation: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing private val currency: JsonField = JsonMissing.of(), @@ -37777,16 +7373,14 @@ private constructor( private val fixedPriceQuantity: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = + private val invoicingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("item") @ExcludeMissing private val item: JsonField = JsonMissing.of(), - @JsonProperty("matrix_with_allocation_config") + @JsonProperty("item") @ExcludeMissing - private val matrixWithAllocationConfig: JsonField = - JsonMissing.of(), + private val item: JsonField = JsonMissing.of(), @JsonProperty("maximum") @ExcludeMissing - private val maximum: JsonField = JsonMissing.of(), + private val maximum: JsonField = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing private val maximumAmount: JsonField = JsonMissing.of(), @@ -37795,7 +7389,7 @@ private constructor( private val metadata: JsonField = JsonMissing.of(), @JsonProperty("minimum") @ExcludeMissing - private val minimum: JsonField = JsonMissing.of(), + private val minimum: JsonField = JsonMissing.of(), @JsonProperty("minimum_amount") @ExcludeMissing private val minimumAmount: JsonField = JsonMissing.of(), @@ -37813,7 +7407,7 @@ private constructor( private val priceType: JsonField = JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing - private val dimensionalPriceConfiguration: JsonField = + private val dimensionalPriceConfiguration: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), @@ -37821,12 +7415,14 @@ private constructor( fun id(): String = id.getRequired("id") - fun billableMetric(): Optional = + fun billableMetric(): Optional = Optional.ofNullable(billableMetric.getNullable("billable_metric")) - fun billingCycleConfiguration(): BillingCycleConfiguration = + fun billingCycleConfiguration(): BillingCycleConfigurationModel = billingCycleConfiguration.getRequired("billing_cycle_configuration") + fun bulkBpsConfig(): BulkBpsConfigModel = bulkBpsConfig.getRequired("bulk_bps_config") + fun cadence(): Cadence = cadence.getRequired("cadence") fun conversionRate(): Optional = @@ -37834,7 +7430,7 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - fun creditAllocation(): Optional = + fun creditAllocation(): Optional = Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) fun currency(): String = currency.getRequired("currency") @@ -37847,17 +7443,14 @@ private constructor( fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - fun invoicingCycleConfiguration(): Optional = + fun invoicingCycleConfiguration(): Optional = Optional.ofNullable( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") ) - fun item(): Item = item.getRequired("item") - - fun matrixWithAllocationConfig(): MatrixWithAllocationConfig = - matrixWithAllocationConfig.getRequired("matrix_with_allocation_config") + fun item(): ItemSlimModel = item.getRequired("item") - fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) @@ -37869,7 +7462,7 @@ private constructor( */ fun metadata(): Metadata = metadata.getRequired("metadata") - fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) fun minimumAmount(): Optional = Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) @@ -37883,7 +7476,7 @@ private constructor( fun priceType(): PriceType = priceType.getRequired("price_type") - fun dimensionalPriceConfiguration(): Optional = + fun dimensionalPriceConfiguration(): Optional = Optional.ofNullable( dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") ) @@ -37892,13 +7485,17 @@ private constructor( @JsonProperty("billable_metric") @ExcludeMissing - fun _billableMetric(): JsonField = billableMetric + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = + fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration + @JsonProperty("bulk_bps_config") + @ExcludeMissing + fun _bulkBpsConfig(): JsonField = bulkBpsConfig + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence @JsonProperty("conversion_rate") @@ -37911,7 +7508,7 @@ private constructor( @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation(): JsonField = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @@ -37927,17 +7524,12 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = + fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - - @JsonProperty("matrix_with_allocation_config") - @ExcludeMissing - fun _matrixWithAllocationConfig(): JsonField = - matrixWithAllocationConfig + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum @JsonProperty("maximum_amount") @ExcludeMissing @@ -37950,7 +7542,7 @@ private constructor( */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum @JsonProperty("minimum_amount") @ExcludeMissing @@ -37972,7 +7564,7 @@ private constructor( @JsonProperty("dimensional_price_configuration") @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = + fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration @JsonAnyGetter @@ -37981,7 +7573,7 @@ private constructor( private var validated: Boolean = false - fun validate(): MatrixWithAllocationPrice = apply { + fun validate(): BulkBpsPrice = apply { if (validated) { return@apply } @@ -37989,6 +7581,7 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() + bulkBpsConfig().validate() cadence() conversionRate() createdAt() @@ -37999,7 +7592,6 @@ private constructor( fixedPriceQuantity() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() - matrixWithAllocationConfig().validate() maximum().ifPresent { it.validate() } maximumAmount() metadata().validate() @@ -38017,90 +7609,129 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [BulkBpsPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .bulkBpsConfig() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [MatrixWithAllocationPrice]. */ + /** A builder for [BulkBpsPrice]. */ class Builder internal constructor() { private var id: JsonField? = null - private var billableMetric: JsonField? = null - private var billingCycleConfiguration: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var bulkBpsConfig: JsonField? = null private var cadence: JsonField? = null private var conversionRate: JsonField? = null private var createdAt: JsonField? = null - private var creditAllocation: 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 matrixWithAllocationConfig: JsonField? = null - private var maximum: 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 minimum: JsonField? = null private var minimumAmount: JsonField? = null private var modelType: JsonField? = null private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null - private var dimensionalPriceConfiguration: JsonField = + private var dimensionalPriceConfiguration: + JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(matrixWithAllocationPrice: MatrixWithAllocationPrice) = apply { - id = matrixWithAllocationPrice.id - billableMetric = matrixWithAllocationPrice.billableMetric - billingCycleConfiguration = matrixWithAllocationPrice.billingCycleConfiguration - cadence = matrixWithAllocationPrice.cadence - conversionRate = matrixWithAllocationPrice.conversionRate - createdAt = matrixWithAllocationPrice.createdAt - creditAllocation = matrixWithAllocationPrice.creditAllocation - currency = matrixWithAllocationPrice.currency - discount = matrixWithAllocationPrice.discount - externalPriceId = matrixWithAllocationPrice.externalPriceId - fixedPriceQuantity = matrixWithAllocationPrice.fixedPriceQuantity - invoicingCycleConfiguration = matrixWithAllocationPrice.invoicingCycleConfiguration - item = matrixWithAllocationPrice.item - matrixWithAllocationConfig = matrixWithAllocationPrice.matrixWithAllocationConfig - maximum = matrixWithAllocationPrice.maximum - maximumAmount = matrixWithAllocationPrice.maximumAmount - metadata = matrixWithAllocationPrice.metadata - minimum = matrixWithAllocationPrice.minimum - minimumAmount = matrixWithAllocationPrice.minimumAmount - modelType = matrixWithAllocationPrice.modelType - name = matrixWithAllocationPrice.name - planPhaseOrder = matrixWithAllocationPrice.planPhaseOrder - priceType = matrixWithAllocationPrice.priceType - dimensionalPriceConfiguration = - matrixWithAllocationPrice.dimensionalPriceConfiguration - additionalProperties = matrixWithAllocationPrice.additionalProperties.toMutableMap() + internal fun from(bulkBpsPrice: BulkBpsPrice) = apply { + id = bulkBpsPrice.id + billableMetric = bulkBpsPrice.billableMetric + billingCycleConfiguration = bulkBpsPrice.billingCycleConfiguration + bulkBpsConfig = bulkBpsPrice.bulkBpsConfig + cadence = bulkBpsPrice.cadence + conversionRate = bulkBpsPrice.conversionRate + createdAt = bulkBpsPrice.createdAt + creditAllocation = bulkBpsPrice.creditAllocation + currency = bulkBpsPrice.currency + discount = bulkBpsPrice.discount + externalPriceId = bulkBpsPrice.externalPriceId + fixedPriceQuantity = bulkBpsPrice.fixedPriceQuantity + invoicingCycleConfiguration = bulkBpsPrice.invoicingCycleConfiguration + item = bulkBpsPrice.item + maximum = bulkBpsPrice.maximum + maximumAmount = bulkBpsPrice.maximumAmount + metadata = bulkBpsPrice.metadata + minimum = bulkBpsPrice.minimum + minimumAmount = bulkBpsPrice.minimumAmount + modelType = bulkBpsPrice.modelType + name = bulkBpsPrice.name + planPhaseOrder = bulkBpsPrice.planPhaseOrder + priceType = bulkBpsPrice.priceType + dimensionalPriceConfiguration = bulkBpsPrice.dimensionalPriceConfiguration + additionalProperties = bulkBpsPrice.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric?) = + fun billableMetric(billableMetric: BillableMetricTinyModel?) = billableMetric(JsonField.ofNullable(billableMetric)) - fun billableMetric(billableMetric: Optional) = + fun billableMetric(billableMetric: Optional) = billableMetric(billableMetric.orElse(null)) - fun billableMetric(billableMetric: JsonField) = apply { + fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric } - fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = - billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) fun billingCycleConfiguration( - billingCycleConfiguration: JsonField + billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfigModel) = + bulkBpsConfig(JsonField.of(bulkBpsConfig)) + + fun bulkBpsConfig(bulkBpsConfig: JsonField) = apply { + this.bulkBpsConfig = bulkBpsConfig + } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) fun cadence(cadence: JsonField) = apply { this.cadence = cadence } @@ -38124,13 +7755,13 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation?) = + fun creditAllocation(creditAllocation: AllocationModel?) = creditAllocation(JsonField.ofNullable(creditAllocation)) - fun creditAllocation(creditAllocation: Optional) = + fun creditAllocation(creditAllocation: Optional) = creditAllocation(creditAllocation.orElse(null)) - fun creditAllocation(creditAllocation: JsonField) = apply { + fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation } @@ -38186,33 +7817,26 @@ private constructor( } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? + invoicingCycleConfiguration: BillingCycleConfigurationModel? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional + invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField + invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun item(item: Item) = item(JsonField.of(item)) - - fun item(item: JsonField) = apply { this.item = item } + fun item(item: ItemSlimModel) = item(JsonField.of(item)) - fun matrixWithAllocationConfig(matrixWithAllocationConfig: MatrixWithAllocationConfig) = - matrixWithAllocationConfig(JsonField.of(matrixWithAllocationConfig)) + fun item(item: JsonField) = apply { this.item = item } - fun matrixWithAllocationConfig( - matrixWithAllocationConfig: JsonField - ) = apply { this.matrixWithAllocationConfig = matrixWithAllocationConfig } + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } fun maximumAmount(maximumAmount: String?) = maximumAmount(JsonField.ofNullable(maximumAmount)) @@ -38238,11 +7862,11 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) - fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } fun minimumAmount(minimumAmount: String?) = minimumAmount(JsonField.ofNullable(minimumAmount)) @@ -38280,15 +7904,15 @@ private constructor( fun priceType(priceType: JsonField) = apply { this.priceType = priceType } fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: DimensionalPriceConfiguration? + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional + dimensionalPriceConfiguration: Optional ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField + dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } fun additionalProperties(additionalProperties: Map) = apply { @@ -38297,371 +7921,47 @@ private constructor( } fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): MatrixWithAllocationPrice = - MatrixWithAllocationPrice( - checkRequired("id", id), - checkRequired("billableMetric", billableMetric), - checkRequired("billingCycleConfiguration", billingCycleConfiguration), - checkRequired("cadence", cadence), - checkRequired("conversionRate", conversionRate), - 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("matrixWithAllocationConfig", matrixWithAllocationConfig), - checkRequired("maximum", maximum), - checkRequired("maximumAmount", maximumAmount), - checkRequired("metadata", metadata), - checkRequired("minimum", minimum), - checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("priceType", priceType), - dimensionalPriceConfiguration, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BillableMetric - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillableMetric = apply { - if (validated) { - return@apply - } - - id() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillableMetric]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billableMetric: BillableMetric) = apply { - id = billableMetric.id - additionalProperties = billableMetric.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - 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) - } - - fun build(): BillableMetric = - BillableMetric(checkRequired("id", id), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillableMetric && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillableMetric{id=$id, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() + additionalProperties.put(key, value) } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - override fun hashCode(): Int = hashCode + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + fun build(): BulkBpsPrice = + BulkBpsPrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("bulkBpsConfig", bulkBpsConfig), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) } class Cadence @JsonCreator private constructor(private val value: JsonField) : @@ -38789,43 +8089,30 @@ private constructor( override fun toString() = value.toString() } + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ @NoAutoDetect - class CreditAllocation + class Metadata @JsonCreator private constructor( - @JsonProperty("allows_rollover") - @ExcludeMissing - private val allowsRollover: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { - fun allowsRollover(): Boolean = allowsRollover.getRequired("allows_rollover") - - fun currency(): String = currency.getRequired("currency") - - @JsonProperty("allows_rollover") - @ExcludeMissing - fun _allowsRollover(): JsonField = allowsRollover - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties private var validated: Boolean = false - fun validate(): CreditAllocation = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } - allowsRollover() - currency() validated = true } @@ -38833,34 +8120,20 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [CreditAllocation]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { - private var allowsRollover: JsonField? = null - private var currency: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(creditAllocation: CreditAllocation) = apply { - allowsRollover = creditAllocation.allowsRollover - currency = creditAllocation.currency - additionalProperties = creditAllocation.additionalProperties.toMutableMap() - } - - fun allowsRollover(allowsRollover: Boolean) = - allowsRollover(JsonField.of(allowsRollover)) - - fun allowsRollover(allowsRollover: JsonField) = apply { - this.allowsRollover = allowsRollover + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -38883,12 +8156,7 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): CreditAllocation = - CreditAllocation( - checkRequired("allowsRollover", allowsRollover), - checkRequired("currency", currency), - additionalProperties.toImmutable(), - ) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -38896,907 +8164,988 @@ private constructor( return true } - return /* spotless:off */ other is CreditAllocation && allowsRollover == other.allowsRollover && currency == other.currency && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allowsRollover, currency, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode - override fun toString() = - "CreditAllocation{allowsRollover=$allowsRollover, currency=$currency, additionalProperties=$additionalProperties}" + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { - fun duration(): Long = duration.getRequired("duration") + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the 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 durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + companion object { - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + @JvmField val BULK_BPS = of("bulk_bps") - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** An enum containing [ModelType]'s known values. */ + enum class Known { + BULK_BPS + } - private var validated: Boolean = false + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + BULK_BPS, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - fun validate(): InvoicingCycleConfiguration = 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) { + BULK_BPS -> Value.BULK_BPS + else -> Value._UNKNOWN } - duration() - durationUnit() - 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) { + BULK_BPS -> Known.BULK_BPS + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } - fun toBuilder() = Builder().from(this) + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - companion object { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JvmStatic fun builder() = Builder() + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ } - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { + override fun hashCode() = value.hashCode() - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + override fun toString() = value.toString() + } - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { - fun duration(duration: Long) = duration(JsonField.of(duration)) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the 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 duration(duration: JsonField) = apply { this.duration = duration } + companion object { - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) + @JvmField val USAGE_PRICE = of("usage_price") - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } + @JvmField val FIXED_PRICE = of("fixed_price") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - 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 /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } - fun build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { + return /* spotless:off */ other is BulkBpsPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && bulkBpsConfig == other.bulkBpsConfig && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + } - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, bulkBpsConfig, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } + /* spotless:on */ - companion object { + override fun hashCode(): Int = hashCode - @JvmField val DAY = of("day") + override fun toString() = + "BulkBpsPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, bulkBpsConfig=$bulkBpsConfig, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } - @JvmField val MONTH = of("month") + @NoAutoDetect + class BulkPrice + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + private val billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("bulk_config") + @ExcludeMissing + private val bulkConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + private val creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + private val dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } + fun id(): String = id.getRequired("id") - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } + fun billableMetric(): Optional = + Optional.ofNullable(billableMetric.getNullable("billable_metric")) - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + fun billingCycleConfiguration(): BillingCycleConfigurationModel = + billingCycleConfiguration.getRequired("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) { - DAY -> Value.DAY - MONTH -> Value.MONTH - else -> Value._UNKNOWN - } + fun bulkConfig(): BulkConfigModel = bulkConfig.getRequired("bulk_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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } + fun cadence(): Cadence = cadence.getRequired("cadence") - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } + fun creditAllocation(): Optional = + Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) - override fun hashCode() = value.hashCode() + fun currency(): String = currency.getRequired("currency") - override fun toString() = value.toString() - } + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) - override fun hashCode(): Int = hashCode + fun item(): ItemSlimModel = item.getRequired("item") - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) - @NoAutoDetect - class Item - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - fun id(): String = id.getRequired("id") + /** + * 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.getRequired("metadata") - fun name(): String = name.getRequired("name") + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + fun modelType(): ModelType = modelType.getRequired("model_type") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun name(): String = name.getRequired("name") - private var validated: Boolean = false + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - fun validate(): Item = apply { - if (validated) { - return@apply - } + fun priceType(): PriceType = priceType.getRequired("price_type") - id() - name() - validated = true - } + fun dimensionalPriceConfiguration(): Optional = + Optional.ofNullable( + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + ) - fun toBuilder() = Builder().from(this) + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - companion object { + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric - @JvmStatic fun builder() = Builder() - } + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - /** A builder for [Item]. */ - class Builder internal constructor() { + @JsonProperty("bulk_config") + @ExcludeMissing + fun _bulkConfig(): JsonField = bulkConfig - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - @JvmSynthetic - internal fun from(item: Item) = apply { - id = item.id - name = item.name - additionalProperties = item.additionalProperties.toMutableMap() - } + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation + + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount + + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - fun id(id: String) = id(JsonField.of(id)) + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType - fun id(id: JsonField) = apply { this.id = id } + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun name(name: String) = name(JsonField.of(name)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - fun name(name: JsonField) = apply { this.name = name } + private var validated: Boolean = false - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun validate(): BulkPrice = apply { + if (validated) { + return@apply + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + bulkConfig().validate() + cadence() + conversionRate() + 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() + name() + planPhaseOrder() + priceType() + dimensionalPriceConfiguration().ifPresent { it.validate() } + validated = true + } - 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 [BulkPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .bulkConfig() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun build(): Item = - Item( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toImmutable(), - ) - } + /** A builder for [BulkPrice]. */ + class Builder internal constructor() { - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var bulkConfig: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: 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: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - return /* spotless:off */ other is Item && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + @JvmSynthetic + internal fun from(bulkPrice: BulkPrice) = apply { + id = bulkPrice.id + billableMetric = bulkPrice.billableMetric + billingCycleConfiguration = bulkPrice.billingCycleConfiguration + bulkConfig = bulkPrice.bulkConfig + cadence = bulkPrice.cadence + conversionRate = bulkPrice.conversionRate + createdAt = bulkPrice.createdAt + creditAllocation = bulkPrice.creditAllocation + currency = bulkPrice.currency + discount = bulkPrice.discount + externalPriceId = bulkPrice.externalPriceId + fixedPriceQuantity = bulkPrice.fixedPriceQuantity + invoicingCycleConfiguration = bulkPrice.invoicingCycleConfiguration + item = bulkPrice.item + maximum = bulkPrice.maximum + maximumAmount = bulkPrice.maximumAmount + metadata = bulkPrice.metadata + minimum = bulkPrice.minimum + minimumAmount = bulkPrice.minimumAmount + modelType = bulkPrice.modelType + name = bulkPrice.name + planPhaseOrder = bulkPrice.planPhaseOrder + priceType = bulkPrice.priceType + dimensionalPriceConfiguration = bulkPrice.dimensionalPriceConfiguration + additionalProperties = bulkPrice.additionalProperties.toMutableMap() } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - /* spotless:on */ + fun id(id: String) = id(JsonField.of(id)) - override fun hashCode(): Int = hashCode + fun id(id: JsonField) = apply { this.id = id } - override fun toString() = - "Item{id=$id, name=$name, additionalProperties=$additionalProperties}" - } + fun billableMetric(billableMetric: BillableMetricTinyModel?) = + billableMetric(JsonField.ofNullable(billableMetric)) - @NoAutoDetect - class MatrixWithAllocationConfig - @JsonCreator - private constructor( - @JsonProperty("allocation") - @ExcludeMissing - private val allocation: JsonField = JsonMissing.of(), - @JsonProperty("default_unit_amount") - @ExcludeMissing - private val defaultUnitAmount: JsonField = JsonMissing.of(), - @JsonProperty("dimensions") - @ExcludeMissing - private val dimensions: JsonField> = JsonMissing.of(), - @JsonProperty("matrix_values") - @ExcludeMissing - private val matrixValues: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) - /** Allocation to be used to calculate the price */ - fun allocation(): Double = allocation.getRequired("allocation") + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } - /** Default per unit rate for any usage not bucketed into a specified matrix_value */ - fun defaultUnitAmount(): String = defaultUnitAmount.getRequired("default_unit_amount") + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) - /** One or two event property values to evaluate matrix groups by */ - fun dimensions(): List = dimensions.getRequired("dimensions") + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - /** Matrix values for specified matrix grouping keys */ - fun matrixValues(): List = matrixValues.getRequired("matrix_values") + fun bulkConfig(bulkConfig: BulkConfigModel) = bulkConfig(JsonField.of(bulkConfig)) - /** Allocation to be used to calculate the price */ - @JsonProperty("allocation") - @ExcludeMissing - fun _allocation(): JsonField = allocation + fun bulkConfig(bulkConfig: JsonField) = apply { + this.bulkConfig = bulkConfig + } - /** Default per unit rate for any usage not bucketed into a specified matrix_value */ - @JsonProperty("default_unit_amount") - @ExcludeMissing - fun _defaultUnitAmount(): JsonField = defaultUnitAmount + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - /** One or two event property values to evaluate matrix groups by */ - @JsonProperty("dimensions") - @ExcludeMissing - fun _dimensions(): JsonField> = dimensions + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** Matrix values for specified matrix grouping keys */ - @JsonProperty("matrix_values") - @ExcludeMissing - fun _matrixValues(): JsonField> = matrixValues + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) - private var validated: Boolean = false + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) - fun validate(): MatrixWithAllocationConfig = apply { - if (validated) { - return@apply - } + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - allocation() - defaultUnitAmount() - dimensions() - matrixValues().forEach { it.validate() } - validated = true + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt } - fun toBuilder() = Builder().from(this) + fun creditAllocation(creditAllocation: AllocationModel?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) - companion object { + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) - @JvmStatic fun builder() = Builder() + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation } - /** A builder for [MatrixWithAllocationConfig]. */ - class Builder internal constructor() { + fun currency(currency: String) = currency(JsonField.of(currency)) - private var allocation: JsonField? = null - private var defaultUnitAmount: JsonField? = null - private var dimensions: JsonField>? = null - private var matrixValues: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun currency(currency: JsonField) = apply { this.currency = currency } - @JvmSynthetic - internal fun from(matrixWithAllocationConfig: MatrixWithAllocationConfig) = apply { - allocation = matrixWithAllocationConfig.allocation - defaultUnitAmount = matrixWithAllocationConfig.defaultUnitAmount - dimensions = matrixWithAllocationConfig.dimensions.map { it.toMutableList() } - matrixValues = - matrixWithAllocationConfig.matrixValues.map { it.toMutableList() } - additionalProperties = - matrixWithAllocationConfig.additionalProperties.toMutableMap() - } + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) - /** Allocation to be used to calculate the price */ - fun allocation(allocation: Double) = allocation(JsonField.of(allocation)) + fun discount(discount: Optional) = discount(discount.orElse(null)) - /** Allocation to be used to calculate the price */ - fun allocation(allocation: JsonField) = apply { - this.allocation = allocation - } + fun discount(discount: JsonField) = apply { this.discount = discount } - /** - * Default per unit rate for any usage not bucketed into a specified matrix_value - */ - fun defaultUnitAmount(defaultUnitAmount: String) = - defaultUnitAmount(JsonField.of(defaultUnitAmount)) + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) - /** - * Default per unit rate for any usage not bucketed into a specified matrix_value - */ - fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { - this.defaultUnitAmount = defaultUnitAmount - } + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) - /** One or two event property values to evaluate matrix groups by */ - fun dimensions(dimensions: List) = dimensions(JsonField.of(dimensions)) + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) - /** One or two event property values to evaluate matrix groups by */ - fun dimensions(dimensions: JsonField>) = apply { - this.dimensions = dimensions.map { it.toMutableList() } - } + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) - /** One or two event property values to evaluate matrix groups by */ - fun addDimension(dimension: String) = apply { - dimensions = - (dimensions ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimension) - } - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - /** Matrix values for specified matrix grouping keys */ - fun matrixValues(matrixValues: List) = - matrixValues(JsonField.of(matrixValues)) + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) - /** Matrix values for specified matrix grouping keys */ - fun matrixValues(matrixValues: JsonField>) = apply { - this.matrixValues = matrixValues.map { it.toMutableList() } - } + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - /** Matrix values for specified matrix grouping keys */ - fun addMatrixValue(matrixValue: MatrixValue) = apply { - matrixValues = - (matrixValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(matrixValue) - } - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) - fun build(): MatrixWithAllocationConfig = - MatrixWithAllocationConfig( - checkRequired("allocation", allocation), - checkRequired("defaultUnitAmount", defaultUnitAmount), - checkRequired("dimensions", dimensions).map { it.toImmutable() }, - checkRequired("matrixValues", matrixValues).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class MatrixValue - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - private val unitAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - /** - * One or two matrix keys to filter usage to this Matrix value by. For example, - * ["region", "tier"] could be used to filter cloud usage by a cloud region and an - * instance tier. - */ - fun dimensionValues(): List = - dimensionValues.getRequired("dimension_values") + fun item(item: ItemSlimModel) = item(JsonField.of(item)) - /** Unit price for the specified dimension_values */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") + fun item(item: JsonField) = apply { this.item = item } - /** - * One or two matrix keys to filter usage to this Matrix value by. For example, - * ["region", "tier"] could be used to filter cloud usage by a cloud region and an - * instance tier. - */ - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) - /** Unit price for the specified dimension_values */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - private var validated: Boolean = false + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) - fun validate(): MatrixValue = apply { - if (validated) { - return@apply - } + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) - dimensionValues() - unitAmount() - validated = true - } + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } - fun toBuilder() = Builder().from(this) + /** + * 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)) - companion object { + /** + * 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: JsonField) = apply { this.metadata = metadata } - @JvmStatic fun builder() = Builder() - } + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) - /** A builder for [MatrixValue]. */ - class Builder internal constructor() { + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - private var dimensionValues: JsonField>? = null - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - @JvmSynthetic - internal fun from(matrixValue: MatrixValue) = apply { - dimensionValues = matrixValue.dimensionValues.map { it.toMutableList() } - unitAmount = matrixValue.unitAmount - additionalProperties = matrixValue.additionalProperties.toMutableMap() - } + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) - /** - * One or two matrix keys to filter usage to this Matrix value by. For example, - * ["region", "tier"] could be used to filter cloud usage by a cloud region and - * an instance tier. - */ - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - /** - * One or two matrix keys to filter usage to this Matrix value by. For example, - * ["region", "tier"] could be used to filter cloud usage by a cloud region and - * an instance tier. - */ - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) - /** - * One or two matrix keys to filter usage to this Matrix value by. For example, - * ["region", "tier"] could be used to filter cloud usage by a cloud region and - * an instance tier. - */ - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } - /** Unit price for the specified dimension_values */ - fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** Unit price for the specified dimension_values */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun name(name: String) = name(JsonField.of(name)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun name(name: JsonField) = apply { this.name = name } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - fun build(): MatrixValue = - MatrixValue( - checkRequired("dimensionValues", dimensionValues).map { - it.toImmutable() - }, - checkRequired("unitAmount", unitAmount), - additionalProperties.toImmutable(), - ) - } + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) - return /* spotless:off */ other is MatrixValue && dimensionValues == other.dimensionValues && unitAmount == other.unitAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, unitAmount, additionalProperties) } - /* spotless:on */ + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) - override fun hashCode(): Int = hashCode + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - override fun toString() = - "MatrixValue{dimensionValues=$dimensionValues, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - return /* spotless:off */ other is MatrixWithAllocationConfig && allocation == other.allocation && defaultUnitAmount == other.defaultUnitAmount && dimensions == other.dimensions && matrixValues == other.matrixValues && additionalProperties == other.additionalProperties /* spotless:on */ + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allocation, defaultUnitAmount, dimensions, matrixValues, additionalProperties) } - /* spotless:on */ + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - override fun hashCode(): Int = hashCode + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun toString() = - "MatrixWithAllocationConfig{allocation=$allocation, defaultUnitAmount=$defaultUnitAmount, dimensions=$dimensions, matrixValues=$matrixValues, additionalProperties=$additionalProperties}" + fun build(): BulkPrice = + BulkPrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("bulkConfig", bulkConfig), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) } - @NoAutoDetect - class Maximum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Maximum amount applied */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** Maximum amount applied */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount + companion object { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + @JvmField val ONE_TIME = of("one_time") - private var validated: Boolean = false + @JvmField val MONTHLY = of("monthly") - fun validate(): Maximum = apply { - if (validated) { - return@apply - } + @JvmField val QUARTERLY = of("quarterly") - appliesToPriceIds() - maximumAmount() - validated = true - } + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun toBuilder() = Builder().from(this) + @JvmField val ANNUAL = of("annual") - companion object { + @JvmField val CUSTOM = of("custom") - @JvmStatic fun builder() = Builder() + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) } - /** A builder for [Maximum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = maximum.maximumAmount - additionalProperties = maximum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } + /** 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, /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. + * An enum member indicating that [Cadence] was instantiated with an unknown value. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + _UNKNOWN, + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + 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 removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + 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 build(): Maximum = - Maximum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("maximumAmount", maximumAmount), - additionalProperties.toImmutable(), - ) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Maximum && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, maximumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "Maximum{appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } /** @@ -39830,6 +9179,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } @@ -39885,171 +9235,6 @@ private constructor( override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - @NoAutoDetect - class Minimum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Minimum amount applied */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Minimum amount applied */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Minimum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - minimumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Minimum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var minimumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } - minimumAmount = minimum.minimumAmount - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Minimum = - Minimum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("minimumAmount", minimumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Minimum && appliesToPriceIds == other.appliesToPriceIds && minimumAmount == other.minimumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, minimumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" - } - class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -40065,14 +9250,14 @@ private constructor( companion object { - @JvmField val MATRIX_WITH_ALLOCATION = of("matrix_with_allocation") + @JvmField val BULK = of("bulk") @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } /** An enum containing [ModelType]'s known values. */ enum class Known { - MATRIX_WITH_ALLOCATION + BULK } /** @@ -40085,7 +9270,7 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - MATRIX_WITH_ALLOCATION, + BULK, /** * An enum member indicating that [ModelType] was instantiated with an unknown * value. @@ -40102,7 +9287,7 @@ private constructor( */ fun value(): Value = when (this) { - MATRIX_WITH_ALLOCATION -> Value.MATRIX_WITH_ALLOCATION + BULK -> Value.BULK else -> Value._UNKNOWN } @@ -40117,7 +9302,7 @@ private constructor( */ fun known(): Known = when (this) { - MATRIX_WITH_ALLOCATION -> Known.MATRIX_WITH_ALLOCATION + BULK -> Known.BULK else -> throw OrbInvalidDataException("Unknown ModelType: $value") } @@ -40248,178 +9433,35 @@ private constructor( override fun toString() = value.toString() } - @NoAutoDetect - class DimensionalPriceConfiguration - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - private val dimensionalPriceGroupId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun dimensionValues(): List = dimensionValues.getRequired("dimension_values") - - fun dimensionalPriceGroupId(): String = - dimensionalPriceGroupId.getRequired("dimensional_price_group_id") - - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - fun _dimensionalPriceGroupId(): JsonField = dimensionalPriceGroupId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): DimensionalPriceConfiguration = apply { - if (validated) { - return@apply - } - - dimensionValues() - dimensionalPriceGroupId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DimensionalPriceConfiguration]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var dimensionalPriceGroupId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(dimensionalPriceConfiguration: DimensionalPriceConfiguration) = - apply { - dimensionValues = - dimensionalPriceConfiguration.dimensionValues.map { it.toMutableList() } - dimensionalPriceGroupId = - dimensionalPriceConfiguration.dimensionalPriceGroupId - additionalProperties = - dimensionalPriceConfiguration.additionalProperties.toMutableMap() - } - - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: String) = - dimensionalPriceGroupId(JsonField.of(dimensionalPriceGroupId)) - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: JsonField) = apply { - this.dimensionalPriceGroupId = dimensionalPriceGroupId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): DimensionalPriceConfiguration = - DimensionalPriceConfiguration( - checkRequired("dimensionValues", dimensionValues).map { it.toImmutable() }, - checkRequired("dimensionalPriceGroupId", dimensionalPriceGroupId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DimensionalPriceConfiguration && dimensionValues == other.dimensionValues && dimensionalPriceGroupId == other.dimensionalPriceGroupId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, dimensionalPriceGroupId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DimensionalPriceConfiguration{dimensionValues=$dimensionValues, dimensionalPriceGroupId=$dimensionalPriceGroupId, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is MatrixWithAllocationPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && matrixWithAllocationConfig == other.matrixWithAllocationConfig && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is BulkPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && bulkConfig == other.bulkConfig && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, matrixWithAllocationConfig, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, bulkConfig, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "MatrixWithAllocationPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixWithAllocationConfig=$matrixWithAllocationConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "BulkPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, bulkConfig=$bulkConfig, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } @NoAutoDetect - class TieredWithProrationPrice + class ThresholdTotalAmountPrice @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("billable_metric") @ExcludeMissing - private val billableMetric: JsonField = JsonMissing.of(), + private val billableMetric: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") @ExcludeMissing - private val billingCycleConfiguration: JsonField = + private val billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing @@ -40432,7 +9474,7 @@ private constructor( private val createdAt: JsonField = JsonMissing.of(), @JsonProperty("credit_allocation") @ExcludeMissing - private val creditAllocation: JsonField = JsonMissing.of(), + private val creditAllocation: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing private val currency: JsonField = JsonMissing.of(), @@ -40447,12 +9489,14 @@ private constructor( private val fixedPriceQuantity: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = + private val invoicingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("item") @ExcludeMissing private val item: JsonField = JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), @JsonProperty("maximum") @ExcludeMissing - private val maximum: JsonField = JsonMissing.of(), + private val maximum: JsonField = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing private val maximumAmount: JsonField = JsonMissing.of(), @@ -40461,7 +9505,7 @@ private constructor( private val metadata: JsonField = JsonMissing.of(), @JsonProperty("minimum") @ExcludeMissing - private val minimum: JsonField = JsonMissing.of(), + private val minimum: JsonField = JsonMissing.of(), @JsonProperty("minimum_amount") @ExcludeMissing private val minimumAmount: JsonField = JsonMissing.of(), @@ -40477,13 +9521,13 @@ private constructor( @JsonProperty("price_type") @ExcludeMissing private val priceType: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") + @JsonProperty("threshold_total_amount_config") @ExcludeMissing - private val tieredWithProrationConfig: JsonField = + private val thresholdTotalAmountConfig: JsonField = JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing - private val dimensionalPriceConfiguration: JsonField = + private val dimensionalPriceConfiguration: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), @@ -40491,10 +9535,10 @@ private constructor( fun id(): String = id.getRequired("id") - fun billableMetric(): Optional = + fun billableMetric(): Optional = Optional.ofNullable(billableMetric.getNullable("billable_metric")) - fun billingCycleConfiguration(): BillingCycleConfiguration = + fun billingCycleConfiguration(): BillingCycleConfigurationModel = billingCycleConfiguration.getRequired("billing_cycle_configuration") fun cadence(): Cadence = cadence.getRequired("cadence") @@ -40504,7 +9548,7 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - fun creditAllocation(): Optional = + fun creditAllocation(): Optional = Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) fun currency(): String = currency.getRequired("currency") @@ -40517,14 +9561,14 @@ private constructor( fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - fun invoicingCycleConfiguration(): Optional = + fun invoicingCycleConfiguration(): Optional = Optional.ofNullable( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") ) - fun item(): Item = item.getRequired("item") + fun item(): ItemSlimModel = item.getRequired("item") - fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) @@ -40536,7 +9580,7 @@ private constructor( */ fun metadata(): Metadata = metadata.getRequired("metadata") - fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) fun minimumAmount(): Optional = Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) @@ -40550,10 +9594,10 @@ private constructor( fun priceType(): PriceType = priceType.getRequired("price_type") - fun tieredWithProrationConfig(): TieredWithProrationConfig = - tieredWithProrationConfig.getRequired("tiered_with_proration_config") + fun thresholdTotalAmountConfig(): CustomRatingFunctionConfigModel = + thresholdTotalAmountConfig.getRequired("threshold_total_amount_config") - fun dimensionalPriceConfiguration(): Optional = + fun dimensionalPriceConfiguration(): Optional = Optional.ofNullable( dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") ) @@ -40562,11 +9606,11 @@ private constructor( @JsonProperty("billable_metric") @ExcludeMissing - fun _billableMetric(): JsonField = billableMetric + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = + fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence @@ -40581,7 +9625,7 @@ private constructor( @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation(): JsonField = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @@ -40597,12 +9641,12 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = + fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum @JsonProperty("maximum_amount") @ExcludeMissing @@ -40615,7 +9659,7 @@ private constructor( */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum @JsonProperty("minimum_amount") @ExcludeMissing @@ -40635,14 +9679,14 @@ private constructor( @ExcludeMissing fun _priceType(): JsonField = priceType - @JsonProperty("tiered_with_proration_config") + @JsonProperty("threshold_total_amount_config") @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig + fun _thresholdTotalAmountConfig(): JsonField = + thresholdTotalAmountConfig @JsonProperty("dimensional_price_configuration") @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = + fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration @JsonAnyGetter @@ -40651,7 +9695,7 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithProrationPrice = apply { + fun validate(): ThresholdTotalAmountPrice = apply { if (validated) { return@apply } @@ -40678,7 +9722,7 @@ private constructor( name() planPhaseOrder() priceType() - tieredWithProrationConfig().validate() + thresholdTotalAmountConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } validated = true } @@ -40687,88 +9731,123 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [ThresholdTotalAmountPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * .thresholdTotalAmountConfig() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [TieredWithProrationPrice]. */ + /** A builder for [ThresholdTotalAmountPrice]. */ class Builder internal constructor() { private var id: JsonField? = null - private var billableMetric: JsonField? = null - private var billingCycleConfiguration: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null private var cadence: JsonField? = null private var conversionRate: JsonField? = null private var createdAt: JsonField? = null - private var creditAllocation: 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 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 minimum: JsonField? = null private var minimumAmount: JsonField? = null private var modelType: JsonField? = null private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null - private var tieredWithProrationConfig: JsonField? = null - private var dimensionalPriceConfiguration: JsonField = + private var thresholdTotalAmountConfig: JsonField? = + null + private var dimensionalPriceConfiguration: + JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredWithProrationPrice: TieredWithProrationPrice) = apply { - id = tieredWithProrationPrice.id - billableMetric = tieredWithProrationPrice.billableMetric - billingCycleConfiguration = tieredWithProrationPrice.billingCycleConfiguration - cadence = tieredWithProrationPrice.cadence - conversionRate = tieredWithProrationPrice.conversionRate - createdAt = tieredWithProrationPrice.createdAt - creditAllocation = tieredWithProrationPrice.creditAllocation - currency = tieredWithProrationPrice.currency - discount = tieredWithProrationPrice.discount - externalPriceId = tieredWithProrationPrice.externalPriceId - fixedPriceQuantity = tieredWithProrationPrice.fixedPriceQuantity - invoicingCycleConfiguration = tieredWithProrationPrice.invoicingCycleConfiguration - item = tieredWithProrationPrice.item - maximum = tieredWithProrationPrice.maximum - maximumAmount = tieredWithProrationPrice.maximumAmount - metadata = tieredWithProrationPrice.metadata - minimum = tieredWithProrationPrice.minimum - minimumAmount = tieredWithProrationPrice.minimumAmount - modelType = tieredWithProrationPrice.modelType - name = tieredWithProrationPrice.name - planPhaseOrder = tieredWithProrationPrice.planPhaseOrder - priceType = tieredWithProrationPrice.priceType - tieredWithProrationConfig = tieredWithProrationPrice.tieredWithProrationConfig + internal fun from(thresholdTotalAmountPrice: ThresholdTotalAmountPrice) = apply { + id = thresholdTotalAmountPrice.id + billableMetric = thresholdTotalAmountPrice.billableMetric + billingCycleConfiguration = thresholdTotalAmountPrice.billingCycleConfiguration + cadence = thresholdTotalAmountPrice.cadence + conversionRate = thresholdTotalAmountPrice.conversionRate + createdAt = thresholdTotalAmountPrice.createdAt + creditAllocation = thresholdTotalAmountPrice.creditAllocation + currency = thresholdTotalAmountPrice.currency + discount = thresholdTotalAmountPrice.discount + externalPriceId = thresholdTotalAmountPrice.externalPriceId + fixedPriceQuantity = thresholdTotalAmountPrice.fixedPriceQuantity + invoicingCycleConfiguration = thresholdTotalAmountPrice.invoicingCycleConfiguration + item = thresholdTotalAmountPrice.item + maximum = thresholdTotalAmountPrice.maximum + maximumAmount = thresholdTotalAmountPrice.maximumAmount + metadata = thresholdTotalAmountPrice.metadata + minimum = thresholdTotalAmountPrice.minimum + minimumAmount = thresholdTotalAmountPrice.minimumAmount + modelType = thresholdTotalAmountPrice.modelType + name = thresholdTotalAmountPrice.name + planPhaseOrder = thresholdTotalAmountPrice.planPhaseOrder + priceType = thresholdTotalAmountPrice.priceType + thresholdTotalAmountConfig = thresholdTotalAmountPrice.thresholdTotalAmountConfig dimensionalPriceConfiguration = - tieredWithProrationPrice.dimensionalPriceConfiguration - additionalProperties = tieredWithProrationPrice.additionalProperties.toMutableMap() + thresholdTotalAmountPrice.dimensionalPriceConfiguration + additionalProperties = thresholdTotalAmountPrice.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric?) = + fun billableMetric(billableMetric: BillableMetricTinyModel?) = billableMetric(JsonField.ofNullable(billableMetric)) - fun billableMetric(billableMetric: Optional) = + fun billableMetric(billableMetric: Optional) = billableMetric(billableMetric.orElse(null)) - fun billableMetric(billableMetric: JsonField) = apply { + fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric } - fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = - billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) fun billingCycleConfiguration( - billingCycleConfiguration: JsonField + billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -40794,13 +9873,13 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation?) = + fun creditAllocation(creditAllocation: AllocationModel?) = creditAllocation(JsonField.ofNullable(creditAllocation)) - fun creditAllocation(creditAllocation: Optional) = + fun creditAllocation(creditAllocation: Optional) = creditAllocation(creditAllocation.orElse(null)) - fun creditAllocation(creditAllocation: JsonField) = apply { + fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation } @@ -40856,26 +9935,26 @@ private constructor( } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? + invoicingCycleConfiguration: BillingCycleConfigurationModel? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional + invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField + invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun item(item: Item) = item(JsonField.of(item)) + fun item(item: ItemSlimModel) = item(JsonField.of(item)) - fun item(item: JsonField) = apply { this.item = item } + fun item(item: JsonField) = apply { this.item = item } - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) - fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } fun maximumAmount(maximumAmount: String?) = maximumAmount(JsonField.ofNullable(maximumAmount)) @@ -40901,11 +9980,11 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) - fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } fun minimumAmount(minimumAmount: String?) = minimumAmount(JsonField.ofNullable(minimumAmount)) @@ -40942,23 +10021,24 @@ private constructor( fun priceType(priceType: JsonField) = apply { this.priceType = priceType } - fun tieredWithProrationConfig(tieredWithProrationConfig: TieredWithProrationConfig) = - tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + fun thresholdTotalAmountConfig( + thresholdTotalAmountConfig: CustomRatingFunctionConfigModel + ) = thresholdTotalAmountConfig(JsonField.of(thresholdTotalAmountConfig)) - fun tieredWithProrationConfig( - tieredWithProrationConfig: JsonField - ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } + fun thresholdTotalAmountConfig( + thresholdTotalAmountConfig: JsonField + ) = apply { this.thresholdTotalAmountConfig = thresholdTotalAmountConfig } fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: DimensionalPriceConfiguration? + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional + dimensionalPriceConfiguration: Optional ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField + dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } fun additionalProperties(additionalProperties: Map) = apply { @@ -40971,367 +10051,43 @@ private constructor( } fun 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 build(): TieredWithProrationPrice = - TieredWithProrationPrice( - checkRequired("id", id), - checkRequired("billableMetric", billableMetric), - checkRequired("billingCycleConfiguration", billingCycleConfiguration), - checkRequired("cadence", cadence), - checkRequired("conversionRate", conversionRate), - checkRequired("createdAt", createdAt), - checkRequired("creditAllocation", creditAllocation), - checkRequired("currency", currency), - checkRequired("discount", discount), - checkRequired("externalPriceId", externalPriceId), - checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), - checkRequired("item", item), - checkRequired("maximum", maximum), - checkRequired("maximumAmount", maximumAmount), - checkRequired("metadata", metadata), - checkRequired("minimum", minimum), - checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("priceType", priceType), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), - dimensionalPriceConfiguration, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BillableMetric - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillableMetric = apply { - if (validated) { - return@apply - } - - id() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillableMetric]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billableMetric: BillableMetric) = apply { - id = billableMetric.id - additionalProperties = billableMetric.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - 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) - } - - fun build(): BillableMetric = - BillableMetric(checkRequired("id", id), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillableMetric && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillableMetric{id=$id, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + this.additionalProperties.putAll(additionalProperties) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - override fun hashCode(): Int = hashCode + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + fun build(): ThresholdTotalAmountPrice = + ThresholdTotalAmountPrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + checkRequired("thresholdTotalAmountConfig", thresholdTotalAmountConfig), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) } class Cadence @JsonCreator private constructor(private val value: JsonField) : @@ -41459,634 +10215,6 @@ private constructor( override fun toString() = value.toString() } - @NoAutoDetect - class CreditAllocation - @JsonCreator - private constructor( - @JsonProperty("allows_rollover") - @ExcludeMissing - private val allowsRollover: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun allowsRollover(): Boolean = allowsRollover.getRequired("allows_rollover") - - fun currency(): String = currency.getRequired("currency") - - @JsonProperty("allows_rollover") - @ExcludeMissing - fun _allowsRollover(): JsonField = allowsRollover - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditAllocation = apply { - if (validated) { - return@apply - } - - allowsRollover() - currency() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditAllocation]. */ - class Builder internal constructor() { - - private var allowsRollover: JsonField? = null - private var currency: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditAllocation: CreditAllocation) = apply { - allowsRollover = creditAllocation.allowsRollover - currency = creditAllocation.currency - additionalProperties = creditAllocation.additionalProperties.toMutableMap() - } - - fun allowsRollover(allowsRollover: Boolean) = - allowsRollover(JsonField.of(allowsRollover)) - - fun allowsRollover(allowsRollover: JsonField) = apply { - this.allowsRollover = allowsRollover - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditAllocation = - CreditAllocation( - checkRequired("allowsRollover", allowsRollover), - checkRequired("currency", currency), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditAllocation && allowsRollover == other.allowsRollover && currency == other.currency && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allowsRollover, currency, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditAllocation{allowsRollover=$allowsRollover, currency=$currency, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Item - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun name(): String = name.getRequired("name") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Item = apply { - if (validated) { - return@apply - } - - id() - name() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Item]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(item: Item) = apply { - id = item.id - name = item.name - additionalProperties = item.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun name(name: String) = name(JsonField.of(name)) - - 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) - } - - fun build(): Item = - Item( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Item && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Item{id=$id, name=$name, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Maximum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Maximum amount applied */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Maximum amount applied */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Maximum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - maximumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Maximum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = maximum.maximumAmount - additionalProperties = maximum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Maximum = - Maximum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("maximumAmount", maximumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Maximum && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, maximumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Maximum{appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, 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 @@ -42094,121 +10222,11 @@ private constructor( */ @NoAutoDetect class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Minimum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Minimum amount applied */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Minimum amount applied */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { @JsonAnyGetter @ExcludeMissing @@ -42216,13 +10234,11 @@ private constructor( private var validated: Boolean = false - fun validate(): Minimum = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } - appliesToPriceIds() - minimumAmount() validated = true } @@ -42230,62 +10246,18 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [Minimum]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { - private var appliesToPriceIds: JsonField>? = null - private var minimumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } - minimumAmount = minimum.minimumAmount - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -42310,14 +10282,7 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): Minimum = - Minimum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("minimumAmount", minimumAmount), - additionalProperties.toImmutable(), - ) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -42325,17 +10290,16 @@ private constructor( return true } - return /* spotless:off */ other is Minimum && appliesToPriceIds == other.appliesToPriceIds && minimumAmount == other.minimumAmount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, minimumAmount, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode - override fun toString() = - "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } class ModelType @JsonCreator private constructor(private val value: JsonField) : @@ -42353,14 +10317,14 @@ private constructor( companion object { - @JvmField val TIERED_WITH_PRORATION = of("tiered_with_proration") + @JvmField val THRESHOLD_TOTAL_AMOUNT = of("threshold_total_amount") @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } /** An enum containing [ModelType]'s known values. */ enum class Known { - TIERED_WITH_PRORATION + THRESHOLD_TOTAL_AMOUNT } /** @@ -42373,7 +10337,7 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - TIERED_WITH_PRORATION, + THRESHOLD_TOTAL_AMOUNT, /** * An enum member indicating that [ModelType] was instantiated with an unknown * value. @@ -42390,7 +10354,7 @@ private constructor( */ fun value(): Value = when (this) { - TIERED_WITH_PRORATION -> Value.TIERED_WITH_PRORATION + THRESHOLD_TOTAL_AMOUNT -> Value.THRESHOLD_TOTAL_AMOUNT else -> Value._UNKNOWN } @@ -42405,7 +10369,7 @@ private constructor( */ fun known(): Known = when (this) { - TIERED_WITH_PRORATION -> Known.TIERED_WITH_PRORATION + THRESHOLD_TOTAL_AMOUNT -> Known.THRESHOLD_TOTAL_AMOUNT else -> throw OrbInvalidDataException("Unknown ModelType: $value") } @@ -42536,262 +10500,35 @@ private constructor( override fun toString() = value.toString() } - @NoAutoDetect - class TieredWithProrationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredWithProrationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredWithProrationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = apply { - additionalProperties = - tieredWithProrationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredWithProrationConfig{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class DimensionalPriceConfiguration - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - private val dimensionalPriceGroupId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun dimensionValues(): List = dimensionValues.getRequired("dimension_values") - - fun dimensionalPriceGroupId(): String = - dimensionalPriceGroupId.getRequired("dimensional_price_group_id") - - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - fun _dimensionalPriceGroupId(): JsonField = dimensionalPriceGroupId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): DimensionalPriceConfiguration = apply { - if (validated) { - return@apply - } - - dimensionValues() - dimensionalPriceGroupId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DimensionalPriceConfiguration]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var dimensionalPriceGroupId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(dimensionalPriceConfiguration: DimensionalPriceConfiguration) = - apply { - dimensionValues = - dimensionalPriceConfiguration.dimensionValues.map { it.toMutableList() } - dimensionalPriceGroupId = - dimensionalPriceConfiguration.dimensionalPriceGroupId - additionalProperties = - dimensionalPriceConfiguration.additionalProperties.toMutableMap() - } - - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: String) = - dimensionalPriceGroupId(JsonField.of(dimensionalPriceGroupId)) - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: JsonField) = apply { - this.dimensionalPriceGroupId = dimensionalPriceGroupId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): DimensionalPriceConfiguration = - DimensionalPriceConfiguration( - checkRequired("dimensionValues", dimensionValues).map { it.toImmutable() }, - checkRequired("dimensionalPriceGroupId", dimensionalPriceGroupId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DimensionalPriceConfiguration && dimensionValues == other.dimensionValues && dimensionalPriceGroupId == other.dimensionalPriceGroupId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, dimensionalPriceGroupId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DimensionalPriceConfiguration{dimensionValues=$dimensionValues, dimensionalPriceGroupId=$dimensionalPriceGroupId, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is TieredWithProrationPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && tieredWithProrationConfig == other.tieredWithProrationConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ThresholdTotalAmountPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, tieredWithProrationConfig, dimensionalPriceConfiguration, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, thresholdTotalAmountConfig, dimensionalPriceConfiguration, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProrationPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, tieredWithProrationConfig=$tieredWithProrationConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "ThresholdTotalAmountPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } @NoAutoDetect - class UnitWithProrationPrice + class TieredPackagePrice @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("billable_metric") @ExcludeMissing - private val billableMetric: JsonField = JsonMissing.of(), + private val billableMetric: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") @ExcludeMissing - private val billingCycleConfiguration: JsonField = + private val billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing @@ -42804,7 +10541,7 @@ private constructor( private val createdAt: JsonField = JsonMissing.of(), @JsonProperty("credit_allocation") @ExcludeMissing - private val creditAllocation: JsonField = JsonMissing.of(), + private val creditAllocation: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing private val currency: JsonField = JsonMissing.of(), @@ -42819,12 +10556,14 @@ private constructor( private val fixedPriceQuantity: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = + private val invoicingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("item") @ExcludeMissing private val item: JsonField = JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), @JsonProperty("maximum") @ExcludeMissing - private val maximum: JsonField = JsonMissing.of(), + private val maximum: JsonField = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing private val maximumAmount: JsonField = JsonMissing.of(), @@ -42833,7 +10572,7 @@ private constructor( private val metadata: JsonField = JsonMissing.of(), @JsonProperty("minimum") @ExcludeMissing - private val minimum: JsonField = JsonMissing.of(), + private val minimum: JsonField = JsonMissing.of(), @JsonProperty("minimum_amount") @ExcludeMissing private val minimumAmount: JsonField = JsonMissing.of(), @@ -42849,12 +10588,13 @@ private constructor( @JsonProperty("price_type") @ExcludeMissing private val priceType: JsonField = JsonMissing.of(), - @JsonProperty("unit_with_proration_config") + @JsonProperty("tiered_package_config") @ExcludeMissing - private val unitWithProrationConfig: JsonField = JsonMissing.of(), + private val tieredPackageConfig: JsonField = + JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing - private val dimensionalPriceConfiguration: JsonField = + private val dimensionalPriceConfiguration: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), @@ -42862,10 +10602,10 @@ private constructor( fun id(): String = id.getRequired("id") - fun billableMetric(): Optional = + fun billableMetric(): Optional = Optional.ofNullable(billableMetric.getNullable("billable_metric")) - fun billingCycleConfiguration(): BillingCycleConfiguration = + fun billingCycleConfiguration(): BillingCycleConfigurationModel = billingCycleConfiguration.getRequired("billing_cycle_configuration") fun cadence(): Cadence = cadence.getRequired("cadence") @@ -42875,7 +10615,7 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - fun creditAllocation(): Optional = + fun creditAllocation(): Optional = Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) fun currency(): String = currency.getRequired("currency") @@ -42888,14 +10628,14 @@ private constructor( fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - fun invoicingCycleConfiguration(): Optional = + fun invoicingCycleConfiguration(): Optional = Optional.ofNullable( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") ) - fun item(): Item = item.getRequired("item") + fun item(): ItemSlimModel = item.getRequired("item") - fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) @@ -42907,7 +10647,7 @@ private constructor( */ fun metadata(): Metadata = metadata.getRequired("metadata") - fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) fun minimumAmount(): Optional = Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) @@ -42921,10 +10661,10 @@ private constructor( fun priceType(): PriceType = priceType.getRequired("price_type") - fun unitWithProrationConfig(): UnitWithProrationConfig = - unitWithProrationConfig.getRequired("unit_with_proration_config") + fun tieredPackageConfig(): CustomRatingFunctionConfigModel = + tieredPackageConfig.getRequired("tiered_package_config") - fun dimensionalPriceConfiguration(): Optional = + fun dimensionalPriceConfiguration(): Optional = Optional.ofNullable( dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") ) @@ -42933,11 +10673,11 @@ private constructor( @JsonProperty("billable_metric") @ExcludeMissing - fun _billableMetric(): JsonField = billableMetric + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = + fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence @@ -42952,7 +10692,7 @@ private constructor( @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation(): JsonField = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @@ -42968,12 +10708,12 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = + fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum @JsonProperty("maximum_amount") @ExcludeMissing @@ -42986,7 +10726,7 @@ private constructor( */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum @JsonProperty("minimum_amount") @ExcludeMissing @@ -43006,13 +10746,13 @@ private constructor( @ExcludeMissing fun _priceType(): JsonField = priceType - @JsonProperty("unit_with_proration_config") + @JsonProperty("tiered_package_config") @ExcludeMissing - fun _unitWithProrationConfig(): JsonField = unitWithProrationConfig + fun _tieredPackageConfig(): JsonField = tieredPackageConfig @JsonProperty("dimensional_price_configuration") @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = + fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration @JsonAnyGetter @@ -43021,7 +10761,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UnitWithProrationPrice = apply { + fun validate(): TieredPackagePrice = apply { if (validated) { return@apply } @@ -43048,7 +10788,7 @@ private constructor( name() planPhaseOrder() priceType() - unitWithProrationConfig().validate() + tieredPackageConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } validated = true } @@ -43057,87 +10797,120 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [TieredPackagePrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * .tieredPackageConfig() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [UnitWithProrationPrice]. */ + /** A builder for [TieredPackagePrice]. */ class Builder internal constructor() { private var id: JsonField? = null - private var billableMetric: JsonField? = null - private var billingCycleConfiguration: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null private var cadence: JsonField? = null private var conversionRate: JsonField? = null private var createdAt: JsonField? = null - private var creditAllocation: 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 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 minimum: JsonField? = null private var minimumAmount: JsonField? = null private var modelType: JsonField? = null private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null - private var unitWithProrationConfig: JsonField? = null - private var dimensionalPriceConfiguration: JsonField = + private var tieredPackageConfig: JsonField? = null + private var dimensionalPriceConfiguration: + JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unitWithProrationPrice: UnitWithProrationPrice) = apply { - id = unitWithProrationPrice.id - billableMetric = unitWithProrationPrice.billableMetric - billingCycleConfiguration = unitWithProrationPrice.billingCycleConfiguration - cadence = unitWithProrationPrice.cadence - conversionRate = unitWithProrationPrice.conversionRate - createdAt = unitWithProrationPrice.createdAt - creditAllocation = unitWithProrationPrice.creditAllocation - currency = unitWithProrationPrice.currency - discount = unitWithProrationPrice.discount - externalPriceId = unitWithProrationPrice.externalPriceId - fixedPriceQuantity = unitWithProrationPrice.fixedPriceQuantity - invoicingCycleConfiguration = unitWithProrationPrice.invoicingCycleConfiguration - item = unitWithProrationPrice.item - maximum = unitWithProrationPrice.maximum - maximumAmount = unitWithProrationPrice.maximumAmount - metadata = unitWithProrationPrice.metadata - minimum = unitWithProrationPrice.minimum - minimumAmount = unitWithProrationPrice.minimumAmount - modelType = unitWithProrationPrice.modelType - name = unitWithProrationPrice.name - planPhaseOrder = unitWithProrationPrice.planPhaseOrder - priceType = unitWithProrationPrice.priceType - unitWithProrationConfig = unitWithProrationPrice.unitWithProrationConfig - dimensionalPriceConfiguration = unitWithProrationPrice.dimensionalPriceConfiguration - additionalProperties = unitWithProrationPrice.additionalProperties.toMutableMap() + internal fun from(tieredPackagePrice: TieredPackagePrice) = apply { + id = tieredPackagePrice.id + billableMetric = tieredPackagePrice.billableMetric + billingCycleConfiguration = tieredPackagePrice.billingCycleConfiguration + cadence = tieredPackagePrice.cadence + conversionRate = tieredPackagePrice.conversionRate + createdAt = tieredPackagePrice.createdAt + creditAllocation = tieredPackagePrice.creditAllocation + currency = tieredPackagePrice.currency + discount = tieredPackagePrice.discount + externalPriceId = tieredPackagePrice.externalPriceId + fixedPriceQuantity = tieredPackagePrice.fixedPriceQuantity + invoicingCycleConfiguration = tieredPackagePrice.invoicingCycleConfiguration + item = tieredPackagePrice.item + maximum = tieredPackagePrice.maximum + maximumAmount = tieredPackagePrice.maximumAmount + metadata = tieredPackagePrice.metadata + minimum = tieredPackagePrice.minimum + minimumAmount = tieredPackagePrice.minimumAmount + modelType = tieredPackagePrice.modelType + name = tieredPackagePrice.name + planPhaseOrder = tieredPackagePrice.planPhaseOrder + priceType = tieredPackagePrice.priceType + tieredPackageConfig = tieredPackagePrice.tieredPackageConfig + dimensionalPriceConfiguration = tieredPackagePrice.dimensionalPriceConfiguration + additionalProperties = tieredPackagePrice.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric?) = + fun billableMetric(billableMetric: BillableMetricTinyModel?) = billableMetric(JsonField.ofNullable(billableMetric)) - fun billableMetric(billableMetric: Optional) = + fun billableMetric(billableMetric: Optional) = billableMetric(billableMetric.orElse(null)) - fun billableMetric(billableMetric: JsonField) = apply { + fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric } - fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = - billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) fun billingCycleConfiguration( - billingCycleConfiguration: JsonField + billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -43163,13 +10936,13 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation?) = + fun creditAllocation(creditAllocation: AllocationModel?) = creditAllocation(JsonField.ofNullable(creditAllocation)) - fun creditAllocation(creditAllocation: Optional) = + fun creditAllocation(creditAllocation: Optional) = creditAllocation(creditAllocation.orElse(null)) - fun creditAllocation(creditAllocation: JsonField) = apply { + fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation } @@ -43225,26 +10998,26 @@ private constructor( } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? + invoicingCycleConfiguration: BillingCycleConfigurationModel? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional + invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField + invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun item(item: Item) = item(JsonField.of(item)) + fun item(item: ItemSlimModel) = item(JsonField.of(item)) - fun item(item: JsonField) = apply { this.item = item } + fun item(item: JsonField) = apply { this.item = item } - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) - fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } fun maximumAmount(maximumAmount: String?) = maximumAmount(JsonField.ofNullable(maximumAmount)) @@ -43270,11 +11043,11 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) - fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } fun minimumAmount(minimumAmount: String?) = minimumAmount(JsonField.ofNullable(minimumAmount)) @@ -43311,23 +11084,23 @@ private constructor( fun priceType(priceType: JsonField) = apply { this.priceType = priceType } - fun unitWithProrationConfig(unitWithProrationConfig: UnitWithProrationConfig) = - unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) + fun tieredPackageConfig(tieredPackageConfig: CustomRatingFunctionConfigModel) = + tieredPackageConfig(JsonField.of(tieredPackageConfig)) - fun unitWithProrationConfig( - unitWithProrationConfig: JsonField - ) = apply { this.unitWithProrationConfig = unitWithProrationConfig } + fun tieredPackageConfig( + tieredPackageConfig: JsonField + ) = apply { this.tieredPackageConfig = tieredPackageConfig } fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: DimensionalPriceConfiguration? + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional + dimensionalPriceConfiguration: Optional ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField + dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } fun additionalProperties(additionalProperties: Map) = apply { @@ -43335,372 +11108,48 @@ private constructor( putAllAdditionalProperties(additionalProperties) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): UnitWithProrationPrice = - UnitWithProrationPrice( - checkRequired("id", id), - checkRequired("billableMetric", billableMetric), - checkRequired("billingCycleConfiguration", billingCycleConfiguration), - checkRequired("cadence", cadence), - checkRequired("conversionRate", conversionRate), - checkRequired("createdAt", createdAt), - checkRequired("creditAllocation", creditAllocation), - checkRequired("currency", currency), - checkRequired("discount", discount), - checkRequired("externalPriceId", externalPriceId), - checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), - checkRequired("item", item), - checkRequired("maximum", maximum), - checkRequired("maximumAmount", maximumAmount), - checkRequired("metadata", metadata), - checkRequired("minimum", minimum), - checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("priceType", priceType), - checkRequired("unitWithProrationConfig", unitWithProrationConfig), - dimensionalPriceConfiguration, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BillableMetric - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillableMetric = apply { - if (validated) { - return@apply - } - - id() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillableMetric]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billableMetric: BillableMetric) = apply { - id = billableMetric.id - additionalProperties = billableMetric.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - 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) - } - - fun build(): BillableMetric = - BillableMetric(checkRequired("id", id), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillableMetric && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillableMetric{id=$id, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - override fun hashCode(): Int = hashCode + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + fun build(): TieredPackagePrice = + TieredPackagePrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + checkRequired("tieredPackageConfig", tieredPackageConfig), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) } class Cadence @JsonCreator private constructor(private val value: JsonField) : @@ -43828,634 +11277,6 @@ private constructor( override fun toString() = value.toString() } - @NoAutoDetect - class CreditAllocation - @JsonCreator - private constructor( - @JsonProperty("allows_rollover") - @ExcludeMissing - private val allowsRollover: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun allowsRollover(): Boolean = allowsRollover.getRequired("allows_rollover") - - fun currency(): String = currency.getRequired("currency") - - @JsonProperty("allows_rollover") - @ExcludeMissing - fun _allowsRollover(): JsonField = allowsRollover - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditAllocation = apply { - if (validated) { - return@apply - } - - allowsRollover() - currency() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditAllocation]. */ - class Builder internal constructor() { - - private var allowsRollover: JsonField? = null - private var currency: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditAllocation: CreditAllocation) = apply { - allowsRollover = creditAllocation.allowsRollover - currency = creditAllocation.currency - additionalProperties = creditAllocation.additionalProperties.toMutableMap() - } - - fun allowsRollover(allowsRollover: Boolean) = - allowsRollover(JsonField.of(allowsRollover)) - - fun allowsRollover(allowsRollover: JsonField) = apply { - this.allowsRollover = allowsRollover - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditAllocation = - CreditAllocation( - checkRequired("allowsRollover", allowsRollover), - checkRequired("currency", currency), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditAllocation && allowsRollover == other.allowsRollover && currency == other.currency && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allowsRollover, currency, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditAllocation{allowsRollover=$allowsRollover, currency=$currency, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Item - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun name(): String = name.getRequired("name") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Item = apply { - if (validated) { - return@apply - } - - id() - name() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Item]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(item: Item) = apply { - id = item.id - name = item.name - additionalProperties = item.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun name(name: String) = name(JsonField.of(name)) - - 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) - } - - fun build(): Item = - Item( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Item && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Item{id=$id, name=$name, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Maximum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Maximum amount applied */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Maximum amount applied */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Maximum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - maximumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Maximum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = maximum.maximumAmount - additionalProperties = maximum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Maximum = - Maximum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("maximumAmount", maximumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Maximum && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, maximumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Maximum{appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, 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 @@ -44475,123 +11296,11 @@ private constructor( private var validated: Boolean = false - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Minimum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Minimum amount applied */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Minimum amount applied */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Minimum = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } - appliesToPriceIds() - minimumAmount() validated = true } @@ -44599,62 +11308,18 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [Minimum]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { - private var appliesToPriceIds: JsonField>? = null - private var minimumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } - minimumAmount = minimum.minimumAmount - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -44679,14 +11344,7 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): Minimum = - Minimum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("minimumAmount", minimumAmount), - additionalProperties.toImmutable(), - ) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -44694,17 +11352,16 @@ private constructor( return true } - return /* spotless:off */ other is Minimum && appliesToPriceIds == other.appliesToPriceIds && minimumAmount == other.minimumAmount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, minimumAmount, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode - override fun toString() = - "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } class ModelType @JsonCreator private constructor(private val value: JsonField) : @@ -44722,14 +11379,14 @@ private constructor( companion object { - @JvmField val UNIT_WITH_PRORATION = of("unit_with_proration") + @JvmField val TIERED_PACKAGE = of("tiered_package") @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } /** An enum containing [ModelType]'s known values. */ enum class Known { - UNIT_WITH_PRORATION + TIERED_PACKAGE } /** @@ -44742,7 +11399,7 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - UNIT_WITH_PRORATION, + TIERED_PACKAGE, /** * An enum member indicating that [ModelType] was instantiated with an unknown * value. @@ -44759,7 +11416,7 @@ private constructor( */ fun value(): Value = when (this) { - UNIT_WITH_PRORATION -> Value.UNIT_WITH_PRORATION + TIERED_PACKAGE -> Value.TIERED_PACKAGE else -> Value._UNKNOWN } @@ -44774,7 +11431,7 @@ private constructor( */ fun known(): Known = when (this) { - UNIT_WITH_PRORATION -> Known.UNIT_WITH_PRORATION + TIERED_PACKAGE -> Known.TIERED_PACKAGE else -> throw OrbInvalidDataException("Unknown ModelType: $value") } @@ -44905,262 +11562,35 @@ private constructor( override fun toString() = value.toString() } - @NoAutoDetect - class UnitWithProrationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): UnitWithProrationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnitWithProrationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unitWithProrationConfig: UnitWithProrationConfig) = apply { - additionalProperties = - unitWithProrationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): UnitWithProrationConfig = - UnitWithProrationConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UnitWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnitWithProrationConfig{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class DimensionalPriceConfiguration - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - private val dimensionalPriceGroupId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun dimensionValues(): List = dimensionValues.getRequired("dimension_values") - - fun dimensionalPriceGroupId(): String = - dimensionalPriceGroupId.getRequired("dimensional_price_group_id") - - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - fun _dimensionalPriceGroupId(): JsonField = dimensionalPriceGroupId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): DimensionalPriceConfiguration = apply { - if (validated) { - return@apply - } - - dimensionValues() - dimensionalPriceGroupId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DimensionalPriceConfiguration]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var dimensionalPriceGroupId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(dimensionalPriceConfiguration: DimensionalPriceConfiguration) = - apply { - dimensionValues = - dimensionalPriceConfiguration.dimensionValues.map { it.toMutableList() } - dimensionalPriceGroupId = - dimensionalPriceConfiguration.dimensionalPriceGroupId - additionalProperties = - dimensionalPriceConfiguration.additionalProperties.toMutableMap() - } - - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: String) = - dimensionalPriceGroupId(JsonField.of(dimensionalPriceGroupId)) - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: JsonField) = apply { - this.dimensionalPriceGroupId = dimensionalPriceGroupId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): DimensionalPriceConfiguration = - DimensionalPriceConfiguration( - checkRequired("dimensionValues", dimensionValues).map { it.toImmutable() }, - checkRequired("dimensionalPriceGroupId", dimensionalPriceGroupId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DimensionalPriceConfiguration && dimensionValues == other.dimensionValues && dimensionalPriceGroupId == other.dimensionalPriceGroupId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, dimensionalPriceGroupId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DimensionalPriceConfiguration{dimensionValues=$dimensionValues, dimensionalPriceGroupId=$dimensionalPriceGroupId, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is UnitWithProrationPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && unitWithProrationConfig == other.unitWithProrationConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredPackagePrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && tieredPackageConfig == other.tieredPackageConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, unitWithProrationConfig, dimensionalPriceConfiguration, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, tieredPackageConfig, dimensionalPriceConfiguration, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "UnitWithProrationPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, unitWithProrationConfig=$unitWithProrationConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "TieredPackagePrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, tieredPackageConfig=$tieredPackageConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } @NoAutoDetect - class GroupedAllocationPrice + class GroupedTieredPrice @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("billable_metric") @ExcludeMissing - private val billableMetric: JsonField = JsonMissing.of(), + private val billableMetric: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") @ExcludeMissing - private val billingCycleConfiguration: JsonField = + private val billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing @@ -45173,7 +11603,7 @@ private constructor( private val createdAt: JsonField = JsonMissing.of(), @JsonProperty("credit_allocation") @ExcludeMissing - private val creditAllocation: JsonField = JsonMissing.of(), + private val creditAllocation: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing private val currency: JsonField = JsonMissing.of(), @@ -45186,17 +11616,20 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("grouped_allocation_config") + @JsonProperty("grouped_tiered_config") @ExcludeMissing - private val groupedAllocationConfig: JsonField = JsonMissing.of(), + private val groupedTieredConfig: JsonField = + JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = + private val invoicingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("item") @ExcludeMissing private val item: JsonField = JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), @JsonProperty("maximum") @ExcludeMissing - private val maximum: JsonField = JsonMissing.of(), + private val maximum: JsonField = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing private val maximumAmount: JsonField = JsonMissing.of(), @@ -45205,7 +11638,7 @@ private constructor( private val metadata: JsonField = JsonMissing.of(), @JsonProperty("minimum") @ExcludeMissing - private val minimum: JsonField = JsonMissing.of(), + private val minimum: JsonField = JsonMissing.of(), @JsonProperty("minimum_amount") @ExcludeMissing private val minimumAmount: JsonField = JsonMissing.of(), @@ -45223,7 +11656,7 @@ private constructor( private val priceType: JsonField = JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing - private val dimensionalPriceConfiguration: JsonField = + private val dimensionalPriceConfiguration: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), @@ -45231,10 +11664,10 @@ private constructor( fun id(): String = id.getRequired("id") - fun billableMetric(): Optional = + fun billableMetric(): Optional = Optional.ofNullable(billableMetric.getNullable("billable_metric")) - fun billingCycleConfiguration(): BillingCycleConfiguration = + fun billingCycleConfiguration(): BillingCycleConfigurationModel = billingCycleConfiguration.getRequired("billing_cycle_configuration") fun cadence(): Cadence = cadence.getRequired("cadence") @@ -45244,7 +11677,7 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - fun creditAllocation(): Optional = + fun creditAllocation(): Optional = Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) fun currency(): String = currency.getRequired("currency") @@ -45257,17 +11690,17 @@ private constructor( fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - fun groupedAllocationConfig(): GroupedAllocationConfig = - groupedAllocationConfig.getRequired("grouped_allocation_config") + fun groupedTieredConfig(): CustomRatingFunctionConfigModel = + groupedTieredConfig.getRequired("grouped_tiered_config") - fun invoicingCycleConfiguration(): Optional = + fun invoicingCycleConfiguration(): Optional = Optional.ofNullable( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") ) - fun item(): Item = item.getRequired("item") + fun item(): ItemSlimModel = item.getRequired("item") - fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) @@ -45279,7 +11712,7 @@ private constructor( */ fun metadata(): Metadata = metadata.getRequired("metadata") - fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) fun minimumAmount(): Optional = Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) @@ -45293,7 +11726,7 @@ private constructor( fun priceType(): PriceType = priceType.getRequired("price_type") - fun dimensionalPriceConfiguration(): Optional = + fun dimensionalPriceConfiguration(): Optional = Optional.ofNullable( dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") ) @@ -45302,11 +11735,11 @@ private constructor( @JsonProperty("billable_metric") @ExcludeMissing - fun _billableMetric(): JsonField = billableMetric + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = + fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence @@ -45321,7 +11754,7 @@ private constructor( @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation(): JsonField = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @@ -45335,18 +11768,18 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - @JsonProperty("grouped_allocation_config") + @JsonProperty("grouped_tiered_config") @ExcludeMissing - fun _groupedAllocationConfig(): JsonField = groupedAllocationConfig + fun _groupedTieredConfig(): JsonField = groupedTieredConfig @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = + fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum @JsonProperty("maximum_amount") @ExcludeMissing @@ -45359,7 +11792,7 @@ private constructor( */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum @JsonProperty("minimum_amount") @ExcludeMissing @@ -45381,7 +11814,7 @@ private constructor( @JsonProperty("dimensional_price_configuration") @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = + fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration @JsonAnyGetter @@ -45390,7 +11823,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedAllocationPrice = apply { + fun validate(): GroupedTieredPrice = apply { if (validated) { return@apply } @@ -45406,7 +11839,7 @@ private constructor( discount().ifPresent { it.validate() } externalPriceId() fixedPriceQuantity() - groupedAllocationConfig().validate() + groupedTieredConfig().validate() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() maximum().ifPresent { it.validate() } @@ -45426,87 +11859,120 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [GroupedTieredPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .groupedTieredConfig() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedAllocationPrice]. */ + /** A builder for [GroupedTieredPrice]. */ class Builder internal constructor() { private var id: JsonField? = null - private var billableMetric: JsonField? = null - private var billingCycleConfiguration: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null private var cadence: JsonField? = null private var conversionRate: JsonField? = null private var createdAt: JsonField? = null - private var creditAllocation: 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 groupedTieredConfig: 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 minimum: JsonField? = null private var minimumAmount: JsonField? = null private var modelType: JsonField? = null private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null - private var dimensionalPriceConfiguration: JsonField = + private var dimensionalPriceConfiguration: + JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(groupedAllocationPrice: GroupedAllocationPrice) = apply { - id = groupedAllocationPrice.id - billableMetric = groupedAllocationPrice.billableMetric - billingCycleConfiguration = groupedAllocationPrice.billingCycleConfiguration - cadence = groupedAllocationPrice.cadence - conversionRate = groupedAllocationPrice.conversionRate - createdAt = groupedAllocationPrice.createdAt - creditAllocation = groupedAllocationPrice.creditAllocation - currency = groupedAllocationPrice.currency - discount = groupedAllocationPrice.discount - externalPriceId = groupedAllocationPrice.externalPriceId - fixedPriceQuantity = groupedAllocationPrice.fixedPriceQuantity - groupedAllocationConfig = groupedAllocationPrice.groupedAllocationConfig - invoicingCycleConfiguration = groupedAllocationPrice.invoicingCycleConfiguration - item = groupedAllocationPrice.item - maximum = groupedAllocationPrice.maximum - maximumAmount = groupedAllocationPrice.maximumAmount - metadata = groupedAllocationPrice.metadata - minimum = groupedAllocationPrice.minimum - minimumAmount = groupedAllocationPrice.minimumAmount - modelType = groupedAllocationPrice.modelType - name = groupedAllocationPrice.name - planPhaseOrder = groupedAllocationPrice.planPhaseOrder - priceType = groupedAllocationPrice.priceType - dimensionalPriceConfiguration = groupedAllocationPrice.dimensionalPriceConfiguration - additionalProperties = groupedAllocationPrice.additionalProperties.toMutableMap() + internal fun from(groupedTieredPrice: GroupedTieredPrice) = apply { + id = groupedTieredPrice.id + billableMetric = groupedTieredPrice.billableMetric + billingCycleConfiguration = groupedTieredPrice.billingCycleConfiguration + cadence = groupedTieredPrice.cadence + conversionRate = groupedTieredPrice.conversionRate + createdAt = groupedTieredPrice.createdAt + creditAllocation = groupedTieredPrice.creditAllocation + currency = groupedTieredPrice.currency + discount = groupedTieredPrice.discount + externalPriceId = groupedTieredPrice.externalPriceId + fixedPriceQuantity = groupedTieredPrice.fixedPriceQuantity + groupedTieredConfig = groupedTieredPrice.groupedTieredConfig + invoicingCycleConfiguration = groupedTieredPrice.invoicingCycleConfiguration + item = groupedTieredPrice.item + maximum = groupedTieredPrice.maximum + maximumAmount = groupedTieredPrice.maximumAmount + metadata = groupedTieredPrice.metadata + minimum = groupedTieredPrice.minimum + minimumAmount = groupedTieredPrice.minimumAmount + modelType = groupedTieredPrice.modelType + name = groupedTieredPrice.name + planPhaseOrder = groupedTieredPrice.planPhaseOrder + priceType = groupedTieredPrice.priceType + dimensionalPriceConfiguration = groupedTieredPrice.dimensionalPriceConfiguration + additionalProperties = groupedTieredPrice.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric?) = + fun billableMetric(billableMetric: BillableMetricTinyModel?) = billableMetric(JsonField.ofNullable(billableMetric)) - fun billableMetric(billableMetric: Optional) = + fun billableMetric(billableMetric: Optional) = billableMetric(billableMetric.orElse(null)) - fun billableMetric(billableMetric: JsonField) = apply { + fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric } - fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = - billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) fun billingCycleConfiguration( - billingCycleConfiguration: JsonField + billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -45532,13 +11998,13 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation?) = + fun creditAllocation(creditAllocation: AllocationModel?) = creditAllocation(JsonField.ofNullable(creditAllocation)) - fun creditAllocation(creditAllocation: Optional) = + fun creditAllocation(creditAllocation: Optional) = creditAllocation(creditAllocation.orElse(null)) - fun creditAllocation(creditAllocation: JsonField) = apply { + fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation } @@ -45593,34 +12059,34 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } - fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = - groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) + fun groupedTieredConfig(groupedTieredConfig: CustomRatingFunctionConfigModel) = + groupedTieredConfig(JsonField.of(groupedTieredConfig)) - fun groupedAllocationConfig( - groupedAllocationConfig: JsonField - ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } + fun groupedTieredConfig( + groupedTieredConfig: JsonField + ) = apply { this.groupedTieredConfig = groupedTieredConfig } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? + invoicingCycleConfiguration: BillingCycleConfigurationModel? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional + invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField + invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun item(item: Item) = item(JsonField.of(item)) + fun item(item: ItemSlimModel) = item(JsonField.of(item)) - fun item(item: JsonField) = apply { this.item = item } + fun item(item: JsonField) = apply { this.item = item } - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) - fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } fun maximumAmount(maximumAmount: String?) = maximumAmount(JsonField.ofNullable(maximumAmount)) @@ -45646,11 +12112,11 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) - fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } fun minimumAmount(minimumAmount: String?) = minimumAmount(JsonField.ofNullable(minimumAmount)) @@ -45683,393 +12149,69 @@ private constructor( this.planPhaseOrder = planPhaseOrder } - fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) - - fun priceType(priceType: JsonField) = apply { this.priceType = priceType } - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: DimensionalPriceConfiguration? - ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional - ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): GroupedAllocationPrice = - GroupedAllocationPrice( - checkRequired("id", id), - checkRequired("billableMetric", billableMetric), - checkRequired("billingCycleConfiguration", billingCycleConfiguration), - checkRequired("cadence", cadence), - checkRequired("conversionRate", conversionRate), - 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), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("priceType", priceType), - dimensionalPriceConfiguration, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BillableMetric - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillableMetric = apply { - if (validated) { - return@apply - } - - id() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillableMetric]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billableMetric: BillableMetric) = apply { - id = billableMetric.id - additionalProperties = billableMetric.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - 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) - } - - fun build(): BillableMetric = - BillableMetric(checkRequired("id", id), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillableMetric && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillableMetric{id=$id, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) - override fun hashCode() = value.hashCode() + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - override fun toString() = value.toString() + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - override fun hashCode(): Int = hashCode + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + fun build(): GroupedTieredPrice = + GroupedTieredPrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("groupedTieredConfig", groupedTieredConfig), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) } class Cadence @JsonCreator private constructor(private val value: JsonField) : @@ -46197,718 +12339,6 @@ private constructor( override fun toString() = value.toString() } - @NoAutoDetect - class CreditAllocation - @JsonCreator - private constructor( - @JsonProperty("allows_rollover") - @ExcludeMissing - private val allowsRollover: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun allowsRollover(): Boolean = allowsRollover.getRequired("allows_rollover") - - fun currency(): String = currency.getRequired("currency") - - @JsonProperty("allows_rollover") - @ExcludeMissing - fun _allowsRollover(): JsonField = allowsRollover - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditAllocation = apply { - if (validated) { - return@apply - } - - allowsRollover() - currency() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditAllocation]. */ - class Builder internal constructor() { - - private var allowsRollover: JsonField? = null - private var currency: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditAllocation: CreditAllocation) = apply { - allowsRollover = creditAllocation.allowsRollover - currency = creditAllocation.currency - additionalProperties = creditAllocation.additionalProperties.toMutableMap() - } - - fun allowsRollover(allowsRollover: Boolean) = - allowsRollover(JsonField.of(allowsRollover)) - - fun allowsRollover(allowsRollover: JsonField) = apply { - this.allowsRollover = allowsRollover - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditAllocation = - CreditAllocation( - checkRequired("allowsRollover", allowsRollover), - checkRequired("currency", currency), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditAllocation && allowsRollover == other.allowsRollover && currency == other.currency && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allowsRollover, currency, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditAllocation{allowsRollover=$allowsRollover, currency=$currency, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class GroupedAllocationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): GroupedAllocationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [GroupedAllocationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(groupedAllocationConfig: GroupedAllocationConfig) = apply { - additionalProperties = - groupedAllocationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): GroupedAllocationConfig = - GroupedAllocationConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GroupedAllocationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedAllocationConfig{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Item - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun name(): String = name.getRequired("name") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Item = apply { - if (validated) { - return@apply - } - - id() - name() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Item]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(item: Item) = apply { - id = item.id - name = item.name - additionalProperties = item.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun name(name: String) = name(JsonField.of(name)) - - 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) - } - - fun build(): Item = - Item( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Item && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Item{id=$id, name=$name, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Maximum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Maximum amount applied */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Maximum amount applied */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Maximum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - maximumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Maximum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = maximum.maximumAmount - additionalProperties = maximum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Maximum = - Maximum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("maximumAmount", maximumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Maximum && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, maximumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Maximum{appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, 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 @@ -46940,6 +12370,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } @@ -46995,171 +12426,6 @@ private constructor( override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - @NoAutoDetect - class Minimum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Minimum amount applied */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Minimum amount applied */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Minimum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - minimumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Minimum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var minimumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } - minimumAmount = minimum.minimumAmount - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Minimum = - Minimum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("minimumAmount", minimumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Minimum && appliesToPriceIds == other.appliesToPriceIds && minimumAmount == other.minimumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, minimumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" - } - class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -47175,14 +12441,14 @@ private constructor( companion object { - @JvmField val GROUPED_ALLOCATION = of("grouped_allocation") + @JvmField val GROUPED_TIERED = of("grouped_tiered") @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } /** An enum containing [ModelType]'s known values. */ enum class Known { - GROUPED_ALLOCATION + GROUPED_TIERED } /** @@ -47195,7 +12461,7 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - GROUPED_ALLOCATION, + GROUPED_TIERED, /** * An enum member indicating that [ModelType] was instantiated with an unknown * value. @@ -47212,7 +12478,7 @@ private constructor( */ fun value(): Value = when (this) { - GROUPED_ALLOCATION -> Value.GROUPED_ALLOCATION + GROUPED_TIERED -> Value.GROUPED_TIERED else -> Value._UNKNOWN } @@ -47227,7 +12493,7 @@ private constructor( */ fun known(): Known = when (this) { - GROUPED_ALLOCATION -> Known.GROUPED_ALLOCATION + GROUPED_TIERED -> Known.GROUPED_TIERED else -> throw OrbInvalidDataException("Unknown ModelType: $value") } @@ -47358,178 +12624,35 @@ private constructor( override fun toString() = value.toString() } - @NoAutoDetect - class DimensionalPriceConfiguration - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - private val dimensionalPriceGroupId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun dimensionValues(): List = dimensionValues.getRequired("dimension_values") - - fun dimensionalPriceGroupId(): String = - dimensionalPriceGroupId.getRequired("dimensional_price_group_id") - - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - fun _dimensionalPriceGroupId(): JsonField = dimensionalPriceGroupId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): DimensionalPriceConfiguration = apply { - if (validated) { - return@apply - } - - dimensionValues() - dimensionalPriceGroupId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DimensionalPriceConfiguration]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var dimensionalPriceGroupId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(dimensionalPriceConfiguration: DimensionalPriceConfiguration) = - apply { - dimensionValues = - dimensionalPriceConfiguration.dimensionValues.map { it.toMutableList() } - dimensionalPriceGroupId = - dimensionalPriceConfiguration.dimensionalPriceGroupId - additionalProperties = - dimensionalPriceConfiguration.additionalProperties.toMutableMap() - } - - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: String) = - dimensionalPriceGroupId(JsonField.of(dimensionalPriceGroupId)) - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: JsonField) = apply { - this.dimensionalPriceGroupId = dimensionalPriceGroupId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): DimensionalPriceConfiguration = - DimensionalPriceConfiguration( - checkRequired("dimensionValues", dimensionValues).map { it.toImmutable() }, - checkRequired("dimensionalPriceGroupId", dimensionalPriceGroupId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DimensionalPriceConfiguration && dimensionValues == other.dimensionValues && dimensionalPriceGroupId == other.dimensionalPriceGroupId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, dimensionalPriceGroupId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DimensionalPriceConfiguration{dimensionValues=$dimensionValues, dimensionalPriceGroupId=$dimensionalPriceGroupId, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is GroupedAllocationPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && groupedAllocationConfig == other.groupedAllocationConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedTieredPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && groupedTieredConfig == other.groupedTieredConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, groupedAllocationConfig, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, groupedTieredConfig, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "GroupedAllocationPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedAllocationConfig=$groupedAllocationConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedTieredPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedTieredConfig=$groupedTieredConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } @NoAutoDetect - class GroupedWithProratedMinimumPrice + class TieredWithMinimumPrice @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("billable_metric") @ExcludeMissing - private val billableMetric: JsonField = JsonMissing.of(), + private val billableMetric: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") @ExcludeMissing - private val billingCycleConfiguration: JsonField = + private val billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing @@ -47542,7 +12665,7 @@ private constructor( private val createdAt: JsonField = JsonMissing.of(), @JsonProperty("credit_allocation") @ExcludeMissing - private val creditAllocation: JsonField = JsonMissing.of(), + private val creditAllocation: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing private val currency: JsonField = JsonMissing.of(), @@ -47555,18 +12678,16 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_prorated_minimum_config") - @ExcludeMissing - private val groupedWithProratedMinimumConfig: JsonField = - JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = + private val invoicingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("item") @ExcludeMissing private val item: JsonField = JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), @JsonProperty("maximum") @ExcludeMissing - private val maximum: JsonField = JsonMissing.of(), + private val maximum: JsonField = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing private val maximumAmount: JsonField = JsonMissing.of(), @@ -47575,7 +12696,7 @@ private constructor( private val metadata: JsonField = JsonMissing.of(), @JsonProperty("minimum") @ExcludeMissing - private val minimum: JsonField = JsonMissing.of(), + private val minimum: JsonField = JsonMissing.of(), @JsonProperty("minimum_amount") @ExcludeMissing private val minimumAmount: JsonField = JsonMissing.of(), @@ -47591,9 +12712,13 @@ private constructor( @JsonProperty("price_type") @ExcludeMissing private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_minimum_config") + @ExcludeMissing + private val tieredWithMinimumConfig: JsonField = + JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing - private val dimensionalPriceConfiguration: JsonField = + private val dimensionalPriceConfiguration: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), @@ -47601,10 +12726,10 @@ private constructor( fun id(): String = id.getRequired("id") - fun billableMetric(): Optional = + fun billableMetric(): Optional = Optional.ofNullable(billableMetric.getNullable("billable_metric")) - fun billingCycleConfiguration(): BillingCycleConfiguration = + fun billingCycleConfiguration(): BillingCycleConfigurationModel = billingCycleConfiguration.getRequired("billing_cycle_configuration") fun cadence(): Cadence = cadence.getRequired("cadence") @@ -47614,7 +12739,7 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - fun creditAllocation(): Optional = + fun creditAllocation(): Optional = Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) fun currency(): String = currency.getRequired("currency") @@ -47627,17 +12752,14 @@ private constructor( fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - fun groupedWithProratedMinimumConfig(): GroupedWithProratedMinimumConfig = - groupedWithProratedMinimumConfig.getRequired("grouped_with_prorated_minimum_config") - - fun invoicingCycleConfiguration(): Optional = + fun invoicingCycleConfiguration(): Optional = Optional.ofNullable( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") ) - fun item(): Item = item.getRequired("item") + fun item(): ItemSlimModel = item.getRequired("item") - fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) @@ -47649,7 +12771,7 @@ private constructor( */ fun metadata(): Metadata = metadata.getRequired("metadata") - fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) fun minimumAmount(): Optional = Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) @@ -47663,7 +12785,10 @@ private constructor( fun priceType(): PriceType = priceType.getRequired("price_type") - fun dimensionalPriceConfiguration(): Optional = + fun tieredWithMinimumConfig(): CustomRatingFunctionConfigModel = + tieredWithMinimumConfig.getRequired("tiered_with_minimum_config") + + fun dimensionalPriceConfiguration(): Optional = Optional.ofNullable( dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") ) @@ -47672,11 +12797,11 @@ private constructor( @JsonProperty("billable_metric") @ExcludeMissing - fun _billableMetric(): JsonField = billableMetric + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = + fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence @@ -47691,7 +12816,7 @@ private constructor( @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation(): JsonField = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @@ -47705,19 +12830,14 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - @JsonProperty("grouped_with_prorated_minimum_config") - @ExcludeMissing - fun _groupedWithProratedMinimumConfig(): JsonField = - groupedWithProratedMinimumConfig - @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = + fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum @JsonProperty("maximum_amount") @ExcludeMissing @@ -47730,7 +12850,7 @@ private constructor( */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum @JsonProperty("minimum_amount") @ExcludeMissing @@ -47750,9 +12870,14 @@ private constructor( @ExcludeMissing fun _priceType(): JsonField = priceType + @JsonProperty("tiered_with_minimum_config") + @ExcludeMissing + fun _tieredWithMinimumConfig(): JsonField = + tieredWithMinimumConfig + @JsonProperty("dimensional_price_configuration") @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = + fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration @JsonAnyGetter @@ -47761,7 +12886,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithProratedMinimumPrice = apply { + fun validate(): TieredWithMinimumPrice = apply { if (validated) { return@apply } @@ -47777,7 +12902,6 @@ private constructor( discount().ifPresent { it.validate() } externalPriceId() fixedPriceQuantity() - groupedWithProratedMinimumConfig().validate() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() maximum().ifPresent { it.validate() } @@ -47789,6 +12913,7 @@ private constructor( name() planPhaseOrder() priceType() + tieredWithMinimumConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } validated = true } @@ -47797,95 +12922,120 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [TieredWithMinimumPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * .tieredWithMinimumConfig() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithProratedMinimumPrice]. */ + /** A builder for [TieredWithMinimumPrice]. */ class Builder internal constructor() { private var id: JsonField? = null - private var billableMetric: JsonField? = null - private var billingCycleConfiguration: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null private var cadence: JsonField? = null private var conversionRate: JsonField? = null private var createdAt: JsonField? = null - private var creditAllocation: 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? = + private var invoicingCycleConfiguration: 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: JsonField? = null - private var name: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var priceType: JsonField? = null - private var dimensionalPriceConfiguration: JsonField = - JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(groupedWithProratedMinimumPrice: GroupedWithProratedMinimumPrice) = - apply { - id = groupedWithProratedMinimumPrice.id - billableMetric = groupedWithProratedMinimumPrice.billableMetric - billingCycleConfiguration = - groupedWithProratedMinimumPrice.billingCycleConfiguration - cadence = groupedWithProratedMinimumPrice.cadence - conversionRate = groupedWithProratedMinimumPrice.conversionRate - createdAt = groupedWithProratedMinimumPrice.createdAt - creditAllocation = groupedWithProratedMinimumPrice.creditAllocation - currency = groupedWithProratedMinimumPrice.currency - discount = groupedWithProratedMinimumPrice.discount - externalPriceId = groupedWithProratedMinimumPrice.externalPriceId - fixedPriceQuantity = groupedWithProratedMinimumPrice.fixedPriceQuantity - groupedWithProratedMinimumConfig = - groupedWithProratedMinimumPrice.groupedWithProratedMinimumConfig - invoicingCycleConfiguration = - groupedWithProratedMinimumPrice.invoicingCycleConfiguration - item = groupedWithProratedMinimumPrice.item - maximum = groupedWithProratedMinimumPrice.maximum - maximumAmount = groupedWithProratedMinimumPrice.maximumAmount - metadata = groupedWithProratedMinimumPrice.metadata - minimum = groupedWithProratedMinimumPrice.minimum - minimumAmount = groupedWithProratedMinimumPrice.minimumAmount - modelType = groupedWithProratedMinimumPrice.modelType - name = groupedWithProratedMinimumPrice.name - planPhaseOrder = groupedWithProratedMinimumPrice.planPhaseOrder - priceType = groupedWithProratedMinimumPrice.priceType - dimensionalPriceConfiguration = - groupedWithProratedMinimumPrice.dimensionalPriceConfiguration - additionalProperties = - groupedWithProratedMinimumPrice.additionalProperties.toMutableMap() - } + 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: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var tieredWithMinimumConfig: JsonField? = null + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredWithMinimumPrice: TieredWithMinimumPrice) = apply { + id = tieredWithMinimumPrice.id + billableMetric = tieredWithMinimumPrice.billableMetric + billingCycleConfiguration = tieredWithMinimumPrice.billingCycleConfiguration + cadence = tieredWithMinimumPrice.cadence + conversionRate = tieredWithMinimumPrice.conversionRate + createdAt = tieredWithMinimumPrice.createdAt + creditAllocation = tieredWithMinimumPrice.creditAllocation + currency = tieredWithMinimumPrice.currency + discount = tieredWithMinimumPrice.discount + externalPriceId = tieredWithMinimumPrice.externalPriceId + fixedPriceQuantity = tieredWithMinimumPrice.fixedPriceQuantity + invoicingCycleConfiguration = tieredWithMinimumPrice.invoicingCycleConfiguration + item = tieredWithMinimumPrice.item + maximum = tieredWithMinimumPrice.maximum + maximumAmount = tieredWithMinimumPrice.maximumAmount + metadata = tieredWithMinimumPrice.metadata + minimum = tieredWithMinimumPrice.minimum + minimumAmount = tieredWithMinimumPrice.minimumAmount + modelType = tieredWithMinimumPrice.modelType + name = tieredWithMinimumPrice.name + planPhaseOrder = tieredWithMinimumPrice.planPhaseOrder + priceType = tieredWithMinimumPrice.priceType + tieredWithMinimumConfig = tieredWithMinimumPrice.tieredWithMinimumConfig + dimensionalPriceConfiguration = tieredWithMinimumPrice.dimensionalPriceConfiguration + additionalProperties = tieredWithMinimumPrice.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric?) = + fun billableMetric(billableMetric: BillableMetricTinyModel?) = billableMetric(JsonField.ofNullable(billableMetric)) - fun billableMetric(billableMetric: Optional) = + fun billableMetric(billableMetric: Optional) = billableMetric(billableMetric.orElse(null)) - fun billableMetric(billableMetric: JsonField) = apply { + fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric } - fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = - billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) fun billingCycleConfiguration( - billingCycleConfiguration: JsonField + billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -47911,13 +13061,13 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation?) = + fun creditAllocation(creditAllocation: AllocationModel?) = creditAllocation(JsonField.ofNullable(creditAllocation)) - fun creditAllocation(creditAllocation: Optional) = + fun creditAllocation(creditAllocation: Optional) = creditAllocation(creditAllocation.orElse(null)) - fun creditAllocation(creditAllocation: JsonField) = apply { + fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation } @@ -47972,35 +13122,27 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } - fun groupedWithProratedMinimumConfig( - groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig - ) = groupedWithProratedMinimumConfig(JsonField.of(groupedWithProratedMinimumConfig)) - - fun groupedWithProratedMinimumConfig( - groupedWithProratedMinimumConfig: JsonField - ) = apply { this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig } - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? + invoicingCycleConfiguration: BillingCycleConfigurationModel? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional + invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField + invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun item(item: Item) = item(JsonField.of(item)) + fun item(item: ItemSlimModel) = item(JsonField.of(item)) - fun item(item: JsonField) = apply { this.item = item } + fun item(item: JsonField) = apply { this.item = item } - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) - fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } fun maximumAmount(maximumAmount: String?) = maximumAmount(JsonField.ofNullable(maximumAmount)) @@ -48026,11 +13168,11 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) - fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } fun minimumAmount(minimumAmount: String?) = minimumAmount(JsonField.ofNullable(minimumAmount)) @@ -48067,16 +13209,23 @@ private constructor( fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + fun tieredWithMinimumConfig(tieredWithMinimumConfig: CustomRatingFunctionConfigModel) = + tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) + + fun tieredWithMinimumConfig( + tieredWithMinimumConfig: JsonField + ) = apply { this.tieredWithMinimumConfig = tieredWithMinimumConfig } + fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: DimensionalPriceConfiguration? + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional + dimensionalPriceConfiguration: Optional ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField + dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } fun additionalProperties(additionalProperties: Map) = apply { @@ -48098,8 +13247,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): GroupedWithProratedMinimumPrice = - GroupedWithProratedMinimumPrice( + fun build(): TieredWithMinimumPrice = + TieredWithMinimumPrice( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -48111,10 +13260,6 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired( - "groupedWithProratedMinimumConfig", - groupedWithProratedMinimumConfig, - ), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -48126,145 +13271,161 @@ private constructor( checkRequired("name", name), checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), + checkRequired("tieredWithMinimumConfig", tieredWithMinimumConfig), dimensionalPriceConfiguration, additionalProperties.toImmutable(), ) } - @NoAutoDetect - class BillableMetric - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillableMetric = apply { - if (validated) { - return@apply - } - - id() - validated = true - } + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { - fun toBuilder() = Builder().from(this) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { - @JvmStatic fun builder() = Builder() - } + @JvmField val ONE_TIME = of("one_time") - /** A builder for [BillableMetric]. */ - class Builder internal constructor() { + @JvmField val MONTHLY = of("monthly") - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + @JvmField val QUARTERLY = of("quarterly") - @JvmSynthetic - internal fun from(billableMetric: BillableMetric) = apply { - id = billableMetric.id - additionalProperties = billableMetric.additionalProperties.toMutableMap() - } + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun id(id: String) = id(JsonField.of(id)) + @JvmField val ANNUAL = of("annual") - fun id(id: JsonField) = apply { this.id = id } + @JvmField val CUSTOM = of("custom") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown value. + */ + _UNKNOWN, + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + 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 removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + 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 build(): BillableMetric = - BillableMetric(checkRequired("id", id), additionalProperties.toImmutable()) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is BillableMetric && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "BillableMetric{id=$id, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ @NoAutoDetect - class BillingCycleConfiguration + class Metadata @JsonCreator private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties private var validated: Boolean = false - fun validate(): BillingCycleConfiguration = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } - duration() - durationUnit() validated = true } @@ -48272,33 +13433,18 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [BillingCycleConfiguration]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { - private var duration: JsonField? = null - private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -48323,139 +13469,123 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } - class DurationUnit - @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 /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } - companion object { + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - @JvmField val DAY = of("day") + override fun hashCode(): Int = hashCode - @JvmField val MONTH = of("month") + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the 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 enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + companion object { - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.MONTH - else -> Value._UNKNOWN - } + @JvmField val TIERED_WITH_MINIMUM = of("tiered_with_minimum") - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + TIERED_WITH_MINIMUM + } + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TIERED_WITH_MINIMUM, /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method 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 [ModelType] was instantiated with an unknown + * value. */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + _UNKNOWN, + } - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TIERED_WITH_MINIMUM -> Value.TIERED_WITH_MINIMUM + else -> Value._UNKNOWN } - override fun hashCode() = value.hashCode() + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TIERED_WITH_MINIMUM -> Known.TIERED_WITH_MINIMUM + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } - override fun toString() = value.toString() - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if 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 } - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } - class Cadence @JsonCreator private constructor(private val value: JsonField) : + class PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -48470,828 +13600,879 @@ private constructor( companion object { - @JvmField val ONE_TIME = of("one_time") - - @JvmField val MONTHLY = of("monthly") - - @JvmField val QUARTERLY = of("quarterly") - - @JvmField val SEMI_ANNUAL = of("semi_annual") - - @JvmField val ANNUAL = of("annual") + @JvmField val USAGE_PRICE = of("usage_price") - @JvmField val CUSTOM = of("custom") + @JvmField val FIXED_PRICE = of("fixed_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, } /** - * 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, /** - * 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, } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TieredWithMinimumPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && tieredWithMinimumConfig == other.tieredWithMinimumConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, tieredWithMinimumConfig, dimensionalPriceConfiguration, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithMinimumPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, tieredWithMinimumConfig=$tieredWithMinimumConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class TieredPackageWithMinimumPrice + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + private val billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + private val creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("tiered_package_with_minimum_config") + @ExcludeMissing + private val tieredPackageWithMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + private val dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - 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(): Optional = + Optional.ofNullable(billableMetric.getNullable("billable_metric")) - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 billingCycleConfiguration(): BillingCycleConfigurationModel = + billingCycleConfiguration.getRequired("billing_cycle_configuration") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun cadence(): Cadence = cadence.getRequired("cadence") - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - override fun hashCode() = value.hashCode() + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - override fun toString() = value.toString() - } + fun creditAllocation(): Optional = + Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) - @NoAutoDetect - class CreditAllocation - @JsonCreator - private constructor( - @JsonProperty("allows_rollover") - @ExcludeMissing - private val allowsRollover: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + fun currency(): String = currency.getRequired("currency") - fun allowsRollover(): Boolean = allowsRollover.getRequired("allows_rollover") + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) - fun currency(): String = currency.getRequired("currency") + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - @JsonProperty("allows_rollover") - @ExcludeMissing - fun _allowsRollover(): JsonField = allowsRollover + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun item(): ItemSlimModel = item.getRequired("item") - private var validated: Boolean = false + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) - fun validate(): CreditAllocation = apply { - if (validated) { - return@apply - } + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - allowsRollover() - currency() - validated = 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.getRequired("metadata") - fun toBuilder() = Builder().from(this) + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) - companion object { + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) - @JvmStatic fun builder() = Builder() - } + fun modelType(): ModelType = modelType.getRequired("model_type") - /** A builder for [CreditAllocation]. */ - class Builder internal constructor() { + fun name(): String = name.getRequired("name") - private var allowsRollover: JsonField? = null - private var currency: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - @JvmSynthetic - internal fun from(creditAllocation: CreditAllocation) = apply { - allowsRollover = creditAllocation.allowsRollover - currency = creditAllocation.currency - additionalProperties = creditAllocation.additionalProperties.toMutableMap() - } + fun priceType(): PriceType = priceType.getRequired("price_type") - fun allowsRollover(allowsRollover: Boolean) = - allowsRollover(JsonField.of(allowsRollover)) + fun tieredPackageWithMinimumConfig(): CustomRatingFunctionConfigModel = + tieredPackageWithMinimumConfig.getRequired("tiered_package_with_minimum_config") - fun allowsRollover(allowsRollover: JsonField) = apply { - this.allowsRollover = allowsRollover - } + fun dimensionalPriceConfiguration(): Optional = + Optional.ofNullable( + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + ) - fun currency(currency: String) = currency(JsonField.of(currency)) + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - fun currency(currency: JsonField) = apply { this.currency = currency } + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation - fun build(): CreditAllocation = - CreditAllocation( - checkRequired("allowsRollover", allowsRollover), - checkRequired("currency", currency), - additionalProperties.toImmutable(), - ) - } + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - return /* spotless:off */ other is CreditAllocation && allowsRollover == other.allowsRollover && currency == other.currency && additionalProperties == other.additionalProperties /* spotless:on */ - } + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allowsRollover, currency, additionalProperties) } - /* spotless:on */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - override fun hashCode(): Int = hashCode + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - override fun toString() = - "CreditAllocation{allowsRollover=$allowsRollover, currency=$currency, additionalProperties=$additionalProperties}" - } + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @NoAutoDetect - class GroupedWithProratedMinimumConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount - private var validated: Boolean = false + /** + * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - fun validate(): GroupedWithProratedMinimumConfig = apply { - if (validated) { - return@apply - } + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - validated = true - } + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - fun toBuilder() = Builder().from(this) + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - companion object { + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JvmStatic fun builder() = Builder() - } + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - /** A builder for [GroupedWithProratedMinimumConfig]. */ - class Builder internal constructor() { + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType - private var additionalProperties: MutableMap = mutableMapOf() + @JsonProperty("tiered_package_with_minimum_config") + @ExcludeMissing + fun _tieredPackageWithMinimumConfig(): JsonField = + tieredPackageWithMinimumConfig - @JvmSynthetic - internal fun from( - groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig - ) = apply { - additionalProperties = - groupedWithProratedMinimumConfig.additionalProperties.toMutableMap() - } + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + private var validated: Boolean = false - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun validate(): TieredPackageWithMinimumPrice = apply { + if (validated) { + return@apply + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + cadence() + conversionRate() + 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() + name() + planPhaseOrder() + priceType() + tieredPackageWithMinimumConfig().validate() + dimensionalPriceConfiguration().ifPresent { it.validate() } + validated = true + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun toBuilder() = Builder().from(this) - fun build(): GroupedWithProratedMinimumConfig = - GroupedWithProratedMinimumConfig(additionalProperties.toImmutable()) - } + companion object { - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns a mutable builder for constructing an instance of + * [TieredPackageWithMinimumPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * .tieredPackageWithMinimumConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - return /* spotless:off */ other is GroupedWithProratedMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** A builder for [TieredPackageWithMinimumPrice]. */ + class Builder internal constructor() { - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var 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: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var tieredPackageWithMinimumConfig: + JsonField? = + null + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - override fun hashCode(): Int = hashCode + @JvmSynthetic + internal fun from(tieredPackageWithMinimumPrice: TieredPackageWithMinimumPrice) = + apply { + id = tieredPackageWithMinimumPrice.id + billableMetric = tieredPackageWithMinimumPrice.billableMetric + billingCycleConfiguration = + tieredPackageWithMinimumPrice.billingCycleConfiguration + cadence = tieredPackageWithMinimumPrice.cadence + conversionRate = tieredPackageWithMinimumPrice.conversionRate + createdAt = tieredPackageWithMinimumPrice.createdAt + creditAllocation = tieredPackageWithMinimumPrice.creditAllocation + currency = tieredPackageWithMinimumPrice.currency + discount = tieredPackageWithMinimumPrice.discount + externalPriceId = tieredPackageWithMinimumPrice.externalPriceId + fixedPriceQuantity = tieredPackageWithMinimumPrice.fixedPriceQuantity + invoicingCycleConfiguration = + tieredPackageWithMinimumPrice.invoicingCycleConfiguration + item = tieredPackageWithMinimumPrice.item + maximum = tieredPackageWithMinimumPrice.maximum + maximumAmount = tieredPackageWithMinimumPrice.maximumAmount + metadata = tieredPackageWithMinimumPrice.metadata + minimum = tieredPackageWithMinimumPrice.minimum + minimumAmount = tieredPackageWithMinimumPrice.minimumAmount + modelType = tieredPackageWithMinimumPrice.modelType + name = tieredPackageWithMinimumPrice.name + planPhaseOrder = tieredPackageWithMinimumPrice.planPhaseOrder + priceType = tieredPackageWithMinimumPrice.priceType + tieredPackageWithMinimumConfig = + tieredPackageWithMinimumPrice.tieredPackageWithMinimumConfig + dimensionalPriceConfiguration = + tieredPackageWithMinimumPrice.dimensionalPriceConfiguration + additionalProperties = + tieredPackageWithMinimumPrice.additionalProperties.toMutableMap() + } - override fun toString() = - "GroupedWithProratedMinimumConfig{additionalProperties=$additionalProperties}" - } + fun id(id: String) = id(JsonField.of(id)) - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + fun id(id: JsonField) = apply { this.id = id } - fun duration(): Long = duration.getRequired("duration") + fun billableMetric(billableMetric: BillableMetricTinyModel?) = + billableMetric(JsonField.ofNullable(billableMetric)) - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - private var validated: Boolean = false + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - duration() - durationUnit() - validated = true - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - fun toBuilder() = Builder().from(this) + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) - companion object { + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) - @JvmStatic fun builder() = Builder() + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } - fun duration(duration: Long) = duration(JsonField.of(duration)) + fun creditAllocation(creditAllocation: AllocationModel?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) - fun duration(duration: JsonField) = apply { this.duration = duration } + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } + fun currency(currency: String) = currency(JsonField.of(currency)) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun currency(currency: JsonField) = apply { this.currency = currency } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun discount(discount: Optional) = discount(discount.orElse(null)) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun discount(discount: JsonField) = apply { this.discount = discount } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) - fun build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) - companion object { + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) - @JvmField val DAY = of("day") + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - @JvmField val MONTH = of("month") + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.MONTH - else -> Value._UNKNOWN - } + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - override fun hashCode() = value.hashCode() + fun item(item: ItemSlimModel) = item(JsonField.of(item)) - override fun toString() = value.toString() - } + fun item(item: JsonField) = apply { this.item = item } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - override fun hashCode(): Int = hashCode + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) - @NoAutoDetect - class Item - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } - fun id(): String = id.getRequired("id") + /** + * 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)) - fun name(): String = name.getRequired("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`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - private var validated: Boolean = false + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) - fun validate(): Item = apply { - if (validated) { - return@apply - } + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) - id() - name() - validated = true + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount } - fun toBuilder() = Builder().from(this) + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - companion object { + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } - @JvmStatic fun builder() = Builder() - } + fun name(name: String) = name(JsonField.of(name)) - /** A builder for [Item]. */ - class Builder internal constructor() { + fun name(name: JsonField) = apply { this.name = name } - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - @JvmSynthetic - internal fun from(item: Item) = apply { - id = item.id - name = item.name - additionalProperties = item.additionalProperties.toMutableMap() - } + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - fun id(id: String) = id(JsonField.of(id)) + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - fun id(id: JsonField) = apply { this.id = id } + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } - fun name(name: String) = name(JsonField.of(name)) + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) - fun name(name: JsonField) = apply { this.name = name } + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun tieredPackageWithMinimumConfig( + tieredPackageWithMinimumConfig: CustomRatingFunctionConfigModel + ) = tieredPackageWithMinimumConfig(JsonField.of(tieredPackageWithMinimumConfig)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun tieredPackageWithMinimumConfig( + tieredPackageWithMinimumConfig: JsonField + ) = apply { this.tieredPackageWithMinimumConfig = tieredPackageWithMinimumConfig } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - fun build(): Item = - Item( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toImmutable(), - ) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - return /* spotless:off */ other is Item && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - /* spotless:on */ + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - override fun hashCode(): Int = hashCode + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun toString() = - "Item{id=$id, name=$name, additionalProperties=$additionalProperties}" + fun build(): TieredPackageWithMinimumPrice = + TieredPackageWithMinimumPrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + checkRequired("tieredPackageWithMinimumConfig", tieredPackageWithMinimumConfig), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) } - @NoAutoDetect - class Maximum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Maximum amount applied */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** Maximum amount applied */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount + companion object { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + @JvmField val ONE_TIME = of("one_time") - private var validated: Boolean = false + @JvmField val MONTHLY = of("monthly") - fun validate(): Maximum = apply { - if (validated) { - return@apply - } + @JvmField val QUARTERLY = of("quarterly") - appliesToPriceIds() - maximumAmount() - validated = true - } + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun toBuilder() = Builder().from(this) + @JvmField val ANNUAL = of("annual") - companion object { + @JvmField val CUSTOM = of("custom") - @JvmStatic fun builder() = Builder() + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) } - /** A builder for [Maximum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = maximum.maximumAmount - additionalProperties = maximum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } + /** 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, /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. + * An enum member indicating that [Cadence] was instantiated with an unknown value. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + _UNKNOWN, + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + 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 removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + 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 build(): Maximum = - Maximum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("maximumAmount", maximumAmount), - additionalProperties.toImmutable(), - ) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Maximum && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, maximumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "Maximum{appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } /** @@ -49325,6 +14506,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } @@ -49380,171 +14562,6 @@ private constructor( override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - @NoAutoDetect - class Minimum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Minimum amount applied */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Minimum amount applied */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Minimum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - minimumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Minimum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var minimumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } - minimumAmount = minimum.minimumAmount - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Minimum = - Minimum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("minimumAmount", minimumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Minimum && appliesToPriceIds == other.appliesToPriceIds && minimumAmount == other.minimumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, minimumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" - } - class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -49560,14 +14577,14 @@ private constructor( companion object { - @JvmField val GROUPED_WITH_PRORATED_MINIMUM = of("grouped_with_prorated_minimum") + @JvmField val TIERED_PACKAGE_WITH_MINIMUM = of("tiered_package_with_minimum") @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } /** An enum containing [ModelType]'s known values. */ enum class Known { - GROUPED_WITH_PRORATED_MINIMUM + TIERED_PACKAGE_WITH_MINIMUM } /** @@ -49580,7 +14597,7 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - GROUPED_WITH_PRORATED_MINIMUM, + TIERED_PACKAGE_WITH_MINIMUM, /** * An enum member indicating that [ModelType] was instantiated with an unknown * value. @@ -49597,7 +14614,7 @@ private constructor( */ fun value(): Value = when (this) { - GROUPED_WITH_PRORATED_MINIMUM -> Value.GROUPED_WITH_PRORATED_MINIMUM + TIERED_PACKAGE_WITH_MINIMUM -> Value.TIERED_PACKAGE_WITH_MINIMUM else -> Value._UNKNOWN } @@ -49612,7 +14629,7 @@ private constructor( */ fun known(): Known = when (this) { - GROUPED_WITH_PRORATED_MINIMUM -> Known.GROUPED_WITH_PRORATED_MINIMUM + TIERED_PACKAGE_WITH_MINIMUM -> Known.TIERED_PACKAGE_WITH_MINIMUM else -> throw OrbInvalidDataException("Unknown ModelType: $value") } @@ -49683,207 +14700,64 @@ private constructor( FIXED_PRICE, /** * An enum member indicating that [PriceType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_PRICE -> Value.USAGE_PRICE - FIXED_PRICE -> Value.FIXED_PRICE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE_PRICE -> Known.USAGE_PRICE - FIXED_PRICE -> Known.FIXED_PRICE - else -> throw OrbInvalidDataException("Unknown PriceType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class DimensionalPriceConfiguration - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - private val dimensionalPriceGroupId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun dimensionValues(): List = dimensionValues.getRequired("dimension_values") - - fun dimensionalPriceGroupId(): String = - dimensionalPriceGroupId.getRequired("dimensional_price_group_id") - - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - fun _dimensionalPriceGroupId(): JsonField = dimensionalPriceGroupId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): DimensionalPriceConfiguration = apply { - if (validated) { - return@apply - } - - dimensionValues() - dimensionalPriceGroupId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DimensionalPriceConfiguration]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var dimensionalPriceGroupId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(dimensionalPriceConfiguration: DimensionalPriceConfiguration) = - apply { - dimensionValues = - dimensionalPriceConfiguration.dimensionValues.map { it.toMutableList() } - dimensionalPriceGroupId = - dimensionalPriceConfiguration.dimensionalPriceGroupId - additionalProperties = - dimensionalPriceConfiguration.additionalProperties.toMutableMap() - } - - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: String) = - dimensionalPriceGroupId(JsonField.of(dimensionalPriceGroupId)) - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: JsonField) = apply { - this.dimensionalPriceGroupId = dimensionalPriceGroupId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + * value. + */ + _UNKNOWN, + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") } - fun build(): DimensionalPriceConfiguration = - DimensionalPriceConfiguration( - checkRequired("dimensionValues", dimensionValues).map { it.toImmutable() }, - checkRequired("dimensionalPriceGroupId", dimensionalPriceGroupId), - additionalProperties.toImmutable(), - ) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is DimensionalPriceConfiguration && dimensionValues == other.dimensionValues && dimensionalPriceGroupId == other.dimensionalPriceGroupId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, dimensionalPriceGroupId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "DimensionalPriceConfiguration{dimensionValues=$dimensionValues, dimensionalPriceGroupId=$dimensionalPriceGroupId, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -49891,30 +14765,30 @@ private constructor( return true } - return /* spotless:off */ other is GroupedWithProratedMinimumPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && groupedWithProratedMinimumConfig == other.groupedWithProratedMinimumConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredPackageWithMinimumPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && tieredPackageWithMinimumConfig == other.tieredPackageWithMinimumConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, groupedWithProratedMinimumConfig, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, tieredPackageWithMinimumConfig, dimensionalPriceConfiguration, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithProratedMinimumPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "TieredPackageWithMinimumPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } @NoAutoDetect - class GroupedWithMeteredMinimumPrice + class PackageWithAllocationPrice @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("billable_metric") @ExcludeMissing - private val billableMetric: JsonField = JsonMissing.of(), + private val billableMetric: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") @ExcludeMissing - private val billingCycleConfiguration: JsonField = + private val billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing @@ -49927,7 +14801,7 @@ private constructor( private val createdAt: JsonField = JsonMissing.of(), @JsonProperty("credit_allocation") @ExcludeMissing - private val creditAllocation: JsonField = JsonMissing.of(), + private val creditAllocation: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing private val currency: JsonField = JsonMissing.of(), @@ -49940,18 +14814,16 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_metered_minimum_config") - @ExcludeMissing - private val groupedWithMeteredMinimumConfig: JsonField = - JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = + private val invoicingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("item") @ExcludeMissing private val item: JsonField = JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), @JsonProperty("maximum") @ExcludeMissing - private val maximum: JsonField = JsonMissing.of(), + private val maximum: JsonField = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing private val maximumAmount: JsonField = JsonMissing.of(), @@ -49960,7 +14832,7 @@ private constructor( private val metadata: JsonField = JsonMissing.of(), @JsonProperty("minimum") @ExcludeMissing - private val minimum: JsonField = JsonMissing.of(), + private val minimum: JsonField = JsonMissing.of(), @JsonProperty("minimum_amount") @ExcludeMissing private val minimumAmount: JsonField = JsonMissing.of(), @@ -49970,6 +14842,10 @@ private constructor( @JsonProperty("name") @ExcludeMissing private val name: JsonField = JsonMissing.of(), + @JsonProperty("package_with_allocation_config") + @ExcludeMissing + private val packageWithAllocationConfig: JsonField = + JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing private val planPhaseOrder: JsonField = JsonMissing.of(), @@ -49978,7 +14854,7 @@ private constructor( private val priceType: JsonField = JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing - private val dimensionalPriceConfiguration: JsonField = + private val dimensionalPriceConfiguration: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), @@ -49986,10 +14862,10 @@ private constructor( fun id(): String = id.getRequired("id") - fun billableMetric(): Optional = + fun billableMetric(): Optional = Optional.ofNullable(billableMetric.getNullable("billable_metric")) - fun billingCycleConfiguration(): BillingCycleConfiguration = + fun billingCycleConfiguration(): BillingCycleConfigurationModel = billingCycleConfiguration.getRequired("billing_cycle_configuration") fun cadence(): Cadence = cadence.getRequired("cadence") @@ -49999,7 +14875,7 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - fun creditAllocation(): Optional = + fun creditAllocation(): Optional = Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) fun currency(): String = currency.getRequired("currency") @@ -50012,17 +14888,14 @@ private constructor( fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - fun groupedWithMeteredMinimumConfig(): GroupedWithMeteredMinimumConfig = - groupedWithMeteredMinimumConfig.getRequired("grouped_with_metered_minimum_config") - - fun invoicingCycleConfiguration(): Optional = + fun invoicingCycleConfiguration(): Optional = Optional.ofNullable( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") ) - fun item(): Item = item.getRequired("item") + fun item(): ItemSlimModel = item.getRequired("item") - fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) @@ -50034,7 +14907,7 @@ private constructor( */ fun metadata(): Metadata = metadata.getRequired("metadata") - fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) fun minimumAmount(): Optional = Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) @@ -50043,12 +14916,15 @@ private constructor( fun name(): String = name.getRequired("name") + fun packageWithAllocationConfig(): CustomRatingFunctionConfigModel = + packageWithAllocationConfig.getRequired("package_with_allocation_config") + fun planPhaseOrder(): Optional = Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) fun priceType(): PriceType = priceType.getRequired("price_type") - fun dimensionalPriceConfiguration(): Optional = + fun dimensionalPriceConfiguration(): Optional = Optional.ofNullable( dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") ) @@ -50057,11 +14933,11 @@ private constructor( @JsonProperty("billable_metric") @ExcludeMissing - fun _billableMetric(): JsonField = billableMetric + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = + fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence @@ -50076,7 +14952,7 @@ private constructor( @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation(): JsonField = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @@ -50090,19 +14966,14 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - @JsonProperty("grouped_with_metered_minimum_config") - @ExcludeMissing - fun _groupedWithMeteredMinimumConfig(): JsonField = - groupedWithMeteredMinimumConfig - @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = + fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum @JsonProperty("maximum_amount") @ExcludeMissing @@ -50115,7 +14986,7 @@ private constructor( */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum @JsonProperty("minimum_amount") @ExcludeMissing @@ -50127,6 +14998,11 @@ private constructor( @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("package_with_allocation_config") + @ExcludeMissing + fun _packageWithAllocationConfig(): JsonField = + packageWithAllocationConfig + @JsonProperty("plan_phase_order") @ExcludeMissing fun _planPhaseOrder(): JsonField = planPhaseOrder @@ -50137,7 +15013,7 @@ private constructor( @JsonProperty("dimensional_price_configuration") @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = + fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration @JsonAnyGetter @@ -50146,7 +15022,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMeteredMinimumPrice = apply { + fun validate(): PackageWithAllocationPrice = apply { if (validated) { return@apply } @@ -50162,7 +15038,6 @@ private constructor( discount().ifPresent { it.validate() } externalPriceId() fixedPriceQuantity() - groupedWithMeteredMinimumConfig().validate() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() maximum().ifPresent { it.validate() } @@ -50172,6 +15047,7 @@ private constructor( minimumAmount() modelType() name() + packageWithAllocationConfig().validate() planPhaseOrder() priceType() dimensionalPriceConfiguration().ifPresent { it.validate() } @@ -50182,95 +15058,124 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [PackageWithAllocationPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .packageWithAllocationConfig() + * .planPhaseOrder() + * .priceType() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithMeteredMinimumPrice]. */ + /** A builder for [PackageWithAllocationPrice]. */ class Builder internal constructor() { private var id: JsonField? = null - private var billableMetric: JsonField? = null - private var billingCycleConfiguration: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null private var cadence: JsonField? = null private var conversionRate: JsonField? = null private var createdAt: JsonField? = null - private var creditAllocation: 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? = + private var invoicingCycleConfiguration: JsonField? = null - private var invoicingCycleConfiguration: JsonField? = null - private var item: JsonField? = null - private var maximum: 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 minimum: JsonField? = null private var minimumAmount: JsonField? = null private var modelType: JsonField? = null private var name: JsonField? = null + private var packageWithAllocationConfig: JsonField? = + null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null - private var dimensionalPriceConfiguration: JsonField = + private var dimensionalPriceConfiguration: + JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(groupedWithMeteredMinimumPrice: GroupedWithMeteredMinimumPrice) = - apply { - id = groupedWithMeteredMinimumPrice.id - billableMetric = groupedWithMeteredMinimumPrice.billableMetric - billingCycleConfiguration = - groupedWithMeteredMinimumPrice.billingCycleConfiguration - cadence = groupedWithMeteredMinimumPrice.cadence - conversionRate = groupedWithMeteredMinimumPrice.conversionRate - createdAt = groupedWithMeteredMinimumPrice.createdAt - creditAllocation = groupedWithMeteredMinimumPrice.creditAllocation - currency = groupedWithMeteredMinimumPrice.currency - discount = groupedWithMeteredMinimumPrice.discount - externalPriceId = groupedWithMeteredMinimumPrice.externalPriceId - fixedPriceQuantity = groupedWithMeteredMinimumPrice.fixedPriceQuantity - groupedWithMeteredMinimumConfig = - groupedWithMeteredMinimumPrice.groupedWithMeteredMinimumConfig - invoicingCycleConfiguration = - groupedWithMeteredMinimumPrice.invoicingCycleConfiguration - item = groupedWithMeteredMinimumPrice.item - maximum = groupedWithMeteredMinimumPrice.maximum - maximumAmount = groupedWithMeteredMinimumPrice.maximumAmount - metadata = groupedWithMeteredMinimumPrice.metadata - minimum = groupedWithMeteredMinimumPrice.minimum - minimumAmount = groupedWithMeteredMinimumPrice.minimumAmount - modelType = groupedWithMeteredMinimumPrice.modelType - name = groupedWithMeteredMinimumPrice.name - planPhaseOrder = groupedWithMeteredMinimumPrice.planPhaseOrder - priceType = groupedWithMeteredMinimumPrice.priceType - dimensionalPriceConfiguration = - groupedWithMeteredMinimumPrice.dimensionalPriceConfiguration - additionalProperties = - groupedWithMeteredMinimumPrice.additionalProperties.toMutableMap() - } + internal fun from(packageWithAllocationPrice: PackageWithAllocationPrice) = apply { + id = packageWithAllocationPrice.id + billableMetric = packageWithAllocationPrice.billableMetric + billingCycleConfiguration = packageWithAllocationPrice.billingCycleConfiguration + cadence = packageWithAllocationPrice.cadence + conversionRate = packageWithAllocationPrice.conversionRate + createdAt = packageWithAllocationPrice.createdAt + creditAllocation = packageWithAllocationPrice.creditAllocation + currency = packageWithAllocationPrice.currency + discount = packageWithAllocationPrice.discount + externalPriceId = packageWithAllocationPrice.externalPriceId + fixedPriceQuantity = packageWithAllocationPrice.fixedPriceQuantity + invoicingCycleConfiguration = packageWithAllocationPrice.invoicingCycleConfiguration + item = packageWithAllocationPrice.item + maximum = packageWithAllocationPrice.maximum + maximumAmount = packageWithAllocationPrice.maximumAmount + metadata = packageWithAllocationPrice.metadata + minimum = packageWithAllocationPrice.minimum + minimumAmount = packageWithAllocationPrice.minimumAmount + modelType = packageWithAllocationPrice.modelType + name = packageWithAllocationPrice.name + packageWithAllocationConfig = packageWithAllocationPrice.packageWithAllocationConfig + planPhaseOrder = packageWithAllocationPrice.planPhaseOrder + priceType = packageWithAllocationPrice.priceType + dimensionalPriceConfiguration = + packageWithAllocationPrice.dimensionalPriceConfiguration + additionalProperties = + packageWithAllocationPrice.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric?) = + fun billableMetric(billableMetric: BillableMetricTinyModel?) = billableMetric(JsonField.ofNullable(billableMetric)) - fun billableMetric(billableMetric: Optional) = + fun billableMetric(billableMetric: Optional) = billableMetric(billableMetric.orElse(null)) - fun billableMetric(billableMetric: JsonField) = apply { + fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric } - fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = - billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) fun billingCycleConfiguration( - billingCycleConfiguration: JsonField + billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -50296,13 +15201,13 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation?) = + fun creditAllocation(creditAllocation: AllocationModel?) = creditAllocation(JsonField.ofNullable(creditAllocation)) - fun creditAllocation(creditAllocation: Optional) = + fun creditAllocation(creditAllocation: Optional) = creditAllocation(creditAllocation.orElse(null)) - fun creditAllocation(creditAllocation: JsonField) = apply { + fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation } @@ -50357,35 +15262,27 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } - fun groupedWithMeteredMinimumConfig( - groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig - ) = groupedWithMeteredMinimumConfig(JsonField.of(groupedWithMeteredMinimumConfig)) - - fun groupedWithMeteredMinimumConfig( - groupedWithMeteredMinimumConfig: JsonField - ) = apply { this.groupedWithMeteredMinimumConfig = groupedWithMeteredMinimumConfig } - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? + invoicingCycleConfiguration: BillingCycleConfigurationModel? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional + invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField + invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun item(item: Item) = item(JsonField.of(item)) + fun item(item: ItemSlimModel) = item(JsonField.of(item)) - fun item(item: JsonField) = apply { this.item = item } + fun item(item: JsonField) = apply { this.item = item } - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) - fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } fun maximumAmount(maximumAmount: String?) = maximumAmount(JsonField.ofNullable(maximumAmount)) @@ -50411,11 +15308,11 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) - fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } fun minimumAmount(minimumAmount: String?) = minimumAmount(JsonField.ofNullable(minimumAmount)) @@ -50435,6 +15332,14 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } + fun packageWithAllocationConfig( + packageWithAllocationConfig: CustomRatingFunctionConfigModel + ) = packageWithAllocationConfig(JsonField.of(packageWithAllocationConfig)) + + fun packageWithAllocationConfig( + packageWithAllocationConfig: JsonField + ) = apply { this.packageWithAllocationConfig = packageWithAllocationConfig } + fun planPhaseOrder(planPhaseOrder: Long?) = planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) @@ -50453,15 +15358,15 @@ private constructor( fun priceType(priceType: JsonField) = apply { this.priceType = priceType } fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: DimensionalPriceConfiguration? + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional + dimensionalPriceConfiguration: Optional ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField + dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } fun additionalProperties(additionalProperties: Map) = apply { @@ -50483,8 +15388,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): GroupedWithMeteredMinimumPrice = - GroupedWithMeteredMinimumPrice( + fun build(): PackageWithAllocationPrice = + PackageWithAllocationPrice( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -50496,10 +15401,6 @@ private constructor( checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired( - "groupedWithMeteredMinimumConfig", - groupedWithMeteredMinimumConfig, - ), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), checkRequired("maximum", maximum), @@ -50509,6 +15410,7 @@ private constructor( checkRequired("minimumAmount", minimumAmount), checkRequired("modelType", modelType), checkRequired("name", name), + checkRequired("packageWithAllocationConfig", packageWithAllocationConfig), checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), dimensionalPriceConfiguration, @@ -50516,140 +15418,155 @@ private constructor( ) } - @NoAutoDetect - class BillableMetric - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillableMetric = apply { - if (validated) { - return@apply - } - - id() - validated = true - } + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { - fun toBuilder() = Builder().from(this) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { - @JvmStatic fun builder() = Builder() - } + @JvmField val ONE_TIME = of("one_time") - /** A builder for [BillableMetric]. */ - class Builder internal constructor() { + @JvmField val MONTHLY = of("monthly") - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + @JvmField val QUARTERLY = of("quarterly") - @JvmSynthetic - internal fun from(billableMetric: BillableMetric) = apply { - id = billableMetric.id - additionalProperties = billableMetric.additionalProperties.toMutableMap() - } + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun id(id: String) = id(JsonField.of(id)) + @JvmField val ANNUAL = of("annual") - fun id(id: JsonField) = apply { this.id = id } + @JvmField val CUSTOM = of("custom") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown value. + */ + _UNKNOWN, + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + 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 removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + 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 build(): BillableMetric = - BillableMetric(checkRequired("id", id), additionalProperties.toImmutable()) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is BillableMetric && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "BillableMetric{id=$id, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ @NoAutoDetect - class BillingCycleConfiguration + class Metadata @JsonCreator private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties private var validated: Boolean = false - fun validate(): BillingCycleConfiguration = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } - duration() - durationUnit() validated = true } @@ -50657,33 +15574,18 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [BillingCycleConfiguration]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { - private var duration: JsonField? = null - private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -50708,139 +15610,123 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } - class DurationUnit - @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 /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } - companion object { + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - @JvmField val DAY = of("day") + override fun hashCode(): Int = hashCode - @JvmField val MONTH = of("month") + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the 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 enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + companion object { - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.MONTH - else -> Value._UNKNOWN - } + @JvmField val PACKAGE_WITH_ALLOCATION = of("package_with_allocation") - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + /** An enum containing [ModelType]'s known values. */ + enum class Known { + PACKAGE_WITH_ALLOCATION + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PACKAGE_WITH_ALLOCATION, /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method 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 [ModelType] was instantiated with an unknown + * value. */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + _UNKNOWN, + } - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PACKAGE_WITH_ALLOCATION -> Value.PACKAGE_WITH_ALLOCATION + else -> Value._UNKNOWN } - override fun hashCode() = value.hashCode() + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PACKAGE_WITH_ALLOCATION -> Known.PACKAGE_WITH_ALLOCATION + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } - override fun toString() = value.toString() - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if 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 } - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } - class Cadence @JsonCreator private constructor(private val value: JsonField) : + class PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -50855,49 +15741,34 @@ private constructor( companion object { - @JvmField val ONE_TIME = of("one_time") - - @JvmField val MONTHLY = of("monthly") - - @JvmField val QUARTERLY = of("quarterly") - - @JvmField val SEMI_ANNUAL = of("semi_annual") - - @JvmField val ANNUAL = of("annual") + @JvmField val USAGE_PRICE = of("usage_price") - @JvmField val CUSTOM = of("custom") + @JvmField val FIXED_PRICE = of("fixed_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, } /** - * 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, /** - * 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, } @@ -50911,12 +15782,8 @@ private constructor( */ fun value(): Value = when (this) { - ONE_TIME -> Value.ONE_TIME - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - SEMI_ANNUAL -> Value.SEMI_ANNUAL - ANNUAL -> Value.ANNUAL - CUSTOM -> Value.CUSTOM + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE else -> Value._UNKNOWN } @@ -50926,18 +15793,14 @@ private constructor( * Use the [value] method instead if you're uncertain the value is always known and * don't want to 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") + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") } /** @@ -50957,7 +15820,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -50965,718 +15828,782 @@ private constructor( override fun toString() = value.toString() } - @NoAutoDetect - class CreditAllocation - @JsonCreator - private constructor( - @JsonProperty("allows_rollover") - @ExcludeMissing - private val allowsRollover: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun allowsRollover(): Boolean = allowsRollover.getRequired("allows_rollover") + return /* spotless:off */ other is PackageWithAllocationPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && packageWithAllocationConfig == other.packageWithAllocationConfig && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + } - fun currency(): String = currency.getRequired("currency") + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, packageWithAllocationConfig, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } + /* spotless:on */ - @JsonProperty("allows_rollover") - @ExcludeMissing - fun _allowsRollover(): JsonField = allowsRollover + override fun hashCode(): Int = hashCode - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + override fun toString() = + "PackageWithAllocationPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + @NoAutoDetect + class UnitWithPercentPrice + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + private val billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + private val creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("unit_with_percent_config") + @ExcludeMissing + private val unitWithPercentConfig: JsonField = + JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + private val dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { - private var validated: Boolean = false + fun id(): String = id.getRequired("id") - fun validate(): CreditAllocation = apply { - if (validated) { - return@apply - } + fun billableMetric(): Optional = + Optional.ofNullable(billableMetric.getNullable("billable_metric")) - allowsRollover() - currency() - validated = true - } + fun billingCycleConfiguration(): BillingCycleConfigurationModel = + billingCycleConfiguration.getRequired("billing_cycle_configuration") - fun toBuilder() = Builder().from(this) + fun cadence(): Cadence = cadence.getRequired("cadence") - companion object { + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - @JvmStatic fun builder() = Builder() - } + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - /** A builder for [CreditAllocation]. */ - class Builder internal constructor() { + fun creditAllocation(): Optional = + Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) - private var allowsRollover: JsonField? = null - private var currency: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun currency(): String = currency.getRequired("currency") - @JvmSynthetic - internal fun from(creditAllocation: CreditAllocation) = apply { - allowsRollover = creditAllocation.allowsRollover - currency = creditAllocation.currency - additionalProperties = creditAllocation.additionalProperties.toMutableMap() - } + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) - fun allowsRollover(allowsRollover: Boolean) = - allowsRollover(JsonField.of(allowsRollover)) + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - fun allowsRollover(allowsRollover: JsonField) = apply { - this.allowsRollover = allowsRollover - } + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - fun currency(currency: String) = currency(JsonField.of(currency)) + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) - fun currency(currency: JsonField) = apply { this.currency = currency } + fun item(): ItemSlimModel = item.getRequired("item") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(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.getRequired("metadata") - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) - fun build(): CreditAllocation = - CreditAllocation( - checkRequired("allowsRollover", allowsRollover), - checkRequired("currency", currency), - additionalProperties.toImmutable(), - ) - } + fun modelType(): ModelType = modelType.getRequired("model_type") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun name(): String = name.getRequired("name") - return /* spotless:off */ other is CreditAllocation && allowsRollover == other.allowsRollover && currency == other.currency && additionalProperties == other.additionalProperties /* spotless:on */ - } + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allowsRollover, currency, additionalProperties) } - /* spotless:on */ + fun priceType(): PriceType = priceType.getRequired("price_type") - override fun hashCode(): Int = hashCode + fun unitWithPercentConfig(): CustomRatingFunctionConfigModel = + unitWithPercentConfig.getRequired("unit_with_percent_config") - override fun toString() = - "CreditAllocation{allowsRollover=$allowsRollover, currency=$currency, additionalProperties=$additionalProperties}" - } + fun dimensionalPriceConfiguration(): Optional = + Optional.ofNullable( + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + ) - @NoAutoDetect - class GroupedWithMeteredMinimumConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric - private var validated: Boolean = false + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - fun validate(): GroupedWithMeteredMinimumConfig = apply { - if (validated) { - return@apply - } + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - validated = true - } + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - fun toBuilder() = Builder().from(this) + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - companion object { + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation - @JvmStatic fun builder() = Builder() - } + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - /** A builder for [GroupedWithMeteredMinimumConfig]. */ - class Builder internal constructor() { + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - private var additionalProperties: MutableMap = mutableMapOf() + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - @JvmSynthetic - internal fun from( - groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig - ) = apply { - additionalProperties = - groupedWithMeteredMinimumConfig.additionalProperties.toMutableMap() - } + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - fun build(): GroupedWithMeteredMinimumConfig = - GroupedWithMeteredMinimumConfig(additionalProperties.toImmutable()) - } + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - return /* spotless:off */ other is GroupedWithMeteredMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - override fun hashCode(): Int = hashCode + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - override fun toString() = - "GroupedWithMeteredMinimumConfig{additionalProperties=$additionalProperties}" - } + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + @JsonProperty("unit_with_percent_config") + @ExcludeMissing + fun _unitWithPercentConfig(): JsonField = + unitWithPercentConfig - fun duration(): Long = duration.getRequired("duration") + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + private var validated: Boolean = false - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit + fun validate(): UnitWithPercentPrice = apply { + if (validated) { + return@apply + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + cadence() + conversionRate() + 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() + name() + planPhaseOrder() + priceType() + unitWithPercentConfig().validate() + dimensionalPriceConfiguration().ifPresent { it.validate() } + validated = true + } - private var validated: Boolean = false + fun toBuilder() = Builder().from(this) - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } + companion object { - duration() - durationUnit() - validated = true + /** + * Returns a mutable builder for constructing an instance of [UnitWithPercentPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * .unitWithPercentConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnitWithPercentPrice]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var 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: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var unitWithPercentConfig: JsonField? = null + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unitWithPercentPrice: UnitWithPercentPrice) = apply { + id = unitWithPercentPrice.id + billableMetric = unitWithPercentPrice.billableMetric + billingCycleConfiguration = unitWithPercentPrice.billingCycleConfiguration + cadence = unitWithPercentPrice.cadence + conversionRate = unitWithPercentPrice.conversionRate + createdAt = unitWithPercentPrice.createdAt + creditAllocation = unitWithPercentPrice.creditAllocation + currency = unitWithPercentPrice.currency + discount = unitWithPercentPrice.discount + externalPriceId = unitWithPercentPrice.externalPriceId + fixedPriceQuantity = unitWithPercentPrice.fixedPriceQuantity + invoicingCycleConfiguration = unitWithPercentPrice.invoicingCycleConfiguration + item = unitWithPercentPrice.item + maximum = unitWithPercentPrice.maximum + maximumAmount = unitWithPercentPrice.maximumAmount + metadata = unitWithPercentPrice.metadata + minimum = unitWithPercentPrice.minimum + minimumAmount = unitWithPercentPrice.minimumAmount + modelType = unitWithPercentPrice.modelType + name = unitWithPercentPrice.name + planPhaseOrder = unitWithPercentPrice.planPhaseOrder + priceType = unitWithPercentPrice.priceType + unitWithPercentConfig = unitWithPercentPrice.unitWithPercentConfig + dimensionalPriceConfiguration = unitWithPercentPrice.dimensionalPriceConfiguration + additionalProperties = unitWithPercentPrice.additionalProperties.toMutableMap() } - fun toBuilder() = Builder().from(this) + fun id(id: String) = id(JsonField.of(id)) - companion object { + fun id(id: JsonField) = apply { this.id = id } - @JvmStatic fun builder() = Builder() + fun billableMetric(billableMetric: BillableMetricTinyModel?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) + + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric } - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - fun duration(duration: Long) = duration(JsonField.of(duration)) + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun duration(duration: JsonField) = apply { this.duration = duration } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun creditAllocation(creditAllocation: AllocationModel?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) - fun build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation } - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { + fun currency(currency: String) = currency(JsonField.of(currency)) - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the 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 currency(currency: JsonField) = apply { this.currency = currency } - companion object { + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) - @JvmField val DAY = of("day") + fun discount(discount: Optional) = discount(discount.orElse(null)) - @JvmField val MONTH = of("month") + fun discount(discount: JsonField) = apply { this.discount = discount } - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.MONTH - else -> Value._UNKNOWN - } + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - override fun hashCode() = value.hashCode() + fun item(item: ItemSlimModel) = item(JsonField.of(item)) - override fun toString() = value.toString() - } + fun item(item: JsonField) = apply { this.item = item } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - override fun hashCode(): Int = hashCode + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) - @NoAutoDetect - class Item - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } - fun id(): String = id.getRequired("id") + /** + * 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)) - fun name(): String = name.getRequired("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`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - private var validated: Boolean = false + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) - fun validate(): Item = apply { - if (validated) { - return@apply - } + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) - id() - name() - validated = true + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount } - fun toBuilder() = Builder().from(this) + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - companion object { + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } - @JvmStatic fun builder() = Builder() - } + fun name(name: String) = name(JsonField.of(name)) - /** A builder for [Item]. */ - class Builder internal constructor() { + fun name(name: JsonField) = apply { this.name = name } - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - @JvmSynthetic - internal fun from(item: Item) = apply { - id = item.id - name = item.name - additionalProperties = item.additionalProperties.toMutableMap() - } + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - fun id(id: String) = id(JsonField.of(id)) + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - fun id(id: JsonField) = apply { this.id = id } + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } - fun name(name: String) = name(JsonField.of(name)) + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) - fun name(name: JsonField) = apply { this.name = name } + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun unitWithPercentConfig(unitWithPercentConfig: CustomRatingFunctionConfigModel) = + unitWithPercentConfig(JsonField.of(unitWithPercentConfig)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun unitWithPercentConfig( + unitWithPercentConfig: JsonField + ) = apply { this.unitWithPercentConfig = unitWithPercentConfig } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - fun build(): Item = - Item( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toImmutable(), - ) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - return /* spotless:off */ other is Item && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - /* spotless:on */ + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - override fun hashCode(): Int = hashCode + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun toString() = - "Item{id=$id, name=$name, additionalProperties=$additionalProperties}" + fun build(): UnitWithPercentPrice = + UnitWithPercentPrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + checkRequired("unitWithPercentConfig", unitWithPercentConfig), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) } - @NoAutoDetect - class Maximum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Maximum amount applied */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** Maximum amount applied */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount + companion object { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + @JvmField val ONE_TIME = of("one_time") - private var validated: Boolean = false + @JvmField val MONTHLY = of("monthly") - fun validate(): Maximum = apply { - if (validated) { - return@apply - } + @JvmField val QUARTERLY = of("quarterly") - appliesToPriceIds() - maximumAmount() - validated = true - } + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun toBuilder() = Builder().from(this) + @JvmField val ANNUAL = of("annual") - companion object { + @JvmField val CUSTOM = of("custom") - @JvmStatic fun builder() = Builder() + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) } - /** A builder for [Maximum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = maximum.maximumAmount - additionalProperties = maximum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } + /** 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, /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. + * An enum member indicating that [Cadence] was instantiated with an unknown value. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + _UNKNOWN, + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + 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 removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + 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 build(): Maximum = - Maximum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("maximumAmount", maximumAmount), - additionalProperties.toImmutable(), - ) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Maximum && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, maximumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "Maximum{appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } /** @@ -51710,6 +16637,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } @@ -51765,171 +16693,6 @@ private constructor( override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - @NoAutoDetect - class Minimum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Minimum amount applied */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Minimum amount applied */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Minimum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - minimumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Minimum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var minimumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } - minimumAmount = minimum.minimumAmount - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Minimum = - Minimum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("minimumAmount", minimumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Minimum && appliesToPriceIds == other.appliesToPriceIds && minimumAmount == other.minimumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, minimumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" - } - class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -51945,14 +16708,14 @@ private constructor( companion object { - @JvmField val GROUPED_WITH_METERED_MINIMUM = of("grouped_with_metered_minimum") + @JvmField val UNIT_WITH_PERCENT = of("unit_with_percent") @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } /** An enum containing [ModelType]'s known values. */ enum class Known { - GROUPED_WITH_METERED_MINIMUM + UNIT_WITH_PERCENT } /** @@ -51965,7 +16728,7 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - GROUPED_WITH_METERED_MINIMUM, + UNIT_WITH_PERCENT, /** * An enum member indicating that [ModelType] was instantiated with an unknown * value. @@ -51982,7 +16745,7 @@ private constructor( */ fun value(): Value = when (this) { - GROUPED_WITH_METERED_MINIMUM -> Value.GROUPED_WITH_METERED_MINIMUM + UNIT_WITH_PERCENT -> Value.UNIT_WITH_PERCENT else -> Value._UNKNOWN } @@ -51997,7 +16760,7 @@ private constructor( */ fun known(): Known = when (this) { - GROUPED_WITH_METERED_MINIMUM -> Known.GROUPED_WITH_METERED_MINIMUM + UNIT_WITH_PERCENT -> Known.UNIT_WITH_PERCENT else -> throw OrbInvalidDataException("Unknown ModelType: $value") } @@ -52128,178 +16891,35 @@ private constructor( override fun toString() = value.toString() } - @NoAutoDetect - class DimensionalPriceConfiguration - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - private val dimensionalPriceGroupId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun dimensionValues(): List = dimensionValues.getRequired("dimension_values") - - fun dimensionalPriceGroupId(): String = - dimensionalPriceGroupId.getRequired("dimensional_price_group_id") - - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - fun _dimensionalPriceGroupId(): JsonField = dimensionalPriceGroupId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): DimensionalPriceConfiguration = apply { - if (validated) { - return@apply - } - - dimensionValues() - dimensionalPriceGroupId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DimensionalPriceConfiguration]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var dimensionalPriceGroupId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(dimensionalPriceConfiguration: DimensionalPriceConfiguration) = - apply { - dimensionValues = - dimensionalPriceConfiguration.dimensionValues.map { it.toMutableList() } - dimensionalPriceGroupId = - dimensionalPriceConfiguration.dimensionalPriceGroupId - additionalProperties = - dimensionalPriceConfiguration.additionalProperties.toMutableMap() - } - - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: String) = - dimensionalPriceGroupId(JsonField.of(dimensionalPriceGroupId)) - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: JsonField) = apply { - this.dimensionalPriceGroupId = dimensionalPriceGroupId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): DimensionalPriceConfiguration = - DimensionalPriceConfiguration( - checkRequired("dimensionValues", dimensionValues).map { it.toImmutable() }, - checkRequired("dimensionalPriceGroupId", dimensionalPriceGroupId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DimensionalPriceConfiguration && dimensionValues == other.dimensionValues && dimensionalPriceGroupId == other.dimensionalPriceGroupId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, dimensionalPriceGroupId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DimensionalPriceConfiguration{dimensionValues=$dimensionValues, dimensionalPriceGroupId=$dimensionalPriceGroupId, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is GroupedWithMeteredMinimumPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && groupedWithMeteredMinimumConfig == other.groupedWithMeteredMinimumConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UnitWithPercentPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && unitWithPercentConfig == other.unitWithPercentConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, groupedWithMeteredMinimumConfig, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, unitWithPercentConfig, dimensionalPriceConfiguration, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMeteredMinimumPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "UnitWithPercentPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, unitWithPercentConfig=$unitWithPercentConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } @NoAutoDetect - class MatrixWithDisplayNamePrice + class MatrixWithAllocationPrice @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("billable_metric") @ExcludeMissing - private val billableMetric: JsonField = JsonMissing.of(), + private val billableMetric: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") @ExcludeMissing - private val billingCycleConfiguration: JsonField = + private val billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing @@ -52312,7 +16932,7 @@ private constructor( private val createdAt: JsonField = JsonMissing.of(), @JsonProperty("credit_allocation") @ExcludeMissing - private val creditAllocation: JsonField = JsonMissing.of(), + private val creditAllocation: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing private val currency: JsonField = JsonMissing.of(), @@ -52327,16 +16947,18 @@ private constructor( private val fixedPriceQuantity: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = + private val invoicingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("item") @ExcludeMissing private val item: JsonField = JsonMissing.of(), - @JsonProperty("matrix_with_display_name_config") + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("matrix_with_allocation_config") @ExcludeMissing - private val matrixWithDisplayNameConfig: JsonField = + private val matrixWithAllocationConfig: JsonField = JsonMissing.of(), @JsonProperty("maximum") @ExcludeMissing - private val maximum: JsonField = JsonMissing.of(), + private val maximum: JsonField = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing private val maximumAmount: JsonField = JsonMissing.of(), @@ -52345,7 +16967,7 @@ private constructor( private val metadata: JsonField = JsonMissing.of(), @JsonProperty("minimum") @ExcludeMissing - private val minimum: JsonField = JsonMissing.of(), + private val minimum: JsonField = JsonMissing.of(), @JsonProperty("minimum_amount") @ExcludeMissing private val minimumAmount: JsonField = JsonMissing.of(), @@ -52363,7 +16985,7 @@ private constructor( private val priceType: JsonField = JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing - private val dimensionalPriceConfiguration: JsonField = + private val dimensionalPriceConfiguration: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), @@ -52371,10 +16993,10 @@ private constructor( fun id(): String = id.getRequired("id") - fun billableMetric(): Optional = + fun billableMetric(): Optional = Optional.ofNullable(billableMetric.getNullable("billable_metric")) - fun billingCycleConfiguration(): BillingCycleConfiguration = + fun billingCycleConfiguration(): BillingCycleConfigurationModel = billingCycleConfiguration.getRequired("billing_cycle_configuration") fun cadence(): Cadence = cadence.getRequired("cadence") @@ -52384,7 +17006,7 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - fun creditAllocation(): Optional = + fun creditAllocation(): Optional = Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) fun currency(): String = currency.getRequired("currency") @@ -52397,17 +17019,17 @@ private constructor( fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - fun invoicingCycleConfiguration(): Optional = + fun invoicingCycleConfiguration(): Optional = Optional.ofNullable( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") ) - fun item(): Item = item.getRequired("item") + fun item(): ItemSlimModel = item.getRequired("item") - fun matrixWithDisplayNameConfig(): MatrixWithDisplayNameConfig = - matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_config") + fun matrixWithAllocationConfig(): MatrixWithAllocationConfigModel = + matrixWithAllocationConfig.getRequired("matrix_with_allocation_config") - fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) @@ -52419,7 +17041,7 @@ private constructor( */ fun metadata(): Metadata = metadata.getRequired("metadata") - fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) fun minimumAmount(): Optional = Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) @@ -52433,7 +17055,7 @@ private constructor( fun priceType(): PriceType = priceType.getRequired("price_type") - fun dimensionalPriceConfiguration(): Optional = + fun dimensionalPriceConfiguration(): Optional = Optional.ofNullable( dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") ) @@ -52442,11 +17064,11 @@ private constructor( @JsonProperty("billable_metric") @ExcludeMissing - fun _billableMetric(): JsonField = billableMetric + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = + fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence @@ -52461,7 +17083,7 @@ private constructor( @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation(): JsonField = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @@ -52477,17 +17099,17 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = + fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @JsonProperty("matrix_with_display_name_config") + @JsonProperty("matrix_with_allocation_config") @ExcludeMissing - fun _matrixWithDisplayNameConfig(): JsonField = - matrixWithDisplayNameConfig + fun _matrixWithAllocationConfig(): JsonField = + matrixWithAllocationConfig - @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum @JsonProperty("maximum_amount") @ExcludeMissing @@ -52500,7 +17122,7 @@ private constructor( */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum @JsonProperty("minimum_amount") @ExcludeMissing @@ -52522,7 +17144,7 @@ private constructor( @JsonProperty("dimensional_price_configuration") @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = + fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration @JsonAnyGetter @@ -52531,7 +17153,7 @@ private constructor( private var validated: Boolean = false - fun validate(): MatrixWithDisplayNamePrice = apply { + fun validate(): MatrixWithAllocationPrice = apply { if (validated) { return@apply } @@ -52549,7 +17171,7 @@ private constructor( fixedPriceQuantity() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() - matrixWithDisplayNameConfig().validate() + matrixWithAllocationConfig().validate() maximum().ifPresent { it.validate() } maximumAmount() metadata().validate() @@ -52567,89 +17189,123 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [MatrixWithAllocationPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .matrixWithAllocationConfig() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [MatrixWithDisplayNamePrice]. */ + /** A builder for [MatrixWithAllocationPrice]. */ class Builder internal constructor() { private var id: JsonField? = null - private var billableMetric: JsonField? = null - private var billingCycleConfiguration: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null private var cadence: JsonField? = null private var conversionRate: JsonField? = null private var createdAt: JsonField? = null - private var creditAllocation: 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 matrixWithDisplayNameConfig: JsonField? = null - private var maximum: JsonField? = null + private var invoicingCycleConfiguration: JsonField? = + null + private var item: JsonField? = null + private var matrixWithAllocationConfig: JsonField? = + null + private var maximum: JsonField? = null private var maximumAmount: JsonField? = null private var metadata: JsonField? = null - private var minimum: JsonField? = null + private var minimum: JsonField? = null private var minimumAmount: JsonField? = null private var modelType: JsonField? = null private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null - private var dimensionalPriceConfiguration: JsonField = + private var dimensionalPriceConfiguration: + JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(matrixWithDisplayNamePrice: MatrixWithDisplayNamePrice) = apply { - id = matrixWithDisplayNamePrice.id - billableMetric = matrixWithDisplayNamePrice.billableMetric - billingCycleConfiguration = matrixWithDisplayNamePrice.billingCycleConfiguration - cadence = matrixWithDisplayNamePrice.cadence - conversionRate = matrixWithDisplayNamePrice.conversionRate - createdAt = matrixWithDisplayNamePrice.createdAt - creditAllocation = matrixWithDisplayNamePrice.creditAllocation - currency = matrixWithDisplayNamePrice.currency - discount = matrixWithDisplayNamePrice.discount - externalPriceId = matrixWithDisplayNamePrice.externalPriceId - fixedPriceQuantity = matrixWithDisplayNamePrice.fixedPriceQuantity - invoicingCycleConfiguration = matrixWithDisplayNamePrice.invoicingCycleConfiguration - item = matrixWithDisplayNamePrice.item - matrixWithDisplayNameConfig = matrixWithDisplayNamePrice.matrixWithDisplayNameConfig - maximum = matrixWithDisplayNamePrice.maximum - maximumAmount = matrixWithDisplayNamePrice.maximumAmount - metadata = matrixWithDisplayNamePrice.metadata - minimum = matrixWithDisplayNamePrice.minimum - minimumAmount = matrixWithDisplayNamePrice.minimumAmount - modelType = matrixWithDisplayNamePrice.modelType - name = matrixWithDisplayNamePrice.name - planPhaseOrder = matrixWithDisplayNamePrice.planPhaseOrder - priceType = matrixWithDisplayNamePrice.priceType + internal fun from(matrixWithAllocationPrice: MatrixWithAllocationPrice) = apply { + id = matrixWithAllocationPrice.id + billableMetric = matrixWithAllocationPrice.billableMetric + billingCycleConfiguration = matrixWithAllocationPrice.billingCycleConfiguration + cadence = matrixWithAllocationPrice.cadence + conversionRate = matrixWithAllocationPrice.conversionRate + createdAt = matrixWithAllocationPrice.createdAt + creditAllocation = matrixWithAllocationPrice.creditAllocation + currency = matrixWithAllocationPrice.currency + discount = matrixWithAllocationPrice.discount + externalPriceId = matrixWithAllocationPrice.externalPriceId + fixedPriceQuantity = matrixWithAllocationPrice.fixedPriceQuantity + invoicingCycleConfiguration = matrixWithAllocationPrice.invoicingCycleConfiguration + item = matrixWithAllocationPrice.item + matrixWithAllocationConfig = matrixWithAllocationPrice.matrixWithAllocationConfig + maximum = matrixWithAllocationPrice.maximum + maximumAmount = matrixWithAllocationPrice.maximumAmount + metadata = matrixWithAllocationPrice.metadata + minimum = matrixWithAllocationPrice.minimum + minimumAmount = matrixWithAllocationPrice.minimumAmount + modelType = matrixWithAllocationPrice.modelType + name = matrixWithAllocationPrice.name + planPhaseOrder = matrixWithAllocationPrice.planPhaseOrder + priceType = matrixWithAllocationPrice.priceType dimensionalPriceConfiguration = - matrixWithDisplayNamePrice.dimensionalPriceConfiguration - additionalProperties = - matrixWithDisplayNamePrice.additionalProperties.toMutableMap() + matrixWithAllocationPrice.dimensionalPriceConfiguration + additionalProperties = matrixWithAllocationPrice.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric?) = + fun billableMetric(billableMetric: BillableMetricTinyModel?) = billableMetric(JsonField.ofNullable(billableMetric)) - fun billableMetric(billableMetric: Optional) = + fun billableMetric(billableMetric: Optional) = billableMetric(billableMetric.orElse(null)) - fun billableMetric(billableMetric: JsonField) = apply { + fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric } - fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = - billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) fun billingCycleConfiguration( - billingCycleConfiguration: JsonField + billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -52675,13 +17331,13 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation?) = + fun creditAllocation(creditAllocation: AllocationModel?) = creditAllocation(JsonField.ofNullable(creditAllocation)) - fun creditAllocation(creditAllocation: Optional) = + fun creditAllocation(creditAllocation: Optional) = creditAllocation(creditAllocation.orElse(null)) - fun creditAllocation(creditAllocation: JsonField) = apply { + fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation } @@ -52737,34 +17393,34 @@ private constructor( } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? + invoicingCycleConfiguration: BillingCycleConfigurationModel? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional + invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField + invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun item(item: Item) = item(JsonField.of(item)) + fun item(item: ItemSlimModel) = item(JsonField.of(item)) - fun item(item: JsonField) = apply { this.item = item } + fun item(item: JsonField) = apply { this.item = item } - fun matrixWithDisplayNameConfig( - matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig - ) = matrixWithDisplayNameConfig(JsonField.of(matrixWithDisplayNameConfig)) + fun matrixWithAllocationConfig( + matrixWithAllocationConfig: MatrixWithAllocationConfigModel + ) = matrixWithAllocationConfig(JsonField.of(matrixWithAllocationConfig)) - fun matrixWithDisplayNameConfig( - matrixWithDisplayNameConfig: JsonField - ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } + fun matrixWithAllocationConfig( + matrixWithAllocationConfig: JsonField + ) = apply { this.matrixWithAllocationConfig = matrixWithAllocationConfig } - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) - fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } fun maximumAmount(maximumAmount: String?) = maximumAmount(JsonField.ofNullable(maximumAmount)) @@ -52790,11 +17446,11 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) - fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } fun minimumAmount(minimumAmount: String?) = minimumAmount(JsonField.ofNullable(minimumAmount)) @@ -52832,15 +17488,15 @@ private constructor( fun priceType(priceType: JsonField) = apply { this.priceType = priceType } fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: DimensionalPriceConfiguration? + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional + dimensionalPriceConfiguration: Optional ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField + dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } fun additionalProperties(additionalProperties: Map) = apply { @@ -52862,8 +17518,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): MatrixWithDisplayNamePrice = - MatrixWithDisplayNamePrice( + fun build(): MatrixWithAllocationPrice = + MatrixWithAllocationPrice( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -52877,7 +17533,7 @@ private constructor( checkRequired("fixedPriceQuantity", fixedPriceQuantity), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), - checkRequired("matrixWithDisplayNameConfig", matrixWithDisplayNameConfig), + checkRequired("matrixWithAllocationConfig", matrixWithAllocationConfig), checkRequired("maximum", maximum), checkRequired("maximumAmount", maximumAmount), checkRequired("metadata", metadata), @@ -52892,140 +17548,155 @@ private constructor( ) } - @NoAutoDetect - class BillableMetric - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillableMetric = apply { - if (validated) { - return@apply - } - - id() - validated = true - } + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { - fun toBuilder() = Builder().from(this) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { - @JvmStatic fun builder() = Builder() - } + @JvmField val ONE_TIME = of("one_time") - /** A builder for [BillableMetric]. */ - class Builder internal constructor() { + @JvmField val MONTHLY = of("monthly") - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + @JvmField val QUARTERLY = of("quarterly") - @JvmSynthetic - internal fun from(billableMetric: BillableMetric) = apply { - id = billableMetric.id - additionalProperties = billableMetric.additionalProperties.toMutableMap() - } + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun id(id: String) = id(JsonField.of(id)) + @JvmField val ANNUAL = of("annual") - fun id(id: JsonField) = apply { this.id = id } + @JvmField val CUSTOM = of("custom") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown value. + */ + _UNKNOWN, + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + 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 removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + 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 build(): BillableMetric = - BillableMetric(checkRequired("id", id), additionalProperties.toImmutable()) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is BillableMetric && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "BillableMetric{id=$id, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ @NoAutoDetect - class BillingCycleConfiguration + class Metadata @JsonCreator private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties private var validated: Boolean = false - fun validate(): BillingCycleConfiguration = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } - duration() - durationUnit() validated = true } @@ -53033,33 +17704,18 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [BillingCycleConfiguration]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { - private var duration: JsonField? = null - private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -53084,139 +17740,123 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } - class DurationUnit - @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 /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } - companion object { + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - @JvmField val DAY = of("day") + override fun hashCode(): Int = hashCode - @JvmField val MONTH = of("month") + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the 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 enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + companion object { - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.MONTH - else -> Value._UNKNOWN - } + @JvmField val MATRIX_WITH_ALLOCATION = of("matrix_with_allocation") - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + /** An enum containing [ModelType]'s known values. */ + enum class Known { + MATRIX_WITH_ALLOCATION + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MATRIX_WITH_ALLOCATION, /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method 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 [ModelType] was instantiated with an unknown + * value. */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + _UNKNOWN, + } - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MATRIX_WITH_ALLOCATION -> Value.MATRIX_WITH_ALLOCATION + else -> Value._UNKNOWN } - override fun hashCode() = value.hashCode() + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MATRIX_WITH_ALLOCATION -> Known.MATRIX_WITH_ALLOCATION + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } - override fun toString() = value.toString() - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if 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 } - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } - class Cadence @JsonCreator private constructor(private val value: JsonField) : + class PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -53231,49 +17871,34 @@ private constructor( companion object { - @JvmField val ONE_TIME = of("one_time") - - @JvmField val MONTHLY = of("monthly") - - @JvmField val QUARTERLY = of("quarterly") - - @JvmField val SEMI_ANNUAL = of("semi_annual") - - @JvmField val ANNUAL = of("annual") + @JvmField val USAGE_PRICE = of("usage_price") - @JvmField val CUSTOM = of("custom") + @JvmField val FIXED_PRICE = of("fixed_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, } /** - * 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, /** - * 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, } @@ -53287,12 +17912,8 @@ private constructor( */ fun value(): Value = when (this) { - ONE_TIME -> Value.ONE_TIME - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - SEMI_ANNUAL -> Value.SEMI_ANNUAL - ANNUAL -> Value.ANNUAL - CUSTOM -> Value.CUSTOM + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE else -> Value._UNKNOWN } @@ -53307,13 +17928,9 @@ private constructor( */ fun known(): Known = when (this) { - ONE_TIME -> Known.ONE_TIME - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - SEMI_ANNUAL -> Known.SEMI_ANNUAL - ANNUAL -> Known.ANNUAL - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") } /** @@ -53333,7 +17950,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -53341,717 +17958,785 @@ private constructor( override fun toString() = value.toString() } - @NoAutoDetect - class CreditAllocation - @JsonCreator - private constructor( - @JsonProperty("allows_rollover") - @ExcludeMissing - private val allowsRollover: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun allowsRollover(): Boolean = allowsRollover.getRequired("allows_rollover") + return /* spotless:off */ other is MatrixWithAllocationPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && matrixWithAllocationConfig == other.matrixWithAllocationConfig && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + } - fun currency(): String = currency.getRequired("currency") + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, matrixWithAllocationConfig, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } + /* spotless:on */ - @JsonProperty("allows_rollover") - @ExcludeMissing - fun _allowsRollover(): JsonField = allowsRollover + override fun hashCode(): Int = hashCode - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + override fun toString() = + "MatrixWithAllocationPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixWithAllocationConfig=$matrixWithAllocationConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + @NoAutoDetect + class TieredWithProrationPrice + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + private val billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + private val creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + private val tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + private val dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { - private var validated: Boolean = false + fun id(): String = id.getRequired("id") - fun validate(): CreditAllocation = apply { - if (validated) { - return@apply - } + fun billableMetric(): Optional = + Optional.ofNullable(billableMetric.getNullable("billable_metric")) - allowsRollover() - currency() - validated = true - } + fun billingCycleConfiguration(): BillingCycleConfigurationModel = + billingCycleConfiguration.getRequired("billing_cycle_configuration") - fun toBuilder() = Builder().from(this) + fun cadence(): Cadence = cadence.getRequired("cadence") - companion object { + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - @JvmStatic fun builder() = Builder() - } + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - /** A builder for [CreditAllocation]. */ - class Builder internal constructor() { + fun creditAllocation(): Optional = + Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) - private var allowsRollover: JsonField? = null - private var currency: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun currency(): String = currency.getRequired("currency") - @JvmSynthetic - internal fun from(creditAllocation: CreditAllocation) = apply { - allowsRollover = creditAllocation.allowsRollover - currency = creditAllocation.currency - additionalProperties = creditAllocation.additionalProperties.toMutableMap() - } + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) - fun allowsRollover(allowsRollover: Boolean) = - allowsRollover(JsonField.of(allowsRollover)) + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - fun allowsRollover(allowsRollover: JsonField) = apply { - this.allowsRollover = allowsRollover - } + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - fun currency(currency: String) = currency(JsonField.of(currency)) + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) - fun currency(currency: JsonField) = apply { this.currency = currency } + fun item(): ItemSlimModel = item.getRequired("item") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(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.getRequired("metadata") - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) - fun build(): CreditAllocation = - CreditAllocation( - checkRequired("allowsRollover", allowsRollover), - checkRequired("currency", currency), - additionalProperties.toImmutable(), - ) - } + fun modelType(): ModelType = modelType.getRequired("model_type") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun name(): String = name.getRequired("name") - return /* spotless:off */ other is CreditAllocation && allowsRollover == other.allowsRollover && currency == other.currency && additionalProperties == other.additionalProperties /* spotless:on */ - } + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allowsRollover, currency, additionalProperties) } - /* spotless:on */ + fun priceType(): PriceType = priceType.getRequired("price_type") - override fun hashCode(): Int = hashCode + fun tieredWithProrationConfig(): CustomRatingFunctionConfigModel = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") - override fun toString() = - "CreditAllocation{allowsRollover=$allowsRollover, currency=$currency, additionalProperties=$additionalProperties}" - } + fun dimensionalPriceConfiguration(): Optional = + Optional.ofNullable( + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + ) - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - fun duration(): Long = duration.getRequired("duration") + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - private var validated: Boolean = false + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - duration() - durationUnit() - validated = true - } + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - fun toBuilder() = Builder().from(this) + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - companion object { + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - @JvmStatic fun builder() = Builder() - } + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount - fun duration(duration: Long) = duration(JsonField.of(duration)) + /** + * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - fun duration(duration: JsonField) = apply { this.duration = duration } + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false - fun build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) + fun validate(): TieredWithProrationPrice = apply { + if (validated) { + return@apply } - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + cadence() + conversionRate() + 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() + name() + planPhaseOrder() + priceType() + tieredWithProrationConfig().validate() + dimensionalPriceConfiguration().ifPresent { it.validate() } + validated = 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 + fun toBuilder() = Builder().from(this) - companion object { + companion object { - @JvmField val DAY = of("day") + /** + * Returns a mutable builder for constructing an instance of [TieredWithProrationPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * .tieredWithProrationConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - @JvmField val MONTH = of("month") + /** A builder for [TieredWithProrationPrice]. */ + class Builder internal constructor() { - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var 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: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } + @JvmSynthetic + internal fun from(tieredWithProrationPrice: TieredWithProrationPrice) = apply { + id = tieredWithProrationPrice.id + billableMetric = tieredWithProrationPrice.billableMetric + billingCycleConfiguration = tieredWithProrationPrice.billingCycleConfiguration + cadence = tieredWithProrationPrice.cadence + conversionRate = tieredWithProrationPrice.conversionRate + createdAt = tieredWithProrationPrice.createdAt + creditAllocation = tieredWithProrationPrice.creditAllocation + currency = tieredWithProrationPrice.currency + discount = tieredWithProrationPrice.discount + externalPriceId = tieredWithProrationPrice.externalPriceId + fixedPriceQuantity = tieredWithProrationPrice.fixedPriceQuantity + invoicingCycleConfiguration = tieredWithProrationPrice.invoicingCycleConfiguration + item = tieredWithProrationPrice.item + maximum = tieredWithProrationPrice.maximum + maximumAmount = tieredWithProrationPrice.maximumAmount + metadata = tieredWithProrationPrice.metadata + minimum = tieredWithProrationPrice.minimum + minimumAmount = tieredWithProrationPrice.minimumAmount + modelType = tieredWithProrationPrice.modelType + name = tieredWithProrationPrice.name + planPhaseOrder = tieredWithProrationPrice.planPhaseOrder + priceType = tieredWithProrationPrice.priceType + tieredWithProrationConfig = tieredWithProrationPrice.tieredWithProrationConfig + dimensionalPriceConfiguration = + tieredWithProrationPrice.dimensionalPriceConfiguration + additionalProperties = tieredWithProrationPrice.additionalProperties.toMutableMap() + } - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + 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. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.MONTH - else -> Value._UNKNOWN - } + fun id(id: JsonField) = apply { this.id = id } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } + fun billableMetric(billableMetric: BillableMetricTinyModel?) = + billableMetric(JsonField.ofNullable(billableMetric)) - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - override fun hashCode() = value.hashCode() + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - override fun toString() = value.toString() + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun creditAllocation(creditAllocation: AllocationModel?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ + fun currency(currency: String) = currency(JsonField.of(currency)) - override fun hashCode(): Int = hashCode + fun currency(currency: JsonField) = apply { this.currency = currency } - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) - @NoAutoDetect - class Item - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + fun discount(discount: Optional) = discount(discount.orElse(null)) - fun id(): String = id.getRequired("id") + fun discount(discount: JsonField) = apply { this.discount = discount } + + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) - fun name(): String = name.getRequired("name") + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) - private var validated: Boolean = false + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - fun validate(): Item = apply { - if (validated) { - return@apply - } + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) - id() - name() - validated = true + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId } - fun toBuilder() = Builder().from(this) + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - companion object { + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - @JvmStatic fun builder() = Builder() + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } - /** A builder for [Item]. */ - class Builder internal constructor() { + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) - @JvmSynthetic - internal fun from(item: Item) = apply { - id = item.id - name = item.name - additionalProperties = item.additionalProperties.toMutableMap() - } + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun id(id: String) = id(JsonField.of(id)) + fun item(item: ItemSlimModel) = item(JsonField.of(item)) - fun id(id: JsonField) = apply { this.id = id } + fun item(item: JsonField) = apply { this.item = item } - fun name(name: String) = name(JsonField.of(name)) + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) - fun name(name: JsonField) = apply { this.name = name } + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * 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)) - fun build(): Item = - Item( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toImmutable(), - ) - } + /** + * 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: JsonField) = apply { this.metadata = metadata } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) - return /* spotless:off */ other is Item && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ - } + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - /* spotless:on */ + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - override fun hashCode(): Int = hashCode + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) - override fun toString() = - "Item{id=$id, name=$name, additionalProperties=$additionalProperties}" - } + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) - @NoAutoDetect - class MatrixWithDisplayNameConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - private var validated: Boolean = false + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } - fun validate(): MatrixWithDisplayNameConfig = apply { - if (validated) { - return@apply - } + fun name(name: String) = name(JsonField.of(name)) - validated = true - } + fun name(name: JsonField) = apply { this.name = name } - fun toBuilder() = Builder().from(this) + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - companion object { + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - @JvmStatic fun builder() = Builder() - } + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - /** A builder for [MatrixWithDisplayNameConfig]. */ - class Builder internal constructor() { + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } - private var additionalProperties: MutableMap = mutableMapOf() + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) - @JvmSynthetic - internal fun from(matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig) = - apply { - additionalProperties = - matrixWithDisplayNameConfig.additionalProperties.toMutableMap() - } + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun tieredWithProrationConfig( + tieredWithProrationConfig: CustomRatingFunctionConfigModel + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - fun build(): MatrixWithDisplayNameConfig = - MatrixWithDisplayNameConfig(additionalProperties.toImmutable()) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - return /* spotless:off */ other is MatrixWithDisplayNameConfig && additionalProperties == other.additionalProperties /* spotless:on */ + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - override fun hashCode(): Int = hashCode + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun toString() = - "MatrixWithDisplayNameConfig{additionalProperties=$additionalProperties}" + fun build(): TieredWithProrationPrice = + TieredWithProrationPrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) } - @NoAutoDetect - class Maximum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Maximum amount applied */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** Maximum amount applied */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount + companion object { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + @JvmField val ONE_TIME = of("one_time") - private var validated: Boolean = false + @JvmField val MONTHLY = of("monthly") - fun validate(): Maximum = apply { - if (validated) { - return@apply - } + @JvmField val QUARTERLY = of("quarterly") - appliesToPriceIds() - maximumAmount() - validated = true - } + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun toBuilder() = Builder().from(this) + @JvmField val ANNUAL = of("annual") - companion object { + @JvmField val CUSTOM = of("custom") - @JvmStatic fun builder() = Builder() + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) } - /** A builder for [Maximum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = maximum.maximumAmount - additionalProperties = maximum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } + /** 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, /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. + * An enum member indicating that [Cadence] was instantiated with an unknown value. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + _UNKNOWN, + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + 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 removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + 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 build(): Maximum = - Maximum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("maximumAmount", maximumAmount), - additionalProperties.toImmutable(), - ) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Maximum && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, maximumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "Maximum{appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } /** @@ -54085,6 +18770,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } @@ -54140,171 +18826,6 @@ private constructor( override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - @NoAutoDetect - class Minimum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Minimum amount applied */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Minimum amount applied */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Minimum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - minimumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Minimum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var minimumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } - minimumAmount = minimum.minimumAmount - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Minimum = - Minimum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("minimumAmount", minimumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Minimum && appliesToPriceIds == other.appliesToPriceIds && minimumAmount == other.minimumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, minimumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" - } - class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -54320,14 +18841,14 @@ private constructor( companion object { - @JvmField val MATRIX_WITH_DISPLAY_NAME = of("matrix_with_display_name") + @JvmField val TIERED_WITH_PRORATION = of("tiered_with_proration") @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } /** An enum containing [ModelType]'s known values. */ enum class Known { - MATRIX_WITH_DISPLAY_NAME + TIERED_WITH_PRORATION } /** @@ -54340,7 +18861,7 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - MATRIX_WITH_DISPLAY_NAME, + TIERED_WITH_PRORATION, /** * An enum member indicating that [ModelType] was instantiated with an unknown * value. @@ -54357,7 +18878,7 @@ private constructor( */ fun value(): Value = when (this) { - MATRIX_WITH_DISPLAY_NAME -> Value.MATRIX_WITH_DISPLAY_NAME + TIERED_WITH_PRORATION -> Value.TIERED_WITH_PRORATION else -> Value._UNKNOWN } @@ -54372,7 +18893,7 @@ private constructor( */ fun known(): Known = when (this) { - MATRIX_WITH_DISPLAY_NAME -> Known.MATRIX_WITH_DISPLAY_NAME + TIERED_WITH_PRORATION -> Known.TIERED_WITH_PRORATION else -> throw OrbInvalidDataException("Unknown ModelType: $value") } @@ -54503,182 +19024,36 @@ private constructor( override fun toString() = value.toString() } - @NoAutoDetect - class DimensionalPriceConfiguration - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - private val dimensionalPriceGroupId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun dimensionValues(): List = dimensionValues.getRequired("dimension_values") - - fun dimensionalPriceGroupId(): String = - dimensionalPriceGroupId.getRequired("dimensional_price_group_id") - - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - fun _dimensionalPriceGroupId(): JsonField = dimensionalPriceGroupId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): DimensionalPriceConfiguration = apply { - if (validated) { - return@apply - } - - dimensionValues() - dimensionalPriceGroupId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DimensionalPriceConfiguration]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var dimensionalPriceGroupId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(dimensionalPriceConfiguration: DimensionalPriceConfiguration) = - apply { - dimensionValues = - dimensionalPriceConfiguration.dimensionValues.map { it.toMutableList() } - dimensionalPriceGroupId = - dimensionalPriceConfiguration.dimensionalPriceGroupId - additionalProperties = - dimensionalPriceConfiguration.additionalProperties.toMutableMap() - } - - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: String) = - dimensionalPriceGroupId(JsonField.of(dimensionalPriceGroupId)) - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: JsonField) = apply { - this.dimensionalPriceGroupId = dimensionalPriceGroupId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): DimensionalPriceConfiguration = - DimensionalPriceConfiguration( - checkRequired("dimensionValues", dimensionValues).map { it.toImmutable() }, - checkRequired("dimensionalPriceGroupId", dimensionalPriceGroupId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DimensionalPriceConfiguration && dimensionValues == other.dimensionValues && dimensionalPriceGroupId == other.dimensionalPriceGroupId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, dimensionalPriceGroupId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DimensionalPriceConfiguration{dimensionValues=$dimensionValues, dimensionalPriceGroupId=$dimensionalPriceGroupId, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is MatrixWithDisplayNamePrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && matrixWithDisplayNameConfig == other.matrixWithDisplayNameConfig && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredWithProrationPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && tieredWithProrationConfig == other.tieredWithProrationConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, matrixWithDisplayNameConfig, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, tieredWithProrationConfig, dimensionalPriceConfiguration, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "MatrixWithDisplayNamePrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "TieredWithProrationPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, tieredWithProrationConfig=$tieredWithProrationConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } @NoAutoDetect - class BulkWithProrationPrice + class UnitWithProrationPrice @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("billable_metric") @ExcludeMissing - private val billableMetric: JsonField = JsonMissing.of(), + private val billableMetric: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") @ExcludeMissing - private val billingCycleConfiguration: JsonField = + private val billingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("bulk_with_proration_config") - @ExcludeMissing - private val bulkWithProrationConfig: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing private val cadence: JsonField = JsonMissing.of(), @@ -54690,7 +19065,7 @@ private constructor( private val createdAt: JsonField = JsonMissing.of(), @JsonProperty("credit_allocation") @ExcludeMissing - private val creditAllocation: JsonField = JsonMissing.of(), + private val creditAllocation: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing private val currency: JsonField = JsonMissing.of(), @@ -54705,12 +19080,14 @@ private constructor( private val fixedPriceQuantity: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = + private val invoicingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("item") @ExcludeMissing private val item: JsonField = JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), @JsonProperty("maximum") @ExcludeMissing - private val maximum: JsonField = JsonMissing.of(), + private val maximum: JsonField = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing private val maximumAmount: JsonField = JsonMissing.of(), @@ -54719,7 +19096,7 @@ private constructor( private val metadata: JsonField = JsonMissing.of(), @JsonProperty("minimum") @ExcludeMissing - private val minimum: JsonField = JsonMissing.of(), + private val minimum: JsonField = JsonMissing.of(), @JsonProperty("minimum_amount") @ExcludeMissing private val minimumAmount: JsonField = JsonMissing.of(), @@ -54735,9 +19112,13 @@ private constructor( @JsonProperty("price_type") @ExcludeMissing private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("unit_with_proration_config") + @ExcludeMissing + private val unitWithProrationConfig: JsonField = + JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing - private val dimensionalPriceConfiguration: JsonField = + private val dimensionalPriceConfiguration: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), @@ -54745,15 +19126,12 @@ private constructor( fun id(): String = id.getRequired("id") - fun billableMetric(): Optional = + fun billableMetric(): Optional = Optional.ofNullable(billableMetric.getNullable("billable_metric")) - fun billingCycleConfiguration(): BillingCycleConfiguration = + fun billingCycleConfiguration(): BillingCycleConfigurationModel = billingCycleConfiguration.getRequired("billing_cycle_configuration") - fun bulkWithProrationConfig(): BulkWithProrationConfig = - bulkWithProrationConfig.getRequired("bulk_with_proration_config") - fun cadence(): Cadence = cadence.getRequired("cadence") fun conversionRate(): Optional = @@ -54761,7 +19139,7 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - fun creditAllocation(): Optional = + fun creditAllocation(): Optional = Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) fun currency(): String = currency.getRequired("currency") @@ -54774,14 +19152,14 @@ private constructor( fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - fun invoicingCycleConfiguration(): Optional = + fun invoicingCycleConfiguration(): Optional = Optional.ofNullable( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") ) - fun item(): Item = item.getRequired("item") + fun item(): ItemSlimModel = item.getRequired("item") - fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) @@ -54793,7 +19171,7 @@ private constructor( */ fun metadata(): Metadata = metadata.getRequired("metadata") - fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) fun minimumAmount(): Optional = Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) @@ -54807,7 +19185,10 @@ private constructor( fun priceType(): PriceType = priceType.getRequired("price_type") - fun dimensionalPriceConfiguration(): Optional = + fun unitWithProrationConfig(): CustomRatingFunctionConfigModel = + unitWithProrationConfig.getRequired("unit_with_proration_config") + + fun dimensionalPriceConfiguration(): Optional = Optional.ofNullable( dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") ) @@ -54816,17 +19197,13 @@ private constructor( @JsonProperty("billable_metric") @ExcludeMissing - fun _billableMetric(): JsonField = billableMetric + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = + fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration - @JsonProperty("bulk_with_proration_config") - @ExcludeMissing - fun _bulkWithProrationConfig(): JsonField = bulkWithProrationConfig - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence @JsonProperty("conversion_rate") @@ -54839,7 +19216,7 @@ private constructor( @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation(): JsonField = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @@ -54855,12 +19232,12 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = + fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum @JsonProperty("maximum_amount") @ExcludeMissing @@ -54873,7 +19250,7 @@ private constructor( */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum @JsonProperty("minimum_amount") @ExcludeMissing @@ -54893,9 +19270,14 @@ private constructor( @ExcludeMissing fun _priceType(): JsonField = priceType + @JsonProperty("unit_with_proration_config") + @ExcludeMissing + fun _unitWithProrationConfig(): JsonField = + unitWithProrationConfig + @JsonProperty("dimensional_price_configuration") @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = + fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration @JsonAnyGetter @@ -54904,7 +19286,7 @@ private constructor( private var validated: Boolean = false - fun validate(): BulkWithProrationPrice = apply { + fun validate(): UnitWithProrationPrice = apply { if (validated) { return@apply } @@ -54912,7 +19294,6 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() - bulkWithProrationConfig().validate() cadence() conversionRate() createdAt() @@ -54932,6 +19313,7 @@ private constructor( name() planPhaseOrder() priceType() + unitWithProrationConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } validated = true } @@ -54940,96 +19322,122 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [UnitWithProrationPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * .unitWithProrationConfig() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [BulkWithProrationPrice]. */ + /** A builder for [UnitWithProrationPrice]. */ class Builder internal constructor() { private var id: JsonField? = null - private var billableMetric: JsonField? = null - private var billingCycleConfiguration: JsonField? = null - private var bulkWithProrationConfig: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null private var cadence: JsonField? = null private var conversionRate: JsonField? = null private var createdAt: JsonField? = null - private var creditAllocation: 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 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 minimum: JsonField? = null private var minimumAmount: JsonField? = null private var modelType: JsonField? = null private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null - private var dimensionalPriceConfiguration: JsonField = + private var unitWithProrationConfig: JsonField? = null + private var dimensionalPriceConfiguration: + JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(bulkWithProrationPrice: BulkWithProrationPrice) = apply { - id = bulkWithProrationPrice.id - billableMetric = bulkWithProrationPrice.billableMetric - billingCycleConfiguration = bulkWithProrationPrice.billingCycleConfiguration - bulkWithProrationConfig = bulkWithProrationPrice.bulkWithProrationConfig - cadence = bulkWithProrationPrice.cadence - conversionRate = bulkWithProrationPrice.conversionRate - createdAt = bulkWithProrationPrice.createdAt - creditAllocation = bulkWithProrationPrice.creditAllocation - currency = bulkWithProrationPrice.currency - discount = bulkWithProrationPrice.discount - externalPriceId = bulkWithProrationPrice.externalPriceId - fixedPriceQuantity = bulkWithProrationPrice.fixedPriceQuantity - invoicingCycleConfiguration = bulkWithProrationPrice.invoicingCycleConfiguration - item = bulkWithProrationPrice.item - maximum = bulkWithProrationPrice.maximum - maximumAmount = bulkWithProrationPrice.maximumAmount - metadata = bulkWithProrationPrice.metadata - minimum = bulkWithProrationPrice.minimum - minimumAmount = bulkWithProrationPrice.minimumAmount - modelType = bulkWithProrationPrice.modelType - name = bulkWithProrationPrice.name - planPhaseOrder = bulkWithProrationPrice.planPhaseOrder - priceType = bulkWithProrationPrice.priceType - dimensionalPriceConfiguration = bulkWithProrationPrice.dimensionalPriceConfiguration - additionalProperties = bulkWithProrationPrice.additionalProperties.toMutableMap() + internal fun from(unitWithProrationPrice: UnitWithProrationPrice) = apply { + id = unitWithProrationPrice.id + billableMetric = unitWithProrationPrice.billableMetric + billingCycleConfiguration = unitWithProrationPrice.billingCycleConfiguration + cadence = unitWithProrationPrice.cadence + conversionRate = unitWithProrationPrice.conversionRate + createdAt = unitWithProrationPrice.createdAt + creditAllocation = unitWithProrationPrice.creditAllocation + currency = unitWithProrationPrice.currency + discount = unitWithProrationPrice.discount + externalPriceId = unitWithProrationPrice.externalPriceId + fixedPriceQuantity = unitWithProrationPrice.fixedPriceQuantity + invoicingCycleConfiguration = unitWithProrationPrice.invoicingCycleConfiguration + item = unitWithProrationPrice.item + maximum = unitWithProrationPrice.maximum + maximumAmount = unitWithProrationPrice.maximumAmount + metadata = unitWithProrationPrice.metadata + minimum = unitWithProrationPrice.minimum + minimumAmount = unitWithProrationPrice.minimumAmount + modelType = unitWithProrationPrice.modelType + name = unitWithProrationPrice.name + planPhaseOrder = unitWithProrationPrice.planPhaseOrder + priceType = unitWithProrationPrice.priceType + unitWithProrationConfig = unitWithProrationPrice.unitWithProrationConfig + dimensionalPriceConfiguration = unitWithProrationPrice.dimensionalPriceConfiguration + additionalProperties = unitWithProrationPrice.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric?) = + fun billableMetric(billableMetric: BillableMetricTinyModel?) = billableMetric(JsonField.ofNullable(billableMetric)) - fun billableMetric(billableMetric: Optional) = + fun billableMetric(billableMetric: Optional) = billableMetric(billableMetric.orElse(null)) - fun billableMetric(billableMetric: JsonField) = apply { + fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric } - fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = - billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) fun billingCycleConfiguration( - billingCycleConfiguration: JsonField + billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = - bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) - - fun bulkWithProrationConfig( - bulkWithProrationConfig: JsonField - ) = apply { this.bulkWithProrationConfig = bulkWithProrationConfig } - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) fun cadence(cadence: JsonField) = apply { this.cadence = cadence } @@ -55053,13 +19461,13 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation?) = + fun creditAllocation(creditAllocation: AllocationModel?) = creditAllocation(JsonField.ofNullable(creditAllocation)) - fun creditAllocation(creditAllocation: Optional) = + fun creditAllocation(creditAllocation: Optional) = creditAllocation(creditAllocation.orElse(null)) - fun creditAllocation(creditAllocation: JsonField) = apply { + fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation } @@ -55115,26 +19523,26 @@ private constructor( } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? + invoicingCycleConfiguration: BillingCycleConfigurationModel? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional + invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField + invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun item(item: Item) = item(JsonField.of(item)) + fun item(item: ItemSlimModel) = item(JsonField.of(item)) - fun item(item: JsonField) = apply { this.item = item } + fun item(item: JsonField) = apply { this.item = item } - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) - fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } fun maximumAmount(maximumAmount: String?) = maximumAmount(JsonField.ofNullable(maximumAmount)) @@ -55160,11 +19568,11 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) - fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } fun minimumAmount(minimumAmount: String?) = minimumAmount(JsonField.ofNullable(minimumAmount)) @@ -55201,16 +19609,23 @@ private constructor( fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + fun unitWithProrationConfig(unitWithProrationConfig: CustomRatingFunctionConfigModel) = + unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) + + fun unitWithProrationConfig( + unitWithProrationConfig: JsonField + ) = apply { this.unitWithProrationConfig = unitWithProrationConfig } + fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: DimensionalPriceConfiguration? + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional + dimensionalPriceConfiguration: Optional ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField + dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } fun additionalProperties(additionalProperties: Map) = apply { @@ -55232,12 +19647,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): BulkWithProrationPrice = - BulkWithProrationPrice( + fun build(): UnitWithProrationPrice = + UnitWithProrationPrice( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), - checkRequired("bulkWithProrationConfig", bulkWithProrationConfig), checkRequired("cadence", cadence), checkRequired("conversionRate", conversionRate), checkRequired("createdAt", createdAt), @@ -55257,145 +19671,161 @@ private constructor( checkRequired("name", name), checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), + checkRequired("unitWithProrationConfig", unitWithProrationConfig), dimensionalPriceConfiguration, additionalProperties.toImmutable(), ) } - @NoAutoDetect - class BillableMetric - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillableMetric = apply { - if (validated) { - return@apply - } - - id() - validated = true - } + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { - fun toBuilder() = Builder().from(this) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { - @JvmStatic fun builder() = Builder() - } + @JvmField val ONE_TIME = of("one_time") - /** A builder for [BillableMetric]. */ - class Builder internal constructor() { + @JvmField val MONTHLY = of("monthly") - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + @JvmField val QUARTERLY = of("quarterly") - @JvmSynthetic - internal fun from(billableMetric: BillableMetric) = apply { - id = billableMetric.id - additionalProperties = billableMetric.additionalProperties.toMutableMap() - } + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun id(id: String) = id(JsonField.of(id)) + @JvmField val ANNUAL = of("annual") - fun id(id: JsonField) = apply { this.id = id } + @JvmField val CUSTOM = of("custom") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown value. + */ + _UNKNOWN, + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + 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 removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + 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 build(): BillableMetric = - BillableMetric(checkRequired("id", id), additionalProperties.toImmutable()) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is BillableMetric && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "BillableMetric{id=$id, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ @NoAutoDetect - class BillingCycleConfiguration + class Metadata @JsonCreator private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties private var validated: Boolean = false - fun validate(): BillingCycleConfiguration = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } - duration() - durationUnit() validated = true } @@ -55403,33 +19833,18 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [BillingCycleConfiguration]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { - private var duration: JsonField? = null - private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -55454,118 +19869,7 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -55573,104 +19877,115 @@ private constructor( return true } - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - @NoAutoDetect - class BulkWithProrationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - private var validated: Boolean = false + companion object { - fun validate(): BulkWithProrationConfig = apply { - if (validated) { - return@apply - } + @JvmField val UNIT_WITH_PRORATION = of("unit_with_proration") - validated = true + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() + /** An enum containing [ModelType]'s known values. */ + enum class Known { + UNIT_WITH_PRORATION } - /** A builder for [BulkWithProrationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(bulkWithProrationConfig: BulkWithProrationConfig) = apply { - additionalProperties = - bulkWithProrationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + UNIT_WITH_PRORATION, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + UNIT_WITH_PRORATION -> Value.UNIT_WITH_PRORATION + else -> Value._UNKNOWN } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + UNIT_WITH_PRORATION -> Known.UNIT_WITH_PRORATION + else -> throw OrbInvalidDataException("Unknown ModelType: $value") } - fun build(): BulkWithProrationConfig = - BulkWithProrationConfig(additionalProperties.toImmutable()) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is BulkWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "BulkWithProrationConfig{additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } - class Cadence @JsonCreator private constructor(private val value: JsonField) : + class PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -55685,49 +20000,34 @@ private constructor( companion object { - @JvmField val ONE_TIME = of("one_time") - - @JvmField val MONTHLY = of("monthly") - - @JvmField val QUARTERLY = of("quarterly") - - @JvmField val SEMI_ANNUAL = of("semi_annual") - - @JvmField val ANNUAL = of("annual") + @JvmField val USAGE_PRICE = of("usage_price") - @JvmField val CUSTOM = of("custom") + @JvmField val FIXED_PRICE = of("fixed_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, } /** - * 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, /** - * 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, } @@ -55741,12 +20041,8 @@ private constructor( */ fun value(): Value = when (this) { - ONE_TIME -> Value.ONE_TIME - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - SEMI_ANNUAL -> Value.SEMI_ANNUAL - ANNUAL -> Value.ANNUAL - CUSTOM -> Value.CUSTOM + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE else -> Value._UNKNOWN } @@ -55761,13 +20057,9 @@ private constructor( */ fun known(): Known = when (this) { - ONE_TIME -> Known.ONE_TIME - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - SEMI_ANNUAL -> Known.SEMI_ANNUAL - ANNUAL -> Known.ANNUAL - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") } /** @@ -55787,7 +20079,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -55795,770 +20087,808 @@ private constructor( override fun toString() = value.toString() } - @NoAutoDetect - class CreditAllocation - @JsonCreator - private constructor( - @JsonProperty("allows_rollover") - @ExcludeMissing - private val allowsRollover: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun allowsRollover(): Boolean = allowsRollover.getRequired("allows_rollover") + return /* spotless:off */ other is UnitWithProrationPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && unitWithProrationConfig == other.unitWithProrationConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + } - fun currency(): String = currency.getRequired("currency") + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, unitWithProrationConfig, dimensionalPriceConfiguration, additionalProperties) } + /* spotless:on */ - @JsonProperty("allows_rollover") - @ExcludeMissing - fun _allowsRollover(): JsonField = allowsRollover + override fun hashCode(): Int = hashCode - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + override fun toString() = + "UnitWithProrationPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, unitWithProrationConfig=$unitWithProrationConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + @NoAutoDetect + class GroupedAllocationPrice + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + private val billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + private val creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("grouped_allocation_config") + @ExcludeMissing + private val groupedAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + private val dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { - private var validated: Boolean = false + fun id(): String = id.getRequired("id") - fun validate(): CreditAllocation = apply { - if (validated) { - return@apply - } + fun billableMetric(): Optional = + Optional.ofNullable(billableMetric.getNullable("billable_metric")) - allowsRollover() - currency() - validated = true - } + fun billingCycleConfiguration(): BillingCycleConfigurationModel = + billingCycleConfiguration.getRequired("billing_cycle_configuration") - fun toBuilder() = Builder().from(this) + fun cadence(): Cadence = cadence.getRequired("cadence") - companion object { + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - @JvmStatic fun builder() = Builder() - } + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - /** A builder for [CreditAllocation]. */ - class Builder internal constructor() { + fun creditAllocation(): Optional = + Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) - private var allowsRollover: JsonField? = null - private var currency: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun currency(): String = currency.getRequired("currency") - @JvmSynthetic - internal fun from(creditAllocation: CreditAllocation) = apply { - allowsRollover = creditAllocation.allowsRollover - currency = creditAllocation.currency - additionalProperties = creditAllocation.additionalProperties.toMutableMap() - } + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) - fun allowsRollover(allowsRollover: Boolean) = - allowsRollover(JsonField.of(allowsRollover)) + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - fun allowsRollover(allowsRollover: JsonField) = apply { - this.allowsRollover = allowsRollover - } + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - fun currency(currency: String) = currency(JsonField.of(currency)) + fun groupedAllocationConfig(): CustomRatingFunctionConfigModel = + groupedAllocationConfig.getRequired("grouped_allocation_config") - fun currency(currency: JsonField) = apply { this.currency = currency } + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun item(): ItemSlimModel = item.getRequired("item") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * 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.getRequired("metadata") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) - fun build(): CreditAllocation = - CreditAllocation( - checkRequired("allowsRollover", allowsRollover), - checkRequired("currency", currency), - additionalProperties.toImmutable(), - ) - } + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun modelType(): ModelType = modelType.getRequired("model_type") - return /* spotless:off */ other is CreditAllocation && allowsRollover == other.allowsRollover && currency == other.currency && additionalProperties == other.additionalProperties /* spotless:on */ - } + fun name(): String = name.getRequired("name") - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allowsRollover, currency, additionalProperties) } - /* spotless:on */ + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - override fun hashCode(): Int = hashCode + fun priceType(): PriceType = priceType.getRequired("price_type") - override fun toString() = - "CreditAllocation{allowsRollover=$allowsRollover, currency=$currency, additionalProperties=$additionalProperties}" - } + fun dimensionalPriceConfiguration(): Optional = + Optional.ofNullable( + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + ) - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric + + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - fun duration(): Long = duration.getRequired("duration") + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - private var validated: Boolean = false + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - duration() - durationUnit() - validated = true - } + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - fun toBuilder() = Builder().from(this) + @JsonProperty("grouped_allocation_config") + @ExcludeMissing + fun _groupedAllocationConfig(): JsonField = + groupedAllocationConfig - companion object { + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - @JvmStatic fun builder() = Builder() - } + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun duration(duration: Long) = duration(JsonField.of(duration)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - fun duration(duration: JsonField) = apply { this.duration = duration } + private var validated: Boolean = false - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) + fun validate(): GroupedAllocationPrice = apply { + if (validated) { + return@apply + } - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + cadence() + conversionRate() + 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() + name() + planPhaseOrder() + priceType() + dimensionalPriceConfiguration().ifPresent { it.validate() } + validated = true + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun toBuilder() = Builder().from(this) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + companion object { - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns a mutable builder for constructing an instance of [GroupedAllocationPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .groupedAllocationConfig() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** A builder for [GroupedAllocationPrice]. */ + class Builder internal constructor() { - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var 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: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) + @JvmSynthetic + internal fun from(groupedAllocationPrice: GroupedAllocationPrice) = apply { + id = groupedAllocationPrice.id + billableMetric = groupedAllocationPrice.billableMetric + billingCycleConfiguration = groupedAllocationPrice.billingCycleConfiguration + cadence = groupedAllocationPrice.cadence + conversionRate = groupedAllocationPrice.conversionRate + createdAt = groupedAllocationPrice.createdAt + creditAllocation = groupedAllocationPrice.creditAllocation + currency = groupedAllocationPrice.currency + discount = groupedAllocationPrice.discount + externalPriceId = groupedAllocationPrice.externalPriceId + fixedPriceQuantity = groupedAllocationPrice.fixedPriceQuantity + groupedAllocationConfig = groupedAllocationPrice.groupedAllocationConfig + invoicingCycleConfiguration = groupedAllocationPrice.invoicingCycleConfiguration + item = groupedAllocationPrice.item + maximum = groupedAllocationPrice.maximum + maximumAmount = groupedAllocationPrice.maximumAmount + metadata = groupedAllocationPrice.metadata + minimum = groupedAllocationPrice.minimum + minimumAmount = groupedAllocationPrice.minimumAmount + modelType = groupedAllocationPrice.modelType + name = groupedAllocationPrice.name + planPhaseOrder = groupedAllocationPrice.planPhaseOrder + priceType = groupedAllocationPrice.priceType + dimensionalPriceConfiguration = groupedAllocationPrice.dimensionalPriceConfiguration + additionalProperties = groupedAllocationPrice.additionalProperties.toMutableMap() } - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { + fun id(id: String) = id(JsonField.of(id)) - @JvmField val DAY = of("day") + fun id(id: JsonField) = apply { this.id = id } - @JvmField val MONTH = of("month") + fun billableMetric(billableMetric: BillableMetricTinyModel?) = + billableMetric(JsonField.ofNullable(billableMetric)) - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.MONTH - else -> Value._UNKNOWN - } + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = 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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 cadence(cadence: JsonField) = apply { this.cadence = cadence } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) - override fun hashCode() = value.hashCode() + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) - override fun toString() = value.toString() + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + fun creditAllocation(creditAllocation: AllocationModel?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) - @NoAutoDetect - class Item - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } - fun id(): String = id.getRequired("id") + fun currency(currency: String) = currency(JsonField.of(currency)) - fun name(): String = name.getRequired("name") + fun currency(currency: JsonField) = apply { this.currency = currency } - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + fun discount(discount: Optional) = discount(discount.orElse(null)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun discount(discount: JsonField) = apply { this.discount = discount } - private var validated: Boolean = false + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) - fun validate(): Item = apply { - if (validated) { - return@apply - } + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) - id() - name() - validated = true - } + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) - fun toBuilder() = Builder().from(this) + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) - companion object { + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) - @JvmStatic fun builder() = Builder() - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - /** A builder for [Item]. */ - class Builder internal constructor() { + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - @JvmSynthetic - internal fun from(item: Item) = apply { - id = item.id - name = item.name - additionalProperties = item.additionalProperties.toMutableMap() - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - fun id(id: String) = id(JsonField.of(id)) + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - fun id(id: JsonField) = apply { this.id = id } + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - fun name(name: String) = name(JsonField.of(name)) + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - fun name(name: JsonField) = apply { this.name = name } + fun groupedAllocationConfig(groupedAllocationConfig: CustomRatingFunctionConfigModel) = + groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun groupedAllocationConfig( + groupedAllocationConfig: JsonField + ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun item(item: ItemSlimModel) = item(JsonField.of(item)) - fun build(): Item = - Item( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toImmutable(), - ) - } + fun item(item: JsonField) = apply { this.item = item } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) - return /* spotless:off */ other is Item && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ - } + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - /* spotless:on */ + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - override fun hashCode(): Int = hashCode + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) - override fun toString() = - "Item{id=$id, name=$name, additionalProperties=$additionalProperties}" - } + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) - @NoAutoDetect - class Maximum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. + * 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 appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Maximum amount applied */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. + * 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("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Maximum amount applied */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - private var validated: Boolean = false + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) - fun validate(): Maximum = apply { - if (validated) { - return@apply - } + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - appliesToPriceIds() - maximumAmount() - validated = true - } + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - fun toBuilder() = Builder().from(this) + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) - companion object { + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) - @JvmStatic fun builder() = Builder() + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount } - /** A builder for [Maximum]. */ - class Builder internal constructor() { + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } - @JvmSynthetic - internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = maximum.maximumAmount - additionalProperties = maximum.additionalProperties.toMutableMap() - } + fun name(name: String) = name(JsonField.of(name)) - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) + fun name(name: JsonField) = apply { this.name = name } - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - fun build(): Maximum = - Maximum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("maximumAmount", maximumAmount), - additionalProperties.toImmutable(), - ) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - return /* spotless:off */ other is Maximum && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && additionalProperties == other.additionalProperties /* spotless:on */ + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, maximumAmount, additionalProperties) } - /* spotless:on */ + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - override fun hashCode(): Int = hashCode + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun toString() = - "Maximum{appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, additionalProperties=$additionalProperties}" + fun build(): GroupedAllocationPrice = + GroupedAllocationPrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + 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), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) } - /** - * 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - validated = true - } + companion object { - fun toBuilder() = Builder().from(this) + @JvmField val ONE_TIME = of("one_time") - companion object { + @JvmField val MONTHLY = of("monthly") - @JvmStatic fun builder() = Builder() - } + @JvmField val QUARTERLY = of("quarterly") - /** A builder for [Metadata]. */ - class Builder internal constructor() { + @JvmField val SEMI_ANNUAL = of("semi_annual") - private var additionalProperties: MutableMap = mutableMapOf() + @JvmField val ANNUAL = of("annual") - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + @JvmField val CUSTOM = of("custom") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown value. + */ + _UNKNOWN, + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + 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 removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + 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 build(): Metadata = Metadata(additionalProperties.toImmutable()) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ @NoAutoDetect - class Minimum + class Metadata @JsonCreator private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Minimum amount applied */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Minimum amount applied */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties private var validated: Boolean = false - fun validate(): Minimum = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } - appliesToPriceIds() - minimumAmount() validated = true } @@ -56566,62 +20896,18 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [Minimum]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { - private var appliesToPriceIds: JsonField>? = null - private var minimumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } - minimumAmount = minimum.minimumAmount - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -56646,14 +20932,7 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): Minimum = - Minimum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("minimumAmount", minimumAmount), - additionalProperties.toImmutable(), - ) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -56661,17 +20940,16 @@ private constructor( return true } - return /* spotless:off */ other is Minimum && appliesToPriceIds == other.appliesToPriceIds && minimumAmount == other.minimumAmount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, minimumAmount, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode - override fun toString() = - "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } class ModelType @JsonCreator private constructor(private val value: JsonField) : @@ -56689,14 +20967,14 @@ private constructor( companion object { - @JvmField val BULK_WITH_PRORATION = of("bulk_with_proration") + @JvmField val GROUPED_ALLOCATION = of("grouped_allocation") @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } /** An enum containing [ModelType]'s known values. */ enum class Known { - BULK_WITH_PRORATION + GROUPED_ALLOCATION } /** @@ -56709,7 +20987,7 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - BULK_WITH_PRORATION, + GROUPED_ALLOCATION, /** * An enum member indicating that [ModelType] was instantiated with an unknown * value. @@ -56726,7 +21004,7 @@ private constructor( */ fun value(): Value = when (this) { - BULK_WITH_PRORATION -> Value.BULK_WITH_PRORATION + GROUPED_ALLOCATION -> Value.GROUPED_ALLOCATION else -> Value._UNKNOWN } @@ -56741,7 +21019,7 @@ private constructor( */ fun known(): Known = when (this) { - BULK_WITH_PRORATION -> Known.BULK_WITH_PRORATION + GROUPED_ALLOCATION -> Known.GROUPED_ALLOCATION else -> throw OrbInvalidDataException("Unknown ModelType: $value") } @@ -56872,178 +21150,35 @@ private constructor( override fun toString() = value.toString() } - @NoAutoDetect - class DimensionalPriceConfiguration - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - private val dimensionalPriceGroupId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun dimensionValues(): List = dimensionValues.getRequired("dimension_values") - - fun dimensionalPriceGroupId(): String = - dimensionalPriceGroupId.getRequired("dimensional_price_group_id") - - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - fun _dimensionalPriceGroupId(): JsonField = dimensionalPriceGroupId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): DimensionalPriceConfiguration = apply { - if (validated) { - return@apply - } - - dimensionValues() - dimensionalPriceGroupId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DimensionalPriceConfiguration]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var dimensionalPriceGroupId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(dimensionalPriceConfiguration: DimensionalPriceConfiguration) = - apply { - dimensionValues = - dimensionalPriceConfiguration.dimensionValues.map { it.toMutableList() } - dimensionalPriceGroupId = - dimensionalPriceConfiguration.dimensionalPriceGroupId - additionalProperties = - dimensionalPriceConfiguration.additionalProperties.toMutableMap() - } - - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: String) = - dimensionalPriceGroupId(JsonField.of(dimensionalPriceGroupId)) - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: JsonField) = apply { - this.dimensionalPriceGroupId = dimensionalPriceGroupId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): DimensionalPriceConfiguration = - DimensionalPriceConfiguration( - checkRequired("dimensionValues", dimensionValues).map { it.toImmutable() }, - checkRequired("dimensionalPriceGroupId", dimensionalPriceGroupId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DimensionalPriceConfiguration && dimensionValues == other.dimensionValues && dimensionalPriceGroupId == other.dimensionalPriceGroupId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, dimensionalPriceGroupId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DimensionalPriceConfiguration{dimensionValues=$dimensionValues, dimensionalPriceGroupId=$dimensionalPriceGroupId, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is BulkWithProrationPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && bulkWithProrationConfig == other.bulkWithProrationConfig && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedAllocationPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && groupedAllocationConfig == other.groupedAllocationConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, bulkWithProrationConfig, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, groupedAllocationConfig, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithProrationPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedAllocationPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedAllocationConfig=$groupedAllocationConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } @NoAutoDetect - class GroupedTieredPackagePrice + class GroupedWithProratedMinimumPrice @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("billable_metric") @ExcludeMissing - private val billableMetric: JsonField = JsonMissing.of(), + private val billableMetric: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") @ExcludeMissing - private val billingCycleConfiguration: JsonField = + private val billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing @@ -57056,7 +21191,7 @@ private constructor( private val createdAt: JsonField = JsonMissing.of(), @JsonProperty("credit_allocation") @ExcludeMissing - private val creditAllocation: JsonField = JsonMissing.of(), + private val creditAllocation: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing private val currency: JsonField = JsonMissing.of(), @@ -57069,18 +21204,20 @@ private constructor( @JsonProperty("fixed_price_quantity") @ExcludeMissing private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("grouped_tiered_package_config") + @JsonProperty("grouped_with_prorated_minimum_config") @ExcludeMissing - private val groupedTieredPackageConfig: JsonField = + private val groupedWithProratedMinimumConfig: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = + private val invoicingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("item") @ExcludeMissing private val item: JsonField = JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), @JsonProperty("maximum") @ExcludeMissing - private val maximum: JsonField = JsonMissing.of(), + private val maximum: JsonField = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing private val maximumAmount: JsonField = JsonMissing.of(), @@ -57089,7 +21226,7 @@ private constructor( private val metadata: JsonField = JsonMissing.of(), @JsonProperty("minimum") @ExcludeMissing - private val minimum: JsonField = JsonMissing.of(), + private val minimum: JsonField = JsonMissing.of(), @JsonProperty("minimum_amount") @ExcludeMissing private val minimumAmount: JsonField = JsonMissing.of(), @@ -57107,7 +21244,7 @@ private constructor( private val priceType: JsonField = JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing - private val dimensionalPriceConfiguration: JsonField = + private val dimensionalPriceConfiguration: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), @@ -57115,10 +21252,10 @@ private constructor( fun id(): String = id.getRequired("id") - fun billableMetric(): Optional = + fun billableMetric(): Optional = Optional.ofNullable(billableMetric.getNullable("billable_metric")) - fun billingCycleConfiguration(): BillingCycleConfiguration = + fun billingCycleConfiguration(): BillingCycleConfigurationModel = billingCycleConfiguration.getRequired("billing_cycle_configuration") fun cadence(): Cadence = cadence.getRequired("cadence") @@ -57128,7 +21265,7 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - fun creditAllocation(): Optional = + fun creditAllocation(): Optional = Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) fun currency(): String = currency.getRequired("currency") @@ -57141,17 +21278,17 @@ private constructor( fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - fun groupedTieredPackageConfig(): GroupedTieredPackageConfig = - groupedTieredPackageConfig.getRequired("grouped_tiered_package_config") + fun groupedWithProratedMinimumConfig(): CustomRatingFunctionConfigModel = + groupedWithProratedMinimumConfig.getRequired("grouped_with_prorated_minimum_config") - fun invoicingCycleConfiguration(): Optional = + fun invoicingCycleConfiguration(): Optional = Optional.ofNullable( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") ) - fun item(): Item = item.getRequired("item") + fun item(): ItemSlimModel = item.getRequired("item") - fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) @@ -57163,7 +21300,7 @@ private constructor( */ fun metadata(): Metadata = metadata.getRequired("metadata") - fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) fun minimumAmount(): Optional = Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) @@ -57177,7 +21314,7 @@ private constructor( fun priceType(): PriceType = priceType.getRequired("price_type") - fun dimensionalPriceConfiguration(): Optional = + fun dimensionalPriceConfiguration(): Optional = Optional.ofNullable( dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") ) @@ -57186,11 +21323,11 @@ private constructor( @JsonProperty("billable_metric") @ExcludeMissing - fun _billableMetric(): JsonField = billableMetric + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = + fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence @@ -57205,7 +21342,7 @@ private constructor( @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation(): JsonField = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @@ -57219,19 +21356,19 @@ private constructor( @ExcludeMissing fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - @JsonProperty("grouped_tiered_package_config") + @JsonProperty("grouped_with_prorated_minimum_config") @ExcludeMissing - fun _groupedTieredPackageConfig(): JsonField = - groupedTieredPackageConfig + fun _groupedWithProratedMinimumConfig(): JsonField = + groupedWithProratedMinimumConfig @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = + fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum @JsonProperty("maximum_amount") @ExcludeMissing @@ -57244,7 +21381,7 @@ private constructor( */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum @JsonProperty("minimum_amount") @ExcludeMissing @@ -57266,7 +21403,7 @@ private constructor( @JsonProperty("dimensional_price_configuration") @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = + fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration @JsonAnyGetter @@ -57275,7 +21412,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedTieredPackagePrice = apply { + fun validate(): GroupedWithProratedMinimumPrice = apply { if (validated) { return@apply } @@ -57291,7 +21428,7 @@ private constructor( discount().ifPresent { it.validate() } externalPriceId() fixedPriceQuantity() - groupedTieredPackageConfig().validate() + groupedWithProratedMinimumConfig().validate() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() maximum().ifPresent { it.validate() } @@ -57311,88 +21448,129 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithProratedMinimumPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .groupedWithProratedMinimumConfig() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedTieredPackagePrice]. */ + /** A builder for [GroupedWithProratedMinimumPrice]. */ class Builder internal constructor() { private var id: JsonField? = null - private var billableMetric: JsonField? = null - private var billingCycleConfiguration: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null private var cadence: JsonField? = null private var conversionRate: JsonField? = null private var createdAt: JsonField? = null - private var creditAllocation: 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 groupedTieredPackageConfig: JsonField? = null - private var invoicingCycleConfiguration: JsonField? = null - private var item: JsonField? = null - private var maximum: JsonField? = null + private var groupedWithProratedMinimumConfig: + 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 minimum: JsonField? = null private var minimumAmount: JsonField? = null private var modelType: JsonField? = null private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null - private var dimensionalPriceConfiguration: JsonField = + private var dimensionalPriceConfiguration: + JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(groupedTieredPackagePrice: GroupedTieredPackagePrice) = apply { - id = groupedTieredPackagePrice.id - billableMetric = groupedTieredPackagePrice.billableMetric - billingCycleConfiguration = groupedTieredPackagePrice.billingCycleConfiguration - cadence = groupedTieredPackagePrice.cadence - conversionRate = groupedTieredPackagePrice.conversionRate - createdAt = groupedTieredPackagePrice.createdAt - creditAllocation = groupedTieredPackagePrice.creditAllocation - currency = groupedTieredPackagePrice.currency - discount = groupedTieredPackagePrice.discount - externalPriceId = groupedTieredPackagePrice.externalPriceId - fixedPriceQuantity = groupedTieredPackagePrice.fixedPriceQuantity - groupedTieredPackageConfig = groupedTieredPackagePrice.groupedTieredPackageConfig - invoicingCycleConfiguration = groupedTieredPackagePrice.invoicingCycleConfiguration - item = groupedTieredPackagePrice.item - maximum = groupedTieredPackagePrice.maximum - maximumAmount = groupedTieredPackagePrice.maximumAmount - metadata = groupedTieredPackagePrice.metadata - minimum = groupedTieredPackagePrice.minimum - minimumAmount = groupedTieredPackagePrice.minimumAmount - modelType = groupedTieredPackagePrice.modelType - name = groupedTieredPackagePrice.name - planPhaseOrder = groupedTieredPackagePrice.planPhaseOrder - priceType = groupedTieredPackagePrice.priceType - dimensionalPriceConfiguration = - groupedTieredPackagePrice.dimensionalPriceConfiguration - additionalProperties = groupedTieredPackagePrice.additionalProperties.toMutableMap() - } + internal fun from(groupedWithProratedMinimumPrice: GroupedWithProratedMinimumPrice) = + apply { + id = groupedWithProratedMinimumPrice.id + billableMetric = groupedWithProratedMinimumPrice.billableMetric + billingCycleConfiguration = + groupedWithProratedMinimumPrice.billingCycleConfiguration + cadence = groupedWithProratedMinimumPrice.cadence + conversionRate = groupedWithProratedMinimumPrice.conversionRate + createdAt = groupedWithProratedMinimumPrice.createdAt + creditAllocation = groupedWithProratedMinimumPrice.creditAllocation + currency = groupedWithProratedMinimumPrice.currency + discount = groupedWithProratedMinimumPrice.discount + externalPriceId = groupedWithProratedMinimumPrice.externalPriceId + fixedPriceQuantity = groupedWithProratedMinimumPrice.fixedPriceQuantity + groupedWithProratedMinimumConfig = + groupedWithProratedMinimumPrice.groupedWithProratedMinimumConfig + invoicingCycleConfiguration = + groupedWithProratedMinimumPrice.invoicingCycleConfiguration + item = groupedWithProratedMinimumPrice.item + maximum = groupedWithProratedMinimumPrice.maximum + maximumAmount = groupedWithProratedMinimumPrice.maximumAmount + metadata = groupedWithProratedMinimumPrice.metadata + minimum = groupedWithProratedMinimumPrice.minimum + minimumAmount = groupedWithProratedMinimumPrice.minimumAmount + modelType = groupedWithProratedMinimumPrice.modelType + name = groupedWithProratedMinimumPrice.name + planPhaseOrder = groupedWithProratedMinimumPrice.planPhaseOrder + priceType = groupedWithProratedMinimumPrice.priceType + dimensionalPriceConfiguration = + groupedWithProratedMinimumPrice.dimensionalPriceConfiguration + additionalProperties = + groupedWithProratedMinimumPrice.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric?) = + fun billableMetric(billableMetric: BillableMetricTinyModel?) = billableMetric(JsonField.ofNullable(billableMetric)) - fun billableMetric(billableMetric: Optional) = + fun billableMetric(billableMetric: Optional) = billableMetric(billableMetric.orElse(null)) - fun billableMetric(billableMetric: JsonField) = apply { + fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric } - fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = - billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) fun billingCycleConfiguration( - billingCycleConfiguration: JsonField + billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -57418,13 +21596,13 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation?) = + fun creditAllocation(creditAllocation: AllocationModel?) = creditAllocation(JsonField.ofNullable(creditAllocation)) - fun creditAllocation(creditAllocation: Optional) = + fun creditAllocation(creditAllocation: Optional) = creditAllocation(creditAllocation.orElse(null)) - fun creditAllocation(creditAllocation: JsonField) = apply { + fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation } @@ -57479,34 +21657,35 @@ private constructor( this.fixedPriceQuantity = fixedPriceQuantity } - fun groupedTieredPackageConfig(groupedTieredPackageConfig: GroupedTieredPackageConfig) = - groupedTieredPackageConfig(JsonField.of(groupedTieredPackageConfig)) + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: CustomRatingFunctionConfigModel + ) = groupedWithProratedMinimumConfig(JsonField.of(groupedWithProratedMinimumConfig)) - fun groupedTieredPackageConfig( - groupedTieredPackageConfig: JsonField - ) = apply { this.groupedTieredPackageConfig = groupedTieredPackageConfig } + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: JsonField + ) = apply { this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? + invoicingCycleConfiguration: BillingCycleConfigurationModel? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional + invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField + invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun item(item: Item) = item(JsonField.of(item)) + fun item(item: ItemSlimModel) = item(JsonField.of(item)) - fun item(item: JsonField) = apply { this.item = item } + fun item(item: JsonField) = apply { this.item = item } - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) - fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } fun maximumAmount(maximumAmount: String?) = maximumAmount(JsonField.ofNullable(maximumAmount)) @@ -57532,11 +21711,11 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) - fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } fun minimumAmount(minimumAmount: String?) = minimumAmount(JsonField.ofNullable(minimumAmount)) @@ -57574,15 +21753,15 @@ private constructor( fun priceType(priceType: JsonField) = apply { this.priceType = priceType } fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: DimensionalPriceConfiguration? + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional + dimensionalPriceConfiguration: Optional ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField + dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } fun additionalProperties(additionalProperties: Map) = apply { @@ -57604,358 +21783,37 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): GroupedTieredPackagePrice = - GroupedTieredPackagePrice( + fun build(): GroupedWithProratedMinimumPrice = + GroupedWithProratedMinimumPrice( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), - checkRequired("cadence", cadence), - checkRequired("conversionRate", conversionRate), - checkRequired("createdAt", createdAt), - checkRequired("creditAllocation", creditAllocation), - checkRequired("currency", currency), - checkRequired("discount", discount), - checkRequired("externalPriceId", externalPriceId), - checkRequired("fixedPriceQuantity", fixedPriceQuantity), - checkRequired("groupedTieredPackageConfig", groupedTieredPackageConfig), - checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), - checkRequired("item", item), - checkRequired("maximum", maximum), - checkRequired("maximumAmount", maximumAmount), - checkRequired("metadata", metadata), - checkRequired("minimum", minimum), - checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("priceType", priceType), - dimensionalPriceConfiguration, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BillableMetric - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillableMetric = apply { - if (validated) { - return@apply - } - - id() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillableMetric]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billableMetric: BillableMetric) = apply { - id = billableMetric.id - additionalProperties = billableMetric.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - 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) - } - - fun build(): BillableMetric = - BillableMetric(checkRequired("id", id), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillableMetric && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillableMetric{id=$id, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired( + "groupedWithProratedMinimumConfig", + groupedWithProratedMinimumConfig, + ), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) } class Cadence @JsonCreator private constructor(private val value: JsonField) : @@ -58083,43 +21941,30 @@ private constructor( override fun toString() = value.toString() } + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ @NoAutoDetect - class CreditAllocation + class Metadata @JsonCreator private constructor( - @JsonProperty("allows_rollover") - @ExcludeMissing - private val allowsRollover: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { - fun allowsRollover(): Boolean = allowsRollover.getRequired("allows_rollover") - - fun currency(): String = currency.getRequired("currency") - - @JsonProperty("allows_rollover") - @ExcludeMissing - fun _allowsRollover(): JsonField = allowsRollover - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties private var validated: Boolean = false - fun validate(): CreditAllocation = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } - allowsRollover() - currency() validated = true } @@ -58127,34 +21972,20 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [CreditAllocation]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { - private var allowsRollover: JsonField? = null - private var currency: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(creditAllocation: CreditAllocation) = apply { - allowsRollover = creditAllocation.allowsRollover - currency = creditAllocation.currency - additionalProperties = creditAllocation.additionalProperties.toMutableMap() - } - - fun allowsRollover(allowsRollover: Boolean) = - allowsRollover(JsonField.of(allowsRollover)) - - fun allowsRollover(allowsRollover: JsonField) = apply { - this.allowsRollover = allowsRollover + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -58177,12 +22008,7 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): CreditAllocation = - CreditAllocation( - checkRequired("allowsRollover", allowsRollover), - checkRequired("currency", currency), - additionalProperties.toImmutable(), - ) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -58190,747 +22016,1031 @@ private constructor( return true } - return /* spotless:off */ other is CreditAllocation && allowsRollover == other.allowsRollover && currency == other.currency && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allowsRollover, currency, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode - override fun toString() = - "CreditAllocation{allowsRollover=$allowsRollover, currency=$currency, additionalProperties=$additionalProperties}" + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - @NoAutoDetect - class GroupedTieredPackageConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - private var validated: Boolean = false + companion object { - fun validate(): GroupedTieredPackageConfig = apply { - if (validated) { - return@apply - } + @JvmField val GROUPED_WITH_PRORATED_MINIMUM = of("grouped_with_prorated_minimum") - validated = true + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() + /** An enum containing [ModelType]'s known values. */ + enum class Known { + GROUPED_WITH_PRORATED_MINIMUM } - /** A builder for [GroupedTieredPackageConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GROUPED_WITH_PRORATED_MINIMUM, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - @JvmSynthetic - internal fun from(groupedTieredPackageConfig: GroupedTieredPackageConfig) = apply { - additionalProperties = - groupedTieredPackageConfig.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) { + GROUPED_WITH_PRORATED_MINIMUM -> Value.GROUPED_WITH_PRORATED_MINIMUM + else -> Value._UNKNOWN } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + GROUPED_WITH_PRORATED_MINIMUM -> Known.GROUPED_WITH_PRORATED_MINIMUM + else -> throw OrbInvalidDataException("Unknown ModelType: $value") } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") } - fun build(): GroupedTieredPackageConfig = - GroupedTieredPackageConfig(additionalProperties.toImmutable()) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is GroupedTieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + override fun hashCode() = value.hashCode() - override fun hashCode(): Int = hashCode + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - override fun toString() = - "GroupedTieredPackageConfig{additionalProperties=$additionalProperties}" + return /* spotless:off */ other is GroupedWithProratedMinimumPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && groupedWithProratedMinimumConfig == other.groupedWithProratedMinimumConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, groupedWithProratedMinimumConfig, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode - fun duration(): Long = duration.getRequired("duration") + override fun toString() = + "GroupedWithProratedMinimumPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + @NoAutoDetect + class GroupedWithMeteredMinimumPrice + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + private val billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + private val creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_metered_minimum_config") + @ExcludeMissing + private val groupedWithMeteredMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + private val dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + fun id(): String = id.getRequired("id") - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit + fun billableMetric(): Optional = + Optional.ofNullable(billableMetric.getNullable("billable_metric")) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun billingCycleConfiguration(): BillingCycleConfigurationModel = + billingCycleConfiguration.getRequired("billing_cycle_configuration") - private var validated: Boolean = false + fun cadence(): Cadence = cadence.getRequired("cadence") - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - duration() - durationUnit() - validated = true - } + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - fun toBuilder() = Builder().from(this) + fun creditAllocation(): Optional = + Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) - companion object { + fun currency(): String = currency.getRequired("currency") - @JvmStatic fun builder() = Builder() - } + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + fun groupedWithMeteredMinimumConfig(): CustomRatingFunctionConfigModel = + groupedWithMeteredMinimumConfig.getRequired("grouped_with_metered_minimum_config") + + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + fun item(): ItemSlimModel = item.getRequired("item") + + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + fun modelType(): ModelType = modelType.getRequired("model_type") + + fun name(): String = name.getRequired("name") + + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + fun priceType(): PriceType = priceType.getRequired("price_type") + + fun dimensionalPriceConfiguration(): Optional = + Optional.ofNullable( + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + ) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric + + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation + + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount + + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + @JsonProperty("grouped_with_metered_minimum_config") + @ExcludeMissing + fun _groupedWithMeteredMinimumConfig(): JsonField = + groupedWithMeteredMinimumConfig + + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType + + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): GroupedWithMeteredMinimumPrice = apply { + if (validated) { + return@apply + } + + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + cadence() + conversionRate() + createdAt() + creditAllocation().ifPresent { it.validate() } + currency() + discount().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + groupedWithMeteredMinimumConfig().validate() + invoicingCycleConfiguration().ifPresent { it.validate() } + item().validate() + maximum().ifPresent { it.validate() } + maximumAmount() + metadata().validate() + minimum().ifPresent { it.validate() } + minimumAmount() + modelType() + name() + planPhaseOrder() + priceType() + dimensionalPriceConfiguration().ifPresent { it.validate() } + validated = true + } - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } + fun toBuilder() = Builder().from(this) - fun duration(duration: Long) = duration(JsonField.of(duration)) + companion object { - fun duration(duration: JsonField) = apply { this.duration = duration } + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMeteredMinimumPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .groupedWithMeteredMinimumConfig() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) + /** A builder for [GroupedWithMeteredMinimumPrice]. */ + class Builder internal constructor() { - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var 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 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: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + @JvmSynthetic + internal fun from(groupedWithMeteredMinimumPrice: GroupedWithMeteredMinimumPrice) = + apply { + id = groupedWithMeteredMinimumPrice.id + billableMetric = groupedWithMeteredMinimumPrice.billableMetric + billingCycleConfiguration = + groupedWithMeteredMinimumPrice.billingCycleConfiguration + cadence = groupedWithMeteredMinimumPrice.cadence + conversionRate = groupedWithMeteredMinimumPrice.conversionRate + createdAt = groupedWithMeteredMinimumPrice.createdAt + creditAllocation = groupedWithMeteredMinimumPrice.creditAllocation + currency = groupedWithMeteredMinimumPrice.currency + discount = groupedWithMeteredMinimumPrice.discount + externalPriceId = groupedWithMeteredMinimumPrice.externalPriceId + fixedPriceQuantity = groupedWithMeteredMinimumPrice.fixedPriceQuantity + groupedWithMeteredMinimumConfig = + groupedWithMeteredMinimumPrice.groupedWithMeteredMinimumConfig + invoicingCycleConfiguration = + groupedWithMeteredMinimumPrice.invoicingCycleConfiguration + item = groupedWithMeteredMinimumPrice.item + maximum = groupedWithMeteredMinimumPrice.maximum + maximumAmount = groupedWithMeteredMinimumPrice.maximumAmount + metadata = groupedWithMeteredMinimumPrice.metadata + minimum = groupedWithMeteredMinimumPrice.minimum + minimumAmount = groupedWithMeteredMinimumPrice.minimumAmount + modelType = groupedWithMeteredMinimumPrice.modelType + name = groupedWithMeteredMinimumPrice.name + planPhaseOrder = groupedWithMeteredMinimumPrice.planPhaseOrder + priceType = groupedWithMeteredMinimumPrice.priceType + dimensionalPriceConfiguration = + groupedWithMeteredMinimumPrice.dimensionalPriceConfiguration + additionalProperties = + groupedWithMeteredMinimumPrice.additionalProperties.toMutableMap() } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun id(id: String) = id(JsonField.of(id)) - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun id(id: JsonField) = apply { this.id = id } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun billableMetric(billableMetric: BillableMetricTinyModel?) = + billableMetric(JsonField.ofNullable(billableMetric)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) - fun build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric } - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) - @JvmField val DAY = of("day") + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - @JvmField val MONTH = of("month") + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.MONTH - else -> Value._UNKNOWN - } + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } + fun creditAllocation(creditAllocation: AllocationModel?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) - override fun hashCode() = value.hashCode() + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) - override fun toString() = value.toString() + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } + fun currency(currency: String) = currency(JsonField.of(currency)) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ + fun currency(currency: JsonField) = apply { this.currency = currency } - override fun hashCode(): Int = hashCode + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } + fun discount(discount: Optional) = discount(discount.orElse(null)) - @NoAutoDetect - class Item - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + fun discount(discount: JsonField) = apply { this.discount = discount } - fun id(): String = id.getRequired("id") + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) - fun name(): String = name.getRequired("name") + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) - private var validated: Boolean = false + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - fun validate(): Item = apply { - if (validated) { - return@apply - } + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) - id() - name() - validated = true + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId } - fun toBuilder() = Builder().from(this) - - companion object { + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - @JvmStatic fun builder() = Builder() - } + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - /** A builder for [Item]. */ - class Builder internal constructor() { + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } - @JvmSynthetic - internal fun from(item: Item) = apply { - id = item.id - name = item.name - additionalProperties = item.additionalProperties.toMutableMap() - } + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: CustomRatingFunctionConfigModel + ) = groupedWithMeteredMinimumConfig(JsonField.of(groupedWithMeteredMinimumConfig)) - fun id(id: String) = id(JsonField.of(id)) + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: JsonField + ) = apply { this.groupedWithMeteredMinimumConfig = groupedWithMeteredMinimumConfig } - fun id(id: JsonField) = apply { this.id = id } + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - fun name(name: String) = name(JsonField.of(name)) + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) - fun name(name: JsonField) = apply { this.name = name } + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun item(item: ItemSlimModel) = item(JsonField.of(item)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun item(item: JsonField) = apply { this.item = item } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - fun build(): Item = - Item( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toImmutable(), - ) - } + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) - return /* spotless:off */ other is Item && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Item{id=$id, name=$name, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Maximum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. + * 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 appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Maximum amount applied */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. + * 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("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Maximum amount applied */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - private var validated: Boolean = false + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) - fun validate(): Maximum = apply { - if (validated) { - return@apply - } + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - appliesToPriceIds() - maximumAmount() - validated = true - } + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - fun toBuilder() = Builder().from(this) + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) - companion object { + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) - @JvmStatic fun builder() = Builder() + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount } - /** A builder for [Maximum]. */ - class Builder internal constructor() { + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } - @JvmSynthetic - internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = maximum.maximumAmount - additionalProperties = maximum.additionalProperties.toMutableMap() - } + fun name(name: String) = name(JsonField.of(name)) - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) + fun name(name: JsonField) = apply { this.name = name } - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - fun build(): Maximum = - Maximum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("maximumAmount", maximumAmount), - additionalProperties.toImmutable(), - ) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - return /* spotless:off */ other is Maximum && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && additionalProperties == other.additionalProperties /* spotless:on */ + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, maximumAmount, additionalProperties) } - /* spotless:on */ + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - override fun hashCode(): Int = hashCode + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun toString() = - "Maximum{appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, additionalProperties=$additionalProperties}" + fun build(): GroupedWithMeteredMinimumPrice = + GroupedWithMeteredMinimumPrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired( + "groupedWithMeteredMinimumConfig", + groupedWithMeteredMinimumConfig, + ), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) } - /** - * 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { - fun validate(): Metadata = apply { - if (validated) { - return@apply - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - validated = true - } + companion object { - fun toBuilder() = Builder().from(this) + @JvmField val ONE_TIME = of("one_time") - companion object { + @JvmField val MONTHLY = of("monthly") - @JvmStatic fun builder() = Builder() - } + @JvmField val QUARTERLY = of("quarterly") - /** A builder for [Metadata]. */ - class Builder internal constructor() { + @JvmField val SEMI_ANNUAL = of("semi_annual") - private var additionalProperties: MutableMap = mutableMapOf() + @JvmField val ANNUAL = of("annual") - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - additionalProperties = metadata.additionalProperties.toMutableMap() - } + @JvmField val CUSTOM = of("custom") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown value. + */ + _UNKNOWN, + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + 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 removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + 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 build(): Metadata = Metadata(additionalProperties.toImmutable()) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ @NoAutoDetect - class Minimum + class Metadata @JsonCreator private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Minimum amount applied */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Minimum amount applied */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties private var validated: Boolean = false - fun validate(): Minimum = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } - appliesToPriceIds() - minimumAmount() validated = true } @@ -58938,62 +23048,18 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [Minimum]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { - private var appliesToPriceIds: JsonField>? = null - private var minimumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } - minimumAmount = minimum.minimumAmount - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -59018,14 +23084,7 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): Minimum = - Minimum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("minimumAmount", minimumAmount), - additionalProperties.toImmutable(), - ) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { @@ -59033,17 +23092,16 @@ private constructor( return true } - return /* spotless:off */ other is Minimum && appliesToPriceIds == other.appliesToPriceIds && minimumAmount == other.minimumAmount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, minimumAmount, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode - override fun toString() = - "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } class ModelType @JsonCreator private constructor(private val value: JsonField) : @@ -59061,14 +23119,14 @@ private constructor( companion object { - @JvmField val GROUPED_TIERED_PACKAGE = of("grouped_tiered_package") + @JvmField val GROUPED_WITH_METERED_MINIMUM = of("grouped_with_metered_minimum") @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } /** An enum containing [ModelType]'s known values. */ enum class Known { - GROUPED_TIERED_PACKAGE + GROUPED_WITH_METERED_MINIMUM } /** @@ -59081,7 +23139,7 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - GROUPED_TIERED_PACKAGE, + GROUPED_WITH_METERED_MINIMUM, /** * An enum member indicating that [ModelType] was instantiated with an unknown * value. @@ -59098,7 +23156,7 @@ private constructor( */ fun value(): Value = when (this) { - GROUPED_TIERED_PACKAGE -> Value.GROUPED_TIERED_PACKAGE + GROUPED_WITH_METERED_MINIMUM -> Value.GROUPED_WITH_METERED_MINIMUM else -> Value._UNKNOWN } @@ -59113,7 +23171,7 @@ private constructor( */ fun known(): Known = when (this) { - GROUPED_TIERED_PACKAGE -> Known.GROUPED_TIERED_PACKAGE + GROUPED_WITH_METERED_MINIMUM -> Known.GROUPED_WITH_METERED_MINIMUM else -> throw OrbInvalidDataException("Unknown ModelType: $value") } @@ -59244,178 +23302,35 @@ private constructor( override fun toString() = value.toString() } - @NoAutoDetect - class DimensionalPriceConfiguration - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - private val dimensionalPriceGroupId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun dimensionValues(): List = dimensionValues.getRequired("dimension_values") - - fun dimensionalPriceGroupId(): String = - dimensionalPriceGroupId.getRequired("dimensional_price_group_id") - - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - fun _dimensionalPriceGroupId(): JsonField = dimensionalPriceGroupId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): DimensionalPriceConfiguration = apply { - if (validated) { - return@apply - } - - dimensionValues() - dimensionalPriceGroupId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DimensionalPriceConfiguration]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var dimensionalPriceGroupId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(dimensionalPriceConfiguration: DimensionalPriceConfiguration) = - apply { - dimensionValues = - dimensionalPriceConfiguration.dimensionValues.map { it.toMutableList() } - dimensionalPriceGroupId = - dimensionalPriceConfiguration.dimensionalPriceGroupId - additionalProperties = - dimensionalPriceConfiguration.additionalProperties.toMutableMap() - } - - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: String) = - dimensionalPriceGroupId(JsonField.of(dimensionalPriceGroupId)) - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: JsonField) = apply { - this.dimensionalPriceGroupId = dimensionalPriceGroupId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): DimensionalPriceConfiguration = - DimensionalPriceConfiguration( - checkRequired("dimensionValues", dimensionValues).map { it.toImmutable() }, - checkRequired("dimensionalPriceGroupId", dimensionalPriceGroupId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DimensionalPriceConfiguration && dimensionValues == other.dimensionValues && dimensionalPriceGroupId == other.dimensionalPriceGroupId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, dimensionalPriceGroupId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DimensionalPriceConfiguration{dimensionValues=$dimensionValues, dimensionalPriceGroupId=$dimensionalPriceGroupId, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is GroupedTieredPackagePrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && groupedTieredPackageConfig == other.groupedTieredPackageConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedWithMeteredMinimumPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && groupedWithMeteredMinimumConfig == other.groupedWithMeteredMinimumConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, groupedTieredPackageConfig, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, groupedWithMeteredMinimumConfig, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "GroupedTieredPackagePrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedTieredPackageConfig=$groupedTieredPackageConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedWithMeteredMinimumPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } @NoAutoDetect - class MaxGroupTieredPackagePrice + class MatrixWithDisplayNamePrice @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("billable_metric") @ExcludeMissing - private val billableMetric: JsonField = JsonMissing.of(), + private val billableMetric: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") @ExcludeMissing - private val billingCycleConfiguration: JsonField = + private val billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing @@ -59428,7 +23343,7 @@ private constructor( private val createdAt: JsonField = JsonMissing.of(), @JsonProperty("credit_allocation") @ExcludeMissing - private val creditAllocation: JsonField = JsonMissing.of(), + private val creditAllocation: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing private val currency: JsonField = JsonMissing.of(), @@ -59443,16 +23358,18 @@ private constructor( private val fixedPriceQuantity: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = + private val invoicingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("item") @ExcludeMissing private val item: JsonField = JsonMissing.of(), - @JsonProperty("max_group_tiered_package_config") + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("matrix_with_display_name_config") @ExcludeMissing - private val maxGroupTieredPackageConfig: JsonField = + private val matrixWithDisplayNameConfig: JsonField = JsonMissing.of(), @JsonProperty("maximum") @ExcludeMissing - private val maximum: JsonField = JsonMissing.of(), + private val maximum: JsonField = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing private val maximumAmount: JsonField = JsonMissing.of(), @@ -59461,7 +23378,7 @@ private constructor( private val metadata: JsonField = JsonMissing.of(), @JsonProperty("minimum") @ExcludeMissing - private val minimum: JsonField = JsonMissing.of(), + private val minimum: JsonField = JsonMissing.of(), @JsonProperty("minimum_amount") @ExcludeMissing private val minimumAmount: JsonField = JsonMissing.of(), @@ -59479,7 +23396,7 @@ private constructor( private val priceType: JsonField = JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing - private val dimensionalPriceConfiguration: JsonField = + private val dimensionalPriceConfiguration: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), @@ -59487,10 +23404,10 @@ private constructor( fun id(): String = id.getRequired("id") - fun billableMetric(): Optional = + fun billableMetric(): Optional = Optional.ofNullable(billableMetric.getNullable("billable_metric")) - fun billingCycleConfiguration(): BillingCycleConfiguration = + fun billingCycleConfiguration(): BillingCycleConfigurationModel = billingCycleConfiguration.getRequired("billing_cycle_configuration") fun cadence(): Cadence = cadence.getRequired("cadence") @@ -59500,7 +23417,7 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - fun creditAllocation(): Optional = + fun creditAllocation(): Optional = Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) fun currency(): String = currency.getRequired("currency") @@ -59513,17 +23430,17 @@ private constructor( fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - fun invoicingCycleConfiguration(): Optional = + fun invoicingCycleConfiguration(): Optional = Optional.ofNullable( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") ) - fun item(): Item = item.getRequired("item") + fun item(): ItemSlimModel = item.getRequired("item") - fun maxGroupTieredPackageConfig(): MaxGroupTieredPackageConfig = - maxGroupTieredPackageConfig.getRequired("max_group_tiered_package_config") + fun matrixWithDisplayNameConfig(): CustomRatingFunctionConfigModel = + matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_config") - fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) @@ -59535,7 +23452,7 @@ private constructor( */ fun metadata(): Metadata = metadata.getRequired("metadata") - fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) fun minimumAmount(): Optional = Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) @@ -59549,7 +23466,7 @@ private constructor( fun priceType(): PriceType = priceType.getRequired("price_type") - fun dimensionalPriceConfiguration(): Optional = + fun dimensionalPriceConfiguration(): Optional = Optional.ofNullable( dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") ) @@ -59558,11 +23475,11 @@ private constructor( @JsonProperty("billable_metric") @ExcludeMissing - fun _billableMetric(): JsonField = billableMetric + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = + fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence @@ -59577,7 +23494,7 @@ private constructor( @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation(): JsonField = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @@ -59593,17 +23510,17 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = + fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @JsonProperty("max_group_tiered_package_config") + @JsonProperty("matrix_with_display_name_config") @ExcludeMissing - fun _maxGroupTieredPackageConfig(): JsonField = - maxGroupTieredPackageConfig + fun _matrixWithDisplayNameConfig(): JsonField = + matrixWithDisplayNameConfig - @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum @JsonProperty("maximum_amount") @ExcludeMissing @@ -59616,7 +23533,7 @@ private constructor( */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum @JsonProperty("minimum_amount") @ExcludeMissing @@ -59638,7 +23555,7 @@ private constructor( @JsonProperty("dimensional_price_configuration") @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = + fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration @JsonAnyGetter @@ -59647,7 +23564,7 @@ private constructor( private var validated: Boolean = false - fun validate(): MaxGroupTieredPackagePrice = apply { + fun validate(): MatrixWithDisplayNamePrice = apply { if (validated) { return@apply } @@ -59665,7 +23582,7 @@ private constructor( fixedPriceQuantity() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() - maxGroupTieredPackageConfig().validate() + matrixWithDisplayNameConfig().validate() maximum().ifPresent { it.validate() } maximumAmount() metadata().validate() @@ -59683,89 +23600,124 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [MatrixWithDisplayNamePrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .matrixWithDisplayNameConfig() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [MaxGroupTieredPackagePrice]. */ + /** A builder for [MatrixWithDisplayNamePrice]. */ class Builder internal constructor() { private var id: JsonField? = null - private var billableMetric: JsonField? = null - private var billingCycleConfiguration: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null private var cadence: JsonField? = null private var conversionRate: JsonField? = null private var createdAt: JsonField? = null - private var creditAllocation: 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 maxGroupTieredPackageConfig: JsonField? = null - private var maximum: 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 minimum: JsonField? = null private var minimumAmount: JsonField? = null private var modelType: JsonField? = null private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null - private var dimensionalPriceConfiguration: JsonField = + private var dimensionalPriceConfiguration: + JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(maxGroupTieredPackagePrice: MaxGroupTieredPackagePrice) = apply { - id = maxGroupTieredPackagePrice.id - billableMetric = maxGroupTieredPackagePrice.billableMetric - billingCycleConfiguration = maxGroupTieredPackagePrice.billingCycleConfiguration - cadence = maxGroupTieredPackagePrice.cadence - conversionRate = maxGroupTieredPackagePrice.conversionRate - createdAt = maxGroupTieredPackagePrice.createdAt - creditAllocation = maxGroupTieredPackagePrice.creditAllocation - currency = maxGroupTieredPackagePrice.currency - discount = maxGroupTieredPackagePrice.discount - externalPriceId = maxGroupTieredPackagePrice.externalPriceId - fixedPriceQuantity = maxGroupTieredPackagePrice.fixedPriceQuantity - invoicingCycleConfiguration = maxGroupTieredPackagePrice.invoicingCycleConfiguration - item = maxGroupTieredPackagePrice.item - maxGroupTieredPackageConfig = maxGroupTieredPackagePrice.maxGroupTieredPackageConfig - maximum = maxGroupTieredPackagePrice.maximum - maximumAmount = maxGroupTieredPackagePrice.maximumAmount - metadata = maxGroupTieredPackagePrice.metadata - minimum = maxGroupTieredPackagePrice.minimum - minimumAmount = maxGroupTieredPackagePrice.minimumAmount - modelType = maxGroupTieredPackagePrice.modelType - name = maxGroupTieredPackagePrice.name - planPhaseOrder = maxGroupTieredPackagePrice.planPhaseOrder - priceType = maxGroupTieredPackagePrice.priceType + internal fun from(matrixWithDisplayNamePrice: MatrixWithDisplayNamePrice) = apply { + id = matrixWithDisplayNamePrice.id + billableMetric = matrixWithDisplayNamePrice.billableMetric + billingCycleConfiguration = matrixWithDisplayNamePrice.billingCycleConfiguration + cadence = matrixWithDisplayNamePrice.cadence + conversionRate = matrixWithDisplayNamePrice.conversionRate + createdAt = matrixWithDisplayNamePrice.createdAt + creditAllocation = matrixWithDisplayNamePrice.creditAllocation + currency = matrixWithDisplayNamePrice.currency + discount = matrixWithDisplayNamePrice.discount + externalPriceId = matrixWithDisplayNamePrice.externalPriceId + fixedPriceQuantity = matrixWithDisplayNamePrice.fixedPriceQuantity + invoicingCycleConfiguration = matrixWithDisplayNamePrice.invoicingCycleConfiguration + item = matrixWithDisplayNamePrice.item + matrixWithDisplayNameConfig = matrixWithDisplayNamePrice.matrixWithDisplayNameConfig + maximum = matrixWithDisplayNamePrice.maximum + maximumAmount = matrixWithDisplayNamePrice.maximumAmount + metadata = matrixWithDisplayNamePrice.metadata + minimum = matrixWithDisplayNamePrice.minimum + minimumAmount = matrixWithDisplayNamePrice.minimumAmount + modelType = matrixWithDisplayNamePrice.modelType + name = matrixWithDisplayNamePrice.name + planPhaseOrder = matrixWithDisplayNamePrice.planPhaseOrder + priceType = matrixWithDisplayNamePrice.priceType dimensionalPriceConfiguration = - maxGroupTieredPackagePrice.dimensionalPriceConfiguration + matrixWithDisplayNamePrice.dimensionalPriceConfiguration additionalProperties = - maxGroupTieredPackagePrice.additionalProperties.toMutableMap() + matrixWithDisplayNamePrice.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric?) = + fun billableMetric(billableMetric: BillableMetricTinyModel?) = billableMetric(JsonField.ofNullable(billableMetric)) - fun billableMetric(billableMetric: Optional) = + fun billableMetric(billableMetric: Optional) = billableMetric(billableMetric.orElse(null)) - fun billableMetric(billableMetric: JsonField) = apply { + fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric } - fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = - billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) fun billingCycleConfiguration( - billingCycleConfiguration: JsonField + billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -59791,13 +23743,13 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation?) = + fun creditAllocation(creditAllocation: AllocationModel?) = creditAllocation(JsonField.ofNullable(creditAllocation)) - fun creditAllocation(creditAllocation: Optional) = + fun creditAllocation(creditAllocation: Optional) = creditAllocation(creditAllocation.orElse(null)) - fun creditAllocation(creditAllocation: JsonField) = apply { + fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation } @@ -59853,34 +23805,34 @@ private constructor( } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? + invoicingCycleConfiguration: BillingCycleConfigurationModel? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional + invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField + invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun item(item: Item) = item(JsonField.of(item)) + fun item(item: ItemSlimModel) = item(JsonField.of(item)) - fun item(item: JsonField) = apply { this.item = item } + fun item(item: JsonField) = apply { this.item = item } - fun maxGroupTieredPackageConfig( - maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig - ) = maxGroupTieredPackageConfig(JsonField.of(maxGroupTieredPackageConfig)) + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: CustomRatingFunctionConfigModel + ) = matrixWithDisplayNameConfig(JsonField.of(matrixWithDisplayNameConfig)) - fun maxGroupTieredPackageConfig( - maxGroupTieredPackageConfig: JsonField - ) = apply { this.maxGroupTieredPackageConfig = maxGroupTieredPackageConfig } + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: JsonField + ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) - fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } fun maximumAmount(maximumAmount: String?) = maximumAmount(JsonField.ofNullable(maximumAmount)) @@ -59906,11 +23858,11 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) - fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } fun minimumAmount(minimumAmount: String?) = minimumAmount(JsonField.ofNullable(minimumAmount)) @@ -59943,393 +23895,69 @@ private constructor( this.planPhaseOrder = planPhaseOrder } - fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) - - fun priceType(priceType: JsonField) = apply { this.priceType = priceType } - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: DimensionalPriceConfiguration? - ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional - ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) - - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField - ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): MaxGroupTieredPackagePrice = - MaxGroupTieredPackagePrice( - checkRequired("id", id), - checkRequired("billableMetric", billableMetric), - checkRequired("billingCycleConfiguration", billingCycleConfiguration), - checkRequired("cadence", cadence), - checkRequired("conversionRate", conversionRate), - 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("maxGroupTieredPackageConfig", maxGroupTieredPackageConfig), - checkRequired("maximum", maximum), - checkRequired("maximumAmount", maximumAmount), - checkRequired("metadata", metadata), - checkRequired("minimum", minimum), - checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("priceType", priceType), - dimensionalPriceConfiguration, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BillableMetric - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillableMetric = apply { - if (validated) { - return@apply - } - - id() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillableMetric]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billableMetric: BillableMetric) = apply { - id = billableMetric.id - additionalProperties = billableMetric.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - 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) - } - - fun build(): BillableMetric = - BillableMetric(checkRequired("id", id), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillableMetric && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillableMetric{id=$id, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) - override fun hashCode() = value.hashCode() + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - override fun toString() = value.toString() + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - override fun hashCode(): Int = hashCode + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + fun build(): MatrixWithDisplayNamePrice = + MatrixWithDisplayNamePrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + 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("matrixWithDisplayNameConfig", matrixWithDisplayNameConfig), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) } class Cadence @JsonCreator private constructor(private val value: JsonField) : @@ -60457,719 +24085,6 @@ private constructor( override fun toString() = value.toString() } - @NoAutoDetect - class CreditAllocation - @JsonCreator - private constructor( - @JsonProperty("allows_rollover") - @ExcludeMissing - private val allowsRollover: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun allowsRollover(): Boolean = allowsRollover.getRequired("allows_rollover") - - fun currency(): String = currency.getRequired("currency") - - @JsonProperty("allows_rollover") - @ExcludeMissing - fun _allowsRollover(): JsonField = allowsRollover - - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CreditAllocation = apply { - if (validated) { - return@apply - } - - allowsRollover() - currency() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CreditAllocation]. */ - class Builder internal constructor() { - - private var allowsRollover: JsonField? = null - private var currency: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(creditAllocation: CreditAllocation) = apply { - allowsRollover = creditAllocation.allowsRollover - currency = creditAllocation.currency - additionalProperties = creditAllocation.additionalProperties.toMutableMap() - } - - fun allowsRollover(allowsRollover: Boolean) = - allowsRollover(JsonField.of(allowsRollover)) - - fun allowsRollover(allowsRollover: JsonField) = apply { - this.allowsRollover = allowsRollover - } - - fun currency(currency: String) = currency(JsonField.of(currency)) - - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): CreditAllocation = - CreditAllocation( - checkRequired("allowsRollover", allowsRollover), - checkRequired("currency", currency), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CreditAllocation && allowsRollover == other.allowsRollover && currency == other.currency && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allowsRollover, currency, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CreditAllocation{allowsRollover=$allowsRollover, currency=$currency, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Item - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun name(): String = name.getRequired("name") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Item = apply { - if (validated) { - return@apply - } - - id() - name() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Item]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(item: Item) = apply { - id = item.id - name = item.name - additionalProperties = item.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun name(name: String) = name(JsonField.of(name)) - - 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) - } - - fun build(): Item = - Item( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Item && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Item{id=$id, name=$name, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class MaxGroupTieredPackageConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MaxGroupTieredPackageConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MaxGroupTieredPackageConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig) = - apply { - additionalProperties = - maxGroupTieredPackageConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): MaxGroupTieredPackageConfig = - MaxGroupTieredPackageConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MaxGroupTieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MaxGroupTieredPackageConfig{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Maximum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Maximum amount applied */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Maximum amount applied */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Maximum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - maximumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Maximum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = maximum.maximumAmount - additionalProperties = maximum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Maximum = - Maximum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("maximumAmount", maximumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Maximum && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, maximumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Maximum{appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, 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 @@ -61201,6 +24116,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } @@ -61256,171 +24172,6 @@ private constructor( override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - @NoAutoDetect - class Minimum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Minimum amount applied */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Minimum amount applied */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Minimum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - minimumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Minimum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var minimumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } - minimumAmount = minimum.minimumAmount - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Minimum = - Minimum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("minimumAmount", minimumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Minimum && appliesToPriceIds == other.appliesToPriceIds && minimumAmount == other.minimumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, minimumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" - } - class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -61436,14 +24187,14 @@ private constructor( companion object { - @JvmField val MAX_GROUP_TIERED_PACKAGE = of("max_group_tiered_package") + @JvmField val MATRIX_WITH_DISPLAY_NAME = of("matrix_with_display_name") @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } /** An enum containing [ModelType]'s known values. */ enum class Known { - MAX_GROUP_TIERED_PACKAGE + MATRIX_WITH_DISPLAY_NAME } /** @@ -61456,7 +24207,7 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - MAX_GROUP_TIERED_PACKAGE, + MATRIX_WITH_DISPLAY_NAME, /** * An enum member indicating that [ModelType] was instantiated with an unknown * value. @@ -61473,7 +24224,7 @@ private constructor( */ fun value(): Value = when (this) { - MAX_GROUP_TIERED_PACKAGE -> Value.MAX_GROUP_TIERED_PACKAGE + MATRIX_WITH_DISPLAY_NAME -> Value.MATRIX_WITH_DISPLAY_NAME else -> Value._UNKNOWN } @@ -61488,7 +24239,7 @@ private constructor( */ fun known(): Known = when (this) { - MAX_GROUP_TIERED_PACKAGE -> Known.MAX_GROUP_TIERED_PACKAGE + MATRIX_WITH_DISPLAY_NAME -> Known.MATRIX_WITH_DISPLAY_NAME else -> throw OrbInvalidDataException("Unknown ModelType: $value") } @@ -61619,178 +24370,39 @@ private constructor( override fun toString() = value.toString() } - @NoAutoDetect - class DimensionalPriceConfiguration - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - private val dimensionalPriceGroupId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun dimensionValues(): List = dimensionValues.getRequired("dimension_values") - - fun dimensionalPriceGroupId(): String = - dimensionalPriceGroupId.getRequired("dimensional_price_group_id") - - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - fun _dimensionalPriceGroupId(): JsonField = dimensionalPriceGroupId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): DimensionalPriceConfiguration = apply { - if (validated) { - return@apply - } - - dimensionValues() - dimensionalPriceGroupId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DimensionalPriceConfiguration]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var dimensionalPriceGroupId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(dimensionalPriceConfiguration: DimensionalPriceConfiguration) = - apply { - dimensionValues = - dimensionalPriceConfiguration.dimensionValues.map { it.toMutableList() } - dimensionalPriceGroupId = - dimensionalPriceConfiguration.dimensionalPriceGroupId - additionalProperties = - dimensionalPriceConfiguration.additionalProperties.toMutableMap() - } - - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: String) = - dimensionalPriceGroupId(JsonField.of(dimensionalPriceGroupId)) - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: JsonField) = apply { - this.dimensionalPriceGroupId = dimensionalPriceGroupId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): DimensionalPriceConfiguration = - DimensionalPriceConfiguration( - checkRequired("dimensionValues", dimensionValues).map { it.toImmutable() }, - checkRequired("dimensionalPriceGroupId", dimensionalPriceGroupId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DimensionalPriceConfiguration && dimensionValues == other.dimensionValues && dimensionalPriceGroupId == other.dimensionalPriceGroupId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, dimensionalPriceGroupId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DimensionalPriceConfiguration{dimensionValues=$dimensionValues, dimensionalPriceGroupId=$dimensionalPriceGroupId, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is MaxGroupTieredPackagePrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maxGroupTieredPackageConfig == other.maxGroupTieredPackageConfig && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MatrixWithDisplayNamePrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && matrixWithDisplayNameConfig == other.matrixWithDisplayNameConfig && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maxGroupTieredPackageConfig, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, matrixWithDisplayNameConfig, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "MaxGroupTieredPackagePrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "MatrixWithDisplayNamePrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } @NoAutoDetect - class ScalableMatrixWithUnitPricingPrice + class BulkWithProrationPrice @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("billable_metric") @ExcludeMissing - private val billableMetric: JsonField = JsonMissing.of(), + private val billableMetric: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") @ExcludeMissing - private val billingCycleConfiguration: JsonField = + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("bulk_with_proration_config") + @ExcludeMissing + private val bulkWithProrationConfig: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing @@ -61803,7 +24415,7 @@ private constructor( private val createdAt: JsonField = JsonMissing.of(), @JsonProperty("credit_allocation") @ExcludeMissing - private val creditAllocation: JsonField = JsonMissing.of(), + private val creditAllocation: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing private val currency: JsonField = JsonMissing.of(), @@ -61818,12 +24430,14 @@ private constructor( private val fixedPriceQuantity: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = + private val invoicingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("item") @ExcludeMissing private val item: JsonField = JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), @JsonProperty("maximum") @ExcludeMissing - private val maximum: JsonField = JsonMissing.of(), + private val maximum: JsonField = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing private val maximumAmount: JsonField = JsonMissing.of(), @@ -61832,7 +24446,7 @@ private constructor( private val metadata: JsonField = JsonMissing.of(), @JsonProperty("minimum") @ExcludeMissing - private val minimum: JsonField = JsonMissing.of(), + private val minimum: JsonField = JsonMissing.of(), @JsonProperty("minimum_amount") @ExcludeMissing private val minimumAmount: JsonField = JsonMissing.of(), @@ -61848,14 +24462,9 @@ private constructor( @JsonProperty("price_type") @ExcludeMissing private val priceType: JsonField = JsonMissing.of(), - @JsonProperty("scalable_matrix_with_unit_pricing_config") - @ExcludeMissing - private val scalableMatrixWithUnitPricingConfig: - JsonField = - JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing - private val dimensionalPriceConfiguration: JsonField = + private val dimensionalPriceConfiguration: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), @@ -61863,12 +24472,15 @@ private constructor( fun id(): String = id.getRequired("id") - fun billableMetric(): Optional = + fun billableMetric(): Optional = Optional.ofNullable(billableMetric.getNullable("billable_metric")) - fun billingCycleConfiguration(): BillingCycleConfiguration = + fun billingCycleConfiguration(): BillingCycleConfigurationModel = billingCycleConfiguration.getRequired("billing_cycle_configuration") + fun bulkWithProrationConfig(): CustomRatingFunctionConfigModel = + bulkWithProrationConfig.getRequired("bulk_with_proration_config") + fun cadence(): Cadence = cadence.getRequired("cadence") fun conversionRate(): Optional = @@ -61876,7 +24488,7 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - fun creditAllocation(): Optional = + fun creditAllocation(): Optional = Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) fun currency(): String = currency.getRequired("currency") @@ -61889,14 +24501,14 @@ private constructor( fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - fun invoicingCycleConfiguration(): Optional = + fun invoicingCycleConfiguration(): Optional = Optional.ofNullable( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") ) - fun item(): Item = item.getRequired("item") + fun item(): ItemSlimModel = item.getRequired("item") - fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) @@ -61908,7 +24520,7 @@ private constructor( */ fun metadata(): Metadata = metadata.getRequired("metadata") - fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) fun minimumAmount(): Optional = Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) @@ -61922,12 +24534,7 @@ private constructor( fun priceType(): PriceType = priceType.getRequired("price_type") - fun scalableMatrixWithUnitPricingConfig(): ScalableMatrixWithUnitPricingConfig = - scalableMatrixWithUnitPricingConfig.getRequired( - "scalable_matrix_with_unit_pricing_config" - ) - - fun dimensionalPriceConfiguration(): Optional = + fun dimensionalPriceConfiguration(): Optional = Optional.ofNullable( dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") ) @@ -61936,13 +24543,18 @@ private constructor( @JsonProperty("billable_metric") @ExcludeMissing - fun _billableMetric(): JsonField = billableMetric + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = + fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration + @JsonProperty("bulk_with_proration_config") + @ExcludeMissing + fun _bulkWithProrationConfig(): JsonField = + bulkWithProrationConfig + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence @JsonProperty("conversion_rate") @@ -61955,7 +24567,7 @@ private constructor( @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation(): JsonField = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @@ -61971,12 +24583,12 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = + fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum @JsonProperty("maximum_amount") @ExcludeMissing @@ -61989,7 +24601,7 @@ private constructor( */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum @JsonProperty("minimum_amount") @ExcludeMissing @@ -62009,14 +24621,9 @@ private constructor( @ExcludeMissing fun _priceType(): JsonField = priceType - @JsonProperty("scalable_matrix_with_unit_pricing_config") - @ExcludeMissing - fun _scalableMatrixWithUnitPricingConfig(): JsonField = - scalableMatrixWithUnitPricingConfig - @JsonProperty("dimensional_price_configuration") @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = + fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration @JsonAnyGetter @@ -62025,7 +24632,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ScalableMatrixWithUnitPricingPrice = apply { + fun validate(): BulkWithProrationPrice = apply { if (validated) { return@apply } @@ -62033,6 +24640,7 @@ private constructor( id() billableMetric().ifPresent { it.validate() } billingCycleConfiguration().validate() + bulkWithProrationConfig().validate() cadence() conversionRate() createdAt() @@ -62052,7 +24660,6 @@ private constructor( name() planPhaseOrder() priceType() - scalableMatrixWithUnitPricingConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } validated = true } @@ -62061,98 +24668,129 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [BulkWithProrationPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .bulkWithProrationConfig() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [ScalableMatrixWithUnitPricingPrice]. */ + /** A builder for [BulkWithProrationPrice]. */ class Builder internal constructor() { private var id: JsonField? = null - private var billableMetric: JsonField? = null - private var billingCycleConfiguration: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var bulkWithProrationConfig: JsonField? = null private var cadence: JsonField? = null private var conversionRate: JsonField? = null private var createdAt: JsonField? = null - private var creditAllocation: 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 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 minimum: JsonField? = null private var minimumAmount: JsonField? = null private var modelType: JsonField? = null private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null - private var scalableMatrixWithUnitPricingConfig: - JsonField? = - null - private var dimensionalPriceConfiguration: JsonField = + private var dimensionalPriceConfiguration: + JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - scalableMatrixWithUnitPricingPrice: ScalableMatrixWithUnitPricingPrice - ) = apply { - id = scalableMatrixWithUnitPricingPrice.id - billableMetric = scalableMatrixWithUnitPricingPrice.billableMetric - billingCycleConfiguration = - scalableMatrixWithUnitPricingPrice.billingCycleConfiguration - cadence = scalableMatrixWithUnitPricingPrice.cadence - conversionRate = scalableMatrixWithUnitPricingPrice.conversionRate - createdAt = scalableMatrixWithUnitPricingPrice.createdAt - creditAllocation = scalableMatrixWithUnitPricingPrice.creditAllocation - currency = scalableMatrixWithUnitPricingPrice.currency - discount = scalableMatrixWithUnitPricingPrice.discount - externalPriceId = scalableMatrixWithUnitPricingPrice.externalPriceId - fixedPriceQuantity = scalableMatrixWithUnitPricingPrice.fixedPriceQuantity - invoicingCycleConfiguration = - scalableMatrixWithUnitPricingPrice.invoicingCycleConfiguration - item = scalableMatrixWithUnitPricingPrice.item - maximum = scalableMatrixWithUnitPricingPrice.maximum - maximumAmount = scalableMatrixWithUnitPricingPrice.maximumAmount - metadata = scalableMatrixWithUnitPricingPrice.metadata - minimum = scalableMatrixWithUnitPricingPrice.minimum - minimumAmount = scalableMatrixWithUnitPricingPrice.minimumAmount - modelType = scalableMatrixWithUnitPricingPrice.modelType - name = scalableMatrixWithUnitPricingPrice.name - planPhaseOrder = scalableMatrixWithUnitPricingPrice.planPhaseOrder - priceType = scalableMatrixWithUnitPricingPrice.priceType - scalableMatrixWithUnitPricingConfig = - scalableMatrixWithUnitPricingPrice.scalableMatrixWithUnitPricingConfig - dimensionalPriceConfiguration = - scalableMatrixWithUnitPricingPrice.dimensionalPriceConfiguration - additionalProperties = - scalableMatrixWithUnitPricingPrice.additionalProperties.toMutableMap() + internal fun from(bulkWithProrationPrice: BulkWithProrationPrice) = apply { + id = bulkWithProrationPrice.id + billableMetric = bulkWithProrationPrice.billableMetric + billingCycleConfiguration = bulkWithProrationPrice.billingCycleConfiguration + bulkWithProrationConfig = bulkWithProrationPrice.bulkWithProrationConfig + cadence = bulkWithProrationPrice.cadence + conversionRate = bulkWithProrationPrice.conversionRate + createdAt = bulkWithProrationPrice.createdAt + creditAllocation = bulkWithProrationPrice.creditAllocation + currency = bulkWithProrationPrice.currency + discount = bulkWithProrationPrice.discount + externalPriceId = bulkWithProrationPrice.externalPriceId + fixedPriceQuantity = bulkWithProrationPrice.fixedPriceQuantity + invoicingCycleConfiguration = bulkWithProrationPrice.invoicingCycleConfiguration + item = bulkWithProrationPrice.item + maximum = bulkWithProrationPrice.maximum + maximumAmount = bulkWithProrationPrice.maximumAmount + metadata = bulkWithProrationPrice.metadata + minimum = bulkWithProrationPrice.minimum + minimumAmount = bulkWithProrationPrice.minimumAmount + modelType = bulkWithProrationPrice.modelType + name = bulkWithProrationPrice.name + planPhaseOrder = bulkWithProrationPrice.planPhaseOrder + priceType = bulkWithProrationPrice.priceType + dimensionalPriceConfiguration = bulkWithProrationPrice.dimensionalPriceConfiguration + additionalProperties = bulkWithProrationPrice.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric?) = + fun billableMetric(billableMetric: BillableMetricTinyModel?) = billableMetric(JsonField.ofNullable(billableMetric)) - fun billableMetric(billableMetric: Optional) = + fun billableMetric(billableMetric: Optional) = billableMetric(billableMetric.orElse(null)) - fun billableMetric(billableMetric: JsonField) = apply { + fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric } - fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = - billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) fun billingCycleConfiguration( - billingCycleConfiguration: JsonField + billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + fun bulkWithProrationConfig(bulkWithProrationConfig: CustomRatingFunctionConfigModel) = + bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) + + fun bulkWithProrationConfig( + bulkWithProrationConfig: JsonField + ) = apply { this.bulkWithProrationConfig = bulkWithProrationConfig } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) fun cadence(cadence: JsonField) = apply { this.cadence = cadence } @@ -62176,13 +24814,13 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation?) = + fun creditAllocation(creditAllocation: AllocationModel?) = creditAllocation(JsonField.ofNullable(creditAllocation)) - fun creditAllocation(creditAllocation: Optional) = + fun creditAllocation(creditAllocation: Optional) = creditAllocation(creditAllocation.orElse(null)) - fun creditAllocation(creditAllocation: JsonField) = apply { + fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation } @@ -62238,26 +24876,26 @@ private constructor( } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? + invoicingCycleConfiguration: BillingCycleConfigurationModel? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional + invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField + invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun item(item: Item) = item(JsonField.of(item)) + fun item(item: ItemSlimModel) = item(JsonField.of(item)) - fun item(item: JsonField) = apply { this.item = item } + fun item(item: JsonField) = apply { this.item = item } - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) - fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } fun maximumAmount(maximumAmount: String?) = maximumAmount(JsonField.ofNullable(maximumAmount)) @@ -62283,11 +24921,11 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) - fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } fun minimumAmount(minimumAmount: String?) = minimumAmount(JsonField.ofNullable(minimumAmount)) @@ -62324,29 +24962,16 @@ private constructor( fun priceType(priceType: JsonField) = apply { this.priceType = priceType } - fun scalableMatrixWithUnitPricingConfig( - scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig - ) = - scalableMatrixWithUnitPricingConfig( - JsonField.of(scalableMatrixWithUnitPricingConfig) - ) - - fun scalableMatrixWithUnitPricingConfig( - scalableMatrixWithUnitPricingConfig: JsonField - ) = apply { - this.scalableMatrixWithUnitPricingConfig = scalableMatrixWithUnitPricingConfig - } - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: DimensionalPriceConfiguration? + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional + dimensionalPriceConfiguration: Optional ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField + dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } fun additionalProperties(additionalProperties: Map) = apply { @@ -62368,11 +24993,12 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): ScalableMatrixWithUnitPricingPrice = - ScalableMatrixWithUnitPricingPrice( + fun build(): BulkWithProrationPrice = + BulkWithProrationPrice( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("bulkWithProrationConfig", bulkWithProrationConfig), checkRequired("cadence", cadence), checkRequired("conversionRate", conversionRate), checkRequired("createdAt", createdAt), @@ -62392,149 +25018,160 @@ private constructor( checkRequired("name", name), checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), - checkRequired( - "scalableMatrixWithUnitPricingConfig", - scalableMatrixWithUnitPricingConfig, - ), dimensionalPriceConfiguration, additionalProperties.toImmutable(), ) } - @NoAutoDetect - class BillableMetric - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillableMetric = apply { - if (validated) { - return@apply - } - - id() - validated = true - } + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { - fun toBuilder() = Builder().from(this) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { - @JvmStatic fun builder() = Builder() - } + @JvmField val ONE_TIME = of("one_time") - /** A builder for [BillableMetric]. */ - class Builder internal constructor() { + @JvmField val MONTHLY = of("monthly") - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + @JvmField val QUARTERLY = of("quarterly") - @JvmSynthetic - internal fun from(billableMetric: BillableMetric) = apply { - id = billableMetric.id - additionalProperties = billableMetric.additionalProperties.toMutableMap() - } + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun id(id: String) = id(JsonField.of(id)) + @JvmField val ANNUAL = of("annual") - fun id(id: JsonField) = apply { this.id = id } + @JvmField val CUSTOM = of("custom") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown value. + */ + _UNKNOWN, + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + 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 removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + 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 build(): BillableMetric = - BillableMetric(checkRequired("id", id), additionalProperties.toImmutable()) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is BillableMetric && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "BillableMetric{id=$id, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ @NoAutoDetect - class BillingCycleConfiguration + class Metadata @JsonCreator private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties private var validated: Boolean = false - fun validate(): BillingCycleConfiguration = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } - duration() - durationUnit() validated = true } @@ -62542,33 +25179,18 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [BillingCycleConfiguration]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { - private var duration: JsonField? = null - private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -62593,139 +25215,123 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } - class DurationUnit - @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 /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } - companion object { + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - @JvmField val DAY = of("day") + override fun hashCode(): Int = hashCode - @JvmField val MONTH = of("month") + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the 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 enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + companion object { - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.MONTH - else -> Value._UNKNOWN - } + @JvmField val BULK_WITH_PRORATION = of("bulk_with_proration") - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + BULK_WITH_PRORATION + } + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + BULK_WITH_PRORATION, /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method 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 [ModelType] was instantiated with an unknown + * value. */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + _UNKNOWN, + } - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + BULK_WITH_PRORATION -> Value.BULK_WITH_PRORATION + else -> Value._UNKNOWN } - override fun hashCode() = value.hashCode() + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + BULK_WITH_PRORATION -> Known.BULK_WITH_PRORATION + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } - override fun toString() = value.toString() - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if 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 } - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } - class Cadence @JsonCreator private constructor(private val value: JsonField) : + class PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -62740,49 +25346,34 @@ private constructor( companion object { - @JvmField val ONE_TIME = of("one_time") - - @JvmField val MONTHLY = of("monthly") - - @JvmField val QUARTERLY = of("quarterly") - - @JvmField val SEMI_ANNUAL = of("semi_annual") - - @JvmField val ANNUAL = of("annual") + @JvmField val USAGE_PRICE = of("usage_price") - @JvmField val CUSTOM = of("custom") + @JvmField val FIXED_PRICE = of("fixed_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, } /** - * 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, /** - * 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, } @@ -62796,686 +25387,832 @@ 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 else -> Value._UNKNOWN } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to 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 an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BulkWithProrationPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && bulkWithProrationConfig == other.bulkWithProrationConfig && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, bulkWithProrationConfig, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithProrationPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class GroupedTieredPackagePrice + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + private val billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + private val creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("grouped_tiered_package_config") + @ExcludeMissing + private val groupedTieredPackageConfig: JsonField = + JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + private val dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + fun billableMetric(): Optional = + Optional.ofNullable(billableMetric.getNullable("billable_metric")) + + fun billingCycleConfiguration(): BillingCycleConfigurationModel = + billingCycleConfiguration.getRequired("billing_cycle_configuration") + + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun creditAllocation(): Optional = + Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } + fun currency(): String = currency.getRequired("currency") - override fun hashCode() = value.hashCode() + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) - override fun toString() = value.toString() - } + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - @NoAutoDetect - class CreditAllocation - @JsonCreator - private constructor( - @JsonProperty("allows_rollover") - @ExcludeMissing - private val allowsRollover: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - fun allowsRollover(): Boolean = allowsRollover.getRequired("allows_rollover") + fun groupedTieredPackageConfig(): CustomRatingFunctionConfigModel = + groupedTieredPackageConfig.getRequired("grouped_tiered_package_config") - fun currency(): String = currency.getRequired("currency") + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) - @JsonProperty("allows_rollover") - @ExcludeMissing - fun _allowsRollover(): JsonField = allowsRollover + fun item(): ItemSlimModel = item.getRequired("item") - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - private var validated: Boolean = false + /** + * 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.getRequired("metadata") - fun validate(): CreditAllocation = apply { - if (validated) { - return@apply - } + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) - allowsRollover() - currency() - validated = true - } + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) - fun toBuilder() = Builder().from(this) + fun modelType(): ModelType = modelType.getRequired("model_type") - companion object { + fun name(): String = name.getRequired("name") - @JvmStatic fun builder() = Builder() - } + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - /** A builder for [CreditAllocation]. */ - class Builder internal constructor() { + fun priceType(): PriceType = priceType.getRequired("price_type") - private var allowsRollover: JsonField? = null - private var currency: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun dimensionalPriceConfiguration(): Optional = + Optional.ofNullable( + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + ) - @JvmSynthetic - internal fun from(creditAllocation: CreditAllocation) = apply { - allowsRollover = creditAllocation.allowsRollover - currency = creditAllocation.currency - additionalProperties = creditAllocation.additionalProperties.toMutableMap() - } + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - fun allowsRollover(allowsRollover: Boolean) = - allowsRollover(JsonField.of(allowsRollover)) + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric - fun allowsRollover(allowsRollover: JsonField) = apply { - this.allowsRollover = allowsRollover - } + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - fun currency(currency: String) = currency(JsonField.of(currency)) + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - fun currency(currency: JsonField) = apply { this.currency = currency } + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun build(): CreditAllocation = - CreditAllocation( - checkRequired("allowsRollover", allowsRollover), - checkRequired("currency", currency), - additionalProperties.toImmutable(), - ) - } + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JsonProperty("grouped_tiered_package_config") + @ExcludeMissing + fun _groupedTieredPackageConfig(): JsonField = + groupedTieredPackageConfig - return /* spotless:off */ other is CreditAllocation && allowsRollover == other.allowsRollover && currency == other.currency && additionalProperties == other.additionalProperties /* spotless:on */ - } + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allowsRollover, currency, additionalProperties) } - /* spotless:on */ + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - override fun hashCode(): Int = hashCode + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - override fun toString() = - "CreditAllocation{allowsRollover=$allowsRollover, currency=$currency, additionalProperties=$additionalProperties}" - } + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + /** + * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - fun duration(): Long = duration.getRequired("duration") + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - private var validated: Boolean = false + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - duration() - durationUnit() - validated = true + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): GroupedTieredPackagePrice = apply { + if (validated) { + return@apply } - fun toBuilder() = Builder().from(this) + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + cadence() + conversionRate() + createdAt() + creditAllocation().ifPresent { it.validate() } + currency() + discount().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + groupedTieredPackageConfig().validate() + invoicingCycleConfiguration().ifPresent { it.validate() } + item().validate() + maximum().ifPresent { it.validate() } + maximumAmount() + metadata().validate() + minimum().ifPresent { it.validate() } + minimumAmount() + modelType() + name() + planPhaseOrder() + priceType() + dimensionalPriceConfiguration().ifPresent { it.validate() } + validated = true + } - companion object { + fun toBuilder() = Builder().from(this) - @JvmStatic fun builder() = Builder() + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedTieredPackagePrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .groupedTieredPackageConfig() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedTieredPackagePrice]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var 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 groupedTieredPackageConfig: 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: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedTieredPackagePrice: GroupedTieredPackagePrice) = apply { + id = groupedTieredPackagePrice.id + billableMetric = groupedTieredPackagePrice.billableMetric + billingCycleConfiguration = groupedTieredPackagePrice.billingCycleConfiguration + cadence = groupedTieredPackagePrice.cadence + conversionRate = groupedTieredPackagePrice.conversionRate + createdAt = groupedTieredPackagePrice.createdAt + creditAllocation = groupedTieredPackagePrice.creditAllocation + currency = groupedTieredPackagePrice.currency + discount = groupedTieredPackagePrice.discount + externalPriceId = groupedTieredPackagePrice.externalPriceId + fixedPriceQuantity = groupedTieredPackagePrice.fixedPriceQuantity + groupedTieredPackageConfig = groupedTieredPackagePrice.groupedTieredPackageConfig + invoicingCycleConfiguration = groupedTieredPackagePrice.invoicingCycleConfiguration + item = groupedTieredPackagePrice.item + maximum = groupedTieredPackagePrice.maximum + maximumAmount = groupedTieredPackagePrice.maximumAmount + metadata = groupedTieredPackagePrice.metadata + minimum = groupedTieredPackagePrice.minimum + minimumAmount = groupedTieredPackagePrice.minimumAmount + modelType = groupedTieredPackagePrice.modelType + name = groupedTieredPackagePrice.name + planPhaseOrder = groupedTieredPackagePrice.planPhaseOrder + priceType = groupedTieredPackagePrice.priceType + dimensionalPriceConfiguration = + groupedTieredPackagePrice.dimensionalPriceConfiguration + additionalProperties = groupedTieredPackagePrice.additionalProperties.toMutableMap() } - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { + fun id(id: String) = id(JsonField.of(id)) - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun id(id: JsonField) = apply { this.id = id } - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } + fun billableMetric(billableMetric: BillableMetricTinyModel?) = + billableMetric(JsonField.ofNullable(billableMetric)) - fun duration(duration: Long) = duration(JsonField.of(duration)) + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) - fun duration(duration: JsonField) = apply { this.duration = duration } + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) - fun build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the 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 createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } - companion object { + fun creditAllocation(creditAllocation: AllocationModel?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) - @JvmField val DAY = of("day") + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) - @JvmField val MONTH = of("month") + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } + fun currency(currency: String) = currency(JsonField.of(currency)) - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } + fun currency(currency: JsonField) = apply { this.currency = currency } - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.MONTH - else -> Value._UNKNOWN - } + fun discount(discount: Optional) = discount(discount.orElse(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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } + fun discount(discount: JsonField) = apply { this.discount = discount } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) + + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) + + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - override fun hashCode() = value.hashCode() + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) - override fun toString() = value.toString() + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ + fun groupedTieredPackageConfig( + groupedTieredPackageConfig: CustomRatingFunctionConfigModel + ) = groupedTieredPackageConfig(JsonField.of(groupedTieredPackageConfig)) - override fun hashCode(): Int = hashCode + fun groupedTieredPackageConfig( + groupedTieredPackageConfig: JsonField + ) = apply { this.groupedTieredPackageConfig = groupedTieredPackageConfig } - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - @NoAutoDetect - class Item - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) - fun id(): String = id.getRequired("id") + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun name(): String = name.getRequired("name") + fun item(item: ItemSlimModel) = item(JsonField.of(item)) - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + fun item(item: JsonField) = apply { this.item = item } - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - private var validated: Boolean = false + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - fun validate(): Item = apply { - if (validated) { - return@apply - } + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) - id() - name() - validated = true + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) + + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount } - fun toBuilder() = Builder().from(this) + /** + * 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)) - companion object { + /** + * 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: JsonField) = apply { this.metadata = metadata } - @JvmStatic fun builder() = Builder() + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount } - /** A builder for [Item]. */ - class Builder internal constructor() { + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } - @JvmSynthetic - internal fun from(item: Item) = apply { - id = item.id - name = item.name - additionalProperties = item.additionalProperties.toMutableMap() - } + fun name(name: String) = name(JsonField.of(name)) - fun id(id: String) = id(JsonField.of(id)) + fun name(name: JsonField) = apply { this.name = name } - fun id(id: JsonField) = apply { this.id = id } + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - fun name(name: String) = name(JsonField.of(name)) + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - fun name(name: JsonField) = apply { this.name = name } + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun build(): Item = - Item( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toImmutable(), - ) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Item && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - /* spotless:on */ + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - override fun hashCode(): Int = hashCode + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun toString() = - "Item{id=$id, name=$name, additionalProperties=$additionalProperties}" + fun build(): GroupedTieredPackagePrice = + GroupedTieredPackagePrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("groupedTieredPackageConfig", groupedTieredPackageConfig), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) } - @NoAutoDetect - class Maximum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Maximum amount applied */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** Maximum amount applied */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount + companion object { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + @JvmField val ONE_TIME = of("one_time") - private var validated: Boolean = false + @JvmField val MONTHLY = of("monthly") - fun validate(): Maximum = apply { - if (validated) { - return@apply - } + @JvmField val QUARTERLY = of("quarterly") - appliesToPriceIds() - maximumAmount() - validated = true - } + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun toBuilder() = Builder().from(this) + @JvmField val ANNUAL = of("annual") - companion object { + @JvmField val CUSTOM = of("custom") - @JvmStatic fun builder() = Builder() + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) } - /** A builder for [Maximum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = maximum.maximumAmount - additionalProperties = maximum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } + /** 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, /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. + * An enum member indicating that [Cadence] was instantiated with an unknown value. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + _UNKNOWN, + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + 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 removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + 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 build(): Maximum = - Maximum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("maximumAmount", maximumAmount), - additionalProperties.toImmutable(), - ) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Maximum && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, maximumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "Maximum{appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } /** @@ -63509,6 +26246,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } @@ -63564,171 +26302,6 @@ private constructor( override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - @NoAutoDetect - class Minimum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Minimum amount applied */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Minimum amount applied */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Minimum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - minimumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Minimum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var minimumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } - minimumAmount = minimum.minimumAmount - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Minimum = - Minimum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("minimumAmount", minimumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Minimum && appliesToPriceIds == other.appliesToPriceIds && minimumAmount == other.minimumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, minimumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" - } - class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -63744,15 +26317,14 @@ private constructor( companion object { - @JvmField - val SCALABLE_MATRIX_WITH_UNIT_PRICING = of("scalable_matrix_with_unit_pricing") + @JvmField val GROUPED_TIERED_PACKAGE = of("grouped_tiered_package") @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } /** An enum containing [ModelType]'s known values. */ enum class Known { - SCALABLE_MATRIX_WITH_UNIT_PRICING + GROUPED_TIERED_PACKAGE } /** @@ -63765,7 +26337,7 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - SCALABLE_MATRIX_WITH_UNIT_PRICING, + GROUPED_TIERED_PACKAGE, /** * An enum member indicating that [ModelType] was instantiated with an unknown * value. @@ -63782,7 +26354,7 @@ private constructor( */ fun value(): Value = when (this) { - SCALABLE_MATRIX_WITH_UNIT_PRICING -> Value.SCALABLE_MATRIX_WITH_UNIT_PRICING + GROUPED_TIERED_PACKAGE -> Value.GROUPED_TIERED_PACKAGE else -> Value._UNKNOWN } @@ -63797,7 +26369,7 @@ private constructor( */ fun known(): Known = when (this) { - SCALABLE_MATRIX_WITH_UNIT_PRICING -> Known.SCALABLE_MATRIX_WITH_UNIT_PRICING + GROUPED_TIERED_PACKAGE -> Known.GROUPED_TIERED_PACKAGE else -> throw OrbInvalidDataException("Unknown ModelType: $value") } @@ -63928,264 +26500,35 @@ private constructor( override fun toString() = value.toString() } - @NoAutoDetect - class ScalableMatrixWithUnitPricingConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): ScalableMatrixWithUnitPricingConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ScalableMatrixWithUnitPricingConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig - ) = apply { - additionalProperties = - scalableMatrixWithUnitPricingConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): ScalableMatrixWithUnitPricingConfig = - ScalableMatrixWithUnitPricingConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ScalableMatrixWithUnitPricingConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ScalableMatrixWithUnitPricingConfig{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class DimensionalPriceConfiguration - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - private val dimensionalPriceGroupId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun dimensionValues(): List = dimensionValues.getRequired("dimension_values") - - fun dimensionalPriceGroupId(): String = - dimensionalPriceGroupId.getRequired("dimensional_price_group_id") - - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - fun _dimensionalPriceGroupId(): JsonField = dimensionalPriceGroupId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): DimensionalPriceConfiguration = apply { - if (validated) { - return@apply - } - - dimensionValues() - dimensionalPriceGroupId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DimensionalPriceConfiguration]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var dimensionalPriceGroupId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(dimensionalPriceConfiguration: DimensionalPriceConfiguration) = - apply { - dimensionValues = - dimensionalPriceConfiguration.dimensionValues.map { it.toMutableList() } - dimensionalPriceGroupId = - dimensionalPriceConfiguration.dimensionalPriceGroupId - additionalProperties = - dimensionalPriceConfiguration.additionalProperties.toMutableMap() - } - - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: String) = - dimensionalPriceGroupId(JsonField.of(dimensionalPriceGroupId)) - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: JsonField) = apply { - this.dimensionalPriceGroupId = dimensionalPriceGroupId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): DimensionalPriceConfiguration = - DimensionalPriceConfiguration( - checkRequired("dimensionValues", dimensionValues).map { it.toImmutable() }, - checkRequired("dimensionalPriceGroupId", dimensionalPriceGroupId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DimensionalPriceConfiguration && dimensionValues == other.dimensionValues && dimensionalPriceGroupId == other.dimensionalPriceGroupId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, dimensionalPriceGroupId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DimensionalPriceConfiguration{dimensionValues=$dimensionValues, dimensionalPriceGroupId=$dimensionalPriceGroupId, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ScalableMatrixWithUnitPricingPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && scalableMatrixWithUnitPricingConfig == other.scalableMatrixWithUnitPricingConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedTieredPackagePrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && groupedTieredPackageConfig == other.groupedTieredPackageConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, groupedTieredPackageConfig, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "ScalableMatrixWithUnitPricingPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedTieredPackagePrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedTieredPackageConfig=$groupedTieredPackageConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } @NoAutoDetect - class ScalableMatrixWithTieredPricingPrice + class MaxGroupTieredPackagePrice @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("billable_metric") @ExcludeMissing - private val billableMetric: JsonField = JsonMissing.of(), + private val billableMetric: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") @ExcludeMissing - private val billingCycleConfiguration: JsonField = + private val billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing @@ -64198,7 +26541,7 @@ private constructor( private val createdAt: JsonField = JsonMissing.of(), @JsonProperty("credit_allocation") @ExcludeMissing - private val creditAllocation: JsonField = JsonMissing.of(), + private val creditAllocation: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing private val currency: JsonField = JsonMissing.of(), @@ -64213,12 +26556,18 @@ private constructor( private val fixedPriceQuantity: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("max_group_tiered_package_config") + @ExcludeMissing + private val maxGroupTieredPackageConfig: JsonField = JsonMissing.of(), - @JsonProperty("item") @ExcludeMissing private val item: JsonField = JsonMissing.of(), @JsonProperty("maximum") @ExcludeMissing - private val maximum: JsonField = JsonMissing.of(), + private val maximum: JsonField = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing private val maximumAmount: JsonField = JsonMissing.of(), @@ -64227,7 +26576,7 @@ private constructor( private val metadata: JsonField = JsonMissing.of(), @JsonProperty("minimum") @ExcludeMissing - private val minimum: JsonField = JsonMissing.of(), + private val minimum: JsonField = JsonMissing.of(), @JsonProperty("minimum_amount") @ExcludeMissing private val minimumAmount: JsonField = JsonMissing.of(), @@ -64243,14 +26592,9 @@ private constructor( @JsonProperty("price_type") @ExcludeMissing private val priceType: JsonField = JsonMissing.of(), - @JsonProperty("scalable_matrix_with_tiered_pricing_config") - @ExcludeMissing - private val scalableMatrixWithTieredPricingConfig: - JsonField = - JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing - private val dimensionalPriceConfiguration: JsonField = + private val dimensionalPriceConfiguration: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), @@ -64258,10 +26602,10 @@ private constructor( fun id(): String = id.getRequired("id") - fun billableMetric(): Optional = + fun billableMetric(): Optional = Optional.ofNullable(billableMetric.getNullable("billable_metric")) - fun billingCycleConfiguration(): BillingCycleConfiguration = + fun billingCycleConfiguration(): BillingCycleConfigurationModel = billingCycleConfiguration.getRequired("billing_cycle_configuration") fun cadence(): Cadence = cadence.getRequired("cadence") @@ -64271,7 +26615,7 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - fun creditAllocation(): Optional = + fun creditAllocation(): Optional = Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) fun currency(): String = currency.getRequired("currency") @@ -64284,14 +26628,17 @@ private constructor( fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - fun invoicingCycleConfiguration(): Optional = + fun invoicingCycleConfiguration(): Optional = Optional.ofNullable( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") ) - fun item(): Item = item.getRequired("item") + fun item(): ItemSlimModel = item.getRequired("item") + + fun maxGroupTieredPackageConfig(): CustomRatingFunctionConfigModel = + maxGroupTieredPackageConfig.getRequired("max_group_tiered_package_config") - fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) @@ -64303,7 +26650,7 @@ private constructor( */ fun metadata(): Metadata = metadata.getRequired("metadata") - fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) fun minimumAmount(): Optional = Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) @@ -64317,12 +26664,7 @@ private constructor( fun priceType(): PriceType = priceType.getRequired("price_type") - fun scalableMatrixWithTieredPricingConfig(): ScalableMatrixWithTieredPricingConfig = - scalableMatrixWithTieredPricingConfig.getRequired( - "scalable_matrix_with_tiered_pricing_config" - ) - - fun dimensionalPriceConfiguration(): Optional = + fun dimensionalPriceConfiguration(): Optional = Optional.ofNullable( dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") ) @@ -64331,11 +26673,11 @@ private constructor( @JsonProperty("billable_metric") @ExcludeMissing - fun _billableMetric(): JsonField = billableMetric + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = + fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence @@ -64350,7 +26692,7 @@ private constructor( @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation(): JsonField = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @@ -64366,12 +26708,17 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = + fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + @JsonProperty("max_group_tiered_package_config") + @ExcludeMissing + fun _maxGroupTieredPackageConfig(): JsonField = + maxGroupTieredPackageConfig - @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum @JsonProperty("maximum_amount") @ExcludeMissing @@ -64384,7 +26731,7 @@ private constructor( */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum @JsonProperty("minimum_amount") @ExcludeMissing @@ -64404,14 +26751,9 @@ private constructor( @ExcludeMissing fun _priceType(): JsonField = priceType - @JsonProperty("scalable_matrix_with_tiered_pricing_config") - @ExcludeMissing - fun _scalableMatrixWithTieredPricingConfig(): - JsonField = scalableMatrixWithTieredPricingConfig - @JsonProperty("dimensional_price_configuration") @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = + fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration @JsonAnyGetter @@ -64420,7 +26762,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ScalableMatrixWithTieredPricingPrice = apply { + fun validate(): MaxGroupTieredPackagePrice = apply { if (validated) { return@apply } @@ -64438,6 +26780,7 @@ private constructor( fixedPriceQuantity() invoicingCycleConfiguration().ifPresent { it.validate() } item().validate() + maxGroupTieredPackageConfig().validate() maximum().ifPresent { it.validate() } maximumAmount() metadata().validate() @@ -64447,7 +26790,6 @@ private constructor( name() planPhaseOrder() priceType() - scalableMatrixWithTieredPricingConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } validated = true } @@ -64456,96 +26798,124 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [MaxGroupTieredPackagePrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maxGroupTieredPackageConfig() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [ScalableMatrixWithTieredPricingPrice]. */ + /** A builder for [MaxGroupTieredPackagePrice]. */ class Builder internal constructor() { private var id: JsonField? = null - private var billableMetric: JsonField? = null - private var billingCycleConfiguration: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null private var cadence: JsonField? = null private var conversionRate: JsonField? = null private var createdAt: JsonField? = null - private var creditAllocation: 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 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 minimum: JsonField? = null private var minimumAmount: JsonField? = null private var modelType: JsonField? = null private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null - private var scalableMatrixWithTieredPricingConfig: - JsonField? = - null - private var dimensionalPriceConfiguration: JsonField = + private var dimensionalPriceConfiguration: + JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - scalableMatrixWithTieredPricingPrice: ScalableMatrixWithTieredPricingPrice - ) = apply { - id = scalableMatrixWithTieredPricingPrice.id - billableMetric = scalableMatrixWithTieredPricingPrice.billableMetric - billingCycleConfiguration = - scalableMatrixWithTieredPricingPrice.billingCycleConfiguration - cadence = scalableMatrixWithTieredPricingPrice.cadence - conversionRate = scalableMatrixWithTieredPricingPrice.conversionRate - createdAt = scalableMatrixWithTieredPricingPrice.createdAt - creditAllocation = scalableMatrixWithTieredPricingPrice.creditAllocation - currency = scalableMatrixWithTieredPricingPrice.currency - discount = scalableMatrixWithTieredPricingPrice.discount - externalPriceId = scalableMatrixWithTieredPricingPrice.externalPriceId - fixedPriceQuantity = scalableMatrixWithTieredPricingPrice.fixedPriceQuantity - invoicingCycleConfiguration = - scalableMatrixWithTieredPricingPrice.invoicingCycleConfiguration - item = scalableMatrixWithTieredPricingPrice.item - maximum = scalableMatrixWithTieredPricingPrice.maximum - maximumAmount = scalableMatrixWithTieredPricingPrice.maximumAmount - metadata = scalableMatrixWithTieredPricingPrice.metadata - minimum = scalableMatrixWithTieredPricingPrice.minimum - minimumAmount = scalableMatrixWithTieredPricingPrice.minimumAmount - modelType = scalableMatrixWithTieredPricingPrice.modelType - name = scalableMatrixWithTieredPricingPrice.name - planPhaseOrder = scalableMatrixWithTieredPricingPrice.planPhaseOrder - priceType = scalableMatrixWithTieredPricingPrice.priceType - scalableMatrixWithTieredPricingConfig = - scalableMatrixWithTieredPricingPrice.scalableMatrixWithTieredPricingConfig + internal fun from(maxGroupTieredPackagePrice: MaxGroupTieredPackagePrice) = apply { + id = maxGroupTieredPackagePrice.id + billableMetric = maxGroupTieredPackagePrice.billableMetric + billingCycleConfiguration = maxGroupTieredPackagePrice.billingCycleConfiguration + cadence = maxGroupTieredPackagePrice.cadence + conversionRate = maxGroupTieredPackagePrice.conversionRate + createdAt = maxGroupTieredPackagePrice.createdAt + creditAllocation = maxGroupTieredPackagePrice.creditAllocation + currency = maxGroupTieredPackagePrice.currency + discount = maxGroupTieredPackagePrice.discount + externalPriceId = maxGroupTieredPackagePrice.externalPriceId + fixedPriceQuantity = maxGroupTieredPackagePrice.fixedPriceQuantity + invoicingCycleConfiguration = maxGroupTieredPackagePrice.invoicingCycleConfiguration + item = maxGroupTieredPackagePrice.item + maxGroupTieredPackageConfig = maxGroupTieredPackagePrice.maxGroupTieredPackageConfig + maximum = maxGroupTieredPackagePrice.maximum + maximumAmount = maxGroupTieredPackagePrice.maximumAmount + metadata = maxGroupTieredPackagePrice.metadata + minimum = maxGroupTieredPackagePrice.minimum + minimumAmount = maxGroupTieredPackagePrice.minimumAmount + modelType = maxGroupTieredPackagePrice.modelType + name = maxGroupTieredPackagePrice.name + planPhaseOrder = maxGroupTieredPackagePrice.planPhaseOrder + priceType = maxGroupTieredPackagePrice.priceType dimensionalPriceConfiguration = - scalableMatrixWithTieredPricingPrice.dimensionalPriceConfiguration + maxGroupTieredPackagePrice.dimensionalPriceConfiguration additionalProperties = - scalableMatrixWithTieredPricingPrice.additionalProperties.toMutableMap() + maxGroupTieredPackagePrice.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric?) = + fun billableMetric(billableMetric: BillableMetricTinyModel?) = billableMetric(JsonField.ofNullable(billableMetric)) - fun billableMetric(billableMetric: Optional) = + fun billableMetric(billableMetric: Optional) = billableMetric(billableMetric.orElse(null)) - fun billableMetric(billableMetric: JsonField) = apply { + fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric } - fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = - billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) fun billingCycleConfiguration( - billingCycleConfiguration: JsonField + billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -64571,13 +26941,13 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation?) = + fun creditAllocation(creditAllocation: AllocationModel?) = creditAllocation(JsonField.ofNullable(creditAllocation)) - fun creditAllocation(creditAllocation: Optional) = + fun creditAllocation(creditAllocation: Optional) = creditAllocation(creditAllocation.orElse(null)) - fun creditAllocation(creditAllocation: JsonField) = apply { + fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation } @@ -64633,26 +27003,34 @@ private constructor( } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? + invoicingCycleConfiguration: BillingCycleConfigurationModel? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional + invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField + invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun item(item: Item) = item(JsonField.of(item)) + fun item(item: ItemSlimModel) = item(JsonField.of(item)) + + fun item(item: JsonField) = apply { this.item = item } + + fun maxGroupTieredPackageConfig( + maxGroupTieredPackageConfig: CustomRatingFunctionConfigModel + ) = maxGroupTieredPackageConfig(JsonField.of(maxGroupTieredPackageConfig)) - fun item(item: JsonField) = apply { this.item = item } + fun maxGroupTieredPackageConfig( + maxGroupTieredPackageConfig: JsonField + ) = apply { this.maxGroupTieredPackageConfig = maxGroupTieredPackageConfig } - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) - fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } fun maximumAmount(maximumAmount: String?) = maximumAmount(JsonField.ofNullable(maximumAmount)) @@ -64678,11 +27056,11 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) - fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } fun minimumAmount(minimumAmount: String?) = minimumAmount(JsonField.ofNullable(minimumAmount)) @@ -64719,30 +27097,16 @@ private constructor( fun priceType(priceType: JsonField) = apply { this.priceType = priceType } - fun scalableMatrixWithTieredPricingConfig( - scalableMatrixWithTieredPricingConfig: ScalableMatrixWithTieredPricingConfig - ) = - scalableMatrixWithTieredPricingConfig( - JsonField.of(scalableMatrixWithTieredPricingConfig) - ) - - fun scalableMatrixWithTieredPricingConfig( - scalableMatrixWithTieredPricingConfig: - JsonField - ) = apply { - this.scalableMatrixWithTieredPricingConfig = scalableMatrixWithTieredPricingConfig - } - fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: DimensionalPriceConfiguration? + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional + dimensionalPriceConfiguration: Optional ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField + dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } fun additionalProperties(additionalProperties: Map) = apply { @@ -64764,8 +27128,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): ScalableMatrixWithTieredPricingPrice = - ScalableMatrixWithTieredPricingPrice( + fun build(): MaxGroupTieredPackagePrice = + MaxGroupTieredPackagePrice( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -64779,6 +27143,7 @@ private constructor( checkRequired("fixedPriceQuantity", fixedPriceQuantity), checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), checkRequired("item", item), + checkRequired("maxGroupTieredPackageConfig", maxGroupTieredPackageConfig), checkRequired("maximum", maximum), checkRequired("maximumAmount", maximumAmount), checkRequired("metadata", metadata), @@ -64788,149 +27153,160 @@ private constructor( checkRequired("name", name), checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), - checkRequired( - "scalableMatrixWithTieredPricingConfig", - scalableMatrixWithTieredPricingConfig, - ), dimensionalPriceConfiguration, additionalProperties.toImmutable(), ) } - @NoAutoDetect - class BillableMetric - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillableMetric = apply { - if (validated) { - return@apply - } - - id() - validated = true - } + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { - fun toBuilder() = Builder().from(this) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { - @JvmStatic fun builder() = Builder() - } + @JvmField val ONE_TIME = of("one_time") - /** A builder for [BillableMetric]. */ - class Builder internal constructor() { + @JvmField val MONTHLY = of("monthly") - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + @JvmField val QUARTERLY = of("quarterly") - @JvmSynthetic - internal fun from(billableMetric: BillableMetric) = apply { - id = billableMetric.id - additionalProperties = billableMetric.additionalProperties.toMutableMap() - } + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun id(id: String) = id(JsonField.of(id)) + @JvmField val ANNUAL = of("annual") - fun id(id: JsonField) = apply { this.id = id } + @JvmField val CUSTOM = of("custom") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown value. + */ + _UNKNOWN, + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + 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 removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + 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 build(): BillableMetric = - BillableMetric(checkRequired("id", id), additionalProperties.toImmutable()) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is BillableMetric && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "BillableMetric{id=$id, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ @NoAutoDetect - class BillingCycleConfiguration + class Metadata @JsonCreator private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties private var validated: Boolean = false - fun validate(): BillingCycleConfiguration = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } - duration() - durationUnit() validated = true } @@ -64938,33 +27314,18 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [BillingCycleConfiguration]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { - private var duration: JsonField? = null - private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -64989,139 +27350,123 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } - class DurationUnit - @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 /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } - companion object { + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - @JvmField val DAY = of("day") + override fun hashCode(): Int = hashCode - @JvmField val MONTH = of("month") + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the 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 enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + companion object { - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.MONTH - else -> Value._UNKNOWN - } + @JvmField val MAX_GROUP_TIERED_PACKAGE = of("max_group_tiered_package") - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + /** An enum containing [ModelType]'s known values. */ + enum class Known { + MAX_GROUP_TIERED_PACKAGE + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MAX_GROUP_TIERED_PACKAGE, /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method 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 [ModelType] was instantiated with an unknown + * value. */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + _UNKNOWN, + } - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MAX_GROUP_TIERED_PACKAGE -> Value.MAX_GROUP_TIERED_PACKAGE + else -> Value._UNKNOWN } - override fun hashCode() = value.hashCode() + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MAX_GROUP_TIERED_PACKAGE -> Known.MAX_GROUP_TIERED_PACKAGE + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } - override fun toString() = value.toString() - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if 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 } - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } - class Cadence @JsonCreator private constructor(private val value: JsonField) : + class PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -65136,49 +27481,34 @@ private constructor( companion object { - @JvmField val ONE_TIME = of("one_time") - - @JvmField val MONTHLY = of("monthly") - - @JvmField val QUARTERLY = of("quarterly") - - @JvmField val SEMI_ANNUAL = of("semi_annual") - - @JvmField val ANNUAL = of("annual") + @JvmField val USAGE_PRICE = of("usage_price") - @JvmField val CUSTOM = of("custom") + @JvmField val FIXED_PRICE = of("fixed_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, } /** - * 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, /** - * 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, } @@ -65192,12 +27522,8 @@ private constructor( */ fun value(): Value = when (this) { - ONE_TIME -> Value.ONE_TIME - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - SEMI_ANNUAL -> Value.SEMI_ANNUAL - ANNUAL -> Value.ANNUAL - CUSTOM -> Value.CUSTOM + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE else -> Value._UNKNOWN } @@ -65212,13 +27538,9 @@ private constructor( */ fun known(): Known = when (this) { - ONE_TIME -> Known.ONE_TIME - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - SEMI_ANNUAL -> Known.SEMI_ANNUAL - ANNUAL -> Known.ANNUAL - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") } /** @@ -65238,640 +27560,812 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } + return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MaxGroupTieredPackagePrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maxGroupTieredPackageConfig == other.maxGroupTieredPackageConfig && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maxGroupTieredPackageConfig, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MaxGroupTieredPackagePrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class ScalableMatrixWithUnitPricingPrice + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + private val billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + private val creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("scalable_matrix_with_unit_pricing_config") + @ExcludeMissing + private val scalableMatrixWithUnitPricingConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + private val dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") - override fun hashCode() = value.hashCode() + fun billableMetric(): Optional = + Optional.ofNullable(billableMetric.getNullable("billable_metric")) - override fun toString() = value.toString() - } + fun billingCycleConfiguration(): BillingCycleConfigurationModel = + billingCycleConfiguration.getRequired("billing_cycle_configuration") - @NoAutoDetect - class CreditAllocation - @JsonCreator - private constructor( - @JsonProperty("allows_rollover") - @ExcludeMissing - private val allowsRollover: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + fun cadence(): Cadence = cadence.getRequired("cadence") - fun allowsRollover(): Boolean = allowsRollover.getRequired("allows_rollover") + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - fun currency(): String = currency.getRequired("currency") + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - @JsonProperty("allows_rollover") - @ExcludeMissing - fun _allowsRollover(): JsonField = allowsRollover + fun creditAllocation(): Optional = + Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + fun currency(): String = currency.getRequired("currency") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) - private var validated: Boolean = false + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - fun validate(): CreditAllocation = apply { - if (validated) { - return@apply - } + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - allowsRollover() - currency() - validated = true - } + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) - fun toBuilder() = Builder().from(this) + fun item(): ItemSlimModel = item.getRequired("item") - companion object { + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) - @JvmStatic fun builder() = Builder() - } + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - /** A builder for [CreditAllocation]. */ - class Builder internal constructor() { + /** + * 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.getRequired("metadata") - private var allowsRollover: JsonField? = null - private var currency: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) - @JvmSynthetic - internal fun from(creditAllocation: CreditAllocation) = apply { - allowsRollover = creditAllocation.allowsRollover - currency = creditAllocation.currency - additionalProperties = creditAllocation.additionalProperties.toMutableMap() - } + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) - fun allowsRollover(allowsRollover: Boolean) = - allowsRollover(JsonField.of(allowsRollover)) + fun modelType(): ModelType = modelType.getRequired("model_type") - fun allowsRollover(allowsRollover: JsonField) = apply { - this.allowsRollover = allowsRollover - } + fun name(): String = name.getRequired("name") - fun currency(currency: String) = currency(JsonField.of(currency)) + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - fun currency(currency: JsonField) = apply { this.currency = currency } + fun priceType(): PriceType = priceType.getRequired("price_type") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun scalableMatrixWithUnitPricingConfig(): CustomRatingFunctionConfigModel = + scalableMatrixWithUnitPricingConfig.getRequired( + "scalable_matrix_with_unit_pricing_config" + ) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun dimensionalPriceConfiguration(): Optional = + Optional.ofNullable( + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + ) - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - fun build(): CreditAllocation = - CreditAllocation( - checkRequired("allowsRollover", allowsRollover), - checkRequired("currency", currency), - additionalProperties.toImmutable(), - ) - } + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - return /* spotless:off */ other is CreditAllocation && allowsRollover == other.allowsRollover && currency == other.currency && additionalProperties == other.additionalProperties /* spotless:on */ - } + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allowsRollover, currency, additionalProperties) } - /* spotless:on */ + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation - override fun hashCode(): Int = hashCode + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - override fun toString() = - "CreditAllocation{allowsRollover=$allowsRollover, currency=$currency, additionalProperties=$additionalProperties}" - } + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun duration(): Long = duration.getRequired("duration") + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount - private var validated: Boolean = false + /** + * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - duration() - durationUnit() - validated = true - } + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - fun toBuilder() = Builder().from(this) + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - companion object { + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JvmStatic fun builder() = Builder() - } + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + @JsonProperty("scalable_matrix_with_unit_pricing_config") + @ExcludeMissing + fun _scalableMatrixWithUnitPricingConfig(): JsonField = + scalableMatrixWithUnitPricingConfig - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun duration(duration: Long) = duration(JsonField.of(duration)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - fun duration(duration: JsonField) = apply { this.duration = duration } + private var validated: Boolean = false - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) + fun validate(): ScalableMatrixWithUnitPricingPrice = apply { + if (validated) { + return@apply + } - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + cadence() + conversionRate() + 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() + name() + planPhaseOrder() + priceType() + scalableMatrixWithUnitPricingConfig().validate() + dimensionalPriceConfiguration().ifPresent { it.validate() } + validated = true + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun toBuilder() = Builder().from(this) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + companion object { - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns a mutable builder for constructing an instance of + * [ScalableMatrixWithUnitPricingPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * .scalableMatrixWithUnitPricingConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** A builder for [ScalableMatrixWithUnitPricingPrice]. */ + class Builder internal constructor() { - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var 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: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var scalableMatrixWithUnitPricingConfig: + JsonField? = + null + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) + @JvmSynthetic + internal fun from( + scalableMatrixWithUnitPricingPrice: ScalableMatrixWithUnitPricingPrice + ) = apply { + id = scalableMatrixWithUnitPricingPrice.id + billableMetric = scalableMatrixWithUnitPricingPrice.billableMetric + billingCycleConfiguration = + scalableMatrixWithUnitPricingPrice.billingCycleConfiguration + cadence = scalableMatrixWithUnitPricingPrice.cadence + conversionRate = scalableMatrixWithUnitPricingPrice.conversionRate + createdAt = scalableMatrixWithUnitPricingPrice.createdAt + creditAllocation = scalableMatrixWithUnitPricingPrice.creditAllocation + currency = scalableMatrixWithUnitPricingPrice.currency + discount = scalableMatrixWithUnitPricingPrice.discount + externalPriceId = scalableMatrixWithUnitPricingPrice.externalPriceId + fixedPriceQuantity = scalableMatrixWithUnitPricingPrice.fixedPriceQuantity + invoicingCycleConfiguration = + scalableMatrixWithUnitPricingPrice.invoicingCycleConfiguration + item = scalableMatrixWithUnitPricingPrice.item + maximum = scalableMatrixWithUnitPricingPrice.maximum + maximumAmount = scalableMatrixWithUnitPricingPrice.maximumAmount + metadata = scalableMatrixWithUnitPricingPrice.metadata + minimum = scalableMatrixWithUnitPricingPrice.minimum + minimumAmount = scalableMatrixWithUnitPricingPrice.minimumAmount + modelType = scalableMatrixWithUnitPricingPrice.modelType + name = scalableMatrixWithUnitPricingPrice.name + planPhaseOrder = scalableMatrixWithUnitPricingPrice.planPhaseOrder + priceType = scalableMatrixWithUnitPricingPrice.priceType + scalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricingPrice.scalableMatrixWithUnitPricingConfig + dimensionalPriceConfiguration = + scalableMatrixWithUnitPricingPrice.dimensionalPriceConfiguration + additionalProperties = + scalableMatrixWithUnitPricingPrice.additionalProperties.toMutableMap() } - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { + fun id(id: String) = id(JsonField.of(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 + fun id(id: JsonField) = apply { this.id = id } - companion object { + fun billableMetric(billableMetric: BillableMetricTinyModel?) = + billableMetric(JsonField.ofNullable(billableMetric)) - @JvmField val DAY = of("day") + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) - @JvmField val MONTH = of("month") + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + fun cadence(cadence: Cadence) = cadence(JsonField.of(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) { - DAY -> Value.DAY - MONTH -> Value.MONTH - else -> Value._UNKNOWN - } + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - override fun hashCode() = value.hashCode() + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - override fun toString() = value.toString() + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun creditAllocation(creditAllocation: AllocationModel?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ + fun currency(currency: String) = currency(JsonField.of(currency)) - override fun hashCode(): Int = hashCode + fun currency(currency: JsonField) = apply { this.currency = currency } - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) - @NoAutoDetect - class Item - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + fun discount(discount: Optional) = discount(discount.orElse(null)) - fun id(): String = id.getRequired("id") + fun discount(discount: JsonField) = apply { this.discount = discount } - fun name(): String = name.getRequired("name") + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) - private var validated: Boolean = false + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) - fun validate(): Item = apply { - if (validated) { - return@apply - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) - id() - name() - validated = true + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId } - fun toBuilder() = Builder().from(this) + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) - companion object { + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - @JvmStatic fun builder() = Builder() + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } - /** A builder for [Item]. */ - class Builder internal constructor() { + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) - @JvmSynthetic - internal fun from(item: Item) = apply { - id = item.id - name = item.name - additionalProperties = item.additionalProperties.toMutableMap() - } + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun id(id: String) = id(JsonField.of(id)) + fun item(item: ItemSlimModel) = item(JsonField.of(item)) - fun id(id: JsonField) = apply { this.id = id } + fun item(item: JsonField) = apply { this.item = item } - fun name(name: String) = name(JsonField.of(name)) + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) - fun name(name: JsonField) = apply { this.name = name } + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * 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)) - fun build(): Item = - Item( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toImmutable(), - ) - } + /** + * 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: JsonField) = apply { this.metadata = metadata } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - return /* spotless:off */ other is Item && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - /* spotless:on */ + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - override fun hashCode(): Int = hashCode + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } - override fun toString() = - "Item{id=$id, name=$name, additionalProperties=$additionalProperties}" - } + fun name(name: String) = name(JsonField.of(name)) - @NoAutoDetect - class Maximum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + fun name(name: JsonField) = apply { this.name = name } - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - /** Maximum amount applied */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - /** Maximum amount applied */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + + fun scalableMatrixWithUnitPricingConfig( + scalableMatrixWithUnitPricingConfig: CustomRatingFunctionConfigModel + ) = + scalableMatrixWithUnitPricingConfig( + JsonField.of(scalableMatrixWithUnitPricingConfig) + ) + + fun scalableMatrixWithUnitPricingConfig( + scalableMatrixWithUnitPricingConfig: JsonField + ) = apply { + this.scalableMatrixWithUnitPricingConfig = scalableMatrixWithUnitPricingConfig + } + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) - private var validated: Boolean = false + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } - fun validate(): Maximum = apply { - if (validated) { - return@apply - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - appliesToPriceIds() - maximumAmount() - validated = true + 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) } - @JvmStatic fun builder() = Builder() + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - /** A builder for [Maximum]. */ - class Builder internal constructor() { + fun build(): ScalableMatrixWithUnitPricingPrice = + ScalableMatrixWithUnitPricingPrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + checkRequired( + "scalableMatrixWithUnitPricingConfig", + scalableMatrixWithUnitPricingConfig, + ), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) + } - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { - @JvmSynthetic - internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = maximum.maximumAmount - additionalProperties = maximum.additionalProperties.toMutableMap() - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) + companion object { - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } + @JvmField val ONE_TIME = of("one_time") - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } + @JvmField val MONTHLY = of("monthly") - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) + @JvmField val QUARTERLY = of("quarterly") - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JvmField val ANNUAL = of("annual") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JvmField val CUSTOM = of("custom") - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** An enum containing [Cadence]'s known values. */ + enum class Known { + 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 } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + 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 build(): Maximum = - Maximum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("maximumAmount", maximumAmount), - additionalProperties.toImmutable(), - ) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Maximum && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, maximumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "Maximum{appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } /** @@ -65905,6 +28399,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } @@ -65960,171 +28455,6 @@ private constructor( override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - @NoAutoDetect - class Minimum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Minimum amount applied */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Minimum amount applied */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Minimum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - minimumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Minimum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var minimumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } - minimumAmount = minimum.minimumAmount - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Minimum = - Minimum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("minimumAmount", minimumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Minimum && appliesToPriceIds == other.appliesToPriceIds && minimumAmount == other.minimumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, minimumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" - } - class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -66141,14 +28471,14 @@ private constructor( companion object { @JvmField - val SCALABLE_MATRIX_WITH_TIERED_PRICING = of("scalable_matrix_with_tiered_pricing") + val SCALABLE_MATRIX_WITH_UNIT_PRICING = of("scalable_matrix_with_unit_pricing") @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) } /** An enum containing [ModelType]'s known values. */ enum class Known { - SCALABLE_MATRIX_WITH_TIERED_PRICING + SCALABLE_MATRIX_WITH_UNIT_PRICING } /** @@ -66161,7 +28491,7 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - SCALABLE_MATRIX_WITH_TIERED_PRICING, + SCALABLE_MATRIX_WITH_UNIT_PRICING, /** * An enum member indicating that [ModelType] was instantiated with an unknown * value. @@ -66178,7 +28508,7 @@ private constructor( */ fun value(): Value = when (this) { - SCALABLE_MATRIX_WITH_TIERED_PRICING -> Value.SCALABLE_MATRIX_WITH_TIERED_PRICING + SCALABLE_MATRIX_WITH_UNIT_PRICING -> Value.SCALABLE_MATRIX_WITH_UNIT_PRICING else -> Value._UNKNOWN } @@ -66193,7 +28523,7 @@ private constructor( */ fun known(): Known = when (this) { - SCALABLE_MATRIX_WITH_TIERED_PRICING -> Known.SCALABLE_MATRIX_WITH_TIERED_PRICING + SCALABLE_MATRIX_WITH_UNIT_PRICING -> Known.SCALABLE_MATRIX_WITH_UNIT_PRICING else -> throw OrbInvalidDataException("Unknown ModelType: $value") } @@ -66247,310 +28577,81 @@ private constructor( /** An enum containing [PriceType]'s known values. */ enum class Known { USAGE_PRICE, - FIXED_PRICE, - } - - /** - * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [PriceType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_PRICE, - FIXED_PRICE, - /** - * An enum member indicating that [PriceType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_PRICE -> Value.USAGE_PRICE - FIXED_PRICE -> Value.FIXED_PRICE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE_PRICE -> Known.USAGE_PRICE - FIXED_PRICE -> Known.FIXED_PRICE - else -> throw OrbInvalidDataException("Unknown PriceType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class ScalableMatrixWithTieredPricingConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): ScalableMatrixWithTieredPricingConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ScalableMatrixWithTieredPricingConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - scalableMatrixWithTieredPricingConfig: ScalableMatrixWithTieredPricingConfig - ) = apply { - additionalProperties = - scalableMatrixWithTieredPricingConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): ScalableMatrixWithTieredPricingConfig = - ScalableMatrixWithTieredPricingConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ScalableMatrixWithTieredPricingConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ScalableMatrixWithTieredPricingConfig{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class DimensionalPriceConfiguration - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - private val dimensionalPriceGroupId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun dimensionValues(): List = dimensionValues.getRequired("dimension_values") - - fun dimensionalPriceGroupId(): String = - dimensionalPriceGroupId.getRequired("dimensional_price_group_id") - - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - fun _dimensionalPriceGroupId(): JsonField = dimensionalPriceGroupId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): DimensionalPriceConfiguration = apply { - if (validated) { - return@apply - } - - dimensionValues() - dimensionalPriceGroupId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DimensionalPriceConfiguration]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var dimensionalPriceGroupId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(dimensionalPriceConfiguration: DimensionalPriceConfiguration) = - apply { - dimensionValues = - dimensionalPriceConfiguration.dimensionValues.map { it.toMutableList() } - dimensionalPriceGroupId = - dimensionalPriceConfiguration.dimensionalPriceGroupId - additionalProperties = - dimensionalPriceConfiguration.additionalProperties.toMutableMap() - } - - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: String) = - dimensionalPriceGroupId(JsonField.of(dimensionalPriceGroupId)) - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: JsonField) = apply { - this.dimensionalPriceGroupId = dimensionalPriceGroupId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + FIXED_PRICE, + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") } - fun build(): DimensionalPriceConfiguration = - DimensionalPriceConfiguration( - checkRequired("dimensionValues", dimensionValues).map { it.toImmutable() }, - checkRequired("dimensionalPriceGroupId", dimensionalPriceGroupId), - additionalProperties.toImmutable(), - ) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is DimensionalPriceConfiguration && dimensionValues == other.dimensionValues && dimensionalPriceGroupId == other.dimensionalPriceGroupId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, dimensionalPriceGroupId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "DimensionalPriceConfiguration{dimensionValues=$dimensionValues, dimensionalPriceGroupId=$dimensionalPriceGroupId, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -66558,30 +28659,30 @@ private constructor( return true } - return /* spotless:off */ other is ScalableMatrixWithTieredPricingPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && scalableMatrixWithTieredPricingConfig == other.scalableMatrixWithTieredPricingConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ScalableMatrixWithUnitPricingPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && scalableMatrixWithUnitPricingConfig == other.scalableMatrixWithUnitPricingConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "ScalableMatrixWithTieredPricingPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "ScalableMatrixWithUnitPricingPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } @NoAutoDetect - class CumulativeGroupedBulkPrice + class ScalableMatrixWithTieredPricingPrice @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonProperty("billable_metric") @ExcludeMissing - private val billableMetric: JsonField = JsonMissing.of(), + private val billableMetric: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") @ExcludeMissing - private val billingCycleConfiguration: JsonField = + private val billingCycleConfiguration: JsonField = JsonMissing.of(), @JsonProperty("cadence") @ExcludeMissing @@ -66594,11 +28695,7 @@ private constructor( private val createdAt: JsonField = JsonMissing.of(), @JsonProperty("credit_allocation") @ExcludeMissing - private val creditAllocation: JsonField = JsonMissing.of(), - @JsonProperty("cumulative_grouped_bulk_config") - @ExcludeMissing - private val cumulativeGroupedBulkConfig: JsonField = - JsonMissing.of(), + private val creditAllocation: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing private val currency: JsonField = JsonMissing.of(), @@ -66613,12 +28710,14 @@ private constructor( private val fixedPriceQuantity: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = + private val invoicingCycleConfiguration: JsonField = JsonMissing.of(), - @JsonProperty("item") @ExcludeMissing private val item: JsonField = JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), @JsonProperty("maximum") @ExcludeMissing - private val maximum: JsonField = JsonMissing.of(), + private val maximum: JsonField = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing private val maximumAmount: JsonField = JsonMissing.of(), @@ -66627,7 +28726,7 @@ private constructor( private val metadata: JsonField = JsonMissing.of(), @JsonProperty("minimum") @ExcludeMissing - private val minimum: JsonField = JsonMissing.of(), + private val minimum: JsonField = JsonMissing.of(), @JsonProperty("minimum_amount") @ExcludeMissing private val minimumAmount: JsonField = JsonMissing.of(), @@ -66643,9 +28742,14 @@ private constructor( @JsonProperty("price_type") @ExcludeMissing private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("scalable_matrix_with_tiered_pricing_config") + @ExcludeMissing + private val scalableMatrixWithTieredPricingConfig: + JsonField = + JsonMissing.of(), @JsonProperty("dimensional_price_configuration") @ExcludeMissing - private val dimensionalPriceConfiguration: JsonField = + private val dimensionalPriceConfiguration: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), @@ -66653,10 +28757,10 @@ private constructor( fun id(): String = id.getRequired("id") - fun billableMetric(): Optional = + fun billableMetric(): Optional = Optional.ofNullable(billableMetric.getNullable("billable_metric")) - fun billingCycleConfiguration(): BillingCycleConfiguration = + fun billingCycleConfiguration(): BillingCycleConfigurationModel = billingCycleConfiguration.getRequired("billing_cycle_configuration") fun cadence(): Cadence = cadence.getRequired("cadence") @@ -66666,12 +28770,9 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - fun creditAllocation(): Optional = + fun creditAllocation(): Optional = Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) - fun cumulativeGroupedBulkConfig(): CumulativeGroupedBulkConfig = - cumulativeGroupedBulkConfig.getRequired("cumulative_grouped_bulk_config") - fun currency(): String = currency.getRequired("currency") fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) @@ -66682,14 +28783,14 @@ private constructor( fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - fun invoicingCycleConfiguration(): Optional = + fun invoicingCycleConfiguration(): Optional = Optional.ofNullable( invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") ) - fun item(): Item = item.getRequired("item") + fun item(): ItemSlimModel = item.getRequired("item") - fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) @@ -66701,7 +28802,7 @@ private constructor( */ fun metadata(): Metadata = metadata.getRequired("metadata") - fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) fun minimumAmount(): Optional = Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) @@ -66715,7 +28816,12 @@ private constructor( fun priceType(): PriceType = priceType.getRequired("price_type") - fun dimensionalPriceConfiguration(): Optional = + fun scalableMatrixWithTieredPricingConfig(): CustomRatingFunctionConfigModel = + scalableMatrixWithTieredPricingConfig.getRequired( + "scalable_matrix_with_tiered_pricing_config" + ) + + fun dimensionalPriceConfiguration(): Optional = Optional.ofNullable( dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") ) @@ -66724,11 +28830,11 @@ private constructor( @JsonProperty("billable_metric") @ExcludeMissing - fun _billableMetric(): JsonField = billableMetric + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = + fun _billingCycleConfiguration(): JsonField = billingCycleConfiguration @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence @@ -66743,12 +28849,7 @@ private constructor( @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation(): JsonField = creditAllocation - - @JsonProperty("cumulative_grouped_bulk_config") - @ExcludeMissing - fun _cumulativeGroupedBulkConfig(): JsonField = - cumulativeGroupedBulkConfig + fun _creditAllocation(): JsonField = creditAllocation @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @@ -66764,12 +28865,12 @@ private constructor( @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = + fun _invoicingCycleConfiguration(): JsonField = invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum @JsonProperty("maximum_amount") @ExcludeMissing @@ -66782,7 +28883,7 @@ private constructor( */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum @JsonProperty("minimum_amount") @ExcludeMissing @@ -66802,9 +28903,14 @@ private constructor( @ExcludeMissing fun _priceType(): JsonField = priceType + @JsonProperty("scalable_matrix_with_tiered_pricing_config") + @ExcludeMissing + fun _scalableMatrixWithTieredPricingConfig(): JsonField = + scalableMatrixWithTieredPricingConfig + @JsonProperty("dimensional_price_configuration") @ExcludeMissing - fun _dimensionalPriceConfiguration(): JsonField = + fun _dimensionalPriceConfiguration(): JsonField = dimensionalPriceConfiguration @JsonAnyGetter @@ -66813,7 +28919,7 @@ private constructor( private var validated: Boolean = false - fun validate(): CumulativeGroupedBulkPrice = apply { + fun validate(): ScalableMatrixWithTieredPricingPrice = apply { if (validated) { return@apply } @@ -66825,7 +28931,6 @@ private constructor( conversionRate() createdAt() creditAllocation().ifPresent { it.validate() } - cumulativeGroupedBulkConfig().validate() currency() discount().ifPresent { it.validate() } externalPriceId() @@ -66841,6 +28946,7 @@ private constructor( name() planPhaseOrder() priceType() + scalableMatrixWithTieredPricingConfig().validate() dimensionalPriceConfiguration().ifPresent { it.validate() } validated = true } @@ -66849,89 +28955,130 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [ScalableMatrixWithTieredPricingPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * .scalableMatrixWithTieredPricingConfig() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [CumulativeGroupedBulkPrice]. */ + /** A builder for [ScalableMatrixWithTieredPricingPrice]. */ class Builder internal constructor() { private var id: JsonField? = null - private var billableMetric: JsonField? = null - private var billingCycleConfiguration: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null private var cadence: JsonField? = null private var conversionRate: JsonField? = null private var createdAt: JsonField? = null - private var creditAllocation: JsonField? = null - private var cumulativeGroupedBulkConfig: 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 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 minimum: JsonField? = null private var minimumAmount: JsonField? = null private var modelType: JsonField? = null private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null - private var dimensionalPriceConfiguration: JsonField = + private var scalableMatrixWithTieredPricingConfig: + JsonField? = + null + private var dimensionalPriceConfiguration: + JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(cumulativeGroupedBulkPrice: CumulativeGroupedBulkPrice) = apply { - id = cumulativeGroupedBulkPrice.id - billableMetric = cumulativeGroupedBulkPrice.billableMetric - billingCycleConfiguration = cumulativeGroupedBulkPrice.billingCycleConfiguration - cadence = cumulativeGroupedBulkPrice.cadence - conversionRate = cumulativeGroupedBulkPrice.conversionRate - createdAt = cumulativeGroupedBulkPrice.createdAt - creditAllocation = cumulativeGroupedBulkPrice.creditAllocation - cumulativeGroupedBulkConfig = cumulativeGroupedBulkPrice.cumulativeGroupedBulkConfig - currency = cumulativeGroupedBulkPrice.currency - discount = cumulativeGroupedBulkPrice.discount - externalPriceId = cumulativeGroupedBulkPrice.externalPriceId - fixedPriceQuantity = cumulativeGroupedBulkPrice.fixedPriceQuantity - invoicingCycleConfiguration = cumulativeGroupedBulkPrice.invoicingCycleConfiguration - item = cumulativeGroupedBulkPrice.item - maximum = cumulativeGroupedBulkPrice.maximum - maximumAmount = cumulativeGroupedBulkPrice.maximumAmount - metadata = cumulativeGroupedBulkPrice.metadata - minimum = cumulativeGroupedBulkPrice.minimum - minimumAmount = cumulativeGroupedBulkPrice.minimumAmount - modelType = cumulativeGroupedBulkPrice.modelType - name = cumulativeGroupedBulkPrice.name - planPhaseOrder = cumulativeGroupedBulkPrice.planPhaseOrder - priceType = cumulativeGroupedBulkPrice.priceType + internal fun from( + scalableMatrixWithTieredPricingPrice: ScalableMatrixWithTieredPricingPrice + ) = apply { + id = scalableMatrixWithTieredPricingPrice.id + billableMetric = scalableMatrixWithTieredPricingPrice.billableMetric + billingCycleConfiguration = + scalableMatrixWithTieredPricingPrice.billingCycleConfiguration + cadence = scalableMatrixWithTieredPricingPrice.cadence + conversionRate = scalableMatrixWithTieredPricingPrice.conversionRate + createdAt = scalableMatrixWithTieredPricingPrice.createdAt + creditAllocation = scalableMatrixWithTieredPricingPrice.creditAllocation + currency = scalableMatrixWithTieredPricingPrice.currency + discount = scalableMatrixWithTieredPricingPrice.discount + externalPriceId = scalableMatrixWithTieredPricingPrice.externalPriceId + fixedPriceQuantity = scalableMatrixWithTieredPricingPrice.fixedPriceQuantity + invoicingCycleConfiguration = + scalableMatrixWithTieredPricingPrice.invoicingCycleConfiguration + item = scalableMatrixWithTieredPricingPrice.item + maximum = scalableMatrixWithTieredPricingPrice.maximum + maximumAmount = scalableMatrixWithTieredPricingPrice.maximumAmount + metadata = scalableMatrixWithTieredPricingPrice.metadata + minimum = scalableMatrixWithTieredPricingPrice.minimum + minimumAmount = scalableMatrixWithTieredPricingPrice.minimumAmount + modelType = scalableMatrixWithTieredPricingPrice.modelType + name = scalableMatrixWithTieredPricingPrice.name + planPhaseOrder = scalableMatrixWithTieredPricingPrice.planPhaseOrder + priceType = scalableMatrixWithTieredPricingPrice.priceType + scalableMatrixWithTieredPricingConfig = + scalableMatrixWithTieredPricingPrice.scalableMatrixWithTieredPricingConfig dimensionalPriceConfiguration = - cumulativeGroupedBulkPrice.dimensionalPriceConfiguration + scalableMatrixWithTieredPricingPrice.dimensionalPriceConfiguration additionalProperties = - cumulativeGroupedBulkPrice.additionalProperties.toMutableMap() + scalableMatrixWithTieredPricingPrice.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric?) = + fun billableMetric(billableMetric: BillableMetricTinyModel?) = billableMetric(JsonField.ofNullable(billableMetric)) - fun billableMetric(billableMetric: Optional) = + fun billableMetric(billableMetric: Optional) = billableMetric(billableMetric.orElse(null)) - fun billableMetric(billableMetric: JsonField) = apply { + fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric } - fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration) = - billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) fun billingCycleConfiguration( - billingCycleConfiguration: JsonField + billingCycleConfiguration: JsonField ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -66957,24 +29104,16 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation?) = + fun creditAllocation(creditAllocation: AllocationModel?) = creditAllocation(JsonField.ofNullable(creditAllocation)) - fun creditAllocation(creditAllocation: Optional) = + fun creditAllocation(creditAllocation: Optional) = creditAllocation(creditAllocation.orElse(null)) - fun creditAllocation(creditAllocation: JsonField) = apply { + fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation } - fun cumulativeGroupedBulkConfig( - cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig - ) = cumulativeGroupedBulkConfig(JsonField.of(cumulativeGroupedBulkConfig)) - - fun cumulativeGroupedBulkConfig( - cumulativeGroupedBulkConfig: JsonField - ) = apply { this.cumulativeGroupedBulkConfig = cumulativeGroupedBulkConfig } - fun currency(currency: String) = currency(JsonField.of(currency)) fun currency(currency: JsonField) = apply { this.currency = currency } @@ -67027,26 +29166,26 @@ private constructor( } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration? + invoicingCycleConfiguration: BillingCycleConfigurationModel? ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional + invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( - invoicingCycleConfiguration: JsonField + invoicingCycleConfiguration: JsonField ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - fun item(item: Item) = item(JsonField.of(item)) + fun item(item: ItemSlimModel) = item(JsonField.of(item)) - fun item(item: JsonField) = apply { this.item = item } + fun item(item: JsonField) = apply { this.item = item } - fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) - fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } fun maximumAmount(maximumAmount: String?) = maximumAmount(JsonField.ofNullable(maximumAmount)) @@ -67072,11 +29211,11 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) - fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } fun minimumAmount(minimumAmount: String?) = minimumAmount(JsonField.ofNullable(minimumAmount)) @@ -67113,16 +29252,29 @@ private constructor( fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + fun scalableMatrixWithTieredPricingConfig( + scalableMatrixWithTieredPricingConfig: CustomRatingFunctionConfigModel + ) = + scalableMatrixWithTieredPricingConfig( + JsonField.of(scalableMatrixWithTieredPricingConfig) + ) + + fun scalableMatrixWithTieredPricingConfig( + scalableMatrixWithTieredPricingConfig: JsonField + ) = apply { + this.scalableMatrixWithTieredPricingConfig = scalableMatrixWithTieredPricingConfig + } + fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: DimensionalPriceConfiguration? + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: Optional + dimensionalPriceConfiguration: Optional ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) fun dimensionalPriceConfiguration( - dimensionalPriceConfiguration: JsonField + dimensionalPriceConfiguration: JsonField ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } fun additionalProperties(additionalProperties: Map) = apply { @@ -67144,8 +29296,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): CumulativeGroupedBulkPrice = - CumulativeGroupedBulkPrice( + fun build(): ScalableMatrixWithTieredPricingPrice = + ScalableMatrixWithTieredPricingPrice( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -67153,7 +29305,6 @@ private constructor( checkRequired("conversionRate", conversionRate), checkRequired("createdAt", createdAt), checkRequired("creditAllocation", creditAllocation), - checkRequired("cumulativeGroupedBulkConfig", cumulativeGroupedBulkConfig), checkRequired("currency", currency), checkRequired("discount", discount), checkRequired("externalPriceId", externalPriceId), @@ -67169,145 +29320,164 @@ private constructor( checkRequired("name", name), checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), + checkRequired( + "scalableMatrixWithTieredPricingConfig", + scalableMatrixWithTieredPricingConfig, + ), dimensionalPriceConfiguration, additionalProperties.toImmutable(), ) } - @NoAutoDetect - class BillableMetric - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillableMetric = apply { - if (validated) { - return@apply - } - - id() - validated = true - } + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { - fun toBuilder() = Builder().from(this) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { - @JvmStatic fun builder() = Builder() - } + @JvmField val ONE_TIME = of("one_time") - /** A builder for [BillableMetric]. */ - class Builder internal constructor() { + @JvmField val MONTHLY = of("monthly") - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + @JvmField val QUARTERLY = of("quarterly") - @JvmSynthetic - internal fun from(billableMetric: BillableMetric) = apply { - id = billableMetric.id - additionalProperties = billableMetric.additionalProperties.toMutableMap() - } + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun id(id: String) = id(JsonField.of(id)) + @JvmField val ANNUAL = of("annual") - fun id(id: JsonField) = apply { this.id = id } + @JvmField val CUSTOM = of("custom") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** An enum containing [Cadence]'s known values. */ + enum class Known { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * An enum containing [Cadence]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Cadence] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ONE_TIME, + MONTHLY, + QUARTERLY, + SEMI_ANNUAL, + ANNUAL, + CUSTOM, + /** + * An enum member indicating that [Cadence] was instantiated with an unknown value. + */ + _UNKNOWN, + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + 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 removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + 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 build(): BillableMetric = - BillableMetric(checkRequired("id", id), additionalProperties.toImmutable()) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is BillableMetric && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "BillableMetric{id=$id, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ @NoAutoDetect - class BillingCycleConfiguration + class Metadata @JsonCreator private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val additionalProperties: Map = immutableEmptyMap() ) { - fun duration(): Long = duration.getRequired("duration") - - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties private var validated: Boolean = false - fun validate(): BillingCycleConfiguration = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } - duration() - durationUnit() validated = true } @@ -67315,33 +29485,18 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [BillingCycleConfiguration]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { - private var duration: JsonField? = null - private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - fun duration(duration: Long) = duration(JsonField.of(duration)) - - fun duration(duration: JsonField) = apply { this.duration = duration } - - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -67366,139 +29521,124 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } - class DurationUnit - @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 /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } - companion object { + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - @JvmField val DAY = of("day") + override fun hashCode(): Int = hashCode - @JvmField val MONTH = of("month") + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the 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 enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + companion object { - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.MONTH - else -> Value._UNKNOWN - } + @JvmField + val SCALABLE_MATRIX_WITH_TIERED_PRICING = of("scalable_matrix_with_tiered_pricing") - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + /** An enum containing [ModelType]'s known values. */ + enum class Known { + SCALABLE_MATRIX_WITH_TIERED_PRICING + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SCALABLE_MATRIX_WITH_TIERED_PRICING, /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method 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 [ModelType] was instantiated with an unknown + * value. */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + _UNKNOWN, + } - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SCALABLE_MATRIX_WITH_TIERED_PRICING -> Value.SCALABLE_MATRIX_WITH_TIERED_PRICING + else -> Value._UNKNOWN } - override fun hashCode() = value.hashCode() + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SCALABLE_MATRIX_WITH_TIERED_PRICING -> Known.SCALABLE_MATRIX_WITH_TIERED_PRICING + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } - override fun toString() = value.toString() - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if 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 } - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } - class Cadence @JsonCreator private constructor(private val value: JsonField) : + class PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -67513,49 +29653,34 @@ private constructor( companion object { - @JvmField val ONE_TIME = of("one_time") - - @JvmField val MONTHLY = of("monthly") - - @JvmField val QUARTERLY = of("quarterly") - - @JvmField val SEMI_ANNUAL = of("semi_annual") - - @JvmField val ANNUAL = of("annual") + @JvmField val USAGE_PRICE = of("usage_price") - @JvmField val CUSTOM = of("custom") + @JvmField val FIXED_PRICE = of("fixed_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, } /** - * 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, + enum class Value { + USAGE_PRICE, + FIXED_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, } @@ -67569,12 +29694,8 @@ private constructor( */ fun value(): Value = when (this) { - ONE_TIME -> Value.ONE_TIME - MONTHLY -> Value.MONTHLY - QUARTERLY -> Value.QUARTERLY - SEMI_ANNUAL -> Value.SEMI_ANNUAL - ANNUAL -> Value.ANNUAL - CUSTOM -> Value.CUSTOM + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE else -> Value._UNKNOWN } @@ -67589,13 +29710,9 @@ private constructor( */ fun known(): Known = when (this) { - ONE_TIME -> Known.ONE_TIME - MONTHLY -> Known.MONTHLY - QUARTERLY -> Known.QUARTERLY - SEMI_ANNUAL -> Known.SEMI_ANNUAL - ANNUAL -> Known.ANNUAL - CUSTOM -> Known.CUSTOM - else -> throw OrbInvalidDataException("Unknown Cadence: $value") + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") } /** @@ -67615,7 +29732,7 @@ private constructor( return true } - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -67623,717 +29740,787 @@ private constructor( override fun toString() = value.toString() } - @NoAutoDetect - class CreditAllocation - @JsonCreator - private constructor( - @JsonProperty("allows_rollover") - @ExcludeMissing - private val allowsRollover: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun allowsRollover(): Boolean = allowsRollover.getRequired("allows_rollover") + return /* spotless:off */ other is ScalableMatrixWithTieredPricingPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && scalableMatrixWithTieredPricingConfig == other.scalableMatrixWithTieredPricingConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + } - fun currency(): String = currency.getRequired("currency") + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration, additionalProperties) } + /* spotless:on */ - @JsonProperty("allows_rollover") - @ExcludeMissing - fun _allowsRollover(): JsonField = allowsRollover + override fun hashCode(): Int = hashCode - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + override fun toString() = + "ScalableMatrixWithTieredPricingPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + @NoAutoDetect + class CumulativeGroupedBulkPrice + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + private val billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + private val creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_bulk_config") + @ExcludeMissing + private val cumulativeGroupedBulkConfig: JsonField = + JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + private val dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { - private var validated: Boolean = false + fun id(): String = id.getRequired("id") - fun validate(): CreditAllocation = apply { - if (validated) { - return@apply - } + fun billableMetric(): Optional = + Optional.ofNullable(billableMetric.getNullable("billable_metric")) - allowsRollover() - currency() - validated = true - } + fun billingCycleConfiguration(): BillingCycleConfigurationModel = + billingCycleConfiguration.getRequired("billing_cycle_configuration") - fun toBuilder() = Builder().from(this) + fun cadence(): Cadence = cadence.getRequired("cadence") - companion object { + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - @JvmStatic fun builder() = Builder() - } + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - /** A builder for [CreditAllocation]. */ - class Builder internal constructor() { + fun creditAllocation(): Optional = + Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) - private var allowsRollover: JsonField? = null - private var currency: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun cumulativeGroupedBulkConfig(): CustomRatingFunctionConfigModel = + cumulativeGroupedBulkConfig.getRequired("cumulative_grouped_bulk_config") - @JvmSynthetic - internal fun from(creditAllocation: CreditAllocation) = apply { - allowsRollover = creditAllocation.allowsRollover - currency = creditAllocation.currency - additionalProperties = creditAllocation.additionalProperties.toMutableMap() - } + fun currency(): String = currency.getRequired("currency") - fun allowsRollover(allowsRollover: Boolean) = - allowsRollover(JsonField.of(allowsRollover)) + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) - fun allowsRollover(allowsRollover: JsonField) = apply { - this.allowsRollover = allowsRollover - } + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - fun currency(currency: String) = currency(JsonField.of(currency)) + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - fun currency(currency: JsonField) = apply { this.currency = currency } + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun item(): ItemSlimModel = item.getRequired("item") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * 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.getRequired("metadata") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) - fun build(): CreditAllocation = - CreditAllocation( - checkRequired("allowsRollover", allowsRollover), - checkRequired("currency", currency), - additionalProperties.toImmutable(), - ) - } + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun modelType(): ModelType = modelType.getRequired("model_type") - return /* spotless:off */ other is CreditAllocation && allowsRollover == other.allowsRollover && currency == other.currency && additionalProperties == other.additionalProperties /* spotless:on */ - } + fun name(): String = name.getRequired("name") - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allowsRollover, currency, additionalProperties) } - /* spotless:on */ + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - override fun hashCode(): Int = hashCode + fun priceType(): PriceType = priceType.getRequired("price_type") - override fun toString() = - "CreditAllocation{allowsRollover=$allowsRollover, currency=$currency, additionalProperties=$additionalProperties}" - } + fun dimensionalPriceConfiguration(): Optional = + Optional.ofNullable( + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + ) - @NoAutoDetect - class CumulativeGroupedBulkConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric - private var validated: Boolean = false + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - fun validate(): CumulativeGroupedBulkConfig = apply { - if (validated) { - return@apply - } + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - validated = true - } + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - fun toBuilder() = Builder().from(this) + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - companion object { + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation - @JvmStatic fun builder() = Builder() - } + @JsonProperty("cumulative_grouped_bulk_config") + @ExcludeMissing + fun _cumulativeGroupedBulkConfig(): JsonField = + cumulativeGroupedBulkConfig - /** A builder for [CumulativeGroupedBulkConfig]. */ - class Builder internal constructor() { + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - private var additionalProperties: MutableMap = mutableMapOf() + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - @JvmSynthetic - internal fun from(cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig) = - apply { - additionalProperties = - cumulativeGroupedBulkConfig.additionalProperties.toMutableMap() - } + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount - fun build(): CumulativeGroupedBulkConfig = - CumulativeGroupedBulkConfig(additionalProperties.toImmutable()) - } + /** + * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - return /* spotless:off */ other is CumulativeGroupedBulkConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - override fun hashCode(): Int = hashCode + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - override fun toString() = - "CumulativeGroupedBulkConfig{additionalProperties=$additionalProperties}" - } + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType - fun duration(): Long = duration.getRequired("duration") + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + private var validated: Boolean = false - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit + fun validate(): CumulativeGroupedBulkPrice = apply { + if (validated) { + return@apply + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + cadence() + conversionRate() + createdAt() + creditAllocation().ifPresent { it.validate() } + cumulativeGroupedBulkConfig().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() + name() + planPhaseOrder() + priceType() + dimensionalPriceConfiguration().ifPresent { it.validate() } + validated = true + } - private var validated: Boolean = false + fun toBuilder() = Builder().from(this) - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } + companion object { - duration() - durationUnit() - validated = true + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedBulkPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .cumulativeGroupedBulkConfig() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedBulkPrice]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var createdAt: JsonField? = null + private var creditAllocation: JsonField? = null + private var cumulativeGroupedBulkConfig: JsonField? = + null + private var currency: JsonField? = null + private var discount: JsonField? = null + private var externalPriceId: JsonField? = null + private var fixedPriceQuantity: JsonField? = null + private var invoicingCycleConfiguration: JsonField? = + null + private var item: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cumulativeGroupedBulkPrice: CumulativeGroupedBulkPrice) = apply { + id = cumulativeGroupedBulkPrice.id + billableMetric = cumulativeGroupedBulkPrice.billableMetric + billingCycleConfiguration = cumulativeGroupedBulkPrice.billingCycleConfiguration + cadence = cumulativeGroupedBulkPrice.cadence + conversionRate = cumulativeGroupedBulkPrice.conversionRate + createdAt = cumulativeGroupedBulkPrice.createdAt + creditAllocation = cumulativeGroupedBulkPrice.creditAllocation + cumulativeGroupedBulkConfig = cumulativeGroupedBulkPrice.cumulativeGroupedBulkConfig + currency = cumulativeGroupedBulkPrice.currency + discount = cumulativeGroupedBulkPrice.discount + externalPriceId = cumulativeGroupedBulkPrice.externalPriceId + fixedPriceQuantity = cumulativeGroupedBulkPrice.fixedPriceQuantity + invoicingCycleConfiguration = cumulativeGroupedBulkPrice.invoicingCycleConfiguration + item = cumulativeGroupedBulkPrice.item + maximum = cumulativeGroupedBulkPrice.maximum + maximumAmount = cumulativeGroupedBulkPrice.maximumAmount + metadata = cumulativeGroupedBulkPrice.metadata + minimum = cumulativeGroupedBulkPrice.minimum + minimumAmount = cumulativeGroupedBulkPrice.minimumAmount + modelType = cumulativeGroupedBulkPrice.modelType + name = cumulativeGroupedBulkPrice.name + planPhaseOrder = cumulativeGroupedBulkPrice.planPhaseOrder + priceType = cumulativeGroupedBulkPrice.priceType + dimensionalPriceConfiguration = + cumulativeGroupedBulkPrice.dimensionalPriceConfiguration + additionalProperties = + cumulativeGroupedBulkPrice.additionalProperties.toMutableMap() } - fun toBuilder() = Builder().from(this) + fun id(id: String) = id(JsonField.of(id)) - companion object { + fun id(id: JsonField) = apply { this.id = id } - @JvmStatic fun builder() = Builder() + fun billableMetric(billableMetric: BillableMetricTinyModel?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) + + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric } - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - fun duration(duration: Long) = duration(JsonField.of(duration)) + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun duration(duration: JsonField) = apply { this.duration = duration } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun creditAllocation(creditAllocation: AllocationModel?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) - fun build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation } - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { + fun cumulativeGroupedBulkConfig( + cumulativeGroupedBulkConfig: CustomRatingFunctionConfigModel + ) = cumulativeGroupedBulkConfig(JsonField.of(cumulativeGroupedBulkConfig)) - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the 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 cumulativeGroupedBulkConfig( + cumulativeGroupedBulkConfig: JsonField + ) = apply { this.cumulativeGroupedBulkConfig = cumulativeGroupedBulkConfig } - companion object { + fun currency(currency: String) = currency(JsonField.of(currency)) - @JvmField val DAY = of("day") + fun currency(currency: JsonField) = apply { this.currency = currency } - @JvmField val MONTH = of("month") + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } + fun discount(discount: Optional) = discount(discount.orElse(null)) - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } + fun discount(discount: JsonField) = apply { this.discount = discount } - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.MONTH - else -> Value._UNKNOWN - } + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .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") - } + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) + + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) - override fun hashCode() = value.hashCode() + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - override fun toString() = value.toString() + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - override fun hashCode(): Int = hashCode + fun item(item: ItemSlimModel) = item(JsonField.of(item)) - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } + fun item(item: JsonField) = apply { this.item = item } - @NoAutoDetect - class Item - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) - fun id(): String = id.getRequired("id") + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) - fun name(): String = name.getRequired("name") + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } - private var validated: Boolean = false + /** + * 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)) - fun validate(): Item = apply { - if (validated) { - return@apply - } + /** + * 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: JsonField) = apply { this.metadata = metadata } - id() - name() - validated = true - } + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) - fun toBuilder() = Builder().from(this) + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) - companion object { + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - @JvmStatic fun builder() = Builder() + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount } - /** A builder for [Item]. */ - class Builder internal constructor() { + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } - @JvmSynthetic - internal fun from(item: Item) = apply { - id = item.id - name = item.name - additionalProperties = item.additionalProperties.toMutableMap() - } + fun name(name: String) = name(JsonField.of(name)) - fun id(id: String) = id(JsonField.of(id)) + fun name(name: JsonField) = apply { this.name = name } - fun id(id: JsonField) = apply { this.id = id } + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - fun name(name: String) = name(JsonField.of(name)) + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - fun name(name: JsonField) = apply { this.name = name } + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) - fun build(): Item = - Item( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toImmutable(), - ) + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - return /* spotless:off */ other is Item && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - /* spotless:on */ + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - override fun hashCode(): Int = hashCode + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - override fun toString() = - "Item{id=$id, name=$name, additionalProperties=$additionalProperties}" + fun build(): CumulativeGroupedBulkPrice = + CumulativeGroupedBulkPrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("cumulativeGroupedBulkConfig", cumulativeGroupedBulkConfig), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) } - @NoAutoDetect - class Maximum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Maximum amount applied */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") + class Cadence @JsonCreator private constructor(private val value: JsonField) : + Enum { /** - * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, - * this can be a subset of prices. + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** Maximum amount applied */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount + companion object { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + @JvmField val ONE_TIME = of("one_time") - private var validated: Boolean = false + @JvmField val MONTHLY = of("monthly") - fun validate(): Maximum = apply { - if (validated) { - return@apply - } + @JvmField val QUARTERLY = of("quarterly") - appliesToPriceIds() - maximumAmount() - validated = true - } + @JvmField val SEMI_ANNUAL = of("semi_annual") - fun toBuilder() = Builder().from(this) + @JvmField val ANNUAL = of("annual") - companion object { + @JvmField val CUSTOM = of("custom") - @JvmStatic fun builder() = Builder() + @JvmStatic fun of(value: String) = Cadence(JsonField.of(value)) } - /** A builder for [Maximum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = maximum.maximumAmount - additionalProperties = maximum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } + /** 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, /** - * List of price_ids that this maximum amount applies to. For plan/plan phase - * maximums, this can be a subset of prices. + * An enum member indicating that [Cadence] was instantiated with an unknown value. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** Maximum amount applied */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + _UNKNOWN, + } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + 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 removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + 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 build(): Maximum = - Maximum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("maximumAmount", maximumAmount), - additionalProperties.toImmutable(), - ) - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Maximum && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, maximumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "Maximum{appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } /** @@ -68367,6 +30554,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } @@ -68422,171 +30610,6 @@ private constructor( override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - @NoAutoDetect - class Minimum - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** Minimum amount applied */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, - * this can be a subset of prices. - */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** Minimum amount applied */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Minimum = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - minimumAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Minimum]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var minimumAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } - minimumAmount = minimum.minimumAmount - additionalProperties = minimum.additionalProperties.toMutableMap() - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** - * List of price_ids that this minimum amount applies to. For plan/plan phase - * minimums, this can be a subset of prices. - */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** Minimum amount applied */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Minimum = - Minimum( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("minimumAmount", minimumAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Minimum && appliesToPriceIds == other.appliesToPriceIds && minimumAmount == other.minimumAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, minimumAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" - } - class ModelType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -68785,149 +30808,6 @@ private constructor( override fun toString() = value.toString() } - @NoAutoDetect - class DimensionalPriceConfiguration - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - private val dimensionalPriceGroupId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun dimensionValues(): List = dimensionValues.getRequired("dimension_values") - - fun dimensionalPriceGroupId(): String = - dimensionalPriceGroupId.getRequired("dimensional_price_group_id") - - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - @JsonProperty("dimensional_price_group_id") - @ExcludeMissing - fun _dimensionalPriceGroupId(): JsonField = dimensionalPriceGroupId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): DimensionalPriceConfiguration = apply { - if (validated) { - return@apply - } - - dimensionValues() - dimensionalPriceGroupId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DimensionalPriceConfiguration]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var dimensionalPriceGroupId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(dimensionalPriceConfiguration: DimensionalPriceConfiguration) = - apply { - dimensionValues = - dimensionalPriceConfiguration.dimensionValues.map { it.toMutableList() } - dimensionalPriceGroupId = - dimensionalPriceConfiguration.dimensionalPriceGroupId - additionalProperties = - dimensionalPriceConfiguration.additionalProperties.toMutableMap() - } - - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: String) = - dimensionalPriceGroupId(JsonField.of(dimensionalPriceGroupId)) - - fun dimensionalPriceGroupId(dimensionalPriceGroupId: JsonField) = apply { - this.dimensionalPriceGroupId = dimensionalPriceGroupId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): DimensionalPriceConfiguration = - DimensionalPriceConfiguration( - checkRequired("dimensionValues", dimensionValues).map { it.toImmutable() }, - checkRequired("dimensionalPriceGroupId", dimensionalPriceGroupId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DimensionalPriceConfiguration && dimensionValues == other.dimensionValues && dimensionalPriceGroupId == other.dimensionalPriceGroupId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, dimensionalPriceGroupId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DimensionalPriceConfiguration{dimensionValues=$dimensionValues, dimensionalPriceGroupId=$dimensionalPriceGroupId, 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/PriceCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt index ea958343d..3df6f0a46 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt @@ -2,36 +2,12 @@ package com.withorb.api.models -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer -import com.withorb.api.core.Enum -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.Params import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams -import com.withorb.api.core.immutableEmptyMap -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull /** * This endpoint is used to create a [price](/product-catalog/price-configuration). A price created @@ -47,44290 +23,35 @@ import kotlin.jvm.optionals.getOrNull */ class PriceCreateParams private constructor( - private val body: Body, + private val newFloatingPriceModel: NewFloatingPriceModel, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun body(): Body = body + fun newFloatingPriceModel(): NewFloatingPriceModel = newFloatingPriceModel fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): NewFloatingPriceModel = newFloatingPriceModel override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams - @JsonDeserialize(using = Body.Deserializer::class) - @JsonSerialize(using = Body.Serializer::class) - class Body - private constructor( - private val newFloatingUnitPrice: NewFloatingUnitPrice? = null, - private val newFloatingPackagePrice: NewFloatingPackagePrice? = null, - private val newFloatingMatrixPrice: NewFloatingMatrixPrice? = null, - private val newFloatingMatrixWithAllocationPrice: NewFloatingMatrixWithAllocationPrice? = - null, - private val newFloatingTieredPrice: NewFloatingTieredPrice? = null, - private val newFloatingTieredBpsPrice: NewFloatingTieredBpsPrice? = null, - private val newFloatingBpsPrice: NewFloatingBpsPrice? = null, - private val newFloatingBulkBpsPrice: NewFloatingBulkBpsPrice? = null, - private val newFloatingBulkPrice: NewFloatingBulkPrice? = null, - private val newFloatingThresholdTotalAmountPrice: NewFloatingThresholdTotalAmountPrice? = - null, - private val newFloatingTieredPackagePrice: NewFloatingTieredPackagePrice? = null, - private val newFloatingGroupedTieredPrice: NewFloatingGroupedTieredPrice? = null, - private val newFloatingMaxGroupTieredPackagePrice: NewFloatingMaxGroupTieredPackagePrice? = - null, - private val newFloatingTieredWithMinimumPrice: NewFloatingTieredWithMinimumPrice? = null, - private val newFloatingPackageWithAllocationPrice: NewFloatingPackageWithAllocationPrice? = - null, - private val newFloatingTieredPackageWithMinimumPrice: - NewFloatingTieredPackageWithMinimumPrice? = - null, - private val newFloatingUnitWithPercentPrice: NewFloatingUnitWithPercentPrice? = null, - private val newFloatingTieredWithProrationPrice: NewFloatingTieredWithProrationPrice? = - null, - private val newFloatingUnitWithProrationPrice: NewFloatingUnitWithProrationPrice? = null, - private val newFloatingGroupedAllocationPrice: NewFloatingGroupedAllocationPrice? = null, - private val newFloatingGroupedWithProratedMinimumPrice: - NewFloatingGroupedWithProratedMinimumPrice? = - null, - private val newFloatingGroupedWithMeteredMinimumPrice: - NewFloatingGroupedWithMeteredMinimumPrice? = - null, - private val newFloatingMatrixWithDisplayNamePrice: NewFloatingMatrixWithDisplayNamePrice? = - null, - private val newFloatingBulkWithProrationPrice: NewFloatingBulkWithProrationPrice? = null, - private val newFloatingGroupedTieredPackagePrice: NewFloatingGroupedTieredPackagePrice? = - null, - private val newFloatingScalableMatrixWithUnitPricingPrice: - NewFloatingScalableMatrixWithUnitPricingPrice? = - null, - private val newFloatingScalableMatrixWithTieredPricingPrice: - NewFloatingScalableMatrixWithTieredPricingPrice? = - null, - private val newFloatingCumulativeGroupedBulkPrice: NewFloatingCumulativeGroupedBulkPrice? = - null, - private val _json: JsonValue? = null, - ) { - - fun newFloatingUnitPrice(): Optional = - Optional.ofNullable(newFloatingUnitPrice) - - fun newFloatingPackagePrice(): Optional = - Optional.ofNullable(newFloatingPackagePrice) - - fun newFloatingMatrixPrice(): Optional = - Optional.ofNullable(newFloatingMatrixPrice) - - fun newFloatingMatrixWithAllocationPrice(): Optional = - Optional.ofNullable(newFloatingMatrixWithAllocationPrice) - - fun newFloatingTieredPrice(): Optional = - Optional.ofNullable(newFloatingTieredPrice) - - fun newFloatingTieredBpsPrice(): Optional = - Optional.ofNullable(newFloatingTieredBpsPrice) - - fun newFloatingBpsPrice(): Optional = - Optional.ofNullable(newFloatingBpsPrice) - - fun newFloatingBulkBpsPrice(): Optional = - Optional.ofNullable(newFloatingBulkBpsPrice) - - fun newFloatingBulkPrice(): Optional = - Optional.ofNullable(newFloatingBulkPrice) - - fun newFloatingThresholdTotalAmountPrice(): Optional = - Optional.ofNullable(newFloatingThresholdTotalAmountPrice) - - fun newFloatingTieredPackagePrice(): Optional = - Optional.ofNullable(newFloatingTieredPackagePrice) - - fun newFloatingGroupedTieredPrice(): Optional = - Optional.ofNullable(newFloatingGroupedTieredPrice) - - fun newFloatingMaxGroupTieredPackagePrice(): - Optional = - Optional.ofNullable(newFloatingMaxGroupTieredPackagePrice) - - fun newFloatingTieredWithMinimumPrice(): Optional = - Optional.ofNullable(newFloatingTieredWithMinimumPrice) - - fun newFloatingPackageWithAllocationPrice(): - Optional = - Optional.ofNullable(newFloatingPackageWithAllocationPrice) - - fun newFloatingTieredPackageWithMinimumPrice(): - Optional = - Optional.ofNullable(newFloatingTieredPackageWithMinimumPrice) - - fun newFloatingUnitWithPercentPrice(): Optional = - Optional.ofNullable(newFloatingUnitWithPercentPrice) - - fun newFloatingTieredWithProrationPrice(): Optional = - Optional.ofNullable(newFloatingTieredWithProrationPrice) - - fun newFloatingUnitWithProrationPrice(): Optional = - Optional.ofNullable(newFloatingUnitWithProrationPrice) - - fun newFloatingGroupedAllocationPrice(): Optional = - Optional.ofNullable(newFloatingGroupedAllocationPrice) - - fun newFloatingGroupedWithProratedMinimumPrice(): - Optional = - Optional.ofNullable(newFloatingGroupedWithProratedMinimumPrice) - - fun newFloatingGroupedWithMeteredMinimumPrice(): - Optional = - Optional.ofNullable(newFloatingGroupedWithMeteredMinimumPrice) - - fun newFloatingMatrixWithDisplayNamePrice(): - Optional = - Optional.ofNullable(newFloatingMatrixWithDisplayNamePrice) - - fun newFloatingBulkWithProrationPrice(): Optional = - Optional.ofNullable(newFloatingBulkWithProrationPrice) - - fun newFloatingGroupedTieredPackagePrice(): Optional = - Optional.ofNullable(newFloatingGroupedTieredPackagePrice) - - fun newFloatingScalableMatrixWithUnitPricingPrice(): - Optional = - Optional.ofNullable(newFloatingScalableMatrixWithUnitPricingPrice) - - fun newFloatingScalableMatrixWithTieredPricingPrice(): - Optional = - Optional.ofNullable(newFloatingScalableMatrixWithTieredPricingPrice) - - fun newFloatingCumulativeGroupedBulkPrice(): - Optional = - Optional.ofNullable(newFloatingCumulativeGroupedBulkPrice) - - fun isNewFloatingUnitPrice(): Boolean = newFloatingUnitPrice != null - - fun isNewFloatingPackagePrice(): Boolean = newFloatingPackagePrice != null - - fun isNewFloatingMatrixPrice(): Boolean = newFloatingMatrixPrice != null - - fun isNewFloatingMatrixWithAllocationPrice(): Boolean = - newFloatingMatrixWithAllocationPrice != null - - fun isNewFloatingTieredPrice(): Boolean = newFloatingTieredPrice != null - - fun isNewFloatingTieredBpsPrice(): Boolean = newFloatingTieredBpsPrice != null - - fun isNewFloatingBpsPrice(): Boolean = newFloatingBpsPrice != null - - fun isNewFloatingBulkBpsPrice(): Boolean = newFloatingBulkBpsPrice != null - - fun isNewFloatingBulkPrice(): Boolean = newFloatingBulkPrice != null - - fun isNewFloatingThresholdTotalAmountPrice(): Boolean = - newFloatingThresholdTotalAmountPrice != null - - fun isNewFloatingTieredPackagePrice(): Boolean = newFloatingTieredPackagePrice != null - - fun isNewFloatingGroupedTieredPrice(): Boolean = newFloatingGroupedTieredPrice != null - - fun isNewFloatingMaxGroupTieredPackagePrice(): Boolean = - newFloatingMaxGroupTieredPackagePrice != null - - fun isNewFloatingTieredWithMinimumPrice(): Boolean = - newFloatingTieredWithMinimumPrice != null - - fun isNewFloatingPackageWithAllocationPrice(): Boolean = - newFloatingPackageWithAllocationPrice != null - - fun isNewFloatingTieredPackageWithMinimumPrice(): Boolean = - newFloatingTieredPackageWithMinimumPrice != null - - fun isNewFloatingUnitWithPercentPrice(): Boolean = newFloatingUnitWithPercentPrice != null - - fun isNewFloatingTieredWithProrationPrice(): Boolean = - newFloatingTieredWithProrationPrice != null - - fun isNewFloatingUnitWithProrationPrice(): Boolean = - newFloatingUnitWithProrationPrice != null - - fun isNewFloatingGroupedAllocationPrice(): Boolean = - newFloatingGroupedAllocationPrice != null - - fun isNewFloatingGroupedWithProratedMinimumPrice(): Boolean = - newFloatingGroupedWithProratedMinimumPrice != null - - fun isNewFloatingGroupedWithMeteredMinimumPrice(): Boolean = - newFloatingGroupedWithMeteredMinimumPrice != null - - fun isNewFloatingMatrixWithDisplayNamePrice(): Boolean = - newFloatingMatrixWithDisplayNamePrice != null - - fun isNewFloatingBulkWithProrationPrice(): Boolean = - newFloatingBulkWithProrationPrice != null - - fun isNewFloatingGroupedTieredPackagePrice(): Boolean = - newFloatingGroupedTieredPackagePrice != null - - fun isNewFloatingScalableMatrixWithUnitPricingPrice(): Boolean = - newFloatingScalableMatrixWithUnitPricingPrice != null - - fun isNewFloatingScalableMatrixWithTieredPricingPrice(): Boolean = - newFloatingScalableMatrixWithTieredPricingPrice != null - - fun isNewFloatingCumulativeGroupedBulkPrice(): Boolean = - newFloatingCumulativeGroupedBulkPrice != null - - fun asNewFloatingUnitPrice(): NewFloatingUnitPrice = - newFloatingUnitPrice.getOrThrow("newFloatingUnitPrice") - - fun asNewFloatingPackagePrice(): NewFloatingPackagePrice = - newFloatingPackagePrice.getOrThrow("newFloatingPackagePrice") - - fun asNewFloatingMatrixPrice(): NewFloatingMatrixPrice = - newFloatingMatrixPrice.getOrThrow("newFloatingMatrixPrice") - - fun asNewFloatingMatrixWithAllocationPrice(): NewFloatingMatrixWithAllocationPrice = - newFloatingMatrixWithAllocationPrice.getOrThrow("newFloatingMatrixWithAllocationPrice") - - fun asNewFloatingTieredPrice(): NewFloatingTieredPrice = - newFloatingTieredPrice.getOrThrow("newFloatingTieredPrice") - - fun asNewFloatingTieredBpsPrice(): NewFloatingTieredBpsPrice = - newFloatingTieredBpsPrice.getOrThrow("newFloatingTieredBpsPrice") - - fun asNewFloatingBpsPrice(): NewFloatingBpsPrice = - newFloatingBpsPrice.getOrThrow("newFloatingBpsPrice") - - fun asNewFloatingBulkBpsPrice(): NewFloatingBulkBpsPrice = - newFloatingBulkBpsPrice.getOrThrow("newFloatingBulkBpsPrice") - - fun asNewFloatingBulkPrice(): NewFloatingBulkPrice = - newFloatingBulkPrice.getOrThrow("newFloatingBulkPrice") - - fun asNewFloatingThresholdTotalAmountPrice(): NewFloatingThresholdTotalAmountPrice = - newFloatingThresholdTotalAmountPrice.getOrThrow("newFloatingThresholdTotalAmountPrice") - - fun asNewFloatingTieredPackagePrice(): NewFloatingTieredPackagePrice = - newFloatingTieredPackagePrice.getOrThrow("newFloatingTieredPackagePrice") - - fun asNewFloatingGroupedTieredPrice(): NewFloatingGroupedTieredPrice = - newFloatingGroupedTieredPrice.getOrThrow("newFloatingGroupedTieredPrice") - - fun asNewFloatingMaxGroupTieredPackagePrice(): NewFloatingMaxGroupTieredPackagePrice = - newFloatingMaxGroupTieredPackagePrice.getOrThrow( - "newFloatingMaxGroupTieredPackagePrice" - ) - - fun asNewFloatingTieredWithMinimumPrice(): NewFloatingTieredWithMinimumPrice = - newFloatingTieredWithMinimumPrice.getOrThrow("newFloatingTieredWithMinimumPrice") - - fun asNewFloatingPackageWithAllocationPrice(): NewFloatingPackageWithAllocationPrice = - newFloatingPackageWithAllocationPrice.getOrThrow( - "newFloatingPackageWithAllocationPrice" - ) - - fun asNewFloatingTieredPackageWithMinimumPrice(): NewFloatingTieredPackageWithMinimumPrice = - newFloatingTieredPackageWithMinimumPrice.getOrThrow( - "newFloatingTieredPackageWithMinimumPrice" - ) - - fun asNewFloatingUnitWithPercentPrice(): NewFloatingUnitWithPercentPrice = - newFloatingUnitWithPercentPrice.getOrThrow("newFloatingUnitWithPercentPrice") - - fun asNewFloatingTieredWithProrationPrice(): NewFloatingTieredWithProrationPrice = - newFloatingTieredWithProrationPrice.getOrThrow("newFloatingTieredWithProrationPrice") - - fun asNewFloatingUnitWithProrationPrice(): NewFloatingUnitWithProrationPrice = - newFloatingUnitWithProrationPrice.getOrThrow("newFloatingUnitWithProrationPrice") - - fun asNewFloatingGroupedAllocationPrice(): NewFloatingGroupedAllocationPrice = - newFloatingGroupedAllocationPrice.getOrThrow("newFloatingGroupedAllocationPrice") - - fun asNewFloatingGroupedWithProratedMinimumPrice(): - NewFloatingGroupedWithProratedMinimumPrice = - newFloatingGroupedWithProratedMinimumPrice.getOrThrow( - "newFloatingGroupedWithProratedMinimumPrice" - ) - - fun asNewFloatingGroupedWithMeteredMinimumPrice(): - NewFloatingGroupedWithMeteredMinimumPrice = - newFloatingGroupedWithMeteredMinimumPrice.getOrThrow( - "newFloatingGroupedWithMeteredMinimumPrice" - ) - - fun asNewFloatingMatrixWithDisplayNamePrice(): NewFloatingMatrixWithDisplayNamePrice = - newFloatingMatrixWithDisplayNamePrice.getOrThrow( - "newFloatingMatrixWithDisplayNamePrice" - ) - - fun asNewFloatingBulkWithProrationPrice(): NewFloatingBulkWithProrationPrice = - newFloatingBulkWithProrationPrice.getOrThrow("newFloatingBulkWithProrationPrice") - - fun asNewFloatingGroupedTieredPackagePrice(): NewFloatingGroupedTieredPackagePrice = - newFloatingGroupedTieredPackagePrice.getOrThrow("newFloatingGroupedTieredPackagePrice") - - fun asNewFloatingScalableMatrixWithUnitPricingPrice(): - NewFloatingScalableMatrixWithUnitPricingPrice = - newFloatingScalableMatrixWithUnitPricingPrice.getOrThrow( - "newFloatingScalableMatrixWithUnitPricingPrice" - ) - - fun asNewFloatingScalableMatrixWithTieredPricingPrice(): - NewFloatingScalableMatrixWithTieredPricingPrice = - newFloatingScalableMatrixWithTieredPricingPrice.getOrThrow( - "newFloatingScalableMatrixWithTieredPricingPrice" - ) - - fun asNewFloatingCumulativeGroupedBulkPrice(): NewFloatingCumulativeGroupedBulkPrice = - newFloatingCumulativeGroupedBulkPrice.getOrThrow( - "newFloatingCumulativeGroupedBulkPrice" - ) - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - newFloatingUnitPrice != null -> - visitor.visitNewFloatingUnitPrice(newFloatingUnitPrice) - newFloatingPackagePrice != null -> - visitor.visitNewFloatingPackagePrice(newFloatingPackagePrice) - newFloatingMatrixPrice != null -> - visitor.visitNewFloatingMatrixPrice(newFloatingMatrixPrice) - newFloatingMatrixWithAllocationPrice != null -> - visitor.visitNewFloatingMatrixWithAllocationPrice( - newFloatingMatrixWithAllocationPrice - ) - newFloatingTieredPrice != null -> - visitor.visitNewFloatingTieredPrice(newFloatingTieredPrice) - newFloatingTieredBpsPrice != null -> - visitor.visitNewFloatingTieredBpsPrice(newFloatingTieredBpsPrice) - newFloatingBpsPrice != null -> visitor.visitNewFloatingBpsPrice(newFloatingBpsPrice) - newFloatingBulkBpsPrice != null -> - visitor.visitNewFloatingBulkBpsPrice(newFloatingBulkBpsPrice) - newFloatingBulkPrice != null -> - visitor.visitNewFloatingBulkPrice(newFloatingBulkPrice) - newFloatingThresholdTotalAmountPrice != null -> - visitor.visitNewFloatingThresholdTotalAmountPrice( - newFloatingThresholdTotalAmountPrice - ) - newFloatingTieredPackagePrice != null -> - visitor.visitNewFloatingTieredPackagePrice(newFloatingTieredPackagePrice) - newFloatingGroupedTieredPrice != null -> - visitor.visitNewFloatingGroupedTieredPrice(newFloatingGroupedTieredPrice) - newFloatingMaxGroupTieredPackagePrice != null -> - visitor.visitNewFloatingMaxGroupTieredPackagePrice( - newFloatingMaxGroupTieredPackagePrice - ) - newFloatingTieredWithMinimumPrice != null -> - visitor.visitNewFloatingTieredWithMinimumPrice( - newFloatingTieredWithMinimumPrice - ) - newFloatingPackageWithAllocationPrice != null -> - visitor.visitNewFloatingPackageWithAllocationPrice( - newFloatingPackageWithAllocationPrice - ) - newFloatingTieredPackageWithMinimumPrice != null -> - visitor.visitNewFloatingTieredPackageWithMinimumPrice( - newFloatingTieredPackageWithMinimumPrice - ) - newFloatingUnitWithPercentPrice != null -> - visitor.visitNewFloatingUnitWithPercentPrice(newFloatingUnitWithPercentPrice) - newFloatingTieredWithProrationPrice != null -> - visitor.visitNewFloatingTieredWithProrationPrice( - newFloatingTieredWithProrationPrice - ) - newFloatingUnitWithProrationPrice != null -> - visitor.visitNewFloatingUnitWithProrationPrice( - newFloatingUnitWithProrationPrice - ) - newFloatingGroupedAllocationPrice != null -> - visitor.visitNewFloatingGroupedAllocationPrice( - newFloatingGroupedAllocationPrice - ) - newFloatingGroupedWithProratedMinimumPrice != null -> - visitor.visitNewFloatingGroupedWithProratedMinimumPrice( - newFloatingGroupedWithProratedMinimumPrice - ) - newFloatingGroupedWithMeteredMinimumPrice != null -> - visitor.visitNewFloatingGroupedWithMeteredMinimumPrice( - newFloatingGroupedWithMeteredMinimumPrice - ) - newFloatingMatrixWithDisplayNamePrice != null -> - visitor.visitNewFloatingMatrixWithDisplayNamePrice( - newFloatingMatrixWithDisplayNamePrice - ) - newFloatingBulkWithProrationPrice != null -> - visitor.visitNewFloatingBulkWithProrationPrice( - newFloatingBulkWithProrationPrice - ) - newFloatingGroupedTieredPackagePrice != null -> - visitor.visitNewFloatingGroupedTieredPackagePrice( - newFloatingGroupedTieredPackagePrice - ) - newFloatingScalableMatrixWithUnitPricingPrice != null -> - visitor.visitNewFloatingScalableMatrixWithUnitPricingPrice( - newFloatingScalableMatrixWithUnitPricingPrice - ) - newFloatingScalableMatrixWithTieredPricingPrice != null -> - visitor.visitNewFloatingScalableMatrixWithTieredPricingPrice( - newFloatingScalableMatrixWithTieredPricingPrice - ) - newFloatingCumulativeGroupedBulkPrice != null -> - visitor.visitNewFloatingCumulativeGroupedBulkPrice( - newFloatingCumulativeGroupedBulkPrice - ) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitNewFloatingUnitPrice( - newFloatingUnitPrice: NewFloatingUnitPrice - ) { - newFloatingUnitPrice.validate() - } - - override fun visitNewFloatingPackagePrice( - newFloatingPackagePrice: NewFloatingPackagePrice - ) { - newFloatingPackagePrice.validate() - } - - override fun visitNewFloatingMatrixPrice( - newFloatingMatrixPrice: NewFloatingMatrixPrice - ) { - newFloatingMatrixPrice.validate() - } - - override fun visitNewFloatingMatrixWithAllocationPrice( - newFloatingMatrixWithAllocationPrice: NewFloatingMatrixWithAllocationPrice - ) { - newFloatingMatrixWithAllocationPrice.validate() - } - - override fun visitNewFloatingTieredPrice( - newFloatingTieredPrice: NewFloatingTieredPrice - ) { - newFloatingTieredPrice.validate() - } - - override fun visitNewFloatingTieredBpsPrice( - newFloatingTieredBpsPrice: NewFloatingTieredBpsPrice - ) { - newFloatingTieredBpsPrice.validate() - } - - override fun visitNewFloatingBpsPrice( - newFloatingBpsPrice: NewFloatingBpsPrice - ) { - newFloatingBpsPrice.validate() - } - - override fun visitNewFloatingBulkBpsPrice( - newFloatingBulkBpsPrice: NewFloatingBulkBpsPrice - ) { - newFloatingBulkBpsPrice.validate() - } - - override fun visitNewFloatingBulkPrice( - newFloatingBulkPrice: NewFloatingBulkPrice - ) { - newFloatingBulkPrice.validate() - } - - override fun visitNewFloatingThresholdTotalAmountPrice( - newFloatingThresholdTotalAmountPrice: NewFloatingThresholdTotalAmountPrice - ) { - newFloatingThresholdTotalAmountPrice.validate() - } - - override fun visitNewFloatingTieredPackagePrice( - newFloatingTieredPackagePrice: NewFloatingTieredPackagePrice - ) { - newFloatingTieredPackagePrice.validate() - } - - override fun visitNewFloatingGroupedTieredPrice( - newFloatingGroupedTieredPrice: NewFloatingGroupedTieredPrice - ) { - newFloatingGroupedTieredPrice.validate() - } - - override fun visitNewFloatingMaxGroupTieredPackagePrice( - newFloatingMaxGroupTieredPackagePrice: NewFloatingMaxGroupTieredPackagePrice - ) { - newFloatingMaxGroupTieredPackagePrice.validate() - } - - override fun visitNewFloatingTieredWithMinimumPrice( - newFloatingTieredWithMinimumPrice: NewFloatingTieredWithMinimumPrice - ) { - newFloatingTieredWithMinimumPrice.validate() - } - - override fun visitNewFloatingPackageWithAllocationPrice( - newFloatingPackageWithAllocationPrice: NewFloatingPackageWithAllocationPrice - ) { - newFloatingPackageWithAllocationPrice.validate() - } - - override fun visitNewFloatingTieredPackageWithMinimumPrice( - newFloatingTieredPackageWithMinimumPrice: - NewFloatingTieredPackageWithMinimumPrice - ) { - newFloatingTieredPackageWithMinimumPrice.validate() - } - - override fun visitNewFloatingUnitWithPercentPrice( - newFloatingUnitWithPercentPrice: NewFloatingUnitWithPercentPrice - ) { - newFloatingUnitWithPercentPrice.validate() - } - - override fun visitNewFloatingTieredWithProrationPrice( - newFloatingTieredWithProrationPrice: NewFloatingTieredWithProrationPrice - ) { - newFloatingTieredWithProrationPrice.validate() - } - - override fun visitNewFloatingUnitWithProrationPrice( - newFloatingUnitWithProrationPrice: NewFloatingUnitWithProrationPrice - ) { - newFloatingUnitWithProrationPrice.validate() - } - - override fun visitNewFloatingGroupedAllocationPrice( - newFloatingGroupedAllocationPrice: NewFloatingGroupedAllocationPrice - ) { - newFloatingGroupedAllocationPrice.validate() - } - - override fun visitNewFloatingGroupedWithProratedMinimumPrice( - newFloatingGroupedWithProratedMinimumPrice: - NewFloatingGroupedWithProratedMinimumPrice - ) { - newFloatingGroupedWithProratedMinimumPrice.validate() - } - - override fun visitNewFloatingGroupedWithMeteredMinimumPrice( - newFloatingGroupedWithMeteredMinimumPrice: - NewFloatingGroupedWithMeteredMinimumPrice - ) { - newFloatingGroupedWithMeteredMinimumPrice.validate() - } - - override fun visitNewFloatingMatrixWithDisplayNamePrice( - newFloatingMatrixWithDisplayNamePrice: NewFloatingMatrixWithDisplayNamePrice - ) { - newFloatingMatrixWithDisplayNamePrice.validate() - } - - override fun visitNewFloatingBulkWithProrationPrice( - newFloatingBulkWithProrationPrice: NewFloatingBulkWithProrationPrice - ) { - newFloatingBulkWithProrationPrice.validate() - } - - override fun visitNewFloatingGroupedTieredPackagePrice( - newFloatingGroupedTieredPackagePrice: NewFloatingGroupedTieredPackagePrice - ) { - newFloatingGroupedTieredPackagePrice.validate() - } - - override fun visitNewFloatingScalableMatrixWithUnitPricingPrice( - newFloatingScalableMatrixWithUnitPricingPrice: - NewFloatingScalableMatrixWithUnitPricingPrice - ) { - newFloatingScalableMatrixWithUnitPricingPrice.validate() - } - - override fun visitNewFloatingScalableMatrixWithTieredPricingPrice( - newFloatingScalableMatrixWithTieredPricingPrice: - NewFloatingScalableMatrixWithTieredPricingPrice - ) { - newFloatingScalableMatrixWithTieredPricingPrice.validate() - } - - override fun visitNewFloatingCumulativeGroupedBulkPrice( - newFloatingCumulativeGroupedBulkPrice: NewFloatingCumulativeGroupedBulkPrice - ) { - newFloatingCumulativeGroupedBulkPrice.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Body && newFloatingUnitPrice == other.newFloatingUnitPrice && newFloatingPackagePrice == other.newFloatingPackagePrice && newFloatingMatrixPrice == other.newFloatingMatrixPrice && newFloatingMatrixWithAllocationPrice == other.newFloatingMatrixWithAllocationPrice && newFloatingTieredPrice == other.newFloatingTieredPrice && newFloatingTieredBpsPrice == other.newFloatingTieredBpsPrice && newFloatingBpsPrice == other.newFloatingBpsPrice && newFloatingBulkBpsPrice == other.newFloatingBulkBpsPrice && newFloatingBulkPrice == other.newFloatingBulkPrice && newFloatingThresholdTotalAmountPrice == other.newFloatingThresholdTotalAmountPrice && newFloatingTieredPackagePrice == other.newFloatingTieredPackagePrice && newFloatingGroupedTieredPrice == other.newFloatingGroupedTieredPrice && newFloatingMaxGroupTieredPackagePrice == other.newFloatingMaxGroupTieredPackagePrice && newFloatingTieredWithMinimumPrice == other.newFloatingTieredWithMinimumPrice && newFloatingPackageWithAllocationPrice == other.newFloatingPackageWithAllocationPrice && newFloatingTieredPackageWithMinimumPrice == other.newFloatingTieredPackageWithMinimumPrice && newFloatingUnitWithPercentPrice == other.newFloatingUnitWithPercentPrice && newFloatingTieredWithProrationPrice == other.newFloatingTieredWithProrationPrice && newFloatingUnitWithProrationPrice == other.newFloatingUnitWithProrationPrice && newFloatingGroupedAllocationPrice == other.newFloatingGroupedAllocationPrice && newFloatingGroupedWithProratedMinimumPrice == other.newFloatingGroupedWithProratedMinimumPrice && newFloatingGroupedWithMeteredMinimumPrice == other.newFloatingGroupedWithMeteredMinimumPrice && newFloatingMatrixWithDisplayNamePrice == other.newFloatingMatrixWithDisplayNamePrice && newFloatingBulkWithProrationPrice == other.newFloatingBulkWithProrationPrice && newFloatingGroupedTieredPackagePrice == other.newFloatingGroupedTieredPackagePrice && newFloatingScalableMatrixWithUnitPricingPrice == other.newFloatingScalableMatrixWithUnitPricingPrice && newFloatingScalableMatrixWithTieredPricingPrice == other.newFloatingScalableMatrixWithTieredPricingPrice && newFloatingCumulativeGroupedBulkPrice == other.newFloatingCumulativeGroupedBulkPrice /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(newFloatingUnitPrice, newFloatingPackagePrice, newFloatingMatrixPrice, newFloatingMatrixWithAllocationPrice, newFloatingTieredPrice, newFloatingTieredBpsPrice, newFloatingBpsPrice, newFloatingBulkBpsPrice, newFloatingBulkPrice, newFloatingThresholdTotalAmountPrice, newFloatingTieredPackagePrice, newFloatingGroupedTieredPrice, newFloatingMaxGroupTieredPackagePrice, newFloatingTieredWithMinimumPrice, newFloatingPackageWithAllocationPrice, newFloatingTieredPackageWithMinimumPrice, newFloatingUnitWithPercentPrice, newFloatingTieredWithProrationPrice, newFloatingUnitWithProrationPrice, newFloatingGroupedAllocationPrice, newFloatingGroupedWithProratedMinimumPrice, newFloatingGroupedWithMeteredMinimumPrice, newFloatingMatrixWithDisplayNamePrice, newFloatingBulkWithProrationPrice, newFloatingGroupedTieredPackagePrice, newFloatingScalableMatrixWithUnitPricingPrice, newFloatingScalableMatrixWithTieredPricingPrice, newFloatingCumulativeGroupedBulkPrice) /* spotless:on */ - - override fun toString(): String = - when { - newFloatingUnitPrice != null -> "Body{newFloatingUnitPrice=$newFloatingUnitPrice}" - newFloatingPackagePrice != null -> - "Body{newFloatingPackagePrice=$newFloatingPackagePrice}" - newFloatingMatrixPrice != null -> - "Body{newFloatingMatrixPrice=$newFloatingMatrixPrice}" - newFloatingMatrixWithAllocationPrice != null -> - "Body{newFloatingMatrixWithAllocationPrice=$newFloatingMatrixWithAllocationPrice}" - newFloatingTieredPrice != null -> - "Body{newFloatingTieredPrice=$newFloatingTieredPrice}" - newFloatingTieredBpsPrice != null -> - "Body{newFloatingTieredBpsPrice=$newFloatingTieredBpsPrice}" - newFloatingBpsPrice != null -> "Body{newFloatingBpsPrice=$newFloatingBpsPrice}" - newFloatingBulkBpsPrice != null -> - "Body{newFloatingBulkBpsPrice=$newFloatingBulkBpsPrice}" - newFloatingBulkPrice != null -> "Body{newFloatingBulkPrice=$newFloatingBulkPrice}" - newFloatingThresholdTotalAmountPrice != null -> - "Body{newFloatingThresholdTotalAmountPrice=$newFloatingThresholdTotalAmountPrice}" - newFloatingTieredPackagePrice != null -> - "Body{newFloatingTieredPackagePrice=$newFloatingTieredPackagePrice}" - newFloatingGroupedTieredPrice != null -> - "Body{newFloatingGroupedTieredPrice=$newFloatingGroupedTieredPrice}" - newFloatingMaxGroupTieredPackagePrice != null -> - "Body{newFloatingMaxGroupTieredPackagePrice=$newFloatingMaxGroupTieredPackagePrice}" - newFloatingTieredWithMinimumPrice != null -> - "Body{newFloatingTieredWithMinimumPrice=$newFloatingTieredWithMinimumPrice}" - newFloatingPackageWithAllocationPrice != null -> - "Body{newFloatingPackageWithAllocationPrice=$newFloatingPackageWithAllocationPrice}" - newFloatingTieredPackageWithMinimumPrice != null -> - "Body{newFloatingTieredPackageWithMinimumPrice=$newFloatingTieredPackageWithMinimumPrice}" - newFloatingUnitWithPercentPrice != null -> - "Body{newFloatingUnitWithPercentPrice=$newFloatingUnitWithPercentPrice}" - newFloatingTieredWithProrationPrice != null -> - "Body{newFloatingTieredWithProrationPrice=$newFloatingTieredWithProrationPrice}" - newFloatingUnitWithProrationPrice != null -> - "Body{newFloatingUnitWithProrationPrice=$newFloatingUnitWithProrationPrice}" - newFloatingGroupedAllocationPrice != null -> - "Body{newFloatingGroupedAllocationPrice=$newFloatingGroupedAllocationPrice}" - newFloatingGroupedWithProratedMinimumPrice != null -> - "Body{newFloatingGroupedWithProratedMinimumPrice=$newFloatingGroupedWithProratedMinimumPrice}" - newFloatingGroupedWithMeteredMinimumPrice != null -> - "Body{newFloatingGroupedWithMeteredMinimumPrice=$newFloatingGroupedWithMeteredMinimumPrice}" - newFloatingMatrixWithDisplayNamePrice != null -> - "Body{newFloatingMatrixWithDisplayNamePrice=$newFloatingMatrixWithDisplayNamePrice}" - newFloatingBulkWithProrationPrice != null -> - "Body{newFloatingBulkWithProrationPrice=$newFloatingBulkWithProrationPrice}" - newFloatingGroupedTieredPackagePrice != null -> - "Body{newFloatingGroupedTieredPackagePrice=$newFloatingGroupedTieredPackagePrice}" - newFloatingScalableMatrixWithUnitPricingPrice != null -> - "Body{newFloatingScalableMatrixWithUnitPricingPrice=$newFloatingScalableMatrixWithUnitPricingPrice}" - newFloatingScalableMatrixWithTieredPricingPrice != null -> - "Body{newFloatingScalableMatrixWithTieredPricingPrice=$newFloatingScalableMatrixWithTieredPricingPrice}" - newFloatingCumulativeGroupedBulkPrice != null -> - "Body{newFloatingCumulativeGroupedBulkPrice=$newFloatingCumulativeGroupedBulkPrice}" - _json != null -> "Body{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Body") - } - - companion object { - - @JvmStatic - fun ofNewFloatingUnitPrice(newFloatingUnitPrice: NewFloatingUnitPrice) = - Body(newFloatingUnitPrice = newFloatingUnitPrice) - - @JvmStatic - fun ofNewFloatingPackagePrice(newFloatingPackagePrice: NewFloatingPackagePrice) = - Body(newFloatingPackagePrice = newFloatingPackagePrice) - - @JvmStatic - fun ofNewFloatingMatrixPrice(newFloatingMatrixPrice: NewFloatingMatrixPrice) = - Body(newFloatingMatrixPrice = newFloatingMatrixPrice) - - @JvmStatic - fun ofNewFloatingMatrixWithAllocationPrice( - newFloatingMatrixWithAllocationPrice: NewFloatingMatrixWithAllocationPrice - ) = Body(newFloatingMatrixWithAllocationPrice = newFloatingMatrixWithAllocationPrice) - - @JvmStatic - fun ofNewFloatingTieredPrice(newFloatingTieredPrice: NewFloatingTieredPrice) = - Body(newFloatingTieredPrice = newFloatingTieredPrice) - - @JvmStatic - fun ofNewFloatingTieredBpsPrice(newFloatingTieredBpsPrice: NewFloatingTieredBpsPrice) = - Body(newFloatingTieredBpsPrice = newFloatingTieredBpsPrice) - - @JvmStatic - fun ofNewFloatingBpsPrice(newFloatingBpsPrice: NewFloatingBpsPrice) = - Body(newFloatingBpsPrice = newFloatingBpsPrice) - - @JvmStatic - fun ofNewFloatingBulkBpsPrice(newFloatingBulkBpsPrice: NewFloatingBulkBpsPrice) = - Body(newFloatingBulkBpsPrice = newFloatingBulkBpsPrice) - - @JvmStatic - fun ofNewFloatingBulkPrice(newFloatingBulkPrice: NewFloatingBulkPrice) = - Body(newFloatingBulkPrice = newFloatingBulkPrice) - - @JvmStatic - fun ofNewFloatingThresholdTotalAmountPrice( - newFloatingThresholdTotalAmountPrice: NewFloatingThresholdTotalAmountPrice - ) = Body(newFloatingThresholdTotalAmountPrice = newFloatingThresholdTotalAmountPrice) - - @JvmStatic - fun ofNewFloatingTieredPackagePrice( - newFloatingTieredPackagePrice: NewFloatingTieredPackagePrice - ) = Body(newFloatingTieredPackagePrice = newFloatingTieredPackagePrice) - - @JvmStatic - fun ofNewFloatingGroupedTieredPrice( - newFloatingGroupedTieredPrice: NewFloatingGroupedTieredPrice - ) = Body(newFloatingGroupedTieredPrice = newFloatingGroupedTieredPrice) - - @JvmStatic - fun ofNewFloatingMaxGroupTieredPackagePrice( - newFloatingMaxGroupTieredPackagePrice: NewFloatingMaxGroupTieredPackagePrice - ) = Body(newFloatingMaxGroupTieredPackagePrice = newFloatingMaxGroupTieredPackagePrice) - - @JvmStatic - fun ofNewFloatingTieredWithMinimumPrice( - newFloatingTieredWithMinimumPrice: NewFloatingTieredWithMinimumPrice - ) = Body(newFloatingTieredWithMinimumPrice = newFloatingTieredWithMinimumPrice) - - @JvmStatic - fun ofNewFloatingPackageWithAllocationPrice( - newFloatingPackageWithAllocationPrice: NewFloatingPackageWithAllocationPrice - ) = Body(newFloatingPackageWithAllocationPrice = newFloatingPackageWithAllocationPrice) - - @JvmStatic - fun ofNewFloatingTieredPackageWithMinimumPrice( - newFloatingTieredPackageWithMinimumPrice: NewFloatingTieredPackageWithMinimumPrice - ) = - Body( - newFloatingTieredPackageWithMinimumPrice = - newFloatingTieredPackageWithMinimumPrice - ) - - @JvmStatic - fun ofNewFloatingUnitWithPercentPrice( - newFloatingUnitWithPercentPrice: NewFloatingUnitWithPercentPrice - ) = Body(newFloatingUnitWithPercentPrice = newFloatingUnitWithPercentPrice) - - @JvmStatic - fun ofNewFloatingTieredWithProrationPrice( - newFloatingTieredWithProrationPrice: NewFloatingTieredWithProrationPrice - ) = Body(newFloatingTieredWithProrationPrice = newFloatingTieredWithProrationPrice) - - @JvmStatic - fun ofNewFloatingUnitWithProrationPrice( - newFloatingUnitWithProrationPrice: NewFloatingUnitWithProrationPrice - ) = Body(newFloatingUnitWithProrationPrice = newFloatingUnitWithProrationPrice) - - @JvmStatic - fun ofNewFloatingGroupedAllocationPrice( - newFloatingGroupedAllocationPrice: NewFloatingGroupedAllocationPrice - ) = Body(newFloatingGroupedAllocationPrice = newFloatingGroupedAllocationPrice) - - @JvmStatic - fun ofNewFloatingGroupedWithProratedMinimumPrice( - newFloatingGroupedWithProratedMinimumPrice: - NewFloatingGroupedWithProratedMinimumPrice - ) = - Body( - newFloatingGroupedWithProratedMinimumPrice = - newFloatingGroupedWithProratedMinimumPrice - ) - - @JvmStatic - fun ofNewFloatingGroupedWithMeteredMinimumPrice( - newFloatingGroupedWithMeteredMinimumPrice: NewFloatingGroupedWithMeteredMinimumPrice - ) = - Body( - newFloatingGroupedWithMeteredMinimumPrice = - newFloatingGroupedWithMeteredMinimumPrice - ) - - @JvmStatic - fun ofNewFloatingMatrixWithDisplayNamePrice( - newFloatingMatrixWithDisplayNamePrice: NewFloatingMatrixWithDisplayNamePrice - ) = Body(newFloatingMatrixWithDisplayNamePrice = newFloatingMatrixWithDisplayNamePrice) - - @JvmStatic - fun ofNewFloatingBulkWithProrationPrice( - newFloatingBulkWithProrationPrice: NewFloatingBulkWithProrationPrice - ) = Body(newFloatingBulkWithProrationPrice = newFloatingBulkWithProrationPrice) - - @JvmStatic - fun ofNewFloatingGroupedTieredPackagePrice( - newFloatingGroupedTieredPackagePrice: NewFloatingGroupedTieredPackagePrice - ) = Body(newFloatingGroupedTieredPackagePrice = newFloatingGroupedTieredPackagePrice) - - @JvmStatic - fun ofNewFloatingScalableMatrixWithUnitPricingPrice( - newFloatingScalableMatrixWithUnitPricingPrice: - NewFloatingScalableMatrixWithUnitPricingPrice - ) = - Body( - newFloatingScalableMatrixWithUnitPricingPrice = - newFloatingScalableMatrixWithUnitPricingPrice - ) - - @JvmStatic - fun ofNewFloatingScalableMatrixWithTieredPricingPrice( - newFloatingScalableMatrixWithTieredPricingPrice: - NewFloatingScalableMatrixWithTieredPricingPrice - ) = - Body( - newFloatingScalableMatrixWithTieredPricingPrice = - newFloatingScalableMatrixWithTieredPricingPrice - ) - - @JvmStatic - fun ofNewFloatingCumulativeGroupedBulkPrice( - newFloatingCumulativeGroupedBulkPrice: NewFloatingCumulativeGroupedBulkPrice - ) = Body(newFloatingCumulativeGroupedBulkPrice = newFloatingCumulativeGroupedBulkPrice) - } - - /** An interface that defines how to map each variant of [Body] to a value of type [T]. */ - interface Visitor { - - fun visitNewFloatingUnitPrice(newFloatingUnitPrice: NewFloatingUnitPrice): T - - fun visitNewFloatingPackagePrice(newFloatingPackagePrice: NewFloatingPackagePrice): T - - fun visitNewFloatingMatrixPrice(newFloatingMatrixPrice: NewFloatingMatrixPrice): T - - fun visitNewFloatingMatrixWithAllocationPrice( - newFloatingMatrixWithAllocationPrice: NewFloatingMatrixWithAllocationPrice - ): T - - fun visitNewFloatingTieredPrice(newFloatingTieredPrice: NewFloatingTieredPrice): T - - fun visitNewFloatingTieredBpsPrice( - newFloatingTieredBpsPrice: NewFloatingTieredBpsPrice - ): T - - fun visitNewFloatingBpsPrice(newFloatingBpsPrice: NewFloatingBpsPrice): T - - fun visitNewFloatingBulkBpsPrice(newFloatingBulkBpsPrice: NewFloatingBulkBpsPrice): T - - fun visitNewFloatingBulkPrice(newFloatingBulkPrice: NewFloatingBulkPrice): T - - fun visitNewFloatingThresholdTotalAmountPrice( - newFloatingThresholdTotalAmountPrice: NewFloatingThresholdTotalAmountPrice - ): T - - fun visitNewFloatingTieredPackagePrice( - newFloatingTieredPackagePrice: NewFloatingTieredPackagePrice - ): T - - fun visitNewFloatingGroupedTieredPrice( - newFloatingGroupedTieredPrice: NewFloatingGroupedTieredPrice - ): T - - fun visitNewFloatingMaxGroupTieredPackagePrice( - newFloatingMaxGroupTieredPackagePrice: NewFloatingMaxGroupTieredPackagePrice - ): T - - fun visitNewFloatingTieredWithMinimumPrice( - newFloatingTieredWithMinimumPrice: NewFloatingTieredWithMinimumPrice - ): T - - fun visitNewFloatingPackageWithAllocationPrice( - newFloatingPackageWithAllocationPrice: NewFloatingPackageWithAllocationPrice - ): T - - fun visitNewFloatingTieredPackageWithMinimumPrice( - newFloatingTieredPackageWithMinimumPrice: NewFloatingTieredPackageWithMinimumPrice - ): T - - fun visitNewFloatingUnitWithPercentPrice( - newFloatingUnitWithPercentPrice: NewFloatingUnitWithPercentPrice - ): T - - fun visitNewFloatingTieredWithProrationPrice( - newFloatingTieredWithProrationPrice: NewFloatingTieredWithProrationPrice - ): T - - fun visitNewFloatingUnitWithProrationPrice( - newFloatingUnitWithProrationPrice: NewFloatingUnitWithProrationPrice - ): T - - fun visitNewFloatingGroupedAllocationPrice( - newFloatingGroupedAllocationPrice: NewFloatingGroupedAllocationPrice - ): T - - fun visitNewFloatingGroupedWithProratedMinimumPrice( - newFloatingGroupedWithProratedMinimumPrice: - NewFloatingGroupedWithProratedMinimumPrice - ): T - - fun visitNewFloatingGroupedWithMeteredMinimumPrice( - newFloatingGroupedWithMeteredMinimumPrice: NewFloatingGroupedWithMeteredMinimumPrice - ): T - - fun visitNewFloatingMatrixWithDisplayNamePrice( - newFloatingMatrixWithDisplayNamePrice: NewFloatingMatrixWithDisplayNamePrice - ): T - - fun visitNewFloatingBulkWithProrationPrice( - newFloatingBulkWithProrationPrice: NewFloatingBulkWithProrationPrice - ): T - - fun visitNewFloatingGroupedTieredPackagePrice( - newFloatingGroupedTieredPackagePrice: NewFloatingGroupedTieredPackagePrice - ): T - - fun visitNewFloatingScalableMatrixWithUnitPricingPrice( - newFloatingScalableMatrixWithUnitPricingPrice: - NewFloatingScalableMatrixWithUnitPricingPrice - ): T - - fun visitNewFloatingScalableMatrixWithTieredPricingPrice( - newFloatingScalableMatrixWithTieredPricingPrice: - NewFloatingScalableMatrixWithTieredPricingPrice - ): T - - fun visitNewFloatingCumulativeGroupedBulkPrice( - newFloatingCumulativeGroupedBulkPrice: NewFloatingCumulativeGroupedBulkPrice - ): T - - /** - * Maps an unknown variant of [Body] to a value of type [T]. - * - * An instance of [Body] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Body: $json") - } - } - - internal class Deserializer : BaseDeserializer(Body::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Body { - val json = JsonValue.fromJsonNode(node) - val modelType = - json.asObject().getOrNull()?.get("model_type")?.asString()?.getOrNull() - - when (modelType) { - "unit" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Body(newFloatingUnitPrice = it, _json = json) - } - } - "package" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Body(newFloatingPackagePrice = it, _json = json) - } - } - "matrix" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Body(newFloatingMatrixPrice = it, _json = json) - } - } - "matrix_with_allocation" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body(newFloatingMatrixWithAllocationPrice = it, _json = json) - } - } - "tiered" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Body(newFloatingTieredPrice = it, _json = json) - } - } - "tiered_bps" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Body(newFloatingTieredBpsPrice = it, _json = json) - } - } - "bps" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Body(newFloatingBpsPrice = it, _json = json) - } - } - "bulk_bps" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Body(newFloatingBulkBpsPrice = it, _json = json) - } - } - "bulk" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Body(newFloatingBulkPrice = it, _json = json) - } - } - "threshold_total_amount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body(newFloatingThresholdTotalAmountPrice = it, _json = json) - } - } - "tiered_package" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Body(newFloatingTieredPackagePrice = it, _json = json) - } - } - "grouped_tiered" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Body(newFloatingGroupedTieredPrice = it, _json = json) - } - } - "max_group_tiered_package" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body( - newFloatingMaxGroupTieredPackagePrice = it, - _json = json, - ) - } - } - "tiered_with_minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Body(newFloatingTieredWithMinimumPrice = it, _json = json) - } - } - "package_with_allocation" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body( - newFloatingPackageWithAllocationPrice = it, - _json = json, - ) - } - } - "tiered_package_with_minimum" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body( - newFloatingTieredPackageWithMinimumPrice = it, - _json = json, - ) - } - } - "unit_with_percent" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Body(newFloatingUnitWithPercentPrice = it, _json = json) - } - } - "tiered_with_proration" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body(newFloatingTieredWithProrationPrice = it, _json = json) - } - } - "unit_with_proration" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Body(newFloatingUnitWithProrationPrice = it, _json = json) - } - } - "grouped_allocation" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Body(newFloatingGroupedAllocationPrice = it, _json = json) - } - } - "grouped_with_prorated_minimum" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body( - newFloatingGroupedWithProratedMinimumPrice = it, - _json = json, - ) - } - } - "grouped_with_metered_minimum" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body( - newFloatingGroupedWithMeteredMinimumPrice = it, - _json = json, - ) - } - } - "matrix_with_display_name" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body( - newFloatingMatrixWithDisplayNamePrice = it, - _json = json, - ) - } - } - "bulk_with_proration" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Body(newFloatingBulkWithProrationPrice = it, _json = json) - } - } - "grouped_tiered_package" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body(newFloatingGroupedTieredPackagePrice = it, _json = json) - } - } - "scalable_matrix_with_unit_pricing" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body( - newFloatingScalableMatrixWithUnitPricingPrice = it, - _json = json, - ) - } - } - "scalable_matrix_with_tiered_pricing" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body( - newFloatingScalableMatrixWithTieredPricingPrice = it, - _json = json, - ) - } - } - "cumulative_grouped_bulk" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Body( - newFloatingCumulativeGroupedBulkPrice = it, - _json = json, - ) - } - } - } - - return Body(_json = json) - } - } - - internal class Serializer : BaseSerializer(Body::class) { - - override fun serialize( - value: Body, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.newFloatingUnitPrice != null -> - generator.writeObject(value.newFloatingUnitPrice) - value.newFloatingPackagePrice != null -> - generator.writeObject(value.newFloatingPackagePrice) - value.newFloatingMatrixPrice != null -> - generator.writeObject(value.newFloatingMatrixPrice) - value.newFloatingMatrixWithAllocationPrice != null -> - generator.writeObject(value.newFloatingMatrixWithAllocationPrice) - value.newFloatingTieredPrice != null -> - generator.writeObject(value.newFloatingTieredPrice) - value.newFloatingTieredBpsPrice != null -> - generator.writeObject(value.newFloatingTieredBpsPrice) - value.newFloatingBpsPrice != null -> - generator.writeObject(value.newFloatingBpsPrice) - value.newFloatingBulkBpsPrice != null -> - generator.writeObject(value.newFloatingBulkBpsPrice) - value.newFloatingBulkPrice != null -> - generator.writeObject(value.newFloatingBulkPrice) - value.newFloatingThresholdTotalAmountPrice != null -> - generator.writeObject(value.newFloatingThresholdTotalAmountPrice) - value.newFloatingTieredPackagePrice != null -> - generator.writeObject(value.newFloatingTieredPackagePrice) - value.newFloatingGroupedTieredPrice != null -> - generator.writeObject(value.newFloatingGroupedTieredPrice) - value.newFloatingMaxGroupTieredPackagePrice != null -> - generator.writeObject(value.newFloatingMaxGroupTieredPackagePrice) - value.newFloatingTieredWithMinimumPrice != null -> - generator.writeObject(value.newFloatingTieredWithMinimumPrice) - value.newFloatingPackageWithAllocationPrice != null -> - generator.writeObject(value.newFloatingPackageWithAllocationPrice) - value.newFloatingTieredPackageWithMinimumPrice != null -> - generator.writeObject(value.newFloatingTieredPackageWithMinimumPrice) - value.newFloatingUnitWithPercentPrice != null -> - generator.writeObject(value.newFloatingUnitWithPercentPrice) - value.newFloatingTieredWithProrationPrice != null -> - generator.writeObject(value.newFloatingTieredWithProrationPrice) - value.newFloatingUnitWithProrationPrice != null -> - generator.writeObject(value.newFloatingUnitWithProrationPrice) - value.newFloatingGroupedAllocationPrice != null -> - generator.writeObject(value.newFloatingGroupedAllocationPrice) - value.newFloatingGroupedWithProratedMinimumPrice != null -> - generator.writeObject(value.newFloatingGroupedWithProratedMinimumPrice) - value.newFloatingGroupedWithMeteredMinimumPrice != null -> - generator.writeObject(value.newFloatingGroupedWithMeteredMinimumPrice) - value.newFloatingMatrixWithDisplayNamePrice != null -> - generator.writeObject(value.newFloatingMatrixWithDisplayNamePrice) - value.newFloatingBulkWithProrationPrice != null -> - generator.writeObject(value.newFloatingBulkWithProrationPrice) - value.newFloatingGroupedTieredPackagePrice != null -> - generator.writeObject(value.newFloatingGroupedTieredPackagePrice) - value.newFloatingScalableMatrixWithUnitPricingPrice != null -> - generator.writeObject(value.newFloatingScalableMatrixWithUnitPricingPrice) - value.newFloatingScalableMatrixWithTieredPricingPrice != null -> - generator.writeObject(value.newFloatingScalableMatrixWithTieredPricingPrice) - value.newFloatingCumulativeGroupedBulkPrice != null -> - generator.writeObject(value.newFloatingCumulativeGroupedBulkPrice) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Body") - } - } - } - - @NoAutoDetect - class NewFloatingUnitPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("unit_config") - @ExcludeMissing - private val unitConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun unitConfig(): UnitConfig = unitConfig.getRequired("unit_config") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("unit_config") - @ExcludeMissing - fun _unitConfig(): JsonField = unitConfig - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingUnitPrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - itemId() - modelType() - name() - unitConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingUnitPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var 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 externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newFloatingUnitPrice: NewFloatingUnitPrice) = apply { - cadence = newFloatingUnitPrice.cadence - currency = newFloatingUnitPrice.currency - itemId = newFloatingUnitPrice.itemId - modelType = newFloatingUnitPrice.modelType - name = newFloatingUnitPrice.name - unitConfig = newFloatingUnitPrice.unitConfig - billableMetricId = newFloatingUnitPrice.billableMetricId - billedInAdvance = newFloatingUnitPrice.billedInAdvance - billingCycleConfiguration = newFloatingUnitPrice.billingCycleConfiguration - conversionRate = newFloatingUnitPrice.conversionRate - externalPriceId = newFloatingUnitPrice.externalPriceId - fixedPriceQuantity = newFloatingUnitPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingUnitPrice.invoiceGroupingKey - invoicingCycleConfiguration = newFloatingUnitPrice.invoicingCycleConfiguration - metadata = newFloatingUnitPrice.metadata - additionalProperties = newFloatingUnitPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) - - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingUnitPrice = - NewFloatingUnitPrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("unitConfig", unitConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class UnitConfig - @JsonCreator - private constructor( - @JsonProperty("unit_amount") - @ExcludeMissing - private val unitAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Rate per unit of usage */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** Rate per unit of usage */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): UnitConfig = apply { - if (validated) { - return@apply - } - - unitAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnitConfig]. */ - class Builder internal constructor() { - - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unitConfig: UnitConfig) = apply { - unitAmount = unitConfig.unitAmount - additionalProperties = unitConfig.additionalProperties.toMutableMap() - } - - /** Rate per unit of usage */ - fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - - /** Rate per unit of usage */ - 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 build(): UnitConfig = - UnitConfig( - checkRequired("unitAmount", unitAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UnitConfig && unitAmount == other.unitAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(unitAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnitConfig{unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingUnitPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && unitConfig == other.unitConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, unitConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingUnitPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingPackagePrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("package_config") - @ExcludeMissing - private val packageConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun packageConfig(): PackageConfig = packageConfig.getRequired("package_config") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("package_config") - @ExcludeMissing - fun _packageConfig(): JsonField = packageConfig - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingPackagePrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - itemId() - modelType() - name() - packageConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingPackagePrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var packageConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newFloatingPackagePrice: NewFloatingPackagePrice) = apply { - cadence = newFloatingPackagePrice.cadence - currency = newFloatingPackagePrice.currency - itemId = newFloatingPackagePrice.itemId - modelType = newFloatingPackagePrice.modelType - name = newFloatingPackagePrice.name - packageConfig = newFloatingPackagePrice.packageConfig - billableMetricId = newFloatingPackagePrice.billableMetricId - billedInAdvance = newFloatingPackagePrice.billedInAdvance - billingCycleConfiguration = newFloatingPackagePrice.billingCycleConfiguration - conversionRate = newFloatingPackagePrice.conversionRate - externalPriceId = newFloatingPackagePrice.externalPriceId - fixedPriceQuantity = newFloatingPackagePrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingPackagePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingPackagePrice.invoicingCycleConfiguration - metadata = newFloatingPackagePrice.metadata - additionalProperties = - newFloatingPackagePrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun packageConfig(packageConfig: PackageConfig) = - packageConfig(JsonField.of(packageConfig)) - - fun packageConfig(packageConfig: JsonField) = apply { - this.packageConfig = packageConfig - } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingPackagePrice = - NewFloatingPackagePrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("packageConfig", packageConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val PACKAGE = of("package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - PACKAGE - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PACKAGE, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PACKAGE -> Value.PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PACKAGE -> Known.PACKAGE - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class PackageConfig - @JsonCreator - private constructor( - @JsonProperty("package_amount") - @ExcludeMissing - private val packageAmount: JsonField = JsonMissing.of(), - @JsonProperty("package_size") - @ExcludeMissing - private val packageSize: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** A currency amount to rate usage by */ - fun packageAmount(): String = packageAmount.getRequired("package_amount") - - /** - * An integer amount to represent package size. For example, 1000 here would divide - * usage by 1000 before multiplying by package_amount in rating - */ - fun packageSize(): Long = packageSize.getRequired("package_size") - - /** A currency amount to rate usage by */ - @JsonProperty("package_amount") - @ExcludeMissing - fun _packageAmount(): JsonField = packageAmount - - /** - * An integer amount to represent package size. For example, 1000 here would divide - * usage by 1000 before multiplying by package_amount in rating - */ - @JsonProperty("package_size") - @ExcludeMissing - fun _packageSize(): JsonField = packageSize - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PackageConfig = apply { - if (validated) { - return@apply - } - - packageAmount() - packageSize() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PackageConfig]. */ - class Builder internal constructor() { - - private var packageAmount: JsonField? = null - private var packageSize: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(packageConfig: PackageConfig) = apply { - packageAmount = packageConfig.packageAmount - packageSize = packageConfig.packageSize - additionalProperties = packageConfig.additionalProperties.toMutableMap() - } - - /** A currency amount to rate usage by */ - fun packageAmount(packageAmount: String) = - packageAmount(JsonField.of(packageAmount)) - - /** A currency amount to rate usage by */ - fun packageAmount(packageAmount: JsonField) = apply { - this.packageAmount = packageAmount - } - - /** - * An integer amount to represent package size. For example, 1000 here would - * divide usage by 1000 before multiplying by package_amount in rating - */ - fun packageSize(packageSize: Long) = packageSize(JsonField.of(packageSize)) - - /** - * An integer amount to represent package size. For example, 1000 here would - * divide usage by 1000 before multiplying by package_amount in rating - */ - fun packageSize(packageSize: JsonField) = apply { - this.packageSize = packageSize - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PackageConfig = - PackageConfig( - checkRequired("packageAmount", packageAmount), - checkRequired("packageSize", packageSize), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PackageConfig && packageAmount == other.packageAmount && packageSize == other.packageSize && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(packageAmount, packageSize, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PackageConfig{packageAmount=$packageAmount, packageSize=$packageSize, additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingPackagePrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && packageConfig == other.packageConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, packageConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingPackagePrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingMatrixPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("matrix_config") - @ExcludeMissing - private val matrixConfig: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_config") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("matrix_config") - @ExcludeMissing - fun _matrixConfig(): JsonField = matrixConfig - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingMatrixPrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - itemId() - matrixConfig().validate() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingMatrixPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var matrixConfig: JsonField? = null - private var modelType: JsonField? = null - private var 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 externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newFloatingMatrixPrice: NewFloatingMatrixPrice) = apply { - cadence = newFloatingMatrixPrice.cadence - currency = newFloatingMatrixPrice.currency - itemId = newFloatingMatrixPrice.itemId - matrixConfig = newFloatingMatrixPrice.matrixConfig - modelType = newFloatingMatrixPrice.modelType - name = newFloatingMatrixPrice.name - billableMetricId = newFloatingMatrixPrice.billableMetricId - billedInAdvance = newFloatingMatrixPrice.billedInAdvance - billingCycleConfiguration = newFloatingMatrixPrice.billingCycleConfiguration - conversionRate = newFloatingMatrixPrice.conversionRate - externalPriceId = newFloatingMatrixPrice.externalPriceId - fixedPriceQuantity = newFloatingMatrixPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingMatrixPrice.invoiceGroupingKey - invoicingCycleConfiguration = newFloatingMatrixPrice.invoicingCycleConfiguration - metadata = newFloatingMatrixPrice.metadata - additionalProperties = - newFloatingMatrixPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun matrixConfig(matrixConfig: MatrixConfig) = - matrixConfig(JsonField.of(matrixConfig)) - - fun matrixConfig(matrixConfig: JsonField) = apply { - this.matrixConfig = matrixConfig - } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingMatrixPrice = - NewFloatingMatrixPrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("matrixConfig", matrixConfig), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class MatrixConfig - @JsonCreator - private constructor( - @JsonProperty("default_unit_amount") - @ExcludeMissing - private val defaultUnitAmount: JsonField = JsonMissing.of(), - @JsonProperty("dimensions") - @ExcludeMissing - private val dimensions: JsonField> = JsonMissing.of(), - @JsonProperty("matrix_values") - @ExcludeMissing - private val matrixValues: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * Default per unit rate for any usage not bucketed into a specified matrix_value - */ - fun defaultUnitAmount(): String = - defaultUnitAmount.getRequired("default_unit_amount") - - /** One or two event property values to evaluate matrix groups by */ - fun dimensions(): List = dimensions.getRequired("dimensions") - - /** Matrix values for specified matrix grouping keys */ - fun matrixValues(): List = matrixValues.getRequired("matrix_values") - - /** - * Default per unit rate for any usage not bucketed into a specified matrix_value - */ - @JsonProperty("default_unit_amount") - @ExcludeMissing - fun _defaultUnitAmount(): JsonField = defaultUnitAmount - - /** One or two event property values to evaluate matrix groups by */ - @JsonProperty("dimensions") - @ExcludeMissing - fun _dimensions(): JsonField> = dimensions - - /** Matrix values for specified matrix grouping keys */ - @JsonProperty("matrix_values") - @ExcludeMissing - fun _matrixValues(): JsonField> = matrixValues - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MatrixConfig = apply { - if (validated) { - return@apply - } - - defaultUnitAmount() - dimensions() - matrixValues().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MatrixConfig]. */ - class Builder internal constructor() { - - private var defaultUnitAmount: JsonField? = null - private var dimensions: JsonField>? = null - private var matrixValues: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(matrixConfig: MatrixConfig) = apply { - defaultUnitAmount = matrixConfig.defaultUnitAmount - dimensions = matrixConfig.dimensions.map { it.toMutableList() } - matrixValues = matrixConfig.matrixValues.map { it.toMutableList() } - additionalProperties = matrixConfig.additionalProperties.toMutableMap() - } - - /** - * Default per unit rate for any usage not bucketed into a specified - * matrix_value - */ - fun defaultUnitAmount(defaultUnitAmount: String) = - defaultUnitAmount(JsonField.of(defaultUnitAmount)) - - /** - * Default per unit rate for any usage not bucketed into a specified - * matrix_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)) - - /** One or two event property values to evaluate matrix groups by */ - fun dimensions(dimensions: JsonField>) = apply { - this.dimensions = dimensions.map { it.toMutableList() } - } - - /** One or two event property values to evaluate matrix groups by */ - fun addDimension(dimension: String) = apply { - dimensions = - (dimensions ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimension) - } - } - - /** Matrix values for specified matrix grouping keys */ - fun matrixValues(matrixValues: List) = - matrixValues(JsonField.of(matrixValues)) - - /** Matrix values for specified matrix grouping keys */ - fun matrixValues(matrixValues: JsonField>) = apply { - this.matrixValues = matrixValues.map { it.toMutableList() } - } - - /** Matrix values for specified matrix grouping keys */ - fun addMatrixValue(matrixValue: MatrixValue) = apply { - matrixValues = - (matrixValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): MatrixConfig = - MatrixConfig( - checkRequired("defaultUnitAmount", defaultUnitAmount), - checkRequired("dimensions", dimensions).map { it.toImmutable() }, - checkRequired("matrixValues", matrixValues).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class MatrixValue - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - private val unitAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * One or two matrix keys to filter usage to this Matrix value by. For example, - * ["region", "tier"] could be used to filter cloud usage by a cloud region and - * an instance tier. - */ - fun dimensionValues(): List = - dimensionValues.getRequired("dimension_values") - - /** Unit price for the specified dimension_values */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** - * One or two matrix keys to filter usage to this Matrix value by. For example, - * ["region", "tier"] could be used to filter cloud usage by a cloud region and - * an instance tier. - */ - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - /** Unit price for the specified dimension_values */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MatrixValue = apply { - if (validated) { - return@apply - } - - dimensionValues() - unitAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MatrixValue]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(matrixValue: MatrixValue) = apply { - dimensionValues = matrixValue.dimensionValues.map { it.toMutableList() } - unitAmount = matrixValue.unitAmount - additionalProperties = matrixValue.additionalProperties.toMutableMap() - } - - /** - * One or two matrix keys to filter usage to this Matrix value by. For - * example, ["region", "tier"] could be used to filter cloud usage by a - * cloud region and an instance tier. - */ - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - /** - * One or two matrix keys to filter usage to this Matrix value by. For - * example, ["region", "tier"] could be used to filter cloud usage by a - * cloud region and an instance tier. - */ - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - /** - * One or two matrix keys to filter usage to this Matrix value by. For - * example, ["region", "tier"] could be used to filter cloud usage by a - * cloud region and an instance tier. - */ - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - /** Unit price for the specified dimension_values */ - fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - - /** Unit price for the specified dimension_values */ - 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 build(): MatrixValue = - MatrixValue( - checkRequired("dimensionValues", dimensionValues).map { - it.toImmutable() - }, - checkRequired("unitAmount", unitAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MatrixValue && dimensionValues == other.dimensionValues && unitAmount == other.unitAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, unitAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MatrixValue{dimensionValues=$dimensionValues, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MatrixConfig && defaultUnitAmount == other.defaultUnitAmount && dimensions == other.dimensions && matrixValues == other.matrixValues && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(defaultUnitAmount, dimensions, matrixValues, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MatrixConfig{defaultUnitAmount=$defaultUnitAmount, dimensions=$dimensions, matrixValues=$matrixValues, additionalProperties=$additionalProperties}" - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val MATRIX = of("matrix") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MATRIX - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MATRIX, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MATRIX -> Value.MATRIX - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - MATRIX -> Known.MATRIX - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingMatrixPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && matrixConfig == other.matrixConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, matrixConfig, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingMatrixPrice{cadence=$cadence, currency=$currency, itemId=$itemId, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingMatrixWithAllocationPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("matrix_with_allocation_config") - @ExcludeMissing - private val matrixWithAllocationConfig: JsonField = - JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun matrixWithAllocationConfig(): MatrixWithAllocationConfig = - matrixWithAllocationConfig.getRequired("matrix_with_allocation_config") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("matrix_with_allocation_config") - @ExcludeMissing - fun _matrixWithAllocationConfig(): JsonField = - matrixWithAllocationConfig - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingMatrixWithAllocationPrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - itemId() - matrixWithAllocationConfig().validate() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingMatrixWithAllocationPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var matrixWithAllocationConfig: JsonField? = - null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newFloatingMatrixWithAllocationPrice: NewFloatingMatrixWithAllocationPrice - ) = apply { - cadence = newFloatingMatrixWithAllocationPrice.cadence - currency = newFloatingMatrixWithAllocationPrice.currency - itemId = newFloatingMatrixWithAllocationPrice.itemId - matrixWithAllocationConfig = - newFloatingMatrixWithAllocationPrice.matrixWithAllocationConfig - modelType = newFloatingMatrixWithAllocationPrice.modelType - name = newFloatingMatrixWithAllocationPrice.name - billableMetricId = newFloatingMatrixWithAllocationPrice.billableMetricId - billedInAdvance = newFloatingMatrixWithAllocationPrice.billedInAdvance - billingCycleConfiguration = - newFloatingMatrixWithAllocationPrice.billingCycleConfiguration - conversionRate = newFloatingMatrixWithAllocationPrice.conversionRate - externalPriceId = newFloatingMatrixWithAllocationPrice.externalPriceId - fixedPriceQuantity = newFloatingMatrixWithAllocationPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingMatrixWithAllocationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingMatrixWithAllocationPrice.invoicingCycleConfiguration - metadata = newFloatingMatrixWithAllocationPrice.metadata - additionalProperties = - newFloatingMatrixWithAllocationPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun matrixWithAllocationConfig( - matrixWithAllocationConfig: MatrixWithAllocationConfig - ) = matrixWithAllocationConfig(JsonField.of(matrixWithAllocationConfig)) - - fun matrixWithAllocationConfig( - matrixWithAllocationConfig: JsonField - ) = apply { this.matrixWithAllocationConfig = matrixWithAllocationConfig } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingMatrixWithAllocationPrice = - NewFloatingMatrixWithAllocationPrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("matrixWithAllocationConfig", matrixWithAllocationConfig), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class MatrixWithAllocationConfig - @JsonCreator - private constructor( - @JsonProperty("allocation") - @ExcludeMissing - private val allocation: JsonField = JsonMissing.of(), - @JsonProperty("default_unit_amount") - @ExcludeMissing - private val defaultUnitAmount: JsonField = JsonMissing.of(), - @JsonProperty("dimensions") - @ExcludeMissing - private val dimensions: JsonField> = JsonMissing.of(), - @JsonProperty("matrix_values") - @ExcludeMissing - private val matrixValues: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Allocation to be used to calculate the price */ - fun allocation(): Double = allocation.getRequired("allocation") - - /** - * Default per unit rate for any usage not bucketed into a specified matrix_value - */ - fun defaultUnitAmount(): String = - defaultUnitAmount.getRequired("default_unit_amount") - - /** One or two event property values to evaluate matrix groups by */ - fun dimensions(): List = dimensions.getRequired("dimensions") - - /** Matrix values for specified matrix grouping keys */ - fun matrixValues(): List = matrixValues.getRequired("matrix_values") - - /** Allocation to be used to calculate the price */ - @JsonProperty("allocation") - @ExcludeMissing - fun _allocation(): JsonField = allocation - - /** - * Default per unit rate for any usage not bucketed into a specified matrix_value - */ - @JsonProperty("default_unit_amount") - @ExcludeMissing - fun _defaultUnitAmount(): JsonField = defaultUnitAmount - - /** One or two event property values to evaluate matrix groups by */ - @JsonProperty("dimensions") - @ExcludeMissing - fun _dimensions(): JsonField> = dimensions - - /** Matrix values for specified matrix grouping keys */ - @JsonProperty("matrix_values") - @ExcludeMissing - fun _matrixValues(): JsonField> = matrixValues - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MatrixWithAllocationConfig = apply { - if (validated) { - return@apply - } - - allocation() - defaultUnitAmount() - dimensions() - matrixValues().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MatrixWithAllocationConfig]. */ - class Builder internal constructor() { - - private var allocation: JsonField? = null - private var defaultUnitAmount: JsonField? = null - private var dimensions: JsonField>? = null - private var matrixValues: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(matrixWithAllocationConfig: MatrixWithAllocationConfig) = - apply { - allocation = matrixWithAllocationConfig.allocation - defaultUnitAmount = matrixWithAllocationConfig.defaultUnitAmount - dimensions = - matrixWithAllocationConfig.dimensions.map { it.toMutableList() } - matrixValues = - matrixWithAllocationConfig.matrixValues.map { it.toMutableList() } - additionalProperties = - matrixWithAllocationConfig.additionalProperties.toMutableMap() - } - - /** Allocation to be used to calculate the price */ - fun allocation(allocation: Double) = allocation(JsonField.of(allocation)) - - /** Allocation to be used to calculate the price */ - fun allocation(allocation: JsonField) = apply { - this.allocation = allocation - } - - /** - * Default per unit rate for any usage not bucketed into a specified - * matrix_value - */ - fun defaultUnitAmount(defaultUnitAmount: String) = - defaultUnitAmount(JsonField.of(defaultUnitAmount)) - - /** - * Default per unit rate for any usage not bucketed into a specified - * matrix_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)) - - /** One or two event property values to evaluate matrix groups by */ - fun dimensions(dimensions: JsonField>) = apply { - this.dimensions = dimensions.map { it.toMutableList() } - } - - /** One or two event property values to evaluate matrix groups by */ - fun addDimension(dimension: String) = apply { - dimensions = - (dimensions ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimension) - } - } - - /** Matrix values for specified matrix grouping keys */ - fun matrixValues(matrixValues: List) = - matrixValues(JsonField.of(matrixValues)) - - /** Matrix values for specified matrix grouping keys */ - fun matrixValues(matrixValues: JsonField>) = apply { - this.matrixValues = matrixValues.map { it.toMutableList() } - } - - /** Matrix values for specified matrix grouping keys */ - fun addMatrixValue(matrixValue: MatrixValue) = apply { - matrixValues = - (matrixValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): MatrixWithAllocationConfig = - MatrixWithAllocationConfig( - checkRequired("allocation", allocation), - checkRequired("defaultUnitAmount", defaultUnitAmount), - checkRequired("dimensions", dimensions).map { it.toImmutable() }, - checkRequired("matrixValues", matrixValues).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class MatrixValue - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - private val unitAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * One or two matrix keys to filter usage to this Matrix value by. For example, - * ["region", "tier"] could be used to filter cloud usage by a cloud region and - * an instance tier. - */ - fun dimensionValues(): List = - dimensionValues.getRequired("dimension_values") - - /** Unit price for the specified dimension_values */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** - * One or two matrix keys to filter usage to this Matrix value by. For example, - * ["region", "tier"] could be used to filter cloud usage by a cloud region and - * an instance tier. - */ - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - /** Unit price for the specified dimension_values */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MatrixValue = apply { - if (validated) { - return@apply - } - - dimensionValues() - unitAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MatrixValue]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(matrixValue: MatrixValue) = apply { - dimensionValues = matrixValue.dimensionValues.map { it.toMutableList() } - unitAmount = matrixValue.unitAmount - additionalProperties = matrixValue.additionalProperties.toMutableMap() - } - - /** - * One or two matrix keys to filter usage to this Matrix value by. For - * example, ["region", "tier"] could be used to filter cloud usage by a - * cloud region and an instance tier. - */ - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - /** - * One or two matrix keys to filter usage to this Matrix value by. For - * example, ["region", "tier"] could be used to filter cloud usage by a - * cloud region and an instance tier. - */ - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - /** - * One or two matrix keys to filter usage to this Matrix value by. For - * example, ["region", "tier"] could be used to filter cloud usage by a - * cloud region and an instance tier. - */ - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - /** Unit price for the specified dimension_values */ - fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - - /** Unit price for the specified dimension_values */ - 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 build(): MatrixValue = - MatrixValue( - checkRequired("dimensionValues", dimensionValues).map { - it.toImmutable() - }, - checkRequired("unitAmount", unitAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MatrixValue && dimensionValues == other.dimensionValues && unitAmount == other.unitAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, unitAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MatrixValue{dimensionValues=$dimensionValues, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MatrixWithAllocationConfig && allocation == other.allocation && defaultUnitAmount == other.defaultUnitAmount && dimensions == other.dimensions && matrixValues == other.matrixValues && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allocation, defaultUnitAmount, dimensions, matrixValues, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MatrixWithAllocationConfig{allocation=$allocation, defaultUnitAmount=$defaultUnitAmount, dimensions=$dimensions, matrixValues=$matrixValues, additionalProperties=$additionalProperties}" - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val MATRIX_WITH_ALLOCATION = of("matrix_with_allocation") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MATRIX_WITH_ALLOCATION - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MATRIX_WITH_ALLOCATION, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MATRIX_WITH_ALLOCATION -> Value.MATRIX_WITH_ALLOCATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - MATRIX_WITH_ALLOCATION -> Known.MATRIX_WITH_ALLOCATION - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingMatrixWithAllocationPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && matrixWithAllocationConfig == other.matrixWithAllocationConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, matrixWithAllocationConfig, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingMatrixWithAllocationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, matrixWithAllocationConfig=$matrixWithAllocationConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingTieredPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_config") - @ExcludeMissing - private val tieredConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun tieredConfig(): TieredConfig = tieredConfig.getRequired("tiered_config") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("tiered_config") - @ExcludeMissing - fun _tieredConfig(): JsonField = tieredConfig - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingTieredPrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - itemId() - modelType() - name() - tieredConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingTieredPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var tieredConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newFloatingTieredPrice: NewFloatingTieredPrice) = apply { - cadence = newFloatingTieredPrice.cadence - currency = newFloatingTieredPrice.currency - itemId = newFloatingTieredPrice.itemId - modelType = newFloatingTieredPrice.modelType - name = newFloatingTieredPrice.name - tieredConfig = newFloatingTieredPrice.tieredConfig - billableMetricId = newFloatingTieredPrice.billableMetricId - billedInAdvance = newFloatingTieredPrice.billedInAdvance - billingCycleConfiguration = newFloatingTieredPrice.billingCycleConfiguration - conversionRate = newFloatingTieredPrice.conversionRate - externalPriceId = newFloatingTieredPrice.externalPriceId - fixedPriceQuantity = newFloatingTieredPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingTieredPrice.invoiceGroupingKey - invoicingCycleConfiguration = newFloatingTieredPrice.invoicingCycleConfiguration - metadata = newFloatingTieredPrice.metadata - additionalProperties = - newFloatingTieredPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredConfig(tieredConfig: TieredConfig) = - tieredConfig(JsonField.of(tieredConfig)) - - fun tieredConfig(tieredConfig: JsonField) = apply { - this.tieredConfig = tieredConfig - } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingTieredPrice = - NewFloatingTieredPrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("tieredConfig", tieredConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED = of("tiered") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED -> Value.TIERED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - TIERED -> Known.TIERED - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TieredConfig - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - private val tiers: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Tiers for rating based on total usage quantities into the specified tier */ - fun tiers(): List = tiers.getRequired("tiers") - - /** Tiers for rating based on total usage quantities into the specified tier */ - @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredConfig = apply { - if (validated) { - return@apply - } - - tiers().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tieredConfig: TieredConfig) = apply { - tiers = tieredConfig.tiers.map { it.toMutableList() } - additionalProperties = tieredConfig.additionalProperties.toMutableMap() - } - - /** Tiers for rating based on total usage quantities into the specified tier */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - - /** Tiers for rating based on total usage quantities into the specified tier */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** Tiers for rating based on total usage quantities into the specified tier */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): TieredConfig = - TieredConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Tier - @JsonCreator - private constructor( - @JsonProperty("first_unit") - @ExcludeMissing - private val firstUnit: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - private val unitAmount: JsonField = JsonMissing.of(), - @JsonProperty("last_unit") - @ExcludeMissing - private val lastUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Inclusive tier starting value */ - fun firstUnit(): Double = firstUnit.getRequired("first_unit") - - /** Amount per unit */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** Exclusive tier ending value. If null, this is treated as the last tier */ - fun lastUnit(): Optional = - Optional.ofNullable(lastUnit.getNullable("last_unit")) - - /** Inclusive tier starting value */ - @JsonProperty("first_unit") - @ExcludeMissing - fun _firstUnit(): JsonField = firstUnit - - /** Amount per unit */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - /** Exclusive tier ending value. If null, this is treated as the last tier */ - @JsonProperty("last_unit") - @ExcludeMissing - fun _lastUnit(): JsonField = lastUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - firstUnit() - unitAmount() - lastUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var firstUnit: JsonField? = null - private var unitAmount: JsonField? = null - private var lastUnit: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - firstUnit = tier.firstUnit - unitAmount = tier.unitAmount - lastUnit = tier.lastUnit - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Inclusive tier starting value */ - fun firstUnit(firstUnit: Double) = firstUnit(JsonField.of(firstUnit)) - - /** Inclusive tier starting value */ - fun firstUnit(firstUnit: JsonField) = apply { - this.firstUnit = firstUnit - } - - /** Amount per unit */ - fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - - /** Amount per unit */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - /** - * Exclusive tier ending value. If null, this is treated as the last tier - */ - fun lastUnit(lastUnit: Double?) = lastUnit(JsonField.ofNullable(lastUnit)) - - /** - * Exclusive tier ending value. If null, this is treated as the last tier - */ - fun lastUnit(lastUnit: Double) = lastUnit(lastUnit as Double?) - - /** - * Exclusive tier ending value. If null, this is treated as the last tier - */ - @Suppress( - "USELESS_CAST" - ) // See https://youtrack.jetbrains.com/issue/KT-74228 - fun lastUnit(lastUnit: Optional) = - lastUnit(lastUnit.orElse(null) as Double?) - - /** - * Exclusive tier ending value. If null, this is treated as the last tier - */ - fun lastUnit(lastUnit: JsonField) = apply { - this.lastUnit = lastUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Tier = - Tier( - checkRequired("firstUnit", firstUnit), - checkRequired("unitAmount", unitAmount), - lastUnit, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tier && firstUnit == other.firstUnit && unitAmount == other.unitAmount && lastUnit == other.lastUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(firstUnit, unitAmount, lastUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{firstUnit=$firstUnit, unitAmount=$unitAmount, lastUnit=$lastUnit, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredConfig && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredConfig{tiers=$tiers, additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingTieredPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredConfig == other.tieredConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, tieredConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingTieredPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingTieredBpsPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_bps_config") - @ExcludeMissing - private val tieredBpsConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun tieredBpsConfig(): TieredBpsConfig = - tieredBpsConfig.getRequired("tiered_bps_config") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("tiered_bps_config") - @ExcludeMissing - fun _tieredBpsConfig(): JsonField = tieredBpsConfig - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingTieredBpsPrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - itemId() - modelType() - name() - tieredBpsConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingTieredBpsPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var tieredBpsConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newFloatingTieredBpsPrice: NewFloatingTieredBpsPrice) = apply { - cadence = newFloatingTieredBpsPrice.cadence - currency = newFloatingTieredBpsPrice.currency - itemId = newFloatingTieredBpsPrice.itemId - modelType = newFloatingTieredBpsPrice.modelType - name = newFloatingTieredBpsPrice.name - tieredBpsConfig = newFloatingTieredBpsPrice.tieredBpsConfig - billableMetricId = newFloatingTieredBpsPrice.billableMetricId - billedInAdvance = newFloatingTieredBpsPrice.billedInAdvance - billingCycleConfiguration = newFloatingTieredBpsPrice.billingCycleConfiguration - conversionRate = newFloatingTieredBpsPrice.conversionRate - externalPriceId = newFloatingTieredBpsPrice.externalPriceId - fixedPriceQuantity = newFloatingTieredBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingTieredBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingTieredBpsPrice.invoicingCycleConfiguration - metadata = newFloatingTieredBpsPrice.metadata - additionalProperties = - newFloatingTieredBpsPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredBpsConfig(tieredBpsConfig: TieredBpsConfig) = - tieredBpsConfig(JsonField.of(tieredBpsConfig)) - - fun tieredBpsConfig(tieredBpsConfig: JsonField) = apply { - this.tieredBpsConfig = tieredBpsConfig - } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingTieredBpsPrice = - NewFloatingTieredBpsPrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("tieredBpsConfig", tieredBpsConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED_BPS = of("tiered_bps") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_BPS -> Value.TIERED_BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - TIERED_BPS -> Known.TIERED_BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TieredBpsConfig - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - private val tiers: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into specified - * tiers - */ - fun tiers(): List = tiers.getRequired("tiers") - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into specified - * tiers - */ - @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredBpsConfig = apply { - if (validated) { - return@apply - } - - tiers().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredBpsConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tieredBpsConfig: TieredBpsConfig) = apply { - tiers = tieredBpsConfig.tiers.map { it.toMutableList() } - additionalProperties = tieredBpsConfig.additionalProperties.toMutableMap() - } - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into - * specified tiers - */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into - * specified tiers - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into - * specified tiers - */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): TieredBpsConfig = - TieredBpsConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Tier - @JsonCreator - private constructor( - @JsonProperty("bps") - @ExcludeMissing - private val bps: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_maximum") - @ExcludeMissing - private val perUnitMaximum: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Per-event basis point rate */ - fun bps(): Double = bps.getRequired("bps") - - /** Inclusive tier starting value */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** Exclusive tier ending value */ - fun maximumAmount(): Optional = - Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - - /** Per unit maximum to charge */ - fun perUnitMaximum(): Optional = - Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) - - /** Per-event basis point rate */ - @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps - - /** Inclusive tier starting value */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** Exclusive tier ending value */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** Per unit maximum to charge */ - @JsonProperty("per_unit_maximum") - @ExcludeMissing - fun _perUnitMaximum(): JsonField = perUnitMaximum - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - bps() - minimumAmount() - maximumAmount() - perUnitMaximum() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var bps: JsonField? = null - private var minimumAmount: JsonField? = null - private var maximumAmount: JsonField = JsonMissing.of() - private var perUnitMaximum: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - bps = tier.bps - minimumAmount = tier.minimumAmount - maximumAmount = tier.maximumAmount - perUnitMaximum = tier.perUnitMaximum - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Per-event basis point rate */ - fun bps(bps: Double) = bps(JsonField.of(bps)) - - /** Per-event basis point rate */ - fun bps(bps: JsonField) = apply { this.bps = bps } - - /** Inclusive tier starting value */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** Inclusive tier starting value */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** Exclusive tier ending value */ - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - /** Exclusive tier ending value */ - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.orElse(null)) - - /** Exclusive tier ending value */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** Per unit maximum to charge */ - fun perUnitMaximum(perUnitMaximum: String?) = - perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) - - /** Per unit maximum to charge */ - fun perUnitMaximum(perUnitMaximum: Optional) = - perUnitMaximum(perUnitMaximum.orElse(null)) - - /** Per unit maximum to charge */ - fun perUnitMaximum(perUnitMaximum: JsonField) = apply { - this.perUnitMaximum = perUnitMaximum - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): Tier = - Tier( - checkRequired("bps", bps), - checkRequired("minimumAmount", minimumAmount), - maximumAmount, - perUnitMaximum, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tier && bps == other.bps && minimumAmount == other.minimumAmount && maximumAmount == other.maximumAmount && perUnitMaximum == other.perUnitMaximum && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bps, minimumAmount, maximumAmount, perUnitMaximum, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{bps=$bps, minimumAmount=$minimumAmount, maximumAmount=$maximumAmount, perUnitMaximum=$perUnitMaximum, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredBpsConfig && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredBpsConfig{tiers=$tiers, additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingTieredBpsPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredBpsConfig == other.tieredBpsConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, tieredBpsConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingTieredBpsPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredBpsConfig=$tieredBpsConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingBpsPrice - @JsonCreator - private constructor( - @JsonProperty("bps_config") - @ExcludeMissing - private val bpsConfig: JsonField = JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun bpsConfig(): BpsConfig = bpsConfig.getRequired("bps_config") - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - @JsonProperty("bps_config") - @ExcludeMissing - fun _bpsConfig(): JsonField = bpsConfig - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingBpsPrice = apply { - if (validated) { - return@apply - } - - bpsConfig().validate() - cadence() - currency() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingBpsPrice]. */ - class Builder internal constructor() { - - private var bpsConfig: JsonField? = null - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newFloatingBpsPrice: NewFloatingBpsPrice) = apply { - bpsConfig = newFloatingBpsPrice.bpsConfig - cadence = newFloatingBpsPrice.cadence - currency = newFloatingBpsPrice.currency - itemId = newFloatingBpsPrice.itemId - modelType = newFloatingBpsPrice.modelType - name = newFloatingBpsPrice.name - billableMetricId = newFloatingBpsPrice.billableMetricId - billedInAdvance = newFloatingBpsPrice.billedInAdvance - billingCycleConfiguration = newFloatingBpsPrice.billingCycleConfiguration - conversionRate = newFloatingBpsPrice.conversionRate - externalPriceId = newFloatingBpsPrice.externalPriceId - fixedPriceQuantity = newFloatingBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = newFloatingBpsPrice.invoicingCycleConfiguration - metadata = newFloatingBpsPrice.metadata - additionalProperties = newFloatingBpsPrice.additionalProperties.toMutableMap() - } - - fun bpsConfig(bpsConfig: BpsConfig) = bpsConfig(JsonField.of(bpsConfig)) - - fun bpsConfig(bpsConfig: JsonField) = apply { - this.bpsConfig = bpsConfig - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingBpsPrice = - NewFloatingBpsPrice( - checkRequired("bpsConfig", bpsConfig), - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BpsConfig - @JsonCreator - private constructor( - @JsonProperty("bps") - @ExcludeMissing - private val bps: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_maximum") - @ExcludeMissing - private val perUnitMaximum: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Basis point take rate per event */ - fun bps(): Double = bps.getRequired("bps") - - /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(): Optional = - Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) - - /** Basis point take rate per event */ - @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps - - /** Optional currency amount maximum to cap spend per event */ - @JsonProperty("per_unit_maximum") - @ExcludeMissing - fun _perUnitMaximum(): JsonField = perUnitMaximum - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BpsConfig = apply { - if (validated) { - return@apply - } - - bps() - perUnitMaximum() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BpsConfig]. */ - class Builder internal constructor() { - - private var bps: JsonField? = null - private var perUnitMaximum: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(bpsConfig: BpsConfig) = apply { - bps = bpsConfig.bps - perUnitMaximum = bpsConfig.perUnitMaximum - additionalProperties = bpsConfig.additionalProperties.toMutableMap() - } - - /** Basis point take rate per event */ - fun bps(bps: Double) = bps(JsonField.of(bps)) - - /** Basis point take rate per event */ - fun bps(bps: JsonField) = apply { this.bps = bps } - - /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(perUnitMaximum: String?) = - perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) - - /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(perUnitMaximum: Optional) = - perUnitMaximum(perUnitMaximum.orElse(null)) - - /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(perUnitMaximum: JsonField) = apply { - this.perUnitMaximum = perUnitMaximum - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): BpsConfig = - BpsConfig( - checkRequired("bps", bps), - perUnitMaximum, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BpsConfig && bps == other.bps && perUnitMaximum == other.perUnitMaximum && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bps, perUnitMaximum, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BpsConfig{bps=$bps, perUnitMaximum=$perUnitMaximum, additionalProperties=$additionalProperties}" - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val BPS = of("bps") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BPS -> Value.BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - BPS -> Known.BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingBpsPrice && bpsConfig == other.bpsConfig && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bpsConfig, cadence, currency, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingBpsPrice{bpsConfig=$bpsConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingBulkBpsPrice - @JsonCreator - private constructor( - @JsonProperty("bulk_bps_config") - @ExcludeMissing - private val bulkBpsConfig: JsonField = JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun bulkBpsConfig(): BulkBpsConfig = bulkBpsConfig.getRequired("bulk_bps_config") - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - @JsonProperty("bulk_bps_config") - @ExcludeMissing - fun _bulkBpsConfig(): JsonField = bulkBpsConfig - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingBulkBpsPrice = apply { - if (validated) { - return@apply - } - - bulkBpsConfig().validate() - cadence() - currency() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingBulkBpsPrice]. */ - class Builder internal constructor() { - - private var bulkBpsConfig: JsonField? = null - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newFloatingBulkBpsPrice: NewFloatingBulkBpsPrice) = apply { - bulkBpsConfig = newFloatingBulkBpsPrice.bulkBpsConfig - cadence = newFloatingBulkBpsPrice.cadence - currency = newFloatingBulkBpsPrice.currency - itemId = newFloatingBulkBpsPrice.itemId - modelType = newFloatingBulkBpsPrice.modelType - name = newFloatingBulkBpsPrice.name - billableMetricId = newFloatingBulkBpsPrice.billableMetricId - billedInAdvance = newFloatingBulkBpsPrice.billedInAdvance - billingCycleConfiguration = newFloatingBulkBpsPrice.billingCycleConfiguration - conversionRate = newFloatingBulkBpsPrice.conversionRate - externalPriceId = newFloatingBulkBpsPrice.externalPriceId - fixedPriceQuantity = newFloatingBulkBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingBulkBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingBulkBpsPrice.invoicingCycleConfiguration - metadata = newFloatingBulkBpsPrice.metadata - additionalProperties = - newFloatingBulkBpsPrice.additionalProperties.toMutableMap() - } - - fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfig) = - bulkBpsConfig(JsonField.of(bulkBpsConfig)) - - fun bulkBpsConfig(bulkBpsConfig: JsonField) = apply { - this.bulkBpsConfig = bulkBpsConfig - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingBulkBpsPrice = - NewFloatingBulkBpsPrice( - checkRequired("bulkBpsConfig", bulkBpsConfig), - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BulkBpsConfig - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - private val tiers: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a single tier - * based on total volume - */ - fun tiers(): List = tiers.getRequired("tiers") - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a single tier - * based on total volume - */ - @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BulkBpsConfig = apply { - if (validated) { - return@apply - } - - tiers().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkBpsConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(bulkBpsConfig: BulkBpsConfig) = apply { - tiers = bulkBpsConfig.tiers.map { it.toMutableList() } - additionalProperties = bulkBpsConfig.additionalProperties.toMutableMap() - } - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a single - * tier based on total volume - */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a single - * tier based on total volume - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a single - * tier based on total volume - */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): BulkBpsConfig = - BulkBpsConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Tier - @JsonCreator - private constructor( - @JsonProperty("bps") - @ExcludeMissing - private val bps: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_maximum") - @ExcludeMissing - private val perUnitMaximum: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Basis points to rate on */ - fun bps(): Double = bps.getRequired("bps") - - /** Upper bound for tier */ - fun maximumAmount(): Optional = - Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(): Optional = - Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) - - /** Basis points to rate on */ - @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps - - /** Upper bound for tier */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** The maximum amount to charge for any one event */ - @JsonProperty("per_unit_maximum") - @ExcludeMissing - fun _perUnitMaximum(): JsonField = perUnitMaximum - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - bps() - maximumAmount() - perUnitMaximum() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var bps: JsonField? = null - private var maximumAmount: JsonField = JsonMissing.of() - private var perUnitMaximum: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - bps = tier.bps - maximumAmount = tier.maximumAmount - perUnitMaximum = tier.perUnitMaximum - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Basis points to rate on */ - fun bps(bps: Double) = bps(JsonField.of(bps)) - - /** Basis points to rate on */ - fun bps(bps: JsonField) = apply { this.bps = bps } - - /** Upper bound for tier */ - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - /** Upper bound for tier */ - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.orElse(null)) - - /** Upper bound for tier */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(perUnitMaximum: String?) = - perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) - - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(perUnitMaximum: Optional) = - perUnitMaximum(perUnitMaximum.orElse(null)) - - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(perUnitMaximum: JsonField) = apply { - this.perUnitMaximum = perUnitMaximum - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): Tier = - Tier( - checkRequired("bps", bps), - maximumAmount, - perUnitMaximum, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tier && bps == other.bps && maximumAmount == other.maximumAmount && perUnitMaximum == other.perUnitMaximum && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bps, maximumAmount, perUnitMaximum, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{bps=$bps, maximumAmount=$maximumAmount, perUnitMaximum=$perUnitMaximum, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BulkBpsConfig && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkBpsConfig{tiers=$tiers, additionalProperties=$additionalProperties}" - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val BULK_BPS = of("bulk_bps") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK_BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK_BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK_BPS -> Value.BULK_BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - BULK_BPS -> Known.BULK_BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingBulkBpsPrice && bulkBpsConfig == other.bulkBpsConfig && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bulkBpsConfig, cadence, currency, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingBulkBpsPrice{bulkBpsConfig=$bulkBpsConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingBulkPrice - @JsonCreator - private constructor( - @JsonProperty("bulk_config") - @ExcludeMissing - private val bulkConfig: JsonField = JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun bulkConfig(): BulkConfig = bulkConfig.getRequired("bulk_config") - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - @JsonProperty("bulk_config") - @ExcludeMissing - fun _bulkConfig(): JsonField = bulkConfig - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingBulkPrice = apply { - if (validated) { - return@apply - } - - bulkConfig().validate() - cadence() - currency() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingBulkPrice]. */ - class Builder internal constructor() { - - private var bulkConfig: JsonField? = null - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var 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 externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newFloatingBulkPrice: NewFloatingBulkPrice) = apply { - bulkConfig = newFloatingBulkPrice.bulkConfig - cadence = newFloatingBulkPrice.cadence - currency = newFloatingBulkPrice.currency - itemId = newFloatingBulkPrice.itemId - modelType = newFloatingBulkPrice.modelType - name = newFloatingBulkPrice.name - billableMetricId = newFloatingBulkPrice.billableMetricId - billedInAdvance = newFloatingBulkPrice.billedInAdvance - billingCycleConfiguration = newFloatingBulkPrice.billingCycleConfiguration - conversionRate = newFloatingBulkPrice.conversionRate - externalPriceId = newFloatingBulkPrice.externalPriceId - fixedPriceQuantity = newFloatingBulkPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingBulkPrice.invoiceGroupingKey - invoicingCycleConfiguration = newFloatingBulkPrice.invoicingCycleConfiguration - metadata = newFloatingBulkPrice.metadata - additionalProperties = newFloatingBulkPrice.additionalProperties.toMutableMap() - } - - fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) - - fun bulkConfig(bulkConfig: JsonField) = apply { - this.bulkConfig = bulkConfig - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingBulkPrice = - NewFloatingBulkPrice( - checkRequired("bulkConfig", bulkConfig), - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BulkConfig - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - private val tiers: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Bulk tiers for rating based on total usage volume */ - fun tiers(): List = tiers.getRequired("tiers") - - /** Bulk tiers for rating based on total usage volume */ - @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BulkConfig = apply { - if (validated) { - return@apply - } - - tiers().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(bulkConfig: BulkConfig) = apply { - tiers = bulkConfig.tiers.map { it.toMutableList() } - additionalProperties = bulkConfig.additionalProperties.toMutableMap() - } - - /** Bulk tiers for rating based on total usage volume */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - - /** Bulk tiers for rating based on total usage volume */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** Bulk tiers for rating based on total usage volume */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): BulkConfig = - BulkConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Tier - @JsonCreator - private constructor( - @JsonProperty("unit_amount") - @ExcludeMissing - private val unitAmount: JsonField = JsonMissing.of(), - @JsonProperty("maximum_units") - @ExcludeMissing - private val maximumUnits: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Amount per unit */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** Upper bound for this tier */ - fun maximumUnits(): Optional = - Optional.ofNullable(maximumUnits.getNullable("maximum_units")) - - /** Amount per unit */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - /** Upper bound for this tier */ - @JsonProperty("maximum_units") - @ExcludeMissing - fun _maximumUnits(): JsonField = maximumUnits - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - unitAmount() - maximumUnits() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var unitAmount: JsonField? = null - private var maximumUnits: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - unitAmount = tier.unitAmount - maximumUnits = tier.maximumUnits - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Amount per unit */ - fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - - /** Amount per unit */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - /** Upper bound for this tier */ - fun maximumUnits(maximumUnits: Double?) = - maximumUnits(JsonField.ofNullable(maximumUnits)) - - /** Upper bound for this tier */ - fun maximumUnits(maximumUnits: Double) = - maximumUnits(maximumUnits as Double?) - - /** Upper bound for this tier */ - @Suppress( - "USELESS_CAST" - ) // See https://youtrack.jetbrains.com/issue/KT-74228 - fun maximumUnits(maximumUnits: Optional) = - maximumUnits(maximumUnits.orElse(null) as Double?) - - /** Upper bound for this tier */ - fun maximumUnits(maximumUnits: JsonField) = apply { - this.maximumUnits = maximumUnits - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Tier = - Tier( - checkRequired("unitAmount", unitAmount), - maximumUnits, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tier && unitAmount == other.unitAmount && maximumUnits == other.maximumUnits && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(unitAmount, maximumUnits, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{unitAmount=$unitAmount, maximumUnits=$maximumUnits, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BulkConfig && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkConfig{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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val BULK = of("bulk") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK -> Value.BULK - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - BULK -> Known.BULK - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingBulkPrice && bulkConfig == other.bulkConfig && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bulkConfig, cadence, currency, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingBulkPrice{bulkConfig=$bulkConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingThresholdTotalAmountPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("threshold_total_amount_config") - @ExcludeMissing - private val thresholdTotalAmountConfig: JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun thresholdTotalAmountConfig(): ThresholdTotalAmountConfig = - thresholdTotalAmountConfig.getRequired("threshold_total_amount_config") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("threshold_total_amount_config") - @ExcludeMissing - fun _thresholdTotalAmountConfig(): JsonField = - thresholdTotalAmountConfig - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingThresholdTotalAmountPrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - itemId() - modelType() - name() - thresholdTotalAmountConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingThresholdTotalAmountPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var thresholdTotalAmountConfig: JsonField? = - null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newFloatingThresholdTotalAmountPrice: NewFloatingThresholdTotalAmountPrice - ) = apply { - cadence = newFloatingThresholdTotalAmountPrice.cadence - currency = newFloatingThresholdTotalAmountPrice.currency - itemId = newFloatingThresholdTotalAmountPrice.itemId - modelType = newFloatingThresholdTotalAmountPrice.modelType - name = newFloatingThresholdTotalAmountPrice.name - thresholdTotalAmountConfig = - newFloatingThresholdTotalAmountPrice.thresholdTotalAmountConfig - billableMetricId = newFloatingThresholdTotalAmountPrice.billableMetricId - billedInAdvance = newFloatingThresholdTotalAmountPrice.billedInAdvance - billingCycleConfiguration = - newFloatingThresholdTotalAmountPrice.billingCycleConfiguration - conversionRate = newFloatingThresholdTotalAmountPrice.conversionRate - externalPriceId = newFloatingThresholdTotalAmountPrice.externalPriceId - fixedPriceQuantity = newFloatingThresholdTotalAmountPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingThresholdTotalAmountPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingThresholdTotalAmountPrice.invoicingCycleConfiguration - metadata = newFloatingThresholdTotalAmountPrice.metadata - additionalProperties = - newFloatingThresholdTotalAmountPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun thresholdTotalAmountConfig( - thresholdTotalAmountConfig: ThresholdTotalAmountConfig - ) = thresholdTotalAmountConfig(JsonField.of(thresholdTotalAmountConfig)) - - fun thresholdTotalAmountConfig( - thresholdTotalAmountConfig: JsonField - ) = apply { this.thresholdTotalAmountConfig = thresholdTotalAmountConfig } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingThresholdTotalAmountPrice = - NewFloatingThresholdTotalAmountPrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("thresholdTotalAmountConfig", thresholdTotalAmountConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val THRESHOLD_TOTAL_AMOUNT = of("threshold_total_amount") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - THRESHOLD_TOTAL_AMOUNT - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - THRESHOLD_TOTAL_AMOUNT, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - THRESHOLD_TOTAL_AMOUNT -> Value.THRESHOLD_TOTAL_AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - THRESHOLD_TOTAL_AMOUNT -> Known.THRESHOLD_TOTAL_AMOUNT - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class ThresholdTotalAmountConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): ThresholdTotalAmountConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ThresholdTotalAmountConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(thresholdTotalAmountConfig: ThresholdTotalAmountConfig) = - apply { - additionalProperties = - thresholdTotalAmountConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): ThresholdTotalAmountConfig = - ThresholdTotalAmountConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ThresholdTotalAmountConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ThresholdTotalAmountConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingThresholdTotalAmountPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, thresholdTotalAmountConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingThresholdTotalAmountPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingTieredPackagePrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_package_config") - @ExcludeMissing - private val tieredPackageConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun tieredPackageConfig(): TieredPackageConfig = - tieredPackageConfig.getRequired("tiered_package_config") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("tiered_package_config") - @ExcludeMissing - fun _tieredPackageConfig(): JsonField = tieredPackageConfig - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingTieredPackagePrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - itemId() - modelType() - name() - tieredPackageConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingTieredPackagePrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var tieredPackageConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newFloatingTieredPackagePrice: NewFloatingTieredPackagePrice) = - apply { - cadence = newFloatingTieredPackagePrice.cadence - currency = newFloatingTieredPackagePrice.currency - itemId = newFloatingTieredPackagePrice.itemId - modelType = newFloatingTieredPackagePrice.modelType - name = newFloatingTieredPackagePrice.name - tieredPackageConfig = newFloatingTieredPackagePrice.tieredPackageConfig - billableMetricId = newFloatingTieredPackagePrice.billableMetricId - billedInAdvance = newFloatingTieredPackagePrice.billedInAdvance - billingCycleConfiguration = - newFloatingTieredPackagePrice.billingCycleConfiguration - conversionRate = newFloatingTieredPackagePrice.conversionRate - externalPriceId = newFloatingTieredPackagePrice.externalPriceId - fixedPriceQuantity = newFloatingTieredPackagePrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingTieredPackagePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingTieredPackagePrice.invoicingCycleConfiguration - metadata = newFloatingTieredPackagePrice.metadata - additionalProperties = - newFloatingTieredPackagePrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = - tieredPackageConfig(JsonField.of(tieredPackageConfig)) - - fun tieredPackageConfig(tieredPackageConfig: JsonField) = - apply { - this.tieredPackageConfig = tieredPackageConfig - } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingTieredPackagePrice = - NewFloatingTieredPackagePrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("tieredPackageConfig", tieredPackageConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED_PACKAGE = of("tiered_package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_PACKAGE - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_PACKAGE, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_PACKAGE -> Value.TIERED_PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - TIERED_PACKAGE -> Known.TIERED_PACKAGE - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TieredPackageConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredPackageConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredPackageConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tieredPackageConfig: TieredPackageConfig) = apply { - additionalProperties = - tieredPackageConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): TieredPackageConfig = - TieredPackageConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredPackageConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingTieredPackagePrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredPackageConfig == other.tieredPackageConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, tieredPackageConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingTieredPackagePrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingGroupedTieredPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("grouped_tiered_config") - @ExcludeMissing - private val groupedTieredConfig: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - fun groupedTieredConfig(): GroupedTieredConfig = - groupedTieredConfig.getRequired("grouped_tiered_config") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonProperty("grouped_tiered_config") - @ExcludeMissing - fun _groupedTieredConfig(): JsonField = groupedTieredConfig - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingGroupedTieredPrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - groupedTieredConfig().validate() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingGroupedTieredPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var groupedTieredConfig: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var 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 externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newFloatingGroupedTieredPrice: NewFloatingGroupedTieredPrice) = - apply { - cadence = newFloatingGroupedTieredPrice.cadence - currency = newFloatingGroupedTieredPrice.currency - groupedTieredConfig = newFloatingGroupedTieredPrice.groupedTieredConfig - itemId = newFloatingGroupedTieredPrice.itemId - modelType = newFloatingGroupedTieredPrice.modelType - name = newFloatingGroupedTieredPrice.name - billableMetricId = newFloatingGroupedTieredPrice.billableMetricId - billedInAdvance = newFloatingGroupedTieredPrice.billedInAdvance - billingCycleConfiguration = - newFloatingGroupedTieredPrice.billingCycleConfiguration - conversionRate = newFloatingGroupedTieredPrice.conversionRate - externalPriceId = newFloatingGroupedTieredPrice.externalPriceId - fixedPriceQuantity = newFloatingGroupedTieredPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingGroupedTieredPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingGroupedTieredPrice.invoicingCycleConfiguration - metadata = newFloatingGroupedTieredPrice.metadata - additionalProperties = - newFloatingGroupedTieredPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun groupedTieredConfig(groupedTieredConfig: GroupedTieredConfig) = - groupedTieredConfig(JsonField.of(groupedTieredConfig)) - - fun groupedTieredConfig(groupedTieredConfig: JsonField) = - apply { - this.groupedTieredConfig = groupedTieredConfig - } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingGroupedTieredPrice = - NewFloatingGroupedTieredPrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("groupedTieredConfig", groupedTieredConfig), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class GroupedTieredConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): GroupedTieredConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [GroupedTieredConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(groupedTieredConfig: GroupedTieredConfig) = apply { - additionalProperties = - groupedTieredConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): GroupedTieredConfig = - GroupedTieredConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GroupedTieredConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedTieredConfig{additionalProperties=$additionalProperties}" - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val GROUPED_TIERED = of("grouped_tiered") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_TIERED - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GROUPED_TIERED, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GROUPED_TIERED -> Value.GROUPED_TIERED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - GROUPED_TIERED -> Known.GROUPED_TIERED - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingGroupedTieredPrice && cadence == other.cadence && currency == other.currency && groupedTieredConfig == other.groupedTieredConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, groupedTieredConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingGroupedTieredPrice{cadence=$cadence, currency=$currency, groupedTieredConfig=$groupedTieredConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingMaxGroupTieredPackagePrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("max_group_tiered_package_config") - @ExcludeMissing - private val maxGroupTieredPackageConfig: JsonField = - JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun maxGroupTieredPackageConfig(): MaxGroupTieredPackageConfig = - maxGroupTieredPackageConfig.getRequired("max_group_tiered_package_config") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("max_group_tiered_package_config") - @ExcludeMissing - fun _maxGroupTieredPackageConfig(): JsonField = - maxGroupTieredPackageConfig - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingMaxGroupTieredPackagePrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - itemId() - maxGroupTieredPackageConfig().validate() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingMaxGroupTieredPackagePrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var maxGroupTieredPackageConfig: JsonField? = - null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newFloatingMaxGroupTieredPackagePrice: NewFloatingMaxGroupTieredPackagePrice - ) = apply { - cadence = newFloatingMaxGroupTieredPackagePrice.cadence - currency = newFloatingMaxGroupTieredPackagePrice.currency - itemId = newFloatingMaxGroupTieredPackagePrice.itemId - maxGroupTieredPackageConfig = - newFloatingMaxGroupTieredPackagePrice.maxGroupTieredPackageConfig - modelType = newFloatingMaxGroupTieredPackagePrice.modelType - name = newFloatingMaxGroupTieredPackagePrice.name - billableMetricId = newFloatingMaxGroupTieredPackagePrice.billableMetricId - billedInAdvance = newFloatingMaxGroupTieredPackagePrice.billedInAdvance - billingCycleConfiguration = - newFloatingMaxGroupTieredPackagePrice.billingCycleConfiguration - conversionRate = newFloatingMaxGroupTieredPackagePrice.conversionRate - externalPriceId = newFloatingMaxGroupTieredPackagePrice.externalPriceId - fixedPriceQuantity = newFloatingMaxGroupTieredPackagePrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingMaxGroupTieredPackagePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingMaxGroupTieredPackagePrice.invoicingCycleConfiguration - metadata = newFloatingMaxGroupTieredPackagePrice.metadata - additionalProperties = - newFloatingMaxGroupTieredPackagePrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun maxGroupTieredPackageConfig( - maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig - ) = maxGroupTieredPackageConfig(JsonField.of(maxGroupTieredPackageConfig)) - - fun maxGroupTieredPackageConfig( - maxGroupTieredPackageConfig: JsonField - ) = apply { this.maxGroupTieredPackageConfig = maxGroupTieredPackageConfig } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingMaxGroupTieredPackagePrice = - NewFloatingMaxGroupTieredPackagePrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("maxGroupTieredPackageConfig", maxGroupTieredPackageConfig), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class MaxGroupTieredPackageConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MaxGroupTieredPackageConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MaxGroupTieredPackageConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig) = - apply { - additionalProperties = - maxGroupTieredPackageConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): MaxGroupTieredPackageConfig = - MaxGroupTieredPackageConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MaxGroupTieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MaxGroupTieredPackageConfig{additionalProperties=$additionalProperties}" - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val MAX_GROUP_TIERED_PACKAGE = of("max_group_tiered_package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MAX_GROUP_TIERED_PACKAGE - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAX_GROUP_TIERED_PACKAGE, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAX_GROUP_TIERED_PACKAGE -> Value.MAX_GROUP_TIERED_PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - MAX_GROUP_TIERED_PACKAGE -> Known.MAX_GROUP_TIERED_PACKAGE - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingMaxGroupTieredPackagePrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && maxGroupTieredPackageConfig == other.maxGroupTieredPackageConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, maxGroupTieredPackageConfig, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingMaxGroupTieredPackagePrice{cadence=$cadence, currency=$currency, itemId=$itemId, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingTieredWithMinimumPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_minimum_config") - @ExcludeMissing - private val tieredWithMinimumConfig: JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun tieredWithMinimumConfig(): TieredWithMinimumConfig = - tieredWithMinimumConfig.getRequired("tiered_with_minimum_config") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("tiered_with_minimum_config") - @ExcludeMissing - fun _tieredWithMinimumConfig(): JsonField = - tieredWithMinimumConfig - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingTieredWithMinimumPrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - itemId() - modelType() - name() - tieredWithMinimumConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingTieredWithMinimumPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var tieredWithMinimumConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newFloatingTieredWithMinimumPrice: NewFloatingTieredWithMinimumPrice - ) = apply { - cadence = newFloatingTieredWithMinimumPrice.cadence - currency = newFloatingTieredWithMinimumPrice.currency - itemId = newFloatingTieredWithMinimumPrice.itemId - modelType = newFloatingTieredWithMinimumPrice.modelType - name = newFloatingTieredWithMinimumPrice.name - tieredWithMinimumConfig = - newFloatingTieredWithMinimumPrice.tieredWithMinimumConfig - billableMetricId = newFloatingTieredWithMinimumPrice.billableMetricId - billedInAdvance = newFloatingTieredWithMinimumPrice.billedInAdvance - billingCycleConfiguration = - newFloatingTieredWithMinimumPrice.billingCycleConfiguration - conversionRate = newFloatingTieredWithMinimumPrice.conversionRate - externalPriceId = newFloatingTieredWithMinimumPrice.externalPriceId - fixedPriceQuantity = newFloatingTieredWithMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingTieredWithMinimumPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingTieredWithMinimumPrice.invoicingCycleConfiguration - metadata = newFloatingTieredWithMinimumPrice.metadata - additionalProperties = - newFloatingTieredWithMinimumPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredWithMinimumConfig(tieredWithMinimumConfig: TieredWithMinimumConfig) = - tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) - - fun tieredWithMinimumConfig( - tieredWithMinimumConfig: JsonField - ) = apply { this.tieredWithMinimumConfig = tieredWithMinimumConfig } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingTieredWithMinimumPrice = - NewFloatingTieredWithMinimumPrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("tieredWithMinimumConfig", tieredWithMinimumConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED_WITH_MINIMUM = of("tiered_with_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_WITH_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_WITH_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_WITH_MINIMUM -> Value.TIERED_WITH_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - TIERED_WITH_MINIMUM -> Known.TIERED_WITH_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TieredWithMinimumConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredWithMinimumConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredWithMinimumConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tieredWithMinimumConfig: TieredWithMinimumConfig) = apply { - additionalProperties = - tieredWithMinimumConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): TieredWithMinimumConfig = - TieredWithMinimumConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredWithMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredWithMinimumConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingTieredWithMinimumPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredWithMinimumConfig == other.tieredWithMinimumConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, tieredWithMinimumConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingTieredWithMinimumPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingPackageWithAllocationPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("package_with_allocation_config") - @ExcludeMissing - private val packageWithAllocationConfig: JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun packageWithAllocationConfig(): PackageWithAllocationConfig = - packageWithAllocationConfig.getRequired("package_with_allocation_config") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("package_with_allocation_config") - @ExcludeMissing - fun _packageWithAllocationConfig(): JsonField = - packageWithAllocationConfig - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingPackageWithAllocationPrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - itemId() - modelType() - name() - packageWithAllocationConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingPackageWithAllocationPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var packageWithAllocationConfig: JsonField? = - null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newFloatingPackageWithAllocationPrice: NewFloatingPackageWithAllocationPrice - ) = apply { - cadence = newFloatingPackageWithAllocationPrice.cadence - currency = newFloatingPackageWithAllocationPrice.currency - itemId = newFloatingPackageWithAllocationPrice.itemId - modelType = newFloatingPackageWithAllocationPrice.modelType - name = newFloatingPackageWithAllocationPrice.name - packageWithAllocationConfig = - newFloatingPackageWithAllocationPrice.packageWithAllocationConfig - billableMetricId = newFloatingPackageWithAllocationPrice.billableMetricId - billedInAdvance = newFloatingPackageWithAllocationPrice.billedInAdvance - billingCycleConfiguration = - newFloatingPackageWithAllocationPrice.billingCycleConfiguration - conversionRate = newFloatingPackageWithAllocationPrice.conversionRate - externalPriceId = newFloatingPackageWithAllocationPrice.externalPriceId - fixedPriceQuantity = newFloatingPackageWithAllocationPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingPackageWithAllocationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingPackageWithAllocationPrice.invoicingCycleConfiguration - metadata = newFloatingPackageWithAllocationPrice.metadata - additionalProperties = - newFloatingPackageWithAllocationPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun packageWithAllocationConfig( - packageWithAllocationConfig: PackageWithAllocationConfig - ) = packageWithAllocationConfig(JsonField.of(packageWithAllocationConfig)) - - fun packageWithAllocationConfig( - packageWithAllocationConfig: JsonField - ) = apply { this.packageWithAllocationConfig = packageWithAllocationConfig } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingPackageWithAllocationPrice = - NewFloatingPackageWithAllocationPrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("packageWithAllocationConfig", packageWithAllocationConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val PACKAGE_WITH_ALLOCATION = of("package_with_allocation") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - PACKAGE_WITH_ALLOCATION - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PACKAGE_WITH_ALLOCATION, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PACKAGE_WITH_ALLOCATION -> Value.PACKAGE_WITH_ALLOCATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PACKAGE_WITH_ALLOCATION -> Known.PACKAGE_WITH_ALLOCATION - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class PackageWithAllocationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PackageWithAllocationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PackageWithAllocationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(packageWithAllocationConfig: PackageWithAllocationConfig) = - apply { - additionalProperties = - packageWithAllocationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): PackageWithAllocationConfig = - PackageWithAllocationConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PackageWithAllocationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PackageWithAllocationConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingPackageWithAllocationPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && packageWithAllocationConfig == other.packageWithAllocationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, packageWithAllocationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingPackageWithAllocationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingTieredPackageWithMinimumPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_package_with_minimum_config") - @ExcludeMissing - private val tieredPackageWithMinimumConfig: JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun tieredPackageWithMinimumConfig(): TieredPackageWithMinimumConfig = - tieredPackageWithMinimumConfig.getRequired("tiered_package_with_minimum_config") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("tiered_package_with_minimum_config") - @ExcludeMissing - fun _tieredPackageWithMinimumConfig(): JsonField = - tieredPackageWithMinimumConfig - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingTieredPackageWithMinimumPrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - itemId() - modelType() - name() - tieredPackageWithMinimumConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingTieredPackageWithMinimumPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var tieredPackageWithMinimumConfig: - JsonField? = - null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newFloatingTieredPackageWithMinimumPrice: - NewFloatingTieredPackageWithMinimumPrice - ) = apply { - cadence = newFloatingTieredPackageWithMinimumPrice.cadence - currency = newFloatingTieredPackageWithMinimumPrice.currency - itemId = newFloatingTieredPackageWithMinimumPrice.itemId - modelType = newFloatingTieredPackageWithMinimumPrice.modelType - name = newFloatingTieredPackageWithMinimumPrice.name - tieredPackageWithMinimumConfig = - newFloatingTieredPackageWithMinimumPrice.tieredPackageWithMinimumConfig - billableMetricId = newFloatingTieredPackageWithMinimumPrice.billableMetricId - billedInAdvance = newFloatingTieredPackageWithMinimumPrice.billedInAdvance - billingCycleConfiguration = - newFloatingTieredPackageWithMinimumPrice.billingCycleConfiguration - conversionRate = newFloatingTieredPackageWithMinimumPrice.conversionRate - externalPriceId = newFloatingTieredPackageWithMinimumPrice.externalPriceId - fixedPriceQuantity = newFloatingTieredPackageWithMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingTieredPackageWithMinimumPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingTieredPackageWithMinimumPrice.invoicingCycleConfiguration - metadata = newFloatingTieredPackageWithMinimumPrice.metadata - additionalProperties = - newFloatingTieredPackageWithMinimumPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredPackageWithMinimumConfig( - tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig - ) = tieredPackageWithMinimumConfig(JsonField.of(tieredPackageWithMinimumConfig)) - - fun tieredPackageWithMinimumConfig( - tieredPackageWithMinimumConfig: JsonField - ) = apply { this.tieredPackageWithMinimumConfig = tieredPackageWithMinimumConfig } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingTieredPackageWithMinimumPrice = - NewFloatingTieredPackageWithMinimumPrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired( - "tieredPackageWithMinimumConfig", - tieredPackageWithMinimumConfig, - ), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED_PACKAGE_WITH_MINIMUM = of("tiered_package_with_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_PACKAGE_WITH_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_PACKAGE_WITH_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_PACKAGE_WITH_MINIMUM -> Value.TIERED_PACKAGE_WITH_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - TIERED_PACKAGE_WITH_MINIMUM -> Known.TIERED_PACKAGE_WITH_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TieredPackageWithMinimumConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredPackageWithMinimumConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredPackageWithMinimumConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig - ) = apply { - additionalProperties = - tieredPackageWithMinimumConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): TieredPackageWithMinimumConfig = - TieredPackageWithMinimumConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredPackageWithMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredPackageWithMinimumConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingTieredPackageWithMinimumPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredPackageWithMinimumConfig == other.tieredPackageWithMinimumConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, tieredPackageWithMinimumConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingTieredPackageWithMinimumPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingUnitWithPercentPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("unit_with_percent_config") - @ExcludeMissing - private val unitWithPercentConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun unitWithPercentConfig(): UnitWithPercentConfig = - unitWithPercentConfig.getRequired("unit_with_percent_config") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("unit_with_percent_config") - @ExcludeMissing - fun _unitWithPercentConfig(): JsonField = unitWithPercentConfig - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingUnitWithPercentPrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - itemId() - modelType() - name() - unitWithPercentConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingUnitWithPercentPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var unitWithPercentConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newFloatingUnitWithPercentPrice: NewFloatingUnitWithPercentPrice - ) = apply { - cadence = newFloatingUnitWithPercentPrice.cadence - currency = newFloatingUnitWithPercentPrice.currency - itemId = newFloatingUnitWithPercentPrice.itemId - modelType = newFloatingUnitWithPercentPrice.modelType - name = newFloatingUnitWithPercentPrice.name - unitWithPercentConfig = newFloatingUnitWithPercentPrice.unitWithPercentConfig - billableMetricId = newFloatingUnitWithPercentPrice.billableMetricId - billedInAdvance = newFloatingUnitWithPercentPrice.billedInAdvance - billingCycleConfiguration = - newFloatingUnitWithPercentPrice.billingCycleConfiguration - conversionRate = newFloatingUnitWithPercentPrice.conversionRate - externalPriceId = newFloatingUnitWithPercentPrice.externalPriceId - fixedPriceQuantity = newFloatingUnitWithPercentPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingUnitWithPercentPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingUnitWithPercentPrice.invoicingCycleConfiguration - metadata = newFloatingUnitWithPercentPrice.metadata - additionalProperties = - newFloatingUnitWithPercentPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun unitWithPercentConfig(unitWithPercentConfig: UnitWithPercentConfig) = - unitWithPercentConfig(JsonField.of(unitWithPercentConfig)) - - fun unitWithPercentConfig(unitWithPercentConfig: JsonField) = - apply { - this.unitWithPercentConfig = unitWithPercentConfig - } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingUnitWithPercentPrice = - NewFloatingUnitWithPercentPrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("unitWithPercentConfig", unitWithPercentConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val UNIT_WITH_PERCENT = of("unit_with_percent") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - UNIT_WITH_PERCENT - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - UNIT_WITH_PERCENT, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - UNIT_WITH_PERCENT -> Value.UNIT_WITH_PERCENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - UNIT_WITH_PERCENT -> Known.UNIT_WITH_PERCENT - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class UnitWithPercentConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): UnitWithPercentConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnitWithPercentConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unitWithPercentConfig: UnitWithPercentConfig) = apply { - additionalProperties = - unitWithPercentConfig.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) - } - - fun build(): UnitWithPercentConfig = - UnitWithPercentConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UnitWithPercentConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnitWithPercentConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingUnitWithPercentPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && unitWithPercentConfig == other.unitWithPercentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, unitWithPercentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingUnitWithPercentPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingTieredWithProrationPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - private val tieredWithProrationConfig: JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - 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. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingTieredWithProrationPrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - itemId() - modelType() - name() - tieredWithProrationConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingTieredWithProrationPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var 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 externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newFloatingTieredWithProrationPrice: NewFloatingTieredWithProrationPrice - ) = apply { - cadence = newFloatingTieredWithProrationPrice.cadence - currency = newFloatingTieredWithProrationPrice.currency - itemId = newFloatingTieredWithProrationPrice.itemId - modelType = newFloatingTieredWithProrationPrice.modelType - name = newFloatingTieredWithProrationPrice.name - tieredWithProrationConfig = - newFloatingTieredWithProrationPrice.tieredWithProrationConfig - billableMetricId = newFloatingTieredWithProrationPrice.billableMetricId - billedInAdvance = newFloatingTieredWithProrationPrice.billedInAdvance - billingCycleConfiguration = - newFloatingTieredWithProrationPrice.billingCycleConfiguration - conversionRate = newFloatingTieredWithProrationPrice.conversionRate - externalPriceId = newFloatingTieredWithProrationPrice.externalPriceId - fixedPriceQuantity = newFloatingTieredWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingTieredWithProrationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingTieredWithProrationPrice.invoicingCycleConfiguration - metadata = newFloatingTieredWithProrationPrice.metadata - additionalProperties = - newFloatingTieredWithProrationPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredWithProrationConfig( - tieredWithProrationConfig: TieredWithProrationConfig - ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingTieredWithProrationPrice = - NewFloatingTieredWithProrationPrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED_WITH_PRORATION = of("tiered_with_proration") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_WITH_PRORATION - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_WITH_PRORATION, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_WITH_PRORATION -> Value.TIERED_WITH_PRORATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - TIERED_WITH_PRORATION -> Known.TIERED_WITH_PRORATION - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TieredWithProrationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredWithProrationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredWithProrationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = - apply { - additionalProperties = - tieredWithProrationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredWithProrationConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingTieredWithProrationPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingTieredWithProrationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingUnitWithProrationPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("unit_with_proration_config") - @ExcludeMissing - private val unitWithProrationConfig: JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun unitWithProrationConfig(): UnitWithProrationConfig = - unitWithProrationConfig.getRequired("unit_with_proration_config") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("unit_with_proration_config") - @ExcludeMissing - fun _unitWithProrationConfig(): JsonField = - unitWithProrationConfig - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingUnitWithProrationPrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - itemId() - modelType() - name() - unitWithProrationConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingUnitWithProrationPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var unitWithProrationConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newFloatingUnitWithProrationPrice: NewFloatingUnitWithProrationPrice - ) = apply { - cadence = newFloatingUnitWithProrationPrice.cadence - currency = newFloatingUnitWithProrationPrice.currency - itemId = newFloatingUnitWithProrationPrice.itemId - modelType = newFloatingUnitWithProrationPrice.modelType - name = newFloatingUnitWithProrationPrice.name - unitWithProrationConfig = - newFloatingUnitWithProrationPrice.unitWithProrationConfig - billableMetricId = newFloatingUnitWithProrationPrice.billableMetricId - billedInAdvance = newFloatingUnitWithProrationPrice.billedInAdvance - billingCycleConfiguration = - newFloatingUnitWithProrationPrice.billingCycleConfiguration - conversionRate = newFloatingUnitWithProrationPrice.conversionRate - externalPriceId = newFloatingUnitWithProrationPrice.externalPriceId - fixedPriceQuantity = newFloatingUnitWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingUnitWithProrationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingUnitWithProrationPrice.invoicingCycleConfiguration - metadata = newFloatingUnitWithProrationPrice.metadata - additionalProperties = - newFloatingUnitWithProrationPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun unitWithProrationConfig(unitWithProrationConfig: UnitWithProrationConfig) = - unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) - - fun unitWithProrationConfig( - unitWithProrationConfig: JsonField - ) = apply { this.unitWithProrationConfig = unitWithProrationConfig } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingUnitWithProrationPrice = - NewFloatingUnitWithProrationPrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("unitWithProrationConfig", unitWithProrationConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val UNIT_WITH_PRORATION = of("unit_with_proration") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - UNIT_WITH_PRORATION - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - UNIT_WITH_PRORATION, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - UNIT_WITH_PRORATION -> Value.UNIT_WITH_PRORATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - UNIT_WITH_PRORATION -> Known.UNIT_WITH_PRORATION - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class UnitWithProrationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): UnitWithProrationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnitWithProrationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unitWithProrationConfig: UnitWithProrationConfig) = apply { - additionalProperties = - unitWithProrationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): UnitWithProrationConfig = - UnitWithProrationConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UnitWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnitWithProrationConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingUnitWithProrationPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && unitWithProrationConfig == other.unitWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, unitWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingUnitWithProrationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingGroupedAllocationPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("grouped_allocation_config") - @ExcludeMissing - private val groupedAllocationConfig: JsonField = - JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - fun groupedAllocationConfig(): GroupedAllocationConfig = - groupedAllocationConfig.getRequired("grouped_allocation_config") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonProperty("grouped_allocation_config") - @ExcludeMissing - fun _groupedAllocationConfig(): JsonField = - groupedAllocationConfig - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingGroupedAllocationPrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - groupedAllocationConfig().validate() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingGroupedAllocationPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var groupedAllocationConfig: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var 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 externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newFloatingGroupedAllocationPrice: NewFloatingGroupedAllocationPrice - ) = apply { - cadence = newFloatingGroupedAllocationPrice.cadence - currency = newFloatingGroupedAllocationPrice.currency - groupedAllocationConfig = - newFloatingGroupedAllocationPrice.groupedAllocationConfig - itemId = newFloatingGroupedAllocationPrice.itemId - modelType = newFloatingGroupedAllocationPrice.modelType - name = newFloatingGroupedAllocationPrice.name - billableMetricId = newFloatingGroupedAllocationPrice.billableMetricId - billedInAdvance = newFloatingGroupedAllocationPrice.billedInAdvance - billingCycleConfiguration = - newFloatingGroupedAllocationPrice.billingCycleConfiguration - conversionRate = newFloatingGroupedAllocationPrice.conversionRate - externalPriceId = newFloatingGroupedAllocationPrice.externalPriceId - fixedPriceQuantity = newFloatingGroupedAllocationPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingGroupedAllocationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingGroupedAllocationPrice.invoicingCycleConfiguration - metadata = newFloatingGroupedAllocationPrice.metadata - additionalProperties = - newFloatingGroupedAllocationPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = - groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) - - fun groupedAllocationConfig( - groupedAllocationConfig: JsonField - ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingGroupedAllocationPrice = - NewFloatingGroupedAllocationPrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("groupedAllocationConfig", groupedAllocationConfig), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class GroupedAllocationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): GroupedAllocationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [GroupedAllocationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(groupedAllocationConfig: GroupedAllocationConfig) = apply { - additionalProperties = - groupedAllocationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): GroupedAllocationConfig = - GroupedAllocationConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GroupedAllocationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedAllocationConfig{additionalProperties=$additionalProperties}" - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val GROUPED_ALLOCATION = of("grouped_allocation") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_ALLOCATION - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GROUPED_ALLOCATION, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GROUPED_ALLOCATION -> Value.GROUPED_ALLOCATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - GROUPED_ALLOCATION -> Known.GROUPED_ALLOCATION - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingGroupedAllocationPrice && cadence == other.cadence && currency == other.currency && groupedAllocationConfig == other.groupedAllocationConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, groupedAllocationConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingGroupedAllocationPrice{cadence=$cadence, currency=$currency, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingGroupedWithProratedMinimumPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_prorated_minimum_config") - @ExcludeMissing - private val groupedWithProratedMinimumConfig: - JsonField = - JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - fun groupedWithProratedMinimumConfig(): GroupedWithProratedMinimumConfig = - groupedWithProratedMinimumConfig.getRequired("grouped_with_prorated_minimum_config") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonProperty("grouped_with_prorated_minimum_config") - @ExcludeMissing - fun _groupedWithProratedMinimumConfig(): JsonField = - groupedWithProratedMinimumConfig - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingGroupedWithProratedMinimumPrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - groupedWithProratedMinimumConfig().validate() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingGroupedWithProratedMinimumPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var groupedWithProratedMinimumConfig: - JsonField? = - null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newFloatingGroupedWithProratedMinimumPrice: - NewFloatingGroupedWithProratedMinimumPrice - ) = apply { - cadence = newFloatingGroupedWithProratedMinimumPrice.cadence - currency = newFloatingGroupedWithProratedMinimumPrice.currency - groupedWithProratedMinimumConfig = - newFloatingGroupedWithProratedMinimumPrice.groupedWithProratedMinimumConfig - itemId = newFloatingGroupedWithProratedMinimumPrice.itemId - modelType = newFloatingGroupedWithProratedMinimumPrice.modelType - name = newFloatingGroupedWithProratedMinimumPrice.name - billableMetricId = newFloatingGroupedWithProratedMinimumPrice.billableMetricId - billedInAdvance = newFloatingGroupedWithProratedMinimumPrice.billedInAdvance - billingCycleConfiguration = - newFloatingGroupedWithProratedMinimumPrice.billingCycleConfiguration - conversionRate = newFloatingGroupedWithProratedMinimumPrice.conversionRate - externalPriceId = newFloatingGroupedWithProratedMinimumPrice.externalPriceId - fixedPriceQuantity = - newFloatingGroupedWithProratedMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = - newFloatingGroupedWithProratedMinimumPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingGroupedWithProratedMinimumPrice.invoicingCycleConfiguration - metadata = newFloatingGroupedWithProratedMinimumPrice.metadata - additionalProperties = - newFloatingGroupedWithProratedMinimumPrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun groupedWithProratedMinimumConfig( - groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig - ) = groupedWithProratedMinimumConfig(JsonField.of(groupedWithProratedMinimumConfig)) - - fun groupedWithProratedMinimumConfig( - groupedWithProratedMinimumConfig: JsonField - ) = apply { - this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig - } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingGroupedWithProratedMinimumPrice = - NewFloatingGroupedWithProratedMinimumPrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired( - "groupedWithProratedMinimumConfig", - groupedWithProratedMinimumConfig, - ), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class GroupedWithProratedMinimumConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): GroupedWithProratedMinimumConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [GroupedWithProratedMinimumConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig - ) = apply { - additionalProperties = - groupedWithProratedMinimumConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): GroupedWithProratedMinimumConfig = - GroupedWithProratedMinimumConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GroupedWithProratedMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedWithProratedMinimumConfig{additionalProperties=$additionalProperties}" - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField - val GROUPED_WITH_PRORATED_MINIMUM = of("grouped_with_prorated_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_WITH_PRORATED_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GROUPED_WITH_PRORATED_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GROUPED_WITH_PRORATED_MINIMUM -> Value.GROUPED_WITH_PRORATED_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - GROUPED_WITH_PRORATED_MINIMUM -> Known.GROUPED_WITH_PRORATED_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingGroupedWithProratedMinimumPrice && cadence == other.cadence && currency == other.currency && groupedWithProratedMinimumConfig == other.groupedWithProratedMinimumConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, groupedWithProratedMinimumConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingGroupedWithProratedMinimumPrice{cadence=$cadence, currency=$currency, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingGroupedWithMeteredMinimumPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_metered_minimum_config") - @ExcludeMissing - private val groupedWithMeteredMinimumConfig: - JsonField = - JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - fun groupedWithMeteredMinimumConfig(): GroupedWithMeteredMinimumConfig = - groupedWithMeteredMinimumConfig.getRequired("grouped_with_metered_minimum_config") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonProperty("grouped_with_metered_minimum_config") - @ExcludeMissing - fun _groupedWithMeteredMinimumConfig(): JsonField = - groupedWithMeteredMinimumConfig - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingGroupedWithMeteredMinimumPrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - groupedWithMeteredMinimumConfig().validate() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingGroupedWithMeteredMinimumPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var groupedWithMeteredMinimumConfig: - JsonField? = - null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newFloatingGroupedWithMeteredMinimumPrice: - NewFloatingGroupedWithMeteredMinimumPrice - ) = apply { - cadence = newFloatingGroupedWithMeteredMinimumPrice.cadence - currency = newFloatingGroupedWithMeteredMinimumPrice.currency - groupedWithMeteredMinimumConfig = - newFloatingGroupedWithMeteredMinimumPrice.groupedWithMeteredMinimumConfig - itemId = newFloatingGroupedWithMeteredMinimumPrice.itemId - modelType = newFloatingGroupedWithMeteredMinimumPrice.modelType - name = newFloatingGroupedWithMeteredMinimumPrice.name - billableMetricId = newFloatingGroupedWithMeteredMinimumPrice.billableMetricId - billedInAdvance = newFloatingGroupedWithMeteredMinimumPrice.billedInAdvance - billingCycleConfiguration = - newFloatingGroupedWithMeteredMinimumPrice.billingCycleConfiguration - conversionRate = newFloatingGroupedWithMeteredMinimumPrice.conversionRate - externalPriceId = newFloatingGroupedWithMeteredMinimumPrice.externalPriceId - fixedPriceQuantity = - newFloatingGroupedWithMeteredMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = - newFloatingGroupedWithMeteredMinimumPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingGroupedWithMeteredMinimumPrice.invoicingCycleConfiguration - metadata = newFloatingGroupedWithMeteredMinimumPrice.metadata - additionalProperties = - newFloatingGroupedWithMeteredMinimumPrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun groupedWithMeteredMinimumConfig( - groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig - ) = groupedWithMeteredMinimumConfig(JsonField.of(groupedWithMeteredMinimumConfig)) - - fun groupedWithMeteredMinimumConfig( - groupedWithMeteredMinimumConfig: JsonField - ) = apply { this.groupedWithMeteredMinimumConfig = groupedWithMeteredMinimumConfig } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingGroupedWithMeteredMinimumPrice = - NewFloatingGroupedWithMeteredMinimumPrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired( - "groupedWithMeteredMinimumConfig", - groupedWithMeteredMinimumConfig, - ), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class GroupedWithMeteredMinimumConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): GroupedWithMeteredMinimumConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [GroupedWithMeteredMinimumConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig - ) = apply { - additionalProperties = - groupedWithMeteredMinimumConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): GroupedWithMeteredMinimumConfig = - GroupedWithMeteredMinimumConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GroupedWithMeteredMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedWithMeteredMinimumConfig{additionalProperties=$additionalProperties}" - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val GROUPED_WITH_METERED_MINIMUM = of("grouped_with_metered_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_WITH_METERED_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GROUPED_WITH_METERED_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GROUPED_WITH_METERED_MINIMUM -> Value.GROUPED_WITH_METERED_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - GROUPED_WITH_METERED_MINIMUM -> Known.GROUPED_WITH_METERED_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingGroupedWithMeteredMinimumPrice && cadence == other.cadence && currency == other.currency && groupedWithMeteredMinimumConfig == other.groupedWithMeteredMinimumConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, groupedWithMeteredMinimumConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingGroupedWithMeteredMinimumPrice{cadence=$cadence, currency=$currency, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingMatrixWithDisplayNamePrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("matrix_with_display_name_config") - @ExcludeMissing - private val matrixWithDisplayNameConfig: JsonField = - JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun matrixWithDisplayNameConfig(): MatrixWithDisplayNameConfig = - matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_config") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("matrix_with_display_name_config") - @ExcludeMissing - fun _matrixWithDisplayNameConfig(): JsonField = - matrixWithDisplayNameConfig - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingMatrixWithDisplayNamePrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - itemId() - matrixWithDisplayNameConfig().validate() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingMatrixWithDisplayNamePrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var matrixWithDisplayNameConfig: JsonField? = - null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newFloatingMatrixWithDisplayNamePrice: NewFloatingMatrixWithDisplayNamePrice - ) = apply { - cadence = newFloatingMatrixWithDisplayNamePrice.cadence - currency = newFloatingMatrixWithDisplayNamePrice.currency - itemId = newFloatingMatrixWithDisplayNamePrice.itemId - matrixWithDisplayNameConfig = - newFloatingMatrixWithDisplayNamePrice.matrixWithDisplayNameConfig - modelType = newFloatingMatrixWithDisplayNamePrice.modelType - name = newFloatingMatrixWithDisplayNamePrice.name - billableMetricId = newFloatingMatrixWithDisplayNamePrice.billableMetricId - billedInAdvance = newFloatingMatrixWithDisplayNamePrice.billedInAdvance - billingCycleConfiguration = - newFloatingMatrixWithDisplayNamePrice.billingCycleConfiguration - conversionRate = newFloatingMatrixWithDisplayNamePrice.conversionRate - externalPriceId = newFloatingMatrixWithDisplayNamePrice.externalPriceId - fixedPriceQuantity = newFloatingMatrixWithDisplayNamePrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingMatrixWithDisplayNamePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingMatrixWithDisplayNamePrice.invoicingCycleConfiguration - metadata = newFloatingMatrixWithDisplayNamePrice.metadata - additionalProperties = - newFloatingMatrixWithDisplayNamePrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun matrixWithDisplayNameConfig( - matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig - ) = matrixWithDisplayNameConfig(JsonField.of(matrixWithDisplayNameConfig)) - - fun matrixWithDisplayNameConfig( - matrixWithDisplayNameConfig: JsonField - ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingMatrixWithDisplayNamePrice = - NewFloatingMatrixWithDisplayNamePrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("matrixWithDisplayNameConfig", matrixWithDisplayNameConfig), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class MatrixWithDisplayNameConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MatrixWithDisplayNameConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MatrixWithDisplayNameConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig) = - apply { - additionalProperties = - matrixWithDisplayNameConfig.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) - } - - fun build(): MatrixWithDisplayNameConfig = - MatrixWithDisplayNameConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MatrixWithDisplayNameConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MatrixWithDisplayNameConfig{additionalProperties=$additionalProperties}" - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val MATRIX_WITH_DISPLAY_NAME = of("matrix_with_display_name") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MATRIX_WITH_DISPLAY_NAME - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MATRIX_WITH_DISPLAY_NAME, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MATRIX_WITH_DISPLAY_NAME -> Value.MATRIX_WITH_DISPLAY_NAME - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - MATRIX_WITH_DISPLAY_NAME -> Known.MATRIX_WITH_DISPLAY_NAME - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingMatrixWithDisplayNamePrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && matrixWithDisplayNameConfig == other.matrixWithDisplayNameConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, matrixWithDisplayNameConfig, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingMatrixWithDisplayNamePrice{cadence=$cadence, currency=$currency, itemId=$itemId, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingBulkWithProrationPrice - @JsonCreator - private constructor( - @JsonProperty("bulk_with_proration_config") - @ExcludeMissing - private val bulkWithProrationConfig: JsonField = - JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun bulkWithProrationConfig(): BulkWithProrationConfig = - bulkWithProrationConfig.getRequired("bulk_with_proration_config") - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - @JsonProperty("bulk_with_proration_config") - @ExcludeMissing - fun _bulkWithProrationConfig(): JsonField = - bulkWithProrationConfig - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingBulkWithProrationPrice = apply { - if (validated) { - return@apply - } - - bulkWithProrationConfig().validate() - cadence() - currency() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingBulkWithProrationPrice]. */ - class Builder internal constructor() { - - private var bulkWithProrationConfig: JsonField? = null - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var 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 externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newFloatingBulkWithProrationPrice: NewFloatingBulkWithProrationPrice - ) = apply { - bulkWithProrationConfig = - newFloatingBulkWithProrationPrice.bulkWithProrationConfig - cadence = newFloatingBulkWithProrationPrice.cadence - currency = newFloatingBulkWithProrationPrice.currency - itemId = newFloatingBulkWithProrationPrice.itemId - modelType = newFloatingBulkWithProrationPrice.modelType - name = newFloatingBulkWithProrationPrice.name - billableMetricId = newFloatingBulkWithProrationPrice.billableMetricId - billedInAdvance = newFloatingBulkWithProrationPrice.billedInAdvance - billingCycleConfiguration = - newFloatingBulkWithProrationPrice.billingCycleConfiguration - conversionRate = newFloatingBulkWithProrationPrice.conversionRate - externalPriceId = newFloatingBulkWithProrationPrice.externalPriceId - fixedPriceQuantity = newFloatingBulkWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingBulkWithProrationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingBulkWithProrationPrice.invoicingCycleConfiguration - metadata = newFloatingBulkWithProrationPrice.metadata - additionalProperties = - newFloatingBulkWithProrationPrice.additionalProperties.toMutableMap() - } - - fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = - bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) - - fun bulkWithProrationConfig( - bulkWithProrationConfig: JsonField - ) = apply { this.bulkWithProrationConfig = bulkWithProrationConfig } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingBulkWithProrationPrice = - NewFloatingBulkWithProrationPrice( - checkRequired("bulkWithProrationConfig", bulkWithProrationConfig), - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BulkWithProrationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BulkWithProrationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkWithProrationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(bulkWithProrationConfig: BulkWithProrationConfig) = apply { - additionalProperties = - bulkWithProrationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): BulkWithProrationConfig = - BulkWithProrationConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BulkWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkWithProrationConfig{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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val BULK_WITH_PRORATION = of("bulk_with_proration") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK_WITH_PRORATION - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK_WITH_PRORATION, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK_WITH_PRORATION -> Value.BULK_WITH_PRORATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - BULK_WITH_PRORATION -> Known.BULK_WITH_PRORATION - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingBulkWithProrationPrice && bulkWithProrationConfig == other.bulkWithProrationConfig && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bulkWithProrationConfig, cadence, currency, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingBulkWithProrationPrice{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingGroupedTieredPackagePrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("grouped_tiered_package_config") - @ExcludeMissing - private val groupedTieredPackageConfig: JsonField = - JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - fun groupedTieredPackageConfig(): GroupedTieredPackageConfig = - groupedTieredPackageConfig.getRequired("grouped_tiered_package_config") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - @JsonProperty("grouped_tiered_package_config") - @ExcludeMissing - fun _groupedTieredPackageConfig(): JsonField = - groupedTieredPackageConfig - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingGroupedTieredPackagePrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - groupedTieredPackageConfig().validate() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingGroupedTieredPackagePrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var groupedTieredPackageConfig: JsonField? = - null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newFloatingGroupedTieredPackagePrice: NewFloatingGroupedTieredPackagePrice - ) = apply { - cadence = newFloatingGroupedTieredPackagePrice.cadence - currency = newFloatingGroupedTieredPackagePrice.currency - groupedTieredPackageConfig = - newFloatingGroupedTieredPackagePrice.groupedTieredPackageConfig - itemId = newFloatingGroupedTieredPackagePrice.itemId - modelType = newFloatingGroupedTieredPackagePrice.modelType - name = newFloatingGroupedTieredPackagePrice.name - billableMetricId = newFloatingGroupedTieredPackagePrice.billableMetricId - billedInAdvance = newFloatingGroupedTieredPackagePrice.billedInAdvance - billingCycleConfiguration = - newFloatingGroupedTieredPackagePrice.billingCycleConfiguration - conversionRate = newFloatingGroupedTieredPackagePrice.conversionRate - externalPriceId = newFloatingGroupedTieredPackagePrice.externalPriceId - fixedPriceQuantity = newFloatingGroupedTieredPackagePrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingGroupedTieredPackagePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingGroupedTieredPackagePrice.invoicingCycleConfiguration - metadata = newFloatingGroupedTieredPackagePrice.metadata - additionalProperties = - newFloatingGroupedTieredPackagePrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun groupedTieredPackageConfig( - groupedTieredPackageConfig: GroupedTieredPackageConfig - ) = groupedTieredPackageConfig(JsonField.of(groupedTieredPackageConfig)) - - fun groupedTieredPackageConfig( - groupedTieredPackageConfig: JsonField - ) = apply { this.groupedTieredPackageConfig = groupedTieredPackageConfig } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingGroupedTieredPackagePrice = - NewFloatingGroupedTieredPackagePrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("groupedTieredPackageConfig", groupedTieredPackageConfig), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class GroupedTieredPackageConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): GroupedTieredPackageConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [GroupedTieredPackageConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(groupedTieredPackageConfig: GroupedTieredPackageConfig) = - apply { - additionalProperties = - groupedTieredPackageConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): GroupedTieredPackageConfig = - GroupedTieredPackageConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GroupedTieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedTieredPackageConfig{additionalProperties=$additionalProperties}" - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val GROUPED_TIERED_PACKAGE = of("grouped_tiered_package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_TIERED_PACKAGE - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GROUPED_TIERED_PACKAGE, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GROUPED_TIERED_PACKAGE -> Value.GROUPED_TIERED_PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - GROUPED_TIERED_PACKAGE -> Known.GROUPED_TIERED_PACKAGE - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingGroupedTieredPackagePrice && cadence == other.cadence && currency == other.currency && groupedTieredPackageConfig == other.groupedTieredPackageConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, groupedTieredPackageConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingGroupedTieredPackagePrice{cadence=$cadence, currency=$currency, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingScalableMatrixWithUnitPricingPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("scalable_matrix_with_unit_pricing_config") - @ExcludeMissing - private val scalableMatrixWithUnitPricingConfig: - JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun scalableMatrixWithUnitPricingConfig(): ScalableMatrixWithUnitPricingConfig = - scalableMatrixWithUnitPricingConfig.getRequired( - "scalable_matrix_with_unit_pricing_config" - ) - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("scalable_matrix_with_unit_pricing_config") - @ExcludeMissing - fun _scalableMatrixWithUnitPricingConfig(): - JsonField = scalableMatrixWithUnitPricingConfig - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingScalableMatrixWithUnitPricingPrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - itemId() - modelType() - name() - scalableMatrixWithUnitPricingConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingScalableMatrixWithUnitPricingPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var scalableMatrixWithUnitPricingConfig: - JsonField? = - null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newFloatingScalableMatrixWithUnitPricingPrice: - NewFloatingScalableMatrixWithUnitPricingPrice - ) = apply { - cadence = newFloatingScalableMatrixWithUnitPricingPrice.cadence - currency = newFloatingScalableMatrixWithUnitPricingPrice.currency - itemId = newFloatingScalableMatrixWithUnitPricingPrice.itemId - modelType = newFloatingScalableMatrixWithUnitPricingPrice.modelType - name = newFloatingScalableMatrixWithUnitPricingPrice.name - scalableMatrixWithUnitPricingConfig = - newFloatingScalableMatrixWithUnitPricingPrice - .scalableMatrixWithUnitPricingConfig - billableMetricId = - newFloatingScalableMatrixWithUnitPricingPrice.billableMetricId - billedInAdvance = newFloatingScalableMatrixWithUnitPricingPrice.billedInAdvance - billingCycleConfiguration = - newFloatingScalableMatrixWithUnitPricingPrice.billingCycleConfiguration - conversionRate = newFloatingScalableMatrixWithUnitPricingPrice.conversionRate - externalPriceId = newFloatingScalableMatrixWithUnitPricingPrice.externalPriceId - fixedPriceQuantity = - newFloatingScalableMatrixWithUnitPricingPrice.fixedPriceQuantity - invoiceGroupingKey = - newFloatingScalableMatrixWithUnitPricingPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingScalableMatrixWithUnitPricingPrice.invoicingCycleConfiguration - metadata = newFloatingScalableMatrixWithUnitPricingPrice.metadata - additionalProperties = - newFloatingScalableMatrixWithUnitPricingPrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun scalableMatrixWithUnitPricingConfig( - scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig - ) = - scalableMatrixWithUnitPricingConfig( - JsonField.of(scalableMatrixWithUnitPricingConfig) - ) - - fun scalableMatrixWithUnitPricingConfig( - scalableMatrixWithUnitPricingConfig: - JsonField - ) = apply { - this.scalableMatrixWithUnitPricingConfig = scalableMatrixWithUnitPricingConfig - } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingScalableMatrixWithUnitPricingPrice = - NewFloatingScalableMatrixWithUnitPricingPrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired( - "scalableMatrixWithUnitPricingConfig", - scalableMatrixWithUnitPricingConfig, - ), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField - val SCALABLE_MATRIX_WITH_UNIT_PRICING = of("scalable_matrix_with_unit_pricing") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - SCALABLE_MATRIX_WITH_UNIT_PRICING - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - SCALABLE_MATRIX_WITH_UNIT_PRICING, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - SCALABLE_MATRIX_WITH_UNIT_PRICING -> Value.SCALABLE_MATRIX_WITH_UNIT_PRICING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - SCALABLE_MATRIX_WITH_UNIT_PRICING -> Known.SCALABLE_MATRIX_WITH_UNIT_PRICING - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class ScalableMatrixWithUnitPricingConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): ScalableMatrixWithUnitPricingConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ScalableMatrixWithUnitPricingConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig - ) = apply { - additionalProperties = - scalableMatrixWithUnitPricingConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): ScalableMatrixWithUnitPricingConfig = - ScalableMatrixWithUnitPricingConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ScalableMatrixWithUnitPricingConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ScalableMatrixWithUnitPricingConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingScalableMatrixWithUnitPricingPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && scalableMatrixWithUnitPricingConfig == other.scalableMatrixWithUnitPricingConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, scalableMatrixWithUnitPricingConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingScalableMatrixWithUnitPricingPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingScalableMatrixWithTieredPricingPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("scalable_matrix_with_tiered_pricing_config") - @ExcludeMissing - private val scalableMatrixWithTieredPricingConfig: - JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun scalableMatrixWithTieredPricingConfig(): ScalableMatrixWithTieredPricingConfig = - scalableMatrixWithTieredPricingConfig.getRequired( - "scalable_matrix_with_tiered_pricing_config" - ) - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("scalable_matrix_with_tiered_pricing_config") - @ExcludeMissing - fun _scalableMatrixWithTieredPricingConfig(): - JsonField = - scalableMatrixWithTieredPricingConfig - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingScalableMatrixWithTieredPricingPrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - itemId() - modelType() - name() - scalableMatrixWithTieredPricingConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingScalableMatrixWithTieredPricingPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var scalableMatrixWithTieredPricingConfig: - JsonField? = - null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newFloatingScalableMatrixWithTieredPricingPrice: - NewFloatingScalableMatrixWithTieredPricingPrice - ) = apply { - cadence = newFloatingScalableMatrixWithTieredPricingPrice.cadence - currency = newFloatingScalableMatrixWithTieredPricingPrice.currency - itemId = newFloatingScalableMatrixWithTieredPricingPrice.itemId - modelType = newFloatingScalableMatrixWithTieredPricingPrice.modelType - name = newFloatingScalableMatrixWithTieredPricingPrice.name - scalableMatrixWithTieredPricingConfig = - newFloatingScalableMatrixWithTieredPricingPrice - .scalableMatrixWithTieredPricingConfig - billableMetricId = - newFloatingScalableMatrixWithTieredPricingPrice.billableMetricId - billedInAdvance = - newFloatingScalableMatrixWithTieredPricingPrice.billedInAdvance - billingCycleConfiguration = - newFloatingScalableMatrixWithTieredPricingPrice.billingCycleConfiguration - conversionRate = newFloatingScalableMatrixWithTieredPricingPrice.conversionRate - externalPriceId = - newFloatingScalableMatrixWithTieredPricingPrice.externalPriceId - fixedPriceQuantity = - newFloatingScalableMatrixWithTieredPricingPrice.fixedPriceQuantity - invoiceGroupingKey = - newFloatingScalableMatrixWithTieredPricingPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingScalableMatrixWithTieredPricingPrice.invoicingCycleConfiguration - metadata = newFloatingScalableMatrixWithTieredPricingPrice.metadata - additionalProperties = - newFloatingScalableMatrixWithTieredPricingPrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun scalableMatrixWithTieredPricingConfig( - scalableMatrixWithTieredPricingConfig: ScalableMatrixWithTieredPricingConfig - ) = - scalableMatrixWithTieredPricingConfig( - JsonField.of(scalableMatrixWithTieredPricingConfig) - ) - - fun scalableMatrixWithTieredPricingConfig( - scalableMatrixWithTieredPricingConfig: - JsonField - ) = apply { - this.scalableMatrixWithTieredPricingConfig = - scalableMatrixWithTieredPricingConfig - } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingScalableMatrixWithTieredPricingPrice = - NewFloatingScalableMatrixWithTieredPricingPrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired( - "scalableMatrixWithTieredPricingConfig", - scalableMatrixWithTieredPricingConfig, - ), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField - val SCALABLE_MATRIX_WITH_TIERED_PRICING = - of("scalable_matrix_with_tiered_pricing") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - SCALABLE_MATRIX_WITH_TIERED_PRICING - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - SCALABLE_MATRIX_WITH_TIERED_PRICING, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - SCALABLE_MATRIX_WITH_TIERED_PRICING -> - Value.SCALABLE_MATRIX_WITH_TIERED_PRICING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - SCALABLE_MATRIX_WITH_TIERED_PRICING -> - Known.SCALABLE_MATRIX_WITH_TIERED_PRICING - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class ScalableMatrixWithTieredPricingConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): ScalableMatrixWithTieredPricingConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ScalableMatrixWithTieredPricingConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - scalableMatrixWithTieredPricingConfig: ScalableMatrixWithTieredPricingConfig - ) = apply { - additionalProperties = - scalableMatrixWithTieredPricingConfig.additionalProperties - .toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): ScalableMatrixWithTieredPricingConfig = - ScalableMatrixWithTieredPricingConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ScalableMatrixWithTieredPricingConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ScalableMatrixWithTieredPricingConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingScalableMatrixWithTieredPricingPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && scalableMatrixWithTieredPricingConfig == other.scalableMatrixWithTieredPricingConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, scalableMatrixWithTieredPricingConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingScalableMatrixWithTieredPricingPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingCumulativeGroupedBulkPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("cumulative_grouped_bulk_config") - @ExcludeMissing - private val cumulativeGroupedBulkConfig: JsonField = - JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - fun cumulativeGroupedBulkConfig(): CumulativeGroupedBulkConfig = - cumulativeGroupedBulkConfig.getRequired("cumulative_grouped_bulk_config") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this is - * true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - @JsonProperty("cumulative_grouped_bulk_config") - @ExcludeMissing - fun _cumulativeGroupedBulkConfig(): JsonField = - cumulativeGroupedBulkConfig - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingCumulativeGroupedBulkPrice = apply { - if (validated) { - return@apply - } - - cadence() - cumulativeGroupedBulkConfig().validate() - currency() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingCumulativeGroupedBulkPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var cumulativeGroupedBulkConfig: JsonField? = - null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newFloatingCumulativeGroupedBulkPrice: NewFloatingCumulativeGroupedBulkPrice - ) = apply { - cadence = newFloatingCumulativeGroupedBulkPrice.cadence - cumulativeGroupedBulkConfig = - newFloatingCumulativeGroupedBulkPrice.cumulativeGroupedBulkConfig - currency = newFloatingCumulativeGroupedBulkPrice.currency - itemId = newFloatingCumulativeGroupedBulkPrice.itemId - modelType = newFloatingCumulativeGroupedBulkPrice.modelType - name = newFloatingCumulativeGroupedBulkPrice.name - billableMetricId = newFloatingCumulativeGroupedBulkPrice.billableMetricId - billedInAdvance = newFloatingCumulativeGroupedBulkPrice.billedInAdvance - billingCycleConfiguration = - newFloatingCumulativeGroupedBulkPrice.billingCycleConfiguration - conversionRate = newFloatingCumulativeGroupedBulkPrice.conversionRate - externalPriceId = newFloatingCumulativeGroupedBulkPrice.externalPriceId - fixedPriceQuantity = newFloatingCumulativeGroupedBulkPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingCumulativeGroupedBulkPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingCumulativeGroupedBulkPrice.invoicingCycleConfiguration - metadata = newFloatingCumulativeGroupedBulkPrice.metadata - additionalProperties = - newFloatingCumulativeGroupedBulkPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - fun cumulativeGroupedBulkConfig( - cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig - ) = cumulativeGroupedBulkConfig(JsonField.of(cumulativeGroupedBulkConfig)) - - fun cumulativeGroupedBulkConfig( - cumulativeGroupedBulkConfig: JsonField - ) = apply { this.cumulativeGroupedBulkConfig = cumulativeGroupedBulkConfig } - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = currency(JsonField.of(currency)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingCumulativeGroupedBulkPrice = - NewFloatingCumulativeGroupedBulkPrice( - checkRequired("cadence", cadence), - checkRequired("cumulativeGroupedBulkConfig", cumulativeGroupedBulkConfig), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class CumulativeGroupedBulkConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CumulativeGroupedBulkConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CumulativeGroupedBulkConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig) = - apply { - additionalProperties = - cumulativeGroupedBulkConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): CumulativeGroupedBulkConfig = - CumulativeGroupedBulkConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CumulativeGroupedBulkConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CumulativeGroupedBulkConfig{additionalProperties=$additionalProperties}" - } - - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val CUMULATIVE_GROUPED_BULK = of("cumulative_grouped_bulk") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - CUMULATIVE_GROUPED_BULK - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - CUMULATIVE_GROUPED_BULK, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - CUMULATIVE_GROUPED_BULK -> Value.CUMULATIVE_GROUPED_BULK - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - CUMULATIVE_GROUPED_BULK -> Known.CUMULATIVE_GROUPED_BULK - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. If - * unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(invoicingCycleConfiguration: InvoicingCycleConfiguration) = - apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingCumulativeGroupedBulkPrice && cadence == other.cadence && cumulativeGroupedBulkConfig == other.cumulativeGroupedBulkConfig && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, cumulativeGroupedBulkConfig, currency, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingCumulativeGroupedBulkPrice{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - } - fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of [PriceCreateParams]. + * + * The following fields are required: + * ```java + * .newFloatingPriceModel() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -44338,151 +59,190 @@ private constructor( @NoAutoDetect class Builder internal constructor() { - private var body: Body? = null + private var newFloatingPriceModel: NewFloatingPriceModel? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(priceCreateParams: PriceCreateParams) = apply { - body = priceCreateParams.body + newFloatingPriceModel = priceCreateParams.newFloatingPriceModel additionalHeaders = priceCreateParams.additionalHeaders.toBuilder() additionalQueryParams = priceCreateParams.additionalQueryParams.toBuilder() } - fun body(body: Body) = apply { this.body = body } + fun newFloatingPriceModel(newFloatingPriceModel: NewFloatingPriceModel) = apply { + this.newFloatingPriceModel = newFloatingPriceModel + } - fun body(newFloatingUnitPrice: Body.NewFloatingUnitPrice) = - body(Body.ofNewFloatingUnitPrice(newFloatingUnitPrice)) + fun newFloatingPriceModel(unitPrice: NewFloatingPriceModel.NewFloatingUnitPrice) = + newFloatingPriceModel(NewFloatingPriceModel.ofUnitPrice(unitPrice)) - fun body(newFloatingPackagePrice: Body.NewFloatingPackagePrice) = - body(Body.ofNewFloatingPackagePrice(newFloatingPackagePrice)) + fun newFloatingPriceModel(packagePrice: NewFloatingPriceModel.NewFloatingPackagePrice) = + newFloatingPriceModel(NewFloatingPriceModel.ofPackagePrice(packagePrice)) - fun body(newFloatingMatrixPrice: Body.NewFloatingMatrixPrice) = - body(Body.ofNewFloatingMatrixPrice(newFloatingMatrixPrice)) + fun newFloatingPriceModel(matrixPrice: NewFloatingPriceModel.NewFloatingMatrixPrice) = + newFloatingPriceModel(NewFloatingPriceModel.ofMatrixPrice(matrixPrice)) - fun body(newFloatingMatrixWithAllocationPrice: Body.NewFloatingMatrixWithAllocationPrice) = - body(Body.ofNewFloatingMatrixWithAllocationPrice(newFloatingMatrixWithAllocationPrice)) + fun newFloatingPriceModel( + matrixWithAllocationPrice: NewFloatingPriceModel.NewFloatingMatrixWithAllocationPrice + ) = + newFloatingPriceModel( + NewFloatingPriceModel.ofMatrixWithAllocationPrice(matrixWithAllocationPrice) + ) - fun body(newFloatingTieredPrice: Body.NewFloatingTieredPrice) = - body(Body.ofNewFloatingTieredPrice(newFloatingTieredPrice)) + fun newFloatingPriceModel(tieredPrice: NewFloatingPriceModel.NewFloatingTieredPrice) = + newFloatingPriceModel(NewFloatingPriceModel.ofTieredPrice(tieredPrice)) - fun body(newFloatingTieredBpsPrice: Body.NewFloatingTieredBpsPrice) = - body(Body.ofNewFloatingTieredBpsPrice(newFloatingTieredBpsPrice)) + fun newFloatingPriceModel(tieredBpsPrice: NewFloatingPriceModel.NewFloatingTieredBpsPrice) = + newFloatingPriceModel(NewFloatingPriceModel.ofTieredBpsPrice(tieredBpsPrice)) - fun body(newFloatingBpsPrice: Body.NewFloatingBpsPrice) = - body(Body.ofNewFloatingBpsPrice(newFloatingBpsPrice)) + fun newFloatingPriceModel(bpsPrice: NewFloatingPriceModel.NewFloatingBpsPrice) = + newFloatingPriceModel(NewFloatingPriceModel.ofBpsPrice(bpsPrice)) - fun body(newFloatingBulkBpsPrice: Body.NewFloatingBulkBpsPrice) = - body(Body.ofNewFloatingBulkBpsPrice(newFloatingBulkBpsPrice)) + fun newFloatingPriceModel(bulkBpsPrice: NewFloatingPriceModel.NewFloatingBulkBpsPrice) = + newFloatingPriceModel(NewFloatingPriceModel.ofBulkBpsPrice(bulkBpsPrice)) - fun body(newFloatingBulkPrice: Body.NewFloatingBulkPrice) = - body(Body.ofNewFloatingBulkPrice(newFloatingBulkPrice)) + fun newFloatingPriceModel(bulkPrice: NewFloatingPriceModel.NewFloatingBulkPrice) = + newFloatingPriceModel(NewFloatingPriceModel.ofBulkPrice(bulkPrice)) - fun body(newFloatingThresholdTotalAmountPrice: Body.NewFloatingThresholdTotalAmountPrice) = - body(Body.ofNewFloatingThresholdTotalAmountPrice(newFloatingThresholdTotalAmountPrice)) + fun newFloatingPriceModel( + thresholdTotalAmountPrice: NewFloatingPriceModel.NewFloatingThresholdTotalAmountPrice + ) = + newFloatingPriceModel( + NewFloatingPriceModel.ofThresholdTotalAmountPrice(thresholdTotalAmountPrice) + ) - fun body(newFloatingTieredPackagePrice: Body.NewFloatingTieredPackagePrice) = - body(Body.ofNewFloatingTieredPackagePrice(newFloatingTieredPackagePrice)) + fun newFloatingPriceModel( + tieredPackagePrice: NewFloatingPriceModel.NewFloatingTieredPackagePrice + ) = newFloatingPriceModel(NewFloatingPriceModel.ofTieredPackagePrice(tieredPackagePrice)) - fun body(newFloatingGroupedTieredPrice: Body.NewFloatingGroupedTieredPrice) = - body(Body.ofNewFloatingGroupedTieredPrice(newFloatingGroupedTieredPrice)) + fun newFloatingPriceModel( + groupedTieredPrice: NewFloatingPriceModel.NewFloatingGroupedTieredPrice + ) = newFloatingPriceModel(NewFloatingPriceModel.ofGroupedTieredPrice(groupedTieredPrice)) - fun body( - newFloatingMaxGroupTieredPackagePrice: Body.NewFloatingMaxGroupTieredPackagePrice + fun newFloatingPriceModel( + maxGroupTieredPackagePrice: NewFloatingPriceModel.NewFloatingMaxGroupTieredPackagePrice ) = - body( - Body.ofNewFloatingMaxGroupTieredPackagePrice(newFloatingMaxGroupTieredPackagePrice) + newFloatingPriceModel( + NewFloatingPriceModel.ofMaxGroupTieredPackagePrice(maxGroupTieredPackagePrice) ) - fun body(newFloatingTieredWithMinimumPrice: Body.NewFloatingTieredWithMinimumPrice) = - body(Body.ofNewFloatingTieredWithMinimumPrice(newFloatingTieredWithMinimumPrice)) + fun newFloatingPriceModel( + tieredWithMinimumPrice: NewFloatingPriceModel.NewFloatingTieredWithMinimumPrice + ) = + newFloatingPriceModel( + NewFloatingPriceModel.ofTieredWithMinimumPrice(tieredWithMinimumPrice) + ) - fun body( - newFloatingPackageWithAllocationPrice: Body.NewFloatingPackageWithAllocationPrice + fun newFloatingPriceModel( + packageWithAllocationPrice: NewFloatingPriceModel.NewFloatingPackageWithAllocationPrice ) = - body( - Body.ofNewFloatingPackageWithAllocationPrice(newFloatingPackageWithAllocationPrice) + newFloatingPriceModel( + NewFloatingPriceModel.ofPackageWithAllocationPrice(packageWithAllocationPrice) ) - fun body( - newFloatingTieredPackageWithMinimumPrice: Body.NewFloatingTieredPackageWithMinimumPrice + fun newFloatingPriceModel( + tieredPackageWithMinimumPrice: + NewFloatingPriceModel.NewFloatingTieredPackageWithMinimumPrice ) = - body( - Body.ofNewFloatingTieredPackageWithMinimumPrice( - newFloatingTieredPackageWithMinimumPrice - ) + newFloatingPriceModel( + NewFloatingPriceModel.ofTieredPackageWithMinimumPrice(tieredPackageWithMinimumPrice) ) - fun body(newFloatingUnitWithPercentPrice: Body.NewFloatingUnitWithPercentPrice) = - body(Body.ofNewFloatingUnitWithPercentPrice(newFloatingUnitWithPercentPrice)) + fun newFloatingPriceModel( + unitWithPercentPrice: NewFloatingPriceModel.NewFloatingUnitWithPercentPrice + ) = + newFloatingPriceModel( + NewFloatingPriceModel.ofUnitWithPercentPrice(unitWithPercentPrice) + ) - fun body(newFloatingTieredWithProrationPrice: Body.NewFloatingTieredWithProrationPrice) = - body(Body.ofNewFloatingTieredWithProrationPrice(newFloatingTieredWithProrationPrice)) + fun newFloatingPriceModel( + tieredWithProrationPrice: NewFloatingPriceModel.NewFloatingTieredWithProrationPrice + ) = + newFloatingPriceModel( + NewFloatingPriceModel.ofTieredWithProrationPrice(tieredWithProrationPrice) + ) - fun body(newFloatingUnitWithProrationPrice: Body.NewFloatingUnitWithProrationPrice) = - body(Body.ofNewFloatingUnitWithProrationPrice(newFloatingUnitWithProrationPrice)) + fun newFloatingPriceModel( + unitWithProrationPrice: NewFloatingPriceModel.NewFloatingUnitWithProrationPrice + ) = + newFloatingPriceModel( + NewFloatingPriceModel.ofUnitWithProrationPrice(unitWithProrationPrice) + ) - fun body(newFloatingGroupedAllocationPrice: Body.NewFloatingGroupedAllocationPrice) = - body(Body.ofNewFloatingGroupedAllocationPrice(newFloatingGroupedAllocationPrice)) + fun newFloatingPriceModel( + groupedAllocationPrice: NewFloatingPriceModel.NewFloatingGroupedAllocationPrice + ) = + newFloatingPriceModel( + NewFloatingPriceModel.ofGroupedAllocationPrice(groupedAllocationPrice) + ) - fun body( - newFloatingGroupedWithProratedMinimumPrice: - Body.NewFloatingGroupedWithProratedMinimumPrice + fun newFloatingPriceModel( + groupedWithProratedMinimumPrice: + NewFloatingPriceModel.NewFloatingGroupedWithProratedMinimumPrice ) = - body( - Body.ofNewFloatingGroupedWithProratedMinimumPrice( - newFloatingGroupedWithProratedMinimumPrice + newFloatingPriceModel( + NewFloatingPriceModel.ofGroupedWithProratedMinimumPrice( + groupedWithProratedMinimumPrice ) ) - fun body( - newFloatingGroupedWithMeteredMinimumPrice: - Body.NewFloatingGroupedWithMeteredMinimumPrice + fun newFloatingPriceModel( + groupedWithMeteredMinimumPrice: + NewFloatingPriceModel.NewFloatingGroupedWithMeteredMinimumPrice ) = - body( - Body.ofNewFloatingGroupedWithMeteredMinimumPrice( - newFloatingGroupedWithMeteredMinimumPrice + newFloatingPriceModel( + NewFloatingPriceModel.ofGroupedWithMeteredMinimumPrice( + groupedWithMeteredMinimumPrice ) ) - fun body( - newFloatingMatrixWithDisplayNamePrice: Body.NewFloatingMatrixWithDisplayNamePrice + fun newFloatingPriceModel( + matrixWithDisplayNamePrice: NewFloatingPriceModel.NewFloatingMatrixWithDisplayNamePrice ) = - body( - Body.ofNewFloatingMatrixWithDisplayNamePrice(newFloatingMatrixWithDisplayNamePrice) + newFloatingPriceModel( + NewFloatingPriceModel.ofMatrixWithDisplayNamePrice(matrixWithDisplayNamePrice) ) - fun body(newFloatingBulkWithProrationPrice: Body.NewFloatingBulkWithProrationPrice) = - body(Body.ofNewFloatingBulkWithProrationPrice(newFloatingBulkWithProrationPrice)) + fun newFloatingPriceModel( + bulkWithProrationPrice: NewFloatingPriceModel.NewFloatingBulkWithProrationPrice + ) = + newFloatingPriceModel( + NewFloatingPriceModel.ofBulkWithProrationPrice(bulkWithProrationPrice) + ) - fun body(newFloatingGroupedTieredPackagePrice: Body.NewFloatingGroupedTieredPackagePrice) = - body(Body.ofNewFloatingGroupedTieredPackagePrice(newFloatingGroupedTieredPackagePrice)) + fun newFloatingPriceModel( + groupedTieredPackagePrice: NewFloatingPriceModel.NewFloatingGroupedTieredPackagePrice + ) = + newFloatingPriceModel( + NewFloatingPriceModel.ofGroupedTieredPackagePrice(groupedTieredPackagePrice) + ) - fun body( - newFloatingScalableMatrixWithUnitPricingPrice: - Body.NewFloatingScalableMatrixWithUnitPricingPrice + fun newFloatingPriceModel( + scalableMatrixWithUnitPricingPrice: + NewFloatingPriceModel.NewFloatingScalableMatrixWithUnitPricingPrice ) = - body( - Body.ofNewFloatingScalableMatrixWithUnitPricingPrice( - newFloatingScalableMatrixWithUnitPricingPrice + newFloatingPriceModel( + NewFloatingPriceModel.ofScalableMatrixWithUnitPricingPrice( + scalableMatrixWithUnitPricingPrice ) ) - fun body( - newFloatingScalableMatrixWithTieredPricingPrice: - Body.NewFloatingScalableMatrixWithTieredPricingPrice + fun newFloatingPriceModel( + scalableMatrixWithTieredPricingPrice: + NewFloatingPriceModel.NewFloatingScalableMatrixWithTieredPricingPrice ) = - body( - Body.ofNewFloatingScalableMatrixWithTieredPricingPrice( - newFloatingScalableMatrixWithTieredPricingPrice + newFloatingPriceModel( + NewFloatingPriceModel.ofScalableMatrixWithTieredPricingPrice( + scalableMatrixWithTieredPricingPrice ) ) - fun body( - newFloatingCumulativeGroupedBulkPrice: Body.NewFloatingCumulativeGroupedBulkPrice + fun newFloatingPriceModel( + cumulativeGroupedBulkPrice: NewFloatingPriceModel.NewFloatingCumulativeGroupedBulkPrice ) = - body( - Body.ofNewFloatingCumulativeGroupedBulkPrice(newFloatingCumulativeGroupedBulkPrice) + newFloatingPriceModel( + NewFloatingPriceModel.ofCumulativeGroupedBulkPrice(cumulativeGroupedBulkPrice) ) fun additionalHeaders(additionalHeaders: Headers) = apply { @@ -44585,7 +345,7 @@ private constructor( fun build(): PriceCreateParams = PriceCreateParams( - checkRequired("body", body), + checkRequired("newFloatingPriceModel", newFloatingPriceModel), additionalHeaders.build(), additionalQueryParams.build(), ) @@ -44596,11 +356,11 @@ private constructor( return true } - return /* spotless:off */ other is PriceCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is PriceCreateParams && newFloatingPriceModel == other.newFloatingPriceModel && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(newFloatingPriceModel, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "PriceCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "PriceCreateParams{newFloatingPriceModel=$newFloatingPriceModel, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } 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 4d9a0f0d4..01f137e57 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 @@ -12,6 +12,7 @@ import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.Params +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams @@ -230,6 +231,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .timeframeEnd() + * .timeframeStart() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -336,14 +346,8 @@ private constructor( */ fun addGroupingKey(groupingKey: String) = apply { groupingKeys = - (groupingKeys ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(groupingKey) + (groupingKeys ?: JsonField.of(mutableListOf())).also { + checkKnown("groupingKeys", it).add(groupingKey) } } @@ -400,6 +404,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [PriceEvaluateParams]. + * + * The following fields are required: + * ```java + * .priceId() + * .timeframeEnd() + * .timeframeStart() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 15d089db8..5e7af5769 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 @@ -11,6 +11,7 @@ import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.immutableEmptyMap import com.withorb.api.core.toImmutable @@ -49,6 +50,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [PriceEvaluateResponse]. + * + * The following fields are required: + * ```java + * .data() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -72,14 +81,8 @@ private constructor( fun addData(data: EvaluatePriceGroup) = apply { this.data = - (this.data ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(data) + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceExternalPriceIdFetchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceExternalPriceIdFetchParams.kt index 52101f08f..3a0cd2601 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceExternalPriceIdFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceExternalPriceIdFetchParams.kt @@ -42,6 +42,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [PriceExternalPriceIdFetchParams]. + * + * The following fields are required: + * ```java + * .externalPriceId() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 350357d41..fa700e38b 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 @@ -2,23 +2,13 @@ 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.NoAutoDetect 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.immutableEmptyMap -import com.withorb.api.core.toImmutable import java.util.Objects -import java.util.Optional /** * This endpoint allows you to update the `metadata` property on a price. If you pass null for the @@ -27,34 +17,23 @@ import java.util.Optional class PriceExternalPriceIdUpdateParams private constructor( private val externalPriceId: String, - private val body: Body, + private val updatePriceRequestParams: UpdatePriceRequestParams, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { fun externalPriceId(): String = 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`. - */ - fun metadata(): Optional = body.metadata() + fun updatePriceRequestParams(): UpdatePriceRequestParams = updatePriceRequestParams - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - */ - fun _metadata(): JsonField = body._metadata() - - fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalBodyProperties(): Map = + updatePriceRequestParams._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): UpdatePriceRequestParams = updatePriceRequestParams override fun _headers(): Headers = additionalHeaders @@ -67,130 +46,20 @@ private constructor( } } - @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by setting - * `metadata` to `null`. - */ - fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * User-specified key/value pairs for the resource. 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - metadata = body.metadata - additionalProperties = body.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`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): Body = Body(metadata, additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Body && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{metadata=$metadata, additionalProperties=$additionalProperties}" - } - fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of + * [PriceExternalPriceIdUpdateParams]. + * + * The following fields are required: + * ```java + * .externalPriceId() + * .updatePriceRequestParams() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -199,7 +68,7 @@ private constructor( class Builder internal constructor() { private var externalPriceId: String? = null - private var body: Body.Builder = Body.builder() + private var updatePriceRequestParams: UpdatePriceRequestParams? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -207,7 +76,7 @@ private constructor( internal fun from(priceExternalPriceIdUpdateParams: PriceExternalPriceIdUpdateParams) = apply { externalPriceId = priceExternalPriceIdUpdateParams.externalPriceId - body = priceExternalPriceIdUpdateParams.body.toBuilder() + updatePriceRequestParams = priceExternalPriceIdUpdateParams.updatePriceRequestParams additionalHeaders = priceExternalPriceIdUpdateParams.additionalHeaders.toBuilder() additionalQueryParams = priceExternalPriceIdUpdateParams.additionalQueryParams.toBuilder() @@ -217,44 +86,8 @@ private constructor( 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`. - */ - fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by setting - * `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: JsonField) = apply { body.metadata(metadata) } - - 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 updatePriceRequestParams(updatePriceRequestParams: UpdatePriceRequestParams) = apply { + this.updatePriceRequestParams = updatePriceRequestParams } fun additionalHeaders(additionalHeaders: Headers) = apply { @@ -358,105 +191,22 @@ private constructor( fun build(): PriceExternalPriceIdUpdateParams = PriceExternalPriceIdUpdateParams( checkRequired("externalPriceId", externalPriceId), - body.build(), + checkRequired("updatePriceRequestParams", updatePriceRequestParams), additionalHeaders.build(), additionalQueryParams.build(), ) } - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PriceExternalPriceIdUpdateParams && externalPriceId == other.externalPriceId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is PriceExternalPriceIdUpdateParams && externalPriceId == other.externalPriceId && updatePriceRequestParams == other.updatePriceRequestParams && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(externalPriceId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(externalPriceId, updatePriceRequestParams, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "PriceExternalPriceIdUpdateParams{externalPriceId=$externalPriceId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "PriceExternalPriceIdUpdateParams{externalPriceId=$externalPriceId, updatePriceRequestParams=$updatePriceRequestParams, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceFetchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceFetchParams.kt index 538ad6e68..426ea9252 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceFetchParams.kt @@ -38,6 +38,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [PriceFetchParams]. + * + * The following fields are required: + * ```java + * .priceId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceIntervalFixedFeeQuantityTransitionModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceIntervalFixedFeeQuantityTransitionModel.kt new file mode 100644 index 000000000..33c726d7a --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceIntervalFixedFeeQuantityTransitionModel.kt @@ -0,0 +1,156 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.time.OffsetDateTime +import java.util.Objects + +@NoAutoDetect +class PriceIntervalFixedFeeQuantityTransitionModel +@JsonCreator +private constructor( + @JsonProperty("effective_date") + @ExcludeMissing + private val effectiveDate: JsonField = JsonMissing.of(), + @JsonProperty("quantity") + @ExcludeMissing + private val quantity: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** The date that the fixed fee quantity transition should take effect. */ + fun effectiveDate(): OffsetDateTime = effectiveDate.getRequired("effective_date") + + /** The quantity of the fixed fee quantity transition. */ + fun quantity(): Long = quantity.getRequired("quantity") + + /** The date that the fixed fee quantity transition should take effect. */ + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate + + /** The quantity of the fixed fee quantity transition. */ + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): PriceIntervalFixedFeeQuantityTransitionModel = apply { + if (validated) { + return@apply + } + + effectiveDate() + quantity() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PriceIntervalFixedFeeQuantityTransitionModel]. + * + * The following fields are required: + * ```java + * .effectiveDate() + * .quantity() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PriceIntervalFixedFeeQuantityTransitionModel]. */ + class Builder internal constructor() { + + private var effectiveDate: JsonField? = null + private var quantity: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + priceIntervalFixedFeeQuantityTransitionModel: + PriceIntervalFixedFeeQuantityTransitionModel + ) = apply { + effectiveDate = priceIntervalFixedFeeQuantityTransitionModel.effectiveDate + quantity = priceIntervalFixedFeeQuantityTransitionModel.quantity + additionalProperties = + priceIntervalFixedFeeQuantityTransitionModel.additionalProperties.toMutableMap() + } + + /** The date that the fixed fee quantity transition should take effect. */ + fun effectiveDate(effectiveDate: OffsetDateTime) = + effectiveDate(JsonField.of(effectiveDate)) + + /** The date that the fixed fee quantity transition should take effect. */ + fun effectiveDate(effectiveDate: JsonField) = apply { + this.effectiveDate = effectiveDate + } + + /** The quantity of the fixed fee quantity transition. */ + fun quantity(quantity: Long) = quantity(JsonField.of(quantity)) + + /** The quantity of the fixed fee quantity transition. */ + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): PriceIntervalFixedFeeQuantityTransitionModel = + PriceIntervalFixedFeeQuantityTransitionModel( + checkRequired("effectiveDate", effectiveDate), + checkRequired("quantity", quantity), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceIntervalFixedFeeQuantityTransitionModel && effectiveDate == other.effectiveDate && quantity == other.quantity && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(effectiveDate, quantity, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PriceIntervalFixedFeeQuantityTransitionModel{effectiveDate=$effectiveDate, quantity=$quantity, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceIntervalModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceIntervalModel.kt new file mode 100644 index 000000000..3ec8f2db5 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceIntervalModel.kt @@ -0,0 +1,1111 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +/** + * The Price Interval resource represents a period of time for which a price will bill on a + * subscription. A subscription’s price intervals define its billing behavior. + */ +@NoAutoDetect +class PriceIntervalModel +@JsonCreator +private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_day") + @ExcludeMissing + private val billingCycleDay: JsonField = JsonMissing.of(), + @JsonProperty("current_billing_period_end_date") + @ExcludeMissing + private val currentBillingPeriodEndDate: JsonField = JsonMissing.of(), + @JsonProperty("current_billing_period_start_date") + @ExcludeMissing + private val currentBillingPeriodStartDate: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + private val endDate: JsonField = JsonMissing.of(), + @JsonProperty("filter") + @ExcludeMissing + private val filter: JsonField = JsonMissing.of(), + @JsonProperty("fixed_fee_quantity_transitions") + @ExcludeMissing + private val fixedFeeQuantityTransitions: JsonField> = + JsonMissing.of(), + @JsonProperty("price") + @ExcludeMissing + private val price: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + private val startDate: JsonField = JsonMissing.of(), + @JsonProperty("usage_customer_ids") + @ExcludeMissing + private val usageCustomerIds: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun id(): String = id.getRequired("id") + + /** The day of the month that Orb bills for this price */ + fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the instant + * returned is exactly the end of the billing period. Set to null if this price interval is not + * currently active. + */ + fun currentBillingPeriodEndDate(): Optional = + Optional.ofNullable( + currentBillingPeriodEndDate.getNullable("current_billing_period_end_date") + ) + + /** + * The start date of the current billing period. This is an inclusive timestamp; the instant + * returned is exactly the beginning of the billing period. Set to null if this price interval + * is not currently active. + */ + fun currentBillingPeriodStartDate(): Optional = + Optional.ofNullable( + currentBillingPeriodStartDate.getNullable("current_billing_period_start_date") + ) + + /** + * The end date of the price interval. This is the date that Orb stops billing for this price. + */ + fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) + + /** An additional filter to apply to usage queries. */ + fun filter(): Optional = Optional.ofNullable(filter.getNullable("filter")) + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for fixed + * fees. + */ + fun fixedFeeQuantityTransitions(): Optional> = + Optional.ofNullable( + fixedFeeQuantityTransitions.getNullable("fixed_fee_quantity_transitions") + ) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in a + * charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key for + * the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ + fun price(): PriceModel = price.getRequired("price") + + /** + * The start date of the price interval. This is the date that Orb starts billing for this + * price. + */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * A list of customer IDs whose usage events will be aggregated and billed under this price + * interval. + */ + fun usageCustomerIds(): Optional> = + Optional.ofNullable(usageCustomerIds.getNullable("usage_customer_ids")) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** The day of the month that Orb bills for this price */ + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun _billingCycleDay(): JsonField = billingCycleDay + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the instant + * returned is exactly the end of the billing period. Set to null if this price interval is not + * currently active. + */ + @JsonProperty("current_billing_period_end_date") + @ExcludeMissing + fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate + + /** + * The start date of the current billing period. This is an inclusive timestamp; the instant + * returned is exactly the beginning of the billing period. Set to null if this price interval + * is not currently active. + */ + @JsonProperty("current_billing_period_start_date") + @ExcludeMissing + fun _currentBillingPeriodStartDate(): JsonField = currentBillingPeriodStartDate + + /** + * The end date of the price interval. This is the date that Orb stops billing for this price. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + /** An additional filter to apply to usage queries. */ + @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField = filter + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for fixed + * fees. + */ + @JsonProperty("fixed_fee_quantity_transitions") + @ExcludeMissing + fun _fixedFeeQuantityTransitions(): JsonField> = + fixedFeeQuantityTransitions + + /** + * 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) + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + + /** + * The start date of the price interval. This is the date that Orb starts billing for this + * price. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + /** + * A list of customer IDs whose usage events will be aggregated and billed under this price + * interval. + */ + @JsonProperty("usage_customer_ids") + @ExcludeMissing + fun _usageCustomerIds(): JsonField> = usageCustomerIds + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): PriceIntervalModel = apply { + if (validated) { + return@apply + } + + id() + billingCycleDay() + currentBillingPeriodEndDate() + currentBillingPeriodStartDate() + endDate() + filter() + fixedFeeQuantityTransitions().ifPresent { it.forEach { it.validate() } } + price().validate() + startDate() + usageCustomerIds() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PriceIntervalModel]. + * + * The following fields are required: + * ```java + * .id() + * .billingCycleDay() + * .currentBillingPeriodEndDate() + * .currentBillingPeriodStartDate() + * .endDate() + * .filter() + * .fixedFeeQuantityTransitions() + * .price() + * .startDate() + * .usageCustomerIds() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PriceIntervalModel]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billingCycleDay: JsonField? = null + private var currentBillingPeriodEndDate: JsonField? = null + private var currentBillingPeriodStartDate: JsonField? = null + private var endDate: JsonField? = null + private var filter: JsonField? = null + private var fixedFeeQuantityTransitions: + JsonField>? = + null + private var price: JsonField? = null + private var startDate: JsonField? = null + private var usageCustomerIds: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(priceIntervalModel: PriceIntervalModel) = apply { + id = priceIntervalModel.id + billingCycleDay = priceIntervalModel.billingCycleDay + currentBillingPeriodEndDate = priceIntervalModel.currentBillingPeriodEndDate + currentBillingPeriodStartDate = priceIntervalModel.currentBillingPeriodStartDate + endDate = priceIntervalModel.endDate + filter = priceIntervalModel.filter + fixedFeeQuantityTransitions = + priceIntervalModel.fixedFeeQuantityTransitions.map { it.toMutableList() } + price = priceIntervalModel.price + startDate = priceIntervalModel.startDate + usageCustomerIds = priceIntervalModel.usageCustomerIds.map { it.toMutableList() } + additionalProperties = priceIntervalModel.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + /** The day of the month that Orb bills for this price */ + fun billingCycleDay(billingCycleDay: Long) = billingCycleDay(JsonField.of(billingCycleDay)) + + /** The day of the month that Orb bills for this price */ + fun billingCycleDay(billingCycleDay: JsonField) = apply { + this.billingCycleDay = billingCycleDay + } + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is exactly the end of the billing period. Set to null if this price + * interval is not currently active. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = + currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is exactly the end of the billing period. Set to null if this price + * interval is not currently active. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = + currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is exactly the end of the billing period. Set to null if this price + * interval is not currently active. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: JsonField) = + apply { + this.currentBillingPeriodEndDate = currentBillingPeriodEndDate + } + + /** + * The start date of the current billing period. This is an inclusive timestamp; the instant + * returned is exactly the beginning of the billing period. Set to null if this price + * interval is not currently active. + */ + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = + currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) + + /** + * The start date of the current billing period. This is an inclusive timestamp; the instant + * returned is exactly the beginning of the billing period. Set to null if this price + * interval is not currently active. + */ + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: Optional) = + currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) + + /** + * The start date of the current billing period. This is an inclusive timestamp; the instant + * returned is exactly the beginning of the billing period. Set to null if this price + * interval is not currently active. + */ + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: JsonField + ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** An additional filter to apply to usage queries. */ + fun filter(filter: String?) = filter(JsonField.ofNullable(filter)) + + /** An additional filter to apply to usage queries. */ + fun filter(filter: Optional) = filter(filter.orElse(null)) + + /** An additional filter to apply to usage queries. */ + fun filter(filter: JsonField) = apply { this.filter = filter } + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: List? + ) = fixedFeeQuantityTransitions(JsonField.ofNullable(fixedFeeQuantityTransitions)) + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: Optional> + ) = fixedFeeQuantityTransitions(fixedFeeQuantityTransitions.orElse(null)) + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: JsonField> + ) = apply { + this.fixedFeeQuantityTransitions = + fixedFeeQuantityTransitions.map { it.toMutableList() } + } + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + fun addFixedFeeQuantityTransition(fixedFeeQuantityTransition: FixedFeeQuantityTransition) = + apply { + fixedFeeQuantityTransitions = + (fixedFeeQuantityTransitions ?: JsonField.of(mutableListOf())).also { + checkKnown("fixedFeeQuantityTransitions", it) + .add(fixedFeeQuantityTransition) + } + } + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ + fun price(price: PriceModel) = price(JsonField.of(price)) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ + fun price(price: JsonField) = apply { this.price = price } + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ + fun price(unitPrice: PriceModel.UnitPrice) = price(PriceModel.ofUnitPrice(unitPrice)) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ + fun price(packagePrice: PriceModel.PackagePrice) = + price(PriceModel.ofPackagePrice(packagePrice)) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ + fun price(matrixPrice: PriceModel.MatrixPrice) = + price(PriceModel.ofMatrixPrice(matrixPrice)) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ + fun price(tieredPrice: PriceModel.TieredPrice) = + price(PriceModel.ofTieredPrice(tieredPrice)) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ + fun price(tieredBpsPrice: PriceModel.TieredBpsPrice) = + price(PriceModel.ofTieredBpsPrice(tieredBpsPrice)) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ + fun price(bpsPrice: PriceModel.BpsPrice) = price(PriceModel.ofBpsPrice(bpsPrice)) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ + fun price(bulkBpsPrice: PriceModel.BulkBpsPrice) = + price(PriceModel.ofBulkBpsPrice(bulkBpsPrice)) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ + fun price(bulkPrice: PriceModel.BulkPrice) = price(PriceModel.ofBulkPrice(bulkPrice)) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ + fun price(thresholdTotalAmountPrice: PriceModel.ThresholdTotalAmountPrice) = + price(PriceModel.ofThresholdTotalAmountPrice(thresholdTotalAmountPrice)) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ + fun price(tieredPackagePrice: PriceModel.TieredPackagePrice) = + price(PriceModel.ofTieredPackagePrice(tieredPackagePrice)) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ + fun price(groupedTieredPrice: PriceModel.GroupedTieredPrice) = + price(PriceModel.ofGroupedTieredPrice(groupedTieredPrice)) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ + fun price(tieredWithMinimumPrice: PriceModel.TieredWithMinimumPrice) = + price(PriceModel.ofTieredWithMinimumPrice(tieredWithMinimumPrice)) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ + fun price(tieredPackageWithMinimumPrice: PriceModel.TieredPackageWithMinimumPrice) = + price(PriceModel.ofTieredPackageWithMinimumPrice(tieredPackageWithMinimumPrice)) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ + fun price(packageWithAllocationPrice: PriceModel.PackageWithAllocationPrice) = + price(PriceModel.ofPackageWithAllocationPrice(packageWithAllocationPrice)) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ + fun price(unitWithPercentPrice: PriceModel.UnitWithPercentPrice) = + price(PriceModel.ofUnitWithPercentPrice(unitWithPercentPrice)) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ + fun price(matrixWithAllocationPrice: PriceModel.MatrixWithAllocationPrice) = + price(PriceModel.ofMatrixWithAllocationPrice(matrixWithAllocationPrice)) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ + fun price(tieredWithProrationPrice: PriceModel.TieredWithProrationPrice) = + price(PriceModel.ofTieredWithProrationPrice(tieredWithProrationPrice)) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ + fun price(unitWithProrationPrice: PriceModel.UnitWithProrationPrice) = + price(PriceModel.ofUnitWithProrationPrice(unitWithProrationPrice)) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ + fun price(groupedAllocationPrice: PriceModel.GroupedAllocationPrice) = + price(PriceModel.ofGroupedAllocationPrice(groupedAllocationPrice)) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ + fun price(groupedWithProratedMinimumPrice: PriceModel.GroupedWithProratedMinimumPrice) = + price(PriceModel.ofGroupedWithProratedMinimumPrice(groupedWithProratedMinimumPrice)) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ + fun price(groupedWithMeteredMinimumPrice: PriceModel.GroupedWithMeteredMinimumPrice) = + price(PriceModel.ofGroupedWithMeteredMinimumPrice(groupedWithMeteredMinimumPrice)) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ + fun price(matrixWithDisplayNamePrice: PriceModel.MatrixWithDisplayNamePrice) = + price(PriceModel.ofMatrixWithDisplayNamePrice(matrixWithDisplayNamePrice)) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ + fun price(bulkWithProrationPrice: PriceModel.BulkWithProrationPrice) = + price(PriceModel.ofBulkWithProrationPrice(bulkWithProrationPrice)) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ + fun price(groupedTieredPackagePrice: PriceModel.GroupedTieredPackagePrice) = + price(PriceModel.ofGroupedTieredPackagePrice(groupedTieredPackagePrice)) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ + fun price(maxGroupTieredPackagePrice: PriceModel.MaxGroupTieredPackagePrice) = + price(PriceModel.ofMaxGroupTieredPackagePrice(maxGroupTieredPackagePrice)) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ + fun price( + scalableMatrixWithUnitPricingPrice: PriceModel.ScalableMatrixWithUnitPricingPrice + ) = + price( + PriceModel.ofScalableMatrixWithUnitPricingPrice(scalableMatrixWithUnitPricingPrice) + ) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ + fun price( + scalableMatrixWithTieredPricingPrice: PriceModel.ScalableMatrixWithTieredPricingPrice + ) = + price( + PriceModel.ofScalableMatrixWithTieredPricingPrice( + scalableMatrixWithTieredPricingPrice + ) + ) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * For more on the types of prices, see + * [the core concepts documentation](/core-concepts#plan-and-price) + */ + fun price(cumulativeGroupedBulkPrice: PriceModel.CumulativeGroupedBulkPrice) = + price(PriceModel.ofCumulativeGroupedBulkPrice(cumulativeGroupedBulkPrice)) + + /** + * The start date of the price interval. This is the date that Orb starts billing for this + * price. + */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** + * The start date of the price interval. This is the date that Orb starts billing for this + * price. + */ + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + /** + * A list of customer IDs whose usage events will be aggregated and billed under this price + * interval. + */ + fun usageCustomerIds(usageCustomerIds: List?) = + usageCustomerIds(JsonField.ofNullable(usageCustomerIds)) + + /** + * A list of customer IDs whose usage events will be aggregated and billed under this price + * interval. + */ + fun usageCustomerIds(usageCustomerIds: Optional>) = + usageCustomerIds(usageCustomerIds.orElse(null)) + + /** + * A list of customer IDs whose usage events will be aggregated and billed under this price + * interval. + */ + fun usageCustomerIds(usageCustomerIds: JsonField>) = apply { + this.usageCustomerIds = usageCustomerIds.map { it.toMutableList() } + } + + /** + * A list of customer IDs whose usage events will be aggregated and billed under this price + * interval. + */ + fun addUsageCustomerId(usageCustomerId: String) = apply { + usageCustomerIds = + (usageCustomerIds ?: JsonField.of(mutableListOf())).also { + checkKnown("usageCustomerIds", it).add(usageCustomerId) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): PriceIntervalModel = + PriceIntervalModel( + checkRequired("id", id), + checkRequired("billingCycleDay", billingCycleDay), + checkRequired("currentBillingPeriodEndDate", currentBillingPeriodEndDate), + checkRequired("currentBillingPeriodStartDate", currentBillingPeriodStartDate), + checkRequired("endDate", endDate), + checkRequired("filter", filter), + checkRequired("fixedFeeQuantityTransitions", fixedFeeQuantityTransitions).map { + it.toImmutable() + }, + checkRequired("price", price), + checkRequired("startDate", startDate), + checkRequired("usageCustomerIds", usageCustomerIds).map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + @NoAutoDetect + class FixedFeeQuantityTransition + @JsonCreator + private constructor( + @JsonProperty("effective_date") + @ExcludeMissing + private val effectiveDate: JsonField = JsonMissing.of(), + @JsonProperty("price_id") + @ExcludeMissing + private val priceId: JsonField = JsonMissing.of(), + @JsonProperty("quantity") + @ExcludeMissing + private val quantity: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun effectiveDate(): OffsetDateTime = effectiveDate.getRequired("effective_date") + + fun priceId(): String = priceId.getRequired("price_id") + + fun quantity(): Long = quantity.getRequired("quantity") + + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate + + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): FixedFeeQuantityTransition = apply { + if (validated) { + return@apply + } + + effectiveDate() + priceId() + quantity() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [FixedFeeQuantityTransition]. + * + * The following fields are required: + * ```java + * .effectiveDate() + * .priceId() + * .quantity() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FixedFeeQuantityTransition]. */ + class Builder internal constructor() { + + private var effectiveDate: JsonField? = null + private var priceId: JsonField? = null + private var quantity: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fixedFeeQuantityTransition: FixedFeeQuantityTransition) = apply { + effectiveDate = fixedFeeQuantityTransition.effectiveDate + priceId = fixedFeeQuantityTransition.priceId + quantity = fixedFeeQuantityTransition.quantity + additionalProperties = + fixedFeeQuantityTransition.additionalProperties.toMutableMap() + } + + fun effectiveDate(effectiveDate: OffsetDateTime) = + effectiveDate(JsonField.of(effectiveDate)) + + fun effectiveDate(effectiveDate: JsonField) = apply { + this.effectiveDate = effectiveDate + } + + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun quantity(quantity: Long) = quantity(JsonField.of(quantity)) + + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): FixedFeeQuantityTransition = + FixedFeeQuantityTransition( + checkRequired("effectiveDate", effectiveDate), + checkRequired("priceId", priceId), + checkRequired("quantity", quantity), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FixedFeeQuantityTransition && effectiveDate == other.effectiveDate && priceId == other.priceId && quantity == other.quantity && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(effectiveDate, priceId, quantity, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FixedFeeQuantityTransition{effectiveDate=$effectiveDate, priceId=$priceId, quantity=$quantity, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceIntervalModel && id == other.id && billingCycleDay == other.billingCycleDay && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && endDate == other.endDate && filter == other.filter && fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && price == other.price && startDate == other.startDate && usageCustomerIds == other.usageCustomerIds && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billingCycleDay, currentBillingPeriodEndDate, currentBillingPeriodStartDate, endDate, filter, fixedFeeQuantityTransitions, price, startDate, usageCustomerIds, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PriceIntervalModel{id=$id, billingCycleDay=$billingCycleDay, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, endDate=$endDate, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, price=$price, startDate=$startDate, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListPage.kt index 35c604ef9..0ece03bc8 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListPage.kt @@ -32,7 +32,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -87,20 +87,20 @@ private constructor( class Response @JsonCreator constructor( - @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), + @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = Optional.ofNullable(data) + fun _data(): Optional>> = Optional.ofNullable(data) @JsonProperty("pagination_metadata") fun _paginationMetadata(): Optional> = @@ -139,12 +139,13 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [PriceListPage]. */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -155,9 +156,9 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { this.data = data } fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) @@ -174,9 +175,9 @@ private constructor( } } - class AutoPager(private val firstPage: PriceListPage) : Iterable { + class AutoPager(private val firstPage: PriceListPage) : Iterable { - override fun iterator(): Iterator = iterator { + override fun iterator(): Iterator = iterator { var page = firstPage var index = 0 while (true) { @@ -188,7 +189,7 @@ private constructor( } } - fun stream(): Stream { + fun stream(): Stream { return StreamSupport.stream(spliterator(), false) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListPageAsync.kt index 94335c1ec..475e50a72 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListPageAsync.kt @@ -33,7 +33,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -90,20 +90,20 @@ private constructor( class Response @JsonCreator constructor( - @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), + @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = Optional.ofNullable(data) + fun _data(): Optional>> = Optional.ofNullable(data) @JsonProperty("pagination_metadata") fun _paginationMetadata(): Optional> = @@ -142,12 +142,13 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [PriceListPageAsync]. */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -158,9 +159,9 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { this.data = data } fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) @@ -179,9 +180,9 @@ private constructor( class AutoPager(private val firstPage: PriceListPageAsync) { - fun forEach(action: Predicate, executor: Executor): CompletableFuture { + fun forEach(action: Predicate, executor: Executor): CompletableFuture { fun CompletableFuture>.forEach( - action: (Price) -> Boolean, + action: (PriceModel) -> Boolean, executor: Executor, ): CompletableFuture = thenComposeAsync( @@ -197,8 +198,8 @@ private constructor( .forEach(action::test, executor) } - fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() + fun toList(executor: Executor): CompletableFuture> { + val values = mutableListOf() return forEach(values::add, executor).thenApply { values } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListParams.kt index ce3fea2fc..c1a75a09a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListParams.kt @@ -50,6 +50,7 @@ private constructor( @JvmStatic fun none(): PriceListParams = builder().build() + /** Returns a mutable builder for constructing an instance of [PriceListParams]. */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceModel.kt new file mode 100644 index 000000000..2d8ea33d0 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceModel.kt @@ -0,0 +1,30886 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.BaseDeserializer +import com.withorb.api.core.BaseSerializer +import com.withorb.api.core.Enum +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.getOrThrow +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional +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) + */ +@JsonDeserialize(using = PriceModel.Deserializer::class) +@JsonSerialize(using = PriceModel.Serializer::class) +class PriceModel +private constructor( + private val unitPrice: UnitPrice? = null, + private val packagePrice: PackagePrice? = null, + private val matrixPrice: MatrixPrice? = null, + private val tieredPrice: TieredPrice? = null, + private val tieredBpsPrice: TieredBpsPrice? = null, + private val bpsPrice: BpsPrice? = null, + private val bulkBpsPrice: BulkBpsPrice? = null, + private val bulkPrice: BulkPrice? = null, + private val thresholdTotalAmountPrice: ThresholdTotalAmountPrice? = null, + private val tieredPackagePrice: TieredPackagePrice? = null, + private val groupedTieredPrice: GroupedTieredPrice? = null, + private val tieredWithMinimumPrice: TieredWithMinimumPrice? = null, + private val tieredPackageWithMinimumPrice: TieredPackageWithMinimumPrice? = null, + private val packageWithAllocationPrice: PackageWithAllocationPrice? = null, + private val unitWithPercentPrice: UnitWithPercentPrice? = null, + private val matrixWithAllocationPrice: MatrixWithAllocationPrice? = null, + private val tieredWithProrationPrice: TieredWithProrationPrice? = null, + private val unitWithProrationPrice: UnitWithProrationPrice? = null, + private val groupedAllocationPrice: GroupedAllocationPrice? = null, + private val groupedWithProratedMinimumPrice: GroupedWithProratedMinimumPrice? = null, + private val groupedWithMeteredMinimumPrice: GroupedWithMeteredMinimumPrice? = null, + private val matrixWithDisplayNamePrice: MatrixWithDisplayNamePrice? = null, + private val bulkWithProrationPrice: BulkWithProrationPrice? = null, + private val groupedTieredPackagePrice: GroupedTieredPackagePrice? = null, + private val maxGroupTieredPackagePrice: MaxGroupTieredPackagePrice? = null, + private val scalableMatrixWithUnitPricingPrice: ScalableMatrixWithUnitPricingPrice? = null, + private val scalableMatrixWithTieredPricingPrice: ScalableMatrixWithTieredPricingPrice? = null, + private val cumulativeGroupedBulkPrice: CumulativeGroupedBulkPrice? = null, + private val _json: JsonValue? = null, +) { + + fun unitPrice(): Optional = Optional.ofNullable(unitPrice) + + fun packagePrice(): Optional = Optional.ofNullable(packagePrice) + + fun matrixPrice(): Optional = Optional.ofNullable(matrixPrice) + + fun tieredPrice(): Optional = Optional.ofNullable(tieredPrice) + + fun tieredBpsPrice(): Optional = Optional.ofNullable(tieredBpsPrice) + + fun bpsPrice(): Optional = Optional.ofNullable(bpsPrice) + + fun bulkBpsPrice(): Optional = Optional.ofNullable(bulkBpsPrice) + + fun bulkPrice(): Optional = Optional.ofNullable(bulkPrice) + + fun thresholdTotalAmountPrice(): Optional = + Optional.ofNullable(thresholdTotalAmountPrice) + + fun tieredPackagePrice(): Optional = Optional.ofNullable(tieredPackagePrice) + + fun groupedTieredPrice(): Optional = Optional.ofNullable(groupedTieredPrice) + + fun tieredWithMinimumPrice(): Optional = + Optional.ofNullable(tieredWithMinimumPrice) + + fun tieredPackageWithMinimumPrice(): Optional = + Optional.ofNullable(tieredPackageWithMinimumPrice) + + fun packageWithAllocationPrice(): Optional = + Optional.ofNullable(packageWithAllocationPrice) + + fun unitWithPercentPrice(): Optional = + Optional.ofNullable(unitWithPercentPrice) + + fun matrixWithAllocationPrice(): Optional = + Optional.ofNullable(matrixWithAllocationPrice) + + fun tieredWithProrationPrice(): Optional = + Optional.ofNullable(tieredWithProrationPrice) + + fun unitWithProrationPrice(): Optional = + Optional.ofNullable(unitWithProrationPrice) + + fun groupedAllocationPrice(): Optional = + Optional.ofNullable(groupedAllocationPrice) + + fun groupedWithProratedMinimumPrice(): Optional = + Optional.ofNullable(groupedWithProratedMinimumPrice) + + fun groupedWithMeteredMinimumPrice(): Optional = + Optional.ofNullable(groupedWithMeteredMinimumPrice) + + fun matrixWithDisplayNamePrice(): Optional = + Optional.ofNullable(matrixWithDisplayNamePrice) + + fun bulkWithProrationPrice(): Optional = + Optional.ofNullable(bulkWithProrationPrice) + + fun groupedTieredPackagePrice(): Optional = + Optional.ofNullable(groupedTieredPackagePrice) + + fun maxGroupTieredPackagePrice(): Optional = + Optional.ofNullable(maxGroupTieredPackagePrice) + + fun scalableMatrixWithUnitPricingPrice(): Optional = + Optional.ofNullable(scalableMatrixWithUnitPricingPrice) + + fun scalableMatrixWithTieredPricingPrice(): Optional = + Optional.ofNullable(scalableMatrixWithTieredPricingPrice) + + fun cumulativeGroupedBulkPrice(): Optional = + Optional.ofNullable(cumulativeGroupedBulkPrice) + + fun isUnitPrice(): Boolean = unitPrice != null + + fun isPackagePrice(): Boolean = packagePrice != null + + fun isMatrixPrice(): Boolean = matrixPrice != null + + fun isTieredPrice(): Boolean = tieredPrice != null + + fun isTieredBpsPrice(): Boolean = tieredBpsPrice != null + + fun isBpsPrice(): Boolean = bpsPrice != null + + fun isBulkBpsPrice(): Boolean = bulkBpsPrice != null + + fun isBulkPrice(): Boolean = bulkPrice != null + + fun isThresholdTotalAmountPrice(): Boolean = thresholdTotalAmountPrice != null + + fun isTieredPackagePrice(): Boolean = tieredPackagePrice != null + + fun isGroupedTieredPrice(): Boolean = groupedTieredPrice != null + + fun isTieredWithMinimumPrice(): Boolean = tieredWithMinimumPrice != null + + fun isTieredPackageWithMinimumPrice(): Boolean = tieredPackageWithMinimumPrice != null + + fun isPackageWithAllocationPrice(): Boolean = packageWithAllocationPrice != null + + fun isUnitWithPercentPrice(): Boolean = unitWithPercentPrice != null + + fun isMatrixWithAllocationPrice(): Boolean = matrixWithAllocationPrice != null + + fun isTieredWithProrationPrice(): Boolean = tieredWithProrationPrice != null + + fun isUnitWithProrationPrice(): Boolean = unitWithProrationPrice != null + + fun isGroupedAllocationPrice(): Boolean = groupedAllocationPrice != null + + fun isGroupedWithProratedMinimumPrice(): Boolean = groupedWithProratedMinimumPrice != null + + fun isGroupedWithMeteredMinimumPrice(): Boolean = groupedWithMeteredMinimumPrice != null + + fun isMatrixWithDisplayNamePrice(): Boolean = matrixWithDisplayNamePrice != null + + fun isBulkWithProrationPrice(): Boolean = bulkWithProrationPrice != null + + fun isGroupedTieredPackagePrice(): Boolean = groupedTieredPackagePrice != null + + fun isMaxGroupTieredPackagePrice(): Boolean = maxGroupTieredPackagePrice != null + + fun isScalableMatrixWithUnitPricingPrice(): Boolean = scalableMatrixWithUnitPricingPrice != null + + fun isScalableMatrixWithTieredPricingPrice(): Boolean = + scalableMatrixWithTieredPricingPrice != null + + fun isCumulativeGroupedBulkPrice(): Boolean = cumulativeGroupedBulkPrice != null + + fun asUnitPrice(): UnitPrice = unitPrice.getOrThrow("unitPrice") + + fun asPackagePrice(): PackagePrice = packagePrice.getOrThrow("packagePrice") + + fun asMatrixPrice(): MatrixPrice = matrixPrice.getOrThrow("matrixPrice") + + fun asTieredPrice(): TieredPrice = tieredPrice.getOrThrow("tieredPrice") + + fun asTieredBpsPrice(): TieredBpsPrice = tieredBpsPrice.getOrThrow("tieredBpsPrice") + + fun asBpsPrice(): BpsPrice = bpsPrice.getOrThrow("bpsPrice") + + fun asBulkBpsPrice(): BulkBpsPrice = bulkBpsPrice.getOrThrow("bulkBpsPrice") + + fun asBulkPrice(): BulkPrice = bulkPrice.getOrThrow("bulkPrice") + + fun asThresholdTotalAmountPrice(): ThresholdTotalAmountPrice = + thresholdTotalAmountPrice.getOrThrow("thresholdTotalAmountPrice") + + fun asTieredPackagePrice(): TieredPackagePrice = + tieredPackagePrice.getOrThrow("tieredPackagePrice") + + fun asGroupedTieredPrice(): GroupedTieredPrice = + groupedTieredPrice.getOrThrow("groupedTieredPrice") + + fun asTieredWithMinimumPrice(): TieredWithMinimumPrice = + tieredWithMinimumPrice.getOrThrow("tieredWithMinimumPrice") + + fun asTieredPackageWithMinimumPrice(): TieredPackageWithMinimumPrice = + tieredPackageWithMinimumPrice.getOrThrow("tieredPackageWithMinimumPrice") + + fun asPackageWithAllocationPrice(): PackageWithAllocationPrice = + packageWithAllocationPrice.getOrThrow("packageWithAllocationPrice") + + fun asUnitWithPercentPrice(): UnitWithPercentPrice = + unitWithPercentPrice.getOrThrow("unitWithPercentPrice") + + fun asMatrixWithAllocationPrice(): MatrixWithAllocationPrice = + matrixWithAllocationPrice.getOrThrow("matrixWithAllocationPrice") + + fun asTieredWithProrationPrice(): TieredWithProrationPrice = + tieredWithProrationPrice.getOrThrow("tieredWithProrationPrice") + + fun asUnitWithProrationPrice(): UnitWithProrationPrice = + unitWithProrationPrice.getOrThrow("unitWithProrationPrice") + + fun asGroupedAllocationPrice(): GroupedAllocationPrice = + groupedAllocationPrice.getOrThrow("groupedAllocationPrice") + + fun asGroupedWithProratedMinimumPrice(): GroupedWithProratedMinimumPrice = + groupedWithProratedMinimumPrice.getOrThrow("groupedWithProratedMinimumPrice") + + fun asGroupedWithMeteredMinimumPrice(): GroupedWithMeteredMinimumPrice = + groupedWithMeteredMinimumPrice.getOrThrow("groupedWithMeteredMinimumPrice") + + fun asMatrixWithDisplayNamePrice(): MatrixWithDisplayNamePrice = + matrixWithDisplayNamePrice.getOrThrow("matrixWithDisplayNamePrice") + + fun asBulkWithProrationPrice(): BulkWithProrationPrice = + bulkWithProrationPrice.getOrThrow("bulkWithProrationPrice") + + fun asGroupedTieredPackagePrice(): GroupedTieredPackagePrice = + groupedTieredPackagePrice.getOrThrow("groupedTieredPackagePrice") + + fun asMaxGroupTieredPackagePrice(): MaxGroupTieredPackagePrice = + maxGroupTieredPackagePrice.getOrThrow("maxGroupTieredPackagePrice") + + fun asScalableMatrixWithUnitPricingPrice(): ScalableMatrixWithUnitPricingPrice = + scalableMatrixWithUnitPricingPrice.getOrThrow("scalableMatrixWithUnitPricingPrice") + + fun asScalableMatrixWithTieredPricingPrice(): ScalableMatrixWithTieredPricingPrice = + scalableMatrixWithTieredPricingPrice.getOrThrow("scalableMatrixWithTieredPricingPrice") + + fun asCumulativeGroupedBulkPrice(): CumulativeGroupedBulkPrice = + cumulativeGroupedBulkPrice.getOrThrow("cumulativeGroupedBulkPrice") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + unitPrice != null -> visitor.visitUnitPrice(unitPrice) + packagePrice != null -> visitor.visitPackagePrice(packagePrice) + matrixPrice != null -> visitor.visitMatrixPrice(matrixPrice) + tieredPrice != null -> visitor.visitTieredPrice(tieredPrice) + tieredBpsPrice != null -> visitor.visitTieredBpsPrice(tieredBpsPrice) + bpsPrice != null -> visitor.visitBpsPrice(bpsPrice) + bulkBpsPrice != null -> visitor.visitBulkBpsPrice(bulkBpsPrice) + bulkPrice != null -> visitor.visitBulkPrice(bulkPrice) + thresholdTotalAmountPrice != null -> + visitor.visitThresholdTotalAmountPrice(thresholdTotalAmountPrice) + tieredPackagePrice != null -> visitor.visitTieredPackagePrice(tieredPackagePrice) + groupedTieredPrice != null -> visitor.visitGroupedTieredPrice(groupedTieredPrice) + tieredWithMinimumPrice != null -> + visitor.visitTieredWithMinimumPrice(tieredWithMinimumPrice) + tieredPackageWithMinimumPrice != null -> + visitor.visitTieredPackageWithMinimumPrice(tieredPackageWithMinimumPrice) + packageWithAllocationPrice != null -> + visitor.visitPackageWithAllocationPrice(packageWithAllocationPrice) + unitWithPercentPrice != null -> visitor.visitUnitWithPercentPrice(unitWithPercentPrice) + matrixWithAllocationPrice != null -> + visitor.visitMatrixWithAllocationPrice(matrixWithAllocationPrice) + tieredWithProrationPrice != null -> + visitor.visitTieredWithProrationPrice(tieredWithProrationPrice) + unitWithProrationPrice != null -> + visitor.visitUnitWithProrationPrice(unitWithProrationPrice) + groupedAllocationPrice != null -> + visitor.visitGroupedAllocationPrice(groupedAllocationPrice) + groupedWithProratedMinimumPrice != null -> + visitor.visitGroupedWithProratedMinimumPrice(groupedWithProratedMinimumPrice) + groupedWithMeteredMinimumPrice != null -> + visitor.visitGroupedWithMeteredMinimumPrice(groupedWithMeteredMinimumPrice) + matrixWithDisplayNamePrice != null -> + visitor.visitMatrixWithDisplayNamePrice(matrixWithDisplayNamePrice) + bulkWithProrationPrice != null -> + visitor.visitBulkWithProrationPrice(bulkWithProrationPrice) + groupedTieredPackagePrice != null -> + visitor.visitGroupedTieredPackagePrice(groupedTieredPackagePrice) + maxGroupTieredPackagePrice != null -> + visitor.visitMaxGroupTieredPackagePrice(maxGroupTieredPackagePrice) + scalableMatrixWithUnitPricingPrice != null -> + visitor.visitScalableMatrixWithUnitPricingPrice(scalableMatrixWithUnitPricingPrice) + scalableMatrixWithTieredPricingPrice != null -> + visitor.visitScalableMatrixWithTieredPricingPrice( + scalableMatrixWithTieredPricingPrice + ) + cumulativeGroupedBulkPrice != null -> + visitor.visitCumulativeGroupedBulkPrice(cumulativeGroupedBulkPrice) + else -> visitor.unknown(_json) + } + } + + private var validated: Boolean = false + + fun validate(): PriceModel = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnitPrice(unitPrice: UnitPrice) { + unitPrice.validate() + } + + override fun visitPackagePrice(packagePrice: PackagePrice) { + packagePrice.validate() + } + + override fun visitMatrixPrice(matrixPrice: MatrixPrice) { + matrixPrice.validate() + } + + override fun visitTieredPrice(tieredPrice: TieredPrice) { + tieredPrice.validate() + } + + override fun visitTieredBpsPrice(tieredBpsPrice: TieredBpsPrice) { + tieredBpsPrice.validate() + } + + override fun visitBpsPrice(bpsPrice: BpsPrice) { + bpsPrice.validate() + } + + override fun visitBulkBpsPrice(bulkBpsPrice: BulkBpsPrice) { + bulkBpsPrice.validate() + } + + override fun visitBulkPrice(bulkPrice: BulkPrice) { + bulkPrice.validate() + } + + override fun visitThresholdTotalAmountPrice( + thresholdTotalAmountPrice: ThresholdTotalAmountPrice + ) { + thresholdTotalAmountPrice.validate() + } + + override fun visitTieredPackagePrice(tieredPackagePrice: TieredPackagePrice) { + tieredPackagePrice.validate() + } + + override fun visitGroupedTieredPrice(groupedTieredPrice: GroupedTieredPrice) { + groupedTieredPrice.validate() + } + + override fun visitTieredWithMinimumPrice( + tieredWithMinimumPrice: TieredWithMinimumPrice + ) { + tieredWithMinimumPrice.validate() + } + + override fun visitTieredPackageWithMinimumPrice( + tieredPackageWithMinimumPrice: TieredPackageWithMinimumPrice + ) { + tieredPackageWithMinimumPrice.validate() + } + + override fun visitPackageWithAllocationPrice( + packageWithAllocationPrice: PackageWithAllocationPrice + ) { + packageWithAllocationPrice.validate() + } + + override fun visitUnitWithPercentPrice(unitWithPercentPrice: UnitWithPercentPrice) { + unitWithPercentPrice.validate() + } + + override fun visitMatrixWithAllocationPrice( + matrixWithAllocationPrice: MatrixWithAllocationPrice + ) { + matrixWithAllocationPrice.validate() + } + + override fun visitTieredWithProrationPrice( + tieredWithProrationPrice: TieredWithProrationPrice + ) { + tieredWithProrationPrice.validate() + } + + override fun visitUnitWithProrationPrice( + unitWithProrationPrice: UnitWithProrationPrice + ) { + unitWithProrationPrice.validate() + } + + override fun visitGroupedAllocationPrice( + groupedAllocationPrice: GroupedAllocationPrice + ) { + groupedAllocationPrice.validate() + } + + override fun visitGroupedWithProratedMinimumPrice( + groupedWithProratedMinimumPrice: GroupedWithProratedMinimumPrice + ) { + groupedWithProratedMinimumPrice.validate() + } + + override fun visitGroupedWithMeteredMinimumPrice( + groupedWithMeteredMinimumPrice: GroupedWithMeteredMinimumPrice + ) { + groupedWithMeteredMinimumPrice.validate() + } + + override fun visitMatrixWithDisplayNamePrice( + matrixWithDisplayNamePrice: MatrixWithDisplayNamePrice + ) { + matrixWithDisplayNamePrice.validate() + } + + override fun visitBulkWithProrationPrice( + bulkWithProrationPrice: BulkWithProrationPrice + ) { + bulkWithProrationPrice.validate() + } + + override fun visitGroupedTieredPackagePrice( + groupedTieredPackagePrice: GroupedTieredPackagePrice + ) { + groupedTieredPackagePrice.validate() + } + + override fun visitMaxGroupTieredPackagePrice( + maxGroupTieredPackagePrice: MaxGroupTieredPackagePrice + ) { + maxGroupTieredPackagePrice.validate() + } + + override fun visitScalableMatrixWithUnitPricingPrice( + scalableMatrixWithUnitPricingPrice: ScalableMatrixWithUnitPricingPrice + ) { + scalableMatrixWithUnitPricingPrice.validate() + } + + override fun visitScalableMatrixWithTieredPricingPrice( + scalableMatrixWithTieredPricingPrice: ScalableMatrixWithTieredPricingPrice + ) { + scalableMatrixWithTieredPricingPrice.validate() + } + + override fun visitCumulativeGroupedBulkPrice( + cumulativeGroupedBulkPrice: CumulativeGroupedBulkPrice + ) { + cumulativeGroupedBulkPrice.validate() + } + } + ) + validated = true + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceModel && unitPrice == other.unitPrice && packagePrice == other.packagePrice && matrixPrice == other.matrixPrice && tieredPrice == other.tieredPrice && tieredBpsPrice == other.tieredBpsPrice && bpsPrice == other.bpsPrice && bulkBpsPrice == other.bulkBpsPrice && bulkPrice == other.bulkPrice && thresholdTotalAmountPrice == other.thresholdTotalAmountPrice && tieredPackagePrice == other.tieredPackagePrice && groupedTieredPrice == other.groupedTieredPrice && tieredWithMinimumPrice == other.tieredWithMinimumPrice && tieredPackageWithMinimumPrice == other.tieredPackageWithMinimumPrice && packageWithAllocationPrice == other.packageWithAllocationPrice && unitWithPercentPrice == other.unitWithPercentPrice && matrixWithAllocationPrice == other.matrixWithAllocationPrice && tieredWithProrationPrice == other.tieredWithProrationPrice && unitWithProrationPrice == other.unitWithProrationPrice && groupedAllocationPrice == other.groupedAllocationPrice && groupedWithProratedMinimumPrice == other.groupedWithProratedMinimumPrice && groupedWithMeteredMinimumPrice == other.groupedWithMeteredMinimumPrice && matrixWithDisplayNamePrice == other.matrixWithDisplayNamePrice && bulkWithProrationPrice == other.bulkWithProrationPrice && groupedTieredPackagePrice == other.groupedTieredPackagePrice && maxGroupTieredPackagePrice == other.maxGroupTieredPackagePrice && scalableMatrixWithUnitPricingPrice == other.scalableMatrixWithUnitPricingPrice && scalableMatrixWithTieredPricingPrice == other.scalableMatrixWithTieredPricingPrice && cumulativeGroupedBulkPrice == other.cumulativeGroupedBulkPrice /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(unitPrice, packagePrice, matrixPrice, tieredPrice, tieredBpsPrice, bpsPrice, bulkBpsPrice, bulkPrice, thresholdTotalAmountPrice, tieredPackagePrice, groupedTieredPrice, tieredWithMinimumPrice, tieredPackageWithMinimumPrice, packageWithAllocationPrice, unitWithPercentPrice, matrixWithAllocationPrice, tieredWithProrationPrice, unitWithProrationPrice, groupedAllocationPrice, groupedWithProratedMinimumPrice, groupedWithMeteredMinimumPrice, matrixWithDisplayNamePrice, bulkWithProrationPrice, groupedTieredPackagePrice, maxGroupTieredPackagePrice, scalableMatrixWithUnitPricingPrice, scalableMatrixWithTieredPricingPrice, cumulativeGroupedBulkPrice) /* spotless:on */ + + override fun toString(): String = + when { + unitPrice != null -> "PriceModel{unitPrice=$unitPrice}" + packagePrice != null -> "PriceModel{packagePrice=$packagePrice}" + matrixPrice != null -> "PriceModel{matrixPrice=$matrixPrice}" + tieredPrice != null -> "PriceModel{tieredPrice=$tieredPrice}" + tieredBpsPrice != null -> "PriceModel{tieredBpsPrice=$tieredBpsPrice}" + bpsPrice != null -> "PriceModel{bpsPrice=$bpsPrice}" + bulkBpsPrice != null -> "PriceModel{bulkBpsPrice=$bulkBpsPrice}" + bulkPrice != null -> "PriceModel{bulkPrice=$bulkPrice}" + thresholdTotalAmountPrice != null -> + "PriceModel{thresholdTotalAmountPrice=$thresholdTotalAmountPrice}" + tieredPackagePrice != null -> "PriceModel{tieredPackagePrice=$tieredPackagePrice}" + groupedTieredPrice != null -> "PriceModel{groupedTieredPrice=$groupedTieredPrice}" + tieredWithMinimumPrice != null -> + "PriceModel{tieredWithMinimumPrice=$tieredWithMinimumPrice}" + tieredPackageWithMinimumPrice != null -> + "PriceModel{tieredPackageWithMinimumPrice=$tieredPackageWithMinimumPrice}" + packageWithAllocationPrice != null -> + "PriceModel{packageWithAllocationPrice=$packageWithAllocationPrice}" + unitWithPercentPrice != null -> "PriceModel{unitWithPercentPrice=$unitWithPercentPrice}" + matrixWithAllocationPrice != null -> + "PriceModel{matrixWithAllocationPrice=$matrixWithAllocationPrice}" + tieredWithProrationPrice != null -> + "PriceModel{tieredWithProrationPrice=$tieredWithProrationPrice}" + unitWithProrationPrice != null -> + "PriceModel{unitWithProrationPrice=$unitWithProrationPrice}" + groupedAllocationPrice != null -> + "PriceModel{groupedAllocationPrice=$groupedAllocationPrice}" + groupedWithProratedMinimumPrice != null -> + "PriceModel{groupedWithProratedMinimumPrice=$groupedWithProratedMinimumPrice}" + groupedWithMeteredMinimumPrice != null -> + "PriceModel{groupedWithMeteredMinimumPrice=$groupedWithMeteredMinimumPrice}" + matrixWithDisplayNamePrice != null -> + "PriceModel{matrixWithDisplayNamePrice=$matrixWithDisplayNamePrice}" + bulkWithProrationPrice != null -> + "PriceModel{bulkWithProrationPrice=$bulkWithProrationPrice}" + groupedTieredPackagePrice != null -> + "PriceModel{groupedTieredPackagePrice=$groupedTieredPackagePrice}" + maxGroupTieredPackagePrice != null -> + "PriceModel{maxGroupTieredPackagePrice=$maxGroupTieredPackagePrice}" + scalableMatrixWithUnitPricingPrice != null -> + "PriceModel{scalableMatrixWithUnitPricingPrice=$scalableMatrixWithUnitPricingPrice}" + scalableMatrixWithTieredPricingPrice != null -> + "PriceModel{scalableMatrixWithTieredPricingPrice=$scalableMatrixWithTieredPricingPrice}" + cumulativeGroupedBulkPrice != null -> + "PriceModel{cumulativeGroupedBulkPrice=$cumulativeGroupedBulkPrice}" + _json != null -> "PriceModel{_unknown=$_json}" + else -> throw IllegalStateException("Invalid PriceModel") + } + + companion object { + + @JvmStatic fun ofUnitPrice(unitPrice: UnitPrice) = PriceModel(unitPrice = unitPrice) + + @JvmStatic + fun ofPackagePrice(packagePrice: PackagePrice) = PriceModel(packagePrice = packagePrice) + + @JvmStatic + fun ofMatrixPrice(matrixPrice: MatrixPrice) = PriceModel(matrixPrice = matrixPrice) + + @JvmStatic + fun ofTieredPrice(tieredPrice: TieredPrice) = PriceModel(tieredPrice = tieredPrice) + + @JvmStatic + fun ofTieredBpsPrice(tieredBpsPrice: TieredBpsPrice) = + PriceModel(tieredBpsPrice = tieredBpsPrice) + + @JvmStatic fun ofBpsPrice(bpsPrice: BpsPrice) = PriceModel(bpsPrice = bpsPrice) + + @JvmStatic + fun ofBulkBpsPrice(bulkBpsPrice: BulkBpsPrice) = PriceModel(bulkBpsPrice = bulkBpsPrice) + + @JvmStatic fun ofBulkPrice(bulkPrice: BulkPrice) = PriceModel(bulkPrice = bulkPrice) + + @JvmStatic + fun ofThresholdTotalAmountPrice(thresholdTotalAmountPrice: ThresholdTotalAmountPrice) = + PriceModel(thresholdTotalAmountPrice = thresholdTotalAmountPrice) + + @JvmStatic + fun ofTieredPackagePrice(tieredPackagePrice: TieredPackagePrice) = + PriceModel(tieredPackagePrice = tieredPackagePrice) + + @JvmStatic + fun ofGroupedTieredPrice(groupedTieredPrice: GroupedTieredPrice) = + PriceModel(groupedTieredPrice = groupedTieredPrice) + + @JvmStatic + fun ofTieredWithMinimumPrice(tieredWithMinimumPrice: TieredWithMinimumPrice) = + PriceModel(tieredWithMinimumPrice = tieredWithMinimumPrice) + + @JvmStatic + fun ofTieredPackageWithMinimumPrice( + tieredPackageWithMinimumPrice: TieredPackageWithMinimumPrice + ) = PriceModel(tieredPackageWithMinimumPrice = tieredPackageWithMinimumPrice) + + @JvmStatic + fun ofPackageWithAllocationPrice(packageWithAllocationPrice: PackageWithAllocationPrice) = + PriceModel(packageWithAllocationPrice = packageWithAllocationPrice) + + @JvmStatic + fun ofUnitWithPercentPrice(unitWithPercentPrice: UnitWithPercentPrice) = + PriceModel(unitWithPercentPrice = unitWithPercentPrice) + + @JvmStatic + fun ofMatrixWithAllocationPrice(matrixWithAllocationPrice: MatrixWithAllocationPrice) = + PriceModel(matrixWithAllocationPrice = matrixWithAllocationPrice) + + @JvmStatic + fun ofTieredWithProrationPrice(tieredWithProrationPrice: TieredWithProrationPrice) = + PriceModel(tieredWithProrationPrice = tieredWithProrationPrice) + + @JvmStatic + fun ofUnitWithProrationPrice(unitWithProrationPrice: UnitWithProrationPrice) = + PriceModel(unitWithProrationPrice = unitWithProrationPrice) + + @JvmStatic + fun ofGroupedAllocationPrice(groupedAllocationPrice: GroupedAllocationPrice) = + PriceModel(groupedAllocationPrice = groupedAllocationPrice) + + @JvmStatic + fun ofGroupedWithProratedMinimumPrice( + groupedWithProratedMinimumPrice: GroupedWithProratedMinimumPrice + ) = PriceModel(groupedWithProratedMinimumPrice = groupedWithProratedMinimumPrice) + + @JvmStatic + fun ofGroupedWithMeteredMinimumPrice( + groupedWithMeteredMinimumPrice: GroupedWithMeteredMinimumPrice + ) = PriceModel(groupedWithMeteredMinimumPrice = groupedWithMeteredMinimumPrice) + + @JvmStatic + fun ofMatrixWithDisplayNamePrice(matrixWithDisplayNamePrice: MatrixWithDisplayNamePrice) = + PriceModel(matrixWithDisplayNamePrice = matrixWithDisplayNamePrice) + + @JvmStatic + fun ofBulkWithProrationPrice(bulkWithProrationPrice: BulkWithProrationPrice) = + PriceModel(bulkWithProrationPrice = bulkWithProrationPrice) + + @JvmStatic + fun ofGroupedTieredPackagePrice(groupedTieredPackagePrice: GroupedTieredPackagePrice) = + PriceModel(groupedTieredPackagePrice = groupedTieredPackagePrice) + + @JvmStatic + fun ofMaxGroupTieredPackagePrice(maxGroupTieredPackagePrice: MaxGroupTieredPackagePrice) = + PriceModel(maxGroupTieredPackagePrice = maxGroupTieredPackagePrice) + + @JvmStatic + fun ofScalableMatrixWithUnitPricingPrice( + scalableMatrixWithUnitPricingPrice: ScalableMatrixWithUnitPricingPrice + ) = PriceModel(scalableMatrixWithUnitPricingPrice = scalableMatrixWithUnitPricingPrice) + + @JvmStatic + fun ofScalableMatrixWithTieredPricingPrice( + scalableMatrixWithTieredPricingPrice: ScalableMatrixWithTieredPricingPrice + ) = PriceModel(scalableMatrixWithTieredPricingPrice = scalableMatrixWithTieredPricingPrice) + + @JvmStatic + fun ofCumulativeGroupedBulkPrice(cumulativeGroupedBulkPrice: CumulativeGroupedBulkPrice) = + PriceModel(cumulativeGroupedBulkPrice = cumulativeGroupedBulkPrice) + } + + /** An interface that defines how to map each variant of [PriceModel] to a value of type [T]. */ + interface Visitor { + + fun visitUnitPrice(unitPrice: UnitPrice): T + + fun visitPackagePrice(packagePrice: PackagePrice): T + + fun visitMatrixPrice(matrixPrice: MatrixPrice): T + + fun visitTieredPrice(tieredPrice: TieredPrice): T + + fun visitTieredBpsPrice(tieredBpsPrice: TieredBpsPrice): T + + fun visitBpsPrice(bpsPrice: BpsPrice): T + + fun visitBulkBpsPrice(bulkBpsPrice: BulkBpsPrice): T + + fun visitBulkPrice(bulkPrice: BulkPrice): T + + fun visitThresholdTotalAmountPrice(thresholdTotalAmountPrice: ThresholdTotalAmountPrice): T + + fun visitTieredPackagePrice(tieredPackagePrice: TieredPackagePrice): T + + fun visitGroupedTieredPrice(groupedTieredPrice: GroupedTieredPrice): T + + fun visitTieredWithMinimumPrice(tieredWithMinimumPrice: TieredWithMinimumPrice): T + + fun visitTieredPackageWithMinimumPrice( + tieredPackageWithMinimumPrice: TieredPackageWithMinimumPrice + ): T + + fun visitPackageWithAllocationPrice( + packageWithAllocationPrice: PackageWithAllocationPrice + ): T + + fun visitUnitWithPercentPrice(unitWithPercentPrice: UnitWithPercentPrice): T + + fun visitMatrixWithAllocationPrice(matrixWithAllocationPrice: MatrixWithAllocationPrice): T + + fun visitTieredWithProrationPrice(tieredWithProrationPrice: TieredWithProrationPrice): T + + fun visitUnitWithProrationPrice(unitWithProrationPrice: UnitWithProrationPrice): T + + fun visitGroupedAllocationPrice(groupedAllocationPrice: GroupedAllocationPrice): T + + fun visitGroupedWithProratedMinimumPrice( + groupedWithProratedMinimumPrice: GroupedWithProratedMinimumPrice + ): T + + fun visitGroupedWithMeteredMinimumPrice( + groupedWithMeteredMinimumPrice: GroupedWithMeteredMinimumPrice + ): T + + fun visitMatrixWithDisplayNamePrice( + matrixWithDisplayNamePrice: MatrixWithDisplayNamePrice + ): T + + fun visitBulkWithProrationPrice(bulkWithProrationPrice: BulkWithProrationPrice): T + + fun visitGroupedTieredPackagePrice(groupedTieredPackagePrice: GroupedTieredPackagePrice): T + + fun visitMaxGroupTieredPackagePrice( + maxGroupTieredPackagePrice: MaxGroupTieredPackagePrice + ): T + + fun visitScalableMatrixWithUnitPricingPrice( + scalableMatrixWithUnitPricingPrice: ScalableMatrixWithUnitPricingPrice + ): T + + fun visitScalableMatrixWithTieredPricingPrice( + scalableMatrixWithTieredPricingPrice: ScalableMatrixWithTieredPricingPrice + ): T + + fun visitCumulativeGroupedBulkPrice( + cumulativeGroupedBulkPrice: CumulativeGroupedBulkPrice + ): T + + /** + * Maps an unknown variant of [PriceModel] to a value of type [T]. + * + * An instance of [PriceModel] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown PriceModel: $json") + } + } + + internal class Deserializer : BaseDeserializer(PriceModel::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): PriceModel { + val json = JsonValue.fromJsonNode(node) + val modelType = json.asObject().getOrNull()?.get("model_type")?.asString()?.getOrNull() + + when (modelType) { + "unit" -> { + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return PriceModel(unitPrice = it, _json = json) + } + } + "package" -> { + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return PriceModel(packagePrice = it, _json = json) + } + } + "matrix" -> { + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return PriceModel(matrixPrice = it, _json = json) + } + } + "tiered" -> { + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return PriceModel(tieredPrice = it, _json = json) + } + } + "tiered_bps" -> { + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return PriceModel(tieredBpsPrice = it, _json = json) + } + } + "bps" -> { + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return PriceModel(bpsPrice = it, _json = json) + } + } + "bulk_bps" -> { + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return PriceModel(bulkBpsPrice = it, _json = json) + } + } + "bulk" -> { + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return PriceModel(bulkPrice = it, _json = json) + } + } + "threshold_total_amount" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return PriceModel(thresholdTotalAmountPrice = it, _json = json) + } + } + "tiered_package" -> { + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return PriceModel(tieredPackagePrice = it, _json = json) + } + } + "grouped_tiered" -> { + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return PriceModel(groupedTieredPrice = it, _json = json) + } + } + "tiered_with_minimum" -> { + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return PriceModel(tieredWithMinimumPrice = it, _json = json) + } + } + "tiered_package_with_minimum" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return PriceModel(tieredPackageWithMinimumPrice = it, _json = json) + } + } + "package_with_allocation" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return PriceModel(packageWithAllocationPrice = it, _json = json) + } + } + "unit_with_percent" -> { + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return PriceModel(unitWithPercentPrice = it, _json = json) + } + } + "matrix_with_allocation" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return PriceModel(matrixWithAllocationPrice = it, _json = json) + } + } + "tiered_with_proration" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return PriceModel(tieredWithProrationPrice = it, _json = json) + } + } + "unit_with_proration" -> { + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return PriceModel(unitWithProrationPrice = it, _json = json) + } + } + "grouped_allocation" -> { + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return PriceModel(groupedAllocationPrice = it, _json = json) + } + } + "grouped_with_prorated_minimum" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return PriceModel(groupedWithProratedMinimumPrice = it, _json = json) + } + } + "grouped_with_metered_minimum" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return PriceModel(groupedWithMeteredMinimumPrice = it, _json = json) + } + } + "matrix_with_display_name" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return PriceModel(matrixWithDisplayNamePrice = it, _json = json) + } + } + "bulk_with_proration" -> { + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return PriceModel(bulkWithProrationPrice = it, _json = json) + } + } + "grouped_tiered_package" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return PriceModel(groupedTieredPackagePrice = it, _json = json) + } + } + "max_group_tiered_package" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return PriceModel(maxGroupTieredPackagePrice = it, _json = json) + } + } + "scalable_matrix_with_unit_pricing" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return PriceModel(scalableMatrixWithUnitPricingPrice = it, _json = json) + } + } + "scalable_matrix_with_tiered_pricing" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return PriceModel( + scalableMatrixWithTieredPricingPrice = it, + _json = json, + ) + } + } + "cumulative_grouped_bulk" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return PriceModel(cumulativeGroupedBulkPrice = it, _json = json) + } + } + } + + return PriceModel(_json = json) + } + } + + internal class Serializer : BaseSerializer(PriceModel::class) { + + override fun serialize( + value: PriceModel, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unitPrice != null -> generator.writeObject(value.unitPrice) + value.packagePrice != null -> generator.writeObject(value.packagePrice) + value.matrixPrice != null -> generator.writeObject(value.matrixPrice) + value.tieredPrice != null -> generator.writeObject(value.tieredPrice) + value.tieredBpsPrice != null -> generator.writeObject(value.tieredBpsPrice) + value.bpsPrice != null -> generator.writeObject(value.bpsPrice) + value.bulkBpsPrice != null -> generator.writeObject(value.bulkBpsPrice) + value.bulkPrice != null -> generator.writeObject(value.bulkPrice) + value.thresholdTotalAmountPrice != null -> + generator.writeObject(value.thresholdTotalAmountPrice) + value.tieredPackagePrice != null -> generator.writeObject(value.tieredPackagePrice) + value.groupedTieredPrice != null -> generator.writeObject(value.groupedTieredPrice) + value.tieredWithMinimumPrice != null -> + generator.writeObject(value.tieredWithMinimumPrice) + value.tieredPackageWithMinimumPrice != null -> + generator.writeObject(value.tieredPackageWithMinimumPrice) + value.packageWithAllocationPrice != null -> + generator.writeObject(value.packageWithAllocationPrice) + value.unitWithPercentPrice != null -> + generator.writeObject(value.unitWithPercentPrice) + value.matrixWithAllocationPrice != null -> + generator.writeObject(value.matrixWithAllocationPrice) + value.tieredWithProrationPrice != null -> + generator.writeObject(value.tieredWithProrationPrice) + value.unitWithProrationPrice != null -> + generator.writeObject(value.unitWithProrationPrice) + value.groupedAllocationPrice != null -> + generator.writeObject(value.groupedAllocationPrice) + value.groupedWithProratedMinimumPrice != null -> + generator.writeObject(value.groupedWithProratedMinimumPrice) + value.groupedWithMeteredMinimumPrice != null -> + generator.writeObject(value.groupedWithMeteredMinimumPrice) + value.matrixWithDisplayNamePrice != null -> + generator.writeObject(value.matrixWithDisplayNamePrice) + value.bulkWithProrationPrice != null -> + generator.writeObject(value.bulkWithProrationPrice) + value.groupedTieredPackagePrice != null -> + generator.writeObject(value.groupedTieredPackagePrice) + value.maxGroupTieredPackagePrice != null -> + generator.writeObject(value.maxGroupTieredPackagePrice) + value.scalableMatrixWithUnitPricingPrice != null -> + generator.writeObject(value.scalableMatrixWithUnitPricingPrice) + value.scalableMatrixWithTieredPricingPrice != null -> + generator.writeObject(value.scalableMatrixWithTieredPricingPrice) + value.cumulativeGroupedBulkPrice != null -> + generator.writeObject(value.cumulativeGroupedBulkPrice) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid PriceModel") + } + } + } + + @NoAutoDetect + class UnitPrice + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + private val billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + private val creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("unit_config") + @ExcludeMissing + private val unitConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + private val dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + fun billableMetric(): Optional = + Optional.ofNullable(billableMetric.getNullable("billable_metric")) + + fun billingCycleConfiguration(): BillingCycleConfigurationModel = + billingCycleConfiguration.getRequired("billing_cycle_configuration") + + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + fun creditAllocation(): Optional = + Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) + + fun currency(): String = currency.getRequired("currency") + + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) + + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + fun item(): ItemSlimModel = item.getRequired("item") + + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + fun modelType(): ModelType = modelType.getRequired("model_type") + + fun name(): String = name.getRequired("name") + + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + fun priceType(): PriceType = priceType.getRequired("price_type") + + fun unitConfig(): UnitConfigModel = unitConfig.getRequired("unit_config") + + fun dimensionalPriceConfiguration(): Optional = + Optional.ofNullable( + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + ) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric + + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation + + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount + + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType + + @JsonProperty("unit_config") + @ExcludeMissing + fun _unitConfig(): JsonField = unitConfig + + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): UnitPrice = apply { + if (validated) { + return@apply + } + + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + cadence() + conversionRate() + 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() + name() + planPhaseOrder() + priceType() + unitConfig().validate() + dimensionalPriceConfiguration().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnitPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * .unitConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnitPrice]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var 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: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var unitConfig: JsonField? = null + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unitPrice: UnitPrice) = apply { + id = unitPrice.id + billableMetric = unitPrice.billableMetric + billingCycleConfiguration = unitPrice.billingCycleConfiguration + cadence = unitPrice.cadence + conversionRate = unitPrice.conversionRate + createdAt = unitPrice.createdAt + creditAllocation = unitPrice.creditAllocation + currency = unitPrice.currency + discount = unitPrice.discount + externalPriceId = unitPrice.externalPriceId + fixedPriceQuantity = unitPrice.fixedPriceQuantity + invoicingCycleConfiguration = unitPrice.invoicingCycleConfiguration + item = unitPrice.item + maximum = unitPrice.maximum + maximumAmount = unitPrice.maximumAmount + metadata = unitPrice.metadata + minimum = unitPrice.minimum + minimumAmount = unitPrice.minimumAmount + modelType = unitPrice.modelType + name = unitPrice.name + planPhaseOrder = unitPrice.planPhaseOrder + priceType = unitPrice.priceType + unitConfig = unitPrice.unitConfig + dimensionalPriceConfiguration = unitPrice.dimensionalPriceConfiguration + additionalProperties = unitPrice.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun billableMetric(billableMetric: BillableMetricTinyModel?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) + + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } + + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditAllocation(creditAllocation: AllocationModel?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) + + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) + + fun discount(discount: JsonField) = apply { this.discount = discount } + + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) + + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) + + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) + + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + fun item(item: ItemSlimModel) = item(JsonField.of(item)) + + fun item(item: JsonField) = apply { this.item = item } + + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) + + 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)) + + /** + * 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: JsonField) = apply { this.metadata = metadata } + + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + fun name(name: String) = name(JsonField.of(name)) + + fun name(name: JsonField) = apply { this.name = name } + + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) + + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + + fun unitConfig(unitConfig: UnitConfigModel) = unitConfig(JsonField.of(unitConfig)) + + fun unitConfig(unitConfig: JsonField) = apply { + this.unitConfig = unitConfig + } + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): UnitPrice = + UnitPrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + checkRequired("unitConfig", unitConfig), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) + } + + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * 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`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is UnitPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && unitConfig == other.unitConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, unitConfig, dimensionalPriceConfiguration, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, unitConfig=$unitConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class PackagePrice + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + private val billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + private val creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("package_config") + @ExcludeMissing + private val packageConfig: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + private val dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + fun billableMetric(): Optional = + Optional.ofNullable(billableMetric.getNullable("billable_metric")) + + fun billingCycleConfiguration(): BillingCycleConfigurationModel = + billingCycleConfiguration.getRequired("billing_cycle_configuration") + + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + fun creditAllocation(): Optional = + Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) + + fun currency(): String = currency.getRequired("currency") + + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) + + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + fun item(): ItemSlimModel = item.getRequired("item") + + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + fun modelType(): ModelType = modelType.getRequired("model_type") + + fun name(): String = name.getRequired("name") + + fun packageConfig(): PackageConfigModel = packageConfig.getRequired("package_config") + + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + fun priceType(): PriceType = priceType.getRequired("price_type") + + fun dimensionalPriceConfiguration(): Optional = + Optional.ofNullable( + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + ) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric + + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation + + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount + + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("package_config") + @ExcludeMissing + fun _packageConfig(): JsonField = packageConfig + + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType + + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): PackagePrice = apply { + if (validated) { + return@apply + } + + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + cadence() + conversionRate() + 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() + name() + packageConfig().validate() + planPhaseOrder() + priceType() + dimensionalPriceConfiguration().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PackagePrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .packageConfig() + * .planPhaseOrder() + * .priceType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PackagePrice]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var 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: JsonField? = null + private var name: JsonField? = null + private var packageConfig: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(packagePrice: PackagePrice) = apply { + id = packagePrice.id + billableMetric = packagePrice.billableMetric + billingCycleConfiguration = packagePrice.billingCycleConfiguration + cadence = packagePrice.cadence + conversionRate = packagePrice.conversionRate + createdAt = packagePrice.createdAt + creditAllocation = packagePrice.creditAllocation + currency = packagePrice.currency + discount = packagePrice.discount + externalPriceId = packagePrice.externalPriceId + fixedPriceQuantity = packagePrice.fixedPriceQuantity + invoicingCycleConfiguration = packagePrice.invoicingCycleConfiguration + item = packagePrice.item + maximum = packagePrice.maximum + maximumAmount = packagePrice.maximumAmount + metadata = packagePrice.metadata + minimum = packagePrice.minimum + minimumAmount = packagePrice.minimumAmount + modelType = packagePrice.modelType + name = packagePrice.name + packageConfig = packagePrice.packageConfig + planPhaseOrder = packagePrice.planPhaseOrder + priceType = packagePrice.priceType + dimensionalPriceConfiguration = packagePrice.dimensionalPriceConfiguration + additionalProperties = packagePrice.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun billableMetric(billableMetric: BillableMetricTinyModel?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) + + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } + + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditAllocation(creditAllocation: AllocationModel?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) + + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) + + fun discount(discount: JsonField) = apply { this.discount = discount } + + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) + + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) + + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) + + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + fun item(item: ItemSlimModel) = item(JsonField.of(item)) + + fun item(item: JsonField) = apply { this.item = item } + + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) + + 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)) + + /** + * 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: JsonField) = apply { this.metadata = metadata } + + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + fun name(name: String) = name(JsonField.of(name)) + + fun name(name: JsonField) = apply { this.name = name } + + fun packageConfig(packageConfig: PackageConfigModel) = + packageConfig(JsonField.of(packageConfig)) + + fun packageConfig(packageConfig: JsonField) = apply { + this.packageConfig = packageConfig + } + + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) + + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): PackagePrice = + PackagePrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("packageConfig", packageConfig), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) + } + + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * 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`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PACKAGE = of("package") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + PACKAGE + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PACKAGE, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PACKAGE -> Value.PACKAGE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PACKAGE -> Known.PACKAGE + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PackagePrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && packageConfig == other.packageConfig && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, packageConfig, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PackagePrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, packageConfig=$packageConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class MatrixPrice + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + private val billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + private val creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("matrix_config") + @ExcludeMissing + private val matrixConfig: JsonField = JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + private val dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + fun billableMetric(): Optional = + Optional.ofNullable(billableMetric.getNullable("billable_metric")) + + fun billingCycleConfiguration(): BillingCycleConfigurationModel = + billingCycleConfiguration.getRequired("billing_cycle_configuration") + + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + fun creditAllocation(): Optional = + Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) + + fun currency(): String = currency.getRequired("currency") + + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) + + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + fun item(): ItemSlimModel = item.getRequired("item") + + fun matrixConfig(): MatrixConfigModel = matrixConfig.getRequired("matrix_config") + + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + fun modelType(): ModelType = modelType.getRequired("model_type") + + fun name(): String = name.getRequired("name") + + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + fun priceType(): PriceType = priceType.getRequired("price_type") + + fun dimensionalPriceConfiguration(): Optional = + Optional.ofNullable( + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + ) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric + + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation + + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount + + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + @JsonProperty("matrix_config") + @ExcludeMissing + fun _matrixConfig(): JsonField = matrixConfig + + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType + + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): MatrixPrice = apply { + if (validated) { + return@apply + } + + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + cadence() + conversionRate() + createdAt() + creditAllocation().ifPresent { it.validate() } + currency() + discount().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoicingCycleConfiguration().ifPresent { it.validate() } + item().validate() + matrixConfig().validate() + maximum().ifPresent { it.validate() } + maximumAmount() + metadata().validate() + minimum().ifPresent { it.validate() } + minimumAmount() + modelType() + name() + planPhaseOrder() + priceType() + dimensionalPriceConfiguration().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MatrixPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .matrixConfig() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixPrice]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var 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 matrixConfig: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(matrixPrice: MatrixPrice) = apply { + id = matrixPrice.id + billableMetric = matrixPrice.billableMetric + billingCycleConfiguration = matrixPrice.billingCycleConfiguration + cadence = matrixPrice.cadence + conversionRate = matrixPrice.conversionRate + createdAt = matrixPrice.createdAt + creditAllocation = matrixPrice.creditAllocation + currency = matrixPrice.currency + discount = matrixPrice.discount + externalPriceId = matrixPrice.externalPriceId + fixedPriceQuantity = matrixPrice.fixedPriceQuantity + invoicingCycleConfiguration = matrixPrice.invoicingCycleConfiguration + item = matrixPrice.item + matrixConfig = matrixPrice.matrixConfig + maximum = matrixPrice.maximum + maximumAmount = matrixPrice.maximumAmount + metadata = matrixPrice.metadata + minimum = matrixPrice.minimum + minimumAmount = matrixPrice.minimumAmount + modelType = matrixPrice.modelType + name = matrixPrice.name + planPhaseOrder = matrixPrice.planPhaseOrder + priceType = matrixPrice.priceType + dimensionalPriceConfiguration = matrixPrice.dimensionalPriceConfiguration + additionalProperties = matrixPrice.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun billableMetric(billableMetric: BillableMetricTinyModel?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) + + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } + + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditAllocation(creditAllocation: AllocationModel?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) + + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) + + fun discount(discount: JsonField) = apply { this.discount = discount } + + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) + + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) + + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) + + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + fun item(item: ItemSlimModel) = item(JsonField.of(item)) + + fun item(item: JsonField) = apply { this.item = item } + + fun matrixConfig(matrixConfig: MatrixConfigModel) = + matrixConfig(JsonField.of(matrixConfig)) + + fun matrixConfig(matrixConfig: JsonField) = apply { + this.matrixConfig = matrixConfig + } + + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) + + 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)) + + /** + * 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: JsonField) = apply { this.metadata = metadata } + + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + fun name(name: String) = name(JsonField.of(name)) + + fun name(name: JsonField) = apply { this.name = name } + + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) + + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): MatrixPrice = + MatrixPrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + 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("matrixConfig", matrixConfig), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) + } + + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * 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`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val MATRIX = of("matrix") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + MATRIX + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MATRIX, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MATRIX -> Value.MATRIX + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MATRIX -> Known.MATRIX + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MatrixPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && matrixConfig == other.matrixConfig && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, matrixConfig, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixConfig=$matrixConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class TieredPrice + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + private val billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + private val creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("tiered_config") + @ExcludeMissing + private val tieredConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + private val dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + fun billableMetric(): Optional = + Optional.ofNullable(billableMetric.getNullable("billable_metric")) + + fun billingCycleConfiguration(): BillingCycleConfigurationModel = + billingCycleConfiguration.getRequired("billing_cycle_configuration") + + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + fun creditAllocation(): Optional = + Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) + + fun currency(): String = currency.getRequired("currency") + + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) + + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + fun item(): ItemSlimModel = item.getRequired("item") + + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + fun modelType(): ModelType = modelType.getRequired("model_type") + + fun name(): String = name.getRequired("name") + + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + fun priceType(): PriceType = priceType.getRequired("price_type") + + fun tieredConfig(): TieredConfigModel = tieredConfig.getRequired("tiered_config") + + fun dimensionalPriceConfiguration(): Optional = + Optional.ofNullable( + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + ) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric + + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation + + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount + + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType + + @JsonProperty("tiered_config") + @ExcludeMissing + fun _tieredConfig(): JsonField = tieredConfig + + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): TieredPrice = apply { + if (validated) { + return@apply + } + + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + cadence() + conversionRate() + 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() + name() + planPhaseOrder() + priceType() + tieredConfig().validate() + dimensionalPriceConfiguration().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TieredPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * .tieredConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredPrice]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var 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: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var tieredConfig: JsonField? = null + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredPrice: TieredPrice) = apply { + id = tieredPrice.id + billableMetric = tieredPrice.billableMetric + billingCycleConfiguration = tieredPrice.billingCycleConfiguration + cadence = tieredPrice.cadence + conversionRate = tieredPrice.conversionRate + createdAt = tieredPrice.createdAt + creditAllocation = tieredPrice.creditAllocation + currency = tieredPrice.currency + discount = tieredPrice.discount + externalPriceId = tieredPrice.externalPriceId + fixedPriceQuantity = tieredPrice.fixedPriceQuantity + invoicingCycleConfiguration = tieredPrice.invoicingCycleConfiguration + item = tieredPrice.item + maximum = tieredPrice.maximum + maximumAmount = tieredPrice.maximumAmount + metadata = tieredPrice.metadata + minimum = tieredPrice.minimum + minimumAmount = tieredPrice.minimumAmount + modelType = tieredPrice.modelType + name = tieredPrice.name + planPhaseOrder = tieredPrice.planPhaseOrder + priceType = tieredPrice.priceType + tieredConfig = tieredPrice.tieredConfig + dimensionalPriceConfiguration = tieredPrice.dimensionalPriceConfiguration + additionalProperties = tieredPrice.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun billableMetric(billableMetric: BillableMetricTinyModel?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) + + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } + + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditAllocation(creditAllocation: AllocationModel?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) + + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) + + fun discount(discount: JsonField) = apply { this.discount = discount } + + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) + + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) + + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) + + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + fun item(item: ItemSlimModel) = item(JsonField.of(item)) + + fun item(item: JsonField) = apply { this.item = item } + + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) + + 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)) + + /** + * 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: JsonField) = apply { this.metadata = metadata } + + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + fun name(name: String) = name(JsonField.of(name)) + + fun name(name: JsonField) = apply { this.name = name } + + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) + + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + + fun tieredConfig(tieredConfig: TieredConfigModel) = + tieredConfig(JsonField.of(tieredConfig)) + + fun tieredConfig(tieredConfig: JsonField) = apply { + this.tieredConfig = tieredConfig + } + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): TieredPrice = + TieredPrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + checkRequired("tieredConfig", tieredConfig), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) + } + + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * 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`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TIERED = of("tiered") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + TIERED + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TIERED, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TIERED -> Value.TIERED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TIERED -> Known.TIERED + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TieredPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && tieredConfig == other.tieredConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, tieredConfig, dimensionalPriceConfiguration, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, tieredConfig=$tieredConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class TieredBpsPrice + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + private val billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + private val creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("tiered_bps_config") + @ExcludeMissing + private val tieredBpsConfig: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + private val dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + fun billableMetric(): Optional = + Optional.ofNullable(billableMetric.getNullable("billable_metric")) + + fun billingCycleConfiguration(): BillingCycleConfigurationModel = + billingCycleConfiguration.getRequired("billing_cycle_configuration") + + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + fun creditAllocation(): Optional = + Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) + + fun currency(): String = currency.getRequired("currency") + + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) + + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + fun item(): ItemSlimModel = item.getRequired("item") + + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + fun modelType(): ModelType = modelType.getRequired("model_type") + + fun name(): String = name.getRequired("name") + + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + fun priceType(): PriceType = priceType.getRequired("price_type") + + fun tieredBpsConfig(): TieredBpsConfigModel = + tieredBpsConfig.getRequired("tiered_bps_config") + + fun dimensionalPriceConfiguration(): Optional = + Optional.ofNullable( + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + ) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric + + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation + + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount + + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType + + @JsonProperty("tiered_bps_config") + @ExcludeMissing + fun _tieredBpsConfig(): JsonField = tieredBpsConfig + + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): TieredBpsPrice = apply { + if (validated) { + return@apply + } + + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + cadence() + conversionRate() + 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() + name() + planPhaseOrder() + priceType() + tieredBpsConfig().validate() + dimensionalPriceConfiguration().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TieredBpsPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * .tieredBpsConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredBpsPrice]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var 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: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var tieredBpsConfig: JsonField? = null + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredBpsPrice: TieredBpsPrice) = apply { + id = tieredBpsPrice.id + billableMetric = tieredBpsPrice.billableMetric + billingCycleConfiguration = tieredBpsPrice.billingCycleConfiguration + cadence = tieredBpsPrice.cadence + conversionRate = tieredBpsPrice.conversionRate + createdAt = tieredBpsPrice.createdAt + creditAllocation = tieredBpsPrice.creditAllocation + currency = tieredBpsPrice.currency + discount = tieredBpsPrice.discount + externalPriceId = tieredBpsPrice.externalPriceId + fixedPriceQuantity = tieredBpsPrice.fixedPriceQuantity + invoicingCycleConfiguration = tieredBpsPrice.invoicingCycleConfiguration + item = tieredBpsPrice.item + maximum = tieredBpsPrice.maximum + maximumAmount = tieredBpsPrice.maximumAmount + metadata = tieredBpsPrice.metadata + minimum = tieredBpsPrice.minimum + minimumAmount = tieredBpsPrice.minimumAmount + modelType = tieredBpsPrice.modelType + name = tieredBpsPrice.name + planPhaseOrder = tieredBpsPrice.planPhaseOrder + priceType = tieredBpsPrice.priceType + tieredBpsConfig = tieredBpsPrice.tieredBpsConfig + dimensionalPriceConfiguration = tieredBpsPrice.dimensionalPriceConfiguration + additionalProperties = tieredBpsPrice.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun billableMetric(billableMetric: BillableMetricTinyModel?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) + + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } + + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditAllocation(creditAllocation: AllocationModel?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) + + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) + + fun discount(discount: JsonField) = apply { this.discount = discount } + + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) + + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) + + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) + + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + fun item(item: ItemSlimModel) = item(JsonField.of(item)) + + fun item(item: JsonField) = apply { this.item = item } + + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) + + 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)) + + /** + * 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: JsonField) = apply { this.metadata = metadata } + + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + fun name(name: String) = name(JsonField.of(name)) + + fun name(name: JsonField) = apply { this.name = name } + + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) + + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + + fun tieredBpsConfig(tieredBpsConfig: TieredBpsConfigModel) = + tieredBpsConfig(JsonField.of(tieredBpsConfig)) + + fun tieredBpsConfig(tieredBpsConfig: JsonField) = apply { + this.tieredBpsConfig = tieredBpsConfig + } + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): TieredBpsPrice = + TieredBpsPrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + checkRequired("tieredBpsConfig", tieredBpsConfig), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) + } + + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * 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`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TIERED_BPS = of("tiered_bps") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + TIERED_BPS + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TIERED_BPS, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TIERED_BPS -> Value.TIERED_BPS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TIERED_BPS -> Known.TIERED_BPS + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TieredBpsPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && tieredBpsConfig == other.tieredBpsConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, tieredBpsConfig, dimensionalPriceConfiguration, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredBpsPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, tieredBpsConfig=$tieredBpsConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class BpsPrice + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + private val billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("bps_config") + @ExcludeMissing + private val bpsConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + private val creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + private val dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + fun billableMetric(): Optional = + Optional.ofNullable(billableMetric.getNullable("billable_metric")) + + fun billingCycleConfiguration(): BillingCycleConfigurationModel = + billingCycleConfiguration.getRequired("billing_cycle_configuration") + + fun bpsConfig(): BpsConfigModel = bpsConfig.getRequired("bps_config") + + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + fun creditAllocation(): Optional = + Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) + + fun currency(): String = currency.getRequired("currency") + + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) + + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + fun item(): ItemSlimModel = item.getRequired("item") + + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + fun modelType(): ModelType = modelType.getRequired("model_type") + + fun name(): String = name.getRequired("name") + + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + fun priceType(): PriceType = priceType.getRequired("price_type") + + fun dimensionalPriceConfiguration(): Optional = + Optional.ofNullable( + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + ) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric + + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + @JsonProperty("bps_config") + @ExcludeMissing + fun _bpsConfig(): JsonField = bpsConfig + + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation + + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount + + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType + + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): BpsPrice = apply { + if (validated) { + return@apply + } + + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + bpsConfig().validate() + cadence() + conversionRate() + 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() + name() + planPhaseOrder() + priceType() + dimensionalPriceConfiguration().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BpsPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .bpsConfig() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BpsPrice]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var bpsConfig: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: 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: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bpsPrice: BpsPrice) = apply { + id = bpsPrice.id + billableMetric = bpsPrice.billableMetric + billingCycleConfiguration = bpsPrice.billingCycleConfiguration + bpsConfig = bpsPrice.bpsConfig + cadence = bpsPrice.cadence + conversionRate = bpsPrice.conversionRate + createdAt = bpsPrice.createdAt + creditAllocation = bpsPrice.creditAllocation + currency = bpsPrice.currency + discount = bpsPrice.discount + externalPriceId = bpsPrice.externalPriceId + fixedPriceQuantity = bpsPrice.fixedPriceQuantity + invoicingCycleConfiguration = bpsPrice.invoicingCycleConfiguration + item = bpsPrice.item + maximum = bpsPrice.maximum + maximumAmount = bpsPrice.maximumAmount + metadata = bpsPrice.metadata + minimum = bpsPrice.minimum + minimumAmount = bpsPrice.minimumAmount + modelType = bpsPrice.modelType + name = bpsPrice.name + planPhaseOrder = bpsPrice.planPhaseOrder + priceType = bpsPrice.priceType + dimensionalPriceConfiguration = bpsPrice.dimensionalPriceConfiguration + additionalProperties = bpsPrice.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun billableMetric(billableMetric: BillableMetricTinyModel?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) + + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } + + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + fun bpsConfig(bpsConfig: BpsConfigModel) = bpsConfig(JsonField.of(bpsConfig)) + + fun bpsConfig(bpsConfig: JsonField) = apply { + this.bpsConfig = bpsConfig + } + + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditAllocation(creditAllocation: AllocationModel?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) + + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) + + fun discount(discount: JsonField) = apply { this.discount = discount } + + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) + + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) + + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) + + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + fun item(item: ItemSlimModel) = item(JsonField.of(item)) + + fun item(item: JsonField) = apply { this.item = item } + + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) + + 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)) + + /** + * 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: JsonField) = apply { this.metadata = metadata } + + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + fun name(name: String) = name(JsonField.of(name)) + + fun name(name: JsonField) = apply { this.name = name } + + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) + + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): BpsPrice = + BpsPrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("bpsConfig", bpsConfig), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) + } + + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * 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`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val BPS = of("bps") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + BPS + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + BPS, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + BPS -> Value.BPS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + BPS -> Known.BPS + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BpsPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && bpsConfig == other.bpsConfig && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, bpsConfig, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BpsPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, bpsConfig=$bpsConfig, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class BulkBpsPrice + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + private val billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("bulk_bps_config") + @ExcludeMissing + private val bulkBpsConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + private val creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + private val dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + fun billableMetric(): Optional = + Optional.ofNullable(billableMetric.getNullable("billable_metric")) + + fun billingCycleConfiguration(): BillingCycleConfigurationModel = + billingCycleConfiguration.getRequired("billing_cycle_configuration") + + fun bulkBpsConfig(): BulkBpsConfigModel = bulkBpsConfig.getRequired("bulk_bps_config") + + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + fun creditAllocation(): Optional = + Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) + + fun currency(): String = currency.getRequired("currency") + + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) + + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + fun item(): ItemSlimModel = item.getRequired("item") + + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + fun modelType(): ModelType = modelType.getRequired("model_type") + + fun name(): String = name.getRequired("name") + + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + fun priceType(): PriceType = priceType.getRequired("price_type") + + fun dimensionalPriceConfiguration(): Optional = + Optional.ofNullable( + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + ) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric + + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + @JsonProperty("bulk_bps_config") + @ExcludeMissing + fun _bulkBpsConfig(): JsonField = bulkBpsConfig + + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation + + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount + + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType + + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): BulkBpsPrice = apply { + if (validated) { + return@apply + } + + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + bulkBpsConfig().validate() + cadence() + conversionRate() + 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() + name() + planPhaseOrder() + priceType() + dimensionalPriceConfiguration().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BulkBpsPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .bulkBpsConfig() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkBpsPrice]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var bulkBpsConfig: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: 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: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkBpsPrice: BulkBpsPrice) = apply { + id = bulkBpsPrice.id + billableMetric = bulkBpsPrice.billableMetric + billingCycleConfiguration = bulkBpsPrice.billingCycleConfiguration + bulkBpsConfig = bulkBpsPrice.bulkBpsConfig + cadence = bulkBpsPrice.cadence + conversionRate = bulkBpsPrice.conversionRate + createdAt = bulkBpsPrice.createdAt + creditAllocation = bulkBpsPrice.creditAllocation + currency = bulkBpsPrice.currency + discount = bulkBpsPrice.discount + externalPriceId = bulkBpsPrice.externalPriceId + fixedPriceQuantity = bulkBpsPrice.fixedPriceQuantity + invoicingCycleConfiguration = bulkBpsPrice.invoicingCycleConfiguration + item = bulkBpsPrice.item + maximum = bulkBpsPrice.maximum + maximumAmount = bulkBpsPrice.maximumAmount + metadata = bulkBpsPrice.metadata + minimum = bulkBpsPrice.minimum + minimumAmount = bulkBpsPrice.minimumAmount + modelType = bulkBpsPrice.modelType + name = bulkBpsPrice.name + planPhaseOrder = bulkBpsPrice.planPhaseOrder + priceType = bulkBpsPrice.priceType + dimensionalPriceConfiguration = bulkBpsPrice.dimensionalPriceConfiguration + additionalProperties = bulkBpsPrice.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun billableMetric(billableMetric: BillableMetricTinyModel?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) + + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } + + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfigModel) = + bulkBpsConfig(JsonField.of(bulkBpsConfig)) + + fun bulkBpsConfig(bulkBpsConfig: JsonField) = apply { + this.bulkBpsConfig = bulkBpsConfig + } + + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditAllocation(creditAllocation: AllocationModel?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) + + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) + + fun discount(discount: JsonField) = apply { this.discount = discount } + + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) + + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) + + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) + + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + fun item(item: ItemSlimModel) = item(JsonField.of(item)) + + fun item(item: JsonField) = apply { this.item = item } + + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) + + 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)) + + /** + * 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: JsonField) = apply { this.metadata = metadata } + + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + fun name(name: String) = name(JsonField.of(name)) + + fun name(name: JsonField) = apply { this.name = name } + + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) + + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): BulkBpsPrice = + BulkBpsPrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("bulkBpsConfig", bulkBpsConfig), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) + } + + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * 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`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val BULK_BPS = of("bulk_bps") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + BULK_BPS + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + BULK_BPS, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + BULK_BPS -> Value.BULK_BPS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + BULK_BPS -> Known.BULK_BPS + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BulkBpsPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && bulkBpsConfig == other.bulkBpsConfig && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, bulkBpsConfig, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkBpsPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, bulkBpsConfig=$bulkBpsConfig, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class BulkPrice + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + private val billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("bulk_config") + @ExcludeMissing + private val bulkConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + private val creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + private val dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + fun billableMetric(): Optional = + Optional.ofNullable(billableMetric.getNullable("billable_metric")) + + fun billingCycleConfiguration(): BillingCycleConfigurationModel = + billingCycleConfiguration.getRequired("billing_cycle_configuration") + + fun bulkConfig(): BulkConfigModel = bulkConfig.getRequired("bulk_config") + + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + fun creditAllocation(): Optional = + Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) + + fun currency(): String = currency.getRequired("currency") + + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) + + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + fun item(): ItemSlimModel = item.getRequired("item") + + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + fun modelType(): ModelType = modelType.getRequired("model_type") + + fun name(): String = name.getRequired("name") + + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + fun priceType(): PriceType = priceType.getRequired("price_type") + + fun dimensionalPriceConfiguration(): Optional = + Optional.ofNullable( + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + ) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric + + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + @JsonProperty("bulk_config") + @ExcludeMissing + fun _bulkConfig(): JsonField = bulkConfig + + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation + + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount + + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType + + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): BulkPrice = apply { + if (validated) { + return@apply + } + + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + bulkConfig().validate() + cadence() + conversionRate() + 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() + name() + planPhaseOrder() + priceType() + dimensionalPriceConfiguration().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BulkPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .bulkConfig() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkPrice]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var bulkConfig: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: 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: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkPrice: BulkPrice) = apply { + id = bulkPrice.id + billableMetric = bulkPrice.billableMetric + billingCycleConfiguration = bulkPrice.billingCycleConfiguration + bulkConfig = bulkPrice.bulkConfig + cadence = bulkPrice.cadence + conversionRate = bulkPrice.conversionRate + createdAt = bulkPrice.createdAt + creditAllocation = bulkPrice.creditAllocation + currency = bulkPrice.currency + discount = bulkPrice.discount + externalPriceId = bulkPrice.externalPriceId + fixedPriceQuantity = bulkPrice.fixedPriceQuantity + invoicingCycleConfiguration = bulkPrice.invoicingCycleConfiguration + item = bulkPrice.item + maximum = bulkPrice.maximum + maximumAmount = bulkPrice.maximumAmount + metadata = bulkPrice.metadata + minimum = bulkPrice.minimum + minimumAmount = bulkPrice.minimumAmount + modelType = bulkPrice.modelType + name = bulkPrice.name + planPhaseOrder = bulkPrice.planPhaseOrder + priceType = bulkPrice.priceType + dimensionalPriceConfiguration = bulkPrice.dimensionalPriceConfiguration + additionalProperties = bulkPrice.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun billableMetric(billableMetric: BillableMetricTinyModel?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) + + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } + + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + fun bulkConfig(bulkConfig: BulkConfigModel) = bulkConfig(JsonField.of(bulkConfig)) + + fun bulkConfig(bulkConfig: JsonField) = apply { + this.bulkConfig = bulkConfig + } + + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditAllocation(creditAllocation: AllocationModel?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) + + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) + + fun discount(discount: JsonField) = apply { this.discount = discount } + + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) + + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) + + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) + + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + fun item(item: ItemSlimModel) = item(JsonField.of(item)) + + fun item(item: JsonField) = apply { this.item = item } + + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) + + 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)) + + /** + * 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: JsonField) = apply { this.metadata = metadata } + + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + fun name(name: String) = name(JsonField.of(name)) + + fun name(name: JsonField) = apply { this.name = name } + + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) + + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): BulkPrice = + BulkPrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("bulkConfig", bulkConfig), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) + } + + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * 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`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val BULK = of("bulk") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + BULK + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + BULK, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + BULK -> Value.BULK + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + BULK -> Known.BULK + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BulkPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && bulkConfig == other.bulkConfig && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, bulkConfig, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, bulkConfig=$bulkConfig, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class ThresholdTotalAmountPrice + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + private val billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + private val creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("threshold_total_amount_config") + @ExcludeMissing + private val thresholdTotalAmountConfig: JsonField = + JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + private val dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + fun billableMetric(): Optional = + Optional.ofNullable(billableMetric.getNullable("billable_metric")) + + fun billingCycleConfiguration(): BillingCycleConfigurationModel = + billingCycleConfiguration.getRequired("billing_cycle_configuration") + + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + fun creditAllocation(): Optional = + Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) + + fun currency(): String = currency.getRequired("currency") + + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) + + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + fun item(): ItemSlimModel = item.getRequired("item") + + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + fun modelType(): ModelType = modelType.getRequired("model_type") + + fun name(): String = name.getRequired("name") + + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + fun priceType(): PriceType = priceType.getRequired("price_type") + + fun thresholdTotalAmountConfig(): CustomRatingFunctionConfigModel = + thresholdTotalAmountConfig.getRequired("threshold_total_amount_config") + + fun dimensionalPriceConfiguration(): Optional = + Optional.ofNullable( + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + ) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric + + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation + + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount + + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType + + @JsonProperty("threshold_total_amount_config") + @ExcludeMissing + fun _thresholdTotalAmountConfig(): JsonField = + thresholdTotalAmountConfig + + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): ThresholdTotalAmountPrice = apply { + if (validated) { + return@apply + } + + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + cadence() + conversionRate() + 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() + name() + planPhaseOrder() + priceType() + thresholdTotalAmountConfig().validate() + dimensionalPriceConfiguration().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ThresholdTotalAmountPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * .thresholdTotalAmountConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ThresholdTotalAmountPrice]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var 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: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var thresholdTotalAmountConfig: JsonField? = + null + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(thresholdTotalAmountPrice: ThresholdTotalAmountPrice) = apply { + id = thresholdTotalAmountPrice.id + billableMetric = thresholdTotalAmountPrice.billableMetric + billingCycleConfiguration = thresholdTotalAmountPrice.billingCycleConfiguration + cadence = thresholdTotalAmountPrice.cadence + conversionRate = thresholdTotalAmountPrice.conversionRate + createdAt = thresholdTotalAmountPrice.createdAt + creditAllocation = thresholdTotalAmountPrice.creditAllocation + currency = thresholdTotalAmountPrice.currency + discount = thresholdTotalAmountPrice.discount + externalPriceId = thresholdTotalAmountPrice.externalPriceId + fixedPriceQuantity = thresholdTotalAmountPrice.fixedPriceQuantity + invoicingCycleConfiguration = thresholdTotalAmountPrice.invoicingCycleConfiguration + item = thresholdTotalAmountPrice.item + maximum = thresholdTotalAmountPrice.maximum + maximumAmount = thresholdTotalAmountPrice.maximumAmount + metadata = thresholdTotalAmountPrice.metadata + minimum = thresholdTotalAmountPrice.minimum + minimumAmount = thresholdTotalAmountPrice.minimumAmount + modelType = thresholdTotalAmountPrice.modelType + name = thresholdTotalAmountPrice.name + planPhaseOrder = thresholdTotalAmountPrice.planPhaseOrder + priceType = thresholdTotalAmountPrice.priceType + thresholdTotalAmountConfig = thresholdTotalAmountPrice.thresholdTotalAmountConfig + dimensionalPriceConfiguration = + thresholdTotalAmountPrice.dimensionalPriceConfiguration + additionalProperties = thresholdTotalAmountPrice.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun billableMetric(billableMetric: BillableMetricTinyModel?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) + + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } + + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditAllocation(creditAllocation: AllocationModel?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) + + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) + + fun discount(discount: JsonField) = apply { this.discount = discount } + + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) + + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) + + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) + + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + fun item(item: ItemSlimModel) = item(JsonField.of(item)) + + fun item(item: JsonField) = apply { this.item = item } + + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) + + 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)) + + /** + * 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: JsonField) = apply { this.metadata = metadata } + + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + fun name(name: String) = name(JsonField.of(name)) + + fun name(name: JsonField) = apply { this.name = name } + + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) + + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + + fun thresholdTotalAmountConfig( + thresholdTotalAmountConfig: CustomRatingFunctionConfigModel + ) = thresholdTotalAmountConfig(JsonField.of(thresholdTotalAmountConfig)) + + fun thresholdTotalAmountConfig( + thresholdTotalAmountConfig: JsonField + ) = apply { this.thresholdTotalAmountConfig = thresholdTotalAmountConfig } + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): ThresholdTotalAmountPrice = + ThresholdTotalAmountPrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + checkRequired("thresholdTotalAmountConfig", thresholdTotalAmountConfig), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) + } + + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * 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`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val THRESHOLD_TOTAL_AMOUNT = of("threshold_total_amount") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + THRESHOLD_TOTAL_AMOUNT + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + THRESHOLD_TOTAL_AMOUNT, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + THRESHOLD_TOTAL_AMOUNT -> Value.THRESHOLD_TOTAL_AMOUNT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + THRESHOLD_TOTAL_AMOUNT -> Known.THRESHOLD_TOTAL_AMOUNT + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ThresholdTotalAmountPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, thresholdTotalAmountConfig, dimensionalPriceConfiguration, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdTotalAmountPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class TieredPackagePrice + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + private val billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + private val creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("tiered_package_config") + @ExcludeMissing + private val tieredPackageConfig: JsonField = + JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + private val dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + fun billableMetric(): Optional = + Optional.ofNullable(billableMetric.getNullable("billable_metric")) + + fun billingCycleConfiguration(): BillingCycleConfigurationModel = + billingCycleConfiguration.getRequired("billing_cycle_configuration") + + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + fun creditAllocation(): Optional = + Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) + + fun currency(): String = currency.getRequired("currency") + + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) + + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + fun item(): ItemSlimModel = item.getRequired("item") + + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + fun modelType(): ModelType = modelType.getRequired("model_type") + + fun name(): String = name.getRequired("name") + + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + fun priceType(): PriceType = priceType.getRequired("price_type") + + fun tieredPackageConfig(): CustomRatingFunctionConfigModel = + tieredPackageConfig.getRequired("tiered_package_config") + + fun dimensionalPriceConfiguration(): Optional = + Optional.ofNullable( + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + ) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric + + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation + + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount + + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType + + @JsonProperty("tiered_package_config") + @ExcludeMissing + fun _tieredPackageConfig(): JsonField = tieredPackageConfig + + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): TieredPackagePrice = apply { + if (validated) { + return@apply + } + + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + cadence() + conversionRate() + 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() + name() + planPhaseOrder() + priceType() + tieredPackageConfig().validate() + dimensionalPriceConfiguration().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TieredPackagePrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * .tieredPackageConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredPackagePrice]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var 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: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var tieredPackageConfig: JsonField? = null + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredPackagePrice: TieredPackagePrice) = apply { + id = tieredPackagePrice.id + billableMetric = tieredPackagePrice.billableMetric + billingCycleConfiguration = tieredPackagePrice.billingCycleConfiguration + cadence = tieredPackagePrice.cadence + conversionRate = tieredPackagePrice.conversionRate + createdAt = tieredPackagePrice.createdAt + creditAllocation = tieredPackagePrice.creditAllocation + currency = tieredPackagePrice.currency + discount = tieredPackagePrice.discount + externalPriceId = tieredPackagePrice.externalPriceId + fixedPriceQuantity = tieredPackagePrice.fixedPriceQuantity + invoicingCycleConfiguration = tieredPackagePrice.invoicingCycleConfiguration + item = tieredPackagePrice.item + maximum = tieredPackagePrice.maximum + maximumAmount = tieredPackagePrice.maximumAmount + metadata = tieredPackagePrice.metadata + minimum = tieredPackagePrice.minimum + minimumAmount = tieredPackagePrice.minimumAmount + modelType = tieredPackagePrice.modelType + name = tieredPackagePrice.name + planPhaseOrder = tieredPackagePrice.planPhaseOrder + priceType = tieredPackagePrice.priceType + tieredPackageConfig = tieredPackagePrice.tieredPackageConfig + dimensionalPriceConfiguration = tieredPackagePrice.dimensionalPriceConfiguration + additionalProperties = tieredPackagePrice.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun billableMetric(billableMetric: BillableMetricTinyModel?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) + + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } + + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditAllocation(creditAllocation: AllocationModel?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) + + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) + + fun discount(discount: JsonField) = apply { this.discount = discount } + + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) + + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) + + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) + + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + fun item(item: ItemSlimModel) = item(JsonField.of(item)) + + fun item(item: JsonField) = apply { this.item = item } + + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) + + 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)) + + /** + * 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: JsonField) = apply { this.metadata = metadata } + + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + fun name(name: String) = name(JsonField.of(name)) + + fun name(name: JsonField) = apply { this.name = name } + + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) + + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + + fun tieredPackageConfig(tieredPackageConfig: CustomRatingFunctionConfigModel) = + tieredPackageConfig(JsonField.of(tieredPackageConfig)) + + fun tieredPackageConfig( + tieredPackageConfig: JsonField + ) = apply { this.tieredPackageConfig = tieredPackageConfig } + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): TieredPackagePrice = + TieredPackagePrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + checkRequired("tieredPackageConfig", tieredPackageConfig), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) + } + + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * 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`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TIERED_PACKAGE = of("tiered_package") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + TIERED_PACKAGE + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TIERED_PACKAGE, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TIERED_PACKAGE -> Value.TIERED_PACKAGE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TIERED_PACKAGE -> Known.TIERED_PACKAGE + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TieredPackagePrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && tieredPackageConfig == other.tieredPackageConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, tieredPackageConfig, dimensionalPriceConfiguration, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackagePrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, tieredPackageConfig=$tieredPackageConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class GroupedTieredPrice + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + private val billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + private val creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("grouped_tiered_config") + @ExcludeMissing + private val groupedTieredConfig: JsonField = + JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + private val dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + fun billableMetric(): Optional = + Optional.ofNullable(billableMetric.getNullable("billable_metric")) + + fun billingCycleConfiguration(): BillingCycleConfigurationModel = + billingCycleConfiguration.getRequired("billing_cycle_configuration") + + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + fun creditAllocation(): Optional = + Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) + + fun currency(): String = currency.getRequired("currency") + + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) + + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + fun groupedTieredConfig(): CustomRatingFunctionConfigModel = + groupedTieredConfig.getRequired("grouped_tiered_config") + + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + fun item(): ItemSlimModel = item.getRequired("item") + + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + fun modelType(): ModelType = modelType.getRequired("model_type") + + fun name(): String = name.getRequired("name") + + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + fun priceType(): PriceType = priceType.getRequired("price_type") + + fun dimensionalPriceConfiguration(): Optional = + Optional.ofNullable( + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + ) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric + + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation + + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount + + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + @JsonProperty("grouped_tiered_config") + @ExcludeMissing + fun _groupedTieredConfig(): JsonField = groupedTieredConfig + + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType + + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): GroupedTieredPrice = apply { + if (validated) { + return@apply + } + + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + cadence() + conversionRate() + createdAt() + creditAllocation().ifPresent { it.validate() } + currency() + discount().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + groupedTieredConfig().validate() + invoicingCycleConfiguration().ifPresent { it.validate() } + item().validate() + maximum().ifPresent { it.validate() } + maximumAmount() + metadata().validate() + minimum().ifPresent { it.validate() } + minimumAmount() + modelType() + name() + planPhaseOrder() + priceType() + dimensionalPriceConfiguration().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [GroupedTieredPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .groupedTieredConfig() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedTieredPrice]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var 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 groupedTieredConfig: 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: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedTieredPrice: GroupedTieredPrice) = apply { + id = groupedTieredPrice.id + billableMetric = groupedTieredPrice.billableMetric + billingCycleConfiguration = groupedTieredPrice.billingCycleConfiguration + cadence = groupedTieredPrice.cadence + conversionRate = groupedTieredPrice.conversionRate + createdAt = groupedTieredPrice.createdAt + creditAllocation = groupedTieredPrice.creditAllocation + currency = groupedTieredPrice.currency + discount = groupedTieredPrice.discount + externalPriceId = groupedTieredPrice.externalPriceId + fixedPriceQuantity = groupedTieredPrice.fixedPriceQuantity + groupedTieredConfig = groupedTieredPrice.groupedTieredConfig + invoicingCycleConfiguration = groupedTieredPrice.invoicingCycleConfiguration + item = groupedTieredPrice.item + maximum = groupedTieredPrice.maximum + maximumAmount = groupedTieredPrice.maximumAmount + metadata = groupedTieredPrice.metadata + minimum = groupedTieredPrice.minimum + minimumAmount = groupedTieredPrice.minimumAmount + modelType = groupedTieredPrice.modelType + name = groupedTieredPrice.name + planPhaseOrder = groupedTieredPrice.planPhaseOrder + priceType = groupedTieredPrice.priceType + dimensionalPriceConfiguration = groupedTieredPrice.dimensionalPriceConfiguration + additionalProperties = groupedTieredPrice.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun billableMetric(billableMetric: BillableMetricTinyModel?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) + + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } + + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditAllocation(creditAllocation: AllocationModel?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) + + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) + + fun discount(discount: JsonField) = apply { this.discount = discount } + + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) + + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) + + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) + + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + fun groupedTieredConfig(groupedTieredConfig: CustomRatingFunctionConfigModel) = + groupedTieredConfig(JsonField.of(groupedTieredConfig)) + + fun groupedTieredConfig( + groupedTieredConfig: JsonField + ) = apply { this.groupedTieredConfig = groupedTieredConfig } + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + fun item(item: ItemSlimModel) = item(JsonField.of(item)) + + fun item(item: JsonField) = apply { this.item = item } + + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) + + 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)) + + /** + * 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: JsonField) = apply { this.metadata = metadata } + + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + fun name(name: String) = name(JsonField.of(name)) + + fun name(name: JsonField) = apply { this.name = name } + + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) + + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): GroupedTieredPrice = + GroupedTieredPrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("groupedTieredConfig", groupedTieredConfig), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) + } + + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * 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`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val GROUPED_TIERED = of("grouped_tiered") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + GROUPED_TIERED + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GROUPED_TIERED, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GROUPED_TIERED -> Value.GROUPED_TIERED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + GROUPED_TIERED -> Known.GROUPED_TIERED + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is GroupedTieredPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && groupedTieredConfig == other.groupedTieredConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, groupedTieredConfig, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTieredPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedTieredConfig=$groupedTieredConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class TieredWithMinimumPrice + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + private val billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + private val creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_minimum_config") + @ExcludeMissing + private val tieredWithMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + private val dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + fun billableMetric(): Optional = + Optional.ofNullable(billableMetric.getNullable("billable_metric")) + + fun billingCycleConfiguration(): BillingCycleConfigurationModel = + billingCycleConfiguration.getRequired("billing_cycle_configuration") + + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + fun creditAllocation(): Optional = + Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) + + fun currency(): String = currency.getRequired("currency") + + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) + + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + fun item(): ItemSlimModel = item.getRequired("item") + + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + fun modelType(): ModelType = modelType.getRequired("model_type") + + fun name(): String = name.getRequired("name") + + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + fun priceType(): PriceType = priceType.getRequired("price_type") + + fun tieredWithMinimumConfig(): CustomRatingFunctionConfigModel = + tieredWithMinimumConfig.getRequired("tiered_with_minimum_config") + + fun dimensionalPriceConfiguration(): Optional = + Optional.ofNullable( + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + ) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric + + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation + + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount + + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType + + @JsonProperty("tiered_with_minimum_config") + @ExcludeMissing + fun _tieredWithMinimumConfig(): JsonField = + tieredWithMinimumConfig + + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): TieredWithMinimumPrice = apply { + if (validated) { + return@apply + } + + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + cadence() + conversionRate() + 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() + name() + planPhaseOrder() + priceType() + tieredWithMinimumConfig().validate() + dimensionalPriceConfiguration().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TieredWithMinimumPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * .tieredWithMinimumConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithMinimumPrice]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var 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: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var tieredWithMinimumConfig: JsonField? = null + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredWithMinimumPrice: TieredWithMinimumPrice) = apply { + id = tieredWithMinimumPrice.id + billableMetric = tieredWithMinimumPrice.billableMetric + billingCycleConfiguration = tieredWithMinimumPrice.billingCycleConfiguration + cadence = tieredWithMinimumPrice.cadence + conversionRate = tieredWithMinimumPrice.conversionRate + createdAt = tieredWithMinimumPrice.createdAt + creditAllocation = tieredWithMinimumPrice.creditAllocation + currency = tieredWithMinimumPrice.currency + discount = tieredWithMinimumPrice.discount + externalPriceId = tieredWithMinimumPrice.externalPriceId + fixedPriceQuantity = tieredWithMinimumPrice.fixedPriceQuantity + invoicingCycleConfiguration = tieredWithMinimumPrice.invoicingCycleConfiguration + item = tieredWithMinimumPrice.item + maximum = tieredWithMinimumPrice.maximum + maximumAmount = tieredWithMinimumPrice.maximumAmount + metadata = tieredWithMinimumPrice.metadata + minimum = tieredWithMinimumPrice.minimum + minimumAmount = tieredWithMinimumPrice.minimumAmount + modelType = tieredWithMinimumPrice.modelType + name = tieredWithMinimumPrice.name + planPhaseOrder = tieredWithMinimumPrice.planPhaseOrder + priceType = tieredWithMinimumPrice.priceType + tieredWithMinimumConfig = tieredWithMinimumPrice.tieredWithMinimumConfig + dimensionalPriceConfiguration = tieredWithMinimumPrice.dimensionalPriceConfiguration + additionalProperties = tieredWithMinimumPrice.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun billableMetric(billableMetric: BillableMetricTinyModel?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) + + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } + + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditAllocation(creditAllocation: AllocationModel?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) + + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) + + fun discount(discount: JsonField) = apply { this.discount = discount } + + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) + + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) + + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) + + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + fun item(item: ItemSlimModel) = item(JsonField.of(item)) + + fun item(item: JsonField) = apply { this.item = item } + + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) + + 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)) + + /** + * 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: JsonField) = apply { this.metadata = metadata } + + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + fun name(name: String) = name(JsonField.of(name)) + + fun name(name: JsonField) = apply { this.name = name } + + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) + + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + + fun tieredWithMinimumConfig(tieredWithMinimumConfig: CustomRatingFunctionConfigModel) = + tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) + + fun tieredWithMinimumConfig( + tieredWithMinimumConfig: JsonField + ) = apply { this.tieredWithMinimumConfig = tieredWithMinimumConfig } + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): TieredWithMinimumPrice = + TieredWithMinimumPrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + checkRequired("tieredWithMinimumConfig", tieredWithMinimumConfig), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) + } + + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * 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`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TIERED_WITH_MINIMUM = of("tiered_with_minimum") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + TIERED_WITH_MINIMUM + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TIERED_WITH_MINIMUM, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TIERED_WITH_MINIMUM -> Value.TIERED_WITH_MINIMUM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TIERED_WITH_MINIMUM -> Known.TIERED_WITH_MINIMUM + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TieredWithMinimumPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && tieredWithMinimumConfig == other.tieredWithMinimumConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, tieredWithMinimumConfig, dimensionalPriceConfiguration, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithMinimumPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, tieredWithMinimumConfig=$tieredWithMinimumConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class TieredPackageWithMinimumPrice + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + private val billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + private val creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("tiered_package_with_minimum_config") + @ExcludeMissing + private val tieredPackageWithMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + private val dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + fun billableMetric(): Optional = + Optional.ofNullable(billableMetric.getNullable("billable_metric")) + + fun billingCycleConfiguration(): BillingCycleConfigurationModel = + billingCycleConfiguration.getRequired("billing_cycle_configuration") + + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + fun creditAllocation(): Optional = + Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) + + fun currency(): String = currency.getRequired("currency") + + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) + + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + fun item(): ItemSlimModel = item.getRequired("item") + + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + fun modelType(): ModelType = modelType.getRequired("model_type") + + fun name(): String = name.getRequired("name") + + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + fun priceType(): PriceType = priceType.getRequired("price_type") + + fun tieredPackageWithMinimumConfig(): CustomRatingFunctionConfigModel = + tieredPackageWithMinimumConfig.getRequired("tiered_package_with_minimum_config") + + fun dimensionalPriceConfiguration(): Optional = + Optional.ofNullable( + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + ) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric + + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation + + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount + + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType + + @JsonProperty("tiered_package_with_minimum_config") + @ExcludeMissing + fun _tieredPackageWithMinimumConfig(): JsonField = + tieredPackageWithMinimumConfig + + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): TieredPackageWithMinimumPrice = apply { + if (validated) { + return@apply + } + + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + cadence() + conversionRate() + 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() + name() + planPhaseOrder() + priceType() + tieredPackageWithMinimumConfig().validate() + dimensionalPriceConfiguration().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [TieredPackageWithMinimumPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * .tieredPackageWithMinimumConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredPackageWithMinimumPrice]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var 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: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var tieredPackageWithMinimumConfig: + JsonField? = + null + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredPackageWithMinimumPrice: TieredPackageWithMinimumPrice) = + apply { + id = tieredPackageWithMinimumPrice.id + billableMetric = tieredPackageWithMinimumPrice.billableMetric + billingCycleConfiguration = + tieredPackageWithMinimumPrice.billingCycleConfiguration + cadence = tieredPackageWithMinimumPrice.cadence + conversionRate = tieredPackageWithMinimumPrice.conversionRate + createdAt = tieredPackageWithMinimumPrice.createdAt + creditAllocation = tieredPackageWithMinimumPrice.creditAllocation + currency = tieredPackageWithMinimumPrice.currency + discount = tieredPackageWithMinimumPrice.discount + externalPriceId = tieredPackageWithMinimumPrice.externalPriceId + fixedPriceQuantity = tieredPackageWithMinimumPrice.fixedPriceQuantity + invoicingCycleConfiguration = + tieredPackageWithMinimumPrice.invoicingCycleConfiguration + item = tieredPackageWithMinimumPrice.item + maximum = tieredPackageWithMinimumPrice.maximum + maximumAmount = tieredPackageWithMinimumPrice.maximumAmount + metadata = tieredPackageWithMinimumPrice.metadata + minimum = tieredPackageWithMinimumPrice.minimum + minimumAmount = tieredPackageWithMinimumPrice.minimumAmount + modelType = tieredPackageWithMinimumPrice.modelType + name = tieredPackageWithMinimumPrice.name + planPhaseOrder = tieredPackageWithMinimumPrice.planPhaseOrder + priceType = tieredPackageWithMinimumPrice.priceType + tieredPackageWithMinimumConfig = + tieredPackageWithMinimumPrice.tieredPackageWithMinimumConfig + dimensionalPriceConfiguration = + tieredPackageWithMinimumPrice.dimensionalPriceConfiguration + additionalProperties = + tieredPackageWithMinimumPrice.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun billableMetric(billableMetric: BillableMetricTinyModel?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) + + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } + + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditAllocation(creditAllocation: AllocationModel?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) + + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) + + fun discount(discount: JsonField) = apply { this.discount = discount } + + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) + + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) + + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) + + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + fun item(item: ItemSlimModel) = item(JsonField.of(item)) + + fun item(item: JsonField) = apply { this.item = item } + + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) + + 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)) + + /** + * 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: JsonField) = apply { this.metadata = metadata } + + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + fun name(name: String) = name(JsonField.of(name)) + + fun name(name: JsonField) = apply { this.name = name } + + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) + + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + + fun tieredPackageWithMinimumConfig( + tieredPackageWithMinimumConfig: CustomRatingFunctionConfigModel + ) = tieredPackageWithMinimumConfig(JsonField.of(tieredPackageWithMinimumConfig)) + + fun tieredPackageWithMinimumConfig( + tieredPackageWithMinimumConfig: JsonField + ) = apply { this.tieredPackageWithMinimumConfig = tieredPackageWithMinimumConfig } + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): TieredPackageWithMinimumPrice = + TieredPackageWithMinimumPrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + checkRequired("tieredPackageWithMinimumConfig", tieredPackageWithMinimumConfig), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) + } + + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * 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`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TIERED_PACKAGE_WITH_MINIMUM = of("tiered_package_with_minimum") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + TIERED_PACKAGE_WITH_MINIMUM + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TIERED_PACKAGE_WITH_MINIMUM, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TIERED_PACKAGE_WITH_MINIMUM -> Value.TIERED_PACKAGE_WITH_MINIMUM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TIERED_PACKAGE_WITH_MINIMUM -> Known.TIERED_PACKAGE_WITH_MINIMUM + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TieredPackageWithMinimumPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && tieredPackageWithMinimumConfig == other.tieredPackageWithMinimumConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, tieredPackageWithMinimumConfig, dimensionalPriceConfiguration, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackageWithMinimumPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class PackageWithAllocationPrice + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + private val billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + private val creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("package_with_allocation_config") + @ExcludeMissing + private val packageWithAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + private val dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + fun billableMetric(): Optional = + Optional.ofNullable(billableMetric.getNullable("billable_metric")) + + fun billingCycleConfiguration(): BillingCycleConfigurationModel = + billingCycleConfiguration.getRequired("billing_cycle_configuration") + + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + fun creditAllocation(): Optional = + Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) + + fun currency(): String = currency.getRequired("currency") + + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) + + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + fun item(): ItemSlimModel = item.getRequired("item") + + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + fun modelType(): ModelType = modelType.getRequired("model_type") + + fun name(): String = name.getRequired("name") + + fun packageWithAllocationConfig(): CustomRatingFunctionConfigModel = + packageWithAllocationConfig.getRequired("package_with_allocation_config") + + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + fun priceType(): PriceType = priceType.getRequired("price_type") + + fun dimensionalPriceConfiguration(): Optional = + Optional.ofNullable( + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + ) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric + + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation + + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount + + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("package_with_allocation_config") + @ExcludeMissing + fun _packageWithAllocationConfig(): JsonField = + packageWithAllocationConfig + + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType + + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): PackageWithAllocationPrice = apply { + if (validated) { + return@apply + } + + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + cadence() + conversionRate() + 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() + name() + packageWithAllocationConfig().validate() + planPhaseOrder() + priceType() + dimensionalPriceConfiguration().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PackageWithAllocationPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .packageWithAllocationConfig() + * .planPhaseOrder() + * .priceType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PackageWithAllocationPrice]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var 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: JsonField? = null + private var name: JsonField? = null + private var packageWithAllocationConfig: JsonField? = + null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(packageWithAllocationPrice: PackageWithAllocationPrice) = apply { + id = packageWithAllocationPrice.id + billableMetric = packageWithAllocationPrice.billableMetric + billingCycleConfiguration = packageWithAllocationPrice.billingCycleConfiguration + cadence = packageWithAllocationPrice.cadence + conversionRate = packageWithAllocationPrice.conversionRate + createdAt = packageWithAllocationPrice.createdAt + creditAllocation = packageWithAllocationPrice.creditAllocation + currency = packageWithAllocationPrice.currency + discount = packageWithAllocationPrice.discount + externalPriceId = packageWithAllocationPrice.externalPriceId + fixedPriceQuantity = packageWithAllocationPrice.fixedPriceQuantity + invoicingCycleConfiguration = packageWithAllocationPrice.invoicingCycleConfiguration + item = packageWithAllocationPrice.item + maximum = packageWithAllocationPrice.maximum + maximumAmount = packageWithAllocationPrice.maximumAmount + metadata = packageWithAllocationPrice.metadata + minimum = packageWithAllocationPrice.minimum + minimumAmount = packageWithAllocationPrice.minimumAmount + modelType = packageWithAllocationPrice.modelType + name = packageWithAllocationPrice.name + packageWithAllocationConfig = packageWithAllocationPrice.packageWithAllocationConfig + planPhaseOrder = packageWithAllocationPrice.planPhaseOrder + priceType = packageWithAllocationPrice.priceType + dimensionalPriceConfiguration = + packageWithAllocationPrice.dimensionalPriceConfiguration + additionalProperties = + packageWithAllocationPrice.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun billableMetric(billableMetric: BillableMetricTinyModel?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) + + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } + + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditAllocation(creditAllocation: AllocationModel?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) + + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) + + fun discount(discount: JsonField) = apply { this.discount = discount } + + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) + + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) + + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) + + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + fun item(item: ItemSlimModel) = item(JsonField.of(item)) + + fun item(item: JsonField) = apply { this.item = item } + + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) + + 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)) + + /** + * 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: JsonField) = apply { this.metadata = metadata } + + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + fun name(name: String) = name(JsonField.of(name)) + + fun name(name: JsonField) = apply { this.name = name } + + fun packageWithAllocationConfig( + packageWithAllocationConfig: CustomRatingFunctionConfigModel + ) = packageWithAllocationConfig(JsonField.of(packageWithAllocationConfig)) + + fun packageWithAllocationConfig( + packageWithAllocationConfig: JsonField + ) = apply { this.packageWithAllocationConfig = packageWithAllocationConfig } + + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) + + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): PackageWithAllocationPrice = + PackageWithAllocationPrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("packageWithAllocationConfig", packageWithAllocationConfig), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) + } + + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * 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`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PACKAGE_WITH_ALLOCATION = of("package_with_allocation") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + PACKAGE_WITH_ALLOCATION + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PACKAGE_WITH_ALLOCATION, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PACKAGE_WITH_ALLOCATION -> Value.PACKAGE_WITH_ALLOCATION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PACKAGE_WITH_ALLOCATION -> Known.PACKAGE_WITH_ALLOCATION + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PackageWithAllocationPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && packageWithAllocationConfig == other.packageWithAllocationConfig && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, packageWithAllocationConfig, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PackageWithAllocationPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class UnitWithPercentPrice + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + private val billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + private val creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("unit_with_percent_config") + @ExcludeMissing + private val unitWithPercentConfig: JsonField = + JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + private val dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + fun billableMetric(): Optional = + Optional.ofNullable(billableMetric.getNullable("billable_metric")) + + fun billingCycleConfiguration(): BillingCycleConfigurationModel = + billingCycleConfiguration.getRequired("billing_cycle_configuration") + + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + fun creditAllocation(): Optional = + Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) + + fun currency(): String = currency.getRequired("currency") + + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) + + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + fun item(): ItemSlimModel = item.getRequired("item") + + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + fun modelType(): ModelType = modelType.getRequired("model_type") + + fun name(): String = name.getRequired("name") + + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + fun priceType(): PriceType = priceType.getRequired("price_type") + + fun unitWithPercentConfig(): CustomRatingFunctionConfigModel = + unitWithPercentConfig.getRequired("unit_with_percent_config") + + fun dimensionalPriceConfiguration(): Optional = + Optional.ofNullable( + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + ) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric + + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation + + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount + + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType + + @JsonProperty("unit_with_percent_config") + @ExcludeMissing + fun _unitWithPercentConfig(): JsonField = + unitWithPercentConfig + + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): UnitWithPercentPrice = apply { + if (validated) { + return@apply + } + + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + cadence() + conversionRate() + 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() + name() + planPhaseOrder() + priceType() + unitWithPercentConfig().validate() + dimensionalPriceConfiguration().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnitWithPercentPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * .unitWithPercentConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnitWithPercentPrice]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var 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: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var unitWithPercentConfig: JsonField? = null + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unitWithPercentPrice: UnitWithPercentPrice) = apply { + id = unitWithPercentPrice.id + billableMetric = unitWithPercentPrice.billableMetric + billingCycleConfiguration = unitWithPercentPrice.billingCycleConfiguration + cadence = unitWithPercentPrice.cadence + conversionRate = unitWithPercentPrice.conversionRate + createdAt = unitWithPercentPrice.createdAt + creditAllocation = unitWithPercentPrice.creditAllocation + currency = unitWithPercentPrice.currency + discount = unitWithPercentPrice.discount + externalPriceId = unitWithPercentPrice.externalPriceId + fixedPriceQuantity = unitWithPercentPrice.fixedPriceQuantity + invoicingCycleConfiguration = unitWithPercentPrice.invoicingCycleConfiguration + item = unitWithPercentPrice.item + maximum = unitWithPercentPrice.maximum + maximumAmount = unitWithPercentPrice.maximumAmount + metadata = unitWithPercentPrice.metadata + minimum = unitWithPercentPrice.minimum + minimumAmount = unitWithPercentPrice.minimumAmount + modelType = unitWithPercentPrice.modelType + name = unitWithPercentPrice.name + planPhaseOrder = unitWithPercentPrice.planPhaseOrder + priceType = unitWithPercentPrice.priceType + unitWithPercentConfig = unitWithPercentPrice.unitWithPercentConfig + dimensionalPriceConfiguration = unitWithPercentPrice.dimensionalPriceConfiguration + additionalProperties = unitWithPercentPrice.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun billableMetric(billableMetric: BillableMetricTinyModel?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) + + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } + + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditAllocation(creditAllocation: AllocationModel?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) + + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) + + fun discount(discount: JsonField) = apply { this.discount = discount } + + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) + + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) + + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) + + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + fun item(item: ItemSlimModel) = item(JsonField.of(item)) + + fun item(item: JsonField) = apply { this.item = item } + + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) + + 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)) + + /** + * 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: JsonField) = apply { this.metadata = metadata } + + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + fun name(name: String) = name(JsonField.of(name)) + + fun name(name: JsonField) = apply { this.name = name } + + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) + + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + + fun unitWithPercentConfig(unitWithPercentConfig: CustomRatingFunctionConfigModel) = + unitWithPercentConfig(JsonField.of(unitWithPercentConfig)) + + fun unitWithPercentConfig( + unitWithPercentConfig: JsonField + ) = apply { this.unitWithPercentConfig = unitWithPercentConfig } + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): UnitWithPercentPrice = + UnitWithPercentPrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + checkRequired("unitWithPercentConfig", unitWithPercentConfig), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) + } + + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * 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`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val UNIT_WITH_PERCENT = of("unit_with_percent") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + UNIT_WITH_PERCENT + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + UNIT_WITH_PERCENT, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + UNIT_WITH_PERCENT -> Value.UNIT_WITH_PERCENT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + UNIT_WITH_PERCENT -> Known.UNIT_WITH_PERCENT + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is UnitWithPercentPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && unitWithPercentConfig == other.unitWithPercentConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, unitWithPercentConfig, dimensionalPriceConfiguration, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithPercentPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, unitWithPercentConfig=$unitWithPercentConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class MatrixWithAllocationPrice + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + private val billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + private val creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("matrix_with_allocation_config") + @ExcludeMissing + private val matrixWithAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + private val dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + fun billableMetric(): Optional = + Optional.ofNullable(billableMetric.getNullable("billable_metric")) + + fun billingCycleConfiguration(): BillingCycleConfigurationModel = + billingCycleConfiguration.getRequired("billing_cycle_configuration") + + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + fun creditAllocation(): Optional = + Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) + + fun currency(): String = currency.getRequired("currency") + + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) + + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + fun item(): ItemSlimModel = item.getRequired("item") + + fun matrixWithAllocationConfig(): MatrixWithAllocationConfigModel = + matrixWithAllocationConfig.getRequired("matrix_with_allocation_config") + + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + fun modelType(): ModelType = modelType.getRequired("model_type") + + fun name(): String = name.getRequired("name") + + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + fun priceType(): PriceType = priceType.getRequired("price_type") + + fun dimensionalPriceConfiguration(): Optional = + Optional.ofNullable( + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + ) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric + + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation + + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount + + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + @JsonProperty("matrix_with_allocation_config") + @ExcludeMissing + fun _matrixWithAllocationConfig(): JsonField = + matrixWithAllocationConfig + + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType + + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): MatrixWithAllocationPrice = apply { + if (validated) { + return@apply + } + + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + cadence() + conversionRate() + createdAt() + creditAllocation().ifPresent { it.validate() } + currency() + discount().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoicingCycleConfiguration().ifPresent { it.validate() } + item().validate() + matrixWithAllocationConfig().validate() + maximum().ifPresent { it.validate() } + maximumAmount() + metadata().validate() + minimum().ifPresent { it.validate() } + minimumAmount() + modelType() + name() + planPhaseOrder() + priceType() + dimensionalPriceConfiguration().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixWithAllocationPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .matrixWithAllocationConfig() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixWithAllocationPrice]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var 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 matrixWithAllocationConfig: JsonField? = + null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(matrixWithAllocationPrice: MatrixWithAllocationPrice) = apply { + id = matrixWithAllocationPrice.id + billableMetric = matrixWithAllocationPrice.billableMetric + billingCycleConfiguration = matrixWithAllocationPrice.billingCycleConfiguration + cadence = matrixWithAllocationPrice.cadence + conversionRate = matrixWithAllocationPrice.conversionRate + createdAt = matrixWithAllocationPrice.createdAt + creditAllocation = matrixWithAllocationPrice.creditAllocation + currency = matrixWithAllocationPrice.currency + discount = matrixWithAllocationPrice.discount + externalPriceId = matrixWithAllocationPrice.externalPriceId + fixedPriceQuantity = matrixWithAllocationPrice.fixedPriceQuantity + invoicingCycleConfiguration = matrixWithAllocationPrice.invoicingCycleConfiguration + item = matrixWithAllocationPrice.item + matrixWithAllocationConfig = matrixWithAllocationPrice.matrixWithAllocationConfig + maximum = matrixWithAllocationPrice.maximum + maximumAmount = matrixWithAllocationPrice.maximumAmount + metadata = matrixWithAllocationPrice.metadata + minimum = matrixWithAllocationPrice.minimum + minimumAmount = matrixWithAllocationPrice.minimumAmount + modelType = matrixWithAllocationPrice.modelType + name = matrixWithAllocationPrice.name + planPhaseOrder = matrixWithAllocationPrice.planPhaseOrder + priceType = matrixWithAllocationPrice.priceType + dimensionalPriceConfiguration = + matrixWithAllocationPrice.dimensionalPriceConfiguration + additionalProperties = matrixWithAllocationPrice.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun billableMetric(billableMetric: BillableMetricTinyModel?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) + + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } + + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditAllocation(creditAllocation: AllocationModel?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) + + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) + + fun discount(discount: JsonField) = apply { this.discount = discount } + + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) + + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) + + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) + + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + fun item(item: ItemSlimModel) = item(JsonField.of(item)) + + fun item(item: JsonField) = apply { this.item = item } + + fun matrixWithAllocationConfig( + matrixWithAllocationConfig: MatrixWithAllocationConfigModel + ) = matrixWithAllocationConfig(JsonField.of(matrixWithAllocationConfig)) + + fun matrixWithAllocationConfig( + matrixWithAllocationConfig: JsonField + ) = apply { this.matrixWithAllocationConfig = matrixWithAllocationConfig } + + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) + + 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)) + + /** + * 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: JsonField) = apply { this.metadata = metadata } + + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + fun name(name: String) = name(JsonField.of(name)) + + fun name(name: JsonField) = apply { this.name = name } + + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) + + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): MatrixWithAllocationPrice = + MatrixWithAllocationPrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + 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("matrixWithAllocationConfig", matrixWithAllocationConfig), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) + } + + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * 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`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val MATRIX_WITH_ALLOCATION = of("matrix_with_allocation") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + MATRIX_WITH_ALLOCATION + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MATRIX_WITH_ALLOCATION, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MATRIX_WITH_ALLOCATION -> Value.MATRIX_WITH_ALLOCATION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MATRIX_WITH_ALLOCATION -> Known.MATRIX_WITH_ALLOCATION + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MatrixWithAllocationPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && matrixWithAllocationConfig == other.matrixWithAllocationConfig && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, matrixWithAllocationConfig, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithAllocationPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixWithAllocationConfig=$matrixWithAllocationConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class TieredWithProrationPrice + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + private val billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + private val creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + private val tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + private val dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + fun billableMetric(): Optional = + Optional.ofNullable(billableMetric.getNullable("billable_metric")) + + fun billingCycleConfiguration(): BillingCycleConfigurationModel = + billingCycleConfiguration.getRequired("billing_cycle_configuration") + + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + fun creditAllocation(): Optional = + Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) + + fun currency(): String = currency.getRequired("currency") + + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) + + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + fun item(): ItemSlimModel = item.getRequired("item") + + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + fun modelType(): ModelType = modelType.getRequired("model_type") + + fun name(): String = name.getRequired("name") + + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + fun priceType(): PriceType = priceType.getRequired("price_type") + + fun tieredWithProrationConfig(): CustomRatingFunctionConfigModel = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + + fun dimensionalPriceConfiguration(): Optional = + Optional.ofNullable( + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + ) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric + + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation + + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount + + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType + + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig + + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): TieredWithProrationPrice = apply { + if (validated) { + return@apply + } + + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + cadence() + conversionRate() + 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() + name() + planPhaseOrder() + priceType() + tieredWithProrationConfig().validate() + dimensionalPriceConfiguration().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TieredWithProrationPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * .tieredWithProrationConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredWithProrationPrice]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var 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: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredWithProrationPrice: TieredWithProrationPrice) = apply { + id = tieredWithProrationPrice.id + billableMetric = tieredWithProrationPrice.billableMetric + billingCycleConfiguration = tieredWithProrationPrice.billingCycleConfiguration + cadence = tieredWithProrationPrice.cadence + conversionRate = tieredWithProrationPrice.conversionRate + createdAt = tieredWithProrationPrice.createdAt + creditAllocation = tieredWithProrationPrice.creditAllocation + currency = tieredWithProrationPrice.currency + discount = tieredWithProrationPrice.discount + externalPriceId = tieredWithProrationPrice.externalPriceId + fixedPriceQuantity = tieredWithProrationPrice.fixedPriceQuantity + invoicingCycleConfiguration = tieredWithProrationPrice.invoicingCycleConfiguration + item = tieredWithProrationPrice.item + maximum = tieredWithProrationPrice.maximum + maximumAmount = tieredWithProrationPrice.maximumAmount + metadata = tieredWithProrationPrice.metadata + minimum = tieredWithProrationPrice.minimum + minimumAmount = tieredWithProrationPrice.minimumAmount + modelType = tieredWithProrationPrice.modelType + name = tieredWithProrationPrice.name + planPhaseOrder = tieredWithProrationPrice.planPhaseOrder + priceType = tieredWithProrationPrice.priceType + tieredWithProrationConfig = tieredWithProrationPrice.tieredWithProrationConfig + dimensionalPriceConfiguration = + tieredWithProrationPrice.dimensionalPriceConfiguration + additionalProperties = tieredWithProrationPrice.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun billableMetric(billableMetric: BillableMetricTinyModel?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) + + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } + + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditAllocation(creditAllocation: AllocationModel?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) + + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) + + fun discount(discount: JsonField) = apply { this.discount = discount } + + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) + + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) + + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) + + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + fun item(item: ItemSlimModel) = item(JsonField.of(item)) + + fun item(item: JsonField) = apply { this.item = item } + + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) + + 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)) + + /** + * 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: JsonField) = apply { this.metadata = metadata } + + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + fun name(name: String) = name(JsonField.of(name)) + + fun name(name: JsonField) = apply { this.name = name } + + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) + + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + + fun tieredWithProrationConfig( + tieredWithProrationConfig: CustomRatingFunctionConfigModel + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): TieredWithProrationPrice = + TieredWithProrationPrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) + } + + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * 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`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TIERED_WITH_PRORATION = of("tiered_with_proration") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + TIERED_WITH_PRORATION + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TIERED_WITH_PRORATION, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TIERED_WITH_PRORATION -> Value.TIERED_WITH_PRORATION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TIERED_WITH_PRORATION -> Known.TIERED_WITH_PRORATION + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TieredWithProrationPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && tieredWithProrationConfig == other.tieredWithProrationConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, tieredWithProrationConfig, dimensionalPriceConfiguration, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredWithProrationPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, tieredWithProrationConfig=$tieredWithProrationConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class UnitWithProrationPrice + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + private val billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + private val creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("unit_with_proration_config") + @ExcludeMissing + private val unitWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + private val dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + fun billableMetric(): Optional = + Optional.ofNullable(billableMetric.getNullable("billable_metric")) + + fun billingCycleConfiguration(): BillingCycleConfigurationModel = + billingCycleConfiguration.getRequired("billing_cycle_configuration") + + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + fun creditAllocation(): Optional = + Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) + + fun currency(): String = currency.getRequired("currency") + + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) + + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + fun item(): ItemSlimModel = item.getRequired("item") + + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + fun modelType(): ModelType = modelType.getRequired("model_type") + + fun name(): String = name.getRequired("name") + + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + fun priceType(): PriceType = priceType.getRequired("price_type") + + fun unitWithProrationConfig(): CustomRatingFunctionConfigModel = + unitWithProrationConfig.getRequired("unit_with_proration_config") + + fun dimensionalPriceConfiguration(): Optional = + Optional.ofNullable( + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + ) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric + + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation + + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount + + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType + + @JsonProperty("unit_with_proration_config") + @ExcludeMissing + fun _unitWithProrationConfig(): JsonField = + unitWithProrationConfig + + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): UnitWithProrationPrice = apply { + if (validated) { + return@apply + } + + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + cadence() + conversionRate() + 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() + name() + planPhaseOrder() + priceType() + unitWithProrationConfig().validate() + dimensionalPriceConfiguration().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnitWithProrationPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * .unitWithProrationConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnitWithProrationPrice]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var 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: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var unitWithProrationConfig: JsonField? = null + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unitWithProrationPrice: UnitWithProrationPrice) = apply { + id = unitWithProrationPrice.id + billableMetric = unitWithProrationPrice.billableMetric + billingCycleConfiguration = unitWithProrationPrice.billingCycleConfiguration + cadence = unitWithProrationPrice.cadence + conversionRate = unitWithProrationPrice.conversionRate + createdAt = unitWithProrationPrice.createdAt + creditAllocation = unitWithProrationPrice.creditAllocation + currency = unitWithProrationPrice.currency + discount = unitWithProrationPrice.discount + externalPriceId = unitWithProrationPrice.externalPriceId + fixedPriceQuantity = unitWithProrationPrice.fixedPriceQuantity + invoicingCycleConfiguration = unitWithProrationPrice.invoicingCycleConfiguration + item = unitWithProrationPrice.item + maximum = unitWithProrationPrice.maximum + maximumAmount = unitWithProrationPrice.maximumAmount + metadata = unitWithProrationPrice.metadata + minimum = unitWithProrationPrice.minimum + minimumAmount = unitWithProrationPrice.minimumAmount + modelType = unitWithProrationPrice.modelType + name = unitWithProrationPrice.name + planPhaseOrder = unitWithProrationPrice.planPhaseOrder + priceType = unitWithProrationPrice.priceType + unitWithProrationConfig = unitWithProrationPrice.unitWithProrationConfig + dimensionalPriceConfiguration = unitWithProrationPrice.dimensionalPriceConfiguration + additionalProperties = unitWithProrationPrice.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun billableMetric(billableMetric: BillableMetricTinyModel?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) + + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } + + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditAllocation(creditAllocation: AllocationModel?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) + + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) + + fun discount(discount: JsonField) = apply { this.discount = discount } + + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) + + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) + + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) + + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + fun item(item: ItemSlimModel) = item(JsonField.of(item)) + + fun item(item: JsonField) = apply { this.item = item } + + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) + + 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)) + + /** + * 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: JsonField) = apply { this.metadata = metadata } + + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + fun name(name: String) = name(JsonField.of(name)) + + fun name(name: JsonField) = apply { this.name = name } + + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) + + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + + fun unitWithProrationConfig(unitWithProrationConfig: CustomRatingFunctionConfigModel) = + unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) + + fun unitWithProrationConfig( + unitWithProrationConfig: JsonField + ) = apply { this.unitWithProrationConfig = unitWithProrationConfig } + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): UnitWithProrationPrice = + UnitWithProrationPrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + checkRequired("unitWithProrationConfig", unitWithProrationConfig), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) + } + + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * 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`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val UNIT_WITH_PRORATION = of("unit_with_proration") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + UNIT_WITH_PRORATION + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + UNIT_WITH_PRORATION, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + UNIT_WITH_PRORATION -> Value.UNIT_WITH_PRORATION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + UNIT_WITH_PRORATION -> Known.UNIT_WITH_PRORATION + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is UnitWithProrationPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && unitWithProrationConfig == other.unitWithProrationConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, unitWithProrationConfig, dimensionalPriceConfiguration, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitWithProrationPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, unitWithProrationConfig=$unitWithProrationConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class GroupedAllocationPrice + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + private val billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + private val creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("grouped_allocation_config") + @ExcludeMissing + private val groupedAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + private val dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + fun billableMetric(): Optional = + Optional.ofNullable(billableMetric.getNullable("billable_metric")) + + fun billingCycleConfiguration(): BillingCycleConfigurationModel = + billingCycleConfiguration.getRequired("billing_cycle_configuration") + + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + fun creditAllocation(): Optional = + Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) + + fun currency(): String = currency.getRequired("currency") + + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) + + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + fun groupedAllocationConfig(): CustomRatingFunctionConfigModel = + groupedAllocationConfig.getRequired("grouped_allocation_config") + + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + fun item(): ItemSlimModel = item.getRequired("item") + + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + fun modelType(): ModelType = modelType.getRequired("model_type") + + fun name(): String = name.getRequired("name") + + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + fun priceType(): PriceType = priceType.getRequired("price_type") + + fun dimensionalPriceConfiguration(): Optional = + Optional.ofNullable( + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + ) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric + + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation + + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount + + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + @JsonProperty("grouped_allocation_config") + @ExcludeMissing + fun _groupedAllocationConfig(): JsonField = + groupedAllocationConfig + + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType + + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): GroupedAllocationPrice = apply { + if (validated) { + return@apply + } + + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + cadence() + conversionRate() + 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() + name() + planPhaseOrder() + priceType() + dimensionalPriceConfiguration().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [GroupedAllocationPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .groupedAllocationConfig() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedAllocationPrice]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var 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: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedAllocationPrice: GroupedAllocationPrice) = apply { + id = groupedAllocationPrice.id + billableMetric = groupedAllocationPrice.billableMetric + billingCycleConfiguration = groupedAllocationPrice.billingCycleConfiguration + cadence = groupedAllocationPrice.cadence + conversionRate = groupedAllocationPrice.conversionRate + createdAt = groupedAllocationPrice.createdAt + creditAllocation = groupedAllocationPrice.creditAllocation + currency = groupedAllocationPrice.currency + discount = groupedAllocationPrice.discount + externalPriceId = groupedAllocationPrice.externalPriceId + fixedPriceQuantity = groupedAllocationPrice.fixedPriceQuantity + groupedAllocationConfig = groupedAllocationPrice.groupedAllocationConfig + invoicingCycleConfiguration = groupedAllocationPrice.invoicingCycleConfiguration + item = groupedAllocationPrice.item + maximum = groupedAllocationPrice.maximum + maximumAmount = groupedAllocationPrice.maximumAmount + metadata = groupedAllocationPrice.metadata + minimum = groupedAllocationPrice.minimum + minimumAmount = groupedAllocationPrice.minimumAmount + modelType = groupedAllocationPrice.modelType + name = groupedAllocationPrice.name + planPhaseOrder = groupedAllocationPrice.planPhaseOrder + priceType = groupedAllocationPrice.priceType + dimensionalPriceConfiguration = groupedAllocationPrice.dimensionalPriceConfiguration + additionalProperties = groupedAllocationPrice.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun billableMetric(billableMetric: BillableMetricTinyModel?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) + + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } + + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditAllocation(creditAllocation: AllocationModel?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) + + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) + + fun discount(discount: JsonField) = apply { this.discount = discount } + + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) + + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) + + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) + + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + fun groupedAllocationConfig(groupedAllocationConfig: CustomRatingFunctionConfigModel) = + groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) + + fun groupedAllocationConfig( + groupedAllocationConfig: JsonField + ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + fun item(item: ItemSlimModel) = item(JsonField.of(item)) + + fun item(item: JsonField) = apply { this.item = item } + + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) + + 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)) + + /** + * 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: JsonField) = apply { this.metadata = metadata } + + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + fun name(name: String) = name(JsonField.of(name)) + + fun name(name: JsonField) = apply { this.name = name } + + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) + + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): GroupedAllocationPrice = + GroupedAllocationPrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + 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), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) + } + + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * 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`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val GROUPED_ALLOCATION = of("grouped_allocation") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + GROUPED_ALLOCATION + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GROUPED_ALLOCATION, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GROUPED_ALLOCATION -> Value.GROUPED_ALLOCATION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + GROUPED_ALLOCATION -> Known.GROUPED_ALLOCATION + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is GroupedAllocationPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && groupedAllocationConfig == other.groupedAllocationConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, groupedAllocationConfig, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedAllocationPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedAllocationConfig=$groupedAllocationConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class GroupedWithProratedMinimumPrice + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + private val billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + private val creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_prorated_minimum_config") + @ExcludeMissing + private val groupedWithProratedMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + private val dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + fun billableMetric(): Optional = + Optional.ofNullable(billableMetric.getNullable("billable_metric")) + + fun billingCycleConfiguration(): BillingCycleConfigurationModel = + billingCycleConfiguration.getRequired("billing_cycle_configuration") + + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + fun creditAllocation(): Optional = + Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) + + fun currency(): String = currency.getRequired("currency") + + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) + + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + fun groupedWithProratedMinimumConfig(): CustomRatingFunctionConfigModel = + groupedWithProratedMinimumConfig.getRequired("grouped_with_prorated_minimum_config") + + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + fun item(): ItemSlimModel = item.getRequired("item") + + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + fun modelType(): ModelType = modelType.getRequired("model_type") + + fun name(): String = name.getRequired("name") + + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + fun priceType(): PriceType = priceType.getRequired("price_type") + + fun dimensionalPriceConfiguration(): Optional = + Optional.ofNullable( + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + ) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric + + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation + + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount + + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + @JsonProperty("grouped_with_prorated_minimum_config") + @ExcludeMissing + fun _groupedWithProratedMinimumConfig(): JsonField = + groupedWithProratedMinimumConfig + + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType + + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): GroupedWithProratedMinimumPrice = apply { + if (validated) { + return@apply + } + + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + cadence() + conversionRate() + createdAt() + creditAllocation().ifPresent { it.validate() } + currency() + discount().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + groupedWithProratedMinimumConfig().validate() + invoicingCycleConfiguration().ifPresent { it.validate() } + item().validate() + maximum().ifPresent { it.validate() } + maximumAmount() + metadata().validate() + minimum().ifPresent { it.validate() } + minimumAmount() + modelType() + name() + planPhaseOrder() + priceType() + dimensionalPriceConfiguration().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithProratedMinimumPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .groupedWithProratedMinimumConfig() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithProratedMinimumPrice]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var 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 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: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedWithProratedMinimumPrice: GroupedWithProratedMinimumPrice) = + apply { + id = groupedWithProratedMinimumPrice.id + billableMetric = groupedWithProratedMinimumPrice.billableMetric + billingCycleConfiguration = + groupedWithProratedMinimumPrice.billingCycleConfiguration + cadence = groupedWithProratedMinimumPrice.cadence + conversionRate = groupedWithProratedMinimumPrice.conversionRate + createdAt = groupedWithProratedMinimumPrice.createdAt + creditAllocation = groupedWithProratedMinimumPrice.creditAllocation + currency = groupedWithProratedMinimumPrice.currency + discount = groupedWithProratedMinimumPrice.discount + externalPriceId = groupedWithProratedMinimumPrice.externalPriceId + fixedPriceQuantity = groupedWithProratedMinimumPrice.fixedPriceQuantity + groupedWithProratedMinimumConfig = + groupedWithProratedMinimumPrice.groupedWithProratedMinimumConfig + invoicingCycleConfiguration = + groupedWithProratedMinimumPrice.invoicingCycleConfiguration + item = groupedWithProratedMinimumPrice.item + maximum = groupedWithProratedMinimumPrice.maximum + maximumAmount = groupedWithProratedMinimumPrice.maximumAmount + metadata = groupedWithProratedMinimumPrice.metadata + minimum = groupedWithProratedMinimumPrice.minimum + minimumAmount = groupedWithProratedMinimumPrice.minimumAmount + modelType = groupedWithProratedMinimumPrice.modelType + name = groupedWithProratedMinimumPrice.name + planPhaseOrder = groupedWithProratedMinimumPrice.planPhaseOrder + priceType = groupedWithProratedMinimumPrice.priceType + dimensionalPriceConfiguration = + groupedWithProratedMinimumPrice.dimensionalPriceConfiguration + additionalProperties = + groupedWithProratedMinimumPrice.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun billableMetric(billableMetric: BillableMetricTinyModel?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) + + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } + + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditAllocation(creditAllocation: AllocationModel?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) + + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) + + fun discount(discount: JsonField) = apply { this.discount = discount } + + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) + + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) + + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) + + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: CustomRatingFunctionConfigModel + ) = groupedWithProratedMinimumConfig(JsonField.of(groupedWithProratedMinimumConfig)) + + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: JsonField + ) = apply { this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig } + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + fun item(item: ItemSlimModel) = item(JsonField.of(item)) + + fun item(item: JsonField) = apply { this.item = item } + + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) + + 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)) + + /** + * 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: JsonField) = apply { this.metadata = metadata } + + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + fun name(name: String) = name(JsonField.of(name)) + + fun name(name: JsonField) = apply { this.name = name } + + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) + + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): GroupedWithProratedMinimumPrice = + GroupedWithProratedMinimumPrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired( + "groupedWithProratedMinimumConfig", + groupedWithProratedMinimumConfig, + ), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) + } + + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * 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`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val GROUPED_WITH_PRORATED_MINIMUM = of("grouped_with_prorated_minimum") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + GROUPED_WITH_PRORATED_MINIMUM + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GROUPED_WITH_PRORATED_MINIMUM, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GROUPED_WITH_PRORATED_MINIMUM -> Value.GROUPED_WITH_PRORATED_MINIMUM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + GROUPED_WITH_PRORATED_MINIMUM -> Known.GROUPED_WITH_PRORATED_MINIMUM + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is GroupedWithProratedMinimumPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && groupedWithProratedMinimumConfig == other.groupedWithProratedMinimumConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, groupedWithProratedMinimumConfig, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithProratedMinimumPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class GroupedWithMeteredMinimumPrice + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + private val billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + private val creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_metered_minimum_config") + @ExcludeMissing + private val groupedWithMeteredMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + private val dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + fun billableMetric(): Optional = + Optional.ofNullable(billableMetric.getNullable("billable_metric")) + + fun billingCycleConfiguration(): BillingCycleConfigurationModel = + billingCycleConfiguration.getRequired("billing_cycle_configuration") + + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + fun creditAllocation(): Optional = + Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) + + fun currency(): String = currency.getRequired("currency") + + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) + + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + fun groupedWithMeteredMinimumConfig(): CustomRatingFunctionConfigModel = + groupedWithMeteredMinimumConfig.getRequired("grouped_with_metered_minimum_config") + + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + fun item(): ItemSlimModel = item.getRequired("item") + + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + fun modelType(): ModelType = modelType.getRequired("model_type") + + fun name(): String = name.getRequired("name") + + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + fun priceType(): PriceType = priceType.getRequired("price_type") + + fun dimensionalPriceConfiguration(): Optional = + Optional.ofNullable( + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + ) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric + + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation + + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount + + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + @JsonProperty("grouped_with_metered_minimum_config") + @ExcludeMissing + fun _groupedWithMeteredMinimumConfig(): JsonField = + groupedWithMeteredMinimumConfig + + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType + + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): GroupedWithMeteredMinimumPrice = apply { + if (validated) { + return@apply + } + + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + cadence() + conversionRate() + createdAt() + creditAllocation().ifPresent { it.validate() } + currency() + discount().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + groupedWithMeteredMinimumConfig().validate() + invoicingCycleConfiguration().ifPresent { it.validate() } + item().validate() + maximum().ifPresent { it.validate() } + maximumAmount() + metadata().validate() + minimum().ifPresent { it.validate() } + minimumAmount() + modelType() + name() + planPhaseOrder() + priceType() + dimensionalPriceConfiguration().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedWithMeteredMinimumPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .groupedWithMeteredMinimumConfig() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedWithMeteredMinimumPrice]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var 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 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: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedWithMeteredMinimumPrice: GroupedWithMeteredMinimumPrice) = + apply { + id = groupedWithMeteredMinimumPrice.id + billableMetric = groupedWithMeteredMinimumPrice.billableMetric + billingCycleConfiguration = + groupedWithMeteredMinimumPrice.billingCycleConfiguration + cadence = groupedWithMeteredMinimumPrice.cadence + conversionRate = groupedWithMeteredMinimumPrice.conversionRate + createdAt = groupedWithMeteredMinimumPrice.createdAt + creditAllocation = groupedWithMeteredMinimumPrice.creditAllocation + currency = groupedWithMeteredMinimumPrice.currency + discount = groupedWithMeteredMinimumPrice.discount + externalPriceId = groupedWithMeteredMinimumPrice.externalPriceId + fixedPriceQuantity = groupedWithMeteredMinimumPrice.fixedPriceQuantity + groupedWithMeteredMinimumConfig = + groupedWithMeteredMinimumPrice.groupedWithMeteredMinimumConfig + invoicingCycleConfiguration = + groupedWithMeteredMinimumPrice.invoicingCycleConfiguration + item = groupedWithMeteredMinimumPrice.item + maximum = groupedWithMeteredMinimumPrice.maximum + maximumAmount = groupedWithMeteredMinimumPrice.maximumAmount + metadata = groupedWithMeteredMinimumPrice.metadata + minimum = groupedWithMeteredMinimumPrice.minimum + minimumAmount = groupedWithMeteredMinimumPrice.minimumAmount + modelType = groupedWithMeteredMinimumPrice.modelType + name = groupedWithMeteredMinimumPrice.name + planPhaseOrder = groupedWithMeteredMinimumPrice.planPhaseOrder + priceType = groupedWithMeteredMinimumPrice.priceType + dimensionalPriceConfiguration = + groupedWithMeteredMinimumPrice.dimensionalPriceConfiguration + additionalProperties = + groupedWithMeteredMinimumPrice.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun billableMetric(billableMetric: BillableMetricTinyModel?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) + + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } + + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditAllocation(creditAllocation: AllocationModel?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) + + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) + + fun discount(discount: JsonField) = apply { this.discount = discount } + + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) + + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) + + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) + + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: CustomRatingFunctionConfigModel + ) = groupedWithMeteredMinimumConfig(JsonField.of(groupedWithMeteredMinimumConfig)) + + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: JsonField + ) = apply { this.groupedWithMeteredMinimumConfig = groupedWithMeteredMinimumConfig } + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + fun item(item: ItemSlimModel) = item(JsonField.of(item)) + + fun item(item: JsonField) = apply { this.item = item } + + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) + + 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)) + + /** + * 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: JsonField) = apply { this.metadata = metadata } + + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + fun name(name: String) = name(JsonField.of(name)) + + fun name(name: JsonField) = apply { this.name = name } + + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) + + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): GroupedWithMeteredMinimumPrice = + GroupedWithMeteredMinimumPrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired( + "groupedWithMeteredMinimumConfig", + groupedWithMeteredMinimumConfig, + ), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) + } + + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * 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`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val GROUPED_WITH_METERED_MINIMUM = of("grouped_with_metered_minimum") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + GROUPED_WITH_METERED_MINIMUM + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GROUPED_WITH_METERED_MINIMUM, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GROUPED_WITH_METERED_MINIMUM -> Value.GROUPED_WITH_METERED_MINIMUM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + GROUPED_WITH_METERED_MINIMUM -> Known.GROUPED_WITH_METERED_MINIMUM + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is GroupedWithMeteredMinimumPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && groupedWithMeteredMinimumConfig == other.groupedWithMeteredMinimumConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, groupedWithMeteredMinimumConfig, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedWithMeteredMinimumPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class MatrixWithDisplayNamePrice + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + private val billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + private val creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + private val matrixWithDisplayNameConfig: JsonField = + JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + private val dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + fun billableMetric(): Optional = + Optional.ofNullable(billableMetric.getNullable("billable_metric")) + + fun billingCycleConfiguration(): BillingCycleConfigurationModel = + billingCycleConfiguration.getRequired("billing_cycle_configuration") + + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + fun creditAllocation(): Optional = + Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) + + fun currency(): String = currency.getRequired("currency") + + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) + + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + fun item(): ItemSlimModel = item.getRequired("item") + + fun matrixWithDisplayNameConfig(): CustomRatingFunctionConfigModel = + matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_config") + + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + fun modelType(): ModelType = modelType.getRequired("model_type") + + fun name(): String = name.getRequired("name") + + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + fun priceType(): PriceType = priceType.getRequired("price_type") + + fun dimensionalPriceConfiguration(): Optional = + Optional.ofNullable( + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + ) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric + + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation + + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount + + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + fun _matrixWithDisplayNameConfig(): JsonField = + matrixWithDisplayNameConfig + + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType + + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): MatrixWithDisplayNamePrice = apply { + if (validated) { + return@apply + } + + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + cadence() + conversionRate() + createdAt() + creditAllocation().ifPresent { it.validate() } + currency() + discount().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoicingCycleConfiguration().ifPresent { it.validate() } + item().validate() + matrixWithDisplayNameConfig().validate() + maximum().ifPresent { it.validate() } + maximumAmount() + metadata().validate() + minimum().ifPresent { it.validate() } + minimumAmount() + modelType() + name() + planPhaseOrder() + priceType() + dimensionalPriceConfiguration().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MatrixWithDisplayNamePrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .matrixWithDisplayNameConfig() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MatrixWithDisplayNamePrice]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var 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 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: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(matrixWithDisplayNamePrice: MatrixWithDisplayNamePrice) = apply { + id = matrixWithDisplayNamePrice.id + billableMetric = matrixWithDisplayNamePrice.billableMetric + billingCycleConfiguration = matrixWithDisplayNamePrice.billingCycleConfiguration + cadence = matrixWithDisplayNamePrice.cadence + conversionRate = matrixWithDisplayNamePrice.conversionRate + createdAt = matrixWithDisplayNamePrice.createdAt + creditAllocation = matrixWithDisplayNamePrice.creditAllocation + currency = matrixWithDisplayNamePrice.currency + discount = matrixWithDisplayNamePrice.discount + externalPriceId = matrixWithDisplayNamePrice.externalPriceId + fixedPriceQuantity = matrixWithDisplayNamePrice.fixedPriceQuantity + invoicingCycleConfiguration = matrixWithDisplayNamePrice.invoicingCycleConfiguration + item = matrixWithDisplayNamePrice.item + matrixWithDisplayNameConfig = matrixWithDisplayNamePrice.matrixWithDisplayNameConfig + maximum = matrixWithDisplayNamePrice.maximum + maximumAmount = matrixWithDisplayNamePrice.maximumAmount + metadata = matrixWithDisplayNamePrice.metadata + minimum = matrixWithDisplayNamePrice.minimum + minimumAmount = matrixWithDisplayNamePrice.minimumAmount + modelType = matrixWithDisplayNamePrice.modelType + name = matrixWithDisplayNamePrice.name + planPhaseOrder = matrixWithDisplayNamePrice.planPhaseOrder + priceType = matrixWithDisplayNamePrice.priceType + dimensionalPriceConfiguration = + matrixWithDisplayNamePrice.dimensionalPriceConfiguration + additionalProperties = + matrixWithDisplayNamePrice.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun billableMetric(billableMetric: BillableMetricTinyModel?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) + + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } + + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditAllocation(creditAllocation: AllocationModel?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) + + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) + + fun discount(discount: JsonField) = apply { this.discount = discount } + + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) + + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) + + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) + + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + fun item(item: ItemSlimModel) = item(JsonField.of(item)) + + fun item(item: JsonField) = apply { this.item = item } + + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: CustomRatingFunctionConfigModel + ) = matrixWithDisplayNameConfig(JsonField.of(matrixWithDisplayNameConfig)) + + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: JsonField + ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } + + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) + + 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)) + + /** + * 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: JsonField) = apply { this.metadata = metadata } + + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + fun name(name: String) = name(JsonField.of(name)) + + fun name(name: JsonField) = apply { this.name = name } + + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) + + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): MatrixWithDisplayNamePrice = + MatrixWithDisplayNamePrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + 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("matrixWithDisplayNameConfig", matrixWithDisplayNameConfig), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) + } + + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * 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`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val MATRIX_WITH_DISPLAY_NAME = of("matrix_with_display_name") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + MATRIX_WITH_DISPLAY_NAME + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MATRIX_WITH_DISPLAY_NAME, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MATRIX_WITH_DISPLAY_NAME -> Value.MATRIX_WITH_DISPLAY_NAME + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MATRIX_WITH_DISPLAY_NAME -> Known.MATRIX_WITH_DISPLAY_NAME + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MatrixWithDisplayNamePrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && matrixWithDisplayNameConfig == other.matrixWithDisplayNameConfig && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, matrixWithDisplayNameConfig, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MatrixWithDisplayNamePrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class BulkWithProrationPrice + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + private val billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("bulk_with_proration_config") + @ExcludeMissing + private val bulkWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + private val creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + private val dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + fun billableMetric(): Optional = + Optional.ofNullable(billableMetric.getNullable("billable_metric")) + + fun billingCycleConfiguration(): BillingCycleConfigurationModel = + billingCycleConfiguration.getRequired("billing_cycle_configuration") + + fun bulkWithProrationConfig(): CustomRatingFunctionConfigModel = + bulkWithProrationConfig.getRequired("bulk_with_proration_config") + + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + fun creditAllocation(): Optional = + Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) + + fun currency(): String = currency.getRequired("currency") + + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) + + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + fun item(): ItemSlimModel = item.getRequired("item") + + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + fun modelType(): ModelType = modelType.getRequired("model_type") + + fun name(): String = name.getRequired("name") + + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + fun priceType(): PriceType = priceType.getRequired("price_type") + + fun dimensionalPriceConfiguration(): Optional = + Optional.ofNullable( + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + ) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric + + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + @JsonProperty("bulk_with_proration_config") + @ExcludeMissing + fun _bulkWithProrationConfig(): JsonField = + bulkWithProrationConfig + + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation + + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount + + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType + + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): BulkWithProrationPrice = apply { + if (validated) { + return@apply + } + + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + bulkWithProrationConfig().validate() + cadence() + conversionRate() + 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() + name() + planPhaseOrder() + priceType() + dimensionalPriceConfiguration().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BulkWithProrationPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .bulkWithProrationConfig() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkWithProrationPrice]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var bulkWithProrationConfig: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: 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: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkWithProrationPrice: BulkWithProrationPrice) = apply { + id = bulkWithProrationPrice.id + billableMetric = bulkWithProrationPrice.billableMetric + billingCycleConfiguration = bulkWithProrationPrice.billingCycleConfiguration + bulkWithProrationConfig = bulkWithProrationPrice.bulkWithProrationConfig + cadence = bulkWithProrationPrice.cadence + conversionRate = bulkWithProrationPrice.conversionRate + createdAt = bulkWithProrationPrice.createdAt + creditAllocation = bulkWithProrationPrice.creditAllocation + currency = bulkWithProrationPrice.currency + discount = bulkWithProrationPrice.discount + externalPriceId = bulkWithProrationPrice.externalPriceId + fixedPriceQuantity = bulkWithProrationPrice.fixedPriceQuantity + invoicingCycleConfiguration = bulkWithProrationPrice.invoicingCycleConfiguration + item = bulkWithProrationPrice.item + maximum = bulkWithProrationPrice.maximum + maximumAmount = bulkWithProrationPrice.maximumAmount + metadata = bulkWithProrationPrice.metadata + minimum = bulkWithProrationPrice.minimum + minimumAmount = bulkWithProrationPrice.minimumAmount + modelType = bulkWithProrationPrice.modelType + name = bulkWithProrationPrice.name + planPhaseOrder = bulkWithProrationPrice.planPhaseOrder + priceType = bulkWithProrationPrice.priceType + dimensionalPriceConfiguration = bulkWithProrationPrice.dimensionalPriceConfiguration + additionalProperties = bulkWithProrationPrice.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun billableMetric(billableMetric: BillableMetricTinyModel?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) + + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } + + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + fun bulkWithProrationConfig(bulkWithProrationConfig: CustomRatingFunctionConfigModel) = + bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) + + fun bulkWithProrationConfig( + bulkWithProrationConfig: JsonField + ) = apply { this.bulkWithProrationConfig = bulkWithProrationConfig } + + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditAllocation(creditAllocation: AllocationModel?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) + + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) + + fun discount(discount: JsonField) = apply { this.discount = discount } + + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) + + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) + + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) + + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + fun item(item: ItemSlimModel) = item(JsonField.of(item)) + + fun item(item: JsonField) = apply { this.item = item } + + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) + + 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)) + + /** + * 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: JsonField) = apply { this.metadata = metadata } + + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + fun name(name: String) = name(JsonField.of(name)) + + fun name(name: JsonField) = apply { this.name = name } + + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) + + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): BulkWithProrationPrice = + BulkWithProrationPrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("bulkWithProrationConfig", bulkWithProrationConfig), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) + } + + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * 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`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val BULK_WITH_PRORATION = of("bulk_with_proration") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + BULK_WITH_PRORATION + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + BULK_WITH_PRORATION, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + BULK_WITH_PRORATION -> Value.BULK_WITH_PRORATION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + BULK_WITH_PRORATION -> Known.BULK_WITH_PRORATION + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BulkWithProrationPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && bulkWithProrationConfig == other.bulkWithProrationConfig && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, bulkWithProrationConfig, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkWithProrationPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class GroupedTieredPackagePrice + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + private val billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + private val creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("grouped_tiered_package_config") + @ExcludeMissing + private val groupedTieredPackageConfig: JsonField = + JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + private val dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + fun billableMetric(): Optional = + Optional.ofNullable(billableMetric.getNullable("billable_metric")) + + fun billingCycleConfiguration(): BillingCycleConfigurationModel = + billingCycleConfiguration.getRequired("billing_cycle_configuration") + + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + fun creditAllocation(): Optional = + Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) + + fun currency(): String = currency.getRequired("currency") + + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) + + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + fun groupedTieredPackageConfig(): CustomRatingFunctionConfigModel = + groupedTieredPackageConfig.getRequired("grouped_tiered_package_config") + + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + fun item(): ItemSlimModel = item.getRequired("item") + + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + fun modelType(): ModelType = modelType.getRequired("model_type") + + fun name(): String = name.getRequired("name") + + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + fun priceType(): PriceType = priceType.getRequired("price_type") + + fun dimensionalPriceConfiguration(): Optional = + Optional.ofNullable( + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + ) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric + + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation + + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount + + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + @JsonProperty("grouped_tiered_package_config") + @ExcludeMissing + fun _groupedTieredPackageConfig(): JsonField = + groupedTieredPackageConfig + + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType + + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): GroupedTieredPackagePrice = apply { + if (validated) { + return@apply + } + + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + cadence() + conversionRate() + createdAt() + creditAllocation().ifPresent { it.validate() } + currency() + discount().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + groupedTieredPackageConfig().validate() + invoicingCycleConfiguration().ifPresent { it.validate() } + item().validate() + maximum().ifPresent { it.validate() } + maximumAmount() + metadata().validate() + minimum().ifPresent { it.validate() } + minimumAmount() + modelType() + name() + planPhaseOrder() + priceType() + dimensionalPriceConfiguration().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GroupedTieredPackagePrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .groupedTieredPackageConfig() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GroupedTieredPackagePrice]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var 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 groupedTieredPackageConfig: 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: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(groupedTieredPackagePrice: GroupedTieredPackagePrice) = apply { + id = groupedTieredPackagePrice.id + billableMetric = groupedTieredPackagePrice.billableMetric + billingCycleConfiguration = groupedTieredPackagePrice.billingCycleConfiguration + cadence = groupedTieredPackagePrice.cadence + conversionRate = groupedTieredPackagePrice.conversionRate + createdAt = groupedTieredPackagePrice.createdAt + creditAllocation = groupedTieredPackagePrice.creditAllocation + currency = groupedTieredPackagePrice.currency + discount = groupedTieredPackagePrice.discount + externalPriceId = groupedTieredPackagePrice.externalPriceId + fixedPriceQuantity = groupedTieredPackagePrice.fixedPriceQuantity + groupedTieredPackageConfig = groupedTieredPackagePrice.groupedTieredPackageConfig + invoicingCycleConfiguration = groupedTieredPackagePrice.invoicingCycleConfiguration + item = groupedTieredPackagePrice.item + maximum = groupedTieredPackagePrice.maximum + maximumAmount = groupedTieredPackagePrice.maximumAmount + metadata = groupedTieredPackagePrice.metadata + minimum = groupedTieredPackagePrice.minimum + minimumAmount = groupedTieredPackagePrice.minimumAmount + modelType = groupedTieredPackagePrice.modelType + name = groupedTieredPackagePrice.name + planPhaseOrder = groupedTieredPackagePrice.planPhaseOrder + priceType = groupedTieredPackagePrice.priceType + dimensionalPriceConfiguration = + groupedTieredPackagePrice.dimensionalPriceConfiguration + additionalProperties = groupedTieredPackagePrice.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun billableMetric(billableMetric: BillableMetricTinyModel?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) + + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } + + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditAllocation(creditAllocation: AllocationModel?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) + + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) + + fun discount(discount: JsonField) = apply { this.discount = discount } + + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) + + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) + + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) + + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + fun groupedTieredPackageConfig( + groupedTieredPackageConfig: CustomRatingFunctionConfigModel + ) = groupedTieredPackageConfig(JsonField.of(groupedTieredPackageConfig)) + + fun groupedTieredPackageConfig( + groupedTieredPackageConfig: JsonField + ) = apply { this.groupedTieredPackageConfig = groupedTieredPackageConfig } + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + fun item(item: ItemSlimModel) = item(JsonField.of(item)) + + fun item(item: JsonField) = apply { this.item = item } + + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) + + 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)) + + /** + * 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: JsonField) = apply { this.metadata = metadata } + + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + fun name(name: String) = name(JsonField.of(name)) + + fun name(name: JsonField) = apply { this.name = name } + + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) + + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): GroupedTieredPackagePrice = + GroupedTieredPackagePrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("groupedTieredPackageConfig", groupedTieredPackageConfig), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) + } + + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * 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`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val GROUPED_TIERED_PACKAGE = of("grouped_tiered_package") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + GROUPED_TIERED_PACKAGE + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GROUPED_TIERED_PACKAGE, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GROUPED_TIERED_PACKAGE -> Value.GROUPED_TIERED_PACKAGE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + GROUPED_TIERED_PACKAGE -> Known.GROUPED_TIERED_PACKAGE + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is GroupedTieredPackagePrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && groupedTieredPackageConfig == other.groupedTieredPackageConfig && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, groupedTieredPackageConfig, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GroupedTieredPackagePrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, groupedTieredPackageConfig=$groupedTieredPackageConfig, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class MaxGroupTieredPackagePrice + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + private val billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + private val creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("max_group_tiered_package_config") + @ExcludeMissing + private val maxGroupTieredPackageConfig: JsonField = + JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + private val dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + fun billableMetric(): Optional = + Optional.ofNullable(billableMetric.getNullable("billable_metric")) + + fun billingCycleConfiguration(): BillingCycleConfigurationModel = + billingCycleConfiguration.getRequired("billing_cycle_configuration") + + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + fun creditAllocation(): Optional = + Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) + + fun currency(): String = currency.getRequired("currency") + + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) + + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + fun item(): ItemSlimModel = item.getRequired("item") + + fun maxGroupTieredPackageConfig(): CustomRatingFunctionConfigModel = + maxGroupTieredPackageConfig.getRequired("max_group_tiered_package_config") + + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + fun modelType(): ModelType = modelType.getRequired("model_type") + + fun name(): String = name.getRequired("name") + + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + fun priceType(): PriceType = priceType.getRequired("price_type") + + fun dimensionalPriceConfiguration(): Optional = + Optional.ofNullable( + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + ) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric + + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation + + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount + + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + @JsonProperty("max_group_tiered_package_config") + @ExcludeMissing + fun _maxGroupTieredPackageConfig(): JsonField = + maxGroupTieredPackageConfig + + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType + + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): MaxGroupTieredPackagePrice = apply { + if (validated) { + return@apply + } + + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + cadence() + conversionRate() + createdAt() + creditAllocation().ifPresent { it.validate() } + currency() + discount().ifPresent { it.validate() } + externalPriceId() + fixedPriceQuantity() + invoicingCycleConfiguration().ifPresent { it.validate() } + item().validate() + maxGroupTieredPackageConfig().validate() + maximum().ifPresent { it.validate() } + maximumAmount() + metadata().validate() + minimum().ifPresent { it.validate() } + minimumAmount() + modelType() + name() + planPhaseOrder() + priceType() + dimensionalPriceConfiguration().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [MaxGroupTieredPackagePrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maxGroupTieredPackageConfig() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MaxGroupTieredPackagePrice]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var 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 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: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(maxGroupTieredPackagePrice: MaxGroupTieredPackagePrice) = apply { + id = maxGroupTieredPackagePrice.id + billableMetric = maxGroupTieredPackagePrice.billableMetric + billingCycleConfiguration = maxGroupTieredPackagePrice.billingCycleConfiguration + cadence = maxGroupTieredPackagePrice.cadence + conversionRate = maxGroupTieredPackagePrice.conversionRate + createdAt = maxGroupTieredPackagePrice.createdAt + creditAllocation = maxGroupTieredPackagePrice.creditAllocation + currency = maxGroupTieredPackagePrice.currency + discount = maxGroupTieredPackagePrice.discount + externalPriceId = maxGroupTieredPackagePrice.externalPriceId + fixedPriceQuantity = maxGroupTieredPackagePrice.fixedPriceQuantity + invoicingCycleConfiguration = maxGroupTieredPackagePrice.invoicingCycleConfiguration + item = maxGroupTieredPackagePrice.item + maxGroupTieredPackageConfig = maxGroupTieredPackagePrice.maxGroupTieredPackageConfig + maximum = maxGroupTieredPackagePrice.maximum + maximumAmount = maxGroupTieredPackagePrice.maximumAmount + metadata = maxGroupTieredPackagePrice.metadata + minimum = maxGroupTieredPackagePrice.minimum + minimumAmount = maxGroupTieredPackagePrice.minimumAmount + modelType = maxGroupTieredPackagePrice.modelType + name = maxGroupTieredPackagePrice.name + planPhaseOrder = maxGroupTieredPackagePrice.planPhaseOrder + priceType = maxGroupTieredPackagePrice.priceType + dimensionalPriceConfiguration = + maxGroupTieredPackagePrice.dimensionalPriceConfiguration + additionalProperties = + maxGroupTieredPackagePrice.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun billableMetric(billableMetric: BillableMetricTinyModel?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) + + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } + + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditAllocation(creditAllocation: AllocationModel?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) + + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) + + fun discount(discount: JsonField) = apply { this.discount = discount } + + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) + + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) + + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) + + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + fun item(item: ItemSlimModel) = item(JsonField.of(item)) + + fun item(item: JsonField) = apply { this.item = item } + + fun maxGroupTieredPackageConfig( + maxGroupTieredPackageConfig: CustomRatingFunctionConfigModel + ) = maxGroupTieredPackageConfig(JsonField.of(maxGroupTieredPackageConfig)) + + fun maxGroupTieredPackageConfig( + maxGroupTieredPackageConfig: JsonField + ) = apply { this.maxGroupTieredPackageConfig = maxGroupTieredPackageConfig } + + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) + + 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)) + + /** + * 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: JsonField) = apply { this.metadata = metadata } + + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + fun name(name: String) = name(JsonField.of(name)) + + fun name(name: JsonField) = apply { this.name = name } + + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) + + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): MaxGroupTieredPackagePrice = + MaxGroupTieredPackagePrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + 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("maxGroupTieredPackageConfig", maxGroupTieredPackageConfig), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) + } + + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * 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`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val MAX_GROUP_TIERED_PACKAGE = of("max_group_tiered_package") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + MAX_GROUP_TIERED_PACKAGE + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MAX_GROUP_TIERED_PACKAGE, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MAX_GROUP_TIERED_PACKAGE -> Value.MAX_GROUP_TIERED_PACKAGE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MAX_GROUP_TIERED_PACKAGE -> Known.MAX_GROUP_TIERED_PACKAGE + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MaxGroupTieredPackagePrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maxGroupTieredPackageConfig == other.maxGroupTieredPackageConfig && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maxGroupTieredPackageConfig, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MaxGroupTieredPackagePrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class ScalableMatrixWithUnitPricingPrice + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + private val billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + private val creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("scalable_matrix_with_unit_pricing_config") + @ExcludeMissing + private val scalableMatrixWithUnitPricingConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + private val dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + fun billableMetric(): Optional = + Optional.ofNullable(billableMetric.getNullable("billable_metric")) + + fun billingCycleConfiguration(): BillingCycleConfigurationModel = + billingCycleConfiguration.getRequired("billing_cycle_configuration") + + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + fun creditAllocation(): Optional = + Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) + + fun currency(): String = currency.getRequired("currency") + + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) + + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + fun item(): ItemSlimModel = item.getRequired("item") + + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + fun modelType(): ModelType = modelType.getRequired("model_type") + + fun name(): String = name.getRequired("name") + + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + fun priceType(): PriceType = priceType.getRequired("price_type") + + fun scalableMatrixWithUnitPricingConfig(): CustomRatingFunctionConfigModel = + scalableMatrixWithUnitPricingConfig.getRequired( + "scalable_matrix_with_unit_pricing_config" + ) + + fun dimensionalPriceConfiguration(): Optional = + Optional.ofNullable( + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + ) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric + + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation + + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount + + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType + + @JsonProperty("scalable_matrix_with_unit_pricing_config") + @ExcludeMissing + fun _scalableMatrixWithUnitPricingConfig(): JsonField = + scalableMatrixWithUnitPricingConfig + + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithUnitPricingPrice = apply { + if (validated) { + return@apply + } + + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + cadence() + conversionRate() + 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() + name() + planPhaseOrder() + priceType() + scalableMatrixWithUnitPricingConfig().validate() + dimensionalPriceConfiguration().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ScalableMatrixWithUnitPricingPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * .scalableMatrixWithUnitPricingConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithUnitPricingPrice]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var 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: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var scalableMatrixWithUnitPricingConfig: + JsonField? = + null + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + scalableMatrixWithUnitPricingPrice: ScalableMatrixWithUnitPricingPrice + ) = apply { + id = scalableMatrixWithUnitPricingPrice.id + billableMetric = scalableMatrixWithUnitPricingPrice.billableMetric + billingCycleConfiguration = + scalableMatrixWithUnitPricingPrice.billingCycleConfiguration + cadence = scalableMatrixWithUnitPricingPrice.cadence + conversionRate = scalableMatrixWithUnitPricingPrice.conversionRate + createdAt = scalableMatrixWithUnitPricingPrice.createdAt + creditAllocation = scalableMatrixWithUnitPricingPrice.creditAllocation + currency = scalableMatrixWithUnitPricingPrice.currency + discount = scalableMatrixWithUnitPricingPrice.discount + externalPriceId = scalableMatrixWithUnitPricingPrice.externalPriceId + fixedPriceQuantity = scalableMatrixWithUnitPricingPrice.fixedPriceQuantity + invoicingCycleConfiguration = + scalableMatrixWithUnitPricingPrice.invoicingCycleConfiguration + item = scalableMatrixWithUnitPricingPrice.item + maximum = scalableMatrixWithUnitPricingPrice.maximum + maximumAmount = scalableMatrixWithUnitPricingPrice.maximumAmount + metadata = scalableMatrixWithUnitPricingPrice.metadata + minimum = scalableMatrixWithUnitPricingPrice.minimum + minimumAmount = scalableMatrixWithUnitPricingPrice.minimumAmount + modelType = scalableMatrixWithUnitPricingPrice.modelType + name = scalableMatrixWithUnitPricingPrice.name + planPhaseOrder = scalableMatrixWithUnitPricingPrice.planPhaseOrder + priceType = scalableMatrixWithUnitPricingPrice.priceType + scalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricingPrice.scalableMatrixWithUnitPricingConfig + dimensionalPriceConfiguration = + scalableMatrixWithUnitPricingPrice.dimensionalPriceConfiguration + additionalProperties = + scalableMatrixWithUnitPricingPrice.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun billableMetric(billableMetric: BillableMetricTinyModel?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) + + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } + + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditAllocation(creditAllocation: AllocationModel?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) + + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) + + fun discount(discount: JsonField) = apply { this.discount = discount } + + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) + + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) + + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) + + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + fun item(item: ItemSlimModel) = item(JsonField.of(item)) + + fun item(item: JsonField) = apply { this.item = item } + + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) + + 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)) + + /** + * 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: JsonField) = apply { this.metadata = metadata } + + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + fun name(name: String) = name(JsonField.of(name)) + + fun name(name: JsonField) = apply { this.name = name } + + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) + + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + + fun scalableMatrixWithUnitPricingConfig( + scalableMatrixWithUnitPricingConfig: CustomRatingFunctionConfigModel + ) = + scalableMatrixWithUnitPricingConfig( + JsonField.of(scalableMatrixWithUnitPricingConfig) + ) + + fun scalableMatrixWithUnitPricingConfig( + scalableMatrixWithUnitPricingConfig: JsonField + ) = apply { + this.scalableMatrixWithUnitPricingConfig = scalableMatrixWithUnitPricingConfig + } + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): ScalableMatrixWithUnitPricingPrice = + ScalableMatrixWithUnitPricingPrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + checkRequired( + "scalableMatrixWithUnitPricingConfig", + scalableMatrixWithUnitPricingConfig, + ), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) + } + + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * 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`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField + val SCALABLE_MATRIX_WITH_UNIT_PRICING = of("scalable_matrix_with_unit_pricing") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + SCALABLE_MATRIX_WITH_UNIT_PRICING + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SCALABLE_MATRIX_WITH_UNIT_PRICING, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SCALABLE_MATRIX_WITH_UNIT_PRICING -> Value.SCALABLE_MATRIX_WITH_UNIT_PRICING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SCALABLE_MATRIX_WITH_UNIT_PRICING -> Known.SCALABLE_MATRIX_WITH_UNIT_PRICING + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ScalableMatrixWithUnitPricingPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && scalableMatrixWithUnitPricingConfig == other.scalableMatrixWithUnitPricingConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithUnitPricingPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class ScalableMatrixWithTieredPricingPrice + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + private val billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + private val creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("scalable_matrix_with_tiered_pricing_config") + @ExcludeMissing + private val scalableMatrixWithTieredPricingConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + private val dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + fun billableMetric(): Optional = + Optional.ofNullable(billableMetric.getNullable("billable_metric")) + + fun billingCycleConfiguration(): BillingCycleConfigurationModel = + billingCycleConfiguration.getRequired("billing_cycle_configuration") + + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + fun creditAllocation(): Optional = + Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) + + fun currency(): String = currency.getRequired("currency") + + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) + + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + fun item(): ItemSlimModel = item.getRequired("item") + + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + fun modelType(): ModelType = modelType.getRequired("model_type") + + fun name(): String = name.getRequired("name") + + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + fun priceType(): PriceType = priceType.getRequired("price_type") + + fun scalableMatrixWithTieredPricingConfig(): CustomRatingFunctionConfigModel = + scalableMatrixWithTieredPricingConfig.getRequired( + "scalable_matrix_with_tiered_pricing_config" + ) + + fun dimensionalPriceConfiguration(): Optional = + Optional.ofNullable( + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + ) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric + + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation + + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount + + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType + + @JsonProperty("scalable_matrix_with_tiered_pricing_config") + @ExcludeMissing + fun _scalableMatrixWithTieredPricingConfig(): JsonField = + scalableMatrixWithTieredPricingConfig + + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): ScalableMatrixWithTieredPricingPrice = apply { + if (validated) { + return@apply + } + + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + cadence() + conversionRate() + 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() + name() + planPhaseOrder() + priceType() + scalableMatrixWithTieredPricingConfig().validate() + dimensionalPriceConfiguration().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ScalableMatrixWithTieredPricingPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * .scalableMatrixWithTieredPricingConfig() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ScalableMatrixWithTieredPricingPrice]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var 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: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var scalableMatrixWithTieredPricingConfig: + JsonField? = + null + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + scalableMatrixWithTieredPricingPrice: ScalableMatrixWithTieredPricingPrice + ) = apply { + id = scalableMatrixWithTieredPricingPrice.id + billableMetric = scalableMatrixWithTieredPricingPrice.billableMetric + billingCycleConfiguration = + scalableMatrixWithTieredPricingPrice.billingCycleConfiguration + cadence = scalableMatrixWithTieredPricingPrice.cadence + conversionRate = scalableMatrixWithTieredPricingPrice.conversionRate + createdAt = scalableMatrixWithTieredPricingPrice.createdAt + creditAllocation = scalableMatrixWithTieredPricingPrice.creditAllocation + currency = scalableMatrixWithTieredPricingPrice.currency + discount = scalableMatrixWithTieredPricingPrice.discount + externalPriceId = scalableMatrixWithTieredPricingPrice.externalPriceId + fixedPriceQuantity = scalableMatrixWithTieredPricingPrice.fixedPriceQuantity + invoicingCycleConfiguration = + scalableMatrixWithTieredPricingPrice.invoicingCycleConfiguration + item = scalableMatrixWithTieredPricingPrice.item + maximum = scalableMatrixWithTieredPricingPrice.maximum + maximumAmount = scalableMatrixWithTieredPricingPrice.maximumAmount + metadata = scalableMatrixWithTieredPricingPrice.metadata + minimum = scalableMatrixWithTieredPricingPrice.minimum + minimumAmount = scalableMatrixWithTieredPricingPrice.minimumAmount + modelType = scalableMatrixWithTieredPricingPrice.modelType + name = scalableMatrixWithTieredPricingPrice.name + planPhaseOrder = scalableMatrixWithTieredPricingPrice.planPhaseOrder + priceType = scalableMatrixWithTieredPricingPrice.priceType + scalableMatrixWithTieredPricingConfig = + scalableMatrixWithTieredPricingPrice.scalableMatrixWithTieredPricingConfig + dimensionalPriceConfiguration = + scalableMatrixWithTieredPricingPrice.dimensionalPriceConfiguration + additionalProperties = + scalableMatrixWithTieredPricingPrice.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun billableMetric(billableMetric: BillableMetricTinyModel?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) + + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } + + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditAllocation(creditAllocation: AllocationModel?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) + + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) + + fun discount(discount: JsonField) = apply { this.discount = discount } + + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) + + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) + + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) + + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + fun item(item: ItemSlimModel) = item(JsonField.of(item)) + + fun item(item: JsonField) = apply { this.item = item } + + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) + + 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)) + + /** + * 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: JsonField) = apply { this.metadata = metadata } + + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + fun name(name: String) = name(JsonField.of(name)) + + fun name(name: JsonField) = apply { this.name = name } + + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) + + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + + fun scalableMatrixWithTieredPricingConfig( + scalableMatrixWithTieredPricingConfig: CustomRatingFunctionConfigModel + ) = + scalableMatrixWithTieredPricingConfig( + JsonField.of(scalableMatrixWithTieredPricingConfig) + ) + + fun scalableMatrixWithTieredPricingConfig( + scalableMatrixWithTieredPricingConfig: JsonField + ) = apply { + this.scalableMatrixWithTieredPricingConfig = scalableMatrixWithTieredPricingConfig + } + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): ScalableMatrixWithTieredPricingPrice = + ScalableMatrixWithTieredPricingPrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + checkRequired( + "scalableMatrixWithTieredPricingConfig", + scalableMatrixWithTieredPricingConfig, + ), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) + } + + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * 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`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField + val SCALABLE_MATRIX_WITH_TIERED_PRICING = of("scalable_matrix_with_tiered_pricing") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + SCALABLE_MATRIX_WITH_TIERED_PRICING + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SCALABLE_MATRIX_WITH_TIERED_PRICING, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SCALABLE_MATRIX_WITH_TIERED_PRICING -> Value.SCALABLE_MATRIX_WITH_TIERED_PRICING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SCALABLE_MATRIX_WITH_TIERED_PRICING -> Known.SCALABLE_MATRIX_WITH_TIERED_PRICING + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ScalableMatrixWithTieredPricingPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && scalableMatrixWithTieredPricingConfig == other.scalableMatrixWithTieredPricingConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ScalableMatrixWithTieredPricingPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class CumulativeGroupedBulkPrice + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric") + @ExcludeMissing + private val billableMetric: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_allocation") + @ExcludeMissing + private val creditAllocation: JsonField = JsonMissing.of(), + @JsonProperty("cumulative_grouped_bulk_config") + @ExcludeMissing + private val cumulativeGroupedBulkConfig: JsonField = + JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("item") + @ExcludeMissing + private val item: JsonField = JsonMissing.of(), + @JsonProperty("maximum") + @ExcludeMissing + private val maximum: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum") + @ExcludeMissing + private val minimum: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price_type") + @ExcludeMissing + private val priceType: JsonField = JsonMissing.of(), + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + private val dimensionalPriceConfiguration: JsonField = + JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun id(): String = id.getRequired("id") + + fun billableMetric(): Optional = + Optional.ofNullable(billableMetric.getNullable("billable_metric")) + + fun billingCycleConfiguration(): BillingCycleConfigurationModel = + billingCycleConfiguration.getRequired("billing_cycle_configuration") + + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + fun creditAllocation(): Optional = + Optional.ofNullable(creditAllocation.getNullable("credit_allocation")) + + fun cumulativeGroupedBulkConfig(): CustomRatingFunctionConfigModel = + cumulativeGroupedBulkConfig.getRequired("cumulative_grouped_bulk_config") + + fun currency(): String = currency.getRequired("currency") + + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) + + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + fun item(): ItemSlimModel = item.getRequired("item") + + fun maximum(): Optional = Optional.ofNullable(maximum.getNullable("maximum")) + + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** + * User specified key-value pairs for the resource. If not present, this defaults to an + * empty dictionary. Individual keys can be removed by setting the value to `null`, and the + * entire metadata mapping can be cleared by setting `metadata` to `null`. + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + fun minimum(): Optional = Optional.ofNullable(minimum.getNullable("minimum")) + + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + fun modelType(): ModelType = modelType.getRequired("model_type") + + fun name(): String = name.getRequired("name") + + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + fun priceType(): PriceType = priceType.getRequired("price_type") + + fun dimensionalPriceConfiguration(): Optional = + Optional.ofNullable( + dimensionalPriceConfiguration.getNullable("dimensional_price_configuration") + ) + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric + + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + @JsonProperty("credit_allocation") + @ExcludeMissing + fun _creditAllocation(): JsonField = creditAllocation + + @JsonProperty("cumulative_grouped_bulk_config") + @ExcludeMissing + fun _cumulativeGroupedBulkConfig(): JsonField = + cumulativeGroupedBulkConfig + + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount + + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item + + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum + + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = 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`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum + + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder + + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType + + @JsonProperty("dimensional_price_configuration") + @ExcludeMissing + fun _dimensionalPriceConfiguration(): JsonField = + dimensionalPriceConfiguration + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): CumulativeGroupedBulkPrice = apply { + if (validated) { + return@apply + } + + id() + billableMetric().ifPresent { it.validate() } + billingCycleConfiguration().validate() + cadence() + conversionRate() + createdAt() + creditAllocation().ifPresent { it.validate() } + cumulativeGroupedBulkConfig().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() + name() + planPhaseOrder() + priceType() + dimensionalPriceConfiguration().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CumulativeGroupedBulkPrice]. + * + * The following fields are required: + * ```java + * .id() + * .billableMetric() + * .billingCycleConfiguration() + * .cadence() + * .conversionRate() + * .createdAt() + * .creditAllocation() + * .cumulativeGroupedBulkConfig() + * .currency() + * .discount() + * .externalPriceId() + * .fixedPriceQuantity() + * .invoicingCycleConfiguration() + * .item() + * .maximum() + * .maximumAmount() + * .metadata() + * .minimum() + * .minimumAmount() + * .modelType() + * .name() + * .planPhaseOrder() + * .priceType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CumulativeGroupedBulkPrice]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var createdAt: JsonField? = null + private var creditAllocation: JsonField? = null + private var cumulativeGroupedBulkConfig: JsonField? = + null + private var currency: JsonField? = null + private var discount: JsonField? = null + private var externalPriceId: JsonField? = null + private var fixedPriceQuantity: JsonField? = null + private var invoicingCycleConfiguration: JsonField? = + null + private var item: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var dimensionalPriceConfiguration: + JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cumulativeGroupedBulkPrice: CumulativeGroupedBulkPrice) = apply { + id = cumulativeGroupedBulkPrice.id + billableMetric = cumulativeGroupedBulkPrice.billableMetric + billingCycleConfiguration = cumulativeGroupedBulkPrice.billingCycleConfiguration + cadence = cumulativeGroupedBulkPrice.cadence + conversionRate = cumulativeGroupedBulkPrice.conversionRate + createdAt = cumulativeGroupedBulkPrice.createdAt + creditAllocation = cumulativeGroupedBulkPrice.creditAllocation + cumulativeGroupedBulkConfig = cumulativeGroupedBulkPrice.cumulativeGroupedBulkConfig + currency = cumulativeGroupedBulkPrice.currency + discount = cumulativeGroupedBulkPrice.discount + externalPriceId = cumulativeGroupedBulkPrice.externalPriceId + fixedPriceQuantity = cumulativeGroupedBulkPrice.fixedPriceQuantity + invoicingCycleConfiguration = cumulativeGroupedBulkPrice.invoicingCycleConfiguration + item = cumulativeGroupedBulkPrice.item + maximum = cumulativeGroupedBulkPrice.maximum + maximumAmount = cumulativeGroupedBulkPrice.maximumAmount + metadata = cumulativeGroupedBulkPrice.metadata + minimum = cumulativeGroupedBulkPrice.minimum + minimumAmount = cumulativeGroupedBulkPrice.minimumAmount + modelType = cumulativeGroupedBulkPrice.modelType + name = cumulativeGroupedBulkPrice.name + planPhaseOrder = cumulativeGroupedBulkPrice.planPhaseOrder + priceType = cumulativeGroupedBulkPrice.priceType + dimensionalPriceConfiguration = + cumulativeGroupedBulkPrice.dimensionalPriceConfiguration + additionalProperties = + cumulativeGroupedBulkPrice.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + fun billableMetric(billableMetric: BillableMetricTinyModel?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) + + fun billableMetric(billableMetric: JsonField) = apply { + this.billableMetric = billableMetric + } + + fun billingCycleConfiguration( + billingCycleConfiguration: BillingCycleConfigurationModel + ) = billingCycleConfiguration(JsonField.of(billingCycleConfiguration)) + + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + fun creditAllocation(creditAllocation: AllocationModel?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) + + fun creditAllocation(creditAllocation: JsonField) = apply { + this.creditAllocation = creditAllocation + } + + fun cumulativeGroupedBulkConfig( + cumulativeGroupedBulkConfig: CustomRatingFunctionConfigModel + ) = cumulativeGroupedBulkConfig(JsonField.of(cumulativeGroupedBulkConfig)) + + fun cumulativeGroupedBulkConfig( + cumulativeGroupedBulkConfig: JsonField + ) = apply { this.cumulativeGroupedBulkConfig = cumulativeGroupedBulkConfig } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) + + fun discount(discount: JsonField) = apply { this.discount = discount } + + fun discount(percentage: PercentageDiscount) = + discount(Discount.ofPercentage(percentage)) + + fun discount(trial: TrialDiscount) = discount(Discount.ofTrial(trial)) + + fun trialDiscount(appliesToPriceIds: List) = + discount( + TrialDiscount.builder() + .discountType(TrialDiscount.DiscountType.TRIAL) + .appliesToPriceIds(appliesToPriceIds) + .build() + ) + + fun discount(usage: Discount.UsageDiscount) = discount(Discount.ofUsage(usage)) + + fun discount(amount: AmountDiscount) = discount(Discount.ofAmount(amount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: BillingCycleConfigurationModel? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + + fun item(item: ItemSlimModel) = item(JsonField.of(item)) + + fun item(item: JsonField) = apply { this.item = item } + + fun maximum(maximum: MaximumModel?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) + + 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)) + + /** + * 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: JsonField) = apply { this.metadata = metadata } + + fun minimum(minimum: MinimumModel?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + fun name(name: String) = name(JsonField.of(name)) + + fun name(name: JsonField) = apply { this.name = name } + + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) + + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + + fun priceType(priceType: PriceType) = priceType(JsonField.of(priceType)) + + fun priceType(priceType: JsonField) = apply { this.priceType = priceType } + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: DimensionalPriceConfigurationModel? + ) = dimensionalPriceConfiguration(JsonField.ofNullable(dimensionalPriceConfiguration)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: Optional + ) = dimensionalPriceConfiguration(dimensionalPriceConfiguration.orElse(null)) + + fun dimensionalPriceConfiguration( + dimensionalPriceConfiguration: JsonField + ) = apply { this.dimensionalPriceConfiguration = dimensionalPriceConfiguration } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): CumulativeGroupedBulkPrice = + CumulativeGroupedBulkPrice( + checkRequired("id", id), + checkRequired("billableMetric", billableMetric), + checkRequired("billingCycleConfiguration", billingCycleConfiguration), + checkRequired("cadence", cadence), + checkRequired("conversionRate", conversionRate), + checkRequired("createdAt", createdAt), + checkRequired("creditAllocation", creditAllocation), + checkRequired("cumulativeGroupedBulkConfig", cumulativeGroupedBulkConfig), + checkRequired("currency", currency), + checkRequired("discount", discount), + checkRequired("externalPriceId", externalPriceId), + checkRequired("fixedPriceQuantity", fixedPriceQuantity), + checkRequired("invoicingCycleConfiguration", invoicingCycleConfiguration), + checkRequired("item", item), + checkRequired("maximum", maximum), + checkRequired("maximumAmount", maximumAmount), + checkRequired("metadata", metadata), + checkRequired("minimum", minimum), + checkRequired("minimumAmount", minimumAmount), + checkRequired("modelType", modelType), + checkRequired("name", name), + checkRequired("planPhaseOrder", planPhaseOrder), + checkRequired("priceType", priceType), + dimensionalPriceConfiguration, + additionalProperties.toImmutable(), + ) + } + + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * 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`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class ModelType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CUMULATIVE_GROUPED_BULK = of("cumulative_grouped_bulk") + + @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + } + + /** An enum containing [ModelType]'s known values. */ + enum class Known { + CUMULATIVE_GROUPED_BULK + } + + /** + * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CUMULATIVE_GROUPED_BULK, + /** + * An enum member indicating that [ModelType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CUMULATIVE_GROUPED_BULK -> Value.CUMULATIVE_GROUPED_BULK + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CUMULATIVE_GROUPED_BULK -> Known.CUMULATIVE_GROUPED_BULK + else -> throw OrbInvalidDataException("Unknown ModelType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class PriceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") + + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) + } + + /** An enum containing [PriceType]'s known values. */ + enum class Known { + USAGE_PRICE, + FIXED_PRICE, + } + + /** + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PriceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE_PRICE, + FIXED_PRICE, + /** + * An enum member indicating that [PriceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PriceType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CumulativeGroupedBulkPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && createdAt == other.createdAt && creditAllocation == other.creditAllocation && cumulativeGroupedBulkConfig == other.cumulativeGroupedBulkConfig && currency == other.currency && discount == other.discount && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoicingCycleConfiguration == other.invoicingCycleConfiguration && item == other.item && maximum == other.maximum && maximumAmount == other.maximumAmount && metadata == other.metadata && minimum == other.minimum && minimumAmount == other.minimumAmount && modelType == other.modelType && name == other.name && planPhaseOrder == other.planPhaseOrder && priceType == other.priceType && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, billableMetric, billingCycleConfiguration, cadence, conversionRate, createdAt, creditAllocation, cumulativeGroupedBulkConfig, currency, discount, externalPriceId, fixedPriceQuantity, invoicingCycleConfiguration, item, maximum, maximumAmount, metadata, minimum, minimumAmount, modelType, name, planPhaseOrder, priceType, dimensionalPriceConfiguration, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CumulativeGroupedBulkPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, createdAt=$createdAt, creditAllocation=$creditAllocation, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, currency=$currency, discount=$discount, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoicingCycleConfiguration=$invoicingCycleConfiguration, item=$item, maximum=$maximum, maximumAmount=$maximumAmount, metadata=$metadata, minimum=$minimum, minimumAmount=$minimumAmount, modelType=$modelType, name=$name, planPhaseOrder=$planPhaseOrder, priceType=$priceType, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + } +} 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 1a34b10cd..d8f07c3c6 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 @@ -2,23 +2,13 @@ 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.NoAutoDetect 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.immutableEmptyMap -import com.withorb.api.core.toImmutable import java.util.Objects -import java.util.Optional /** * This endpoint allows you to update the `metadata` property on a price. If you pass null for the @@ -27,34 +17,23 @@ import java.util.Optional class PriceUpdateParams private constructor( private val priceId: String, - private val body: Body, + private val updatePriceRequestParams: UpdatePriceRequestParams, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { fun priceId(): String = priceId - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - */ - fun metadata(): Optional = body.metadata() + fun updatePriceRequestParams(): UpdatePriceRequestParams = updatePriceRequestParams - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - */ - fun _metadata(): JsonField = body._metadata() - - fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalBodyProperties(): Map = + updatePriceRequestParams._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun _body(): Body = body + @JvmSynthetic internal fun _body(): UpdatePriceRequestParams = updatePriceRequestParams override fun _headers(): Headers = additionalHeaders @@ -67,130 +46,19 @@ private constructor( } } - @NoAutoDetect - class Body - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by setting - * `metadata` to `null`. - */ - fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * User-specified key/value pairs for the resource. 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - metadata = body.metadata - additionalProperties = body.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`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): Body = Body(metadata, additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Body && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{metadata=$metadata, additionalProperties=$additionalProperties}" - } - fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of [PriceUpdateParams]. + * + * The following fields are required: + * ```java + * .priceId() + * .updatePriceRequestParams() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -199,58 +67,22 @@ private constructor( class Builder internal constructor() { private var priceId: String? = null - private var body: Body.Builder = Body.builder() + private var updatePriceRequestParams: UpdatePriceRequestParams? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(priceUpdateParams: PriceUpdateParams) = apply { priceId = priceUpdateParams.priceId - body = priceUpdateParams.body.toBuilder() + updatePriceRequestParams = priceUpdateParams.updatePriceRequestParams additionalHeaders = priceUpdateParams.additionalHeaders.toBuilder() additionalQueryParams = priceUpdateParams.additionalQueryParams.toBuilder() } fun priceId(priceId: String) = apply { this.priceId = priceId } - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by setting - * `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = apply { body.metadata(metadata) } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by - * setting the value to `null`, and the entire metadata mapping can be cleared by setting - * `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: JsonField) = apply { body.metadata(metadata) } - - 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 updatePriceRequestParams(updatePriceRequestParams: UpdatePriceRequestParams) = apply { + this.updatePriceRequestParams = updatePriceRequestParams } fun additionalHeaders(additionalHeaders: Headers) = apply { @@ -354,105 +186,22 @@ private constructor( fun build(): PriceUpdateParams = PriceUpdateParams( checkRequired("priceId", priceId), - body.build(), + checkRequired("updatePriceRequestParams", updatePriceRequestParams), additionalHeaders.build(), additionalQueryParams.build(), ) } - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PriceUpdateParams && priceId == other.priceId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is PriceUpdateParams && priceId == other.priceId && updatePriceRequestParams == other.updatePriceRequestParams && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(priceId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(priceId, updatePriceRequestParams, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "PriceUpdateParams{priceId=$priceId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "PriceUpdateParams{priceId=$priceId, updatePriceRequestParams=$updatePriceRequestParams, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/RemoveSubscriptionAdjustmentParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/RemoveSubscriptionAdjustmentParams.kt new file mode 100644 index 000000000..170c31d52 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/RemoveSubscriptionAdjustmentParams.kt @@ -0,0 +1,132 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects + +@NoAutoDetect +class RemoveSubscriptionAdjustmentParams +@JsonCreator +private constructor( + @JsonProperty("adjustment_id") + @ExcludeMissing + private val adjustmentId: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** The id of the adjustment to remove on the subscription. */ + fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + + /** The id of the adjustment to remove on the subscription. */ + @JsonProperty("adjustment_id") + @ExcludeMissing + fun _adjustmentId(): JsonField = adjustmentId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): RemoveSubscriptionAdjustmentParams = apply { + if (validated) { + return@apply + } + + adjustmentId() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [RemoveSubscriptionAdjustmentParams]. + * + * The following fields are required: + * ```java + * .adjustmentId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RemoveSubscriptionAdjustmentParams]. */ + class Builder internal constructor() { + + private var adjustmentId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(removeSubscriptionAdjustmentParams: RemoveSubscriptionAdjustmentParams) = + apply { + adjustmentId = removeSubscriptionAdjustmentParams.adjustmentId + additionalProperties = + removeSubscriptionAdjustmentParams.additionalProperties.toMutableMap() + } + + /** The id of the adjustment to remove on the subscription. */ + fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + + /** The id of the adjustment to remove on the subscription. */ + 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) + } + + fun build(): RemoveSubscriptionAdjustmentParams = + RemoveSubscriptionAdjustmentParams( + checkRequired("adjustmentId", adjustmentId), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RemoveSubscriptionAdjustmentParams && adjustmentId == other.adjustmentId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(adjustmentId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemoveSubscriptionAdjustmentParams{adjustmentId=$adjustmentId, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/RemoveSubscriptionPriceParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/RemoveSubscriptionPriceParams.kt new file mode 100644 index 000000000..d89d9931f --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/RemoveSubscriptionPriceParams.kt @@ -0,0 +1,153 @@ +// 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.NoAutoDetect +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class RemoveSubscriptionPriceParams +@JsonCreator +private constructor( + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("price_id") + @ExcludeMissing + private val priceId: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** The external price id of the price to remove on the subscription. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** The id of the price to remove on the subscription. */ + fun priceId(): Optional = Optional.ofNullable(priceId.getNullable("price_id")) + + /** The external price id of the price to remove on the subscription. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** The id of the price to remove on the subscription. */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): RemoveSubscriptionPriceParams = apply { + if (validated) { + return@apply + } + + externalPriceId() + priceId() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [RemoveSubscriptionPriceParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RemoveSubscriptionPriceParams]. */ + 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(removeSubscriptionPriceParams: RemoveSubscriptionPriceParams) = apply { + externalPriceId = removeSubscriptionPriceParams.externalPriceId + priceId = removeSubscriptionPriceParams.priceId + additionalProperties = removeSubscriptionPriceParams.additionalProperties.toMutableMap() + } + + /** The external price id of the price to remove on the subscription. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + /** The external price id of the price to remove on the subscription. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** The external price id of the price to remove on the subscription. */ + 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)) + + /** The id of the price to remove on the subscription. */ + fun priceId(priceId: Optional) = priceId(priceId.orElse(null)) + + /** The id of the price to remove on the subscription. */ + 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) + } + + fun build(): RemoveSubscriptionPriceParams = + RemoveSubscriptionPriceParams( + externalPriceId, + priceId, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RemoveSubscriptionPriceParams && externalPriceId == other.externalPriceId && priceId == other.priceId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(externalPriceId, priceId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RemoveSubscriptionPriceParams{externalPriceId=$externalPriceId, priceId=$priceId, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/ReplaceSubscriptionAdjustmentParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ReplaceSubscriptionAdjustmentParams.kt new file mode 100644 index 000000000..eec488be8 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ReplaceSubscriptionAdjustmentParams.kt @@ -0,0 +1,178 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects + +@NoAutoDetect +class ReplaceSubscriptionAdjustmentParams +@JsonCreator +private constructor( + @JsonProperty("adjustment") + @ExcludeMissing + private val adjustment: JsonField = JsonMissing.of(), + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + private val replacesAdjustmentId: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(): NewAdjustmentModel = adjustment.getRequired("adjustment") + + /** The id of the adjustment on the plan to replace in the subscription. */ + fun replacesAdjustmentId(): String = replacesAdjustmentId.getRequired("replaces_adjustment_id") + + /** The definition of a new adjustment to create and add to the subscription. */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment + + /** The id of the adjustment on the plan to replace in the subscription. */ + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): ReplaceSubscriptionAdjustmentParams = apply { + if (validated) { + return@apply + } + + adjustment().validate() + replacesAdjustmentId() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ReplaceSubscriptionAdjustmentParams]. + * + * The following fields are required: + * ```java + * .adjustment() + * .replacesAdjustmentId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ReplaceSubscriptionAdjustmentParams]. */ + class Builder internal constructor() { + + private var adjustment: JsonField? = null + private var replacesAdjustmentId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + replaceSubscriptionAdjustmentParams: ReplaceSubscriptionAdjustmentParams + ) = apply { + adjustment = replaceSubscriptionAdjustmentParams.adjustment + replacesAdjustmentId = replaceSubscriptionAdjustmentParams.replacesAdjustmentId + additionalProperties = + replaceSubscriptionAdjustmentParams.additionalProperties.toMutableMap() + } + + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(adjustment: NewAdjustmentModel) = adjustment(JsonField.of(adjustment)) + + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } + + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(percentageDiscount: NewAdjustmentModel.NewPercentageDiscount) = + adjustment(NewAdjustmentModel.ofPercentageDiscount(percentageDiscount)) + + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(usageDiscount: NewAdjustmentModel.NewUsageDiscount) = + adjustment(NewAdjustmentModel.ofUsageDiscount(usageDiscount)) + + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(amountDiscount: NewAdjustmentModel.NewAmountDiscount) = + adjustment(NewAdjustmentModel.ofAmountDiscount(amountDiscount)) + + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(minimum: NewAdjustmentModel.NewMinimum) = + adjustment(NewAdjustmentModel.ofMinimum(minimum)) + + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(maximum: NewAdjustmentModel.NewMaximum) = + adjustment(NewAdjustmentModel.ofMaximum(maximum)) + + /** The id of the adjustment on the plan to replace in the subscription. */ + fun replacesAdjustmentId(replacesAdjustmentId: String) = + replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) + + /** The id of the adjustment on the plan to replace in the subscription. */ + 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) + } + + fun build(): ReplaceSubscriptionAdjustmentParams = + ReplaceSubscriptionAdjustmentParams( + checkRequired("adjustment", adjustment), + checkRequired("replacesAdjustmentId", replacesAdjustmentId), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ReplaceSubscriptionAdjustmentParams && adjustment == other.adjustment && replacesAdjustmentId == other.replacesAdjustmentId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReplaceSubscriptionAdjustmentParams{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/ReplaceSubscriptionPriceParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ReplaceSubscriptionPriceParams.kt new file mode 100644 index 000000000..20af3ad2a --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ReplaceSubscriptionPriceParams.kt @@ -0,0 +1,590 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class ReplaceSubscriptionPriceParams +@JsonCreator +private constructor( + @JsonProperty("replaces_price_id") + @ExcludeMissing + private val replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("allocation_price") + @ExcludeMissing + private val allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("discounts") + @ExcludeMissing + private val discounts: JsonField> = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("price") + @ExcludeMissing + private val price: JsonField = JsonMissing.of(), + @JsonProperty("price_id") + @ExcludeMissing + private val priceId: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** The id of the price on the plan to replace in the subscription. */ + fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + + /** The definition of a new allocation price to create and add to the subscription. */ + fun allocationPrice(): Optional = + Optional.ofNullable(allocationPrice.getNullable("allocation_price")) + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the replacement + * price. + */ + @Deprecated("deprecated") + fun discounts(): Optional> = + Optional.ofNullable(discounts.getNullable("discounts")) + + /** The external price id of the price to add to the subscription. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** The new quantity of the price, if the price is a fixed price. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + */ + @Deprecated("deprecated") + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. + */ + @Deprecated("deprecated") + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + /** The definition of a new price to create and add to the subscription. */ + fun price(): Optional = + Optional.ofNullable(price.getNullable("price")) + + /** The id of the price to add to the subscription. */ + fun priceId(): Optional = Optional.ofNullable(priceId.getNullable("price_id")) + + /** The id of the price on the plan to replace in the subscription. */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId + + /** The definition of a new allocation price to create and add to the subscription. */ + @JsonProperty("allocation_price") + @ExcludeMissing + fun _allocationPrice(): JsonField = allocationPrice + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the replacement + * price. + */ + @Deprecated("deprecated") + @JsonProperty("discounts") + @ExcludeMissing + fun _discounts(): JsonField> = discounts + + /** The external price id of the price to add to the subscription. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** The new quantity of the price, if the price is a fixed price. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + */ + @Deprecated("deprecated") + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. + */ + @Deprecated("deprecated") + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** The definition of a new price to create and add to the subscription. */ + @JsonProperty("price") + @ExcludeMissing + fun _price(): JsonField = price + + /** The id of the price to add to the subscription. */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): ReplaceSubscriptionPriceParams = apply { + if (validated) { + return@apply + } + + replacesPriceId() + allocationPrice().ifPresent { it.validate() } + discounts().ifPresent { it.forEach { it.validate() } } + externalPriceId() + fixedPriceQuantity() + maximumAmount() + minimumAmount() + price().ifPresent { it.validate() } + priceId() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ReplaceSubscriptionPriceParams]. + * + * The following fields are required: + * ```java + * .replacesPriceId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ReplaceSubscriptionPriceParams]. */ + class Builder internal constructor() { + + private var replacesPriceId: JsonField? = null + private var allocationPrice: JsonField = JsonMissing.of() + private var discounts: JsonField>? = null + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(replaceSubscriptionPriceParams: ReplaceSubscriptionPriceParams) = apply { + replacesPriceId = replaceSubscriptionPriceParams.replacesPriceId + allocationPrice = replaceSubscriptionPriceParams.allocationPrice + discounts = replaceSubscriptionPriceParams.discounts.map { it.toMutableList() } + externalPriceId = replaceSubscriptionPriceParams.externalPriceId + fixedPriceQuantity = replaceSubscriptionPriceParams.fixedPriceQuantity + maximumAmount = replaceSubscriptionPriceParams.maximumAmount + minimumAmount = replaceSubscriptionPriceParams.minimumAmount + price = replaceSubscriptionPriceParams.price + priceId = replaceSubscriptionPriceParams.priceId + additionalProperties = + replaceSubscriptionPriceParams.additionalProperties.toMutableMap() + } + + /** The id of the price on the plan to replace in the subscription. */ + fun replacesPriceId(replacesPriceId: String) = + replacesPriceId(JsonField.of(replacesPriceId)) + + /** The id of the price on the plan to replace in the subscription. */ + 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: NewAllocationPriceModel?) = + allocationPrice(JsonField.ofNullable(allocationPrice)) + + /** The definition of a new allocation price to create and add to the subscription. */ + fun allocationPrice(allocationPrice: Optional) = + allocationPrice(allocationPrice.orElse(null)) + + /** The definition of a new allocation price to create and add to the subscription. */ + 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)) + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the + * replacement price. + */ + @Deprecated("deprecated") + fun discounts(discounts: Optional>) = + discounts(discounts.orElse(null)) + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the + * replacement price. + */ + @Deprecated("deprecated") + fun discounts(discounts: JsonField>) = apply { + this.discounts = discounts.map { it.toMutableList() } + } + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the + * replacement price. + */ + @Deprecated("deprecated") + fun addDiscount(discount: DiscountOverrideModel) = 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)) + + /** The external price id of the price to add to the subscription. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) + + /** The external price id of the price to add to the subscription. */ + 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)) + + /** The new quantity of the price, if the price is a fixed price. */ + fun fixedPriceQuantity(fixedPriceQuantity: Double) = + fixedPriceQuantity(fixedPriceQuantity as Double?) + + /** The new quantity of the price, if the price is a fixed price. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + + /** The new quantity of the price, if the price is a fixed price. */ + 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)) + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + */ + @Deprecated("deprecated") + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. + */ + @Deprecated("deprecated") + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** The definition of a new price to create and add to the subscription. */ + fun price(price: NewSubscriptionPriceModel?) = price(JsonField.ofNullable(price)) + + /** The definition of a new price to create and add to the subscription. */ + fun price(price: Optional) = price(price.orElse(null)) + + /** The definition of a new price to create and add to the subscription. */ + fun price(price: JsonField) = apply { this.price = price } + + /** The definition of a new price to create and add to the subscription. */ + fun price(unitPrice: NewSubscriptionPriceModel.NewSubscriptionUnitPrice) = + price(NewSubscriptionPriceModel.ofUnitPrice(unitPrice)) + + /** The definition of a new price to create and add to the subscription. */ + fun price(packagePrice: NewSubscriptionPriceModel.NewSubscriptionPackagePrice) = + price(NewSubscriptionPriceModel.ofPackagePrice(packagePrice)) + + /** The definition of a new price to create and add to the subscription. */ + fun price(matrixPrice: NewSubscriptionPriceModel.NewSubscriptionMatrixPrice) = + price(NewSubscriptionPriceModel.ofMatrixPrice(matrixPrice)) + + /** The definition of a new price to create and add to the subscription. */ + fun price(tieredPrice: NewSubscriptionPriceModel.NewSubscriptionTieredPrice) = + price(NewSubscriptionPriceModel.ofTieredPrice(tieredPrice)) + + /** The definition of a new price to create and add to the subscription. */ + fun price(tieredBpsPrice: NewSubscriptionPriceModel.NewSubscriptionTieredBpsPrice) = + price(NewSubscriptionPriceModel.ofTieredBpsPrice(tieredBpsPrice)) + + /** The definition of a new price to create and add to the subscription. */ + fun price(bpsPrice: NewSubscriptionPriceModel.NewSubscriptionBpsPrice) = + price(NewSubscriptionPriceModel.ofBpsPrice(bpsPrice)) + + /** The definition of a new price to create and add to the subscription. */ + fun price(bulkBpsPrice: NewSubscriptionPriceModel.NewSubscriptionBulkBpsPrice) = + price(NewSubscriptionPriceModel.ofBulkBpsPrice(bulkBpsPrice)) + + /** The definition of a new price to create and add to the subscription. */ + fun price(bulkPrice: NewSubscriptionPriceModel.NewSubscriptionBulkPrice) = + price(NewSubscriptionPriceModel.ofBulkPrice(bulkPrice)) + + /** The definition of a new price to create and add to the subscription. */ + fun price( + thresholdTotalAmountPrice: + NewSubscriptionPriceModel.NewSubscriptionThresholdTotalAmountPrice + ) = price(NewSubscriptionPriceModel.ofThresholdTotalAmountPrice(thresholdTotalAmountPrice)) + + /** The definition of a new price to create and add to the subscription. */ + fun price(tieredPackagePrice: NewSubscriptionPriceModel.NewSubscriptionTieredPackagePrice) = + price(NewSubscriptionPriceModel.ofTieredPackagePrice(tieredPackagePrice)) + + /** The definition of a new price to create and add to the subscription. */ + fun price( + tieredWithMinimumPrice: NewSubscriptionPriceModel.NewSubscriptionTieredWithMinimumPrice + ) = price(NewSubscriptionPriceModel.ofTieredWithMinimumPrice(tieredWithMinimumPrice)) + + /** The definition of a new price to create and add to the subscription. */ + fun price( + unitWithPercentPrice: NewSubscriptionPriceModel.NewSubscriptionUnitWithPercentPrice + ) = price(NewSubscriptionPriceModel.ofUnitWithPercentPrice(unitWithPercentPrice)) + + /** The definition of a new price to create and add to the subscription. */ + fun price( + packageWithAllocationPrice: + NewSubscriptionPriceModel.NewSubscriptionPackageWithAllocationPrice + ) = + price( + NewSubscriptionPriceModel.ofPackageWithAllocationPrice(packageWithAllocationPrice) + ) + + /** The definition of a new price to create and add to the subscription. */ + fun price( + tierWithProrationPrice: NewSubscriptionPriceModel.NewSubscriptionTierWithProrationPrice + ) = price(NewSubscriptionPriceModel.ofTierWithProrationPrice(tierWithProrationPrice)) + + /** The definition of a new price to create and add to the subscription. */ + fun price( + unitWithProrationPrice: NewSubscriptionPriceModel.NewSubscriptionUnitWithProrationPrice + ) = price(NewSubscriptionPriceModel.ofUnitWithProrationPrice(unitWithProrationPrice)) + + /** The definition of a new price to create and add to the subscription. */ + fun price( + groupedAllocationPrice: NewSubscriptionPriceModel.NewSubscriptionGroupedAllocationPrice + ) = price(NewSubscriptionPriceModel.ofGroupedAllocationPrice(groupedAllocationPrice)) + + /** The definition of a new price to create and add to the subscription. */ + fun price( + groupedWithProratedMinimumPrice: + NewSubscriptionPriceModel.NewSubscriptionGroupedWithProratedMinimumPrice + ) = + price( + NewSubscriptionPriceModel.ofGroupedWithProratedMinimumPrice( + groupedWithProratedMinimumPrice + ) + ) + + /** The definition of a new price to create and add to the subscription. */ + fun price( + bulkWithProrationPrice: NewSubscriptionPriceModel.NewSubscriptionBulkWithProrationPrice + ) = price(NewSubscriptionPriceModel.ofBulkWithProrationPrice(bulkWithProrationPrice)) + + /** The definition of a new price to create and add to the subscription. */ + fun price( + scalableMatrixWithUnitPricingPrice: + NewSubscriptionPriceModel.NewSubscriptionScalableMatrixWithUnitPricingPrice + ) = + price( + NewSubscriptionPriceModel.ofScalableMatrixWithUnitPricingPrice( + scalableMatrixWithUnitPricingPrice + ) + ) + + /** The definition of a new price to create and add to the subscription. */ + fun price( + scalableMatrixWithTieredPricingPrice: + NewSubscriptionPriceModel.NewSubscriptionScalableMatrixWithTieredPricingPrice + ) = + price( + NewSubscriptionPriceModel.ofScalableMatrixWithTieredPricingPrice( + scalableMatrixWithTieredPricingPrice + ) + ) + + /** The definition of a new price to create and add to the subscription. */ + fun price( + cumulativeGroupedBulkPrice: + NewSubscriptionPriceModel.NewSubscriptionCumulativeGroupedBulkPrice + ) = + price( + NewSubscriptionPriceModel.ofCumulativeGroupedBulkPrice(cumulativeGroupedBulkPrice) + ) + + /** The definition of a new price to create and add to the subscription. */ + fun price( + maxGroupTieredPackagePrice: + NewSubscriptionPriceModel.NewSubscriptionMaxGroupTieredPackagePrice + ) = + price( + NewSubscriptionPriceModel.ofMaxGroupTieredPackagePrice(maxGroupTieredPackagePrice) + ) + + /** The definition of a new price to create and add to the subscription. */ + fun price( + groupedWithMeteredMinimumPrice: + NewSubscriptionPriceModel.NewSubscriptionGroupedWithMeteredMinimumPrice + ) = + price( + NewSubscriptionPriceModel.ofGroupedWithMeteredMinimumPrice( + groupedWithMeteredMinimumPrice + ) + ) + + /** The definition of a new price to create and add to the subscription. */ + fun price( + matrixWithDisplayNamePrice: + NewSubscriptionPriceModel.NewSubscriptionMatrixWithDisplayNamePrice + ) = + price( + NewSubscriptionPriceModel.ofMatrixWithDisplayNamePrice(matrixWithDisplayNamePrice) + ) + + /** The definition of a new price to create and add to the subscription. */ + fun price( + groupedTieredPackagePrice: + NewSubscriptionPriceModel.NewSubscriptionGroupedTieredPackagePrice + ) = price(NewSubscriptionPriceModel.ofGroupedTieredPackagePrice(groupedTieredPackagePrice)) + + /** The id of the price to add to the subscription. */ + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + + /** The id of the price to add to the subscription. */ + fun priceId(priceId: Optional) = priceId(priceId.orElse(null)) + + /** The id of the price to add to the subscription. */ + 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) + } + + fun build(): ReplaceSubscriptionPriceParams = + ReplaceSubscriptionPriceParams( + checkRequired("replacesPriceId", replacesPriceId), + allocationPrice, + (discounts ?: JsonMissing.of()).map { it.toImmutable() }, + externalPriceId, + fixedPriceQuantity, + maximumAmount, + minimumAmount, + price, + priceId, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ReplaceSubscriptionPriceParams && replacesPriceId == other.replacesPriceId && allocationPrice == other.allocationPrice && discounts == other.discounts && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && maximumAmount == other.maximumAmount && minimumAmount == other.minimumAmount && price == other.price && priceId == other.priceId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(replacesPriceId, allocationPrice, discounts, externalPriceId, fixedPriceQuantity, maximumAmount, minimumAmount, price, priceId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReplaceSubscriptionPriceParams{replacesPriceId=$replacesPriceId, allocationPrice=$allocationPrice, discounts=$discounts, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, price=$price, priceId=$priceId, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubLineItemGroupingModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubLineItemGroupingModel.kt new file mode 100644 index 000000000..aaf66a90f --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubLineItemGroupingModel.kt @@ -0,0 +1,141 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class SubLineItemGroupingModel +@JsonCreator +private constructor( + @JsonProperty("key") @ExcludeMissing private val key: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing private val value: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun key(): String = key.getRequired("key") + + /** No value indicates the default group */ + fun value(): Optional = Optional.ofNullable(value.getNullable("value")) + + @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key + + /** No value indicates the default group */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): SubLineItemGroupingModel = apply { + if (validated) { + return@apply + } + + key() + value() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SubLineItemGroupingModel]. + * + * The following fields are required: + * ```java + * .key() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SubLineItemGroupingModel]. */ + class Builder internal constructor() { + + private var key: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(subLineItemGroupingModel: SubLineItemGroupingModel) = apply { + key = subLineItemGroupingModel.key + value = subLineItemGroupingModel.value + additionalProperties = subLineItemGroupingModel.additionalProperties.toMutableMap() + } + + fun key(key: String) = key(JsonField.of(key)) + + fun key(key: JsonField) = apply { this.key = key } + + /** No value indicates the default group */ + fun value(value: String?) = value(JsonField.ofNullable(value)) + + /** No value indicates the default group */ + fun value(value: Optional) = value(value.orElse(null)) + + /** No value indicates the default group */ + fun value(value: JsonField) = apply { this.value = 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) + } + + fun build(): SubLineItemGroupingModel = + SubLineItemGroupingModel( + checkRequired("key", key), + checkRequired("value", value), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SubLineItemGroupingModel && key == other.key && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(key, value, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SubLineItemGroupingModel{key=$key, value=$value, additionalProperties=$additionalProperties}" +} 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 9515f0ffb..bbe8489e4 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 @@ -21,6 +21,7 @@ import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.getOrThrow import com.withorb.api.core.immutableEmptyMap @@ -58,13 +59,13 @@ private constructor( private val activePlanPhaseOrder: JsonField = JsonMissing.of(), @JsonProperty("adjustment_intervals") @ExcludeMissing - private val adjustmentIntervals: JsonField> = JsonMissing.of(), + private val adjustmentIntervals: JsonField> = JsonMissing.of(), @JsonProperty("auto_collection") @ExcludeMissing private val autoCollection: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_anchor_configuration") @ExcludeMissing - private val billingCycleAnchorConfiguration: JsonField = + private val billingCycleAnchorConfiguration: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_day") @ExcludeMissing @@ -80,7 +81,7 @@ private constructor( private val currentBillingPeriodStartDate: JsonField = JsonMissing.of(), @JsonProperty("customer") @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), + private val customer: JsonField = JsonMissing.of(), @JsonProperty("default_invoice_memo") @ExcludeMissing private val defaultInvoiceMemo: JsonField = JsonMissing.of(), @@ -92,30 +93,30 @@ private constructor( private val endDate: JsonField = JsonMissing.of(), @JsonProperty("fixed_fee_quantity_schedule") @ExcludeMissing - private val fixedFeeQuantitySchedule: JsonField> = + private val fixedFeeQuantitySchedule: JsonField> = JsonMissing.of(), @JsonProperty("invoicing_threshold") @ExcludeMissing private val invoicingThreshold: JsonField = JsonMissing.of(), @JsonProperty("maximum_intervals") @ExcludeMissing - private val maximumIntervals: JsonField> = JsonMissing.of(), + private val maximumIntervals: JsonField> = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing private val metadata: JsonField = JsonMissing.of(), @JsonProperty("minimum_intervals") @ExcludeMissing - private val minimumIntervals: JsonField> = JsonMissing.of(), + private val minimumIntervals: JsonField> = JsonMissing.of(), @JsonProperty("net_terms") @ExcludeMissing private val netTerms: JsonField = JsonMissing.of(), - @JsonProperty("plan") @ExcludeMissing private val plan: JsonField = JsonMissing.of(), + @JsonProperty("plan") @ExcludeMissing private val plan: JsonField = JsonMissing.of(), @JsonProperty("price_intervals") @ExcludeMissing - private val priceIntervals: JsonField> = JsonMissing.of(), + private val priceIntervals: JsonField> = JsonMissing.of(), @JsonProperty("redeemed_coupon") @ExcludeMissing - private val redeemedCoupon: JsonField = JsonMissing.of(), + private val redeemedCoupon: JsonField = JsonMissing.of(), @JsonProperty("start_date") @ExcludeMissing private val startDate: JsonField = JsonMissing.of(), @@ -124,7 +125,7 @@ private constructor( private val status: JsonField = JsonMissing.of(), @JsonProperty("trial_info") @ExcludeMissing - private val trialInfo: JsonField = JsonMissing.of(), + private val trialInfo: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -135,7 +136,7 @@ private constructor( Optional.ofNullable(activePlanPhaseOrder.getNullable("active_plan_phase_order")) /** The adjustment intervals for this subscription. */ - fun adjustmentIntervals(): List = + fun adjustmentIntervals(): List = adjustmentIntervals.getRequired("adjustment_intervals") /** @@ -146,7 +147,7 @@ private constructor( fun autoCollection(): Optional = Optional.ofNullable(autoCollection.getNullable("auto_collection")) - fun billingCycleAnchorConfiguration(): BillingCycleAnchorConfiguration = + fun billingCycleAnchorConfiguration(): BillingCycleAnchorConfigurationModel = billingCycleAnchorConfiguration.getRequired("billing_cycle_anchor_configuration") /** @@ -196,7 +197,7 @@ private constructor( * timezone. See [Timezone localization](/essentials/timezones) for information on what this * timezone parameter influences within Orb. */ - fun customer(): Customer = customer.getRequired("customer") + fun customer(): CustomerModel = customer.getRequired("customer") /** * Determines the default memo on this subscriptions' invoices. Note that if this is not @@ -212,14 +213,14 @@ private constructor( /** The date Orb stops billing for this subscription. */ fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) - fun fixedFeeQuantitySchedule(): List = + fun fixedFeeQuantitySchedule(): List = fixedFeeQuantitySchedule.getRequired("fixed_fee_quantity_schedule") fun invoicingThreshold(): Optional = Optional.ofNullable(invoicingThreshold.getNullable("invoicing_threshold")) /** The maximum intervals for this subscription. */ - fun maximumIntervals(): List = + fun maximumIntervals(): List = maximumIntervals.getRequired("maximum_intervals") /** @@ -230,7 +231,7 @@ private constructor( fun metadata(): Metadata = metadata.getRequired("metadata") /** The minimum intervals for this subscription. */ - fun minimumIntervals(): List = + fun minimumIntervals(): List = minimumIntervals.getRequired("minimum_intervals") /** @@ -245,12 +246,12 @@ private constructor( * 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 plan(): Plan = plan.getRequired("plan") + fun plan(): PlanModel = plan.getRequired("plan") /** The price intervals for this subscription. */ - fun priceIntervals(): List = priceIntervals.getRequired("price_intervals") + fun priceIntervals(): List = priceIntervals.getRequired("price_intervals") - fun redeemedCoupon(): Optional = + fun redeemedCoupon(): Optional = Optional.ofNullable(redeemedCoupon.getNullable("redeemed_coupon")) /** The date Orb starts billing for this subscription. */ @@ -258,7 +259,7 @@ private constructor( fun status(): Status = status.getRequired("status") - fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") + fun trialInfo(): SubscriptionTrialInfoModel = trialInfo.getRequired("trial_info") @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @@ -270,7 +271,7 @@ private constructor( /** The adjustment intervals for this subscription. */ @JsonProperty("adjustment_intervals") @ExcludeMissing - fun _adjustmentIntervals(): JsonField> = adjustmentIntervals + fun _adjustmentIntervals(): JsonField> = adjustmentIntervals /** * Determines whether issued invoices for this subscription will automatically be charged with @@ -283,7 +284,7 @@ private constructor( @JsonProperty("billing_cycle_anchor_configuration") @ExcludeMissing - fun _billingCycleAnchorConfiguration(): JsonField = + fun _billingCycleAnchorConfiguration(): JsonField = billingCycleAnchorConfiguration /** @@ -335,7 +336,7 @@ private constructor( * timezone. See [Timezone localization](/essentials/timezones) for information on what this * timezone parameter influences within Orb. */ - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer /** * Determines the default memo on this subscriptions' invoices. Note that if this is not @@ -355,7 +356,7 @@ private constructor( @JsonProperty("fixed_fee_quantity_schedule") @ExcludeMissing - fun _fixedFeeQuantitySchedule(): JsonField> = + fun _fixedFeeQuantitySchedule(): JsonField> = fixedFeeQuantitySchedule @JsonProperty("invoicing_threshold") @@ -365,7 +366,7 @@ private constructor( /** The maximum intervals for this subscription. */ @JsonProperty("maximum_intervals") @ExcludeMissing - fun _maximumIntervals(): JsonField> = maximumIntervals + fun _maximumIntervals(): JsonField> = maximumIntervals /** * User specified key-value pairs for the resource. If not present, this defaults to an empty @@ -377,7 +378,7 @@ private constructor( /** The minimum intervals for this subscription. */ @JsonProperty("minimum_intervals") @ExcludeMissing - fun _minimumIntervals(): JsonField> = minimumIntervals + fun _minimumIntervals(): JsonField> = minimumIntervals /** * Determines the difference between the invoice issue date for subscription invoices as the @@ -391,16 +392,16 @@ private constructor( * 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). */ - @JsonProperty("plan") @ExcludeMissing fun _plan(): JsonField = plan + @JsonProperty("plan") @ExcludeMissing fun _plan(): JsonField = plan /** The price intervals for this subscription. */ @JsonProperty("price_intervals") @ExcludeMissing - fun _priceIntervals(): JsonField> = priceIntervals + fun _priceIntervals(): JsonField> = priceIntervals @JsonProperty("redeemed_coupon") @ExcludeMissing - fun _redeemedCoupon(): JsonField = redeemedCoupon + fun _redeemedCoupon(): JsonField = redeemedCoupon /** The date Orb starts billing for this subscription. */ @JsonProperty("start_date") @@ -409,7 +410,9 @@ private constructor( @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo(): JsonField = trialInfo + @JsonProperty("trial_info") + @ExcludeMissing + fun _trialInfo(): JsonField = trialInfo @JsonAnyGetter @ExcludeMissing @@ -454,6 +457,38 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Subscription]. + * + * The following fields are required: + * ```java + * .id() + * .activePlanPhaseOrder() + * .adjustmentIntervals() + * .autoCollection() + * .billingCycleAnchorConfiguration() + * .billingCycleDay() + * .createdAt() + * .currentBillingPeriodEndDate() + * .currentBillingPeriodStartDate() + * .customer() + * .defaultInvoiceMemo() + * .discountIntervals() + * .endDate() + * .fixedFeeQuantitySchedule() + * .invoicingThreshold() + * .maximumIntervals() + * .metadata() + * .minimumIntervals() + * .netTerms() + * .plan() + * .priceIntervals() + * .redeemedCoupon() + * .startDate() + * .status() + * .trialInfo() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -462,31 +497,33 @@ private constructor( private var id: JsonField? = null private var activePlanPhaseOrder: JsonField? = null - private var adjustmentIntervals: JsonField>? = null + private var adjustmentIntervals: JsonField>? = null private var autoCollection: JsonField? = null - private var billingCycleAnchorConfiguration: JsonField? = + private var billingCycleAnchorConfiguration: + JsonField? = null private var billingCycleDay: JsonField? = null private var createdAt: JsonField? = null private var currentBillingPeriodEndDate: JsonField? = null private var currentBillingPeriodStartDate: JsonField? = null - private var customer: JsonField? = null + private var customer: JsonField? = null private var defaultInvoiceMemo: JsonField? = null private var discountIntervals: JsonField>? = null private var endDate: JsonField? = null - private var fixedFeeQuantitySchedule: JsonField>? = + private var fixedFeeQuantitySchedule: + JsonField>? = null private var invoicingThreshold: JsonField? = null - private var maximumIntervals: JsonField>? = null + private var maximumIntervals: JsonField>? = null private var metadata: JsonField? = null - private var minimumIntervals: JsonField>? = null + private var minimumIntervals: JsonField>? = null private var netTerms: JsonField? = null - private var plan: JsonField? = null - private var priceIntervals: JsonField>? = null - private var redeemedCoupon: JsonField? = null + private var plan: JsonField? = null + private var priceIntervals: JsonField>? = null + private var redeemedCoupon: JsonField? = null private var startDate: JsonField? = null private var status: JsonField? = null - private var trialInfo: JsonField? = null + private var trialInfo: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -543,25 +580,20 @@ private constructor( } /** The adjustment intervals for this subscription. */ - fun adjustmentIntervals(adjustmentIntervals: List) = + fun adjustmentIntervals(adjustmentIntervals: List) = adjustmentIntervals(JsonField.of(adjustmentIntervals)) /** The adjustment intervals for this subscription. */ - fun adjustmentIntervals(adjustmentIntervals: JsonField>) = apply { - this.adjustmentIntervals = adjustmentIntervals.map { it.toMutableList() } - } + fun adjustmentIntervals(adjustmentIntervals: JsonField>) = + apply { + this.adjustmentIntervals = adjustmentIntervals.map { it.toMutableList() } + } /** The adjustment intervals for this subscription. */ - fun addAdjustmentInterval(adjustmentInterval: AdjustmentInterval) = apply { + fun addAdjustmentInterval(adjustmentInterval: AdjustmentIntervalModel) = apply { adjustmentIntervals = - (adjustmentIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(adjustmentInterval) + (adjustmentIntervals ?: JsonField.of(mutableListOf())).also { + checkKnown("adjustmentIntervals", it).add(adjustmentInterval) } } @@ -599,11 +631,11 @@ private constructor( } fun billingCycleAnchorConfiguration( - billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration + billingCycleAnchorConfiguration: BillingCycleAnchorConfigurationModel ) = billingCycleAnchorConfiguration(JsonField.of(billingCycleAnchorConfiguration)) fun billingCycleAnchorConfiguration( - billingCycleAnchorConfiguration: JsonField + billingCycleAnchorConfiguration: JsonField ) = apply { this.billingCycleAnchorConfiguration = billingCycleAnchorConfiguration } /** @@ -697,7 +729,7 @@ private constructor( * account's timezone. See [Timezone localization](/essentials/timezones) for information on * what this timezone parameter influences within Orb. */ - fun customer(customer: Customer) = customer(JsonField.of(customer)) + fun customer(customer: CustomerModel) = customer(JsonField.of(customer)) /** * A customer is a buyer of your products, and the other party to the billing relationship. @@ -717,7 +749,7 @@ private constructor( * account's timezone. See [Timezone localization](/essentials/timezones) for information on * what this timezone parameter influences within Orb. */ - fun customer(customer: JsonField) = apply { this.customer = customer } + fun customer(customer: JsonField) = apply { this.customer = customer } /** * Determines the default memo on this subscriptions' invoices. Note that if this is not @@ -753,28 +785,28 @@ private constructor( /** The discount intervals for this subscription. */ fun addDiscountInterval(discountInterval: DiscountInterval) = apply { discountIntervals = - (discountIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(discountInterval) + (discountIntervals ?: JsonField.of(mutableListOf())).also { + checkKnown("discountIntervals", it).add(discountInterval) } } /** The discount intervals for this subscription. */ - fun addDiscountInterval(amount: DiscountInterval.AmountDiscountInterval) = - addDiscountInterval(DiscountInterval.ofAmount(amount)) + fun addDiscountInterval(amountDiscountIntervalModel: AmountDiscountIntervalModel) = + addDiscountInterval( + DiscountInterval.ofAmountDiscountIntervalModel(amountDiscountIntervalModel) + ) /** The discount intervals for this subscription. */ - fun addDiscountInterval(percentage: DiscountInterval.PercentageDiscountInterval) = - addDiscountInterval(DiscountInterval.ofPercentage(percentage)) + fun addDiscountInterval(percentageDiscountIntervalModel: PercentageDiscountIntervalModel) = + addDiscountInterval( + DiscountInterval.ofPercentageDiscountIntervalModel(percentageDiscountIntervalModel) + ) /** The discount intervals for this subscription. */ - fun addDiscountInterval(usage: DiscountInterval.UsageDiscountInterval) = - addDiscountInterval(DiscountInterval.ofUsage(usage)) + fun addDiscountInterval(usageDiscountIntervalModel: UsageDiscountIntervalModel) = + addDiscountInterval( + DiscountInterval.ofUsageDiscountIntervalModel(usageDiscountIntervalModel) + ) /** The date Orb stops billing for this subscription. */ fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) @@ -785,28 +817,24 @@ private constructor( /** The date Orb stops billing for this subscription. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - fun fixedFeeQuantitySchedule(fixedFeeQuantitySchedule: List) = - fixedFeeQuantitySchedule(JsonField.of(fixedFeeQuantitySchedule)) + fun fixedFeeQuantitySchedule( + fixedFeeQuantitySchedule: List + ) = fixedFeeQuantitySchedule(JsonField.of(fixedFeeQuantitySchedule)) fun fixedFeeQuantitySchedule( - fixedFeeQuantitySchedule: JsonField> + fixedFeeQuantitySchedule: JsonField> ) = apply { this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule.map { it.toMutableList() } } - fun addFixedFeeQuantitySchedule(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = - apply { - this.fixedFeeQuantitySchedule = - (this.fixedFeeQuantitySchedule ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(fixedFeeQuantitySchedule) - } - } + fun addFixedFeeQuantitySchedule( + fixedFeeQuantitySchedule: FixedFeeQuantityScheduleEntryModel + ) = apply { + this.fixedFeeQuantitySchedule = + (this.fixedFeeQuantitySchedule ?: JsonField.of(mutableListOf())).also { + checkKnown("fixedFeeQuantitySchedule", it).add(fixedFeeQuantitySchedule) + } + } fun invoicingThreshold(invoicingThreshold: String?) = invoicingThreshold(JsonField.ofNullable(invoicingThreshold)) @@ -819,25 +847,19 @@ private constructor( } /** The maximum intervals for this subscription. */ - fun maximumIntervals(maximumIntervals: List) = + fun maximumIntervals(maximumIntervals: List) = maximumIntervals(JsonField.of(maximumIntervals)) /** The maximum intervals for this subscription. */ - fun maximumIntervals(maximumIntervals: JsonField>) = apply { + fun maximumIntervals(maximumIntervals: JsonField>) = apply { this.maximumIntervals = maximumIntervals.map { it.toMutableList() } } /** The maximum intervals for this subscription. */ - fun addMaximumInterval(maximumInterval: MaximumInterval) = apply { + fun addMaximumInterval(maximumInterval: MaximumIntervalModel) = apply { maximumIntervals = - (maximumIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(maximumInterval) + (maximumIntervals ?: JsonField.of(mutableListOf())).also { + checkKnown("maximumIntervals", it).add(maximumInterval) } } @@ -856,25 +878,19 @@ private constructor( fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** The minimum intervals for this subscription. */ - fun minimumIntervals(minimumIntervals: List) = + fun minimumIntervals(minimumIntervals: List) = minimumIntervals(JsonField.of(minimumIntervals)) /** The minimum intervals for this subscription. */ - fun minimumIntervals(minimumIntervals: JsonField>) = apply { + fun minimumIntervals(minimumIntervals: JsonField>) = apply { this.minimumIntervals = minimumIntervals.map { it.toMutableList() } } /** The minimum intervals for this subscription. */ - fun addMinimumInterval(minimumInterval: MinimumInterval) = apply { + fun addMinimumInterval(minimumInterval: MinimumIntervalModel) = apply { minimumIntervals = - (minimumIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(minimumInterval) + (minimumIntervals ?: JsonField.of(mutableListOf())).also { + checkKnown("minimumIntervals", it).add(minimumInterval) } } @@ -897,45 +913,39 @@ private constructor( * 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 plan(plan: Plan) = plan(JsonField.of(plan)) + fun plan(plan: PlanModel) = plan(JsonField.of(plan)) /** * 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 plan(plan: JsonField) = apply { this.plan = plan } + fun plan(plan: JsonField) = apply { this.plan = plan } /** The price intervals for this subscription. */ - fun priceIntervals(priceIntervals: List) = + fun priceIntervals(priceIntervals: List) = priceIntervals(JsonField.of(priceIntervals)) /** The price intervals for this subscription. */ - fun priceIntervals(priceIntervals: JsonField>) = apply { + fun priceIntervals(priceIntervals: JsonField>) = apply { this.priceIntervals = priceIntervals.map { it.toMutableList() } } /** The price intervals for this subscription. */ - fun addPriceInterval(priceInterval: PriceInterval) = apply { + fun addPriceInterval(priceInterval: PriceIntervalModel) = apply { priceIntervals = - (priceIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(priceInterval) + (priceIntervals ?: JsonField.of(mutableListOf())).also { + checkKnown("priceIntervals", it).add(priceInterval) } } - fun redeemedCoupon(redeemedCoupon: RedeemedCoupon?) = + fun redeemedCoupon(redeemedCoupon: CouponRedemptionModel?) = redeemedCoupon(JsonField.ofNullable(redeemedCoupon)) - fun redeemedCoupon(redeemedCoupon: Optional) = + fun redeemedCoupon(redeemedCoupon: Optional) = redeemedCoupon(redeemedCoupon.orElse(null)) - fun redeemedCoupon(redeemedCoupon: JsonField) = apply { + fun redeemedCoupon(redeemedCoupon: JsonField) = apply { this.redeemedCoupon = redeemedCoupon } @@ -949,9 +959,11 @@ private constructor( fun status(status: JsonField) = apply { this.status = status } - fun trialInfo(trialInfo: TrialInfo) = trialInfo(JsonField.of(trialInfo)) + fun trialInfo(trialInfo: SubscriptionTrialInfoModel) = trialInfo(JsonField.of(trialInfo)) - fun trialInfo(trialInfo: JsonField) = apply { this.trialInfo = trialInfo } + fun trialInfo(trialInfo: JsonField) = apply { + this.trialInfo = trialInfo + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1005,176 +1017,269 @@ private constructor( ) } - @NoAutoDetect - class AdjustmentInterval - @JsonCreator + @JsonDeserialize(using = DiscountInterval.Deserializer::class) + @JsonSerialize(using = DiscountInterval.Serializer::class) + class DiscountInterval private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment") - @ExcludeMissing - private val adjustment: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + private val amountDiscountIntervalModel: AmountDiscountIntervalModel? = null, + private val percentageDiscountIntervalModel: PercentageDiscountIntervalModel? = null, + private val usageDiscountIntervalModel: UsageDiscountIntervalModel? = null, + private val _json: JsonValue? = null, ) { - fun id(): String = id.getRequired("id") + fun amountDiscountIntervalModel(): Optional = + Optional.ofNullable(amountDiscountIntervalModel) - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + fun percentageDiscountIntervalModel(): Optional = + Optional.ofNullable(percentageDiscountIntervalModel) - /** The price interval IDs that this adjustment applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") + fun usageDiscountIntervalModel(): Optional = + Optional.ofNullable(usageDiscountIntervalModel) - /** The end date of the adjustment interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) + fun isAmountDiscountIntervalModel(): Boolean = amountDiscountIntervalModel != null - /** The start date of the adjustment interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + fun isPercentageDiscountIntervalModel(): Boolean = percentageDiscountIntervalModel != null - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + fun isUsageDiscountIntervalModel(): Boolean = usageDiscountIntervalModel != null - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment + fun asAmountDiscountIntervalModel(): AmountDiscountIntervalModel = + amountDiscountIntervalModel.getOrThrow("amountDiscountIntervalModel") - /** The price interval IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds + fun asPercentageDiscountIntervalModel(): PercentageDiscountIntervalModel = + percentageDiscountIntervalModel.getOrThrow("percentageDiscountIntervalModel") - /** The end date of the adjustment interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate + fun asUsageDiscountIntervalModel(): UsageDiscountIntervalModel = + usageDiscountIntervalModel.getOrThrow("usageDiscountIntervalModel") - /** The start date of the adjustment interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate + fun _json(): Optional = Optional.ofNullable(_json) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun accept(visitor: Visitor): T { + return when { + amountDiscountIntervalModel != null -> + visitor.visitAmountDiscountIntervalModel(amountDiscountIntervalModel) + percentageDiscountIntervalModel != null -> + visitor.visitPercentageDiscountIntervalModel(percentageDiscountIntervalModel) + usageDiscountIntervalModel != null -> + visitor.visitUsageDiscountIntervalModel(usageDiscountIntervalModel) + else -> visitor.unknown(_json) + } + } private var validated: Boolean = false - fun validate(): AdjustmentInterval = apply { + fun validate(): DiscountInterval = apply { if (validated) { return@apply } - id() - adjustment().validate() - appliesToPriceIntervalIds() - endDate() - startDate() + accept( + object : Visitor { + override fun visitAmountDiscountIntervalModel( + amountDiscountIntervalModel: AmountDiscountIntervalModel + ) { + amountDiscountIntervalModel.validate() + } + + override fun visitPercentageDiscountIntervalModel( + percentageDiscountIntervalModel: PercentageDiscountIntervalModel + ) { + percentageDiscountIntervalModel.validate() + } + + override fun visitUsageDiscountIntervalModel( + usageDiscountIntervalModel: UsageDiscountIntervalModel + ) { + usageDiscountIntervalModel.validate() + } + } + ) validated = true } - fun toBuilder() = Builder().from(this) - - companion object { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JvmStatic fun builder() = Builder() + return /* spotless:off */ other is DiscountInterval && amountDiscountIntervalModel == other.amountDiscountIntervalModel && percentageDiscountIntervalModel == other.percentageDiscountIntervalModel && usageDiscountIntervalModel == other.usageDiscountIntervalModel /* spotless:on */ } - /** A builder for [AdjustmentInterval]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustment: JsonField? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + override fun hashCode(): Int = /* spotless:off */ Objects.hash(amountDiscountIntervalModel, percentageDiscountIntervalModel, usageDiscountIntervalModel) /* spotless:on */ - @JvmSynthetic - internal fun from(adjustmentInterval: AdjustmentInterval) = apply { - id = adjustmentInterval.id - adjustment = adjustmentInterval.adjustment - appliesToPriceIntervalIds = - adjustmentInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - endDate = adjustmentInterval.endDate - startDate = adjustmentInterval.startDate - additionalProperties = adjustmentInterval.additionalProperties.toMutableMap() + override fun toString(): String = + when { + amountDiscountIntervalModel != null -> + "DiscountInterval{amountDiscountIntervalModel=$amountDiscountIntervalModel}" + percentageDiscountIntervalModel != null -> + "DiscountInterval{percentageDiscountIntervalModel=$percentageDiscountIntervalModel}" + usageDiscountIntervalModel != null -> + "DiscountInterval{usageDiscountIntervalModel=$usageDiscountIntervalModel}" + _json != null -> "DiscountInterval{_unknown=$_json}" + else -> throw IllegalStateException("Invalid DiscountInterval") } - fun id(id: String) = id(JsonField.of(id)) + companion object { - fun id(id: JsonField) = apply { this.id = id } + @JvmStatic + fun ofAmountDiscountIntervalModel( + amountDiscountIntervalModel: AmountDiscountIntervalModel + ) = DiscountInterval(amountDiscountIntervalModel = amountDiscountIntervalModel) - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) + @JvmStatic + fun ofPercentageDiscountIntervalModel( + percentageDiscountIntervalModel: PercentageDiscountIntervalModel + ) = DiscountInterval(percentageDiscountIntervalModel = percentageDiscountIntervalModel) - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } + @JvmStatic + fun ofUsageDiscountIntervalModel( + usageDiscountIntervalModel: UsageDiscountIntervalModel + ) = DiscountInterval(usageDiscountIntervalModel = usageDiscountIntervalModel) + } - fun adjustment(planPhaseUsageDiscount: Adjustment.PlanPhaseUsageDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)) + /** + * An interface that defines how to map each variant of [DiscountInterval] to a value of + * type [T]. + */ + interface Visitor { - fun adjustment(planPhaseAmountDiscount: Adjustment.PlanPhaseAmountDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)) + fun visitAmountDiscountIntervalModel( + amountDiscountIntervalModel: AmountDiscountIntervalModel + ): T - fun adjustment( - planPhasePercentageDiscount: Adjustment.PlanPhasePercentageDiscountAdjustment - ) = adjustment(Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)) + fun visitPercentageDiscountIntervalModel( + percentageDiscountIntervalModel: PercentageDiscountIntervalModel + ): T - fun adjustment(planPhaseMinimum: Adjustment.PlanPhaseMinimumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)) + fun visitUsageDiscountIntervalModel( + usageDiscountIntervalModel: UsageDiscountIntervalModel + ): T - fun adjustment(planPhaseMaximum: Adjustment.PlanPhaseMaximumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)) + /** + * Maps an unknown variant of [DiscountInterval] to a value of type [T]. + * + * An instance of [DiscountInterval] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the SDK + * is on an older version than the API, then the API may respond with new variants that + * the SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown DiscountInterval: $json") + } + } - /** The price interval IDs that this adjustment applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) + internal class Deserializer : BaseDeserializer(DiscountInterval::class) { - /** The price interval IDs that this adjustment applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } + override fun ObjectCodec.deserialize(node: JsonNode): DiscountInterval { + val json = JsonValue.fromJsonNode(node) + val discountType = + json.asObject().getOrNull()?.get("discount_type")?.asString()?.getOrNull() - /** The price interval IDs that this adjustment applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" + when (discountType) { + "amount" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return DiscountInterval( + amountDiscountIntervalModel = it, + _json = json, + ) + } + } + "percentage" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return DiscountInterval( + percentageDiscountIntervalModel = it, + _json = json, + ) + } + } + "usage" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return DiscountInterval( + usageDiscountIntervalModel = it, + _json = json, ) } - .add(appliesToPriceIntervalId) } + } + + return DiscountInterval(_json = json) + } + } + + internal class Serializer : BaseSerializer(DiscountInterval::class) { + + override fun serialize( + value: DiscountInterval, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.amountDiscountIntervalModel != null -> + generator.writeObject(value.amountDiscountIntervalModel) + value.percentageDiscountIntervalModel != null -> + generator.writeObject(value.percentageDiscountIntervalModel) + value.usageDiscountIntervalModel != null -> + generator.writeObject(value.usageDiscountIntervalModel) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid DiscountInterval") + } + } + } + } + + /** + * 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`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply } - /** The end date of the adjustment interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { - /** The end date of the adjustment interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } - /** The end date of the adjustment interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** The start date of the adjustment interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + private var additionalProperties: MutableMap = mutableMapOf() - /** The start date of the adjustment interval. */ - fun startDate(startDate: JsonField) = apply { - this.startDate = startDate + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -1196,5824 +1301,86 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): AdjustmentInterval = - AdjustmentInterval( - checkRequired("id", id), - checkRequired("adjustment", adjustment), - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment? = null, - private val planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment? = null, - private val planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment? = null, - private val planPhaseMinimum: PlanPhaseMinimumAdjustment? = null, - private val planPhaseMaximum: PlanPhaseMaximumAdjustment? = null, - private val _json: JsonValue? = null, - ) { - - fun planPhaseUsageDiscount(): Optional = - Optional.ofNullable(planPhaseUsageDiscount) - - fun planPhaseAmountDiscount(): Optional = - Optional.ofNullable(planPhaseAmountDiscount) - - fun planPhasePercentageDiscount(): Optional = - Optional.ofNullable(planPhasePercentageDiscount) - - fun planPhaseMinimum(): Optional = - Optional.ofNullable(planPhaseMinimum) - - fun planPhaseMaximum(): Optional = - Optional.ofNullable(planPhaseMaximum) - - fun isPlanPhaseUsageDiscount(): Boolean = planPhaseUsageDiscount != null - - fun isPlanPhaseAmountDiscount(): Boolean = planPhaseAmountDiscount != null - - fun isPlanPhasePercentageDiscount(): Boolean = planPhasePercentageDiscount != null + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isPlanPhaseMinimum(): Boolean = planPhaseMinimum != null + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } - fun isPlanPhaseMaximum(): Boolean = planPhaseMaximum != null + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - fun asPlanPhaseUsageDiscount(): PlanPhaseUsageDiscountAdjustment = - planPhaseUsageDiscount.getOrThrow("planPhaseUsageDiscount") + override fun hashCode(): Int = hashCode - fun asPlanPhaseAmountDiscount(): PlanPhaseAmountDiscountAdjustment = - planPhaseAmountDiscount.getOrThrow("planPhaseAmountDiscount") + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } - fun asPlanPhasePercentageDiscount(): PlanPhasePercentageDiscountAdjustment = - planPhasePercentageDiscount.getOrThrow("planPhasePercentageDiscount") + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { - fun asPlanPhaseMinimum(): PlanPhaseMinimumAdjustment = - planPhaseMinimum.getOrThrow("planPhaseMinimum") + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the 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 asPlanPhaseMaximum(): PlanPhaseMaximumAdjustment = - planPhaseMaximum.getOrThrow("planPhaseMaximum") + companion object { - fun _json(): Optional = Optional.ofNullable(_json) + @JvmField val ACTIVE = of("active") - fun accept(visitor: Visitor): T { - return when { - planPhaseUsageDiscount != null -> - visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) - planPhaseAmountDiscount != null -> - visitor.visitPlanPhaseAmountDiscount(planPhaseAmountDiscount) - planPhasePercentageDiscount != null -> - visitor.visitPlanPhasePercentageDiscount(planPhasePercentageDiscount) - planPhaseMinimum != null -> visitor.visitPlanPhaseMinimum(planPhaseMinimum) - planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) - else -> visitor.unknown(_json) - } - } + @JvmField val ENDED = of("ended") - private var validated: Boolean = false + @JvmField val UPCOMING = of("upcoming") - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } - accept( - object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) { - planPhaseUsageDiscount.validate() - } - - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) { - planPhaseAmountDiscount.validate() - } - - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) { - planPhasePercentageDiscount.validate() - } - - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) { - planPhaseMinimum.validate() - } - - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) { - planPhaseMaximum.validate() - } - } - ) - validated = true - } + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + ENDED, + UPCOMING, + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * 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, + ENDED, + UPCOMING, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } - return /* spotless:off */ other is Adjustment && planPhaseUsageDiscount == other.planPhaseUsageDiscount && planPhaseAmountDiscount == other.planPhaseAmountDiscount && planPhasePercentageDiscount == other.planPhasePercentageDiscount && planPhaseMinimum == other.planPhaseMinimum && planPhaseMaximum == other.planPhaseMaximum /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(planPhaseUsageDiscount, planPhaseAmountDiscount, planPhasePercentageDiscount, planPhaseMinimum, planPhaseMaximum) /* spotless:on */ - - override fun toString(): String = - when { - planPhaseUsageDiscount != null -> - "Adjustment{planPhaseUsageDiscount=$planPhaseUsageDiscount}" - planPhaseAmountDiscount != null -> - "Adjustment{planPhaseAmountDiscount=$planPhaseAmountDiscount}" - planPhasePercentageDiscount != null -> - "Adjustment{planPhasePercentageDiscount=$planPhasePercentageDiscount}" - planPhaseMinimum != null -> "Adjustment{planPhaseMinimum=$planPhaseMinimum}" - planPhaseMaximum != null -> "Adjustment{planPhaseMaximum=$planPhaseMaximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } - - companion object { - - @JvmStatic - fun ofPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = Adjustment(planPhaseUsageDiscount = planPhaseUsageDiscount) - - @JvmStatic - fun ofPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = Adjustment(planPhaseAmountDiscount = planPhaseAmountDiscount) - - @JvmStatic - fun ofPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = Adjustment(planPhasePercentageDiscount = planPhasePercentageDiscount) - - @JvmStatic - fun ofPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment) = - Adjustment(planPhaseMinimum = planPhaseMinimum) - - @JvmStatic - fun ofPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment) = - Adjustment(planPhaseMaximum = planPhaseMaximum) - } - - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { - - fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ): T - - fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ): T - - fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ): T - - fun visitPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment): T - - fun visitPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment): T - - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } - - internal class Deserializer : BaseDeserializer(Adjustment::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = - json.asObject().getOrNull()?.get("adjustment_type")?.asString()?.getOrNull() - - when (adjustmentType) { - "usage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseUsageDiscount = it, _json = json) - } - } - "amount_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseAmountDiscount = it, _json = json) - } - } - "percentage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment( - planPhasePercentageDiscount = it, - _json = json, - ) - } - } - "minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMinimum = it, _json = json) - } - } - "maximum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMaximum = it, _json = json) - } - } - } - - return Adjustment(_json = json) - } - } - - internal class Serializer : BaseSerializer(Adjustment::class) { - - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.planPhaseUsageDiscount != null -> - generator.writeObject(value.planPhaseUsageDiscount) - value.planPhaseAmountDiscount != null -> - generator.writeObject(value.planPhaseAmountDiscount) - value.planPhasePercentageDiscount != null -> - generator.writeObject(value.planPhasePercentageDiscount) - value.planPhaseMinimum != null -> - generator.writeObject(value.planPhaseMinimum) - value.planPhaseMaximum != null -> - generator.writeObject(value.planPhaseMaximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") - } - } - } - - @NoAutoDetect - class PlanPhaseUsageDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonProperty("usage_discount") - @ExcludeMissing - private val usageDiscount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - /** - * The number of usage units by which to discount the price this adjustment applies - * to in a given billing period. - */ - fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - /** - * The number of usage units by which to discount the price this adjustment applies - * to in a given billing period. - */ - @JsonProperty("usage_discount") - @ExcludeMissing - fun _usageDiscount(): JsonField = usageDiscount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseUsageDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - planPhaseOrder() - reason() - usageDiscount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseUsageDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var usageDiscount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - planPhaseUsageDiscountAdjustment: PlanPhaseUsageDiscountAdjustment - ) = apply { - id = planPhaseUsageDiscountAdjustment.id - adjustmentType = planPhaseUsageDiscountAdjustment.adjustmentType - appliesToPriceIds = - planPhaseUsageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseUsageDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseUsageDiscountAdjustment.planPhaseOrder - reason = planPhaseUsageDiscountAdjustment.reason - usageDiscount = planPhaseUsageDiscountAdjustment.usageDiscount - additionalProperties = - planPhaseUsageDiscountAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - /** - * The number of usage units by which to discount the price this adjustment - * applies to in a given billing period. - */ - fun usageDiscount(usageDiscount: Double) = - usageDiscount(JsonField.of(usageDiscount)) - - /** - * The number of usage units by which to discount the price this adjustment - * applies to in a given billing period. - */ - fun usageDiscount(usageDiscount: JsonField) = apply { - this.usageDiscount = usageDiscount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseUsageDiscountAdjustment = - PlanPhaseUsageDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - checkRequired("usageDiscount", usageDiscount), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - USAGE_DISCOUNT -> Known.USAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseUsageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, planPhaseOrder, reason, usageDiscount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseUsageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhaseAmountDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("amount_discount") - @ExcludeMissing - private val amountDiscount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** - * The amount by which to discount the prices this adjustment applies to in a given - * billing period. - */ - fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** - * The amount by which to discount the prices this adjustment applies to in a given - * billing period. - */ - @JsonProperty("amount_discount") - @ExcludeMissing - fun _amountDiscount(): JsonField = amountDiscount - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseAmountDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - amountDiscount() - appliesToPriceIds() - isInvoiceLevel() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseAmountDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var amountDiscount: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - planPhaseAmountDiscountAdjustment: PlanPhaseAmountDiscountAdjustment - ) = apply { - id = planPhaseAmountDiscountAdjustment.id - adjustmentType = planPhaseAmountDiscountAdjustment.adjustmentType - amountDiscount = planPhaseAmountDiscountAdjustment.amountDiscount - appliesToPriceIds = - planPhaseAmountDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseAmountDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseAmountDiscountAdjustment.planPhaseOrder - reason = planPhaseAmountDiscountAdjustment.reason - additionalProperties = - planPhaseAmountDiscountAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** - * The amount by which to discount the prices this adjustment applies to in a - * given billing period. - */ - fun amountDiscount(amountDiscount: String) = - amountDiscount(JsonField.of(amountDiscount)) - - /** - * The amount by which to discount the prices this adjustment applies to in a - * given billing period. - */ - fun amountDiscount(amountDiscount: JsonField) = apply { - this.amountDiscount = amountDiscount - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseAmountDiscountAdjustment = - PlanPhaseAmountDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("amountDiscount", amountDiscount), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseAmountDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, amountDiscount, appliesToPriceIds, isInvoiceLevel, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseAmountDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhasePercentageDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("percentage_discount") - @ExcludeMissing - private val percentageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(): Double = - percentageDiscount.getRequired("percentage_discount") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - @JsonProperty("percentage_discount") - @ExcludeMissing - fun _percentageDiscount(): JsonField = percentageDiscount - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhasePercentageDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - percentageDiscount() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhasePercentageDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var percentageDiscount: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - planPhasePercentageDiscountAdjustment: PlanPhasePercentageDiscountAdjustment - ) = apply { - id = planPhasePercentageDiscountAdjustment.id - adjustmentType = planPhasePercentageDiscountAdjustment.adjustmentType - appliesToPriceIds = - planPhasePercentageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhasePercentageDiscountAdjustment.isInvoiceLevel - percentageDiscount = - planPhasePercentageDiscountAdjustment.percentageDiscount - planPhaseOrder = planPhasePercentageDiscountAdjustment.planPhaseOrder - reason = planPhasePercentageDiscountAdjustment.reason - additionalProperties = - planPhasePercentageDiscountAdjustment.additionalProperties - .toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(percentageDiscount: Double) = - percentageDiscount(JsonField.of(percentageDiscount)) - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(percentageDiscount: JsonField) = apply { - this.percentageDiscount = percentageDiscount - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhasePercentageDiscountAdjustment = - PlanPhasePercentageDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("percentageDiscount", percentageDiscount), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val PERCENTAGE_DISCOUNT = of("percentage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhasePercentageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, percentageDiscount, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhasePercentageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhaseMinimumAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(): String = itemId.getRequired("item_id") - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The item ID that revenue from this minimum will be attributed to. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseMinimumAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - itemId() - minimumAmount() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseMinimumAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var itemId: JsonField? = null - private var minimumAmount: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(planPhaseMinimumAdjustment: PlanPhaseMinimumAdjustment) = - apply { - id = planPhaseMinimumAdjustment.id - adjustmentType = planPhaseMinimumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMinimumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMinimumAdjustment.isInvoiceLevel - itemId = planPhaseMinimumAdjustment.itemId - minimumAmount = planPhaseMinimumAdjustment.minimumAmount - planPhaseOrder = planPhaseMinimumAdjustment.planPhaseOrder - reason = planPhaseMinimumAdjustment.reason - additionalProperties = - planPhaseMinimumAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseMinimumAdjustment = - PlanPhaseMinimumAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("itemId", itemId), - checkRequired("minimumAmount", minimumAmount), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseMinimumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, itemId, minimumAmount, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseMinimumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhaseMaximumAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseMaximumAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - maximumAmount() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseMaximumAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var maximumAmount: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(planPhaseMaximumAdjustment: PlanPhaseMaximumAdjustment) = - apply { - id = planPhaseMaximumAdjustment.id - adjustmentType = planPhaseMaximumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMaximumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMaximumAdjustment.isInvoiceLevel - maximumAmount = planPhaseMaximumAdjustment.maximumAmount - planPhaseOrder = planPhaseMaximumAdjustment.planPhaseOrder - reason = planPhaseMaximumAdjustment.reason - additionalProperties = - planPhaseMaximumAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseMaximumAdjustment = - PlanPhaseMaximumAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("maximumAmount", maximumAmount), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseMaximumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, maximumAmount, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseMaximumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentInterval && id == other.id && adjustment == other.adjustment && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustment, appliesToPriceIntervalIds, endDate, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AdjustmentInterval{id=$id, adjustment=$adjustment, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BillingCycleAnchorConfiguration - @JsonCreator - private constructor( - @JsonProperty("day") @ExcludeMissing private val day: JsonField = JsonMissing.of(), - @JsonProperty("month") - @ExcludeMissing - private val month: JsonField = JsonMissing.of(), - @JsonProperty("year") @ExcludeMissing private val year: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun day(): Long = day.getRequired("day") - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(): Optional = Optional.ofNullable(month.getNullable("month")) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on - * 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(): Optional = Optional.ofNullable(year.getNullable("year")) - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - @JsonProperty("day") @ExcludeMissing fun _day(): JsonField = day - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - @JsonProperty("month") @ExcludeMissing fun _month(): JsonField = month - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on - * 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - @JsonProperty("year") @ExcludeMissing fun _year(): JsonField = year - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleAnchorConfiguration = apply { - if (validated) { - return@apply - } - - day() - month() - year() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleAnchorConfiguration]. */ - class Builder internal constructor() { - - private var day: JsonField? = null - private var month: JsonField = JsonMissing.of() - private var year: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration) = - apply { - day = billingCycleAnchorConfiguration.day - month = billingCycleAnchorConfiguration.month - year = billingCycleAnchorConfiguration.year - additionalProperties = - billingCycleAnchorConfiguration.additionalProperties.toMutableMap() - } - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun day(day: Long) = day(JsonField.of(day)) - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun day(day: JsonField) = apply { this.day = day } - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(month: Long?) = month(JsonField.ofNullable(month)) - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(month: Long) = month(month as Long?) - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun month(month: Optional) = month(month.orElse(null) as Long?) - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(month: JsonField) = apply { this.month = month } - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(year: Long?) = year(JsonField.ofNullable(year)) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(year: Long) = year(year as Long?) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun year(year: Optional) = year(year.orElse(null) as Long?) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(year: JsonField) = apply { this.year = year } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleAnchorConfiguration = - BillingCycleAnchorConfiguration( - checkRequired("day", day), - month, - year, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleAnchorConfiguration && day == other.day && month == other.month && year == other.year && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(day, month, year, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleAnchorConfiguration{day=$day, month=$month, year=$year, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(using = DiscountInterval.Deserializer::class) - @JsonSerialize(using = DiscountInterval.Serializer::class) - class DiscountInterval - private constructor( - private val amount: AmountDiscountInterval? = null, - private val percentage: PercentageDiscountInterval? = null, - private val usage: UsageDiscountInterval? = null, - private val _json: JsonValue? = null, - ) { - - fun amount(): Optional = Optional.ofNullable(amount) - - fun percentage(): Optional = Optional.ofNullable(percentage) - - fun usage(): Optional = Optional.ofNullable(usage) - - fun isAmount(): Boolean = amount != null - - fun isPercentage(): Boolean = percentage != null - - fun isUsage(): Boolean = usage != null - - fun asAmount(): AmountDiscountInterval = amount.getOrThrow("amount") - - fun asPercentage(): PercentageDiscountInterval = percentage.getOrThrow("percentage") - - fun asUsage(): UsageDiscountInterval = usage.getOrThrow("usage") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - amount != null -> visitor.visitAmount(amount) - percentage != null -> visitor.visitPercentage(percentage) - usage != null -> visitor.visitUsage(usage) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): DiscountInterval = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitAmount(amount: AmountDiscountInterval) { - amount.validate() - } - - override fun visitPercentage(percentage: PercentageDiscountInterval) { - percentage.validate() - } - - override fun visitUsage(usage: UsageDiscountInterval) { - usage.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountInterval && amount == other.amount && percentage == other.percentage && usage == other.usage /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(amount, percentage, usage) /* spotless:on */ - - override fun toString(): String = - when { - amount != null -> "DiscountInterval{amount=$amount}" - percentage != null -> "DiscountInterval{percentage=$percentage}" - usage != null -> "DiscountInterval{usage=$usage}" - _json != null -> "DiscountInterval{_unknown=$_json}" - else -> throw IllegalStateException("Invalid DiscountInterval") - } - - companion object { - - @JvmStatic - fun ofAmount(amount: AmountDiscountInterval) = DiscountInterval(amount = amount) - - @JvmStatic - fun ofPercentage(percentage: PercentageDiscountInterval) = - DiscountInterval(percentage = percentage) - - @JvmStatic fun ofUsage(usage: UsageDiscountInterval) = DiscountInterval(usage = usage) - } - - /** - * An interface that defines how to map each variant of [DiscountInterval] to a value of - * type [T]. - */ - interface Visitor { - - fun visitAmount(amount: AmountDiscountInterval): T - - fun visitPercentage(percentage: PercentageDiscountInterval): T - - fun visitUsage(usage: UsageDiscountInterval): T - - /** - * Maps an unknown variant of [DiscountInterval] to a value of type [T]. - * - * An instance of [DiscountInterval] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown DiscountInterval: $json") - } - } - - internal class Deserializer : BaseDeserializer(DiscountInterval::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): DiscountInterval { - val json = JsonValue.fromJsonNode(node) - val discountType = - json.asObject().getOrNull()?.get("discount_type")?.asString()?.getOrNull() - - when (discountType) { - "amount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(amount = it, _json = json) - } - } - "percentage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(percentage = it, _json = json) - } - } - "usage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(usage = it, _json = json) - } - } - } - - return DiscountInterval(_json = json) - } - } - - internal class Serializer : BaseSerializer(DiscountInterval::class) { - - override fun serialize( - value: DiscountInterval, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.amount != null -> generator.writeObject(value.amount) - value.percentage != null -> generator.writeObject(value.percentage) - value.usage != null -> generator.writeObject(value.usage) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid DiscountInterval") - } - } - } - - @NoAutoDetect - class AmountDiscountInterval - @JsonCreator - private constructor( - @JsonProperty("amount_discount") - @ExcludeMissing - private val amountDiscount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("discount_type") - @ExcludeMissing - private val discountType: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - fun discountType(): DiscountType = discountType.getRequired("discount_type") - - /** The end date of the discount interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** The start date of the discount interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** Only available if discount_type is `amount`. */ - @JsonProperty("amount_discount") - @ExcludeMissing - fun _amountDiscount(): JsonField = amountDiscount - - /** The price ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - - /** The end date of the discount interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** The start date of the discount interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AmountDiscountInterval = apply { - if (validated) { - return@apply - } - - amountDiscount() - appliesToPriceIds() - appliesToPriceIntervalIds() - discountType() - endDate() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AmountDiscountInterval]. */ - class Builder internal constructor() { - - private var amountDiscount: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { - amountDiscount = amountDiscountInterval.amountDiscount - appliesToPriceIds = - amountDiscountInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - amountDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = amountDiscountInterval.discountType - endDate = amountDiscountInterval.endDate - startDate = amountDiscountInterval.startDate - additionalProperties = - amountDiscountInterval.additionalProperties.toMutableMap() - } - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(amountDiscount: String) = - amountDiscount(JsonField.of(amountDiscount)) - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(amountDiscount: JsonField) = apply { - this.amountDiscount = amountDiscount - } - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this discount interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this discount interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the discount interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the discount interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** The start date of the discount interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the discount interval. */ - 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) - } - - fun build(): AmountDiscountInterval = - AmountDiscountInterval( - checkRequired("amountDiscount", amountDiscount), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("discountType", discountType), - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val AMOUNT = of("amount") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - AMOUNT - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT -> Value.AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AMOUNT -> Known.AMOUNT - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AmountDiscountInterval && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amountDiscount, appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AmountDiscountInterval{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PercentageDiscountInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("discount_type") - @ExcludeMissing - private val discountType: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("percentage_discount") - @ExcludeMissing - private val percentageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - fun discountType(): DiscountType = discountType.getRequired("discount_type") - - /** The end date of the discount interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ - fun percentageDiscount(): Double = percentageDiscount.getRequired("percentage_discount") - - /** The start date of the discount interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** The price ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - - /** The end date of the discount interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ - @JsonProperty("percentage_discount") - @ExcludeMissing - fun _percentageDiscount(): JsonField = percentageDiscount - - /** The start date of the discount interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PercentageDiscountInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - discountType() - endDate() - percentageDiscount() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PercentageDiscountInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null - private var endDate: JsonField? = null - private var percentageDiscount: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { - appliesToPriceIds = - percentageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - percentageDiscountInterval.appliesToPriceIntervalIds.map { - it.toMutableList() - } - discountType = percentageDiscountInterval.discountType - endDate = percentageDiscountInterval.endDate - percentageDiscount = percentageDiscountInterval.percentageDiscount - startDate = percentageDiscountInterval.startDate - additionalProperties = - percentageDiscountInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this discount interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this discount interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the discount interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the discount interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** - * Only available if discount_type is `percentage`.This is a number between 0 and 1. - */ - fun percentageDiscount(percentageDiscount: Double) = - percentageDiscount(JsonField.of(percentageDiscount)) - - /** - * Only available if discount_type is `percentage`.This is a number between 0 and 1. - */ - fun percentageDiscount(percentageDiscount: JsonField) = apply { - this.percentageDiscount = percentageDiscount - } - - /** The start date of the discount interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the discount interval. */ - 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) - } - - fun build(): PercentageDiscountInterval = - PercentageDiscountInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("discountType", discountType), - checkRequired("endDate", endDate), - checkRequired("percentageDiscount", percentageDiscount), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val PERCENTAGE = of("percentage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - PERCENTAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE -> Value.PERCENTAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PERCENTAGE -> Known.PERCENTAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PercentageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, percentageDiscount, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PercentageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class UsageDiscountInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("discount_type") - @ExcludeMissing - private val discountType: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonProperty("usage_discount") - @ExcludeMissing - private val usageDiscount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - fun discountType(): DiscountType = discountType.getRequired("discount_type") - - /** The end date of the discount interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** The start date of the discount interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** - * Only available if discount_type is `usage`. Number of usage units that this discount - * is for - */ - fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - - /** The price ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - - /** The end date of the discount interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** The start date of the discount interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - /** - * Only available if discount_type is `usage`. Number of usage units that this discount - * is for - */ - @JsonProperty("usage_discount") - @ExcludeMissing - fun _usageDiscount(): JsonField = usageDiscount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): UsageDiscountInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - discountType() - endDate() - startDate() - usageDiscount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UsageDiscountInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var usageDiscount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { - appliesToPriceIds = - usageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - usageDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = usageDiscountInterval.discountType - endDate = usageDiscountInterval.endDate - startDate = usageDiscountInterval.startDate - usageDiscount = usageDiscountInterval.usageDiscount - additionalProperties = usageDiscountInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this discount interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this discount interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the discount interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the discount interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** The start date of the discount interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the discount interval. */ - fun startDate(startDate: JsonField) = apply { - this.startDate = startDate - } - - /** - * Only available if discount_type is `usage`. Number of usage units that this - * discount is for - */ - fun usageDiscount(usageDiscount: Double) = - usageDiscount(JsonField.of(usageDiscount)) - - /** - * Only available if discount_type is `usage`. Number of usage units that this - * discount is for - */ - fun usageDiscount(usageDiscount: JsonField) = apply { - this.usageDiscount = usageDiscount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): UsageDiscountInterval = - UsageDiscountInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("discountType", discountType), - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - checkRequired("usageDiscount", usageDiscount), - additionalProperties.toImmutable(), - ) - } - - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE = of("usage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - USAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE -> Value.USAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE -> Known.USAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UsageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, startDate, usageDiscount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UsageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" - } - } - - @NoAutoDetect - class FixedFeeQuantitySchedule - @JsonCreator - private constructor( - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("price_id") - @ExcludeMissing - private val priceId: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - private val quantity: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - fun priceId(): String = priceId.getRequired("price_id") - - fun quantity(): Double = quantity.getRequired("quantity") - - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - - @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): FixedFeeQuantitySchedule = apply { - if (validated) { - return@apply - } - - endDate() - priceId() - quantity() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FixedFeeQuantitySchedule]. */ - class Builder internal constructor() { - - private var endDate: JsonField? = null - private var priceId: JsonField? = null - private var quantity: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = apply { - endDate = fixedFeeQuantitySchedule.endDate - priceId = fixedFeeQuantitySchedule.priceId - quantity = fixedFeeQuantitySchedule.quantity - startDate = fixedFeeQuantitySchedule.startDate - additionalProperties = fixedFeeQuantitySchedule.additionalProperties.toMutableMap() - } - - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) - - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - 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) - } - - fun build(): FixedFeeQuantitySchedule = - FixedFeeQuantitySchedule( - checkRequired("endDate", endDate), - checkRequired("priceId", priceId), - checkRequired("quantity", quantity), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FixedFeeQuantitySchedule && endDate == other.endDate && priceId == other.priceId && quantity == other.quantity && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(endDate, priceId, quantity, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "FixedFeeQuantitySchedule{endDate=$endDate, priceId=$priceId, quantity=$quantity, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class MaximumInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this maximum interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this maximum interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - /** The end date of the maximum interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** The start date of the maximum interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** The price ids that this maximum interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this maximum interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - /** The end date of the maximum interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** The start date of the maximum interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MaximumInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - endDate() - maximumAmount() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MaximumInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var endDate: JsonField? = null - private var maximumAmount: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximumInterval: MaximumInterval) = apply { - appliesToPriceIds = maximumInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - maximumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - endDate = maximumInterval.endDate - maximumAmount = maximumInterval.maximumAmount - startDate = maximumInterval.startDate - additionalProperties = maximumInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this maximum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this maximum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this maximum interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this maximum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this maximum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this maximum interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - /** The end date of the maximum interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the maximum interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the maximum interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** The start date of the maximum interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the maximum interval. */ - 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) - } - - fun build(): MaximumInterval = - MaximumInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("endDate", endDate), - checkRequired("maximumAmount", maximumAmount), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MaximumInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && maximumAmount == other.maximumAmount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, endDate, maximumAmount, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MaximumInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, maximumAmount=$maximumAmount, startDate=$startDate, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class MinimumInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this minimum interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this minimum interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - /** The end date of the minimum interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** The start date of the minimum interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** The price ids that this minimum interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this minimum interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - /** The end date of the minimum interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** The start date of the minimum interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MinimumInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - endDate() - minimumAmount() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MinimumInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var endDate: JsonField? = null - private var minimumAmount: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(minimumInterval: MinimumInterval) = apply { - appliesToPriceIds = minimumInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - minimumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - endDate = minimumInterval.endDate - minimumAmount = minimumInterval.minimumAmount - startDate = minimumInterval.startDate - additionalProperties = minimumInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this minimum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this minimum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this minimum interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this minimum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this minimum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this minimum interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - /** The end date of the minimum interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the minimum interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the minimum interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** The start date of the minimum interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the minimum interval. */ - 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) - } - - fun build(): MinimumInterval = - MinimumInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("endDate", endDate), - checkRequired("minimumAmount", minimumAmount), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MinimumInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && minimumAmount == other.minimumAmount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, endDate, minimumAmount, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MinimumInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, minimumAmount=$minimumAmount, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - /** - * The Price Interval resource represents a period of time for which a price will bill on a - * subscription. A subscription’s price intervals define its billing behavior. - */ - @NoAutoDetect - class PriceInterval - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_day") - @ExcludeMissing - private val billingCycleDay: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - private val currentBillingPeriodEndDate: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - private val currentBillingPeriodStartDate: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("filter") - @ExcludeMissing - private val filter: JsonField = JsonMissing.of(), - @JsonProperty("fixed_fee_quantity_transitions") - @ExcludeMissing - private val fixedFeeQuantityTransitions: JsonField> = - JsonMissing.of(), - @JsonProperty("price") - @ExcludeMissing - private val price: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonProperty("usage_customer_ids") - @ExcludeMissing - private val usageCustomerIds: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - /** The day of the month that Orb bills for this price */ - fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate(): Optional = - Optional.ofNullable( - currentBillingPeriodEndDate.getNullable("current_billing_period_end_date") - ) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodStartDate(): Optional = - Optional.ofNullable( - currentBillingPeriodStartDate.getNullable("current_billing_period_start_date") - ) - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** An additional filter to apply to usage queries. */ - fun filter(): Optional = Optional.ofNullable(filter.getNullable("filter")) - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions(): Optional> = - Optional.ofNullable( - fixedFeeQuantityTransitions.getNullable("fixed_fee_quantity_transitions") - ) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting in - * a charge on an invoice in the form of an invoice line item. Prices take a quantity and - * determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the key - * for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(): Price = price.getRequired("price") - - /** - * The start date of the price interval. This is the date that Orb starts billing for this - * price. - */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this price - * interval. - */ - fun usageCustomerIds(): Optional> = - Optional.ofNullable(usageCustomerIds.getNullable("usage_customer_ids")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** The day of the month that Orb bills for this price */ - @JsonProperty("billing_cycle_day") - @ExcludeMissing - fun _billingCycleDay(): JsonField = billingCycleDay - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if this price - * interval is not currently active. - */ - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - fun _currentBillingPeriodStartDate(): JsonField = - currentBillingPeriodStartDate - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** An additional filter to apply to usage queries. */ - @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField = filter - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - @JsonProperty("fixed_fee_quantity_transitions") - @ExcludeMissing - fun _fixedFeeQuantityTransitions(): JsonField> = - fixedFeeQuantityTransitions - - /** - * 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) - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - - /** - * The start date of the price interval. This is the date that Orb starts billing for this - * price. - */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this price - * interval. - */ - @JsonProperty("usage_customer_ids") - @ExcludeMissing - fun _usageCustomerIds(): JsonField> = usageCustomerIds - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PriceInterval = apply { - if (validated) { - return@apply - } - - id() - billingCycleDay() - currentBillingPeriodEndDate() - currentBillingPeriodStartDate() - endDate() - filter() - fixedFeeQuantityTransitions().ifPresent { it.forEach { it.validate() } } - price().validate() - startDate() - usageCustomerIds() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PriceInterval]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var billingCycleDay: JsonField? = null - private var currentBillingPeriodEndDate: JsonField? = null - private var currentBillingPeriodStartDate: JsonField? = null - private var endDate: JsonField? = null - private var filter: JsonField? = null - private var fixedFeeQuantityTransitions: - JsonField>? = - null - private var price: JsonField? = null - private var startDate: JsonField? = null - private var usageCustomerIds: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(priceInterval: PriceInterval) = apply { - id = priceInterval.id - billingCycleDay = priceInterval.billingCycleDay - currentBillingPeriodEndDate = priceInterval.currentBillingPeriodEndDate - currentBillingPeriodStartDate = priceInterval.currentBillingPeriodStartDate - endDate = priceInterval.endDate - filter = priceInterval.filter - fixedFeeQuantityTransitions = - priceInterval.fixedFeeQuantityTransitions.map { it.toMutableList() } - price = priceInterval.price - startDate = priceInterval.startDate - usageCustomerIds = priceInterval.usageCustomerIds.map { it.toMutableList() } - additionalProperties = priceInterval.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - /** The day of the month that Orb bills for this price */ - fun billingCycleDay(billingCycleDay: Long) = - billingCycleDay(JsonField.of(billingCycleDay)) - - /** The day of the month that Orb bills for this price */ - fun billingCycleDay(billingCycleDay: JsonField) = apply { - this.billingCycleDay = billingCycleDay - } - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = - currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = - currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate( - currentBillingPeriodEndDate: JsonField - ) = apply { this.currentBillingPeriodEndDate = currentBillingPeriodEndDate } - - /** - * The start date of the current billing period. This is an inclusive timestamp; the - * instant returned is exactly the beginning of the billing period. Set to null if this - * price interval is not currently active. - */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = - currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the - * instant returned is exactly the beginning of the billing period. Set to null if this - * price interval is not currently active. - */ - fun currentBillingPeriodStartDate( - currentBillingPeriodStartDate: Optional - ) = currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the - * instant returned is exactly the beginning of the billing period. Set to null if this - * price interval is not currently active. - */ - fun currentBillingPeriodStartDate( - currentBillingPeriodStartDate: JsonField - ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** An additional filter to apply to usage queries. */ - fun filter(filter: String?) = filter(JsonField.ofNullable(filter)) - - /** An additional filter to apply to usage queries. */ - fun filter(filter: Optional) = filter(filter.orElse(null)) - - /** An additional filter to apply to usage queries. */ - fun filter(filter: JsonField) = apply { this.filter = filter } - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: List? - ) = fixedFeeQuantityTransitions(JsonField.ofNullable(fixedFeeQuantityTransitions)) - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: Optional> - ) = fixedFeeQuantityTransitions(fixedFeeQuantityTransitions.orElse(null)) - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: JsonField> - ) = apply { - this.fixedFeeQuantityTransitions = - fixedFeeQuantityTransitions.map { it.toMutableList() } - } - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun addFixedFeeQuantityTransition( - fixedFeeQuantityTransition: FixedFeeQuantityTransition - ) = apply { - fixedFeeQuantityTransitions = - (fixedFeeQuantityTransitions ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(fixedFeeQuantityTransition) - } - } - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(price: Price) = price(JsonField.of(price)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(price: JsonField) = apply { this.price = price } - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(matrix: Price.MatrixPrice) = price(Price.ofMatrix(matrix)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredPackage: Price.TieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedTiered: Price.GroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(unitWithPercent: Price.UnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredWithProration: Price.TieredWithProrationPrice) = - price(Price.ofTieredWithProration(tieredWithProration)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(unitWithProration: Price.UnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedAllocation: Price.GroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bulkWithProration: Price.BulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = - price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice) = - price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - - /** - * The start date of the price interval. This is the date that Orb starts billing for - * this price. - */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** - * The start date of the price interval. This is the date that Orb starts billing for - * this price. - */ - fun startDate(startDate: JsonField) = apply { - this.startDate = startDate - } - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun usageCustomerIds(usageCustomerIds: List?) = - usageCustomerIds(JsonField.ofNullable(usageCustomerIds)) - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun usageCustomerIds(usageCustomerIds: Optional>) = - usageCustomerIds(usageCustomerIds.orElse(null)) - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun usageCustomerIds(usageCustomerIds: JsonField>) = apply { - this.usageCustomerIds = usageCustomerIds.map { it.toMutableList() } - } - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun addUsageCustomerId(usageCustomerId: String) = apply { - usageCustomerIds = - (usageCustomerIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(usageCustomerId) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): PriceInterval = - PriceInterval( - checkRequired("id", id), - checkRequired("billingCycleDay", billingCycleDay), - checkRequired("currentBillingPeriodEndDate", currentBillingPeriodEndDate), - checkRequired("currentBillingPeriodStartDate", currentBillingPeriodStartDate), - checkRequired("endDate", endDate), - checkRequired("filter", filter), - checkRequired("fixedFeeQuantityTransitions", fixedFeeQuantityTransitions).map { - it.toImmutable() - }, - checkRequired("price", price), - checkRequired("startDate", startDate), - checkRequired("usageCustomerIds", usageCustomerIds).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class FixedFeeQuantityTransition - @JsonCreator - private constructor( - @JsonProperty("effective_date") - @ExcludeMissing - private val effectiveDate: JsonField = JsonMissing.of(), - @JsonProperty("price_id") - @ExcludeMissing - private val priceId: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - private val quantity: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun effectiveDate(): OffsetDateTime = effectiveDate.getRequired("effective_date") - - fun priceId(): String = priceId.getRequired("price_id") - - fun quantity(): Long = quantity.getRequired("quantity") - - @JsonProperty("effective_date") - @ExcludeMissing - fun _effectiveDate(): JsonField = effectiveDate - - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - - @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): FixedFeeQuantityTransition = apply { - if (validated) { - return@apply - } - - effectiveDate() - priceId() - quantity() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FixedFeeQuantityTransition]. */ - class Builder internal constructor() { - - private var effectiveDate: JsonField? = null - private var priceId: JsonField? = null - private var quantity: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(fixedFeeQuantityTransition: FixedFeeQuantityTransition) = apply { - effectiveDate = fixedFeeQuantityTransition.effectiveDate - priceId = fixedFeeQuantityTransition.priceId - quantity = fixedFeeQuantityTransition.quantity - additionalProperties = - fixedFeeQuantityTransition.additionalProperties.toMutableMap() - } - - fun effectiveDate(effectiveDate: OffsetDateTime) = - effectiveDate(JsonField.of(effectiveDate)) - - fun effectiveDate(effectiveDate: JsonField) = apply { - this.effectiveDate = effectiveDate - } - - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) - - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - - fun quantity(quantity: Long) = quantity(JsonField.of(quantity)) - - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): FixedFeeQuantityTransition = - FixedFeeQuantityTransition( - checkRequired("effectiveDate", effectiveDate), - checkRequired("priceId", priceId), - checkRequired("quantity", quantity), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FixedFeeQuantityTransition && effectiveDate == other.effectiveDate && priceId == other.priceId && quantity == other.quantity && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(effectiveDate, priceId, quantity, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "FixedFeeQuantityTransition{effectiveDate=$effectiveDate, priceId=$priceId, quantity=$quantity, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PriceInterval && id == other.id && billingCycleDay == other.billingCycleDay && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && endDate == other.endDate && filter == other.filter && fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && price == other.price && startDate == other.startDate && usageCustomerIds == other.usageCustomerIds && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billingCycleDay, currentBillingPeriodEndDate, currentBillingPeriodStartDate, endDate, filter, fixedFeeQuantityTransitions, price, startDate, usageCustomerIds, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PriceInterval{id=$id, billingCycleDay=$billingCycleDay, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, endDate=$endDate, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, price=$price, startDate=$startDate, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class RedeemedCoupon - @JsonCreator - private constructor( - @JsonProperty("coupon_id") - @ExcludeMissing - private val couponId: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun couponId(): String = couponId.getRequired("coupon_id") - - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - @JsonProperty("coupon_id") @ExcludeMissing fun _couponId(): JsonField = couponId - - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): RedeemedCoupon = apply { - if (validated) { - return@apply - } - - couponId() - endDate() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RedeemedCoupon]. */ - class Builder internal constructor() { - - private var couponId: JsonField? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(redeemedCoupon: RedeemedCoupon) = apply { - couponId = redeemedCoupon.couponId - endDate = redeemedCoupon.endDate - startDate = redeemedCoupon.startDate - additionalProperties = redeemedCoupon.additionalProperties.toMutableMap() - } - - fun couponId(couponId: String) = couponId(JsonField.of(couponId)) - - fun couponId(couponId: JsonField) = apply { this.couponId = couponId } - - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - 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) - } - - fun build(): RedeemedCoupon = - RedeemedCoupon( - checkRequired("couponId", couponId), - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RedeemedCoupon && couponId == other.couponId && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(couponId, endDate, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RedeemedCoupon{couponId=$couponId, endDate=$endDate, startDate=$startDate, 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 ENDED = of("ended") - - @JvmField val UPCOMING = of("upcoming") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - ACTIVE, - ENDED, - UPCOMING, - } - - /** - * 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, - ENDED, - UPCOMING, - /** 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 - ENDED -> Value.ENDED - UPCOMING -> Value.UPCOMING - else -> Value._UNKNOWN + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead 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 + ENDED -> Value.ENDED + UPCOMING -> Value.UPCOMING + else -> Value._UNKNOWN } /** @@ -7057,105 +1424,6 @@ private constructor( override fun toString() = value.toString() } - @NoAutoDetect - class TrialInfo - @JsonCreator - private constructor( - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TrialInfo = apply { - if (validated) { - return@apply - } - - endDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TrialInfo]. */ - class Builder internal constructor() { - - private var endDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(trialInfo: TrialInfo) = apply { - endDate = trialInfo.endDate - additionalProperties = trialInfo.additionalProperties.toMutableMap() - } - - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - 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) - } - - fun build(): TrialInfo = - TrialInfo(checkRequired("endDate", endDate), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TrialInfo && endDate == other.endDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(endDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TrialInfo{endDate=$endDate, 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/SubscriptionCancelParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelParams.kt index 2f92b266d..005344a3a 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 @@ -215,6 +215,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .cancelOption() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -348,6 +356,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [SubscriptionCancelParams]. + * + * The following fields are required: + * ```java + * .subscriptionId() + * .cancelOption() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelResponse.kt deleted file mode 100644 index ea64fb832..000000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelResponse.kt +++ /dev/null @@ -1,7163 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer -import com.withorb.api.core.Enum -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow -import com.withorb.api.core.immutableEmptyMap -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -@NoAutoDetect -class SubscriptionCancelResponse -@JsonCreator -private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("active_plan_phase_order") - @ExcludeMissing - private val activePlanPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_intervals") - @ExcludeMissing - private val adjustmentIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("auto_collection") - @ExcludeMissing - private val autoCollection: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_anchor_configuration") - @ExcludeMissing - private val billingCycleAnchorConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("billing_cycle_day") - @ExcludeMissing - private val billingCycleDay: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - private val currentBillingPeriodEndDate: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - private val currentBillingPeriodStartDate: JsonField = JsonMissing.of(), - @JsonProperty("customer") - @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), - @JsonProperty("default_invoice_memo") - @ExcludeMissing - private val defaultInvoiceMemo: JsonField = JsonMissing.of(), - @JsonProperty("discount_intervals") - @ExcludeMissing - private val discountIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("fixed_fee_quantity_schedule") - @ExcludeMissing - private val fixedFeeQuantitySchedule: JsonField> = - JsonMissing.of(), - @JsonProperty("invoicing_threshold") - @ExcludeMissing - private val invoicingThreshold: JsonField = JsonMissing.of(), - @JsonProperty("maximum_intervals") - @ExcludeMissing - private val maximumIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("minimum_intervals") - @ExcludeMissing - private val minimumIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("net_terms") - @ExcludeMissing - private val netTerms: JsonField = JsonMissing.of(), - @JsonProperty("plan") @ExcludeMissing private val plan: JsonField = JsonMissing.of(), - @JsonProperty("price_intervals") - @ExcludeMissing - private val priceIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("redeemed_coupon") - @ExcludeMissing - private val redeemedCoupon: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonProperty("status") - @ExcludeMissing - private val status: JsonField = JsonMissing.of(), - @JsonProperty("trial_info") - @ExcludeMissing - private val trialInfo: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun id(): String = id.getRequired("id") - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(): Optional = - Optional.ofNullable(activePlanPhaseOrder.getNullable("active_plan_phase_order")) - - /** The adjustment intervals for this subscription. */ - fun adjustmentIntervals(): List = - adjustmentIntervals.getRequired("adjustment_intervals") - - /** - * Determines whether issued invoices for this subscription will automatically be charged with - * the saved payment method on the due date. This property defaults to the plan's behavior. If - * null, defaults to the customer's setting. - */ - fun autoCollection(): Optional = - Optional.ofNullable(autoCollection.getNullable("auto_collection")) - - fun billingCycleAnchorConfiguration(): BillingCycleAnchorConfiguration = - billingCycleAnchorConfiguration.getRequired("billing_cycle_anchor_configuration") - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of days in - * a month is greater than this value, the last day of the month is the billing cycle day (e.g. - * billing_cycle_day=31 for April means the billing period begins on the 30th. - */ - fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the instant - * returned is not part of the billing period. Set to null for subscriptions that are not - * currently active. - */ - fun currentBillingPeriodEndDate(): Optional = - Optional.ofNullable( - currentBillingPeriodEndDate.getNullable("current_billing_period_end_date") - ) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription is - * not currently active. - */ - fun currentBillingPeriodStartDate(): Optional = - Optional.ofNullable( - currentBillingPeriodStartDate.getNullable("current_billing_period_start_date") - ) - - /** - * 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 customer(): Customer = customer.getRequired("customer") - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(): Optional = - Optional.ofNullable(defaultInvoiceMemo.getNullable("default_invoice_memo")) - - /** The discount intervals for this subscription. */ - fun discountIntervals(): List = - discountIntervals.getRequired("discount_intervals") - - /** The date Orb stops billing for this subscription. */ - fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) - - fun fixedFeeQuantitySchedule(): List = - fixedFeeQuantitySchedule.getRequired("fixed_fee_quantity_schedule") - - fun invoicingThreshold(): Optional = - Optional.ofNullable(invoicingThreshold.getNullable("invoicing_threshold")) - - /** The maximum intervals for this subscription. */ - fun maximumIntervals(): List = - maximumIntervals.getRequired("maximum_intervals") - - /** - * 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.getRequired("metadata") - - /** The minimum intervals for this subscription. */ - fun minimumIntervals(): List = - minimumIntervals.getRequired("minimum_intervals") - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - fun netTerms(): Long = netTerms.getRequired("net_terms") - - /** - * 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 plan(): Plan = plan.getRequired("plan") - - /** The price intervals for this subscription. */ - fun priceIntervals(): List = priceIntervals.getRequired("price_intervals") - - fun redeemedCoupon(): Optional = - Optional.ofNullable(redeemedCoupon.getNullable("redeemed_coupon")) - - /** The date Orb starts billing for this subscription. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - fun status(): Status = status.getRequired("status") - - fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - @JsonProperty("active_plan_phase_order") - @ExcludeMissing - fun _activePlanPhaseOrder(): JsonField = activePlanPhaseOrder - - /** The adjustment intervals for this subscription. */ - @JsonProperty("adjustment_intervals") - @ExcludeMissing - fun _adjustmentIntervals(): JsonField> = adjustmentIntervals - - /** - * Determines whether issued invoices for this subscription will automatically be charged with - * the saved payment method on the due date. This property defaults to the plan's behavior. If - * null, defaults to the customer's setting. - */ - @JsonProperty("auto_collection") - @ExcludeMissing - fun _autoCollection(): JsonField = autoCollection - - @JsonProperty("billing_cycle_anchor_configuration") - @ExcludeMissing - fun _billingCycleAnchorConfiguration(): JsonField = - billingCycleAnchorConfiguration - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of days in - * a month is greater than this value, the last day of the month is the billing cycle day (e.g. - * billing_cycle_day=31 for April means the billing period begins on the 30th. - */ - @JsonProperty("billing_cycle_day") - @ExcludeMissing - fun _billingCycleDay(): JsonField = billingCycleDay - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the instant - * returned is not part of the billing period. Set to null for subscriptions that are not - * currently active. - */ - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription is - * not currently active. - */ - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - fun _currentBillingPeriodStartDate(): JsonField = currentBillingPeriodStartDate - - /** - * 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. - */ - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - @JsonProperty("default_invoice_memo") - @ExcludeMissing - fun _defaultInvoiceMemo(): JsonField = defaultInvoiceMemo - - /** The discount intervals for this subscription. */ - @JsonProperty("discount_intervals") - @ExcludeMissing - fun _discountIntervals(): JsonField> = discountIntervals - - /** The date Orb stops billing for this subscription. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate - - @JsonProperty("fixed_fee_quantity_schedule") - @ExcludeMissing - fun _fixedFeeQuantitySchedule(): JsonField> = - fixedFeeQuantitySchedule - - @JsonProperty("invoicing_threshold") - @ExcludeMissing - fun _invoicingThreshold(): JsonField = invoicingThreshold - - /** The maximum intervals for this subscription. */ - @JsonProperty("maximum_intervals") - @ExcludeMissing - fun _maximumIntervals(): JsonField> = maximumIntervals - - /** - * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - /** The minimum intervals for this subscription. */ - @JsonProperty("minimum_intervals") - @ExcludeMissing - fun _minimumIntervals(): JsonField> = minimumIntervals - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms - - /** - * 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). - */ - @JsonProperty("plan") @ExcludeMissing fun _plan(): JsonField = plan - - /** The price intervals for this subscription. */ - @JsonProperty("price_intervals") - @ExcludeMissing - fun _priceIntervals(): JsonField> = priceIntervals - - @JsonProperty("redeemed_coupon") - @ExcludeMissing - fun _redeemedCoupon(): JsonField = redeemedCoupon - - /** The date Orb starts billing for this subscription. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo(): JsonField = trialInfo - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): SubscriptionCancelResponse = apply { - if (validated) { - return@apply - } - - id() - activePlanPhaseOrder() - adjustmentIntervals().forEach { it.validate() } - autoCollection() - billingCycleAnchorConfiguration().validate() - billingCycleDay() - createdAt() - currentBillingPeriodEndDate() - currentBillingPeriodStartDate() - customer().validate() - defaultInvoiceMemo() - discountIntervals().forEach { it.validate() } - endDate() - fixedFeeQuantitySchedule().forEach { it.validate() } - invoicingThreshold() - maximumIntervals().forEach { it.validate() } - metadata().validate() - minimumIntervals().forEach { it.validate() } - netTerms() - plan().validate() - priceIntervals().forEach { it.validate() } - redeemedCoupon().ifPresent { it.validate() } - startDate() - status() - trialInfo().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SubscriptionCancelResponse]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var activePlanPhaseOrder: JsonField? = null - private var adjustmentIntervals: JsonField>? = null - private var autoCollection: JsonField? = null - private var billingCycleAnchorConfiguration: JsonField? = - null - private var billingCycleDay: JsonField? = null - private var createdAt: JsonField? = null - private var currentBillingPeriodEndDate: JsonField? = null - private var currentBillingPeriodStartDate: JsonField? = null - private var customer: JsonField? = null - private var defaultInvoiceMemo: JsonField? = null - private var discountIntervals: JsonField>? = null - private var endDate: JsonField? = null - private var fixedFeeQuantitySchedule: JsonField>? = - null - private var invoicingThreshold: JsonField? = null - private var maximumIntervals: JsonField>? = null - private var metadata: JsonField? = null - private var minimumIntervals: JsonField>? = null - private var netTerms: JsonField? = null - private var plan: JsonField? = null - private var priceIntervals: JsonField>? = null - private var redeemedCoupon: JsonField? = null - private var startDate: JsonField? = null - private var status: JsonField? = null - private var trialInfo: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(subscriptionCancelResponse: SubscriptionCancelResponse) = apply { - id = subscriptionCancelResponse.id - activePlanPhaseOrder = subscriptionCancelResponse.activePlanPhaseOrder - adjustmentIntervals = - subscriptionCancelResponse.adjustmentIntervals.map { it.toMutableList() } - autoCollection = subscriptionCancelResponse.autoCollection - billingCycleAnchorConfiguration = - subscriptionCancelResponse.billingCycleAnchorConfiguration - billingCycleDay = subscriptionCancelResponse.billingCycleDay - createdAt = subscriptionCancelResponse.createdAt - currentBillingPeriodEndDate = subscriptionCancelResponse.currentBillingPeriodEndDate - currentBillingPeriodStartDate = subscriptionCancelResponse.currentBillingPeriodStartDate - customer = subscriptionCancelResponse.customer - defaultInvoiceMemo = subscriptionCancelResponse.defaultInvoiceMemo - discountIntervals = - subscriptionCancelResponse.discountIntervals.map { it.toMutableList() } - endDate = subscriptionCancelResponse.endDate - fixedFeeQuantitySchedule = - subscriptionCancelResponse.fixedFeeQuantitySchedule.map { it.toMutableList() } - invoicingThreshold = subscriptionCancelResponse.invoicingThreshold - maximumIntervals = - subscriptionCancelResponse.maximumIntervals.map { it.toMutableList() } - metadata = subscriptionCancelResponse.metadata - minimumIntervals = - subscriptionCancelResponse.minimumIntervals.map { it.toMutableList() } - netTerms = subscriptionCancelResponse.netTerms - plan = subscriptionCancelResponse.plan - priceIntervals = subscriptionCancelResponse.priceIntervals.map { it.toMutableList() } - redeemedCoupon = subscriptionCancelResponse.redeemedCoupon - startDate = subscriptionCancelResponse.startDate - status = subscriptionCancelResponse.status - trialInfo = subscriptionCancelResponse.trialInfo - additionalProperties = subscriptionCancelResponse.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(activePlanPhaseOrder: Long?) = - activePlanPhaseOrder(JsonField.ofNullable(activePlanPhaseOrder)) - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(activePlanPhaseOrder: Long) = - activePlanPhaseOrder(activePlanPhaseOrder as Long?) - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun activePlanPhaseOrder(activePlanPhaseOrder: Optional) = - activePlanPhaseOrder(activePlanPhaseOrder.orElse(null) as Long?) - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(activePlanPhaseOrder: JsonField) = apply { - this.activePlanPhaseOrder = activePlanPhaseOrder - } - - /** The adjustment intervals for this subscription. */ - fun adjustmentIntervals(adjustmentIntervals: List) = - adjustmentIntervals(JsonField.of(adjustmentIntervals)) - - /** The adjustment intervals for this subscription. */ - fun adjustmentIntervals(adjustmentIntervals: JsonField>) = apply { - this.adjustmentIntervals = adjustmentIntervals.map { it.toMutableList() } - } - - /** The adjustment intervals for this subscription. */ - fun addAdjustmentInterval(adjustmentInterval: AdjustmentInterval) = apply { - adjustmentIntervals = - (adjustmentIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(adjustmentInterval) - } - } - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - fun autoCollection(autoCollection: Boolean?) = - autoCollection(JsonField.ofNullable(autoCollection)) - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun autoCollection(autoCollection: Optional) = - autoCollection(autoCollection.orElse(null) as Boolean?) - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - fun autoCollection(autoCollection: JsonField) = apply { - this.autoCollection = autoCollection - } - - fun billingCycleAnchorConfiguration( - billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration - ) = billingCycleAnchorConfiguration(JsonField.of(billingCycleAnchorConfiguration)) - - fun billingCycleAnchorConfiguration( - billingCycleAnchorConfiguration: JsonField - ) = apply { this.billingCycleAnchorConfiguration = billingCycleAnchorConfiguration } - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun billingCycleDay(billingCycleDay: Long) = billingCycleDay(JsonField.of(billingCycleDay)) - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun billingCycleDay(billingCycleDay: JsonField) = apply { - this.billingCycleDay = billingCycleDay - } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is not part of the billing period. Set to null for subscriptions that - * are not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = - currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is not part of the billing period. Set to null for subscriptions that - * are not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = - currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is not part of the billing period. Set to null for subscriptions that - * are not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: JsonField) = - apply { - this.currentBillingPeriodEndDate = currentBillingPeriodEndDate - } - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription - * is not currently active. - */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = - currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription - * is not currently active. - */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: Optional) = - currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription - * is not currently active. - */ - fun currentBillingPeriodStartDate( - currentBillingPeriodStartDate: JsonField - ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } - - /** - * 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 customer(customer: Customer) = customer(JsonField.of(customer)) - - /** - * 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 customer(customer: JsonField) = apply { this.customer = customer } - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(defaultInvoiceMemo: String?) = - defaultInvoiceMemo(JsonField.ofNullable(defaultInvoiceMemo)) - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(defaultInvoiceMemo: Optional) = - defaultInvoiceMemo(defaultInvoiceMemo.orElse(null)) - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(defaultInvoiceMemo: JsonField) = apply { - this.defaultInvoiceMemo = defaultInvoiceMemo - } - - /** The discount intervals for this subscription. */ - fun discountIntervals(discountIntervals: List) = - discountIntervals(JsonField.of(discountIntervals)) - - /** The discount intervals for this subscription. */ - fun discountIntervals(discountIntervals: JsonField>) = apply { - this.discountIntervals = discountIntervals.map { it.toMutableList() } - } - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(discountInterval: DiscountInterval) = apply { - discountIntervals = - (discountIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(discountInterval) - } - } - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(amount: DiscountInterval.AmountDiscountInterval) = - addDiscountInterval(DiscountInterval.ofAmount(amount)) - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(percentage: DiscountInterval.PercentageDiscountInterval) = - addDiscountInterval(DiscountInterval.ofPercentage(percentage)) - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(usage: DiscountInterval.UsageDiscountInterval) = - addDiscountInterval(DiscountInterval.ofUsage(usage)) - - /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - fun fixedFeeQuantitySchedule(fixedFeeQuantitySchedule: List) = - fixedFeeQuantitySchedule(JsonField.of(fixedFeeQuantitySchedule)) - - fun fixedFeeQuantitySchedule( - fixedFeeQuantitySchedule: JsonField> - ) = apply { - this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule.map { it.toMutableList() } - } - - fun addFixedFeeQuantitySchedule(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = - apply { - this.fixedFeeQuantitySchedule = - (this.fixedFeeQuantitySchedule ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(fixedFeeQuantitySchedule) - } - } - - fun invoicingThreshold(invoicingThreshold: String?) = - invoicingThreshold(JsonField.ofNullable(invoicingThreshold)) - - fun invoicingThreshold(invoicingThreshold: Optional) = - invoicingThreshold(invoicingThreshold.orElse(null)) - - fun invoicingThreshold(invoicingThreshold: JsonField) = apply { - this.invoicingThreshold = invoicingThreshold - } - - /** The maximum intervals for this subscription. */ - fun maximumIntervals(maximumIntervals: List) = - maximumIntervals(JsonField.of(maximumIntervals)) - - /** The maximum intervals for this subscription. */ - fun maximumIntervals(maximumIntervals: JsonField>) = apply { - this.maximumIntervals = maximumIntervals.map { it.toMutableList() } - } - - /** The maximum intervals for this subscription. */ - fun addMaximumInterval(maximumInterval: MaximumInterval) = apply { - maximumIntervals = - (maximumIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(maximumInterval) - } - } - - /** - * 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - /** The minimum intervals for this subscription. */ - fun minimumIntervals(minimumIntervals: List) = - minimumIntervals(JsonField.of(minimumIntervals)) - - /** The minimum intervals for this subscription. */ - fun minimumIntervals(minimumIntervals: JsonField>) = apply { - this.minimumIntervals = minimumIntervals.map { it.toMutableList() } - } - - /** The minimum intervals for this subscription. */ - fun addMinimumInterval(minimumInterval: MinimumInterval) = apply { - minimumIntervals = - (minimumIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(minimumInterval) - } - } - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - fun netTerms(netTerms: Long) = netTerms(JsonField.of(netTerms)) - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } - - /** - * 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 plan(plan: Plan) = plan(JsonField.of(plan)) - - /** - * 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 plan(plan: JsonField) = apply { this.plan = plan } - - /** The price intervals for this subscription. */ - fun priceIntervals(priceIntervals: List) = - priceIntervals(JsonField.of(priceIntervals)) - - /** The price intervals for this subscription. */ - fun priceIntervals(priceIntervals: JsonField>) = apply { - this.priceIntervals = priceIntervals.map { it.toMutableList() } - } - - /** The price intervals for this subscription. */ - fun addPriceInterval(priceInterval: PriceInterval) = apply { - priceIntervals = - (priceIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(priceInterval) - } - } - - fun redeemedCoupon(redeemedCoupon: RedeemedCoupon?) = - redeemedCoupon(JsonField.ofNullable(redeemedCoupon)) - - fun redeemedCoupon(redeemedCoupon: Optional) = - redeemedCoupon(redeemedCoupon.orElse(null)) - - fun redeemedCoupon(redeemedCoupon: JsonField) = apply { - this.redeemedCoupon = redeemedCoupon - } - - /** The date Orb starts billing for this subscription. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The date Orb starts billing for this subscription. */ - fun startDate(startDate: JsonField) = apply { this.startDate = startDate } - - fun status(status: Status) = status(JsonField.of(status)) - - fun status(status: JsonField) = apply { this.status = status } - - fun trialInfo(trialInfo: TrialInfo) = trialInfo(JsonField.of(trialInfo)) - - fun trialInfo(trialInfo: JsonField) = apply { this.trialInfo = trialInfo } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): SubscriptionCancelResponse = - SubscriptionCancelResponse( - checkRequired("id", id), - checkRequired("activePlanPhaseOrder", activePlanPhaseOrder), - checkRequired("adjustmentIntervals", adjustmentIntervals).map { it.toImmutable() }, - checkRequired("autoCollection", autoCollection), - checkRequired("billingCycleAnchorConfiguration", billingCycleAnchorConfiguration), - checkRequired("billingCycleDay", billingCycleDay), - checkRequired("createdAt", createdAt), - checkRequired("currentBillingPeriodEndDate", currentBillingPeriodEndDate), - checkRequired("currentBillingPeriodStartDate", currentBillingPeriodStartDate), - checkRequired("customer", customer), - checkRequired("defaultInvoiceMemo", defaultInvoiceMemo), - checkRequired("discountIntervals", discountIntervals).map { it.toImmutable() }, - checkRequired("endDate", endDate), - checkRequired("fixedFeeQuantitySchedule", fixedFeeQuantitySchedule).map { - it.toImmutable() - }, - checkRequired("invoicingThreshold", invoicingThreshold), - checkRequired("maximumIntervals", maximumIntervals).map { it.toImmutable() }, - checkRequired("metadata", metadata), - checkRequired("minimumIntervals", minimumIntervals).map { it.toImmutable() }, - checkRequired("netTerms", netTerms), - checkRequired("plan", plan), - checkRequired("priceIntervals", priceIntervals).map { it.toImmutable() }, - checkRequired("redeemedCoupon", redeemedCoupon), - checkRequired("startDate", startDate), - checkRequired("status", status), - checkRequired("trialInfo", trialInfo), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class AdjustmentInterval - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment") - @ExcludeMissing - private val adjustment: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") - - /** The price interval IDs that this adjustment applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - /** The end date of the adjustment interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** The start date of the adjustment interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment - - /** The price interval IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - /** The end date of the adjustment interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** The start date of the adjustment interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AdjustmentInterval = apply { - if (validated) { - return@apply - } - - id() - adjustment().validate() - appliesToPriceIntervalIds() - endDate() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AdjustmentInterval]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustment: JsonField? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(adjustmentInterval: AdjustmentInterval) = apply { - id = adjustmentInterval.id - adjustment = adjustmentInterval.adjustment - appliesToPriceIntervalIds = - adjustmentInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - endDate = adjustmentInterval.endDate - startDate = adjustmentInterval.startDate - additionalProperties = adjustmentInterval.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) - - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } - - fun adjustment(planPhaseUsageDiscount: Adjustment.PlanPhaseUsageDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)) - - fun adjustment(planPhaseAmountDiscount: Adjustment.PlanPhaseAmountDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)) - - fun adjustment( - planPhasePercentageDiscount: Adjustment.PlanPhasePercentageDiscountAdjustment - ) = adjustment(Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)) - - fun adjustment(planPhaseMinimum: Adjustment.PlanPhaseMinimumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)) - - fun adjustment(planPhaseMaximum: Adjustment.PlanPhaseMaximumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)) - - /** The price interval IDs that this adjustment applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval IDs that this adjustment applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval IDs that this adjustment applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - /** The end date of the adjustment interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the adjustment interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the adjustment interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** The start date of the adjustment interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the adjustment interval. */ - 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) - } - - fun build(): AdjustmentInterval = - AdjustmentInterval( - checkRequired("id", id), - checkRequired("adjustment", adjustment), - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment? = null, - private val planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment? = null, - private val planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment? = null, - private val planPhaseMinimum: PlanPhaseMinimumAdjustment? = null, - private val planPhaseMaximum: PlanPhaseMaximumAdjustment? = null, - private val _json: JsonValue? = null, - ) { - - fun planPhaseUsageDiscount(): Optional = - Optional.ofNullable(planPhaseUsageDiscount) - - fun planPhaseAmountDiscount(): Optional = - Optional.ofNullable(planPhaseAmountDiscount) - - fun planPhasePercentageDiscount(): Optional = - Optional.ofNullable(planPhasePercentageDiscount) - - fun planPhaseMinimum(): Optional = - Optional.ofNullable(planPhaseMinimum) - - fun planPhaseMaximum(): Optional = - Optional.ofNullable(planPhaseMaximum) - - fun isPlanPhaseUsageDiscount(): Boolean = planPhaseUsageDiscount != null - - fun isPlanPhaseAmountDiscount(): Boolean = planPhaseAmountDiscount != null - - fun isPlanPhasePercentageDiscount(): Boolean = planPhasePercentageDiscount != null - - fun isPlanPhaseMinimum(): Boolean = planPhaseMinimum != null - - fun isPlanPhaseMaximum(): Boolean = planPhaseMaximum != null - - fun asPlanPhaseUsageDiscount(): PlanPhaseUsageDiscountAdjustment = - planPhaseUsageDiscount.getOrThrow("planPhaseUsageDiscount") - - fun asPlanPhaseAmountDiscount(): PlanPhaseAmountDiscountAdjustment = - planPhaseAmountDiscount.getOrThrow("planPhaseAmountDiscount") - - fun asPlanPhasePercentageDiscount(): PlanPhasePercentageDiscountAdjustment = - planPhasePercentageDiscount.getOrThrow("planPhasePercentageDiscount") - - fun asPlanPhaseMinimum(): PlanPhaseMinimumAdjustment = - planPhaseMinimum.getOrThrow("planPhaseMinimum") - - fun asPlanPhaseMaximum(): PlanPhaseMaximumAdjustment = - planPhaseMaximum.getOrThrow("planPhaseMaximum") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - planPhaseUsageDiscount != null -> - visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) - planPhaseAmountDiscount != null -> - visitor.visitPlanPhaseAmountDiscount(planPhaseAmountDiscount) - planPhasePercentageDiscount != null -> - visitor.visitPlanPhasePercentageDiscount(planPhasePercentageDiscount) - planPhaseMinimum != null -> visitor.visitPlanPhaseMinimum(planPhaseMinimum) - planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) { - planPhaseUsageDiscount.validate() - } - - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) { - planPhaseAmountDiscount.validate() - } - - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) { - planPhasePercentageDiscount.validate() - } - - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) { - planPhaseMinimum.validate() - } - - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) { - planPhaseMaximum.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Adjustment && planPhaseUsageDiscount == other.planPhaseUsageDiscount && planPhaseAmountDiscount == other.planPhaseAmountDiscount && planPhasePercentageDiscount == other.planPhasePercentageDiscount && planPhaseMinimum == other.planPhaseMinimum && planPhaseMaximum == other.planPhaseMaximum /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(planPhaseUsageDiscount, planPhaseAmountDiscount, planPhasePercentageDiscount, planPhaseMinimum, planPhaseMaximum) /* spotless:on */ - - override fun toString(): String = - when { - planPhaseUsageDiscount != null -> - "Adjustment{planPhaseUsageDiscount=$planPhaseUsageDiscount}" - planPhaseAmountDiscount != null -> - "Adjustment{planPhaseAmountDiscount=$planPhaseAmountDiscount}" - planPhasePercentageDiscount != null -> - "Adjustment{planPhasePercentageDiscount=$planPhasePercentageDiscount}" - planPhaseMinimum != null -> "Adjustment{planPhaseMinimum=$planPhaseMinimum}" - planPhaseMaximum != null -> "Adjustment{planPhaseMaximum=$planPhaseMaximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } - - companion object { - - @JvmStatic - fun ofPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = Adjustment(planPhaseUsageDiscount = planPhaseUsageDiscount) - - @JvmStatic - fun ofPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = Adjustment(planPhaseAmountDiscount = planPhaseAmountDiscount) - - @JvmStatic - fun ofPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = Adjustment(planPhasePercentageDiscount = planPhasePercentageDiscount) - - @JvmStatic - fun ofPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment) = - Adjustment(planPhaseMinimum = planPhaseMinimum) - - @JvmStatic - fun ofPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment) = - Adjustment(planPhaseMaximum = planPhaseMaximum) - } - - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { - - fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ): T - - fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ): T - - fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ): T - - fun visitPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment): T - - fun visitPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment): T - - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } - - internal class Deserializer : BaseDeserializer(Adjustment::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = - json.asObject().getOrNull()?.get("adjustment_type")?.asString()?.getOrNull() - - when (adjustmentType) { - "usage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseUsageDiscount = it, _json = json) - } - } - "amount_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseAmountDiscount = it, _json = json) - } - } - "percentage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment( - planPhasePercentageDiscount = it, - _json = json, - ) - } - } - "minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMinimum = it, _json = json) - } - } - "maximum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMaximum = it, _json = json) - } - } - } - - return Adjustment(_json = json) - } - } - - internal class Serializer : BaseSerializer(Adjustment::class) { - - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.planPhaseUsageDiscount != null -> - generator.writeObject(value.planPhaseUsageDiscount) - value.planPhaseAmountDiscount != null -> - generator.writeObject(value.planPhaseAmountDiscount) - value.planPhasePercentageDiscount != null -> - generator.writeObject(value.planPhasePercentageDiscount) - value.planPhaseMinimum != null -> - generator.writeObject(value.planPhaseMinimum) - value.planPhaseMaximum != null -> - generator.writeObject(value.planPhaseMaximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") - } - } - } - - @NoAutoDetect - class PlanPhaseUsageDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonProperty("usage_discount") - @ExcludeMissing - private val usageDiscount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - /** - * The number of usage units by which to discount the price this adjustment applies - * to in a given billing period. - */ - fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - /** - * The number of usage units by which to discount the price this adjustment applies - * to in a given billing period. - */ - @JsonProperty("usage_discount") - @ExcludeMissing - fun _usageDiscount(): JsonField = usageDiscount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseUsageDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - planPhaseOrder() - reason() - usageDiscount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseUsageDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var usageDiscount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - planPhaseUsageDiscountAdjustment: PlanPhaseUsageDiscountAdjustment - ) = apply { - id = planPhaseUsageDiscountAdjustment.id - adjustmentType = planPhaseUsageDiscountAdjustment.adjustmentType - appliesToPriceIds = - planPhaseUsageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseUsageDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseUsageDiscountAdjustment.planPhaseOrder - reason = planPhaseUsageDiscountAdjustment.reason - usageDiscount = planPhaseUsageDiscountAdjustment.usageDiscount - additionalProperties = - planPhaseUsageDiscountAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - /** - * The number of usage units by which to discount the price this adjustment - * applies to in a given billing period. - */ - fun usageDiscount(usageDiscount: Double) = - usageDiscount(JsonField.of(usageDiscount)) - - /** - * The number of usage units by which to discount the price this adjustment - * applies to in a given billing period. - */ - fun usageDiscount(usageDiscount: JsonField) = apply { - this.usageDiscount = usageDiscount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseUsageDiscountAdjustment = - PlanPhaseUsageDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - checkRequired("usageDiscount", usageDiscount), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - USAGE_DISCOUNT -> Known.USAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseUsageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, planPhaseOrder, reason, usageDiscount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseUsageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhaseAmountDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("amount_discount") - @ExcludeMissing - private val amountDiscount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** - * The amount by which to discount the prices this adjustment applies to in a given - * billing period. - */ - fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** - * The amount by which to discount the prices this adjustment applies to in a given - * billing period. - */ - @JsonProperty("amount_discount") - @ExcludeMissing - fun _amountDiscount(): JsonField = amountDiscount - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseAmountDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - amountDiscount() - appliesToPriceIds() - isInvoiceLevel() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseAmountDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var amountDiscount: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - planPhaseAmountDiscountAdjustment: PlanPhaseAmountDiscountAdjustment - ) = apply { - id = planPhaseAmountDiscountAdjustment.id - adjustmentType = planPhaseAmountDiscountAdjustment.adjustmentType - amountDiscount = planPhaseAmountDiscountAdjustment.amountDiscount - appliesToPriceIds = - planPhaseAmountDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseAmountDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseAmountDiscountAdjustment.planPhaseOrder - reason = planPhaseAmountDiscountAdjustment.reason - additionalProperties = - planPhaseAmountDiscountAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** - * The amount by which to discount the prices this adjustment applies to in a - * given billing period. - */ - fun amountDiscount(amountDiscount: String) = - amountDiscount(JsonField.of(amountDiscount)) - - /** - * The amount by which to discount the prices this adjustment applies to in a - * given billing period. - */ - fun amountDiscount(amountDiscount: JsonField) = apply { - this.amountDiscount = amountDiscount - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseAmountDiscountAdjustment = - PlanPhaseAmountDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("amountDiscount", amountDiscount), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseAmountDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, amountDiscount, appliesToPriceIds, isInvoiceLevel, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseAmountDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhasePercentageDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("percentage_discount") - @ExcludeMissing - private val percentageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(): Double = - percentageDiscount.getRequired("percentage_discount") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - @JsonProperty("percentage_discount") - @ExcludeMissing - fun _percentageDiscount(): JsonField = percentageDiscount - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhasePercentageDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - percentageDiscount() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhasePercentageDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var percentageDiscount: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - planPhasePercentageDiscountAdjustment: PlanPhasePercentageDiscountAdjustment - ) = apply { - id = planPhasePercentageDiscountAdjustment.id - adjustmentType = planPhasePercentageDiscountAdjustment.adjustmentType - appliesToPriceIds = - planPhasePercentageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhasePercentageDiscountAdjustment.isInvoiceLevel - percentageDiscount = - planPhasePercentageDiscountAdjustment.percentageDiscount - planPhaseOrder = planPhasePercentageDiscountAdjustment.planPhaseOrder - reason = planPhasePercentageDiscountAdjustment.reason - additionalProperties = - planPhasePercentageDiscountAdjustment.additionalProperties - .toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(percentageDiscount: Double) = - percentageDiscount(JsonField.of(percentageDiscount)) - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(percentageDiscount: JsonField) = apply { - this.percentageDiscount = percentageDiscount - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhasePercentageDiscountAdjustment = - PlanPhasePercentageDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("percentageDiscount", percentageDiscount), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val PERCENTAGE_DISCOUNT = of("percentage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhasePercentageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, percentageDiscount, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhasePercentageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhaseMinimumAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(): String = itemId.getRequired("item_id") - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The item ID that revenue from this minimum will be attributed to. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseMinimumAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - itemId() - minimumAmount() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseMinimumAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var itemId: JsonField? = null - private var minimumAmount: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(planPhaseMinimumAdjustment: PlanPhaseMinimumAdjustment) = - apply { - id = planPhaseMinimumAdjustment.id - adjustmentType = planPhaseMinimumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMinimumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMinimumAdjustment.isInvoiceLevel - itemId = planPhaseMinimumAdjustment.itemId - minimumAmount = planPhaseMinimumAdjustment.minimumAmount - planPhaseOrder = planPhaseMinimumAdjustment.planPhaseOrder - reason = planPhaseMinimumAdjustment.reason - additionalProperties = - planPhaseMinimumAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseMinimumAdjustment = - PlanPhaseMinimumAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("itemId", itemId), - checkRequired("minimumAmount", minimumAmount), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseMinimumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, itemId, minimumAmount, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseMinimumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhaseMaximumAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseMaximumAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - maximumAmount() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseMaximumAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var maximumAmount: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(planPhaseMaximumAdjustment: PlanPhaseMaximumAdjustment) = - apply { - id = planPhaseMaximumAdjustment.id - adjustmentType = planPhaseMaximumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMaximumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMaximumAdjustment.isInvoiceLevel - maximumAmount = planPhaseMaximumAdjustment.maximumAmount - planPhaseOrder = planPhaseMaximumAdjustment.planPhaseOrder - reason = planPhaseMaximumAdjustment.reason - additionalProperties = - planPhaseMaximumAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseMaximumAdjustment = - PlanPhaseMaximumAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("maximumAmount", maximumAmount), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseMaximumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, maximumAmount, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseMaximumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentInterval && id == other.id && adjustment == other.adjustment && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustment, appliesToPriceIntervalIds, endDate, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AdjustmentInterval{id=$id, adjustment=$adjustment, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BillingCycleAnchorConfiguration - @JsonCreator - private constructor( - @JsonProperty("day") @ExcludeMissing private val day: JsonField = JsonMissing.of(), - @JsonProperty("month") - @ExcludeMissing - private val month: JsonField = JsonMissing.of(), - @JsonProperty("year") @ExcludeMissing private val year: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun day(): Long = day.getRequired("day") - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(): Optional = Optional.ofNullable(month.getNullable("month")) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on - * 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(): Optional = Optional.ofNullable(year.getNullable("year")) - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - @JsonProperty("day") @ExcludeMissing fun _day(): JsonField = day - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - @JsonProperty("month") @ExcludeMissing fun _month(): JsonField = month - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on - * 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - @JsonProperty("year") @ExcludeMissing fun _year(): JsonField = year - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleAnchorConfiguration = apply { - if (validated) { - return@apply - } - - day() - month() - year() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleAnchorConfiguration]. */ - class Builder internal constructor() { - - private var day: JsonField? = null - private var month: JsonField = JsonMissing.of() - private var year: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration) = - apply { - day = billingCycleAnchorConfiguration.day - month = billingCycleAnchorConfiguration.month - year = billingCycleAnchorConfiguration.year - additionalProperties = - billingCycleAnchorConfiguration.additionalProperties.toMutableMap() - } - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun day(day: Long) = day(JsonField.of(day)) - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun day(day: JsonField) = apply { this.day = day } - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(month: Long?) = month(JsonField.ofNullable(month)) - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(month: Long) = month(month as Long?) - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun month(month: Optional) = month(month.orElse(null) as Long?) - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(month: JsonField) = apply { this.month = month } - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(year: Long?) = year(JsonField.ofNullable(year)) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(year: Long) = year(year as Long?) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun year(year: Optional) = year(year.orElse(null) as Long?) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(year: JsonField) = apply { this.year = year } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleAnchorConfiguration = - BillingCycleAnchorConfiguration( - checkRequired("day", day), - month, - year, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleAnchorConfiguration && day == other.day && month == other.month && year == other.year && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(day, month, year, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleAnchorConfiguration{day=$day, month=$month, year=$year, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(using = DiscountInterval.Deserializer::class) - @JsonSerialize(using = DiscountInterval.Serializer::class) - class DiscountInterval - private constructor( - private val amount: AmountDiscountInterval? = null, - private val percentage: PercentageDiscountInterval? = null, - private val usage: UsageDiscountInterval? = null, - private val _json: JsonValue? = null, - ) { - - fun amount(): Optional = Optional.ofNullable(amount) - - fun percentage(): Optional = Optional.ofNullable(percentage) - - fun usage(): Optional = Optional.ofNullable(usage) - - fun isAmount(): Boolean = amount != null - - fun isPercentage(): Boolean = percentage != null - - fun isUsage(): Boolean = usage != null - - fun asAmount(): AmountDiscountInterval = amount.getOrThrow("amount") - - fun asPercentage(): PercentageDiscountInterval = percentage.getOrThrow("percentage") - - fun asUsage(): UsageDiscountInterval = usage.getOrThrow("usage") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - amount != null -> visitor.visitAmount(amount) - percentage != null -> visitor.visitPercentage(percentage) - usage != null -> visitor.visitUsage(usage) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): DiscountInterval = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitAmount(amount: AmountDiscountInterval) { - amount.validate() - } - - override fun visitPercentage(percentage: PercentageDiscountInterval) { - percentage.validate() - } - - override fun visitUsage(usage: UsageDiscountInterval) { - usage.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountInterval && amount == other.amount && percentage == other.percentage && usage == other.usage /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(amount, percentage, usage) /* spotless:on */ - - override fun toString(): String = - when { - amount != null -> "DiscountInterval{amount=$amount}" - percentage != null -> "DiscountInterval{percentage=$percentage}" - usage != null -> "DiscountInterval{usage=$usage}" - _json != null -> "DiscountInterval{_unknown=$_json}" - else -> throw IllegalStateException("Invalid DiscountInterval") - } - - companion object { - - @JvmStatic - fun ofAmount(amount: AmountDiscountInterval) = DiscountInterval(amount = amount) - - @JvmStatic - fun ofPercentage(percentage: PercentageDiscountInterval) = - DiscountInterval(percentage = percentage) - - @JvmStatic fun ofUsage(usage: UsageDiscountInterval) = DiscountInterval(usage = usage) - } - - /** - * An interface that defines how to map each variant of [DiscountInterval] to a value of - * type [T]. - */ - interface Visitor { - - fun visitAmount(amount: AmountDiscountInterval): T - - fun visitPercentage(percentage: PercentageDiscountInterval): T - - fun visitUsage(usage: UsageDiscountInterval): T - - /** - * Maps an unknown variant of [DiscountInterval] to a value of type [T]. - * - * An instance of [DiscountInterval] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown DiscountInterval: $json") - } - } - - internal class Deserializer : BaseDeserializer(DiscountInterval::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): DiscountInterval { - val json = JsonValue.fromJsonNode(node) - val discountType = - json.asObject().getOrNull()?.get("discount_type")?.asString()?.getOrNull() - - when (discountType) { - "amount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(amount = it, _json = json) - } - } - "percentage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(percentage = it, _json = json) - } - } - "usage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(usage = it, _json = json) - } - } - } - - return DiscountInterval(_json = json) - } - } - - internal class Serializer : BaseSerializer(DiscountInterval::class) { - - override fun serialize( - value: DiscountInterval, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.amount != null -> generator.writeObject(value.amount) - value.percentage != null -> generator.writeObject(value.percentage) - value.usage != null -> generator.writeObject(value.usage) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid DiscountInterval") - } - } - } - - @NoAutoDetect - class AmountDiscountInterval - @JsonCreator - private constructor( - @JsonProperty("amount_discount") - @ExcludeMissing - private val amountDiscount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("discount_type") - @ExcludeMissing - private val discountType: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - fun discountType(): DiscountType = discountType.getRequired("discount_type") - - /** The end date of the discount interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** The start date of the discount interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** Only available if discount_type is `amount`. */ - @JsonProperty("amount_discount") - @ExcludeMissing - fun _amountDiscount(): JsonField = amountDiscount - - /** The price ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - - /** The end date of the discount interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** The start date of the discount interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AmountDiscountInterval = apply { - if (validated) { - return@apply - } - - amountDiscount() - appliesToPriceIds() - appliesToPriceIntervalIds() - discountType() - endDate() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AmountDiscountInterval]. */ - class Builder internal constructor() { - - private var amountDiscount: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { - amountDiscount = amountDiscountInterval.amountDiscount - appliesToPriceIds = - amountDiscountInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - amountDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = amountDiscountInterval.discountType - endDate = amountDiscountInterval.endDate - startDate = amountDiscountInterval.startDate - additionalProperties = - amountDiscountInterval.additionalProperties.toMutableMap() - } - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(amountDiscount: String) = - amountDiscount(JsonField.of(amountDiscount)) - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(amountDiscount: JsonField) = apply { - this.amountDiscount = amountDiscount - } - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this discount interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this discount interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the discount interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the discount interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** The start date of the discount interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the discount interval. */ - 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) - } - - fun build(): AmountDiscountInterval = - AmountDiscountInterval( - checkRequired("amountDiscount", amountDiscount), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("discountType", discountType), - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val AMOUNT = of("amount") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - AMOUNT - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT -> Value.AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AMOUNT -> Known.AMOUNT - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AmountDiscountInterval && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amountDiscount, appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AmountDiscountInterval{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PercentageDiscountInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("discount_type") - @ExcludeMissing - private val discountType: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("percentage_discount") - @ExcludeMissing - private val percentageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - fun discountType(): DiscountType = discountType.getRequired("discount_type") - - /** The end date of the discount interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ - fun percentageDiscount(): Double = percentageDiscount.getRequired("percentage_discount") - - /** The start date of the discount interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** The price ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - - /** The end date of the discount interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ - @JsonProperty("percentage_discount") - @ExcludeMissing - fun _percentageDiscount(): JsonField = percentageDiscount - - /** The start date of the discount interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PercentageDiscountInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - discountType() - endDate() - percentageDiscount() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PercentageDiscountInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null - private var endDate: JsonField? = null - private var percentageDiscount: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { - appliesToPriceIds = - percentageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - percentageDiscountInterval.appliesToPriceIntervalIds.map { - it.toMutableList() - } - discountType = percentageDiscountInterval.discountType - endDate = percentageDiscountInterval.endDate - percentageDiscount = percentageDiscountInterval.percentageDiscount - startDate = percentageDiscountInterval.startDate - additionalProperties = - percentageDiscountInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this discount interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this discount interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the discount interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the discount interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** - * Only available if discount_type is `percentage`.This is a number between 0 and 1. - */ - fun percentageDiscount(percentageDiscount: Double) = - percentageDiscount(JsonField.of(percentageDiscount)) - - /** - * Only available if discount_type is `percentage`.This is a number between 0 and 1. - */ - fun percentageDiscount(percentageDiscount: JsonField) = apply { - this.percentageDiscount = percentageDiscount - } - - /** The start date of the discount interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the discount interval. */ - 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) - } - - fun build(): PercentageDiscountInterval = - PercentageDiscountInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("discountType", discountType), - checkRequired("endDate", endDate), - checkRequired("percentageDiscount", percentageDiscount), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val PERCENTAGE = of("percentage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - PERCENTAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE -> Value.PERCENTAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PERCENTAGE -> Known.PERCENTAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PercentageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, percentageDiscount, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PercentageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class UsageDiscountInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("discount_type") - @ExcludeMissing - private val discountType: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonProperty("usage_discount") - @ExcludeMissing - private val usageDiscount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - fun discountType(): DiscountType = discountType.getRequired("discount_type") - - /** The end date of the discount interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** The start date of the discount interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** - * Only available if discount_type is `usage`. Number of usage units that this discount - * is for - */ - fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - - /** The price ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - - /** The end date of the discount interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** The start date of the discount interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - /** - * Only available if discount_type is `usage`. Number of usage units that this discount - * is for - */ - @JsonProperty("usage_discount") - @ExcludeMissing - fun _usageDiscount(): JsonField = usageDiscount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): UsageDiscountInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - discountType() - endDate() - startDate() - usageDiscount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UsageDiscountInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var usageDiscount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { - appliesToPriceIds = - usageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - usageDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = usageDiscountInterval.discountType - endDate = usageDiscountInterval.endDate - startDate = usageDiscountInterval.startDate - usageDiscount = usageDiscountInterval.usageDiscount - additionalProperties = usageDiscountInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this discount interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this discount interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the discount interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the discount interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** The start date of the discount interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the discount interval. */ - fun startDate(startDate: JsonField) = apply { - this.startDate = startDate - } - - /** - * Only available if discount_type is `usage`. Number of usage units that this - * discount is for - */ - fun usageDiscount(usageDiscount: Double) = - usageDiscount(JsonField.of(usageDiscount)) - - /** - * Only available if discount_type is `usage`. Number of usage units that this - * discount is for - */ - fun usageDiscount(usageDiscount: JsonField) = apply { - this.usageDiscount = usageDiscount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): UsageDiscountInterval = - UsageDiscountInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("discountType", discountType), - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - checkRequired("usageDiscount", usageDiscount), - additionalProperties.toImmutable(), - ) - } - - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE = of("usage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - USAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE -> Value.USAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE -> Known.USAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UsageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, startDate, usageDiscount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UsageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" - } - } - - @NoAutoDetect - class FixedFeeQuantitySchedule - @JsonCreator - private constructor( - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("price_id") - @ExcludeMissing - private val priceId: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - private val quantity: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - fun priceId(): String = priceId.getRequired("price_id") - - fun quantity(): Double = quantity.getRequired("quantity") - - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - - @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): FixedFeeQuantitySchedule = apply { - if (validated) { - return@apply - } - - endDate() - priceId() - quantity() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FixedFeeQuantitySchedule]. */ - class Builder internal constructor() { - - private var endDate: JsonField? = null - private var priceId: JsonField? = null - private var quantity: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = apply { - endDate = fixedFeeQuantitySchedule.endDate - priceId = fixedFeeQuantitySchedule.priceId - quantity = fixedFeeQuantitySchedule.quantity - startDate = fixedFeeQuantitySchedule.startDate - additionalProperties = fixedFeeQuantitySchedule.additionalProperties.toMutableMap() - } - - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) - - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - 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) - } - - fun build(): FixedFeeQuantitySchedule = - FixedFeeQuantitySchedule( - checkRequired("endDate", endDate), - checkRequired("priceId", priceId), - checkRequired("quantity", quantity), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FixedFeeQuantitySchedule && endDate == other.endDate && priceId == other.priceId && quantity == other.quantity && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(endDate, priceId, quantity, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "FixedFeeQuantitySchedule{endDate=$endDate, priceId=$priceId, quantity=$quantity, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class MaximumInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this maximum interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this maximum interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - /** The end date of the maximum interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** The start date of the maximum interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** The price ids that this maximum interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this maximum interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - /** The end date of the maximum interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** The start date of the maximum interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MaximumInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - endDate() - maximumAmount() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MaximumInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var endDate: JsonField? = null - private var maximumAmount: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximumInterval: MaximumInterval) = apply { - appliesToPriceIds = maximumInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - maximumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - endDate = maximumInterval.endDate - maximumAmount = maximumInterval.maximumAmount - startDate = maximumInterval.startDate - additionalProperties = maximumInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this maximum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this maximum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this maximum interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this maximum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this maximum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this maximum interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - /** The end date of the maximum interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the maximum interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the maximum interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** The start date of the maximum interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the maximum interval. */ - 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) - } - - fun build(): MaximumInterval = - MaximumInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("endDate", endDate), - checkRequired("maximumAmount", maximumAmount), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MaximumInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && maximumAmount == other.maximumAmount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, endDate, maximumAmount, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MaximumInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, maximumAmount=$maximumAmount, startDate=$startDate, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class MinimumInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this minimum interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this minimum interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - /** The end date of the minimum interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** The start date of the minimum interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** The price ids that this minimum interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this minimum interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - /** The end date of the minimum interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** The start date of the minimum interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MinimumInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - endDate() - minimumAmount() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MinimumInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var endDate: JsonField? = null - private var minimumAmount: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(minimumInterval: MinimumInterval) = apply { - appliesToPriceIds = minimumInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - minimumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - endDate = minimumInterval.endDate - minimumAmount = minimumInterval.minimumAmount - startDate = minimumInterval.startDate - additionalProperties = minimumInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this minimum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this minimum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this minimum interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this minimum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this minimum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this minimum interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - /** The end date of the minimum interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the minimum interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the minimum interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** The start date of the minimum interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the minimum interval. */ - 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) - } - - fun build(): MinimumInterval = - MinimumInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("endDate", endDate), - checkRequired("minimumAmount", minimumAmount), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MinimumInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && minimumAmount == other.minimumAmount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, endDate, minimumAmount, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MinimumInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, minimumAmount=$minimumAmount, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - /** - * The Price Interval resource represents a period of time for which a price will bill on a - * subscription. A subscription’s price intervals define its billing behavior. - */ - @NoAutoDetect - class PriceInterval - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_day") - @ExcludeMissing - private val billingCycleDay: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - private val currentBillingPeriodEndDate: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - private val currentBillingPeriodStartDate: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("filter") - @ExcludeMissing - private val filter: JsonField = JsonMissing.of(), - @JsonProperty("fixed_fee_quantity_transitions") - @ExcludeMissing - private val fixedFeeQuantityTransitions: JsonField> = - JsonMissing.of(), - @JsonProperty("price") - @ExcludeMissing - private val price: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonProperty("usage_customer_ids") - @ExcludeMissing - private val usageCustomerIds: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - /** The day of the month that Orb bills for this price */ - fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate(): Optional = - Optional.ofNullable( - currentBillingPeriodEndDate.getNullable("current_billing_period_end_date") - ) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodStartDate(): Optional = - Optional.ofNullable( - currentBillingPeriodStartDate.getNullable("current_billing_period_start_date") - ) - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** An additional filter to apply to usage queries. */ - fun filter(): Optional = Optional.ofNullable(filter.getNullable("filter")) - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions(): Optional> = - Optional.ofNullable( - fixedFeeQuantityTransitions.getNullable("fixed_fee_quantity_transitions") - ) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting in - * a charge on an invoice in the form of an invoice line item. Prices take a quantity and - * determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the key - * for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(): Price = price.getRequired("price") - - /** - * The start date of the price interval. This is the date that Orb starts billing for this - * price. - */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this price - * interval. - */ - fun usageCustomerIds(): Optional> = - Optional.ofNullable(usageCustomerIds.getNullable("usage_customer_ids")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** The day of the month that Orb bills for this price */ - @JsonProperty("billing_cycle_day") - @ExcludeMissing - fun _billingCycleDay(): JsonField = billingCycleDay - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if this price - * interval is not currently active. - */ - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - fun _currentBillingPeriodStartDate(): JsonField = - currentBillingPeriodStartDate - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** An additional filter to apply to usage queries. */ - @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField = filter - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - @JsonProperty("fixed_fee_quantity_transitions") - @ExcludeMissing - fun _fixedFeeQuantityTransitions(): JsonField> = - fixedFeeQuantityTransitions - - /** - * 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) - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - - /** - * The start date of the price interval. This is the date that Orb starts billing for this - * price. - */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this price - * interval. - */ - @JsonProperty("usage_customer_ids") - @ExcludeMissing - fun _usageCustomerIds(): JsonField> = usageCustomerIds - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PriceInterval = apply { - if (validated) { - return@apply - } - - id() - billingCycleDay() - currentBillingPeriodEndDate() - currentBillingPeriodStartDate() - endDate() - filter() - fixedFeeQuantityTransitions().ifPresent { it.forEach { it.validate() } } - price().validate() - startDate() - usageCustomerIds() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PriceInterval]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var billingCycleDay: JsonField? = null - private var currentBillingPeriodEndDate: JsonField? = null - private var currentBillingPeriodStartDate: JsonField? = null - private var endDate: JsonField? = null - private var filter: JsonField? = null - private var fixedFeeQuantityTransitions: - JsonField>? = - null - private var price: JsonField? = null - private var startDate: JsonField? = null - private var usageCustomerIds: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(priceInterval: PriceInterval) = apply { - id = priceInterval.id - billingCycleDay = priceInterval.billingCycleDay - currentBillingPeriodEndDate = priceInterval.currentBillingPeriodEndDate - currentBillingPeriodStartDate = priceInterval.currentBillingPeriodStartDate - endDate = priceInterval.endDate - filter = priceInterval.filter - fixedFeeQuantityTransitions = - priceInterval.fixedFeeQuantityTransitions.map { it.toMutableList() } - price = priceInterval.price - startDate = priceInterval.startDate - usageCustomerIds = priceInterval.usageCustomerIds.map { it.toMutableList() } - additionalProperties = priceInterval.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - /** The day of the month that Orb bills for this price */ - fun billingCycleDay(billingCycleDay: Long) = - billingCycleDay(JsonField.of(billingCycleDay)) - - /** The day of the month that Orb bills for this price */ - fun billingCycleDay(billingCycleDay: JsonField) = apply { - this.billingCycleDay = billingCycleDay - } - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = - currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = - currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate( - currentBillingPeriodEndDate: JsonField - ) = apply { this.currentBillingPeriodEndDate = currentBillingPeriodEndDate } - - /** - * The start date of the current billing period. This is an inclusive timestamp; the - * instant returned is exactly the beginning of the billing period. Set to null if this - * price interval is not currently active. - */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = - currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the - * instant returned is exactly the beginning of the billing period. Set to null if this - * price interval is not currently active. - */ - fun currentBillingPeriodStartDate( - currentBillingPeriodStartDate: Optional - ) = currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the - * instant returned is exactly the beginning of the billing period. Set to null if this - * price interval is not currently active. - */ - fun currentBillingPeriodStartDate( - currentBillingPeriodStartDate: JsonField - ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** An additional filter to apply to usage queries. */ - fun filter(filter: String?) = filter(JsonField.ofNullable(filter)) - - /** An additional filter to apply to usage queries. */ - fun filter(filter: Optional) = filter(filter.orElse(null)) - - /** An additional filter to apply to usage queries. */ - fun filter(filter: JsonField) = apply { this.filter = filter } - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: List? - ) = fixedFeeQuantityTransitions(JsonField.ofNullable(fixedFeeQuantityTransitions)) - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: Optional> - ) = fixedFeeQuantityTransitions(fixedFeeQuantityTransitions.orElse(null)) - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: JsonField> - ) = apply { - this.fixedFeeQuantityTransitions = - fixedFeeQuantityTransitions.map { it.toMutableList() } - } - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun addFixedFeeQuantityTransition( - fixedFeeQuantityTransition: FixedFeeQuantityTransition - ) = apply { - fixedFeeQuantityTransitions = - (fixedFeeQuantityTransitions ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(fixedFeeQuantityTransition) - } - } - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(price: Price) = price(JsonField.of(price)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(price: JsonField) = apply { this.price = price } - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(matrix: Price.MatrixPrice) = price(Price.ofMatrix(matrix)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredPackage: Price.TieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedTiered: Price.GroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(unitWithPercent: Price.UnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredWithProration: Price.TieredWithProrationPrice) = - price(Price.ofTieredWithProration(tieredWithProration)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(unitWithProration: Price.UnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedAllocation: Price.GroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bulkWithProration: Price.BulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = - price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice) = - price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - - /** - * The start date of the price interval. This is the date that Orb starts billing for - * this price. - */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** - * The start date of the price interval. This is the date that Orb starts billing for - * this price. - */ - fun startDate(startDate: JsonField) = apply { - this.startDate = startDate - } - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun usageCustomerIds(usageCustomerIds: List?) = - usageCustomerIds(JsonField.ofNullable(usageCustomerIds)) - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun usageCustomerIds(usageCustomerIds: Optional>) = - usageCustomerIds(usageCustomerIds.orElse(null)) - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun usageCustomerIds(usageCustomerIds: JsonField>) = apply { - this.usageCustomerIds = usageCustomerIds.map { it.toMutableList() } - } - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun addUsageCustomerId(usageCustomerId: String) = apply { - usageCustomerIds = - (usageCustomerIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(usageCustomerId) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): PriceInterval = - PriceInterval( - checkRequired("id", id), - checkRequired("billingCycleDay", billingCycleDay), - checkRequired("currentBillingPeriodEndDate", currentBillingPeriodEndDate), - checkRequired("currentBillingPeriodStartDate", currentBillingPeriodStartDate), - checkRequired("endDate", endDate), - checkRequired("filter", filter), - checkRequired("fixedFeeQuantityTransitions", fixedFeeQuantityTransitions).map { - it.toImmutable() - }, - checkRequired("price", price), - checkRequired("startDate", startDate), - checkRequired("usageCustomerIds", usageCustomerIds).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class FixedFeeQuantityTransition - @JsonCreator - private constructor( - @JsonProperty("effective_date") - @ExcludeMissing - private val effectiveDate: JsonField = JsonMissing.of(), - @JsonProperty("price_id") - @ExcludeMissing - private val priceId: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - private val quantity: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun effectiveDate(): OffsetDateTime = effectiveDate.getRequired("effective_date") - - fun priceId(): String = priceId.getRequired("price_id") - - fun quantity(): Long = quantity.getRequired("quantity") - - @JsonProperty("effective_date") - @ExcludeMissing - fun _effectiveDate(): JsonField = effectiveDate - - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - - @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): FixedFeeQuantityTransition = apply { - if (validated) { - return@apply - } - - effectiveDate() - priceId() - quantity() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FixedFeeQuantityTransition]. */ - class Builder internal constructor() { - - private var effectiveDate: JsonField? = null - private var priceId: JsonField? = null - private var quantity: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(fixedFeeQuantityTransition: FixedFeeQuantityTransition) = apply { - effectiveDate = fixedFeeQuantityTransition.effectiveDate - priceId = fixedFeeQuantityTransition.priceId - quantity = fixedFeeQuantityTransition.quantity - additionalProperties = - fixedFeeQuantityTransition.additionalProperties.toMutableMap() - } - - fun effectiveDate(effectiveDate: OffsetDateTime) = - effectiveDate(JsonField.of(effectiveDate)) - - fun effectiveDate(effectiveDate: JsonField) = apply { - this.effectiveDate = effectiveDate - } - - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) - - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - - fun quantity(quantity: Long) = quantity(JsonField.of(quantity)) - - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): FixedFeeQuantityTransition = - FixedFeeQuantityTransition( - checkRequired("effectiveDate", effectiveDate), - checkRequired("priceId", priceId), - checkRequired("quantity", quantity), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FixedFeeQuantityTransition && effectiveDate == other.effectiveDate && priceId == other.priceId && quantity == other.quantity && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(effectiveDate, priceId, quantity, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "FixedFeeQuantityTransition{effectiveDate=$effectiveDate, priceId=$priceId, quantity=$quantity, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PriceInterval && id == other.id && billingCycleDay == other.billingCycleDay && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && endDate == other.endDate && filter == other.filter && fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && price == other.price && startDate == other.startDate && usageCustomerIds == other.usageCustomerIds && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billingCycleDay, currentBillingPeriodEndDate, currentBillingPeriodStartDate, endDate, filter, fixedFeeQuantityTransitions, price, startDate, usageCustomerIds, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PriceInterval{id=$id, billingCycleDay=$billingCycleDay, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, endDate=$endDate, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, price=$price, startDate=$startDate, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class RedeemedCoupon - @JsonCreator - private constructor( - @JsonProperty("coupon_id") - @ExcludeMissing - private val couponId: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun couponId(): String = couponId.getRequired("coupon_id") - - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - @JsonProperty("coupon_id") @ExcludeMissing fun _couponId(): JsonField = couponId - - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): RedeemedCoupon = apply { - if (validated) { - return@apply - } - - couponId() - endDate() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RedeemedCoupon]. */ - class Builder internal constructor() { - - private var couponId: JsonField? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(redeemedCoupon: RedeemedCoupon) = apply { - couponId = redeemedCoupon.couponId - endDate = redeemedCoupon.endDate - startDate = redeemedCoupon.startDate - additionalProperties = redeemedCoupon.additionalProperties.toMutableMap() - } - - fun couponId(couponId: String) = couponId(JsonField.of(couponId)) - - fun couponId(couponId: JsonField) = apply { this.couponId = couponId } - - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - 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) - } - - fun build(): RedeemedCoupon = - RedeemedCoupon( - checkRequired("couponId", couponId), - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RedeemedCoupon && couponId == other.couponId && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(couponId, endDate, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RedeemedCoupon{couponId=$couponId, endDate=$endDate, startDate=$startDate, 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 ENDED = of("ended") - - @JvmField val UPCOMING = of("upcoming") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - ACTIVE, - ENDED, - UPCOMING, - } - - /** - * 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, - ENDED, - UPCOMING, - /** 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 - ENDED -> Value.ENDED - UPCOMING -> Value.UPCOMING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to 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 - ENDED -> Known.ENDED - UPCOMING -> Known.UPCOMING - 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TrialInfo - @JsonCreator - private constructor( - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TrialInfo = apply { - if (validated) { - return@apply - } - - endDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TrialInfo]. */ - class Builder internal constructor() { - - private var endDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(trialInfo: TrialInfo) = apply { - endDate = trialInfo.endDate - additionalProperties = trialInfo.additionalProperties.toMutableMap() - } - - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - 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) - } - - fun build(): TrialInfo = - TrialInfo(checkRequired("endDate", endDate), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TrialInfo && endDate == other.endDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(endDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TrialInfo{endDate=$endDate, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is SubscriptionCancelResponse && id == other.id && activePlanPhaseOrder == other.activePlanPhaseOrder && adjustmentIntervals == other.adjustmentIntervals && autoCollection == other.autoCollection && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && billingCycleDay == other.billingCycleDay && createdAt == other.createdAt && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && customer == other.customer && defaultInvoiceMemo == other.defaultInvoiceMemo && discountIntervals == other.discountIntervals && endDate == other.endDate && fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && invoicingThreshold == other.invoicingThreshold && maximumIntervals == other.maximumIntervals && metadata == other.metadata && minimumIntervals == other.minimumIntervals && netTerms == other.netTerms && plan == other.plan && priceIntervals == other.priceIntervals && redeemedCoupon == other.redeemedCoupon && startDate == other.startDate && status == other.status && trialInfo == other.trialInfo && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, activePlanPhaseOrder, adjustmentIntervals, autoCollection, billingCycleAnchorConfiguration, billingCycleDay, createdAt, currentBillingPeriodEndDate, currentBillingPeriodStartDate, customer, defaultInvoiceMemo, discountIntervals, endDate, fixedFeeQuantitySchedule, invoicingThreshold, maximumIntervals, metadata, minimumIntervals, netTerms, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SubscriptionCancelResponse{id=$id, activePlanPhaseOrder=$activePlanPhaseOrder, adjustmentIntervals=$adjustmentIntervals, autoCollection=$autoCollection, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, billingCycleDay=$billingCycleDay, createdAt=$createdAt, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, customer=$customer, defaultInvoiceMemo=$defaultInvoiceMemo, discountIntervals=$discountIntervals, endDate=$endDate, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, invoicingThreshold=$invoicingThreshold, maximumIntervals=$maximumIntervals, metadata=$metadata, minimumIntervals=$minimumIntervals, netTerms=$netTerms, plan=$plan, priceIntervals=$priceIntervals, redeemedCoupon=$redeemedCoupon, startDate=$startDate, status=$status, trialInfo=$trialInfo, additionalProperties=$additionalProperties}" -} 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 5ab96ded4..b067c80d7 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 @@ -6,15 +6,6 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField @@ -22,8 +13,7 @@ import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow +import com.withorb.api.core.checkKnown import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import com.withorb.api.core.immutableEmptyMap @@ -32,7 +22,6 @@ import com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import java.util.Objects import java.util.Optional -import kotlin.jvm.optionals.getOrNull /** * A subscription represents the purchase of a plan by a customer. The customer is identified by @@ -277,13 +266,13 @@ private constructor( * Additional adjustments to be added to the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun addAdjustments(): Optional> = body.addAdjustments() + fun addAdjustments(): Optional> = body.addAdjustments() /** * Additional prices to be added to the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) */ - fun addPrices(): Optional> = body.addPrices() + fun addPrices(): Optional> = body.addPrices() fun alignBillingWithSubscriptionStartDate(): Optional = body.alignBillingWithSubscriptionStartDate() @@ -297,7 +286,7 @@ private constructor( @Deprecated("deprecated") fun awsRegion(): Optional = body.awsRegion() - fun billingCycleAnchorConfiguration(): Optional = + fun billingCycleAnchorConfiguration(): Optional = body.billingCycleAnchorConfiguration() /** @@ -387,25 +376,27 @@ private constructor( * Plan adjustments to be removed from the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) */ - fun removeAdjustments(): Optional> = body.removeAdjustments() + fun removeAdjustments(): Optional> = + body.removeAdjustments() /** * Plan prices to be removed from the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) */ - fun removePrices(): Optional> = body.removePrices() + fun removePrices(): Optional> = body.removePrices() /** * Plan adjustments to be replaced with additional adjustments on the subscription. (Only * available for accounts that have migrated off of legacy subscription overrides) */ - fun replaceAdjustments(): Optional> = body.replaceAdjustments() + fun replaceAdjustments(): Optional> = + body.replaceAdjustments() /** * Plan prices to be replaced with additional prices on the subscription. (Only available for * accounts that have migrated off of legacy subscription overrides) */ - fun replacePrices(): Optional> = body.replacePrices() + fun replacePrices(): Optional> = body.replacePrices() fun startDate(): Optional = body.startDate() @@ -428,13 +419,13 @@ private constructor( * Additional adjustments to be added to the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun _addAdjustments(): JsonField> = body._addAdjustments() + fun _addAdjustments(): JsonField> = body._addAdjustments() /** * Additional prices to be added to the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) */ - fun _addPrices(): JsonField> = body._addPrices() + fun _addPrices(): JsonField> = body._addPrices() fun _alignBillingWithSubscriptionStartDate(): JsonField = body._alignBillingWithSubscriptionStartDate() @@ -448,7 +439,7 @@ private constructor( @Deprecated("deprecated") fun _awsRegion(): JsonField = body._awsRegion() - fun _billingCycleAnchorConfiguration(): JsonField = + fun _billingCycleAnchorConfiguration(): JsonField = body._billingCycleAnchorConfiguration() /** @@ -540,25 +531,27 @@ private constructor( * Plan adjustments to be removed from the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) */ - fun _removeAdjustments(): JsonField> = body._removeAdjustments() + fun _removeAdjustments(): JsonField> = + body._removeAdjustments() /** * Plan prices to be removed from the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) */ - fun _removePrices(): JsonField> = body._removePrices() + fun _removePrices(): JsonField> = body._removePrices() /** * Plan adjustments to be replaced with additional adjustments on the subscription. (Only * available for accounts that have migrated off of legacy subscription overrides) */ - fun _replaceAdjustments(): JsonField> = body._replaceAdjustments() + fun _replaceAdjustments(): JsonField> = + body._replaceAdjustments() /** * Plan prices to be replaced with additional prices on the subscription. (Only available for * accounts that have migrated off of legacy subscription overrides) */ - fun _replacePrices(): JsonField> = body._replacePrices() + fun _replacePrices(): JsonField> = body._replacePrices() fun _startDate(): JsonField = body._startDate() @@ -595,10 +588,11 @@ private constructor( private constructor( @JsonProperty("add_adjustments") @ExcludeMissing - private val addAdjustments: JsonField> = JsonMissing.of(), + private val addAdjustments: JsonField> = + JsonMissing.of(), @JsonProperty("add_prices") @ExcludeMissing - private val addPrices: JsonField> = JsonMissing.of(), + private val addPrices: JsonField> = JsonMissing.of(), @JsonProperty("align_billing_with_subscription_start_date") @ExcludeMissing private val alignBillingWithSubscriptionStartDate: JsonField = JsonMissing.of(), @@ -610,7 +604,8 @@ private constructor( private val awsRegion: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_anchor_configuration") @ExcludeMissing - private val billingCycleAnchorConfiguration: JsonField = + private val billingCycleAnchorConfiguration: + JsonField = JsonMissing.of(), @JsonProperty("coupon_redemption_code") @ExcludeMissing @@ -668,16 +663,19 @@ private constructor( private val priceOverrides: JsonField> = JsonMissing.of(), @JsonProperty("remove_adjustments") @ExcludeMissing - private val removeAdjustments: JsonField> = JsonMissing.of(), + private val removeAdjustments: JsonField> = + JsonMissing.of(), @JsonProperty("remove_prices") @ExcludeMissing - private val removePrices: JsonField> = JsonMissing.of(), + private val removePrices: JsonField> = JsonMissing.of(), @JsonProperty("replace_adjustments") @ExcludeMissing - private val replaceAdjustments: JsonField> = JsonMissing.of(), + private val replaceAdjustments: JsonField> = + JsonMissing.of(), @JsonProperty("replace_prices") @ExcludeMissing - private val replacePrices: JsonField> = JsonMissing.of(), + private val replacePrices: JsonField> = + JsonMissing.of(), @JsonProperty("start_date") @ExcludeMissing private val startDate: JsonField = JsonMissing.of(), @@ -695,14 +693,14 @@ private constructor( * Additional adjustments to be added to the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun addAdjustments(): Optional> = + fun addAdjustments(): Optional> = Optional.ofNullable(addAdjustments.getNullable("add_adjustments")) /** * Additional prices to be added to the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) */ - fun addPrices(): Optional> = + fun addPrices(): Optional> = Optional.ofNullable(addPrices.getNullable("add_prices")) fun alignBillingWithSubscriptionStartDate(): Optional = @@ -723,7 +721,7 @@ private constructor( @Deprecated("deprecated") fun awsRegion(): Optional = Optional.ofNullable(awsRegion.getNullable("aws_region")) - fun billingCycleAnchorConfiguration(): Optional = + fun billingCycleAnchorConfiguration(): Optional = Optional.ofNullable( billingCycleAnchorConfiguration.getNullable("billing_cycle_anchor_configuration") ) @@ -832,28 +830,28 @@ private constructor( * Plan adjustments to be removed from the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun removeAdjustments(): Optional> = + fun removeAdjustments(): Optional> = Optional.ofNullable(removeAdjustments.getNullable("remove_adjustments")) /** * Plan prices to be removed from the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) */ - fun removePrices(): Optional> = + fun removePrices(): Optional> = Optional.ofNullable(removePrices.getNullable("remove_prices")) /** * Plan adjustments to be replaced with additional adjustments on the subscription. (Only * available for accounts that have migrated off of legacy subscription overrides) */ - fun replaceAdjustments(): Optional> = + fun replaceAdjustments(): Optional> = Optional.ofNullable(replaceAdjustments.getNullable("replace_adjustments")) /** * Plan prices to be replaced with additional prices on the subscription. (Only available * for accounts that have migrated off of legacy subscription overrides) */ - fun replacePrices(): Optional> = + fun replacePrices(): Optional> = Optional.ofNullable(replacePrices.getNullable("replace_prices")) fun startDate(): Optional = @@ -882,7 +880,7 @@ private constructor( */ @JsonProperty("add_adjustments") @ExcludeMissing - fun _addAdjustments(): JsonField> = addAdjustments + fun _addAdjustments(): JsonField> = addAdjustments /** * Additional prices to be added to the subscription. (Only available for accounts that have @@ -890,7 +888,7 @@ private constructor( */ @JsonProperty("add_prices") @ExcludeMissing - fun _addPrices(): JsonField> = addPrices + fun _addPrices(): JsonField> = addPrices @JsonProperty("align_billing_with_subscription_start_date") @ExcludeMissing @@ -913,7 +911,7 @@ private constructor( @JsonProperty("billing_cycle_anchor_configuration") @ExcludeMissing - fun _billingCycleAnchorConfiguration(): JsonField = + fun _billingCycleAnchorConfiguration(): JsonField = billingCycleAnchorConfiguration /** @@ -1034,7 +1032,8 @@ private constructor( */ @JsonProperty("remove_adjustments") @ExcludeMissing - fun _removeAdjustments(): JsonField> = removeAdjustments + fun _removeAdjustments(): JsonField> = + removeAdjustments /** * Plan prices to be removed from the subscription. (Only available for accounts that have @@ -1042,7 +1041,7 @@ private constructor( */ @JsonProperty("remove_prices") @ExcludeMissing - fun _removePrices(): JsonField> = removePrices + fun _removePrices(): JsonField> = removePrices /** * Plan adjustments to be replaced with additional adjustments on the subscription. (Only @@ -1050,7 +1049,8 @@ private constructor( */ @JsonProperty("replace_adjustments") @ExcludeMissing - fun _replaceAdjustments(): JsonField> = replaceAdjustments + fun _replaceAdjustments(): JsonField> = + replaceAdjustments /** * Plan prices to be replaced with additional prices on the subscription. (Only available @@ -1058,7 +1058,7 @@ private constructor( */ @JsonProperty("replace_prices") @ExcludeMissing - fun _replacePrices(): JsonField> = replacePrices + fun _replacePrices(): JsonField> = replacePrices @JsonProperty("start_date") @ExcludeMissing @@ -1132,19 +1132,21 @@ private constructor( 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 addAdjustments: JsonField>? = null - private var addPrices: JsonField>? = null + private var addAdjustments: JsonField>? = + null + private var addPrices: JsonField>? = null private var alignBillingWithSubscriptionStartDate: JsonField = JsonMissing.of() private var autoCollection: JsonField = JsonMissing.of() private var awsRegion: JsonField = JsonMissing.of() private var billingCycleAnchorConfiguration: - JsonField = + JsonField = JsonMissing.of() private var couponRedemptionCode: JsonField = JsonMissing.of() private var creditsOverageRate: JsonField = JsonMissing.of() @@ -1164,10 +1166,15 @@ private constructor( private var planId: JsonField = JsonMissing.of() private var planVersionNumber: JsonField = JsonMissing.of() private var priceOverrides: JsonField>? = null - private var removeAdjustments: JsonField>? = null - private var removePrices: JsonField>? = null - private var replaceAdjustments: JsonField>? = null - private var replacePrices: JsonField>? = null + private var removeAdjustments: + JsonField>? = + null + private var removePrices: JsonField>? = null + private var replaceAdjustments: + JsonField>? = + null + private var replacePrices: JsonField>? = + null private var startDate: JsonField = JsonMissing.of() private var trialDurationDays: JsonField = JsonMissing.of() private var usageCustomerIds: JsonField>? = null @@ -1213,38 +1220,33 @@ private constructor( * Additional adjustments to be added to the subscription. (Only available for accounts * that have migrated off of legacy subscription overrides) */ - fun addAdjustments(addAdjustments: List?) = + fun addAdjustments(addAdjustments: List?) = addAdjustments(JsonField.ofNullable(addAdjustments)) /** * Additional adjustments to be added to the subscription. (Only available for accounts * that have migrated off of legacy subscription overrides) */ - fun addAdjustments(addAdjustments: Optional>) = + fun addAdjustments(addAdjustments: Optional>) = addAdjustments(addAdjustments.orElse(null)) /** * Additional adjustments to be added to the subscription. (Only available for accounts * that have migrated off of legacy subscription overrides) */ - fun addAdjustments(addAdjustments: JsonField>) = apply { - this.addAdjustments = addAdjustments.map { it.toMutableList() } - } + fun addAdjustments(addAdjustments: JsonField>) = + apply { + this.addAdjustments = addAdjustments.map { it.toMutableList() } + } /** * Additional adjustments to be added to the subscription. (Only available for accounts * that have migrated off of legacy subscription overrides) */ - fun addAddAdjustment(addAdjustment: AddAdjustment) = apply { + fun addAddAdjustment(addAdjustment: AddSubscriptionAdjustmentParams) = apply { addAdjustments = - (addAdjustments ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(addAdjustment) + (addAdjustments ?: JsonField.of(mutableListOf())).also { + checkKnown("addAdjustments", it).add(addAdjustment) } } @@ -1252,19 +1254,21 @@ private constructor( * Additional prices to be added to the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun addPrices(addPrices: List?) = addPrices(JsonField.ofNullable(addPrices)) + fun addPrices(addPrices: List?) = + addPrices(JsonField.ofNullable(addPrices)) /** * Additional prices to be added to the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun addPrices(addPrices: Optional>) = addPrices(addPrices.orElse(null)) + fun addPrices(addPrices: Optional>) = + addPrices(addPrices.orElse(null)) /** * Additional prices to be added to the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun addPrices(addPrices: JsonField>) = apply { + fun addPrices(addPrices: JsonField>) = apply { this.addPrices = addPrices.map { it.toMutableList() } } @@ -1272,16 +1276,10 @@ private constructor( * Additional prices to be added to the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun addAddPrice(addPrice: AddPrice) = apply { + fun addAddPrice(addPrice: AddSubscriptionPriceParams) = apply { addPrices = - (addPrices ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(addPrice) + (addPrices ?: JsonField.of(mutableListOf())).also { + checkKnown("addPrices", it).add(addPrice) } } @@ -1341,18 +1339,18 @@ private constructor( fun awsRegion(awsRegion: JsonField) = apply { this.awsRegion = awsRegion } fun billingCycleAnchorConfiguration( - billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration? + billingCycleAnchorConfiguration: BillingCycleAnchorConfigurationModel? ) = billingCycleAnchorConfiguration( JsonField.ofNullable(billingCycleAnchorConfiguration) ) fun billingCycleAnchorConfiguration( - billingCycleAnchorConfiguration: Optional + billingCycleAnchorConfiguration: Optional ) = billingCycleAnchorConfiguration(billingCycleAnchorConfiguration.orElse(null)) fun billingCycleAnchorConfiguration( - billingCycleAnchorConfiguration: JsonField + billingCycleAnchorConfiguration: JsonField ) = apply { this.billingCycleAnchorConfiguration = billingCycleAnchorConfiguration } /** @@ -1691,14 +1689,8 @@ private constructor( @Deprecated("deprecated") fun addPriceOverride(priceOverride: JsonValue) = apply { priceOverrides = - (priceOverrides ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(priceOverride) + (priceOverrides ?: JsonField.of(mutableListOf())).also { + checkKnown("priceOverrides", it).add(priceOverride) } } @@ -1706,38 +1698,33 @@ private constructor( * Plan adjustments to be removed from the subscription. (Only available for accounts * that have migrated off of legacy subscription overrides) */ - fun removeAdjustments(removeAdjustments: List?) = + fun removeAdjustments(removeAdjustments: List?) = removeAdjustments(JsonField.ofNullable(removeAdjustments)) /** * Plan adjustments to be removed from the subscription. (Only available for accounts * that have migrated off of legacy subscription overrides) */ - fun removeAdjustments(removeAdjustments: Optional>) = - removeAdjustments(removeAdjustments.orElse(null)) + fun removeAdjustments( + removeAdjustments: Optional> + ) = removeAdjustments(removeAdjustments.orElse(null)) /** * Plan adjustments to be removed from the subscription. (Only available for accounts * that have migrated off of legacy subscription overrides) */ - fun removeAdjustments(removeAdjustments: JsonField>) = apply { - this.removeAdjustments = removeAdjustments.map { it.toMutableList() } - } + fun removeAdjustments( + removeAdjustments: JsonField> + ) = apply { this.removeAdjustments = removeAdjustments.map { it.toMutableList() } } /** * Plan adjustments to be removed from the subscription. (Only available for accounts * that have migrated off of legacy subscription overrides) */ - fun addRemoveAdjustment(removeAdjustment: RemoveAdjustment) = apply { + fun addRemoveAdjustment(removeAdjustment: RemoveSubscriptionAdjustmentParams) = apply { removeAdjustments = - (removeAdjustments ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(removeAdjustment) + (removeAdjustments ?: JsonField.of(mutableListOf())).also { + checkKnown("removeAdjustments", it).add(removeAdjustment) } } @@ -1745,21 +1732,21 @@ private constructor( * Plan prices to be removed from the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun removePrices(removePrices: List?) = + fun removePrices(removePrices: List?) = removePrices(JsonField.ofNullable(removePrices)) /** * Plan prices to be removed from the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun removePrices(removePrices: Optional>) = + fun removePrices(removePrices: Optional>) = removePrices(removePrices.orElse(null)) /** * Plan prices to be removed from the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun removePrices(removePrices: JsonField>) = apply { + fun removePrices(removePrices: JsonField>) = apply { this.removePrices = removePrices.map { it.toMutableList() } } @@ -1767,16 +1754,10 @@ private constructor( * Plan prices to be removed from the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun addRemovePrice(removePrice: RemovePrice) = apply { + fun addRemovePrice(removePrice: RemoveSubscriptionPriceParams) = apply { removePrices = - (removePrices ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(removePrice) + (removePrices ?: JsonField.of(mutableListOf())).also { + checkKnown("removePrices", it).add(removePrice) } } @@ -1784,77 +1765,68 @@ private constructor( * Plan adjustments to be replaced with additional adjustments on the subscription. * (Only available for accounts that have migrated off of legacy subscription overrides) */ - fun replaceAdjustments(replaceAdjustments: List?) = + fun replaceAdjustments(replaceAdjustments: List?) = replaceAdjustments(JsonField.ofNullable(replaceAdjustments)) /** * Plan adjustments to be replaced with additional adjustments on the subscription. * (Only available for accounts that have migrated off of legacy subscription overrides) */ - fun replaceAdjustments(replaceAdjustments: Optional>) = - replaceAdjustments(replaceAdjustments.orElse(null)) + fun replaceAdjustments( + replaceAdjustments: Optional> + ) = replaceAdjustments(replaceAdjustments.orElse(null)) /** * Plan adjustments to be replaced with additional adjustments on the subscription. * (Only available for accounts that have migrated off of legacy subscription overrides) */ - fun replaceAdjustments(replaceAdjustments: JsonField>) = apply { - this.replaceAdjustments = replaceAdjustments.map { it.toMutableList() } - } + fun replaceAdjustments( + replaceAdjustments: JsonField> + ) = apply { this.replaceAdjustments = replaceAdjustments.map { it.toMutableList() } } /** * Plan adjustments to be replaced with additional adjustments on the subscription. * (Only available for accounts that have migrated off of legacy subscription overrides) */ - fun addReplaceAdjustment(replaceAdjustment: ReplaceAdjustment) = apply { - replaceAdjustments = - (replaceAdjustments ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(replaceAdjustment) - } - } + fun addReplaceAdjustment(replaceAdjustment: ReplaceSubscriptionAdjustmentParams) = + apply { + replaceAdjustments = + (replaceAdjustments ?: JsonField.of(mutableListOf())).also { + checkKnown("replaceAdjustments", it).add(replaceAdjustment) + } + } /** * Plan prices to be replaced with additional prices on the subscription. (Only * available for accounts that have migrated off of legacy subscription overrides) */ - fun replacePrices(replacePrices: List?) = + fun replacePrices(replacePrices: List?) = replacePrices(JsonField.ofNullable(replacePrices)) /** * Plan prices to be replaced with additional prices on the subscription. (Only * available for accounts that have migrated off of legacy subscription overrides) */ - fun replacePrices(replacePrices: Optional>) = + fun replacePrices(replacePrices: Optional>) = replacePrices(replacePrices.orElse(null)) /** * Plan prices to be replaced with additional prices on the subscription. (Only * available for accounts that have migrated off of legacy subscription overrides) */ - fun replacePrices(replacePrices: JsonField>) = apply { - this.replacePrices = replacePrices.map { it.toMutableList() } - } + fun replacePrices(replacePrices: JsonField>) = + apply { + this.replacePrices = replacePrices.map { it.toMutableList() } + } /** * Plan prices to be replaced with additional prices on the subscription. (Only * available for accounts that have migrated off of legacy subscription overrides) */ - fun addReplacePrice(replacePrice: ReplacePrice) = apply { + fun addReplacePrice(replacePrice: ReplaceSubscriptionPriceParams) = apply { replacePrices = - (replacePrices ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(replacePrice) + (replacePrices ?: JsonField.of(mutableListOf())).also { + checkKnown("replacePrices", it).add(replacePrice) } } @@ -1940,14 +1912,8 @@ private constructor( */ fun addUsageCustomerId(usageCustomerId: String) = apply { usageCustomerIds = - (usageCustomerIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(usageCustomerId) + (usageCustomerIds ?: JsonField.of(mutableListOf())).also { + checkKnown("usageCustomerIds", it).add(usageCustomerId) } } @@ -2029,6 +1995,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [SubscriptionCreateParams]. */ @JvmStatic fun builder() = Builder() } @@ -2051,7 +2018,7 @@ private constructor( * Additional adjustments to be added to the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun addAdjustments(addAdjustments: List?) = apply { + fun addAdjustments(addAdjustments: List?) = apply { body.addAdjustments(addAdjustments) } @@ -2059,22 +2026,23 @@ private constructor( * Additional adjustments to be added to the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun addAdjustments(addAdjustments: Optional>) = + fun addAdjustments(addAdjustments: Optional>) = addAdjustments(addAdjustments.orElse(null)) /** * Additional adjustments to be added to the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun addAdjustments(addAdjustments: JsonField>) = apply { - body.addAdjustments(addAdjustments) - } + fun addAdjustments(addAdjustments: JsonField>) = + apply { + body.addAdjustments(addAdjustments) + } /** * Additional adjustments to be added to the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun addAddAdjustment(addAdjustment: AddAdjustment) = apply { + fun addAddAdjustment(addAdjustment: AddSubscriptionAdjustmentParams) = apply { body.addAddAdjustment(addAdjustment) } @@ -2082,25 +2050,30 @@ private constructor( * Additional prices to be added to the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) */ - fun addPrices(addPrices: List?) = apply { body.addPrices(addPrices) } + fun addPrices(addPrices: List?) = apply { + body.addPrices(addPrices) + } /** * Additional prices to be added to the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) */ - fun addPrices(addPrices: Optional>) = addPrices(addPrices.orElse(null)) + fun addPrices(addPrices: Optional>) = + addPrices(addPrices.orElse(null)) /** * Additional prices to be added to the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) */ - fun addPrices(addPrices: JsonField>) = apply { body.addPrices(addPrices) } + fun addPrices(addPrices: JsonField>) = apply { + body.addPrices(addPrices) + } /** * Additional prices to be added to the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) */ - fun addAddPrice(addPrice: AddPrice) = apply { body.addAddPrice(addPrice) } + fun addAddPrice(addPrice: AddSubscriptionPriceParams) = apply { body.addAddPrice(addPrice) } fun alignBillingWithSubscriptionStartDate(alignBillingWithSubscriptionStartDate: Boolean) = apply { @@ -2155,15 +2128,15 @@ private constructor( fun awsRegion(awsRegion: JsonField) = apply { body.awsRegion(awsRegion) } fun billingCycleAnchorConfiguration( - billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration? + billingCycleAnchorConfiguration: BillingCycleAnchorConfigurationModel? ) = apply { body.billingCycleAnchorConfiguration(billingCycleAnchorConfiguration) } fun billingCycleAnchorConfiguration( - billingCycleAnchorConfiguration: Optional + billingCycleAnchorConfiguration: Optional ) = billingCycleAnchorConfiguration(billingCycleAnchorConfiguration.orElse(null)) fun billingCycleAnchorConfiguration( - billingCycleAnchorConfiguration: JsonField + billingCycleAnchorConfiguration: JsonField ) = apply { body.billingCycleAnchorConfiguration(billingCycleAnchorConfiguration) } /** @@ -2518,30 +2491,32 @@ private constructor( * Plan adjustments to be removed from the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun removeAdjustments(removeAdjustments: List?) = apply { - body.removeAdjustments(removeAdjustments) - } + fun removeAdjustments(removeAdjustments: List?) = + apply { + body.removeAdjustments(removeAdjustments) + } /** * Plan adjustments to be removed from the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun removeAdjustments(removeAdjustments: Optional>) = - removeAdjustments(removeAdjustments.orElse(null)) + fun removeAdjustments( + removeAdjustments: Optional> + ) = removeAdjustments(removeAdjustments.orElse(null)) /** * Plan adjustments to be removed from the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun removeAdjustments(removeAdjustments: JsonField>) = apply { - body.removeAdjustments(removeAdjustments) - } + fun removeAdjustments( + removeAdjustments: JsonField> + ) = apply { body.removeAdjustments(removeAdjustments) } /** * Plan adjustments to be removed from the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun addRemoveAdjustment(removeAdjustment: RemoveAdjustment) = apply { + fun addRemoveAdjustment(removeAdjustment: RemoveSubscriptionAdjustmentParams) = apply { body.addRemoveAdjustment(removeAdjustment) } @@ -2549,7 +2524,7 @@ private constructor( * Plan prices to be removed from the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) */ - fun removePrices(removePrices: List?) = apply { + fun removePrices(removePrices: List?) = apply { body.removePrices(removePrices) } @@ -2557,14 +2532,14 @@ private constructor( * Plan prices to be removed from the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) */ - fun removePrices(removePrices: Optional>) = + fun removePrices(removePrices: Optional>) = removePrices(removePrices.orElse(null)) /** * Plan prices to be removed from the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) */ - fun removePrices(removePrices: JsonField>) = apply { + fun removePrices(removePrices: JsonField>) = apply { body.removePrices(removePrices) } @@ -2572,36 +2547,40 @@ private constructor( * Plan prices to be removed from the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) */ - fun addRemovePrice(removePrice: RemovePrice) = apply { body.addRemovePrice(removePrice) } + fun addRemovePrice(removePrice: RemoveSubscriptionPriceParams) = apply { + body.addRemovePrice(removePrice) + } /** * Plan adjustments to be replaced with additional adjustments on the subscription. (Only * available for accounts that have migrated off of legacy subscription overrides) */ - fun replaceAdjustments(replaceAdjustments: List?) = apply { - body.replaceAdjustments(replaceAdjustments) - } + fun replaceAdjustments(replaceAdjustments: List?) = + apply { + body.replaceAdjustments(replaceAdjustments) + } /** * Plan adjustments to be replaced with additional adjustments on the subscription. (Only * available for accounts that have migrated off of legacy subscription overrides) */ - fun replaceAdjustments(replaceAdjustments: Optional>) = - replaceAdjustments(replaceAdjustments.orElse(null)) + fun replaceAdjustments( + replaceAdjustments: Optional> + ) = replaceAdjustments(replaceAdjustments.orElse(null)) /** * Plan adjustments to be replaced with additional adjustments on the subscription. (Only * available for accounts that have migrated off of legacy subscription overrides) */ - fun replaceAdjustments(replaceAdjustments: JsonField>) = apply { - body.replaceAdjustments(replaceAdjustments) - } + fun replaceAdjustments( + replaceAdjustments: JsonField> + ) = apply { body.replaceAdjustments(replaceAdjustments) } /** * Plan adjustments to be replaced with additional adjustments on the subscription. (Only * available for accounts that have migrated off of legacy subscription overrides) */ - fun addReplaceAdjustment(replaceAdjustment: ReplaceAdjustment) = apply { + fun addReplaceAdjustment(replaceAdjustment: ReplaceSubscriptionAdjustmentParams) = apply { body.addReplaceAdjustment(replaceAdjustment) } @@ -2609,7 +2588,7 @@ private constructor( * Plan prices to be replaced with additional prices on the subscription. (Only available * for accounts that have migrated off of legacy subscription overrides) */ - fun replacePrices(replacePrices: List?) = apply { + fun replacePrices(replacePrices: List?) = apply { body.replacePrices(replacePrices) } @@ -2617,14 +2596,14 @@ private constructor( * Plan prices to be replaced with additional prices on the subscription. (Only available * for accounts that have migrated off of legacy subscription overrides) */ - fun replacePrices(replacePrices: Optional>) = + fun replacePrices(replacePrices: Optional>) = replacePrices(replacePrices.orElse(null)) /** * Plan prices to be replaced with additional prices on the subscription. (Only available * for accounts that have migrated off of legacy subscription overrides) */ - fun replacePrices(replacePrices: JsonField>) = apply { + fun replacePrices(replacePrices: JsonField>) = apply { body.replacePrices(replacePrices) } @@ -2632,7 +2611,7 @@ private constructor( * Plan prices to be replaced with additional prices on the subscription. (Only available * for accounts that have migrated off of legacy subscription overrides) */ - fun addReplacePrice(replacePrice: ReplacePrice) = apply { + fun addReplacePrice(replacePrice: ReplaceSubscriptionPriceParams) = apply { body.addReplacePrice(replacePrice) } @@ -2841,74 +2820,127 @@ private constructor( ) } - @NoAutoDetect - class AddAdjustment + @Deprecated("deprecated") + class ExternalMarketplace @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - private val adjustment: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + private constructor(private val value: JsonField) : Enum { /** - * The end date of the adjustment interval. This is the date that the adjustment will stop - * affecting prices on the subscription. + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if 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 endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val GOOGLE = of("google") + + @JvmField val AWS = of("aws") - /** The phase to add this adjustment to. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + @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, + } /** - * The start date of the adjustment interval. This is the date that the adjustment will - * start affecting prices on the subscription. If null, the adjustment will start when the - * phase or subscription starts. + * 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. */ - fun startDate(): Optional = - Optional.ofNullable(startDate.getNullable("start_date")) - - /** The definition of a new adjustment to create and add to the subscription. */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment + enum class Value { + GOOGLE, + AWS, + AZURE, + /** + * An enum member indicating that [ExternalMarketplace] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } /** - * The end date of the adjustment interval. This is the date that the adjustment will stop - * affecting prices on the subscription. + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate + fun value(): Value = + when (this) { + GOOGLE -> Value.GOOGLE + AWS -> Value.AWS + AZURE -> Value.AZURE + else -> Value._UNKNOWN + } - /** The phase to add this adjustment to. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + GOOGLE -> Known.GOOGLE + AWS -> Known.AWS + AZURE -> Known.AZURE + else -> throw OrbInvalidDataException("Unknown ExternalMarketplace: $value") + } /** - * The start date of the adjustment interval. This is the date that the adjustment will - * start affecting prices on the subscription. If null, the adjustment will start when the - * phase or subscription starts. + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ExternalMarketplace && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by setting + * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to + * `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { @JsonAnyGetter @ExcludeMissing @@ -2916,15 +2948,11 @@ private constructor( private var validated: Boolean = false - fun validate(): AddAdjustment = apply { + fun validate(): Metadata = apply { if (validated) { return@apply } - adjustment().validate() - endDate() - planPhaseOrder() - startDate() validated = true } @@ -2932,111 +2960,18 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [AddAdjustment]. */ + /** A builder for [Metadata]. */ class Builder internal constructor() { - private var adjustment: JsonField? = null - private var endDate: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(addAdjustment: AddAdjustment) = apply { - adjustment = addAdjustment.adjustment - endDate = addAdjustment.endDate - planPhaseOrder = addAdjustment.planPhaseOrder - startDate = addAdjustment.startDate - additionalProperties = addAdjustment.additionalProperties.toMutableMap() - } - - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) - - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } - - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(newPercentageDiscount: Adjustment.NewPercentageDiscount) = - adjustment(Adjustment.ofNewPercentageDiscount(newPercentageDiscount)) - - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(newUsageDiscount: Adjustment.NewUsageDiscount) = - adjustment(Adjustment.ofNewUsageDiscount(newUsageDiscount)) - - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(newAmountDiscount: Adjustment.NewAmountDiscount) = - adjustment(Adjustment.ofNewAmountDiscount(newAmountDiscount)) - - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(newMinimum: Adjustment.NewMinimum) = - adjustment(Adjustment.ofNewMinimum(newMinimum)) - - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(newMaximum: Adjustment.NewMaximum) = - adjustment(Adjustment.ofNewMaximum(newMaximum)) - - /** - * The end date of the adjustment interval. This is the date that the adjustment will - * stop affecting prices on the subscription. - */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** - * The end date of the adjustment interval. This is the date that the adjustment will - * stop affecting prices on the subscription. - */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** - * The end date of the adjustment interval. This is the date that the adjustment will - * stop affecting prices on the subscription. - */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** The phase to add this adjustment to. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The phase to add this adjustment to. */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - - /** The phase to add this adjustment to. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The phase to add this adjustment to. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** - * The start date of the adjustment interval. This is the date that the adjustment will - * start affecting prices on the subscription. If null, the adjustment will start when - * the phase or subscription starts. - */ - fun startDate(startDate: OffsetDateTime?) = startDate(JsonField.ofNullable(startDate)) - - /** - * The start date of the adjustment interval. This is the date that the adjustment will - * start affecting prices on the subscription. If null, the adjustment will start when - * the phase or subscription starts. - */ - fun startDate(startDate: Optional) = startDate(startDate.orElse(null)) - - /** - * The start date of the adjustment interval. This is the date that the adjustment will - * start affecting prices on the subscription. If null, the adjustment will start when - * the phase or subscription starts. - */ - fun startDate(startDate: JsonField) = apply { - this.startDate = startDate + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -3058,67867 +2993,24 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): AddAdjustment = - AddAdjustment( - checkRequired("adjustment", adjustment), - endDate, - planPhaseOrder, - startDate, - additionalProperties.toImmutable(), - ) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } - /** The definition of a new adjustment to create and add to the subscription. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val newPercentageDiscount: NewPercentageDiscount? = null, - private val newUsageDiscount: NewUsageDiscount? = null, - private val newAmountDiscount: NewAmountDiscount? = null, - private val newMinimum: NewMinimum? = null, - private val newMaximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { - - fun newPercentageDiscount(): Optional = - Optional.ofNullable(newPercentageDiscount) - - fun newUsageDiscount(): Optional = - Optional.ofNullable(newUsageDiscount) - - fun newAmountDiscount(): Optional = - Optional.ofNullable(newAmountDiscount) - - fun newMinimum(): Optional = Optional.ofNullable(newMinimum) - - fun newMaximum(): Optional = Optional.ofNullable(newMaximum) - - fun isNewPercentageDiscount(): Boolean = newPercentageDiscount != null - - fun isNewUsageDiscount(): Boolean = newUsageDiscount != null - - fun isNewAmountDiscount(): Boolean = newAmountDiscount != null - - fun isNewMinimum(): Boolean = newMinimum != null - - fun isNewMaximum(): Boolean = newMaximum != null - - fun asNewPercentageDiscount(): NewPercentageDiscount = - newPercentageDiscount.getOrThrow("newPercentageDiscount") - - fun asNewUsageDiscount(): NewUsageDiscount = - newUsageDiscount.getOrThrow("newUsageDiscount") - - fun asNewAmountDiscount(): NewAmountDiscount = - newAmountDiscount.getOrThrow("newAmountDiscount") - - fun asNewMinimum(): NewMinimum = newMinimum.getOrThrow("newMinimum") - - fun asNewMaximum(): NewMaximum = newMaximum.getOrThrow("newMaximum") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - newPercentageDiscount != null -> - visitor.visitNewPercentageDiscount(newPercentageDiscount) - newUsageDiscount != null -> visitor.visitNewUsageDiscount(newUsageDiscount) - newAmountDiscount != null -> visitor.visitNewAmountDiscount(newAmountDiscount) - newMinimum != null -> visitor.visitNewMinimum(newMinimum) - newMaximum != null -> visitor.visitNewMaximum(newMaximum) - else -> visitor.unknown(_json) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - private var validated: Boolean = false - - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitNewPercentageDiscount( - newPercentageDiscount: NewPercentageDiscount - ) { - newPercentageDiscount.validate() - } - - override fun visitNewUsageDiscount(newUsageDiscount: NewUsageDiscount) { - newUsageDiscount.validate() - } + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } - override fun visitNewAmountDiscount(newAmountDiscount: NewAmountDiscount) { - newAmountDiscount.validate() - } + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun visitNewMinimum(newMinimum: NewMinimum) { - newMinimum.validate() - } + override fun hashCode(): Int = hashCode - override fun visitNewMaximum(newMaximum: NewMaximum) { - newMaximum.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Adjustment && newPercentageDiscount == other.newPercentageDiscount && newUsageDiscount == other.newUsageDiscount && newAmountDiscount == other.newAmountDiscount && newMinimum == other.newMinimum && newMaximum == other.newMaximum /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(newPercentageDiscount, newUsageDiscount, newAmountDiscount, newMinimum, newMaximum) /* spotless:on */ - - override fun toString(): String = - when { - newPercentageDiscount != null -> - "Adjustment{newPercentageDiscount=$newPercentageDiscount}" - newUsageDiscount != null -> "Adjustment{newUsageDiscount=$newUsageDiscount}" - newAmountDiscount != null -> "Adjustment{newAmountDiscount=$newAmountDiscount}" - newMinimum != null -> "Adjustment{newMinimum=$newMinimum}" - newMaximum != null -> "Adjustment{newMaximum=$newMaximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } - - companion object { - - @JvmStatic - fun ofNewPercentageDiscount(newPercentageDiscount: NewPercentageDiscount) = - Adjustment(newPercentageDiscount = newPercentageDiscount) - - @JvmStatic - fun ofNewUsageDiscount(newUsageDiscount: NewUsageDiscount) = - Adjustment(newUsageDiscount = newUsageDiscount) - - @JvmStatic - fun ofNewAmountDiscount(newAmountDiscount: NewAmountDiscount) = - Adjustment(newAmountDiscount = newAmountDiscount) - - @JvmStatic - fun ofNewMinimum(newMinimum: NewMinimum) = Adjustment(newMinimum = newMinimum) - - @JvmStatic - fun ofNewMaximum(newMaximum: NewMaximum) = Adjustment(newMaximum = newMaximum) - } - - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { - - fun visitNewPercentageDiscount(newPercentageDiscount: NewPercentageDiscount): T - - fun visitNewUsageDiscount(newUsageDiscount: NewUsageDiscount): T - - fun visitNewAmountDiscount(newAmountDiscount: NewAmountDiscount): T - - fun visitNewMinimum(newMinimum: NewMinimum): T - - fun visitNewMaximum(newMaximum: 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" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(newPercentageDiscount = it, _json = json) - } - } - "usage_discount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(newUsageDiscount = it, _json = json) - } - } - "amount_discount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(newAmountDiscount = it, _json = json) - } - } - "minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Adjustment(newMinimum = it, _json = json) - } - } - "maximum" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Adjustment(newMaximum = it, _json = json) - } - } - } - - return Adjustment(_json = json) - } - } - - internal class Serializer : BaseSerializer(Adjustment::class) { - - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.newPercentageDiscount != null -> - generator.writeObject(value.newPercentageDiscount) - value.newUsageDiscount != null -> - generator.writeObject(value.newUsageDiscount) - value.newAmountDiscount != null -> - generator.writeObject(value.newAmountDiscount) - value.newMinimum != null -> generator.writeObject(value.newMinimum) - value.newMaximum != null -> generator.writeObject(value.newMaximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") - } - } - } - - @NoAutoDetect - class NewPercentageDiscount - @JsonCreator - private constructor( - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("percentage_discount") - @ExcludeMissing - private val percentageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - fun percentageDiscount(): Double = - percentageDiscount.getRequired("percentage_discount") - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(): Optional = - Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The set of price IDs to which this adjustment applies. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - @JsonProperty("percentage_discount") - @ExcludeMissing - fun _percentageDiscount(): JsonField = percentageDiscount - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewPercentageDiscount = apply { - if (validated) { - return@apply - } - - adjustmentType() - appliesToPriceIds() - percentageDiscount() - isInvoiceLevel() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewPercentageDiscount]. */ - class Builder internal constructor() { - - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var percentageDiscount: JsonField? = null - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newPercentageDiscount: NewPercentageDiscount) = apply { - adjustmentType = newPercentageDiscount.adjustmentType - appliesToPriceIds = - newPercentageDiscount.appliesToPriceIds.map { it.toMutableList() } - percentageDiscount = newPercentageDiscount.percentageDiscount - isInvoiceLevel = newPercentageDiscount.isInvoiceLevel - additionalProperties = - newPercentageDiscount.additionalProperties.toMutableMap() - } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The set of price IDs to which this adjustment applies. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - fun percentageDiscount(percentageDiscount: Double) = - percentageDiscount(JsonField.of(percentageDiscount)) - - fun percentageDiscount(percentageDiscount: JsonField) = apply { - this.percentageDiscount = percentageDiscount - } - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): NewPercentageDiscount = - NewPercentageDiscount( - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("percentageDiscount", percentageDiscount), - isInvoiceLevel, - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val PERCENTAGE_DISCOUNT = of("percentage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewPercentageDiscount && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && percentageDiscount == other.percentageDiscount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustmentType, appliesToPriceIds, percentageDiscount, isInvoiceLevel, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewPercentageDiscount{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, percentageDiscount=$percentageDiscount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewUsageDiscount - @JsonCreator - private constructor( - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("usage_discount") - @ExcludeMissing - private val usageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(): Optional = - Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The set of price IDs to which this adjustment applies. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - @JsonProperty("usage_discount") - @ExcludeMissing - fun _usageDiscount(): JsonField = usageDiscount - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewUsageDiscount = apply { - if (validated) { - return@apply - } - - adjustmentType() - appliesToPriceIds() - usageDiscount() - isInvoiceLevel() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewUsageDiscount]. */ - class Builder internal constructor() { - - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var usageDiscount: JsonField? = null - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newUsageDiscount: NewUsageDiscount) = apply { - adjustmentType = newUsageDiscount.adjustmentType - appliesToPriceIds = - newUsageDiscount.appliesToPriceIds.map { it.toMutableList() } - usageDiscount = newUsageDiscount.usageDiscount - isInvoiceLevel = newUsageDiscount.isInvoiceLevel - additionalProperties = newUsageDiscount.additionalProperties.toMutableMap() - } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The set of price IDs to which this adjustment applies. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - fun usageDiscount(usageDiscount: Double) = - usageDiscount(JsonField.of(usageDiscount)) - - fun usageDiscount(usageDiscount: JsonField) = apply { - this.usageDiscount = usageDiscount - } - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): NewUsageDiscount = - NewUsageDiscount( - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("usageDiscount", usageDiscount), - isInvoiceLevel, - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - USAGE_DISCOUNT -> Known.USAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewUsageDiscount && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && usageDiscount == other.usageDiscount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustmentType, appliesToPriceIds, usageDiscount, isInvoiceLevel, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewUsageDiscount{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, usageDiscount=$usageDiscount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewAmountDiscount - @JsonCreator - private constructor( - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("amount_discount") - @ExcludeMissing - private val amountDiscount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(): Optional = - Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - @JsonProperty("amount_discount") - @ExcludeMissing - fun _amountDiscount(): JsonField = amountDiscount - - /** The set of price IDs to which this adjustment applies. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewAmountDiscount = apply { - if (validated) { - return@apply - } - - adjustmentType() - amountDiscount() - appliesToPriceIds() - isInvoiceLevel() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewAmountDiscount]. */ - class Builder internal constructor() { - - private var adjustmentType: JsonField? = null - private var amountDiscount: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newAmountDiscount: NewAmountDiscount) = apply { - adjustmentType = newAmountDiscount.adjustmentType - amountDiscount = newAmountDiscount.amountDiscount - appliesToPriceIds = - newAmountDiscount.appliesToPriceIds.map { it.toMutableList() } - isInvoiceLevel = newAmountDiscount.isInvoiceLevel - additionalProperties = newAmountDiscount.additionalProperties.toMutableMap() - } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - fun amountDiscount(amountDiscount: String) = - amountDiscount(JsonField.of(amountDiscount)) - - fun amountDiscount(amountDiscount: JsonField) = apply { - this.amountDiscount = amountDiscount - } - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The set of price IDs to which this adjustment applies. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): NewAmountDiscount = - NewAmountDiscount( - checkRequired("adjustmentType", adjustmentType), - checkRequired("amountDiscount", amountDiscount), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - isInvoiceLevel, - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewAmountDiscount && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustmentType, amountDiscount, appliesToPriceIds, isInvoiceLevel, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewAmountDiscount{adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewMinimum - @JsonCreator - private constructor( - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(): Optional = - Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The set of price IDs to which this adjustment applies. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The item ID that revenue from this minimum will be attributed to. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewMinimum = apply { - if (validated) { - return@apply - } - - adjustmentType() - appliesToPriceIds() - itemId() - minimumAmount() - isInvoiceLevel() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewMinimum]. */ - class Builder internal constructor() { - - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var itemId: JsonField? = null - private var minimumAmount: JsonField? = null - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newMinimum: NewMinimum) = apply { - adjustmentType = newMinimum.adjustmentType - appliesToPriceIds = newMinimum.appliesToPriceIds.map { it.toMutableList() } - itemId = newMinimum.itemId - minimumAmount = newMinimum.minimumAmount - isInvoiceLevel = newMinimum.isInvoiceLevel - additionalProperties = newMinimum.additionalProperties.toMutableMap() - } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The set of price IDs to which this adjustment applies. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): NewMinimum = - NewMinimum( - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("itemId", itemId), - checkRequired("minimumAmount", minimumAmount), - isInvoiceLevel, - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewMinimum && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && itemId == other.itemId && minimumAmount == other.minimumAmount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustmentType, appliesToPriceIds, itemId, minimumAmount, isInvoiceLevel, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewMinimum{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, itemId=$itemId, minimumAmount=$minimumAmount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewMaximum - @JsonCreator - private constructor( - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(): Optional = - Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The set of price IDs to which this adjustment applies. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewMaximum = apply { - if (validated) { - return@apply - } - - adjustmentType() - appliesToPriceIds() - maximumAmount() - isInvoiceLevel() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewMaximum]. */ - class Builder internal constructor() { - - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newMaximum: NewMaximum) = apply { - adjustmentType = newMaximum.adjustmentType - appliesToPriceIds = newMaximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = newMaximum.maximumAmount - isInvoiceLevel = newMaximum.isInvoiceLevel - additionalProperties = newMaximum.additionalProperties.toMutableMap() - } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The set of price IDs to which this adjustment applies. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): NewMaximum = - NewMaximum( - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("maximumAmount", maximumAmount), - isInvoiceLevel, - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewMaximum && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustmentType, appliesToPriceIds, maximumAmount, isInvoiceLevel, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewMaximum{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AddAdjustment && adjustment == other.adjustment && endDate == other.endDate && planPhaseOrder == other.planPhaseOrder && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustment, endDate, planPhaseOrder, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AddAdjustment{adjustment=$adjustment, endDate=$endDate, planPhaseOrder=$planPhaseOrder, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class AddPrice - @JsonCreator - private constructor( - @JsonProperty("allocation_price") - @ExcludeMissing - private val allocationPrice: JsonField = JsonMissing.of(), - @JsonProperty("discounts") - @ExcludeMissing - private val discounts: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("price") - @ExcludeMissing - private val price: JsonField = JsonMissing.of(), - @JsonProperty("price_id") - @ExcludeMissing - private val priceId: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The definition of a new allocation price to create and add to the subscription. */ - fun allocationPrice(): Optional = - Optional.ofNullable(allocationPrice.getNullable("allocation_price")) - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for this price. - */ - @Deprecated("deprecated") - fun discounts(): Optional> = - Optional.ofNullable(discounts.getNullable("discounts")) - - /** - * The end date of the price interval. This is the date that the price will stop billing on - * the subscription. If null, billing will end when the phase or subscription ends. - */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** The external price id of the price to add to the subscription. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for this - * price. - */ - @Deprecated("deprecated") - fun maximumAmount(): Optional = - Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for this - * price. - */ - @Deprecated("deprecated") - fun minimumAmount(): Optional = - Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) - - /** The phase to add this price to. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The definition of a new price to create and add to the subscription. */ - fun price(): Optional = Optional.ofNullable(price.getNullable("price")) - - /** The id of the price to add to the subscription. */ - fun priceId(): Optional = Optional.ofNullable(priceId.getNullable("price_id")) - - /** - * The start date of the price interval. This is the date that the price will start billing - * on the subscription. If null, billing will start when the phase or subscription starts. - */ - fun startDate(): Optional = - Optional.ofNullable(startDate.getNullable("start_date")) - - /** The definition of a new allocation price to create and add to the subscription. */ - @JsonProperty("allocation_price") - @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for this price. - */ - @Deprecated("deprecated") - @JsonProperty("discounts") - @ExcludeMissing - fun _discounts(): JsonField> = discounts - - /** - * The end date of the price interval. This is the date that the price will stop billing on - * the subscription. If null, billing will end when the phase or subscription ends. - */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** The external price id of the price to add to the subscription. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for this - * price. - */ - @Deprecated("deprecated") - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for this - * price. - */ - @Deprecated("deprecated") - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** The phase to add this price to. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The definition of a new price to create and add to the subscription. */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - - /** The id of the price to add to the subscription. */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - - /** - * The start date of the price interval. This is the date that the price will start billing - * on the subscription. If null, billing will start when the phase or subscription starts. - */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AddPrice = apply { - if (validated) { - return@apply - } - - allocationPrice().ifPresent { it.validate() } - discounts().ifPresent { it.forEach { it.validate() } } - endDate() - externalPriceId() - maximumAmount() - minimumAmount() - planPhaseOrder() - price().ifPresent { it.validate() } - priceId() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AddPrice]. */ - class Builder internal constructor() { - - private var allocationPrice: JsonField = JsonMissing.of() - private var discounts: JsonField>? = null - private var endDate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(addPrice: AddPrice) = apply { - allocationPrice = addPrice.allocationPrice - discounts = addPrice.discounts.map { it.toMutableList() } - endDate = addPrice.endDate - externalPriceId = addPrice.externalPriceId - maximumAmount = addPrice.maximumAmount - minimumAmount = addPrice.minimumAmount - planPhaseOrder = addPrice.planPhaseOrder - price = addPrice.price - priceId = addPrice.priceId - startDate = addPrice.startDate - additionalProperties = addPrice.additionalProperties.toMutableMap() - } - - /** The definition of a new allocation price to create and add to the subscription. */ - fun allocationPrice(allocationPrice: AllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) - - /** The definition of a new allocation price to create and add to the subscription. */ - fun allocationPrice(allocationPrice: Optional) = - allocationPrice(allocationPrice.orElse(null)) - - /** The definition of a new allocation price to create and add to the subscription. */ - fun allocationPrice(allocationPrice: JsonField) = apply { - this.allocationPrice = allocationPrice - } - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for this - * price. - */ - @Deprecated("deprecated") - fun discounts(discounts: List?) = discounts(JsonField.ofNullable(discounts)) - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for this - * price. - */ - @Deprecated("deprecated") - fun discounts(discounts: Optional>) = discounts(discounts.orElse(null)) - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for this - * price. - */ - @Deprecated("deprecated") - fun discounts(discounts: JsonField>) = apply { - this.discounts = discounts.map { it.toMutableList() } - } - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for this - * price. - */ - @Deprecated("deprecated") - fun addDiscount(discount: Discount) = apply { - discounts = - (discounts ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(discount) - } - } - - /** - * The end date of the price interval. This is the date that the price will stop billing - * on the subscription. If null, billing will end when the phase or subscription ends. - */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** - * The end date of the price interval. This is the date that the price will stop billing - * on the subscription. If null, billing will end when the phase or subscription ends. - */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** - * The end date of the price interval. This is the date that the price will stop billing - * on the subscription. If null, billing will end when the phase or subscription ends. - */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** The external price id of the price to add to the subscription. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** The external price id of the price to add to the subscription. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** The external price id of the price to add to the subscription. */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for this - * price. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for this - * price. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.orElse(null)) - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for this - * price. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for this - * price. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for this - * price. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: Optional) = - minimumAmount(minimumAmount.orElse(null)) - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for this - * price. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** The phase to add this price to. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The phase to add this price to. */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - - /** The phase to add this price to. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The phase to add this price to. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The definition of a new price to create and add to the subscription. */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(price: Optional) = price(price.orElse(null)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(price: JsonField) = apply { this.price = price } - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionUnit: Price.NewSubscriptionUnitPrice) = - price(Price.ofNewSubscriptionUnit(newSubscriptionUnit)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionPackage: Price.NewSubscriptionPackagePrice) = - price(Price.ofNewSubscriptionPackage(newSubscriptionPackage)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionMatrix: Price.NewSubscriptionMatrixPrice) = - price(Price.ofNewSubscriptionMatrix(newSubscriptionMatrix)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionTiered: Price.NewSubscriptionTieredPrice) = - price(Price.ofNewSubscriptionTiered(newSubscriptionTiered)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionTieredBps: Price.NewSubscriptionTieredBpsPrice) = - price(Price.ofNewSubscriptionTieredBps(newSubscriptionTieredBps)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionBps: Price.NewSubscriptionBpsPrice) = - price(Price.ofNewSubscriptionBps(newSubscriptionBps)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionBulkBps: Price.NewSubscriptionBulkBpsPrice) = - price(Price.ofNewSubscriptionBulkBps(newSubscriptionBulkBps)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionBulk: Price.NewSubscriptionBulkPrice) = - price(Price.ofNewSubscriptionBulk(newSubscriptionBulk)) - - /** The definition of a new price to create and add to the subscription. */ - fun price( - newSubscriptionThresholdTotalAmount: Price.NewSubscriptionThresholdTotalAmountPrice - ) = - price( - Price.ofNewSubscriptionThresholdTotalAmount(newSubscriptionThresholdTotalAmount) - ) - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionTieredPackage: Price.NewSubscriptionTieredPackagePrice) = - price(Price.ofNewSubscriptionTieredPackage(newSubscriptionTieredPackage)) - - /** The definition of a new price to create and add to the subscription. */ - fun price( - newSubscriptionTieredWithMinimum: Price.NewSubscriptionTieredWithMinimumPrice - ) = price(Price.ofNewSubscriptionTieredWithMinimum(newSubscriptionTieredWithMinimum)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionUnitWithPercent: Price.NewSubscriptionUnitWithPercentPrice) = - price(Price.ofNewSubscriptionUnitWithPercent(newSubscriptionUnitWithPercent)) - - /** The definition of a new price to create and add to the subscription. */ - fun price( - newSubscriptionPackageWithAllocation: - Price.NewSubscriptionPackageWithAllocationPrice - ) = - price( - Price.ofNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation - ) - ) - - /** The definition of a new price to create and add to the subscription. */ - fun price( - newSubscriptionTierWithProration: Price.NewSubscriptionTierWithProrationPrice - ) = price(Price.ofNewSubscriptionTierWithProration(newSubscriptionTierWithProration)) - - /** The definition of a new price to create and add to the subscription. */ - fun price( - newSubscriptionUnitWithProration: Price.NewSubscriptionUnitWithProrationPrice - ) = price(Price.ofNewSubscriptionUnitWithProration(newSubscriptionUnitWithProration)) - - /** The definition of a new price to create and add to the subscription. */ - fun price( - newSubscriptionGroupedAllocation: Price.NewSubscriptionGroupedAllocationPrice - ) = price(Price.ofNewSubscriptionGroupedAllocation(newSubscriptionGroupedAllocation)) - - /** The definition of a new price to create and add to the subscription. */ - fun price( - newSubscriptionGroupedWithProratedMinimum: - Price.NewSubscriptionGroupedWithProratedMinimumPrice - ) = - price( - Price.ofNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum - ) - ) - - /** The definition of a new price to create and add to the subscription. */ - fun price( - newSubscriptionBulkWithProration: Price.NewSubscriptionBulkWithProrationPrice - ) = price(Price.ofNewSubscriptionBulkWithProration(newSubscriptionBulkWithProration)) - - /** The id of the price to add to the subscription. */ - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) - - /** The id of the price to add to the subscription. */ - fun priceId(priceId: Optional) = priceId(priceId.orElse(null)) - - /** The id of the price to add to the subscription. */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - - /** - * The start date of the price interval. This is the date that the price will start - * billing on the subscription. If null, billing will start when the phase or - * subscription starts. - */ - fun startDate(startDate: OffsetDateTime?) = startDate(JsonField.ofNullable(startDate)) - - /** - * The start date of the price interval. This is the date that the price will start - * billing on the subscription. If null, billing will start when the phase or - * subscription starts. - */ - fun startDate(startDate: Optional) = startDate(startDate.orElse(null)) - - /** - * The start date of the price interval. This is the date that the price will start - * billing on the subscription. If null, billing will start when the phase or - * subscription starts. - */ - 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) - } - - fun build(): AddPrice = - AddPrice( - allocationPrice, - (discounts ?: JsonMissing.of()).map { it.toImmutable() }, - endDate, - externalPriceId, - maximumAmount, - minimumAmount, - planPhaseOrder, - price, - priceId, - startDate, - additionalProperties.toImmutable(), - ) - } - - /** The definition of a new allocation price to create and add to the subscription. */ - @NoAutoDetect - class AllocationPrice - @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("expires_at_end_of_cadence") - @ExcludeMissing - private val expiresAtEndOfCadence: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** An amount of the currency to allocate to the customer at the specified cadence. */ - fun amount(): String = amount.getRequired("amount") - - /** The cadence at which to allocate the amount to the customer. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** - * An ISO 4217 currency string or a custom pricing unit identifier in which to bill this - * price. - */ - fun currency(): String = currency.getRequired("currency") - - /** - * Whether the allocated amount should expire at the end of the cadence or roll over to - * the next period. - */ - fun expiresAtEndOfCadence(): Boolean = - expiresAtEndOfCadence.getRequired("expires_at_end_of_cadence") - - /** An amount of the currency to allocate to the customer at the specified cadence. */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** The cadence at which to allocate the amount to the customer. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** - * An ISO 4217 currency string or a custom pricing unit identifier in which to bill this - * price. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** - * Whether the allocated amount should expire at the end of the cadence or roll over to - * the next period. - */ - @JsonProperty("expires_at_end_of_cadence") - @ExcludeMissing - fun _expiresAtEndOfCadence(): JsonField = expiresAtEndOfCadence - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AllocationPrice = apply { - if (validated) { - return@apply - } - - amount() - cadence() - currency() - expiresAtEndOfCadence() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AllocationPrice]. */ - class Builder internal constructor() { - - private var amount: JsonField? = null - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var expiresAtEndOfCadence: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(allocationPrice: AllocationPrice) = apply { - amount = allocationPrice.amount - cadence = allocationPrice.cadence - currency = allocationPrice.currency - expiresAtEndOfCadence = allocationPrice.expiresAtEndOfCadence - additionalProperties = allocationPrice.additionalProperties.toMutableMap() - } - - /** - * An amount of the currency to allocate to the customer at the specified cadence. - */ - fun amount(amount: String) = amount(JsonField.of(amount)) - - /** - * An amount of the currency to allocate to the customer at the specified cadence. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** The cadence at which to allocate the amount to the customer. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence at which to allocate the amount to the customer. */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - /** - * An ISO 4217 currency string or a custom pricing unit identifier in which to bill - * this price. - */ - fun currency(currency: String) = currency(JsonField.of(currency)) - - /** - * An ISO 4217 currency string or a custom pricing unit identifier in which to bill - * this price. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** - * Whether the allocated amount should expire at the end of the cadence or roll over - * to the next period. - */ - fun expiresAtEndOfCadence(expiresAtEndOfCadence: Boolean) = - expiresAtEndOfCadence(JsonField.of(expiresAtEndOfCadence)) - - /** - * Whether the allocated amount should expire at the end of the cadence or roll over - * to the next period. - */ - fun expiresAtEndOfCadence(expiresAtEndOfCadence: JsonField) = apply { - this.expiresAtEndOfCadence = expiresAtEndOfCadence - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): AllocationPrice = - AllocationPrice( - checkRequired("amount", amount), - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("expiresAtEndOfCadence", expiresAtEndOfCadence), - additionalProperties.toImmutable(), - ) - } - - /** The cadence at which to allocate the amount to the customer. */ - 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AllocationPrice && amount == other.amount && cadence == other.cadence && currency == other.currency && expiresAtEndOfCadence == other.expiresAtEndOfCadence && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, cadence, currency, expiresAtEndOfCadence, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AllocationPrice{amount=$amount, cadence=$cadence, currency=$currency, expiresAtEndOfCadence=$expiresAtEndOfCadence, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Discount - @JsonCreator - private constructor( - @JsonProperty("discount_type") - @ExcludeMissing - private val discountType: JsonField = JsonMissing.of(), - @JsonProperty("amount_discount") - @ExcludeMissing - private val amountDiscount: JsonField = JsonMissing.of(), - @JsonProperty("percentage_discount") - @ExcludeMissing - private val percentageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("usage_discount") - @ExcludeMissing - private val usageDiscount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun discountType(): DiscountType = discountType.getRequired("discount_type") - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(): Optional = - Optional.ofNullable(amountDiscount.getNullable("amount_discount")) - - /** - * Only available if discount_type is `percentage`. This is a number between 0 and 1. - */ - fun percentageDiscount(): Optional = - Optional.ofNullable(percentageDiscount.getNullable("percentage_discount")) - - /** - * Only available if discount_type is `usage`. Number of usage units that this discount - * is for - */ - fun usageDiscount(): Optional = - Optional.ofNullable(usageDiscount.getNullable("usage_discount")) - - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - - /** Only available if discount_type is `amount`. */ - @JsonProperty("amount_discount") - @ExcludeMissing - fun _amountDiscount(): JsonField = amountDiscount - - /** - * Only available if discount_type is `percentage`. This is a number between 0 and 1. - */ - @JsonProperty("percentage_discount") - @ExcludeMissing - fun _percentageDiscount(): JsonField = percentageDiscount - - /** - * Only available if discount_type is `usage`. Number of usage units that this discount - * is for - */ - @JsonProperty("usage_discount") - @ExcludeMissing - fun _usageDiscount(): JsonField = usageDiscount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Discount = apply { - if (validated) { - return@apply - } - - discountType() - amountDiscount() - percentageDiscount() - usageDiscount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Discount]. */ - class Builder internal constructor() { - - private var discountType: JsonField? = null - private var amountDiscount: JsonField = JsonMissing.of() - private var percentageDiscount: JsonField = JsonMissing.of() - private var usageDiscount: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(discount: Discount) = apply { - discountType = discount.discountType - amountDiscount = discount.amountDiscount - percentageDiscount = discount.percentageDiscount - usageDiscount = discount.usageDiscount - additionalProperties = discount.additionalProperties.toMutableMap() - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(amountDiscount: String?) = - amountDiscount(JsonField.ofNullable(amountDiscount)) - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(amountDiscount: Optional) = - amountDiscount(amountDiscount.orElse(null)) - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(amountDiscount: JsonField) = apply { - this.amountDiscount = amountDiscount - } - - /** - * Only available if discount_type is `percentage`. This is a number between 0 - * and 1. - */ - fun percentageDiscount(percentageDiscount: Double?) = - percentageDiscount(JsonField.ofNullable(percentageDiscount)) - - /** - * Only available if discount_type is `percentage`. This is a number between 0 - * and 1. - */ - fun percentageDiscount(percentageDiscount: Double) = - percentageDiscount(percentageDiscount as Double?) - - /** - * Only available if discount_type is `percentage`. This is a number between 0 - * and 1. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun percentageDiscount(percentageDiscount: Optional) = - percentageDiscount(percentageDiscount.orElse(null) as Double?) - - /** - * Only available if discount_type is `percentage`. This is a number between 0 - * and 1. - */ - fun percentageDiscount(percentageDiscount: JsonField) = apply { - this.percentageDiscount = percentageDiscount - } - - /** - * Only available if discount_type is `usage`. Number of usage units that this - * discount is for - */ - fun usageDiscount(usageDiscount: Double?) = - usageDiscount(JsonField.ofNullable(usageDiscount)) - - /** - * Only available if discount_type is `usage`. Number of usage units that this - * discount is for - */ - fun usageDiscount(usageDiscount: Double) = usageDiscount(usageDiscount as Double?) - - /** - * Only available if discount_type is `usage`. Number of usage units that this - * discount is for - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun usageDiscount(usageDiscount: Optional) = - usageDiscount(usageDiscount.orElse(null) as Double?) - - /** - * Only available if discount_type is `usage`. Number of usage units that this - * discount is for - */ - fun usageDiscount(usageDiscount: JsonField) = apply { - this.usageDiscount = usageDiscount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Discount = - Discount( - checkRequired("discountType", discountType), - amountDiscount, - percentageDiscount, - usageDiscount, - additionalProperties.toImmutable(), - ) - } - - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val PERCENTAGE = of("percentage") - - @JvmField val USAGE = of("usage") - - @JvmField val AMOUNT = of("amount") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - PERCENTAGE, - USAGE, - AMOUNT, - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE, - USAGE, - AMOUNT, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE -> Value.PERCENTAGE - USAGE -> Value.USAGE - AMOUNT -> Value.AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PERCENTAGE -> Known.PERCENTAGE - USAGE -> Known.USAGE - AMOUNT -> Known.AMOUNT - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Discount && discountType == other.discountType && amountDiscount == other.amountDiscount && percentageDiscount == other.percentageDiscount && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(discountType, amountDiscount, percentageDiscount, usageDiscount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Discount{discountType=$discountType, amountDiscount=$amountDiscount, percentageDiscount=$percentageDiscount, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" - } - - /** The definition of a new price to create and add to the subscription. */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price - private constructor( - private val newSubscriptionUnit: NewSubscriptionUnitPrice? = null, - private val newSubscriptionPackage: NewSubscriptionPackagePrice? = null, - private val newSubscriptionMatrix: NewSubscriptionMatrixPrice? = null, - private val newSubscriptionTiered: NewSubscriptionTieredPrice? = null, - private val newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice? = null, - private val newSubscriptionBps: NewSubscriptionBpsPrice? = null, - private val newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice? = null, - private val newSubscriptionBulk: NewSubscriptionBulkPrice? = null, - private val newSubscriptionThresholdTotalAmount: - NewSubscriptionThresholdTotalAmountPrice? = - null, - private val newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice? = null, - private val newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = - null, - private val newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, - private val newSubscriptionPackageWithAllocation: - NewSubscriptionPackageWithAllocationPrice? = - null, - private val newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice? = - null, - private val newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice? = - null, - private val newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice? = - null, - private val newSubscriptionGroupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice? = - null, - private val newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice? = - null, - private val _json: JsonValue? = null, - ) { - - fun newSubscriptionUnit(): Optional = - Optional.ofNullable(newSubscriptionUnit) - - fun newSubscriptionPackage(): Optional = - Optional.ofNullable(newSubscriptionPackage) - - fun newSubscriptionMatrix(): Optional = - Optional.ofNullable(newSubscriptionMatrix) - - fun newSubscriptionTiered(): Optional = - Optional.ofNullable(newSubscriptionTiered) - - fun newSubscriptionTieredBps(): Optional = - Optional.ofNullable(newSubscriptionTieredBps) - - fun newSubscriptionBps(): Optional = - Optional.ofNullable(newSubscriptionBps) - - fun newSubscriptionBulkBps(): Optional = - Optional.ofNullable(newSubscriptionBulkBps) - - fun newSubscriptionBulk(): Optional = - Optional.ofNullable(newSubscriptionBulk) - - fun newSubscriptionThresholdTotalAmount(): - Optional = - Optional.ofNullable(newSubscriptionThresholdTotalAmount) - - fun newSubscriptionTieredPackage(): Optional = - Optional.ofNullable(newSubscriptionTieredPackage) - - fun newSubscriptionTieredWithMinimum(): - Optional = - Optional.ofNullable(newSubscriptionTieredWithMinimum) - - fun newSubscriptionUnitWithPercent(): Optional = - Optional.ofNullable(newSubscriptionUnitWithPercent) - - fun newSubscriptionPackageWithAllocation(): - Optional = - Optional.ofNullable(newSubscriptionPackageWithAllocation) - - fun newSubscriptionTierWithProration(): - Optional = - Optional.ofNullable(newSubscriptionTierWithProration) - - fun newSubscriptionUnitWithProration(): - Optional = - Optional.ofNullable(newSubscriptionUnitWithProration) - - fun newSubscriptionGroupedAllocation(): - Optional = - Optional.ofNullable(newSubscriptionGroupedAllocation) - - fun newSubscriptionGroupedWithProratedMinimum(): - Optional = - Optional.ofNullable(newSubscriptionGroupedWithProratedMinimum) - - fun newSubscriptionBulkWithProration(): - Optional = - Optional.ofNullable(newSubscriptionBulkWithProration) - - fun isNewSubscriptionUnit(): Boolean = newSubscriptionUnit != null - - fun isNewSubscriptionPackage(): Boolean = newSubscriptionPackage != null - - fun isNewSubscriptionMatrix(): Boolean = newSubscriptionMatrix != null - - fun isNewSubscriptionTiered(): Boolean = newSubscriptionTiered != null - - fun isNewSubscriptionTieredBps(): Boolean = newSubscriptionTieredBps != null - - fun isNewSubscriptionBps(): Boolean = newSubscriptionBps != null - - fun isNewSubscriptionBulkBps(): Boolean = newSubscriptionBulkBps != null - - fun isNewSubscriptionBulk(): Boolean = newSubscriptionBulk != null - - fun isNewSubscriptionThresholdTotalAmount(): Boolean = - newSubscriptionThresholdTotalAmount != null - - fun isNewSubscriptionTieredPackage(): Boolean = newSubscriptionTieredPackage != null - - fun isNewSubscriptionTieredWithMinimum(): Boolean = - newSubscriptionTieredWithMinimum != null - - fun isNewSubscriptionUnitWithPercent(): Boolean = newSubscriptionUnitWithPercent != null - - fun isNewSubscriptionPackageWithAllocation(): Boolean = - newSubscriptionPackageWithAllocation != null - - fun isNewSubscriptionTierWithProration(): Boolean = - newSubscriptionTierWithProration != null - - fun isNewSubscriptionUnitWithProration(): Boolean = - newSubscriptionUnitWithProration != null - - fun isNewSubscriptionGroupedAllocation(): Boolean = - newSubscriptionGroupedAllocation != null - - fun isNewSubscriptionGroupedWithProratedMinimum(): Boolean = - newSubscriptionGroupedWithProratedMinimum != null - - fun isNewSubscriptionBulkWithProration(): Boolean = - newSubscriptionBulkWithProration != null - - fun asNewSubscriptionUnit(): NewSubscriptionUnitPrice = - newSubscriptionUnit.getOrThrow("newSubscriptionUnit") - - fun asNewSubscriptionPackage(): NewSubscriptionPackagePrice = - newSubscriptionPackage.getOrThrow("newSubscriptionPackage") - - fun asNewSubscriptionMatrix(): NewSubscriptionMatrixPrice = - newSubscriptionMatrix.getOrThrow("newSubscriptionMatrix") - - fun asNewSubscriptionTiered(): NewSubscriptionTieredPrice = - newSubscriptionTiered.getOrThrow("newSubscriptionTiered") - - fun asNewSubscriptionTieredBps(): NewSubscriptionTieredBpsPrice = - newSubscriptionTieredBps.getOrThrow("newSubscriptionTieredBps") - - fun asNewSubscriptionBps(): NewSubscriptionBpsPrice = - newSubscriptionBps.getOrThrow("newSubscriptionBps") - - fun asNewSubscriptionBulkBps(): NewSubscriptionBulkBpsPrice = - newSubscriptionBulkBps.getOrThrow("newSubscriptionBulkBps") - - fun asNewSubscriptionBulk(): NewSubscriptionBulkPrice = - newSubscriptionBulk.getOrThrow("newSubscriptionBulk") - - fun asNewSubscriptionThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = - newSubscriptionThresholdTotalAmount.getOrThrow( - "newSubscriptionThresholdTotalAmount" - ) - - fun asNewSubscriptionTieredPackage(): NewSubscriptionTieredPackagePrice = - newSubscriptionTieredPackage.getOrThrow("newSubscriptionTieredPackage") - - fun asNewSubscriptionTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = - newSubscriptionTieredWithMinimum.getOrThrow("newSubscriptionTieredWithMinimum") - - fun asNewSubscriptionUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = - newSubscriptionUnitWithPercent.getOrThrow("newSubscriptionUnitWithPercent") - - fun asNewSubscriptionPackageWithAllocation(): - NewSubscriptionPackageWithAllocationPrice = - newSubscriptionPackageWithAllocation.getOrThrow( - "newSubscriptionPackageWithAllocation" - ) - - fun asNewSubscriptionTierWithProration(): NewSubscriptionTierWithProrationPrice = - newSubscriptionTierWithProration.getOrThrow("newSubscriptionTierWithProration") - - fun asNewSubscriptionUnitWithProration(): NewSubscriptionUnitWithProrationPrice = - newSubscriptionUnitWithProration.getOrThrow("newSubscriptionUnitWithProration") - - fun asNewSubscriptionGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = - newSubscriptionGroupedAllocation.getOrThrow("newSubscriptionGroupedAllocation") - - fun asNewSubscriptionGroupedWithProratedMinimum(): - NewSubscriptionGroupedWithProratedMinimumPrice = - newSubscriptionGroupedWithProratedMinimum.getOrThrow( - "newSubscriptionGroupedWithProratedMinimum" - ) - - fun asNewSubscriptionBulkWithProration(): NewSubscriptionBulkWithProrationPrice = - newSubscriptionBulkWithProration.getOrThrow("newSubscriptionBulkWithProration") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - newSubscriptionUnit != null -> - visitor.visitNewSubscriptionUnit(newSubscriptionUnit) - newSubscriptionPackage != null -> - visitor.visitNewSubscriptionPackage(newSubscriptionPackage) - newSubscriptionMatrix != null -> - visitor.visitNewSubscriptionMatrix(newSubscriptionMatrix) - newSubscriptionTiered != null -> - visitor.visitNewSubscriptionTiered(newSubscriptionTiered) - newSubscriptionTieredBps != null -> - visitor.visitNewSubscriptionTieredBps(newSubscriptionTieredBps) - newSubscriptionBps != null -> - visitor.visitNewSubscriptionBps(newSubscriptionBps) - newSubscriptionBulkBps != null -> - visitor.visitNewSubscriptionBulkBps(newSubscriptionBulkBps) - newSubscriptionBulk != null -> - visitor.visitNewSubscriptionBulk(newSubscriptionBulk) - newSubscriptionThresholdTotalAmount != null -> - visitor.visitNewSubscriptionThresholdTotalAmount( - newSubscriptionThresholdTotalAmount - ) - newSubscriptionTieredPackage != null -> - visitor.visitNewSubscriptionTieredPackage(newSubscriptionTieredPackage) - newSubscriptionTieredWithMinimum != null -> - visitor.visitNewSubscriptionTieredWithMinimum( - newSubscriptionTieredWithMinimum - ) - newSubscriptionUnitWithPercent != null -> - visitor.visitNewSubscriptionUnitWithPercent(newSubscriptionUnitWithPercent) - newSubscriptionPackageWithAllocation != null -> - visitor.visitNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation - ) - newSubscriptionTierWithProration != null -> - visitor.visitNewSubscriptionTierWithProration( - newSubscriptionTierWithProration - ) - newSubscriptionUnitWithProration != null -> - visitor.visitNewSubscriptionUnitWithProration( - newSubscriptionUnitWithProration - ) - newSubscriptionGroupedAllocation != null -> - visitor.visitNewSubscriptionGroupedAllocation( - newSubscriptionGroupedAllocation - ) - newSubscriptionGroupedWithProratedMinimum != null -> - visitor.visitNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum - ) - newSubscriptionBulkWithProration != null -> - visitor.visitNewSubscriptionBulkWithProration( - newSubscriptionBulkWithProration - ) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): Price = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitNewSubscriptionUnit( - newSubscriptionUnit: NewSubscriptionUnitPrice - ) { - newSubscriptionUnit.validate() - } - - override fun visitNewSubscriptionPackage( - newSubscriptionPackage: NewSubscriptionPackagePrice - ) { - newSubscriptionPackage.validate() - } - - override fun visitNewSubscriptionMatrix( - newSubscriptionMatrix: NewSubscriptionMatrixPrice - ) { - newSubscriptionMatrix.validate() - } - - override fun visitNewSubscriptionTiered( - newSubscriptionTiered: NewSubscriptionTieredPrice - ) { - newSubscriptionTiered.validate() - } - - override fun visitNewSubscriptionTieredBps( - newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice - ) { - newSubscriptionTieredBps.validate() - } - - override fun visitNewSubscriptionBps( - newSubscriptionBps: NewSubscriptionBpsPrice - ) { - newSubscriptionBps.validate() - } - - override fun visitNewSubscriptionBulkBps( - newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice - ) { - newSubscriptionBulkBps.validate() - } - - override fun visitNewSubscriptionBulk( - newSubscriptionBulk: NewSubscriptionBulkPrice - ) { - newSubscriptionBulk.validate() - } - - override fun visitNewSubscriptionThresholdTotalAmount( - newSubscriptionThresholdTotalAmount: - NewSubscriptionThresholdTotalAmountPrice - ) { - newSubscriptionThresholdTotalAmount.validate() - } - - override fun visitNewSubscriptionTieredPackage( - newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice - ) { - newSubscriptionTieredPackage.validate() - } - - override fun visitNewSubscriptionTieredWithMinimum( - newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) { - newSubscriptionTieredWithMinimum.validate() - } - - override fun visitNewSubscriptionUnitWithPercent( - newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice - ) { - newSubscriptionUnitWithPercent.validate() - } - - override fun visitNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation: - NewSubscriptionPackageWithAllocationPrice - ) { - newSubscriptionPackageWithAllocation.validate() - } - - override fun visitNewSubscriptionTierWithProration( - newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice - ) { - newSubscriptionTierWithProration.validate() - } - - override fun visitNewSubscriptionUnitWithProration( - newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice - ) { - newSubscriptionUnitWithProration.validate() - } - - override fun visitNewSubscriptionGroupedAllocation( - newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice - ) { - newSubscriptionGroupedAllocation.validate() - } - - override fun visitNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) { - newSubscriptionGroupedWithProratedMinimum.validate() - } - - override fun visitNewSubscriptionBulkWithProration( - newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice - ) { - newSubscriptionBulkWithProration.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Price && newSubscriptionUnit == other.newSubscriptionUnit && newSubscriptionPackage == other.newSubscriptionPackage && newSubscriptionMatrix == other.newSubscriptionMatrix && newSubscriptionTiered == other.newSubscriptionTiered && newSubscriptionTieredBps == other.newSubscriptionTieredBps && newSubscriptionBps == other.newSubscriptionBps && newSubscriptionBulkBps == other.newSubscriptionBulkBps && newSubscriptionBulk == other.newSubscriptionBulk && newSubscriptionThresholdTotalAmount == other.newSubscriptionThresholdTotalAmount && newSubscriptionTieredPackage == other.newSubscriptionTieredPackage && newSubscriptionTieredWithMinimum == other.newSubscriptionTieredWithMinimum && newSubscriptionUnitWithPercent == other.newSubscriptionUnitWithPercent && newSubscriptionPackageWithAllocation == other.newSubscriptionPackageWithAllocation && newSubscriptionTierWithProration == other.newSubscriptionTierWithProration && newSubscriptionUnitWithProration == other.newSubscriptionUnitWithProration && newSubscriptionGroupedAllocation == other.newSubscriptionGroupedAllocation && newSubscriptionGroupedWithProratedMinimum == other.newSubscriptionGroupedWithProratedMinimum && newSubscriptionBulkWithProration == other.newSubscriptionBulkWithProration /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(newSubscriptionUnit, newSubscriptionPackage, newSubscriptionMatrix, newSubscriptionTiered, newSubscriptionTieredBps, newSubscriptionBps, newSubscriptionBulkBps, newSubscriptionBulk, newSubscriptionThresholdTotalAmount, newSubscriptionTieredPackage, newSubscriptionTieredWithMinimum, newSubscriptionUnitWithPercent, newSubscriptionPackageWithAllocation, newSubscriptionTierWithProration, newSubscriptionUnitWithProration, newSubscriptionGroupedAllocation, newSubscriptionGroupedWithProratedMinimum, newSubscriptionBulkWithProration) /* spotless:on */ - - override fun toString(): String = - when { - newSubscriptionUnit != null -> "Price{newSubscriptionUnit=$newSubscriptionUnit}" - newSubscriptionPackage != null -> - "Price{newSubscriptionPackage=$newSubscriptionPackage}" - newSubscriptionMatrix != null -> - "Price{newSubscriptionMatrix=$newSubscriptionMatrix}" - newSubscriptionTiered != null -> - "Price{newSubscriptionTiered=$newSubscriptionTiered}" - newSubscriptionTieredBps != null -> - "Price{newSubscriptionTieredBps=$newSubscriptionTieredBps}" - newSubscriptionBps != null -> "Price{newSubscriptionBps=$newSubscriptionBps}" - newSubscriptionBulkBps != null -> - "Price{newSubscriptionBulkBps=$newSubscriptionBulkBps}" - newSubscriptionBulk != null -> "Price{newSubscriptionBulk=$newSubscriptionBulk}" - newSubscriptionThresholdTotalAmount != null -> - "Price{newSubscriptionThresholdTotalAmount=$newSubscriptionThresholdTotalAmount}" - newSubscriptionTieredPackage != null -> - "Price{newSubscriptionTieredPackage=$newSubscriptionTieredPackage}" - newSubscriptionTieredWithMinimum != null -> - "Price{newSubscriptionTieredWithMinimum=$newSubscriptionTieredWithMinimum}" - newSubscriptionUnitWithPercent != null -> - "Price{newSubscriptionUnitWithPercent=$newSubscriptionUnitWithPercent}" - newSubscriptionPackageWithAllocation != null -> - "Price{newSubscriptionPackageWithAllocation=$newSubscriptionPackageWithAllocation}" - newSubscriptionTierWithProration != null -> - "Price{newSubscriptionTierWithProration=$newSubscriptionTierWithProration}" - newSubscriptionUnitWithProration != null -> - "Price{newSubscriptionUnitWithProration=$newSubscriptionUnitWithProration}" - newSubscriptionGroupedAllocation != null -> - "Price{newSubscriptionGroupedAllocation=$newSubscriptionGroupedAllocation}" - newSubscriptionGroupedWithProratedMinimum != null -> - "Price{newSubscriptionGroupedWithProratedMinimum=$newSubscriptionGroupedWithProratedMinimum}" - newSubscriptionBulkWithProration != null -> - "Price{newSubscriptionBulkWithProration=$newSubscriptionBulkWithProration}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") - } - - companion object { - - @JvmStatic - fun ofNewSubscriptionUnit(newSubscriptionUnit: NewSubscriptionUnitPrice) = - Price(newSubscriptionUnit = newSubscriptionUnit) - - @JvmStatic - fun ofNewSubscriptionPackage(newSubscriptionPackage: NewSubscriptionPackagePrice) = - Price(newSubscriptionPackage = newSubscriptionPackage) - - @JvmStatic - fun ofNewSubscriptionMatrix(newSubscriptionMatrix: NewSubscriptionMatrixPrice) = - Price(newSubscriptionMatrix = newSubscriptionMatrix) - - @JvmStatic - fun ofNewSubscriptionTiered(newSubscriptionTiered: NewSubscriptionTieredPrice) = - Price(newSubscriptionTiered = newSubscriptionTiered) - - @JvmStatic - fun ofNewSubscriptionTieredBps( - newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice - ) = Price(newSubscriptionTieredBps = newSubscriptionTieredBps) - - @JvmStatic - fun ofNewSubscriptionBps(newSubscriptionBps: NewSubscriptionBpsPrice) = - Price(newSubscriptionBps = newSubscriptionBps) - - @JvmStatic - fun ofNewSubscriptionBulkBps(newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice) = - Price(newSubscriptionBulkBps = newSubscriptionBulkBps) - - @JvmStatic - fun ofNewSubscriptionBulk(newSubscriptionBulk: NewSubscriptionBulkPrice) = - Price(newSubscriptionBulk = newSubscriptionBulk) - - @JvmStatic - fun ofNewSubscriptionThresholdTotalAmount( - newSubscriptionThresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = Price(newSubscriptionThresholdTotalAmount = newSubscriptionThresholdTotalAmount) - - @JvmStatic - fun ofNewSubscriptionTieredPackage( - newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice - ) = Price(newSubscriptionTieredPackage = newSubscriptionTieredPackage) - - @JvmStatic - fun ofNewSubscriptionTieredWithMinimum( - newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) = Price(newSubscriptionTieredWithMinimum = newSubscriptionTieredWithMinimum) - - @JvmStatic - fun ofNewSubscriptionUnitWithPercent( - newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice - ) = Price(newSubscriptionUnitWithPercent = newSubscriptionUnitWithPercent) - - @JvmStatic - fun ofNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = - Price( - newSubscriptionPackageWithAllocation = newSubscriptionPackageWithAllocation - ) - - @JvmStatic - fun ofNewSubscriptionTierWithProration( - newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice - ) = Price(newSubscriptionTierWithProration = newSubscriptionTierWithProration) - - @JvmStatic - fun ofNewSubscriptionUnitWithProration( - newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice - ) = Price(newSubscriptionUnitWithProration = newSubscriptionUnitWithProration) - - @JvmStatic - fun ofNewSubscriptionGroupedAllocation( - newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice - ) = Price(newSubscriptionGroupedAllocation = newSubscriptionGroupedAllocation) - - @JvmStatic - fun ofNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) = - Price( - newSubscriptionGroupedWithProratedMinimum = - newSubscriptionGroupedWithProratedMinimum - ) - - @JvmStatic - fun ofNewSubscriptionBulkWithProration( - newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice - ) = Price(newSubscriptionBulkWithProration = newSubscriptionBulkWithProration) - } - - /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. - */ - interface Visitor { - - fun visitNewSubscriptionUnit(newSubscriptionUnit: NewSubscriptionUnitPrice): T - - fun visitNewSubscriptionPackage( - newSubscriptionPackage: NewSubscriptionPackagePrice - ): T - - fun visitNewSubscriptionMatrix(newSubscriptionMatrix: NewSubscriptionMatrixPrice): T - - fun visitNewSubscriptionTiered(newSubscriptionTiered: NewSubscriptionTieredPrice): T - - fun visitNewSubscriptionTieredBps( - newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice - ): T - - fun visitNewSubscriptionBps(newSubscriptionBps: NewSubscriptionBpsPrice): T - - fun visitNewSubscriptionBulkBps( - newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice - ): T - - fun visitNewSubscriptionBulk(newSubscriptionBulk: NewSubscriptionBulkPrice): T - - fun visitNewSubscriptionThresholdTotalAmount( - newSubscriptionThresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ): T - - fun visitNewSubscriptionTieredPackage( - newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice - ): T - - fun visitNewSubscriptionTieredWithMinimum( - newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ): T - - fun visitNewSubscriptionUnitWithPercent( - newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice - ): T - - fun visitNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ): T - - fun visitNewSubscriptionTierWithProration( - newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice - ): T - - fun visitNewSubscriptionUnitWithProration( - newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice - ): T - - fun visitNewSubscriptionGroupedAllocation( - newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice - ): T - - fun visitNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ): T - - fun visitNewSubscriptionBulkWithProration( - newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice - ): 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" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionUnit = it, _json = json) - } - } - "package" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionPackage = it, _json = json) - } - } - "matrix" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionMatrix = it, _json = json) - } - } - "tiered" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionTiered = it, _json = json) - } - } - "tiered_bps" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionTieredBps = it, _json = json) - } - } - "bps" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionBps = it, _json = json) - } - } - "bulk_bps" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionBulkBps = it, _json = json) - } - } - "bulk" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionBulk = it, _json = json) - } - } - "threshold_total_amount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionThresholdTotalAmount = it, - _json = json, - ) - } - } - "tiered_package" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price(newSubscriptionTieredPackage = it, _json = json) - } - } - "tiered_with_minimum" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionTieredWithMinimum = it, - _json = json, - ) - } - } - "unit_with_percent" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price(newSubscriptionUnitWithPercent = it, _json = json) - } - } - "package_with_allocation" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionPackageWithAllocation = it, - _json = json, - ) - } - } - "tiered_with_proration" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionTierWithProration = it, - _json = json, - ) - } - } - "unit_with_proration" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionUnitWithProration = it, - _json = json, - ) - } - } - "grouped_allocation" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionGroupedAllocation = it, - _json = json, - ) - } - } - "grouped_with_prorated_minimum" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionGroupedWithProratedMinimum = it, - _json = json, - ) - } - } - "bulk_with_proration" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionBulkWithProration = it, - _json = json, - ) - } - } - } - - return Price(_json = json) - } - } - - internal class Serializer : BaseSerializer(Price::class) { - - override fun serialize( - value: Price, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.newSubscriptionUnit != null -> - generator.writeObject(value.newSubscriptionUnit) - value.newSubscriptionPackage != null -> - generator.writeObject(value.newSubscriptionPackage) - value.newSubscriptionMatrix != null -> - generator.writeObject(value.newSubscriptionMatrix) - value.newSubscriptionTiered != null -> - generator.writeObject(value.newSubscriptionTiered) - value.newSubscriptionTieredBps != null -> - generator.writeObject(value.newSubscriptionTieredBps) - value.newSubscriptionBps != null -> - generator.writeObject(value.newSubscriptionBps) - value.newSubscriptionBulkBps != null -> - generator.writeObject(value.newSubscriptionBulkBps) - value.newSubscriptionBulk != null -> - generator.writeObject(value.newSubscriptionBulk) - value.newSubscriptionThresholdTotalAmount != null -> - generator.writeObject(value.newSubscriptionThresholdTotalAmount) - value.newSubscriptionTieredPackage != null -> - generator.writeObject(value.newSubscriptionTieredPackage) - value.newSubscriptionTieredWithMinimum != null -> - generator.writeObject(value.newSubscriptionTieredWithMinimum) - value.newSubscriptionUnitWithPercent != null -> - generator.writeObject(value.newSubscriptionUnitWithPercent) - value.newSubscriptionPackageWithAllocation != null -> - generator.writeObject(value.newSubscriptionPackageWithAllocation) - value.newSubscriptionTierWithProration != null -> - generator.writeObject(value.newSubscriptionTierWithProration) - value.newSubscriptionUnitWithProration != null -> - generator.writeObject(value.newSubscriptionUnitWithProration) - value.newSubscriptionGroupedAllocation != null -> - generator.writeObject(value.newSubscriptionGroupedAllocation) - value.newSubscriptionGroupedWithProratedMinimum != null -> - generator.writeObject(value.newSubscriptionGroupedWithProratedMinimum) - value.newSubscriptionBulkWithProration != null -> - generator.writeObject(value.newSubscriptionBulkWithProration) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") - } - } - } - - @NoAutoDetect - class NewSubscriptionUnitPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("unit_config") - @ExcludeMissing - private val unitConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun unitConfig(): UnitConfig = unitConfig.getRequired("unit_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("unit_config") - @ExcludeMissing - fun _unitConfig(): JsonField = unitConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionUnitPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - unitConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionUnitPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var 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 currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newSubscriptionUnitPrice: NewSubscriptionUnitPrice) = apply { - cadence = newSubscriptionUnitPrice.cadence - itemId = newSubscriptionUnitPrice.itemId - modelType = newSubscriptionUnitPrice.modelType - name = newSubscriptionUnitPrice.name - unitConfig = newSubscriptionUnitPrice.unitConfig - billableMetricId = newSubscriptionUnitPrice.billableMetricId - billedInAdvance = newSubscriptionUnitPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionUnitPrice.billingCycleConfiguration - conversionRate = newSubscriptionUnitPrice.conversionRate - currency = newSubscriptionUnitPrice.currency - externalPriceId = newSubscriptionUnitPrice.externalPriceId - fixedPriceQuantity = newSubscriptionUnitPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionUnitPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionUnitPrice.invoicingCycleConfiguration - metadata = newSubscriptionUnitPrice.metadata - referenceId = newSubscriptionUnitPrice.referenceId - additionalProperties = - newSubscriptionUnitPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) - - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionUnitPrice = - NewSubscriptionUnitPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("unitConfig", unitConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class UnitConfig - @JsonCreator - private constructor( - @JsonProperty("unit_amount") - @ExcludeMissing - private val unitAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Rate per unit of usage */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** Rate per unit of usage */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): UnitConfig = apply { - if (validated) { - return@apply - } - - unitAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnitConfig]. */ - class Builder internal constructor() { - - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unitConfig: UnitConfig) = apply { - unitAmount = unitConfig.unitAmount - additionalProperties = unitConfig.additionalProperties.toMutableMap() - } - - /** Rate per unit of usage */ - fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - - /** Rate per unit of usage */ - 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 build(): UnitConfig = - UnitConfig( - checkRequired("unitAmount", unitAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UnitConfig && unitAmount == other.unitAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(unitAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnitConfig{unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionUnitPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && unitConfig == other.unitConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, unitConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionUnitPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionPackagePrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("package_config") - @ExcludeMissing - private val packageConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun packageConfig(): PackageConfig = packageConfig.getRequired("package_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("package_config") - @ExcludeMissing - fun _packageConfig(): JsonField = packageConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionPackagePrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - packageConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionPackagePrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var packageConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newSubscriptionPackagePrice: NewSubscriptionPackagePrice) = - apply { - cadence = newSubscriptionPackagePrice.cadence - itemId = newSubscriptionPackagePrice.itemId - modelType = newSubscriptionPackagePrice.modelType - name = newSubscriptionPackagePrice.name - packageConfig = newSubscriptionPackagePrice.packageConfig - billableMetricId = newSubscriptionPackagePrice.billableMetricId - billedInAdvance = newSubscriptionPackagePrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionPackagePrice.billingCycleConfiguration - conversionRate = newSubscriptionPackagePrice.conversionRate - currency = newSubscriptionPackagePrice.currency - externalPriceId = newSubscriptionPackagePrice.externalPriceId - fixedPriceQuantity = newSubscriptionPackagePrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionPackagePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionPackagePrice.invoicingCycleConfiguration - metadata = newSubscriptionPackagePrice.metadata - referenceId = newSubscriptionPackagePrice.referenceId - additionalProperties = - newSubscriptionPackagePrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun packageConfig(packageConfig: PackageConfig) = - packageConfig(JsonField.of(packageConfig)) - - fun packageConfig(packageConfig: JsonField) = apply { - this.packageConfig = packageConfig - } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionPackagePrice = - NewSubscriptionPackagePrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("packageConfig", packageConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val PACKAGE = of("package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - PACKAGE - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PACKAGE, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PACKAGE -> Value.PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PACKAGE -> Known.PACKAGE - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class PackageConfig - @JsonCreator - private constructor( - @JsonProperty("package_amount") - @ExcludeMissing - private val packageAmount: JsonField = JsonMissing.of(), - @JsonProperty("package_size") - @ExcludeMissing - private val packageSize: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** A currency amount to rate usage by */ - fun packageAmount(): String = packageAmount.getRequired("package_amount") - - /** - * An integer amount to represent package size. For example, 1000 here would - * divide usage by 1000 before multiplying by package_amount in rating - */ - fun packageSize(): Long = packageSize.getRequired("package_size") - - /** A currency amount to rate usage by */ - @JsonProperty("package_amount") - @ExcludeMissing - fun _packageAmount(): JsonField = packageAmount - - /** - * An integer amount to represent package size. For example, 1000 here would - * divide usage by 1000 before multiplying by package_amount in rating - */ - @JsonProperty("package_size") - @ExcludeMissing - fun _packageSize(): JsonField = packageSize - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PackageConfig = apply { - if (validated) { - return@apply - } - - packageAmount() - packageSize() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PackageConfig]. */ - class Builder internal constructor() { - - private var packageAmount: JsonField? = null - private var packageSize: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(packageConfig: PackageConfig) = apply { - packageAmount = packageConfig.packageAmount - packageSize = packageConfig.packageSize - additionalProperties = packageConfig.additionalProperties.toMutableMap() - } - - /** A currency amount to rate usage by */ - fun packageAmount(packageAmount: String) = - packageAmount(JsonField.of(packageAmount)) - - /** A currency amount to rate usage by */ - fun packageAmount(packageAmount: JsonField) = apply { - this.packageAmount = packageAmount - } - - /** - * An integer amount to represent package size. For example, 1000 here would - * divide usage by 1000 before multiplying by package_amount in rating - */ - fun packageSize(packageSize: Long) = packageSize(JsonField.of(packageSize)) - - /** - * An integer amount to represent package size. For example, 1000 here would - * divide usage by 1000 before multiplying by package_amount in rating - */ - fun packageSize(packageSize: JsonField) = apply { - this.packageSize = packageSize - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PackageConfig = - PackageConfig( - checkRequired("packageAmount", packageAmount), - checkRequired("packageSize", packageSize), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PackageConfig && packageAmount == other.packageAmount && packageSize == other.packageSize && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(packageAmount, packageSize, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PackageConfig{packageAmount=$packageAmount, packageSize=$packageSize, additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionPackagePrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && packageConfig == other.packageConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, packageConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionMatrixPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("matrix_config") - @ExcludeMissing - private val matrixConfig: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_config") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("matrix_config") - @ExcludeMissing - fun _matrixConfig(): JsonField = matrixConfig - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionMatrixPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - matrixConfig().validate() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionMatrixPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var matrixConfig: JsonField? = null - private var modelType: JsonField? = null - private var 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 currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newSubscriptionMatrixPrice: NewSubscriptionMatrixPrice) = - apply { - cadence = newSubscriptionMatrixPrice.cadence - itemId = newSubscriptionMatrixPrice.itemId - matrixConfig = newSubscriptionMatrixPrice.matrixConfig - modelType = newSubscriptionMatrixPrice.modelType - name = newSubscriptionMatrixPrice.name - billableMetricId = newSubscriptionMatrixPrice.billableMetricId - billedInAdvance = newSubscriptionMatrixPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionMatrixPrice.billingCycleConfiguration - conversionRate = newSubscriptionMatrixPrice.conversionRate - currency = newSubscriptionMatrixPrice.currency - externalPriceId = newSubscriptionMatrixPrice.externalPriceId - fixedPriceQuantity = newSubscriptionMatrixPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionMatrixPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionMatrixPrice.invoicingCycleConfiguration - metadata = newSubscriptionMatrixPrice.metadata - referenceId = newSubscriptionMatrixPrice.referenceId - additionalProperties = - newSubscriptionMatrixPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun matrixConfig(matrixConfig: MatrixConfig) = - matrixConfig(JsonField.of(matrixConfig)) - - fun matrixConfig(matrixConfig: JsonField) = apply { - this.matrixConfig = matrixConfig - } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionMatrixPrice = - NewSubscriptionMatrixPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("matrixConfig", matrixConfig), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class MatrixConfig - @JsonCreator - private constructor( - @JsonProperty("default_unit_amount") - @ExcludeMissing - private val defaultUnitAmount: JsonField = JsonMissing.of(), - @JsonProperty("dimensions") - @ExcludeMissing - private val dimensions: JsonField> = JsonMissing.of(), - @JsonProperty("matrix_values") - @ExcludeMissing - private val matrixValues: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * Default per unit rate for any usage not bucketed into a specified - * matrix_value - */ - fun defaultUnitAmount(): String = - defaultUnitAmount.getRequired("default_unit_amount") - - /** One or two event property values to evaluate matrix groups by */ - fun dimensions(): List = dimensions.getRequired("dimensions") - - /** Matrix values for specified matrix grouping keys */ - fun matrixValues(): List = - matrixValues.getRequired("matrix_values") - - /** - * Default per unit rate for any usage not bucketed into a specified - * matrix_value - */ - @JsonProperty("default_unit_amount") - @ExcludeMissing - fun _defaultUnitAmount(): JsonField = defaultUnitAmount - - /** One or two event property values to evaluate matrix groups by */ - @JsonProperty("dimensions") - @ExcludeMissing - fun _dimensions(): JsonField> = dimensions - - /** Matrix values for specified matrix grouping keys */ - @JsonProperty("matrix_values") - @ExcludeMissing - fun _matrixValues(): JsonField> = matrixValues - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MatrixConfig = apply { - if (validated) { - return@apply - } - - defaultUnitAmount() - dimensions() - matrixValues().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MatrixConfig]. */ - class Builder internal constructor() { - - private var defaultUnitAmount: JsonField? = null - private var dimensions: JsonField>? = null - private var matrixValues: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(matrixConfig: MatrixConfig) = apply { - defaultUnitAmount = matrixConfig.defaultUnitAmount - dimensions = matrixConfig.dimensions.map { it.toMutableList() } - matrixValues = matrixConfig.matrixValues.map { it.toMutableList() } - additionalProperties = matrixConfig.additionalProperties.toMutableMap() - } - - /** - * Default per unit rate for any usage not bucketed into a specified - * matrix_value - */ - fun defaultUnitAmount(defaultUnitAmount: String) = - defaultUnitAmount(JsonField.of(defaultUnitAmount)) - - /** - * Default per unit rate for any usage not bucketed into a specified - * matrix_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)) - - /** One or two event property values to evaluate matrix groups by */ - fun dimensions(dimensions: JsonField>) = apply { - this.dimensions = dimensions.map { it.toMutableList() } - } - - /** One or two event property values to evaluate matrix groups by */ - fun addDimension(dimension: String) = apply { - dimensions = - (dimensions ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimension) - } - } - - /** Matrix values for specified matrix grouping keys */ - fun matrixValues(matrixValues: List) = - matrixValues(JsonField.of(matrixValues)) - - /** Matrix values for specified matrix grouping keys */ - fun matrixValues(matrixValues: JsonField>) = apply { - this.matrixValues = matrixValues.map { it.toMutableList() } - } - - /** Matrix values for specified matrix grouping keys */ - fun addMatrixValue(matrixValue: MatrixValue) = apply { - matrixValues = - (matrixValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): MatrixConfig = - MatrixConfig( - checkRequired("defaultUnitAmount", defaultUnitAmount), - checkRequired("dimensions", dimensions).map { it.toImmutable() }, - checkRequired("matrixValues", matrixValues).map { - it.toImmutable() - }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class MatrixValue - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - private val unitAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), - ) { - - /** - * One or two matrix keys to filter usage to this Matrix value by. For - * example, ["region", "tier"] could be used to filter cloud usage by a - * cloud region and an instance tier. - */ - fun dimensionValues(): List = - dimensionValues.getRequired("dimension_values") - - /** Unit price for the specified dimension_values */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** - * One or two matrix keys to filter usage to this Matrix value by. For - * example, ["region", "tier"] could be used to filter cloud usage by a - * cloud region and an instance tier. - */ - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - /** Unit price for the specified dimension_values */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MatrixValue = apply { - if (validated) { - return@apply - } - - dimensionValues() - unitAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MatrixValue]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(matrixValue: MatrixValue) = apply { - dimensionValues = - matrixValue.dimensionValues.map { it.toMutableList() } - unitAmount = matrixValue.unitAmount - additionalProperties = - matrixValue.additionalProperties.toMutableMap() - } - - /** - * One or two matrix keys to filter usage to this Matrix value by. For - * example, ["region", "tier"] could be used to filter cloud usage by a - * cloud region and an instance tier. - */ - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - /** - * One or two matrix keys to filter usage to this Matrix value by. For - * example, ["region", "tier"] could be used to filter cloud usage by a - * cloud region and an instance tier. - */ - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - /** - * One or two matrix keys to filter usage to this Matrix value by. For - * example, ["region", "tier"] could be used to filter cloud usage by a - * cloud region and an instance tier. - */ - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - /** Unit price for the specified dimension_values */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) - - /** Unit price for the specified dimension_values */ - 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 build(): MatrixValue = - MatrixValue( - checkRequired("dimensionValues", dimensionValues).map { - it.toImmutable() - }, - checkRequired("unitAmount", unitAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MatrixValue && dimensionValues == other.dimensionValues && unitAmount == other.unitAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, unitAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MatrixValue{dimensionValues=$dimensionValues, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MatrixConfig && defaultUnitAmount == other.defaultUnitAmount && dimensions == other.dimensions && matrixValues == other.matrixValues && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(defaultUnitAmount, dimensions, matrixValues, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MatrixConfig{defaultUnitAmount=$defaultUnitAmount, dimensions=$dimensions, matrixValues=$matrixValues, additionalProperties=$additionalProperties}" - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MATRIX = of("matrix") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MATRIX - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MATRIX, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MATRIX -> Value.MATRIX - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MATRIX -> Known.MATRIX - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionMatrixPrice && cadence == other.cadence && itemId == other.itemId && matrixConfig == other.matrixConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, matrixConfig, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionMatrixPrice{cadence=$cadence, itemId=$itemId, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionTieredPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_config") - @ExcludeMissing - private val tieredConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun tieredConfig(): TieredConfig = tieredConfig.getRequired("tiered_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("tiered_config") - @ExcludeMissing - fun _tieredConfig(): JsonField = tieredConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionTieredPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - tieredConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionTieredPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var tieredConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newSubscriptionTieredPrice: NewSubscriptionTieredPrice) = - apply { - cadence = newSubscriptionTieredPrice.cadence - itemId = newSubscriptionTieredPrice.itemId - modelType = newSubscriptionTieredPrice.modelType - name = newSubscriptionTieredPrice.name - tieredConfig = newSubscriptionTieredPrice.tieredConfig - billableMetricId = newSubscriptionTieredPrice.billableMetricId - billedInAdvance = newSubscriptionTieredPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionTieredPrice.billingCycleConfiguration - conversionRate = newSubscriptionTieredPrice.conversionRate - currency = newSubscriptionTieredPrice.currency - externalPriceId = newSubscriptionTieredPrice.externalPriceId - fixedPriceQuantity = newSubscriptionTieredPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionTieredPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionTieredPrice.invoicingCycleConfiguration - metadata = newSubscriptionTieredPrice.metadata - referenceId = newSubscriptionTieredPrice.referenceId - additionalProperties = - newSubscriptionTieredPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredConfig(tieredConfig: TieredConfig) = - tieredConfig(JsonField.of(tieredConfig)) - - fun tieredConfig(tieredConfig: JsonField) = apply { - this.tieredConfig = tieredConfig - } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionTieredPrice = - NewSubscriptionTieredPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("tieredConfig", tieredConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED = of("tiered") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED -> Value.TIERED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TIERED -> Known.TIERED - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TieredConfig - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - private val tiers: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Tiers for rating based on total usage quantities into the specified tier */ - fun tiers(): List = tiers.getRequired("tiers") - - /** Tiers for rating based on total usage quantities into the specified tier */ - @JsonProperty("tiers") - @ExcludeMissing - fun _tiers(): JsonField> = tiers - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredConfig = apply { - if (validated) { - return@apply - } - - tiers().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tieredConfig: TieredConfig) = apply { - tiers = tieredConfig.tiers.map { it.toMutableList() } - additionalProperties = tieredConfig.additionalProperties.toMutableMap() - } - - /** - * Tiers for rating based on total usage quantities into the specified tier - */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - - /** - * Tiers for rating based on total usage quantities into the specified tier - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** - * Tiers for rating based on total usage quantities into the specified tier - */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): TieredConfig = - TieredConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Tier - @JsonCreator - private constructor( - @JsonProperty("first_unit") - @ExcludeMissing - private val firstUnit: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - private val unitAmount: JsonField = JsonMissing.of(), - @JsonProperty("last_unit") - @ExcludeMissing - private val lastUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), - ) { - - /** Inclusive tier starting value */ - fun firstUnit(): Double = firstUnit.getRequired("first_unit") - - /** Amount per unit */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** - * Exclusive tier ending value. If null, this is treated as the last tier - */ - fun lastUnit(): Optional = - Optional.ofNullable(lastUnit.getNullable("last_unit")) - - /** Inclusive tier starting value */ - @JsonProperty("first_unit") - @ExcludeMissing - fun _firstUnit(): JsonField = firstUnit - - /** Amount per unit */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - /** - * Exclusive tier ending value. If null, this is treated as the last tier - */ - @JsonProperty("last_unit") - @ExcludeMissing - fun _lastUnit(): JsonField = lastUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - firstUnit() - unitAmount() - lastUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var firstUnit: JsonField? = null - private var unitAmount: JsonField? = null - private var lastUnit: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - firstUnit = tier.firstUnit - unitAmount = tier.unitAmount - lastUnit = tier.lastUnit - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Inclusive tier starting value */ - fun firstUnit(firstUnit: Double) = firstUnit(JsonField.of(firstUnit)) - - /** Inclusive tier starting value */ - fun firstUnit(firstUnit: JsonField) = apply { - this.firstUnit = firstUnit - } - - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) - - /** Amount per unit */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - /** - * Exclusive tier ending value. If null, this is treated as the last - * tier - */ - fun lastUnit(lastUnit: Double?) = - lastUnit(JsonField.ofNullable(lastUnit)) - - /** - * Exclusive tier ending value. If null, this is treated as the last - * tier - */ - fun lastUnit(lastUnit: Double) = lastUnit(lastUnit as Double?) - - /** - * Exclusive tier ending value. If null, this is treated as the last - * tier - */ - @Suppress( - "USELESS_CAST" - ) // See https://youtrack.jetbrains.com/issue/KT-74228 - fun lastUnit(lastUnit: Optional) = - lastUnit(lastUnit.orElse(null) as Double?) - - /** - * Exclusive tier ending value. If null, this is treated as the last - * tier - */ - fun lastUnit(lastUnit: JsonField) = apply { - this.lastUnit = lastUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Tier = - Tier( - checkRequired("firstUnit", firstUnit), - checkRequired("unitAmount", unitAmount), - lastUnit, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tier && firstUnit == other.firstUnit && unitAmount == other.unitAmount && lastUnit == other.lastUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(firstUnit, unitAmount, lastUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{firstUnit=$firstUnit, unitAmount=$unitAmount, lastUnit=$lastUnit, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredConfig && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredConfig{tiers=$tiers, additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionTieredPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredConfig == other.tieredConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionTieredPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionTieredBpsPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_bps_config") - @ExcludeMissing - private val tieredBpsConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun tieredBpsConfig(): TieredBpsConfig = - tieredBpsConfig.getRequired("tiered_bps_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("tiered_bps_config") - @ExcludeMissing - fun _tieredBpsConfig(): JsonField = tieredBpsConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionTieredBpsPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - tieredBpsConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionTieredBpsPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var tieredBpsConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionTieredBpsPrice: NewSubscriptionTieredBpsPrice - ) = apply { - cadence = newSubscriptionTieredBpsPrice.cadence - itemId = newSubscriptionTieredBpsPrice.itemId - modelType = newSubscriptionTieredBpsPrice.modelType - name = newSubscriptionTieredBpsPrice.name - tieredBpsConfig = newSubscriptionTieredBpsPrice.tieredBpsConfig - billableMetricId = newSubscriptionTieredBpsPrice.billableMetricId - billedInAdvance = newSubscriptionTieredBpsPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionTieredBpsPrice.billingCycleConfiguration - conversionRate = newSubscriptionTieredBpsPrice.conversionRate - currency = newSubscriptionTieredBpsPrice.currency - externalPriceId = newSubscriptionTieredBpsPrice.externalPriceId - fixedPriceQuantity = newSubscriptionTieredBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionTieredBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionTieredBpsPrice.invoicingCycleConfiguration - metadata = newSubscriptionTieredBpsPrice.metadata - referenceId = newSubscriptionTieredBpsPrice.referenceId - additionalProperties = - newSubscriptionTieredBpsPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredBpsConfig(tieredBpsConfig: TieredBpsConfig) = - tieredBpsConfig(JsonField.of(tieredBpsConfig)) - - fun tieredBpsConfig(tieredBpsConfig: JsonField) = apply { - this.tieredBpsConfig = tieredBpsConfig - } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionTieredBpsPrice = - NewSubscriptionTieredBpsPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("tieredBpsConfig", tieredBpsConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED_BPS = of("tiered_bps") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_BPS -> Value.TIERED_BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TIERED_BPS -> Known.TIERED_BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TieredBpsConfig - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - private val tiers: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into - * specified tiers - */ - fun tiers(): List = tiers.getRequired("tiers") - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into - * specified tiers - */ - @JsonProperty("tiers") - @ExcludeMissing - fun _tiers(): JsonField> = tiers - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredBpsConfig = apply { - if (validated) { - return@apply - } - - tiers().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredBpsConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tieredBpsConfig: TieredBpsConfig) = apply { - tiers = tieredBpsConfig.tiers.map { it.toMutableList() } - additionalProperties = - tieredBpsConfig.additionalProperties.toMutableMap() - } - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into - * specified tiers - */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into - * specified tiers - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into - * specified tiers - */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): TieredBpsConfig = - TieredBpsConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Tier - @JsonCreator - private constructor( - @JsonProperty("bps") - @ExcludeMissing - private val bps: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_maximum") - @ExcludeMissing - private val perUnitMaximum: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), - ) { - - /** Per-event basis point rate */ - fun bps(): Double = bps.getRequired("bps") - - /** Inclusive tier starting value */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** Exclusive tier ending value */ - fun maximumAmount(): Optional = - Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - - /** Per unit maximum to charge */ - fun perUnitMaximum(): Optional = - Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) - - /** Per-event basis point rate */ - @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps - - /** Inclusive tier starting value */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** Exclusive tier ending value */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** Per unit maximum to charge */ - @JsonProperty("per_unit_maximum") - @ExcludeMissing - fun _perUnitMaximum(): JsonField = perUnitMaximum - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - bps() - minimumAmount() - maximumAmount() - perUnitMaximum() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var bps: JsonField? = null - private var minimumAmount: JsonField? = null - private var maximumAmount: JsonField = JsonMissing.of() - private var perUnitMaximum: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - bps = tier.bps - minimumAmount = tier.minimumAmount - maximumAmount = tier.maximumAmount - perUnitMaximum = tier.perUnitMaximum - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Per-event basis point rate */ - fun bps(bps: Double) = bps(JsonField.of(bps)) - - /** Per-event basis point rate */ - fun bps(bps: JsonField) = apply { this.bps = bps } - - /** Inclusive tier starting value */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** Inclusive tier starting value */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** Exclusive tier ending value */ - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - /** Exclusive tier ending value */ - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.orElse(null)) - - /** Exclusive tier ending value */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** Per unit maximum to charge */ - fun perUnitMaximum(perUnitMaximum: String?) = - perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) - - /** Per unit maximum to charge */ - fun perUnitMaximum(perUnitMaximum: Optional) = - perUnitMaximum(perUnitMaximum.orElse(null)) - - /** Per unit maximum to charge */ - fun perUnitMaximum(perUnitMaximum: JsonField) = apply { - this.perUnitMaximum = perUnitMaximum - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): Tier = - Tier( - checkRequired("bps", bps), - checkRequired("minimumAmount", minimumAmount), - maximumAmount, - perUnitMaximum, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tier && bps == other.bps && minimumAmount == other.minimumAmount && maximumAmount == other.maximumAmount && perUnitMaximum == other.perUnitMaximum && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bps, minimumAmount, maximumAmount, perUnitMaximum, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{bps=$bps, minimumAmount=$minimumAmount, maximumAmount=$maximumAmount, perUnitMaximum=$perUnitMaximum, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredBpsConfig && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredBpsConfig{tiers=$tiers, additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionTieredBpsPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredBpsConfig == other.tieredBpsConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredBpsConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionTieredBpsPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredBpsConfig=$tieredBpsConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionBpsPrice - @JsonCreator - private constructor( - @JsonProperty("bps_config") - @ExcludeMissing - private val bpsConfig: JsonField = JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun bpsConfig(): BpsConfig = bpsConfig.getRequired("bps_config") - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - @JsonProperty("bps_config") - @ExcludeMissing - fun _bpsConfig(): JsonField = bpsConfig - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionBpsPrice = apply { - if (validated) { - return@apply - } - - bpsConfig().validate() - cadence() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionBpsPrice]. */ - class Builder internal constructor() { - - private var bpsConfig: JsonField? = null - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newSubscriptionBpsPrice: NewSubscriptionBpsPrice) = apply { - bpsConfig = newSubscriptionBpsPrice.bpsConfig - cadence = newSubscriptionBpsPrice.cadence - itemId = newSubscriptionBpsPrice.itemId - modelType = newSubscriptionBpsPrice.modelType - name = newSubscriptionBpsPrice.name - billableMetricId = newSubscriptionBpsPrice.billableMetricId - billedInAdvance = newSubscriptionBpsPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionBpsPrice.billingCycleConfiguration - conversionRate = newSubscriptionBpsPrice.conversionRate - currency = newSubscriptionBpsPrice.currency - externalPriceId = newSubscriptionBpsPrice.externalPriceId - fixedPriceQuantity = newSubscriptionBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionBpsPrice.invoicingCycleConfiguration - metadata = newSubscriptionBpsPrice.metadata - referenceId = newSubscriptionBpsPrice.referenceId - additionalProperties = - newSubscriptionBpsPrice.additionalProperties.toMutableMap() - } - - fun bpsConfig(bpsConfig: BpsConfig) = bpsConfig(JsonField.of(bpsConfig)) - - fun bpsConfig(bpsConfig: JsonField) = apply { - this.bpsConfig = bpsConfig - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionBpsPrice = - NewSubscriptionBpsPrice( - checkRequired("bpsConfig", bpsConfig), - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BpsConfig - @JsonCreator - private constructor( - @JsonProperty("bps") - @ExcludeMissing - private val bps: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_maximum") - @ExcludeMissing - private val perUnitMaximum: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Basis point take rate per event */ - fun bps(): Double = bps.getRequired("bps") - - /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(): Optional = - Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) - - /** Basis point take rate per event */ - @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps - - /** Optional currency amount maximum to cap spend per event */ - @JsonProperty("per_unit_maximum") - @ExcludeMissing - fun _perUnitMaximum(): JsonField = perUnitMaximum - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BpsConfig = apply { - if (validated) { - return@apply - } - - bps() - perUnitMaximum() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BpsConfig]. */ - class Builder internal constructor() { - - private var bps: JsonField? = null - private var perUnitMaximum: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(bpsConfig: BpsConfig) = apply { - bps = bpsConfig.bps - perUnitMaximum = bpsConfig.perUnitMaximum - additionalProperties = bpsConfig.additionalProperties.toMutableMap() - } - - /** Basis point take rate per event */ - fun bps(bps: Double) = bps(JsonField.of(bps)) - - /** Basis point take rate per event */ - fun bps(bps: JsonField) = apply { this.bps = bps } - - /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(perUnitMaximum: String?) = - perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) - - /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(perUnitMaximum: Optional) = - perUnitMaximum(perUnitMaximum.orElse(null)) - - /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(perUnitMaximum: JsonField) = apply { - this.perUnitMaximum = perUnitMaximum - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): BpsConfig = - BpsConfig( - checkRequired("bps", bps), - perUnitMaximum, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BpsConfig && bps == other.bps && perUnitMaximum == other.perUnitMaximum && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bps, perUnitMaximum, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BpsConfig{bps=$bps, perUnitMaximum=$perUnitMaximum, additionalProperties=$additionalProperties}" - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val BPS = of("bps") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BPS -> Value.BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - BPS -> Known.BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionBpsPrice && bpsConfig == other.bpsConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bpsConfig, cadence, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionBpsPrice{bpsConfig=$bpsConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionBulkBpsPrice - @JsonCreator - private constructor( - @JsonProperty("bulk_bps_config") - @ExcludeMissing - private val bulkBpsConfig: JsonField = JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun bulkBpsConfig(): BulkBpsConfig = bulkBpsConfig.getRequired("bulk_bps_config") - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - @JsonProperty("bulk_bps_config") - @ExcludeMissing - fun _bulkBpsConfig(): JsonField = bulkBpsConfig - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionBulkBpsPrice = apply { - if (validated) { - return@apply - } - - bulkBpsConfig().validate() - cadence() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionBulkBpsPrice]. */ - class Builder internal constructor() { - - private var bulkBpsConfig: JsonField? = null - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newSubscriptionBulkBpsPrice: NewSubscriptionBulkBpsPrice) = - apply { - bulkBpsConfig = newSubscriptionBulkBpsPrice.bulkBpsConfig - cadence = newSubscriptionBulkBpsPrice.cadence - itemId = newSubscriptionBulkBpsPrice.itemId - modelType = newSubscriptionBulkBpsPrice.modelType - name = newSubscriptionBulkBpsPrice.name - billableMetricId = newSubscriptionBulkBpsPrice.billableMetricId - billedInAdvance = newSubscriptionBulkBpsPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionBulkBpsPrice.billingCycleConfiguration - conversionRate = newSubscriptionBulkBpsPrice.conversionRate - currency = newSubscriptionBulkBpsPrice.currency - externalPriceId = newSubscriptionBulkBpsPrice.externalPriceId - fixedPriceQuantity = newSubscriptionBulkBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionBulkBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionBulkBpsPrice.invoicingCycleConfiguration - metadata = newSubscriptionBulkBpsPrice.metadata - referenceId = newSubscriptionBulkBpsPrice.referenceId - additionalProperties = - newSubscriptionBulkBpsPrice.additionalProperties.toMutableMap() - } - - fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfig) = - bulkBpsConfig(JsonField.of(bulkBpsConfig)) - - fun bulkBpsConfig(bulkBpsConfig: JsonField) = apply { - this.bulkBpsConfig = bulkBpsConfig - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionBulkBpsPrice = - NewSubscriptionBulkBpsPrice( - checkRequired("bulkBpsConfig", bulkBpsConfig), - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BulkBpsConfig - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - private val tiers: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a single - * tier based on total volume - */ - fun tiers(): List = tiers.getRequired("tiers") - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a single - * tier based on total volume - */ - @JsonProperty("tiers") - @ExcludeMissing - fun _tiers(): JsonField> = tiers - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BulkBpsConfig = apply { - if (validated) { - return@apply - } - - tiers().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkBpsConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(bulkBpsConfig: BulkBpsConfig) = apply { - tiers = bulkBpsConfig.tiers.map { it.toMutableList() } - additionalProperties = bulkBpsConfig.additionalProperties.toMutableMap() - } - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a - * single tier based on total volume - */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a - * single tier based on total volume - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a - * single tier based on total volume - */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): BulkBpsConfig = - BulkBpsConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Tier - @JsonCreator - private constructor( - @JsonProperty("bps") - @ExcludeMissing - private val bps: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_maximum") - @ExcludeMissing - private val perUnitMaximum: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), - ) { - - /** Basis points to rate on */ - fun bps(): Double = bps.getRequired("bps") - - /** Upper bound for tier */ - fun maximumAmount(): Optional = - Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(): Optional = - Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) - - /** Basis points to rate on */ - @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps - - /** Upper bound for tier */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** The maximum amount to charge for any one event */ - @JsonProperty("per_unit_maximum") - @ExcludeMissing - fun _perUnitMaximum(): JsonField = perUnitMaximum - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - bps() - maximumAmount() - perUnitMaximum() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var bps: JsonField? = null - private var maximumAmount: JsonField = JsonMissing.of() - private var perUnitMaximum: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - bps = tier.bps - maximumAmount = tier.maximumAmount - perUnitMaximum = tier.perUnitMaximum - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Basis points to rate on */ - fun bps(bps: Double) = bps(JsonField.of(bps)) - - /** Basis points to rate on */ - fun bps(bps: JsonField) = apply { this.bps = bps } - - /** Upper bound for tier */ - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - /** Upper bound for tier */ - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.orElse(null)) - - /** Upper bound for tier */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(perUnitMaximum: String?) = - perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) - - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(perUnitMaximum: Optional) = - perUnitMaximum(perUnitMaximum.orElse(null)) - - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(perUnitMaximum: JsonField) = apply { - this.perUnitMaximum = perUnitMaximum - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): Tier = - Tier( - checkRequired("bps", bps), - maximumAmount, - perUnitMaximum, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tier && bps == other.bps && maximumAmount == other.maximumAmount && perUnitMaximum == other.perUnitMaximum && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bps, maximumAmount, perUnitMaximum, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{bps=$bps, maximumAmount=$maximumAmount, perUnitMaximum=$perUnitMaximum, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BulkBpsConfig && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkBpsConfig{tiers=$tiers, additionalProperties=$additionalProperties}" - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val BULK_BPS = of("bulk_bps") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK_BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK_BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK_BPS -> Value.BULK_BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - BULK_BPS -> Known.BULK_BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionBulkBpsPrice && bulkBpsConfig == other.bulkBpsConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bulkBpsConfig, cadence, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionBulkBpsPrice{bulkBpsConfig=$bulkBpsConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionBulkPrice - @JsonCreator - private constructor( - @JsonProperty("bulk_config") - @ExcludeMissing - private val bulkConfig: JsonField = JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun bulkConfig(): BulkConfig = bulkConfig.getRequired("bulk_config") - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - @JsonProperty("bulk_config") - @ExcludeMissing - fun _bulkConfig(): JsonField = bulkConfig - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionBulkPrice = apply { - if (validated) { - return@apply - } - - bulkConfig().validate() - cadence() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionBulkPrice]. */ - class Builder internal constructor() { - - private var bulkConfig: JsonField? = null - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var 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 currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newSubscriptionBulkPrice: NewSubscriptionBulkPrice) = apply { - bulkConfig = newSubscriptionBulkPrice.bulkConfig - cadence = newSubscriptionBulkPrice.cadence - itemId = newSubscriptionBulkPrice.itemId - modelType = newSubscriptionBulkPrice.modelType - name = newSubscriptionBulkPrice.name - billableMetricId = newSubscriptionBulkPrice.billableMetricId - billedInAdvance = newSubscriptionBulkPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionBulkPrice.billingCycleConfiguration - conversionRate = newSubscriptionBulkPrice.conversionRate - currency = newSubscriptionBulkPrice.currency - externalPriceId = newSubscriptionBulkPrice.externalPriceId - fixedPriceQuantity = newSubscriptionBulkPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionBulkPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionBulkPrice.invoicingCycleConfiguration - metadata = newSubscriptionBulkPrice.metadata - referenceId = newSubscriptionBulkPrice.referenceId - additionalProperties = - newSubscriptionBulkPrice.additionalProperties.toMutableMap() - } - - fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) - - fun bulkConfig(bulkConfig: JsonField) = apply { - this.bulkConfig = bulkConfig - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionBulkPrice = - NewSubscriptionBulkPrice( - checkRequired("bulkConfig", bulkConfig), - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BulkConfig - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - private val tiers: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Bulk tiers for rating based on total usage volume */ - fun tiers(): List = tiers.getRequired("tiers") - - /** Bulk tiers for rating based on total usage volume */ - @JsonProperty("tiers") - @ExcludeMissing - fun _tiers(): JsonField> = tiers - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BulkConfig = apply { - if (validated) { - return@apply - } - - tiers().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(bulkConfig: BulkConfig) = apply { - tiers = bulkConfig.tiers.map { it.toMutableList() } - additionalProperties = bulkConfig.additionalProperties.toMutableMap() - } - - /** Bulk tiers for rating based on total usage volume */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - - /** Bulk tiers for rating based on total usage volume */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** Bulk tiers for rating based on total usage volume */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): BulkConfig = - BulkConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Tier - @JsonCreator - private constructor( - @JsonProperty("unit_amount") - @ExcludeMissing - private val unitAmount: JsonField = JsonMissing.of(), - @JsonProperty("maximum_units") - @ExcludeMissing - private val maximumUnits: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), - ) { - - /** Amount per unit */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** Upper bound for this tier */ - fun maximumUnits(): Optional = - Optional.ofNullable(maximumUnits.getNullable("maximum_units")) - - /** Amount per unit */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - /** Upper bound for this tier */ - @JsonProperty("maximum_units") - @ExcludeMissing - fun _maximumUnits(): JsonField = maximumUnits - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - unitAmount() - maximumUnits() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var unitAmount: JsonField? = null - private var maximumUnits: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - unitAmount = tier.unitAmount - maximumUnits = tier.maximumUnits - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) - - /** Amount per unit */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - /** Upper bound for this tier */ - fun maximumUnits(maximumUnits: Double?) = - maximumUnits(JsonField.ofNullable(maximumUnits)) - - /** Upper bound for this tier */ - fun maximumUnits(maximumUnits: Double) = - maximumUnits(maximumUnits as Double?) - - /** Upper bound for this tier */ - @Suppress( - "USELESS_CAST" - ) // See https://youtrack.jetbrains.com/issue/KT-74228 - fun maximumUnits(maximumUnits: Optional) = - maximumUnits(maximumUnits.orElse(null) as Double?) - - /** Upper bound for this tier */ - fun maximumUnits(maximumUnits: JsonField) = apply { - this.maximumUnits = maximumUnits - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Tier = - Tier( - checkRequired("unitAmount", unitAmount), - maximumUnits, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tier && unitAmount == other.unitAmount && maximumUnits == other.maximumUnits && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(unitAmount, maximumUnits, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{unitAmount=$unitAmount, maximumUnits=$maximumUnits, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BulkConfig && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkConfig{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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val BULK = of("bulk") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK -> Value.BULK - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - BULK -> Known.BULK - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionBulkPrice && bulkConfig == other.bulkConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bulkConfig, cadence, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionBulkPrice{bulkConfig=$bulkConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionThresholdTotalAmountPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("threshold_total_amount_config") - @ExcludeMissing - private val thresholdTotalAmountConfig: JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun thresholdTotalAmountConfig(): ThresholdTotalAmountConfig = - thresholdTotalAmountConfig.getRequired("threshold_total_amount_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("threshold_total_amount_config") - @ExcludeMissing - fun _thresholdTotalAmountConfig(): JsonField = - thresholdTotalAmountConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionThresholdTotalAmountPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - thresholdTotalAmountConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionThresholdTotalAmountPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var thresholdTotalAmountConfig: JsonField? = - null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionThresholdTotalAmountPrice: - NewSubscriptionThresholdTotalAmountPrice - ) = apply { - cadence = newSubscriptionThresholdTotalAmountPrice.cadence - itemId = newSubscriptionThresholdTotalAmountPrice.itemId - modelType = newSubscriptionThresholdTotalAmountPrice.modelType - name = newSubscriptionThresholdTotalAmountPrice.name - thresholdTotalAmountConfig = - newSubscriptionThresholdTotalAmountPrice.thresholdTotalAmountConfig - billableMetricId = newSubscriptionThresholdTotalAmountPrice.billableMetricId - billedInAdvance = newSubscriptionThresholdTotalAmountPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionThresholdTotalAmountPrice.billingCycleConfiguration - conversionRate = newSubscriptionThresholdTotalAmountPrice.conversionRate - currency = newSubscriptionThresholdTotalAmountPrice.currency - externalPriceId = newSubscriptionThresholdTotalAmountPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionThresholdTotalAmountPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionThresholdTotalAmountPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionThresholdTotalAmountPrice.invoicingCycleConfiguration - metadata = newSubscriptionThresholdTotalAmountPrice.metadata - referenceId = newSubscriptionThresholdTotalAmountPrice.referenceId - additionalProperties = - newSubscriptionThresholdTotalAmountPrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun thresholdTotalAmountConfig( - thresholdTotalAmountConfig: ThresholdTotalAmountConfig - ) = thresholdTotalAmountConfig(JsonField.of(thresholdTotalAmountConfig)) - - fun thresholdTotalAmountConfig( - thresholdTotalAmountConfig: JsonField - ) = apply { this.thresholdTotalAmountConfig = thresholdTotalAmountConfig } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionThresholdTotalAmountPrice = - NewSubscriptionThresholdTotalAmountPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("thresholdTotalAmountConfig", thresholdTotalAmountConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val THRESHOLD_TOTAL_AMOUNT = of("threshold_total_amount") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - THRESHOLD_TOTAL_AMOUNT - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - THRESHOLD_TOTAL_AMOUNT, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - THRESHOLD_TOTAL_AMOUNT -> Value.THRESHOLD_TOTAL_AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - THRESHOLD_TOTAL_AMOUNT -> Known.THRESHOLD_TOTAL_AMOUNT - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class ThresholdTotalAmountConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): ThresholdTotalAmountConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ThresholdTotalAmountConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(thresholdTotalAmountConfig: ThresholdTotalAmountConfig) = - apply { - additionalProperties = - thresholdTotalAmountConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): ThresholdTotalAmountConfig = - ThresholdTotalAmountConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ThresholdTotalAmountConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ThresholdTotalAmountConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionThresholdTotalAmountPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, thresholdTotalAmountConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionThresholdTotalAmountPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionTieredPackagePrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_package_config") - @ExcludeMissing - private val tieredPackageConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun tieredPackageConfig(): TieredPackageConfig = - tieredPackageConfig.getRequired("tiered_package_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("tiered_package_config") - @ExcludeMissing - fun _tieredPackageConfig(): JsonField = tieredPackageConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionTieredPackagePrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - tieredPackageConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionTieredPackagePrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var tieredPackageConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionTieredPackagePrice: NewSubscriptionTieredPackagePrice - ) = apply { - cadence = newSubscriptionTieredPackagePrice.cadence - itemId = newSubscriptionTieredPackagePrice.itemId - modelType = newSubscriptionTieredPackagePrice.modelType - name = newSubscriptionTieredPackagePrice.name - tieredPackageConfig = newSubscriptionTieredPackagePrice.tieredPackageConfig - billableMetricId = newSubscriptionTieredPackagePrice.billableMetricId - billedInAdvance = newSubscriptionTieredPackagePrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionTieredPackagePrice.billingCycleConfiguration - conversionRate = newSubscriptionTieredPackagePrice.conversionRate - currency = newSubscriptionTieredPackagePrice.currency - externalPriceId = newSubscriptionTieredPackagePrice.externalPriceId - fixedPriceQuantity = newSubscriptionTieredPackagePrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionTieredPackagePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionTieredPackagePrice.invoicingCycleConfiguration - metadata = newSubscriptionTieredPackagePrice.metadata - referenceId = newSubscriptionTieredPackagePrice.referenceId - additionalProperties = - newSubscriptionTieredPackagePrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = - tieredPackageConfig(JsonField.of(tieredPackageConfig)) - - fun tieredPackageConfig(tieredPackageConfig: JsonField) = - apply { - this.tieredPackageConfig = tieredPackageConfig - } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionTieredPackagePrice = - NewSubscriptionTieredPackagePrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("tieredPackageConfig", tieredPackageConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED_PACKAGE = of("tiered_package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_PACKAGE - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_PACKAGE, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_PACKAGE -> Value.TIERED_PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TIERED_PACKAGE -> Known.TIERED_PACKAGE - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TieredPackageConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredPackageConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredPackageConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tieredPackageConfig: TieredPackageConfig) = apply { - additionalProperties = - tieredPackageConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): TieredPackageConfig = - TieredPackageConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredPackageConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionTieredPackagePrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredPackageConfig == other.tieredPackageConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredPackageConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionTieredPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionTieredWithMinimumPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_minimum_config") - @ExcludeMissing - private val tieredWithMinimumConfig: JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun tieredWithMinimumConfig(): TieredWithMinimumConfig = - tieredWithMinimumConfig.getRequired("tiered_with_minimum_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("tiered_with_minimum_config") - @ExcludeMissing - fun _tieredWithMinimumConfig(): JsonField = - tieredWithMinimumConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionTieredWithMinimumPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - tieredWithMinimumConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionTieredWithMinimumPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var tieredWithMinimumConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionTieredWithMinimumPrice: NewSubscriptionTieredWithMinimumPrice - ) = apply { - cadence = newSubscriptionTieredWithMinimumPrice.cadence - itemId = newSubscriptionTieredWithMinimumPrice.itemId - modelType = newSubscriptionTieredWithMinimumPrice.modelType - name = newSubscriptionTieredWithMinimumPrice.name - tieredWithMinimumConfig = - newSubscriptionTieredWithMinimumPrice.tieredWithMinimumConfig - billableMetricId = newSubscriptionTieredWithMinimumPrice.billableMetricId - billedInAdvance = newSubscriptionTieredWithMinimumPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionTieredWithMinimumPrice.billingCycleConfiguration - conversionRate = newSubscriptionTieredWithMinimumPrice.conversionRate - currency = newSubscriptionTieredWithMinimumPrice.currency - externalPriceId = newSubscriptionTieredWithMinimumPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionTieredWithMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionTieredWithMinimumPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionTieredWithMinimumPrice.invoicingCycleConfiguration - metadata = newSubscriptionTieredWithMinimumPrice.metadata - referenceId = newSubscriptionTieredWithMinimumPrice.referenceId - additionalProperties = - newSubscriptionTieredWithMinimumPrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredWithMinimumConfig(tieredWithMinimumConfig: TieredWithMinimumConfig) = - tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) - - fun tieredWithMinimumConfig( - tieredWithMinimumConfig: JsonField - ) = apply { this.tieredWithMinimumConfig = tieredWithMinimumConfig } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionTieredWithMinimumPrice = - NewSubscriptionTieredWithMinimumPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("tieredWithMinimumConfig", tieredWithMinimumConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED_WITH_MINIMUM = of("tiered_with_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_WITH_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_WITH_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_WITH_MINIMUM -> Value.TIERED_WITH_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TIERED_WITH_MINIMUM -> Known.TIERED_WITH_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TieredWithMinimumConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredWithMinimumConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredWithMinimumConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tieredWithMinimumConfig: TieredWithMinimumConfig) = - apply { - additionalProperties = - tieredWithMinimumConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): TieredWithMinimumConfig = - TieredWithMinimumConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredWithMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredWithMinimumConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionTieredWithMinimumPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredWithMinimumConfig == other.tieredWithMinimumConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredWithMinimumConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionTieredWithMinimumPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionUnitWithPercentPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("unit_with_percent_config") - @ExcludeMissing - private val unitWithPercentConfig: JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun unitWithPercentConfig(): UnitWithPercentConfig = - unitWithPercentConfig.getRequired("unit_with_percent_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("unit_with_percent_config") - @ExcludeMissing - fun _unitWithPercentConfig(): JsonField = - unitWithPercentConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionUnitWithPercentPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - unitWithPercentConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionUnitWithPercentPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var unitWithPercentConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionUnitWithPercentPrice: NewSubscriptionUnitWithPercentPrice - ) = apply { - cadence = newSubscriptionUnitWithPercentPrice.cadence - itemId = newSubscriptionUnitWithPercentPrice.itemId - modelType = newSubscriptionUnitWithPercentPrice.modelType - name = newSubscriptionUnitWithPercentPrice.name - unitWithPercentConfig = - newSubscriptionUnitWithPercentPrice.unitWithPercentConfig - billableMetricId = newSubscriptionUnitWithPercentPrice.billableMetricId - billedInAdvance = newSubscriptionUnitWithPercentPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionUnitWithPercentPrice.billingCycleConfiguration - conversionRate = newSubscriptionUnitWithPercentPrice.conversionRate - currency = newSubscriptionUnitWithPercentPrice.currency - externalPriceId = newSubscriptionUnitWithPercentPrice.externalPriceId - fixedPriceQuantity = newSubscriptionUnitWithPercentPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionUnitWithPercentPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionUnitWithPercentPrice.invoicingCycleConfiguration - metadata = newSubscriptionUnitWithPercentPrice.metadata - referenceId = newSubscriptionUnitWithPercentPrice.referenceId - additionalProperties = - newSubscriptionUnitWithPercentPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun unitWithPercentConfig(unitWithPercentConfig: UnitWithPercentConfig) = - unitWithPercentConfig(JsonField.of(unitWithPercentConfig)) - - fun unitWithPercentConfig( - unitWithPercentConfig: JsonField - ) = apply { this.unitWithPercentConfig = unitWithPercentConfig } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionUnitWithPercentPrice = - NewSubscriptionUnitWithPercentPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("unitWithPercentConfig", unitWithPercentConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val UNIT_WITH_PERCENT = of("unit_with_percent") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - UNIT_WITH_PERCENT - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - UNIT_WITH_PERCENT, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - UNIT_WITH_PERCENT -> Value.UNIT_WITH_PERCENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - UNIT_WITH_PERCENT -> Known.UNIT_WITH_PERCENT - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class UnitWithPercentConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): UnitWithPercentConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnitWithPercentConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unitWithPercentConfig: UnitWithPercentConfig) = apply { - additionalProperties = - unitWithPercentConfig.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) - } - - fun build(): UnitWithPercentConfig = - UnitWithPercentConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UnitWithPercentConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnitWithPercentConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionUnitWithPercentPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && unitWithPercentConfig == other.unitWithPercentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, unitWithPercentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionUnitWithPercentPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionPackageWithAllocationPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("package_with_allocation_config") - @ExcludeMissing - private val packageWithAllocationConfig: JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun packageWithAllocationConfig(): PackageWithAllocationConfig = - packageWithAllocationConfig.getRequired("package_with_allocation_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("package_with_allocation_config") - @ExcludeMissing - fun _packageWithAllocationConfig(): JsonField = - packageWithAllocationConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionPackageWithAllocationPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - packageWithAllocationConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionPackageWithAllocationPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var packageWithAllocationConfig: - JsonField? = - null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionPackageWithAllocationPrice: - NewSubscriptionPackageWithAllocationPrice - ) = apply { - cadence = newSubscriptionPackageWithAllocationPrice.cadence - itemId = newSubscriptionPackageWithAllocationPrice.itemId - modelType = newSubscriptionPackageWithAllocationPrice.modelType - name = newSubscriptionPackageWithAllocationPrice.name - packageWithAllocationConfig = - newSubscriptionPackageWithAllocationPrice.packageWithAllocationConfig - billableMetricId = - newSubscriptionPackageWithAllocationPrice.billableMetricId - billedInAdvance = newSubscriptionPackageWithAllocationPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionPackageWithAllocationPrice.billingCycleConfiguration - conversionRate = newSubscriptionPackageWithAllocationPrice.conversionRate - currency = newSubscriptionPackageWithAllocationPrice.currency - externalPriceId = newSubscriptionPackageWithAllocationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionPackageWithAllocationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionPackageWithAllocationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionPackageWithAllocationPrice.invoicingCycleConfiguration - metadata = newSubscriptionPackageWithAllocationPrice.metadata - referenceId = newSubscriptionPackageWithAllocationPrice.referenceId - additionalProperties = - newSubscriptionPackageWithAllocationPrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun packageWithAllocationConfig( - packageWithAllocationConfig: PackageWithAllocationConfig - ) = packageWithAllocationConfig(JsonField.of(packageWithAllocationConfig)) - - fun packageWithAllocationConfig( - packageWithAllocationConfig: JsonField - ) = apply { this.packageWithAllocationConfig = packageWithAllocationConfig } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionPackageWithAllocationPrice = - NewSubscriptionPackageWithAllocationPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired( - "packageWithAllocationConfig", - packageWithAllocationConfig, - ), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val PACKAGE_WITH_ALLOCATION = of("package_with_allocation") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - PACKAGE_WITH_ALLOCATION - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PACKAGE_WITH_ALLOCATION, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PACKAGE_WITH_ALLOCATION -> Value.PACKAGE_WITH_ALLOCATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PACKAGE_WITH_ALLOCATION -> Known.PACKAGE_WITH_ALLOCATION - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class PackageWithAllocationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PackageWithAllocationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PackageWithAllocationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - packageWithAllocationConfig: PackageWithAllocationConfig - ) = apply { - additionalProperties = - packageWithAllocationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): PackageWithAllocationConfig = - PackageWithAllocationConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PackageWithAllocationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PackageWithAllocationConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionPackageWithAllocationPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && packageWithAllocationConfig == other.packageWithAllocationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, packageWithAllocationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionPackageWithAllocationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionTierWithProrationPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - private val tieredWithProrationConfig: JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - 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. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionTierWithProrationPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - tieredWithProrationConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionTierWithProrationPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var tieredWithProrationConfig: JsonField? = - null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionTierWithProrationPrice: NewSubscriptionTierWithProrationPrice - ) = apply { - cadence = newSubscriptionTierWithProrationPrice.cadence - itemId = newSubscriptionTierWithProrationPrice.itemId - modelType = newSubscriptionTierWithProrationPrice.modelType - name = newSubscriptionTierWithProrationPrice.name - tieredWithProrationConfig = - newSubscriptionTierWithProrationPrice.tieredWithProrationConfig - billableMetricId = newSubscriptionTierWithProrationPrice.billableMetricId - billedInAdvance = newSubscriptionTierWithProrationPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionTierWithProrationPrice.billingCycleConfiguration - conversionRate = newSubscriptionTierWithProrationPrice.conversionRate - currency = newSubscriptionTierWithProrationPrice.currency - externalPriceId = newSubscriptionTierWithProrationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionTierWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionTierWithProrationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionTierWithProrationPrice.invoicingCycleConfiguration - metadata = newSubscriptionTierWithProrationPrice.metadata - referenceId = newSubscriptionTierWithProrationPrice.referenceId - additionalProperties = - newSubscriptionTierWithProrationPrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredWithProrationConfig( - tieredWithProrationConfig: TieredWithProrationConfig - ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionTierWithProrationPrice = - NewSubscriptionTierWithProrationPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED_WITH_PRORATION = of("tiered_with_proration") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_WITH_PRORATION - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_WITH_PRORATION, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_WITH_PRORATION -> Value.TIERED_WITH_PRORATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TIERED_WITH_PRORATION -> Known.TIERED_WITH_PRORATION - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TieredWithProrationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredWithProrationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredWithProrationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = - apply { - additionalProperties = - tieredWithProrationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredWithProrationConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionTierWithProrationPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionTierWithProrationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionUnitWithProrationPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("unit_with_proration_config") - @ExcludeMissing - private val unitWithProrationConfig: JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun unitWithProrationConfig(): UnitWithProrationConfig = - unitWithProrationConfig.getRequired("unit_with_proration_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("unit_with_proration_config") - @ExcludeMissing - fun _unitWithProrationConfig(): JsonField = - unitWithProrationConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionUnitWithProrationPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - unitWithProrationConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionUnitWithProrationPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var unitWithProrationConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionUnitWithProrationPrice: NewSubscriptionUnitWithProrationPrice - ) = apply { - cadence = newSubscriptionUnitWithProrationPrice.cadence - itemId = newSubscriptionUnitWithProrationPrice.itemId - modelType = newSubscriptionUnitWithProrationPrice.modelType - name = newSubscriptionUnitWithProrationPrice.name - unitWithProrationConfig = - newSubscriptionUnitWithProrationPrice.unitWithProrationConfig - billableMetricId = newSubscriptionUnitWithProrationPrice.billableMetricId - billedInAdvance = newSubscriptionUnitWithProrationPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionUnitWithProrationPrice.billingCycleConfiguration - conversionRate = newSubscriptionUnitWithProrationPrice.conversionRate - currency = newSubscriptionUnitWithProrationPrice.currency - externalPriceId = newSubscriptionUnitWithProrationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionUnitWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionUnitWithProrationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionUnitWithProrationPrice.invoicingCycleConfiguration - metadata = newSubscriptionUnitWithProrationPrice.metadata - referenceId = newSubscriptionUnitWithProrationPrice.referenceId - additionalProperties = - newSubscriptionUnitWithProrationPrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun unitWithProrationConfig(unitWithProrationConfig: UnitWithProrationConfig) = - unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) - - fun unitWithProrationConfig( - unitWithProrationConfig: JsonField - ) = apply { this.unitWithProrationConfig = unitWithProrationConfig } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionUnitWithProrationPrice = - NewSubscriptionUnitWithProrationPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("unitWithProrationConfig", unitWithProrationConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val UNIT_WITH_PRORATION = of("unit_with_proration") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - UNIT_WITH_PRORATION - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - UNIT_WITH_PRORATION, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - UNIT_WITH_PRORATION -> Value.UNIT_WITH_PRORATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - UNIT_WITH_PRORATION -> Known.UNIT_WITH_PRORATION - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class UnitWithProrationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): UnitWithProrationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnitWithProrationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unitWithProrationConfig: UnitWithProrationConfig) = - apply { - additionalProperties = - unitWithProrationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): UnitWithProrationConfig = - UnitWithProrationConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UnitWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnitWithProrationConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionUnitWithProrationPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && unitWithProrationConfig == other.unitWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, unitWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionUnitWithProrationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionGroupedAllocationPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_allocation_config") - @ExcludeMissing - private val groupedAllocationConfig: JsonField = - JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - fun groupedAllocationConfig(): GroupedAllocationConfig = - groupedAllocationConfig.getRequired("grouped_allocation_config") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - @JsonProperty("grouped_allocation_config") - @ExcludeMissing - fun _groupedAllocationConfig(): JsonField = - groupedAllocationConfig - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionGroupedAllocationPrice = apply { - if (validated) { - return@apply - } - - cadence() - groupedAllocationConfig().validate() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionGroupedAllocationPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var groupedAllocationConfig: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var 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 currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionGroupedAllocationPrice: NewSubscriptionGroupedAllocationPrice - ) = apply { - cadence = newSubscriptionGroupedAllocationPrice.cadence - groupedAllocationConfig = - newSubscriptionGroupedAllocationPrice.groupedAllocationConfig - itemId = newSubscriptionGroupedAllocationPrice.itemId - modelType = newSubscriptionGroupedAllocationPrice.modelType - name = newSubscriptionGroupedAllocationPrice.name - billableMetricId = newSubscriptionGroupedAllocationPrice.billableMetricId - billedInAdvance = newSubscriptionGroupedAllocationPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionGroupedAllocationPrice.billingCycleConfiguration - conversionRate = newSubscriptionGroupedAllocationPrice.conversionRate - currency = newSubscriptionGroupedAllocationPrice.currency - externalPriceId = newSubscriptionGroupedAllocationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionGroupedAllocationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionGroupedAllocationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionGroupedAllocationPrice.invoicingCycleConfiguration - metadata = newSubscriptionGroupedAllocationPrice.metadata - referenceId = newSubscriptionGroupedAllocationPrice.referenceId - additionalProperties = - newSubscriptionGroupedAllocationPrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = - groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) - - fun groupedAllocationConfig( - groupedAllocationConfig: JsonField - ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionGroupedAllocationPrice = - NewSubscriptionGroupedAllocationPrice( - checkRequired("cadence", cadence), - checkRequired("groupedAllocationConfig", groupedAllocationConfig), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class GroupedAllocationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): GroupedAllocationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [GroupedAllocationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(groupedAllocationConfig: GroupedAllocationConfig) = - apply { - additionalProperties = - groupedAllocationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): GroupedAllocationConfig = - GroupedAllocationConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GroupedAllocationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedAllocationConfig{additionalProperties=$additionalProperties}" - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val GROUPED_ALLOCATION = of("grouped_allocation") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_ALLOCATION - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GROUPED_ALLOCATION, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GROUPED_ALLOCATION -> Value.GROUPED_ALLOCATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - GROUPED_ALLOCATION -> Known.GROUPED_ALLOCATION - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionGroupedAllocationPrice && cadence == other.cadence && groupedAllocationConfig == other.groupedAllocationConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, groupedAllocationConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionGroupedAllocationPrice{cadence=$cadence, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionGroupedWithProratedMinimumPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_prorated_minimum_config") - @ExcludeMissing - private val groupedWithProratedMinimumConfig: - JsonField = - JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - fun groupedWithProratedMinimumConfig(): GroupedWithProratedMinimumConfig = - groupedWithProratedMinimumConfig.getRequired( - "grouped_with_prorated_minimum_config" - ) - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - @JsonProperty("grouped_with_prorated_minimum_config") - @ExcludeMissing - fun _groupedWithProratedMinimumConfig(): - JsonField = groupedWithProratedMinimumConfig - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionGroupedWithProratedMinimumPrice = apply { - if (validated) { - return@apply - } - - cadence() - groupedWithProratedMinimumConfig().validate() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionGroupedWithProratedMinimumPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var groupedWithProratedMinimumConfig: - JsonField? = - null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionGroupedWithProratedMinimumPrice: - NewSubscriptionGroupedWithProratedMinimumPrice - ) = apply { - cadence = newSubscriptionGroupedWithProratedMinimumPrice.cadence - groupedWithProratedMinimumConfig = - newSubscriptionGroupedWithProratedMinimumPrice - .groupedWithProratedMinimumConfig - itemId = newSubscriptionGroupedWithProratedMinimumPrice.itemId - modelType = newSubscriptionGroupedWithProratedMinimumPrice.modelType - name = newSubscriptionGroupedWithProratedMinimumPrice.name - billableMetricId = - newSubscriptionGroupedWithProratedMinimumPrice.billableMetricId - billedInAdvance = - newSubscriptionGroupedWithProratedMinimumPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionGroupedWithProratedMinimumPrice.billingCycleConfiguration - conversionRate = - newSubscriptionGroupedWithProratedMinimumPrice.conversionRate - currency = newSubscriptionGroupedWithProratedMinimumPrice.currency - externalPriceId = - newSubscriptionGroupedWithProratedMinimumPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionGroupedWithProratedMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionGroupedWithProratedMinimumPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionGroupedWithProratedMinimumPrice - .invoicingCycleConfiguration - metadata = newSubscriptionGroupedWithProratedMinimumPrice.metadata - referenceId = newSubscriptionGroupedWithProratedMinimumPrice.referenceId - additionalProperties = - newSubscriptionGroupedWithProratedMinimumPrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - fun groupedWithProratedMinimumConfig( - groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig - ) = - groupedWithProratedMinimumConfig( - JsonField.of(groupedWithProratedMinimumConfig) - ) - - fun groupedWithProratedMinimumConfig( - groupedWithProratedMinimumConfig: - JsonField - ) = apply { - this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig - } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionGroupedWithProratedMinimumPrice = - NewSubscriptionGroupedWithProratedMinimumPrice( - checkRequired("cadence", cadence), - checkRequired( - "groupedWithProratedMinimumConfig", - groupedWithProratedMinimumConfig, - ), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class GroupedWithProratedMinimumConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): GroupedWithProratedMinimumConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [GroupedWithProratedMinimumConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig - ) = apply { - additionalProperties = - groupedWithProratedMinimumConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): GroupedWithProratedMinimumConfig = - GroupedWithProratedMinimumConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GroupedWithProratedMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedWithProratedMinimumConfig{additionalProperties=$additionalProperties}" - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField - val GROUPED_WITH_PRORATED_MINIMUM = of("grouped_with_prorated_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_WITH_PRORATED_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GROUPED_WITH_PRORATED_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GROUPED_WITH_PRORATED_MINIMUM -> Value.GROUPED_WITH_PRORATED_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - GROUPED_WITH_PRORATED_MINIMUM -> Known.GROUPED_WITH_PRORATED_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionGroupedWithProratedMinimumPrice && cadence == other.cadence && groupedWithProratedMinimumConfig == other.groupedWithProratedMinimumConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, groupedWithProratedMinimumConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionGroupedWithProratedMinimumPrice{cadence=$cadence, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionBulkWithProrationPrice - @JsonCreator - private constructor( - @JsonProperty("bulk_with_proration_config") - @ExcludeMissing - private val bulkWithProrationConfig: JsonField = - JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun bulkWithProrationConfig(): BulkWithProrationConfig = - bulkWithProrationConfig.getRequired("bulk_with_proration_config") - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - @JsonProperty("bulk_with_proration_config") - @ExcludeMissing - fun _bulkWithProrationConfig(): JsonField = - bulkWithProrationConfig - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionBulkWithProrationPrice = apply { - if (validated) { - return@apply - } - - bulkWithProrationConfig().validate() - cadence() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionBulkWithProrationPrice]. */ - class Builder internal constructor() { - - private var bulkWithProrationConfig: JsonField? = null - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var 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 currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionBulkWithProrationPrice: NewSubscriptionBulkWithProrationPrice - ) = apply { - bulkWithProrationConfig = - newSubscriptionBulkWithProrationPrice.bulkWithProrationConfig - cadence = newSubscriptionBulkWithProrationPrice.cadence - itemId = newSubscriptionBulkWithProrationPrice.itemId - modelType = newSubscriptionBulkWithProrationPrice.modelType - name = newSubscriptionBulkWithProrationPrice.name - billableMetricId = newSubscriptionBulkWithProrationPrice.billableMetricId - billedInAdvance = newSubscriptionBulkWithProrationPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionBulkWithProrationPrice.billingCycleConfiguration - conversionRate = newSubscriptionBulkWithProrationPrice.conversionRate - currency = newSubscriptionBulkWithProrationPrice.currency - externalPriceId = newSubscriptionBulkWithProrationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionBulkWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionBulkWithProrationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionBulkWithProrationPrice.invoicingCycleConfiguration - metadata = newSubscriptionBulkWithProrationPrice.metadata - referenceId = newSubscriptionBulkWithProrationPrice.referenceId - additionalProperties = - newSubscriptionBulkWithProrationPrice.additionalProperties - .toMutableMap() - } - - fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = - bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) - - fun bulkWithProrationConfig( - bulkWithProrationConfig: JsonField - ) = apply { this.bulkWithProrationConfig = bulkWithProrationConfig } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionBulkWithProrationPrice = - NewSubscriptionBulkWithProrationPrice( - checkRequired("bulkWithProrationConfig", bulkWithProrationConfig), - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BulkWithProrationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BulkWithProrationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkWithProrationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(bulkWithProrationConfig: BulkWithProrationConfig) = - apply { - additionalProperties = - bulkWithProrationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): BulkWithProrationConfig = - BulkWithProrationConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BulkWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkWithProrationConfig{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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val BULK_WITH_PRORATION = of("bulk_with_proration") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK_WITH_PRORATION - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK_WITH_PRORATION, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK_WITH_PRORATION -> Value.BULK_WITH_PRORATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - BULK_WITH_PRORATION -> Known.BULK_WITH_PRORATION - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionBulkWithProrationPrice && bulkWithProrationConfig == other.bulkWithProrationConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bulkWithProrationConfig, cadence, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionBulkWithProrationPrice{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AddPrice && allocationPrice == other.allocationPrice && discounts == other.discounts && endDate == other.endDate && externalPriceId == other.externalPriceId && maximumAmount == other.maximumAmount && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && price == other.price && priceId == other.priceId && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allocationPrice, discounts, endDate, externalPriceId, maximumAmount, minimumAmount, planPhaseOrder, price, priceId, startDate, additionalProperties) } - /* spotless:on */ - - 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}" - } - - @NoAutoDetect - class BillingCycleAnchorConfiguration - @JsonCreator - private constructor( - @JsonProperty("day") @ExcludeMissing private val day: JsonField = JsonMissing.of(), - @JsonProperty("month") - @ExcludeMissing - private val month: JsonField = JsonMissing.of(), - @JsonProperty("year") @ExcludeMissing private val year: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun day(): Long = day.getRequired("day") - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(): Optional = Optional.ofNullable(month.getNullable("month")) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on - * 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(): Optional = Optional.ofNullable(year.getNullable("year")) - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - @JsonProperty("day") @ExcludeMissing fun _day(): JsonField = day - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - @JsonProperty("month") @ExcludeMissing fun _month(): JsonField = month - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on - * 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - @JsonProperty("year") @ExcludeMissing fun _year(): JsonField = year - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleAnchorConfiguration = apply { - if (validated) { - return@apply - } - - day() - month() - year() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleAnchorConfiguration]. */ - class Builder internal constructor() { - - private var day: JsonField? = null - private var month: JsonField = JsonMissing.of() - private var year: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration) = - apply { - day = billingCycleAnchorConfiguration.day - month = billingCycleAnchorConfiguration.month - year = billingCycleAnchorConfiguration.year - additionalProperties = - billingCycleAnchorConfiguration.additionalProperties.toMutableMap() - } - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun day(day: Long) = day(JsonField.of(day)) - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun day(day: JsonField) = apply { this.day = day } - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(month: Long?) = month(JsonField.ofNullable(month)) - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(month: Long) = month(month as Long?) - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun month(month: Optional) = month(month.orElse(null) as Long?) - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(month: JsonField) = apply { this.month = month } - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(year: Long?) = year(JsonField.ofNullable(year)) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(year: Long) = year(year as Long?) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun year(year: Optional) = year(year.orElse(null) as Long?) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(year: JsonField) = apply { this.year = year } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleAnchorConfiguration = - BillingCycleAnchorConfiguration( - checkRequired("day", day), - month, - year, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleAnchorConfiguration && day == other.day && month == other.month && year == other.year && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(day, month, year, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleAnchorConfiguration{day=$day, month=$month, year=$year, 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ExternalMarketplace && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed by setting - * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to - * `null`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class RemoveAdjustment - @JsonCreator - private constructor( - @JsonProperty("adjustment_id") - @ExcludeMissing - private val adjustmentId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The id of the adjustment to remove on the subscription. */ - fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") - - /** The id of the adjustment to remove on the subscription. */ - @JsonProperty("adjustment_id") - @ExcludeMissing - fun _adjustmentId(): JsonField = adjustmentId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): RemoveAdjustment = apply { - if (validated) { - return@apply - } - - adjustmentId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - /** The id of the adjustment to remove on the subscription. */ - 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) - } - - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RemoveAdjustment && adjustmentId == other.adjustmentId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustmentId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class RemovePrice - @JsonCreator - private constructor( - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("price_id") - @ExcludeMissing - private val priceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The external price id of the price to remove on the subscription. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** The id of the price to remove on the subscription. */ - fun priceId(): Optional = Optional.ofNullable(priceId.getNullable("price_id")) - - /** The external price id of the price to remove on the subscription. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** The id of the price to remove on the subscription. */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): RemovePrice = apply { - if (validated) { - return@apply - } - - externalPriceId() - priceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - /** The external price id of the price to remove on the subscription. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** The external price id of the price to remove on the subscription. */ - 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)) - - /** The id of the price to remove on the subscription. */ - fun priceId(priceId: Optional) = priceId(priceId.orElse(null)) - - /** The id of the price to remove on the subscription. */ - 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) - } - - fun build(): RemovePrice = - RemovePrice(externalPriceId, priceId, additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RemovePrice && externalPriceId == other.externalPriceId && priceId == other.priceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(externalPriceId, priceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RemovePrice{externalPriceId=$externalPriceId, priceId=$priceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class ReplaceAdjustment - @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - private val adjustment: JsonField = JsonMissing.of(), - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - private val replacesAdjustmentId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") - - /** The id of the adjustment on the plan to replace in the subscription. */ - fun replacesAdjustmentId(): String = - replacesAdjustmentId.getRequired("replaces_adjustment_id") - - /** The definition of a new adjustment to create and add to the subscription. */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment - - /** The id of the adjustment on the plan to replace in the subscription. */ - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } - - adjustment().validate() - replacesAdjustmentId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } - - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(newPercentageDiscount: Adjustment.NewPercentageDiscount) = - adjustment(Adjustment.ofNewPercentageDiscount(newPercentageDiscount)) - - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(newUsageDiscount: Adjustment.NewUsageDiscount) = - adjustment(Adjustment.ofNewUsageDiscount(newUsageDiscount)) - - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(newAmountDiscount: Adjustment.NewAmountDiscount) = - adjustment(Adjustment.ofNewAmountDiscount(newAmountDiscount)) - - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(newMinimum: Adjustment.NewMinimum) = - adjustment(Adjustment.ofNewMinimum(newMinimum)) - - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(newMaximum: Adjustment.NewMaximum) = - adjustment(Adjustment.ofNewMaximum(newMaximum)) - - /** The id of the adjustment on the plan to replace in the subscription. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) - - /** The id of the adjustment on the plan to replace in the subscription. */ - 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) - } - - fun build(): ReplaceAdjustment = - ReplaceAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("replacesAdjustmentId", replacesAdjustmentId), - additionalProperties.toImmutable(), - ) - } - - /** The definition of a new adjustment to create and add to the subscription. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val newPercentageDiscount: NewPercentageDiscount? = null, - private val newUsageDiscount: NewUsageDiscount? = null, - private val newAmountDiscount: NewAmountDiscount? = null, - private val newMinimum: NewMinimum? = null, - private val newMaximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { - - fun newPercentageDiscount(): Optional = - Optional.ofNullable(newPercentageDiscount) - - fun newUsageDiscount(): Optional = - Optional.ofNullable(newUsageDiscount) - - fun newAmountDiscount(): Optional = - Optional.ofNullable(newAmountDiscount) - - fun newMinimum(): Optional = Optional.ofNullable(newMinimum) - - fun newMaximum(): Optional = Optional.ofNullable(newMaximum) - - fun isNewPercentageDiscount(): Boolean = newPercentageDiscount != null - - fun isNewUsageDiscount(): Boolean = newUsageDiscount != null - - fun isNewAmountDiscount(): Boolean = newAmountDiscount != null - - fun isNewMinimum(): Boolean = newMinimum != null - - fun isNewMaximum(): Boolean = newMaximum != null - - fun asNewPercentageDiscount(): NewPercentageDiscount = - newPercentageDiscount.getOrThrow("newPercentageDiscount") - - fun asNewUsageDiscount(): NewUsageDiscount = - newUsageDiscount.getOrThrow("newUsageDiscount") - - fun asNewAmountDiscount(): NewAmountDiscount = - newAmountDiscount.getOrThrow("newAmountDiscount") - - fun asNewMinimum(): NewMinimum = newMinimum.getOrThrow("newMinimum") - - fun asNewMaximum(): NewMaximum = newMaximum.getOrThrow("newMaximum") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - newPercentageDiscount != null -> - visitor.visitNewPercentageDiscount(newPercentageDiscount) - newUsageDiscount != null -> visitor.visitNewUsageDiscount(newUsageDiscount) - newAmountDiscount != null -> visitor.visitNewAmountDiscount(newAmountDiscount) - newMinimum != null -> visitor.visitNewMinimum(newMinimum) - newMaximum != null -> visitor.visitNewMaximum(newMaximum) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitNewPercentageDiscount( - newPercentageDiscount: NewPercentageDiscount - ) { - newPercentageDiscount.validate() - } - - override fun visitNewUsageDiscount(newUsageDiscount: NewUsageDiscount) { - newUsageDiscount.validate() - } - - override fun visitNewAmountDiscount(newAmountDiscount: NewAmountDiscount) { - newAmountDiscount.validate() - } - - override fun visitNewMinimum(newMinimum: NewMinimum) { - newMinimum.validate() - } - - override fun visitNewMaximum(newMaximum: NewMaximum) { - newMaximum.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Adjustment && newPercentageDiscount == other.newPercentageDiscount && newUsageDiscount == other.newUsageDiscount && newAmountDiscount == other.newAmountDiscount && newMinimum == other.newMinimum && newMaximum == other.newMaximum /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(newPercentageDiscount, newUsageDiscount, newAmountDiscount, newMinimum, newMaximum) /* spotless:on */ - - override fun toString(): String = - when { - newPercentageDiscount != null -> - "Adjustment{newPercentageDiscount=$newPercentageDiscount}" - newUsageDiscount != null -> "Adjustment{newUsageDiscount=$newUsageDiscount}" - newAmountDiscount != null -> "Adjustment{newAmountDiscount=$newAmountDiscount}" - newMinimum != null -> "Adjustment{newMinimum=$newMinimum}" - newMaximum != null -> "Adjustment{newMaximum=$newMaximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } - - companion object { - - @JvmStatic - fun ofNewPercentageDiscount(newPercentageDiscount: NewPercentageDiscount) = - Adjustment(newPercentageDiscount = newPercentageDiscount) - - @JvmStatic - fun ofNewUsageDiscount(newUsageDiscount: NewUsageDiscount) = - Adjustment(newUsageDiscount = newUsageDiscount) - - @JvmStatic - fun ofNewAmountDiscount(newAmountDiscount: NewAmountDiscount) = - Adjustment(newAmountDiscount = newAmountDiscount) - - @JvmStatic - fun ofNewMinimum(newMinimum: NewMinimum) = Adjustment(newMinimum = newMinimum) - - @JvmStatic - fun ofNewMaximum(newMaximum: NewMaximum) = Adjustment(newMaximum = newMaximum) - } - - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { - - fun visitNewPercentageDiscount(newPercentageDiscount: NewPercentageDiscount): T - - fun visitNewUsageDiscount(newUsageDiscount: NewUsageDiscount): T - - fun visitNewAmountDiscount(newAmountDiscount: NewAmountDiscount): T - - fun visitNewMinimum(newMinimum: NewMinimum): T - - fun visitNewMaximum(newMaximum: 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" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(newPercentageDiscount = it, _json = json) - } - } - "usage_discount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(newUsageDiscount = it, _json = json) - } - } - "amount_discount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(newAmountDiscount = it, _json = json) - } - } - "minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Adjustment(newMinimum = it, _json = json) - } - } - "maximum" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Adjustment(newMaximum = it, _json = json) - } - } - } - - return Adjustment(_json = json) - } - } - - internal class Serializer : BaseSerializer(Adjustment::class) { - - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.newPercentageDiscount != null -> - generator.writeObject(value.newPercentageDiscount) - value.newUsageDiscount != null -> - generator.writeObject(value.newUsageDiscount) - value.newAmountDiscount != null -> - generator.writeObject(value.newAmountDiscount) - value.newMinimum != null -> generator.writeObject(value.newMinimum) - value.newMaximum != null -> generator.writeObject(value.newMaximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") - } - } - } - - @NoAutoDetect - class NewPercentageDiscount - @JsonCreator - private constructor( - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("percentage_discount") - @ExcludeMissing - private val percentageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - fun percentageDiscount(): Double = - percentageDiscount.getRequired("percentage_discount") - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(): Optional = - Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The set of price IDs to which this adjustment applies. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - @JsonProperty("percentage_discount") - @ExcludeMissing - fun _percentageDiscount(): JsonField = percentageDiscount - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewPercentageDiscount = apply { - if (validated) { - return@apply - } - - adjustmentType() - appliesToPriceIds() - percentageDiscount() - isInvoiceLevel() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewPercentageDiscount]. */ - class Builder internal constructor() { - - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var percentageDiscount: JsonField? = null - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newPercentageDiscount: NewPercentageDiscount) = apply { - adjustmentType = newPercentageDiscount.adjustmentType - appliesToPriceIds = - newPercentageDiscount.appliesToPriceIds.map { it.toMutableList() } - percentageDiscount = newPercentageDiscount.percentageDiscount - isInvoiceLevel = newPercentageDiscount.isInvoiceLevel - additionalProperties = - newPercentageDiscount.additionalProperties.toMutableMap() - } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The set of price IDs to which this adjustment applies. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - fun percentageDiscount(percentageDiscount: Double) = - percentageDiscount(JsonField.of(percentageDiscount)) - - fun percentageDiscount(percentageDiscount: JsonField) = apply { - this.percentageDiscount = percentageDiscount - } - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): NewPercentageDiscount = - NewPercentageDiscount( - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("percentageDiscount", percentageDiscount), - isInvoiceLevel, - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val PERCENTAGE_DISCOUNT = of("percentage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewPercentageDiscount && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && percentageDiscount == other.percentageDiscount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustmentType, appliesToPriceIds, percentageDiscount, isInvoiceLevel, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewPercentageDiscount{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, percentageDiscount=$percentageDiscount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewUsageDiscount - @JsonCreator - private constructor( - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("usage_discount") - @ExcludeMissing - private val usageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(): Optional = - Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The set of price IDs to which this adjustment applies. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - @JsonProperty("usage_discount") - @ExcludeMissing - fun _usageDiscount(): JsonField = usageDiscount - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewUsageDiscount = apply { - if (validated) { - return@apply - } - - adjustmentType() - appliesToPriceIds() - usageDiscount() - isInvoiceLevel() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewUsageDiscount]. */ - class Builder internal constructor() { - - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var usageDiscount: JsonField? = null - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newUsageDiscount: NewUsageDiscount) = apply { - adjustmentType = newUsageDiscount.adjustmentType - appliesToPriceIds = - newUsageDiscount.appliesToPriceIds.map { it.toMutableList() } - usageDiscount = newUsageDiscount.usageDiscount - isInvoiceLevel = newUsageDiscount.isInvoiceLevel - additionalProperties = newUsageDiscount.additionalProperties.toMutableMap() - } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The set of price IDs to which this adjustment applies. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - fun usageDiscount(usageDiscount: Double) = - usageDiscount(JsonField.of(usageDiscount)) - - fun usageDiscount(usageDiscount: JsonField) = apply { - this.usageDiscount = usageDiscount - } - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): NewUsageDiscount = - NewUsageDiscount( - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("usageDiscount", usageDiscount), - isInvoiceLevel, - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - USAGE_DISCOUNT -> Known.USAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewUsageDiscount && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && usageDiscount == other.usageDiscount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustmentType, appliesToPriceIds, usageDiscount, isInvoiceLevel, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewUsageDiscount{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, usageDiscount=$usageDiscount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewAmountDiscount - @JsonCreator - private constructor( - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("amount_discount") - @ExcludeMissing - private val amountDiscount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(): Optional = - Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - @JsonProperty("amount_discount") - @ExcludeMissing - fun _amountDiscount(): JsonField = amountDiscount - - /** The set of price IDs to which this adjustment applies. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewAmountDiscount = apply { - if (validated) { - return@apply - } - - adjustmentType() - amountDiscount() - appliesToPriceIds() - isInvoiceLevel() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewAmountDiscount]. */ - class Builder internal constructor() { - - private var adjustmentType: JsonField? = null - private var amountDiscount: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newAmountDiscount: NewAmountDiscount) = apply { - adjustmentType = newAmountDiscount.adjustmentType - amountDiscount = newAmountDiscount.amountDiscount - appliesToPriceIds = - newAmountDiscount.appliesToPriceIds.map { it.toMutableList() } - isInvoiceLevel = newAmountDiscount.isInvoiceLevel - additionalProperties = newAmountDiscount.additionalProperties.toMutableMap() - } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - fun amountDiscount(amountDiscount: String) = - amountDiscount(JsonField.of(amountDiscount)) - - fun amountDiscount(amountDiscount: JsonField) = apply { - this.amountDiscount = amountDiscount - } - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The set of price IDs to which this adjustment applies. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): NewAmountDiscount = - NewAmountDiscount( - checkRequired("adjustmentType", adjustmentType), - checkRequired("amountDiscount", amountDiscount), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - isInvoiceLevel, - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewAmountDiscount && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustmentType, amountDiscount, appliesToPriceIds, isInvoiceLevel, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewAmountDiscount{adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewMinimum - @JsonCreator - private constructor( - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(): Optional = - Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The set of price IDs to which this adjustment applies. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The item ID that revenue from this minimum will be attributed to. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewMinimum = apply { - if (validated) { - return@apply - } - - adjustmentType() - appliesToPriceIds() - itemId() - minimumAmount() - isInvoiceLevel() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewMinimum]. */ - class Builder internal constructor() { - - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var itemId: JsonField? = null - private var minimumAmount: JsonField? = null - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newMinimum: NewMinimum) = apply { - adjustmentType = newMinimum.adjustmentType - appliesToPriceIds = newMinimum.appliesToPriceIds.map { it.toMutableList() } - itemId = newMinimum.itemId - minimumAmount = newMinimum.minimumAmount - isInvoiceLevel = newMinimum.isInvoiceLevel - additionalProperties = newMinimum.additionalProperties.toMutableMap() - } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The set of price IDs to which this adjustment applies. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): NewMinimum = - NewMinimum( - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("itemId", itemId), - checkRequired("minimumAmount", minimumAmount), - isInvoiceLevel, - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewMinimum && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && itemId == other.itemId && minimumAmount == other.minimumAmount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustmentType, appliesToPriceIds, itemId, minimumAmount, isInvoiceLevel, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewMinimum{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, itemId=$itemId, minimumAmount=$minimumAmount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewMaximum - @JsonCreator - private constructor( - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(): Optional = - Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The set of price IDs to which this adjustment applies. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewMaximum = apply { - if (validated) { - return@apply - } - - adjustmentType() - appliesToPriceIds() - maximumAmount() - isInvoiceLevel() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewMaximum]. */ - class Builder internal constructor() { - - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newMaximum: NewMaximum) = apply { - adjustmentType = newMaximum.adjustmentType - appliesToPriceIds = newMaximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = newMaximum.maximumAmount - isInvoiceLevel = newMaximum.isInvoiceLevel - additionalProperties = newMaximum.additionalProperties.toMutableMap() - } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The set of price IDs to which this adjustment applies. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): NewMaximum = - NewMaximum( - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("maximumAmount", maximumAmount), - isInvoiceLevel, - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewMaximum && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustmentType, appliesToPriceIds, maximumAmount, isInvoiceLevel, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewMaximum{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ReplaceAdjustment && adjustment == other.adjustment && replacesAdjustmentId == other.replacesAdjustmentId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class ReplacePrice - @JsonCreator - private constructor( - @JsonProperty("replaces_price_id") - @ExcludeMissing - private val replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("allocation_price") - @ExcludeMissing - private val allocationPrice: JsonField = JsonMissing.of(), - @JsonProperty("discounts") - @ExcludeMissing - private val discounts: JsonField> = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("price") - @ExcludeMissing - private val price: JsonField = JsonMissing.of(), - @JsonProperty("price_id") - @ExcludeMissing - private val priceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The id of the price on the plan to replace in the subscription. */ - fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") - - /** The definition of a new allocation price to create and add to the subscription. */ - fun allocationPrice(): Optional = - Optional.ofNullable(allocationPrice.getNullable("allocation_price")) - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - */ - @Deprecated("deprecated") - fun discounts(): Optional> = - Optional.ofNullable(discounts.getNullable("discounts")) - - /** The external price id of the price to add to the subscription. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** The new quantity of the price, if the price is a fixed price. */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun maximumAmount(): Optional = - Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun minimumAmount(): Optional = - Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) - - /** The definition of a new price to create and add to the subscription. */ - fun price(): Optional = Optional.ofNullable(price.getNullable("price")) - - /** The id of the price to add to the subscription. */ - fun priceId(): Optional = Optional.ofNullable(priceId.getNullable("price_id")) - - /** The id of the price on the plan to replace in the subscription. */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId - - /** The definition of a new allocation price to create and add to the subscription. */ - @JsonProperty("allocation_price") - @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - */ - @Deprecated("deprecated") - @JsonProperty("discounts") - @ExcludeMissing - fun _discounts(): JsonField> = discounts - - /** The external price id of the price to add to the subscription. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** The new quantity of the price, if the price is a fixed price. */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. - */ - @Deprecated("deprecated") - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - */ - @Deprecated("deprecated") - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** The definition of a new price to create and add to the subscription. */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - - /** The id of the price to add to the subscription. */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): ReplacePrice = apply { - if (validated) { - return@apply - } - - replacesPriceId() - allocationPrice().ifPresent { it.validate() } - discounts().ifPresent { it.forEach { it.validate() } } - externalPriceId() - fixedPriceQuantity() - maximumAmount() - minimumAmount() - price().ifPresent { it.validate() } - priceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ReplacePrice]. */ - class Builder internal constructor() { - - private var replacesPriceId: JsonField? = null - private var allocationPrice: JsonField = JsonMissing.of() - private var discounts: JsonField>? = null - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - discounts = replacePrice.discounts.map { it.toMutableList() } - externalPriceId = replacePrice.externalPriceId - fixedPriceQuantity = replacePrice.fixedPriceQuantity - maximumAmount = replacePrice.maximumAmount - minimumAmount = replacePrice.minimumAmount - price = replacePrice.price - priceId = replacePrice.priceId - additionalProperties = replacePrice.additionalProperties.toMutableMap() - } - - /** The id of the price on the plan to replace in the subscription. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) - - /** The id of the price on the plan to replace in the subscription. */ - 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: AllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) - - /** The definition of a new allocation price to create and add to the subscription. */ - fun allocationPrice(allocationPrice: Optional) = - allocationPrice(allocationPrice.orElse(null)) - - /** The definition of a new allocation price to create and add to the subscription. */ - 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)) - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - */ - @Deprecated("deprecated") - fun discounts(discounts: Optional>) = discounts(discounts.orElse(null)) - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - */ - @Deprecated("deprecated") - fun discounts(discounts: JsonField>) = apply { - this.discounts = discounts.map { it.toMutableList() } - } - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - */ - @Deprecated("deprecated") - fun addDiscount(discount: Discount) = apply { - discounts = - (discounts ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(discount) - } - } - - /** The external price id of the price to add to the subscription. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** The external price id of the price to add to the subscription. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** The external price id of the price to add to the subscription. */ - 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)) - - /** The new quantity of the price, if the price is a fixed price. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** The new quantity of the price, if the price is a fixed price. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** The new quantity of the price, if the price is a fixed price. */ - 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)) - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.orElse(null)) - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: Optional) = - minimumAmount(minimumAmount.orElse(null)) - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** The definition of a new price to create and add to the subscription. */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(price: Optional) = price(price.orElse(null)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(price: JsonField) = apply { this.price = price } - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionUnit: Price.NewSubscriptionUnitPrice) = - price(Price.ofNewSubscriptionUnit(newSubscriptionUnit)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionPackage: Price.NewSubscriptionPackagePrice) = - price(Price.ofNewSubscriptionPackage(newSubscriptionPackage)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionMatrix: Price.NewSubscriptionMatrixPrice) = - price(Price.ofNewSubscriptionMatrix(newSubscriptionMatrix)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionTiered: Price.NewSubscriptionTieredPrice) = - price(Price.ofNewSubscriptionTiered(newSubscriptionTiered)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionTieredBps: Price.NewSubscriptionTieredBpsPrice) = - price(Price.ofNewSubscriptionTieredBps(newSubscriptionTieredBps)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionBps: Price.NewSubscriptionBpsPrice) = - price(Price.ofNewSubscriptionBps(newSubscriptionBps)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionBulkBps: Price.NewSubscriptionBulkBpsPrice) = - price(Price.ofNewSubscriptionBulkBps(newSubscriptionBulkBps)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionBulk: Price.NewSubscriptionBulkPrice) = - price(Price.ofNewSubscriptionBulk(newSubscriptionBulk)) - - /** The definition of a new price to create and add to the subscription. */ - fun price( - newSubscriptionThresholdTotalAmount: Price.NewSubscriptionThresholdTotalAmountPrice - ) = - price( - Price.ofNewSubscriptionThresholdTotalAmount(newSubscriptionThresholdTotalAmount) - ) - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionTieredPackage: Price.NewSubscriptionTieredPackagePrice) = - price(Price.ofNewSubscriptionTieredPackage(newSubscriptionTieredPackage)) - - /** The definition of a new price to create and add to the subscription. */ - fun price( - newSubscriptionTieredWithMinimum: Price.NewSubscriptionTieredWithMinimumPrice - ) = price(Price.ofNewSubscriptionTieredWithMinimum(newSubscriptionTieredWithMinimum)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionUnitWithPercent: Price.NewSubscriptionUnitWithPercentPrice) = - price(Price.ofNewSubscriptionUnitWithPercent(newSubscriptionUnitWithPercent)) - - /** The definition of a new price to create and add to the subscription. */ - fun price( - newSubscriptionPackageWithAllocation: - Price.NewSubscriptionPackageWithAllocationPrice - ) = - price( - Price.ofNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation - ) - ) - - /** The definition of a new price to create and add to the subscription. */ - fun price( - newSubscriptionTierWithProration: Price.NewSubscriptionTierWithProrationPrice - ) = price(Price.ofNewSubscriptionTierWithProration(newSubscriptionTierWithProration)) - - /** The definition of a new price to create and add to the subscription. */ - fun price( - newSubscriptionUnitWithProration: Price.NewSubscriptionUnitWithProrationPrice - ) = price(Price.ofNewSubscriptionUnitWithProration(newSubscriptionUnitWithProration)) - - /** The definition of a new price to create and add to the subscription. */ - fun price( - newSubscriptionGroupedAllocation: Price.NewSubscriptionGroupedAllocationPrice - ) = price(Price.ofNewSubscriptionGroupedAllocation(newSubscriptionGroupedAllocation)) - - /** The definition of a new price to create and add to the subscription. */ - fun price( - newSubscriptionGroupedWithProratedMinimum: - Price.NewSubscriptionGroupedWithProratedMinimumPrice - ) = - price( - Price.ofNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum - ) - ) - - /** The definition of a new price to create and add to the subscription. */ - fun price( - newSubscriptionBulkWithProration: Price.NewSubscriptionBulkWithProrationPrice - ) = price(Price.ofNewSubscriptionBulkWithProration(newSubscriptionBulkWithProration)) - - /** The id of the price to add to the subscription. */ - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) - - /** The id of the price to add to the subscription. */ - fun priceId(priceId: Optional) = priceId(priceId.orElse(null)) - - /** The id of the price to add to the subscription. */ - 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) - } - - fun build(): ReplacePrice = - ReplacePrice( - checkRequired("replacesPriceId", replacesPriceId), - allocationPrice, - (discounts ?: JsonMissing.of()).map { it.toImmutable() }, - externalPriceId, - fixedPriceQuantity, - maximumAmount, - minimumAmount, - price, - priceId, - additionalProperties.toImmutable(), - ) - } - - /** The definition of a new allocation price to create and add to the subscription. */ - @NoAutoDetect - class AllocationPrice - @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("expires_at_end_of_cadence") - @ExcludeMissing - private val expiresAtEndOfCadence: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** An amount of the currency to allocate to the customer at the specified cadence. */ - fun amount(): String = amount.getRequired("amount") - - /** The cadence at which to allocate the amount to the customer. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** - * An ISO 4217 currency string or a custom pricing unit identifier in which to bill this - * price. - */ - fun currency(): String = currency.getRequired("currency") - - /** - * Whether the allocated amount should expire at the end of the cadence or roll over to - * the next period. - */ - fun expiresAtEndOfCadence(): Boolean = - expiresAtEndOfCadence.getRequired("expires_at_end_of_cadence") - - /** An amount of the currency to allocate to the customer at the specified cadence. */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** The cadence at which to allocate the amount to the customer. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** - * An ISO 4217 currency string or a custom pricing unit identifier in which to bill this - * price. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** - * Whether the allocated amount should expire at the end of the cadence or roll over to - * the next period. - */ - @JsonProperty("expires_at_end_of_cadence") - @ExcludeMissing - fun _expiresAtEndOfCadence(): JsonField = expiresAtEndOfCadence - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AllocationPrice = apply { - if (validated) { - return@apply - } - - amount() - cadence() - currency() - expiresAtEndOfCadence() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AllocationPrice]. */ - class Builder internal constructor() { - - private var amount: JsonField? = null - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var expiresAtEndOfCadence: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(allocationPrice: AllocationPrice) = apply { - amount = allocationPrice.amount - cadence = allocationPrice.cadence - currency = allocationPrice.currency - expiresAtEndOfCadence = allocationPrice.expiresAtEndOfCadence - additionalProperties = allocationPrice.additionalProperties.toMutableMap() - } - - /** - * An amount of the currency to allocate to the customer at the specified cadence. - */ - fun amount(amount: String) = amount(JsonField.of(amount)) - - /** - * An amount of the currency to allocate to the customer at the specified cadence. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** The cadence at which to allocate the amount to the customer. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence at which to allocate the amount to the customer. */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - /** - * An ISO 4217 currency string or a custom pricing unit identifier in which to bill - * this price. - */ - fun currency(currency: String) = currency(JsonField.of(currency)) - - /** - * An ISO 4217 currency string or a custom pricing unit identifier in which to bill - * this price. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** - * Whether the allocated amount should expire at the end of the cadence or roll over - * to the next period. - */ - fun expiresAtEndOfCadence(expiresAtEndOfCadence: Boolean) = - expiresAtEndOfCadence(JsonField.of(expiresAtEndOfCadence)) - - /** - * Whether the allocated amount should expire at the end of the cadence or roll over - * to the next period. - */ - fun expiresAtEndOfCadence(expiresAtEndOfCadence: JsonField) = apply { - this.expiresAtEndOfCadence = expiresAtEndOfCadence - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): AllocationPrice = - AllocationPrice( - checkRequired("amount", amount), - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("expiresAtEndOfCadence", expiresAtEndOfCadence), - additionalProperties.toImmutable(), - ) - } - - /** The cadence at which to allocate the amount to the customer. */ - 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AllocationPrice && amount == other.amount && cadence == other.cadence && currency == other.currency && expiresAtEndOfCadence == other.expiresAtEndOfCadence && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, cadence, currency, expiresAtEndOfCadence, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AllocationPrice{amount=$amount, cadence=$cadence, currency=$currency, expiresAtEndOfCadence=$expiresAtEndOfCadence, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Discount - @JsonCreator - private constructor( - @JsonProperty("discount_type") - @ExcludeMissing - private val discountType: JsonField = JsonMissing.of(), - @JsonProperty("amount_discount") - @ExcludeMissing - private val amountDiscount: JsonField = JsonMissing.of(), - @JsonProperty("percentage_discount") - @ExcludeMissing - private val percentageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("usage_discount") - @ExcludeMissing - private val usageDiscount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun discountType(): DiscountType = discountType.getRequired("discount_type") - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(): Optional = - Optional.ofNullable(amountDiscount.getNullable("amount_discount")) - - /** - * Only available if discount_type is `percentage`. This is a number between 0 and 1. - */ - fun percentageDiscount(): Optional = - Optional.ofNullable(percentageDiscount.getNullable("percentage_discount")) - - /** - * Only available if discount_type is `usage`. Number of usage units that this discount - * is for - */ - fun usageDiscount(): Optional = - Optional.ofNullable(usageDiscount.getNullable("usage_discount")) - - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - - /** Only available if discount_type is `amount`. */ - @JsonProperty("amount_discount") - @ExcludeMissing - fun _amountDiscount(): JsonField = amountDiscount - - /** - * Only available if discount_type is `percentage`. This is a number between 0 and 1. - */ - @JsonProperty("percentage_discount") - @ExcludeMissing - fun _percentageDiscount(): JsonField = percentageDiscount - - /** - * Only available if discount_type is `usage`. Number of usage units that this discount - * is for - */ - @JsonProperty("usage_discount") - @ExcludeMissing - fun _usageDiscount(): JsonField = usageDiscount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Discount = apply { - if (validated) { - return@apply - } - - discountType() - amountDiscount() - percentageDiscount() - usageDiscount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Discount]. */ - class Builder internal constructor() { - - private var discountType: JsonField? = null - private var amountDiscount: JsonField = JsonMissing.of() - private var percentageDiscount: JsonField = JsonMissing.of() - private var usageDiscount: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(discount: Discount) = apply { - discountType = discount.discountType - amountDiscount = discount.amountDiscount - percentageDiscount = discount.percentageDiscount - usageDiscount = discount.usageDiscount - additionalProperties = discount.additionalProperties.toMutableMap() - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(amountDiscount: String?) = - amountDiscount(JsonField.ofNullable(amountDiscount)) - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(amountDiscount: Optional) = - amountDiscount(amountDiscount.orElse(null)) - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(amountDiscount: JsonField) = apply { - this.amountDiscount = amountDiscount - } - - /** - * Only available if discount_type is `percentage`. This is a number between 0 - * and 1. - */ - fun percentageDiscount(percentageDiscount: Double?) = - percentageDiscount(JsonField.ofNullable(percentageDiscount)) - - /** - * Only available if discount_type is `percentage`. This is a number between 0 - * and 1. - */ - fun percentageDiscount(percentageDiscount: Double) = - percentageDiscount(percentageDiscount as Double?) - - /** - * Only available if discount_type is `percentage`. This is a number between 0 - * and 1. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun percentageDiscount(percentageDiscount: Optional) = - percentageDiscount(percentageDiscount.orElse(null) as Double?) - - /** - * Only available if discount_type is `percentage`. This is a number between 0 - * and 1. - */ - fun percentageDiscount(percentageDiscount: JsonField) = apply { - this.percentageDiscount = percentageDiscount - } - - /** - * Only available if discount_type is `usage`. Number of usage units that this - * discount is for - */ - fun usageDiscount(usageDiscount: Double?) = - usageDiscount(JsonField.ofNullable(usageDiscount)) - - /** - * Only available if discount_type is `usage`. Number of usage units that this - * discount is for - */ - fun usageDiscount(usageDiscount: Double) = usageDiscount(usageDiscount as Double?) - - /** - * Only available if discount_type is `usage`. Number of usage units that this - * discount is for - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun usageDiscount(usageDiscount: Optional) = - usageDiscount(usageDiscount.orElse(null) as Double?) - - /** - * Only available if discount_type is `usage`. Number of usage units that this - * discount is for - */ - fun usageDiscount(usageDiscount: JsonField) = apply { - this.usageDiscount = usageDiscount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Discount = - Discount( - checkRequired("discountType", discountType), - amountDiscount, - percentageDiscount, - usageDiscount, - additionalProperties.toImmutable(), - ) - } - - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val PERCENTAGE = of("percentage") - - @JvmField val USAGE = of("usage") - - @JvmField val AMOUNT = of("amount") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - PERCENTAGE, - USAGE, - AMOUNT, - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE, - USAGE, - AMOUNT, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE -> Value.PERCENTAGE - USAGE -> Value.USAGE - AMOUNT -> Value.AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PERCENTAGE -> Known.PERCENTAGE - USAGE -> Known.USAGE - AMOUNT -> Known.AMOUNT - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Discount && discountType == other.discountType && amountDiscount == other.amountDiscount && percentageDiscount == other.percentageDiscount && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(discountType, amountDiscount, percentageDiscount, usageDiscount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Discount{discountType=$discountType, amountDiscount=$amountDiscount, percentageDiscount=$percentageDiscount, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" - } - - /** The definition of a new price to create and add to the subscription. */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price - private constructor( - private val newSubscriptionUnit: NewSubscriptionUnitPrice? = null, - private val newSubscriptionPackage: NewSubscriptionPackagePrice? = null, - private val newSubscriptionMatrix: NewSubscriptionMatrixPrice? = null, - private val newSubscriptionTiered: NewSubscriptionTieredPrice? = null, - private val newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice? = null, - private val newSubscriptionBps: NewSubscriptionBpsPrice? = null, - private val newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice? = null, - private val newSubscriptionBulk: NewSubscriptionBulkPrice? = null, - private val newSubscriptionThresholdTotalAmount: - NewSubscriptionThresholdTotalAmountPrice? = - null, - private val newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice? = null, - private val newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = - null, - private val newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, - private val newSubscriptionPackageWithAllocation: - NewSubscriptionPackageWithAllocationPrice? = - null, - private val newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice? = - null, - private val newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice? = - null, - private val newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice? = - null, - private val newSubscriptionGroupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice? = - null, - private val newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice? = - null, - private val _json: JsonValue? = null, - ) { - - fun newSubscriptionUnit(): Optional = - Optional.ofNullable(newSubscriptionUnit) - - fun newSubscriptionPackage(): Optional = - Optional.ofNullable(newSubscriptionPackage) - - fun newSubscriptionMatrix(): Optional = - Optional.ofNullable(newSubscriptionMatrix) - - fun newSubscriptionTiered(): Optional = - Optional.ofNullable(newSubscriptionTiered) - - fun newSubscriptionTieredBps(): Optional = - Optional.ofNullable(newSubscriptionTieredBps) - - fun newSubscriptionBps(): Optional = - Optional.ofNullable(newSubscriptionBps) - - fun newSubscriptionBulkBps(): Optional = - Optional.ofNullable(newSubscriptionBulkBps) - - fun newSubscriptionBulk(): Optional = - Optional.ofNullable(newSubscriptionBulk) - - fun newSubscriptionThresholdTotalAmount(): - Optional = - Optional.ofNullable(newSubscriptionThresholdTotalAmount) - - fun newSubscriptionTieredPackage(): Optional = - Optional.ofNullable(newSubscriptionTieredPackage) - - fun newSubscriptionTieredWithMinimum(): - Optional = - Optional.ofNullable(newSubscriptionTieredWithMinimum) - - fun newSubscriptionUnitWithPercent(): Optional = - Optional.ofNullable(newSubscriptionUnitWithPercent) - - fun newSubscriptionPackageWithAllocation(): - Optional = - Optional.ofNullable(newSubscriptionPackageWithAllocation) - - fun newSubscriptionTierWithProration(): - Optional = - Optional.ofNullable(newSubscriptionTierWithProration) - - fun newSubscriptionUnitWithProration(): - Optional = - Optional.ofNullable(newSubscriptionUnitWithProration) - - fun newSubscriptionGroupedAllocation(): - Optional = - Optional.ofNullable(newSubscriptionGroupedAllocation) - - fun newSubscriptionGroupedWithProratedMinimum(): - Optional = - Optional.ofNullable(newSubscriptionGroupedWithProratedMinimum) - - fun newSubscriptionBulkWithProration(): - Optional = - Optional.ofNullable(newSubscriptionBulkWithProration) - - fun isNewSubscriptionUnit(): Boolean = newSubscriptionUnit != null - - fun isNewSubscriptionPackage(): Boolean = newSubscriptionPackage != null - - fun isNewSubscriptionMatrix(): Boolean = newSubscriptionMatrix != null - - fun isNewSubscriptionTiered(): Boolean = newSubscriptionTiered != null - - fun isNewSubscriptionTieredBps(): Boolean = newSubscriptionTieredBps != null - - fun isNewSubscriptionBps(): Boolean = newSubscriptionBps != null - - fun isNewSubscriptionBulkBps(): Boolean = newSubscriptionBulkBps != null - - fun isNewSubscriptionBulk(): Boolean = newSubscriptionBulk != null - - fun isNewSubscriptionThresholdTotalAmount(): Boolean = - newSubscriptionThresholdTotalAmount != null - - fun isNewSubscriptionTieredPackage(): Boolean = newSubscriptionTieredPackage != null - - fun isNewSubscriptionTieredWithMinimum(): Boolean = - newSubscriptionTieredWithMinimum != null - - fun isNewSubscriptionUnitWithPercent(): Boolean = newSubscriptionUnitWithPercent != null - - fun isNewSubscriptionPackageWithAllocation(): Boolean = - newSubscriptionPackageWithAllocation != null - - fun isNewSubscriptionTierWithProration(): Boolean = - newSubscriptionTierWithProration != null - - fun isNewSubscriptionUnitWithProration(): Boolean = - newSubscriptionUnitWithProration != null - - fun isNewSubscriptionGroupedAllocation(): Boolean = - newSubscriptionGroupedAllocation != null - - fun isNewSubscriptionGroupedWithProratedMinimum(): Boolean = - newSubscriptionGroupedWithProratedMinimum != null - - fun isNewSubscriptionBulkWithProration(): Boolean = - newSubscriptionBulkWithProration != null - - fun asNewSubscriptionUnit(): NewSubscriptionUnitPrice = - newSubscriptionUnit.getOrThrow("newSubscriptionUnit") - - fun asNewSubscriptionPackage(): NewSubscriptionPackagePrice = - newSubscriptionPackage.getOrThrow("newSubscriptionPackage") - - fun asNewSubscriptionMatrix(): NewSubscriptionMatrixPrice = - newSubscriptionMatrix.getOrThrow("newSubscriptionMatrix") - - fun asNewSubscriptionTiered(): NewSubscriptionTieredPrice = - newSubscriptionTiered.getOrThrow("newSubscriptionTiered") - - fun asNewSubscriptionTieredBps(): NewSubscriptionTieredBpsPrice = - newSubscriptionTieredBps.getOrThrow("newSubscriptionTieredBps") - - fun asNewSubscriptionBps(): NewSubscriptionBpsPrice = - newSubscriptionBps.getOrThrow("newSubscriptionBps") - - fun asNewSubscriptionBulkBps(): NewSubscriptionBulkBpsPrice = - newSubscriptionBulkBps.getOrThrow("newSubscriptionBulkBps") - - fun asNewSubscriptionBulk(): NewSubscriptionBulkPrice = - newSubscriptionBulk.getOrThrow("newSubscriptionBulk") - - fun asNewSubscriptionThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = - newSubscriptionThresholdTotalAmount.getOrThrow( - "newSubscriptionThresholdTotalAmount" - ) - - fun asNewSubscriptionTieredPackage(): NewSubscriptionTieredPackagePrice = - newSubscriptionTieredPackage.getOrThrow("newSubscriptionTieredPackage") - - fun asNewSubscriptionTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = - newSubscriptionTieredWithMinimum.getOrThrow("newSubscriptionTieredWithMinimum") - - fun asNewSubscriptionUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = - newSubscriptionUnitWithPercent.getOrThrow("newSubscriptionUnitWithPercent") - - fun asNewSubscriptionPackageWithAllocation(): - NewSubscriptionPackageWithAllocationPrice = - newSubscriptionPackageWithAllocation.getOrThrow( - "newSubscriptionPackageWithAllocation" - ) - - fun asNewSubscriptionTierWithProration(): NewSubscriptionTierWithProrationPrice = - newSubscriptionTierWithProration.getOrThrow("newSubscriptionTierWithProration") - - fun asNewSubscriptionUnitWithProration(): NewSubscriptionUnitWithProrationPrice = - newSubscriptionUnitWithProration.getOrThrow("newSubscriptionUnitWithProration") - - fun asNewSubscriptionGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = - newSubscriptionGroupedAllocation.getOrThrow("newSubscriptionGroupedAllocation") - - fun asNewSubscriptionGroupedWithProratedMinimum(): - NewSubscriptionGroupedWithProratedMinimumPrice = - newSubscriptionGroupedWithProratedMinimum.getOrThrow( - "newSubscriptionGroupedWithProratedMinimum" - ) - - fun asNewSubscriptionBulkWithProration(): NewSubscriptionBulkWithProrationPrice = - newSubscriptionBulkWithProration.getOrThrow("newSubscriptionBulkWithProration") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - newSubscriptionUnit != null -> - visitor.visitNewSubscriptionUnit(newSubscriptionUnit) - newSubscriptionPackage != null -> - visitor.visitNewSubscriptionPackage(newSubscriptionPackage) - newSubscriptionMatrix != null -> - visitor.visitNewSubscriptionMatrix(newSubscriptionMatrix) - newSubscriptionTiered != null -> - visitor.visitNewSubscriptionTiered(newSubscriptionTiered) - newSubscriptionTieredBps != null -> - visitor.visitNewSubscriptionTieredBps(newSubscriptionTieredBps) - newSubscriptionBps != null -> - visitor.visitNewSubscriptionBps(newSubscriptionBps) - newSubscriptionBulkBps != null -> - visitor.visitNewSubscriptionBulkBps(newSubscriptionBulkBps) - newSubscriptionBulk != null -> - visitor.visitNewSubscriptionBulk(newSubscriptionBulk) - newSubscriptionThresholdTotalAmount != null -> - visitor.visitNewSubscriptionThresholdTotalAmount( - newSubscriptionThresholdTotalAmount - ) - newSubscriptionTieredPackage != null -> - visitor.visitNewSubscriptionTieredPackage(newSubscriptionTieredPackage) - newSubscriptionTieredWithMinimum != null -> - visitor.visitNewSubscriptionTieredWithMinimum( - newSubscriptionTieredWithMinimum - ) - newSubscriptionUnitWithPercent != null -> - visitor.visitNewSubscriptionUnitWithPercent(newSubscriptionUnitWithPercent) - newSubscriptionPackageWithAllocation != null -> - visitor.visitNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation - ) - newSubscriptionTierWithProration != null -> - visitor.visitNewSubscriptionTierWithProration( - newSubscriptionTierWithProration - ) - newSubscriptionUnitWithProration != null -> - visitor.visitNewSubscriptionUnitWithProration( - newSubscriptionUnitWithProration - ) - newSubscriptionGroupedAllocation != null -> - visitor.visitNewSubscriptionGroupedAllocation( - newSubscriptionGroupedAllocation - ) - newSubscriptionGroupedWithProratedMinimum != null -> - visitor.visitNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum - ) - newSubscriptionBulkWithProration != null -> - visitor.visitNewSubscriptionBulkWithProration( - newSubscriptionBulkWithProration - ) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): Price = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitNewSubscriptionUnit( - newSubscriptionUnit: NewSubscriptionUnitPrice - ) { - newSubscriptionUnit.validate() - } - - override fun visitNewSubscriptionPackage( - newSubscriptionPackage: NewSubscriptionPackagePrice - ) { - newSubscriptionPackage.validate() - } - - override fun visitNewSubscriptionMatrix( - newSubscriptionMatrix: NewSubscriptionMatrixPrice - ) { - newSubscriptionMatrix.validate() - } - - override fun visitNewSubscriptionTiered( - newSubscriptionTiered: NewSubscriptionTieredPrice - ) { - newSubscriptionTiered.validate() - } - - override fun visitNewSubscriptionTieredBps( - newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice - ) { - newSubscriptionTieredBps.validate() - } - - override fun visitNewSubscriptionBps( - newSubscriptionBps: NewSubscriptionBpsPrice - ) { - newSubscriptionBps.validate() - } - - override fun visitNewSubscriptionBulkBps( - newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice - ) { - newSubscriptionBulkBps.validate() - } - - override fun visitNewSubscriptionBulk( - newSubscriptionBulk: NewSubscriptionBulkPrice - ) { - newSubscriptionBulk.validate() - } - - override fun visitNewSubscriptionThresholdTotalAmount( - newSubscriptionThresholdTotalAmount: - NewSubscriptionThresholdTotalAmountPrice - ) { - newSubscriptionThresholdTotalAmount.validate() - } - - override fun visitNewSubscriptionTieredPackage( - newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice - ) { - newSubscriptionTieredPackage.validate() - } - - override fun visitNewSubscriptionTieredWithMinimum( - newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) { - newSubscriptionTieredWithMinimum.validate() - } - - override fun visitNewSubscriptionUnitWithPercent( - newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice - ) { - newSubscriptionUnitWithPercent.validate() - } - - override fun visitNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation: - NewSubscriptionPackageWithAllocationPrice - ) { - newSubscriptionPackageWithAllocation.validate() - } - - override fun visitNewSubscriptionTierWithProration( - newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice - ) { - newSubscriptionTierWithProration.validate() - } - - override fun visitNewSubscriptionUnitWithProration( - newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice - ) { - newSubscriptionUnitWithProration.validate() - } - - override fun visitNewSubscriptionGroupedAllocation( - newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice - ) { - newSubscriptionGroupedAllocation.validate() - } - - override fun visitNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) { - newSubscriptionGroupedWithProratedMinimum.validate() - } - - override fun visitNewSubscriptionBulkWithProration( - newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice - ) { - newSubscriptionBulkWithProration.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Price && newSubscriptionUnit == other.newSubscriptionUnit && newSubscriptionPackage == other.newSubscriptionPackage && newSubscriptionMatrix == other.newSubscriptionMatrix && newSubscriptionTiered == other.newSubscriptionTiered && newSubscriptionTieredBps == other.newSubscriptionTieredBps && newSubscriptionBps == other.newSubscriptionBps && newSubscriptionBulkBps == other.newSubscriptionBulkBps && newSubscriptionBulk == other.newSubscriptionBulk && newSubscriptionThresholdTotalAmount == other.newSubscriptionThresholdTotalAmount && newSubscriptionTieredPackage == other.newSubscriptionTieredPackage && newSubscriptionTieredWithMinimum == other.newSubscriptionTieredWithMinimum && newSubscriptionUnitWithPercent == other.newSubscriptionUnitWithPercent && newSubscriptionPackageWithAllocation == other.newSubscriptionPackageWithAllocation && newSubscriptionTierWithProration == other.newSubscriptionTierWithProration && newSubscriptionUnitWithProration == other.newSubscriptionUnitWithProration && newSubscriptionGroupedAllocation == other.newSubscriptionGroupedAllocation && newSubscriptionGroupedWithProratedMinimum == other.newSubscriptionGroupedWithProratedMinimum && newSubscriptionBulkWithProration == other.newSubscriptionBulkWithProration /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(newSubscriptionUnit, newSubscriptionPackage, newSubscriptionMatrix, newSubscriptionTiered, newSubscriptionTieredBps, newSubscriptionBps, newSubscriptionBulkBps, newSubscriptionBulk, newSubscriptionThresholdTotalAmount, newSubscriptionTieredPackage, newSubscriptionTieredWithMinimum, newSubscriptionUnitWithPercent, newSubscriptionPackageWithAllocation, newSubscriptionTierWithProration, newSubscriptionUnitWithProration, newSubscriptionGroupedAllocation, newSubscriptionGroupedWithProratedMinimum, newSubscriptionBulkWithProration) /* spotless:on */ - - override fun toString(): String = - when { - newSubscriptionUnit != null -> "Price{newSubscriptionUnit=$newSubscriptionUnit}" - newSubscriptionPackage != null -> - "Price{newSubscriptionPackage=$newSubscriptionPackage}" - newSubscriptionMatrix != null -> - "Price{newSubscriptionMatrix=$newSubscriptionMatrix}" - newSubscriptionTiered != null -> - "Price{newSubscriptionTiered=$newSubscriptionTiered}" - newSubscriptionTieredBps != null -> - "Price{newSubscriptionTieredBps=$newSubscriptionTieredBps}" - newSubscriptionBps != null -> "Price{newSubscriptionBps=$newSubscriptionBps}" - newSubscriptionBulkBps != null -> - "Price{newSubscriptionBulkBps=$newSubscriptionBulkBps}" - newSubscriptionBulk != null -> "Price{newSubscriptionBulk=$newSubscriptionBulk}" - newSubscriptionThresholdTotalAmount != null -> - "Price{newSubscriptionThresholdTotalAmount=$newSubscriptionThresholdTotalAmount}" - newSubscriptionTieredPackage != null -> - "Price{newSubscriptionTieredPackage=$newSubscriptionTieredPackage}" - newSubscriptionTieredWithMinimum != null -> - "Price{newSubscriptionTieredWithMinimum=$newSubscriptionTieredWithMinimum}" - newSubscriptionUnitWithPercent != null -> - "Price{newSubscriptionUnitWithPercent=$newSubscriptionUnitWithPercent}" - newSubscriptionPackageWithAllocation != null -> - "Price{newSubscriptionPackageWithAllocation=$newSubscriptionPackageWithAllocation}" - newSubscriptionTierWithProration != null -> - "Price{newSubscriptionTierWithProration=$newSubscriptionTierWithProration}" - newSubscriptionUnitWithProration != null -> - "Price{newSubscriptionUnitWithProration=$newSubscriptionUnitWithProration}" - newSubscriptionGroupedAllocation != null -> - "Price{newSubscriptionGroupedAllocation=$newSubscriptionGroupedAllocation}" - newSubscriptionGroupedWithProratedMinimum != null -> - "Price{newSubscriptionGroupedWithProratedMinimum=$newSubscriptionGroupedWithProratedMinimum}" - newSubscriptionBulkWithProration != null -> - "Price{newSubscriptionBulkWithProration=$newSubscriptionBulkWithProration}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") - } - - companion object { - - @JvmStatic - fun ofNewSubscriptionUnit(newSubscriptionUnit: NewSubscriptionUnitPrice) = - Price(newSubscriptionUnit = newSubscriptionUnit) - - @JvmStatic - fun ofNewSubscriptionPackage(newSubscriptionPackage: NewSubscriptionPackagePrice) = - Price(newSubscriptionPackage = newSubscriptionPackage) - - @JvmStatic - fun ofNewSubscriptionMatrix(newSubscriptionMatrix: NewSubscriptionMatrixPrice) = - Price(newSubscriptionMatrix = newSubscriptionMatrix) - - @JvmStatic - fun ofNewSubscriptionTiered(newSubscriptionTiered: NewSubscriptionTieredPrice) = - Price(newSubscriptionTiered = newSubscriptionTiered) - - @JvmStatic - fun ofNewSubscriptionTieredBps( - newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice - ) = Price(newSubscriptionTieredBps = newSubscriptionTieredBps) - - @JvmStatic - fun ofNewSubscriptionBps(newSubscriptionBps: NewSubscriptionBpsPrice) = - Price(newSubscriptionBps = newSubscriptionBps) - - @JvmStatic - fun ofNewSubscriptionBulkBps(newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice) = - Price(newSubscriptionBulkBps = newSubscriptionBulkBps) - - @JvmStatic - fun ofNewSubscriptionBulk(newSubscriptionBulk: NewSubscriptionBulkPrice) = - Price(newSubscriptionBulk = newSubscriptionBulk) - - @JvmStatic - fun ofNewSubscriptionThresholdTotalAmount( - newSubscriptionThresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = Price(newSubscriptionThresholdTotalAmount = newSubscriptionThresholdTotalAmount) - - @JvmStatic - fun ofNewSubscriptionTieredPackage( - newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice - ) = Price(newSubscriptionTieredPackage = newSubscriptionTieredPackage) - - @JvmStatic - fun ofNewSubscriptionTieredWithMinimum( - newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) = Price(newSubscriptionTieredWithMinimum = newSubscriptionTieredWithMinimum) - - @JvmStatic - fun ofNewSubscriptionUnitWithPercent( - newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice - ) = Price(newSubscriptionUnitWithPercent = newSubscriptionUnitWithPercent) - - @JvmStatic - fun ofNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = - Price( - newSubscriptionPackageWithAllocation = newSubscriptionPackageWithAllocation - ) - - @JvmStatic - fun ofNewSubscriptionTierWithProration( - newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice - ) = Price(newSubscriptionTierWithProration = newSubscriptionTierWithProration) - - @JvmStatic - fun ofNewSubscriptionUnitWithProration( - newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice - ) = Price(newSubscriptionUnitWithProration = newSubscriptionUnitWithProration) - - @JvmStatic - fun ofNewSubscriptionGroupedAllocation( - newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice - ) = Price(newSubscriptionGroupedAllocation = newSubscriptionGroupedAllocation) - - @JvmStatic - fun ofNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) = - Price( - newSubscriptionGroupedWithProratedMinimum = - newSubscriptionGroupedWithProratedMinimum - ) - - @JvmStatic - fun ofNewSubscriptionBulkWithProration( - newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice - ) = Price(newSubscriptionBulkWithProration = newSubscriptionBulkWithProration) - } - - /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. - */ - interface Visitor { - - fun visitNewSubscriptionUnit(newSubscriptionUnit: NewSubscriptionUnitPrice): T - - fun visitNewSubscriptionPackage( - newSubscriptionPackage: NewSubscriptionPackagePrice - ): T - - fun visitNewSubscriptionMatrix(newSubscriptionMatrix: NewSubscriptionMatrixPrice): T - - fun visitNewSubscriptionTiered(newSubscriptionTiered: NewSubscriptionTieredPrice): T - - fun visitNewSubscriptionTieredBps( - newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice - ): T - - fun visitNewSubscriptionBps(newSubscriptionBps: NewSubscriptionBpsPrice): T - - fun visitNewSubscriptionBulkBps( - newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice - ): T - - fun visitNewSubscriptionBulk(newSubscriptionBulk: NewSubscriptionBulkPrice): T - - fun visitNewSubscriptionThresholdTotalAmount( - newSubscriptionThresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ): T - - fun visitNewSubscriptionTieredPackage( - newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice - ): T - - fun visitNewSubscriptionTieredWithMinimum( - newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ): T - - fun visitNewSubscriptionUnitWithPercent( - newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice - ): T - - fun visitNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ): T - - fun visitNewSubscriptionTierWithProration( - newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice - ): T - - fun visitNewSubscriptionUnitWithProration( - newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice - ): T - - fun visitNewSubscriptionGroupedAllocation( - newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice - ): T - - fun visitNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ): T - - fun visitNewSubscriptionBulkWithProration( - newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice - ): 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" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionUnit = it, _json = json) - } - } - "package" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionPackage = it, _json = json) - } - } - "matrix" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionMatrix = it, _json = json) - } - } - "tiered" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionTiered = it, _json = json) - } - } - "tiered_bps" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionTieredBps = it, _json = json) - } - } - "bps" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionBps = it, _json = json) - } - } - "bulk_bps" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionBulkBps = it, _json = json) - } - } - "bulk" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionBulk = it, _json = json) - } - } - "threshold_total_amount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionThresholdTotalAmount = it, - _json = json, - ) - } - } - "tiered_package" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price(newSubscriptionTieredPackage = it, _json = json) - } - } - "tiered_with_minimum" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionTieredWithMinimum = it, - _json = json, - ) - } - } - "unit_with_percent" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price(newSubscriptionUnitWithPercent = it, _json = json) - } - } - "package_with_allocation" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionPackageWithAllocation = it, - _json = json, - ) - } - } - "tiered_with_proration" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionTierWithProration = it, - _json = json, - ) - } - } - "unit_with_proration" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionUnitWithProration = it, - _json = json, - ) - } - } - "grouped_allocation" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionGroupedAllocation = it, - _json = json, - ) - } - } - "grouped_with_prorated_minimum" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionGroupedWithProratedMinimum = it, - _json = json, - ) - } - } - "bulk_with_proration" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionBulkWithProration = it, - _json = json, - ) - } - } - } - - return Price(_json = json) - } - } - - internal class Serializer : BaseSerializer(Price::class) { - - override fun serialize( - value: Price, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.newSubscriptionUnit != null -> - generator.writeObject(value.newSubscriptionUnit) - value.newSubscriptionPackage != null -> - generator.writeObject(value.newSubscriptionPackage) - value.newSubscriptionMatrix != null -> - generator.writeObject(value.newSubscriptionMatrix) - value.newSubscriptionTiered != null -> - generator.writeObject(value.newSubscriptionTiered) - value.newSubscriptionTieredBps != null -> - generator.writeObject(value.newSubscriptionTieredBps) - value.newSubscriptionBps != null -> - generator.writeObject(value.newSubscriptionBps) - value.newSubscriptionBulkBps != null -> - generator.writeObject(value.newSubscriptionBulkBps) - value.newSubscriptionBulk != null -> - generator.writeObject(value.newSubscriptionBulk) - value.newSubscriptionThresholdTotalAmount != null -> - generator.writeObject(value.newSubscriptionThresholdTotalAmount) - value.newSubscriptionTieredPackage != null -> - generator.writeObject(value.newSubscriptionTieredPackage) - value.newSubscriptionTieredWithMinimum != null -> - generator.writeObject(value.newSubscriptionTieredWithMinimum) - value.newSubscriptionUnitWithPercent != null -> - generator.writeObject(value.newSubscriptionUnitWithPercent) - value.newSubscriptionPackageWithAllocation != null -> - generator.writeObject(value.newSubscriptionPackageWithAllocation) - value.newSubscriptionTierWithProration != null -> - generator.writeObject(value.newSubscriptionTierWithProration) - value.newSubscriptionUnitWithProration != null -> - generator.writeObject(value.newSubscriptionUnitWithProration) - value.newSubscriptionGroupedAllocation != null -> - generator.writeObject(value.newSubscriptionGroupedAllocation) - value.newSubscriptionGroupedWithProratedMinimum != null -> - generator.writeObject(value.newSubscriptionGroupedWithProratedMinimum) - value.newSubscriptionBulkWithProration != null -> - generator.writeObject(value.newSubscriptionBulkWithProration) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") - } - } - } - - @NoAutoDetect - class NewSubscriptionUnitPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("unit_config") - @ExcludeMissing - private val unitConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun unitConfig(): UnitConfig = unitConfig.getRequired("unit_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("unit_config") - @ExcludeMissing - fun _unitConfig(): JsonField = unitConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionUnitPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - unitConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionUnitPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var 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 currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newSubscriptionUnitPrice: NewSubscriptionUnitPrice) = apply { - cadence = newSubscriptionUnitPrice.cadence - itemId = newSubscriptionUnitPrice.itemId - modelType = newSubscriptionUnitPrice.modelType - name = newSubscriptionUnitPrice.name - unitConfig = newSubscriptionUnitPrice.unitConfig - billableMetricId = newSubscriptionUnitPrice.billableMetricId - billedInAdvance = newSubscriptionUnitPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionUnitPrice.billingCycleConfiguration - conversionRate = newSubscriptionUnitPrice.conversionRate - currency = newSubscriptionUnitPrice.currency - externalPriceId = newSubscriptionUnitPrice.externalPriceId - fixedPriceQuantity = newSubscriptionUnitPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionUnitPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionUnitPrice.invoicingCycleConfiguration - metadata = newSubscriptionUnitPrice.metadata - referenceId = newSubscriptionUnitPrice.referenceId - additionalProperties = - newSubscriptionUnitPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) - - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionUnitPrice = - NewSubscriptionUnitPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("unitConfig", unitConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class UnitConfig - @JsonCreator - private constructor( - @JsonProperty("unit_amount") - @ExcludeMissing - private val unitAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Rate per unit of usage */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** Rate per unit of usage */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): UnitConfig = apply { - if (validated) { - return@apply - } - - unitAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnitConfig]. */ - class Builder internal constructor() { - - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unitConfig: UnitConfig) = apply { - unitAmount = unitConfig.unitAmount - additionalProperties = unitConfig.additionalProperties.toMutableMap() - } - - /** Rate per unit of usage */ - fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - - /** Rate per unit of usage */ - 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 build(): UnitConfig = - UnitConfig( - checkRequired("unitAmount", unitAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UnitConfig && unitAmount == other.unitAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(unitAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnitConfig{unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionUnitPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && unitConfig == other.unitConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, unitConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionUnitPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionPackagePrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("package_config") - @ExcludeMissing - private val packageConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun packageConfig(): PackageConfig = packageConfig.getRequired("package_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("package_config") - @ExcludeMissing - fun _packageConfig(): JsonField = packageConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionPackagePrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - packageConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionPackagePrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var packageConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newSubscriptionPackagePrice: NewSubscriptionPackagePrice) = - apply { - cadence = newSubscriptionPackagePrice.cadence - itemId = newSubscriptionPackagePrice.itemId - modelType = newSubscriptionPackagePrice.modelType - name = newSubscriptionPackagePrice.name - packageConfig = newSubscriptionPackagePrice.packageConfig - billableMetricId = newSubscriptionPackagePrice.billableMetricId - billedInAdvance = newSubscriptionPackagePrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionPackagePrice.billingCycleConfiguration - conversionRate = newSubscriptionPackagePrice.conversionRate - currency = newSubscriptionPackagePrice.currency - externalPriceId = newSubscriptionPackagePrice.externalPriceId - fixedPriceQuantity = newSubscriptionPackagePrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionPackagePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionPackagePrice.invoicingCycleConfiguration - metadata = newSubscriptionPackagePrice.metadata - referenceId = newSubscriptionPackagePrice.referenceId - additionalProperties = - newSubscriptionPackagePrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun packageConfig(packageConfig: PackageConfig) = - packageConfig(JsonField.of(packageConfig)) - - fun packageConfig(packageConfig: JsonField) = apply { - this.packageConfig = packageConfig - } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionPackagePrice = - NewSubscriptionPackagePrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("packageConfig", packageConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val PACKAGE = of("package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - PACKAGE - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PACKAGE, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PACKAGE -> Value.PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PACKAGE -> Known.PACKAGE - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class PackageConfig - @JsonCreator - private constructor( - @JsonProperty("package_amount") - @ExcludeMissing - private val packageAmount: JsonField = JsonMissing.of(), - @JsonProperty("package_size") - @ExcludeMissing - private val packageSize: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** A currency amount to rate usage by */ - fun packageAmount(): String = packageAmount.getRequired("package_amount") - - /** - * An integer amount to represent package size. For example, 1000 here would - * divide usage by 1000 before multiplying by package_amount in rating - */ - fun packageSize(): Long = packageSize.getRequired("package_size") - - /** A currency amount to rate usage by */ - @JsonProperty("package_amount") - @ExcludeMissing - fun _packageAmount(): JsonField = packageAmount - - /** - * An integer amount to represent package size. For example, 1000 here would - * divide usage by 1000 before multiplying by package_amount in rating - */ - @JsonProperty("package_size") - @ExcludeMissing - fun _packageSize(): JsonField = packageSize - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PackageConfig = apply { - if (validated) { - return@apply - } - - packageAmount() - packageSize() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PackageConfig]. */ - class Builder internal constructor() { - - private var packageAmount: JsonField? = null - private var packageSize: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(packageConfig: PackageConfig) = apply { - packageAmount = packageConfig.packageAmount - packageSize = packageConfig.packageSize - additionalProperties = packageConfig.additionalProperties.toMutableMap() - } - - /** A currency amount to rate usage by */ - fun packageAmount(packageAmount: String) = - packageAmount(JsonField.of(packageAmount)) - - /** A currency amount to rate usage by */ - fun packageAmount(packageAmount: JsonField) = apply { - this.packageAmount = packageAmount - } - - /** - * An integer amount to represent package size. For example, 1000 here would - * divide usage by 1000 before multiplying by package_amount in rating - */ - fun packageSize(packageSize: Long) = packageSize(JsonField.of(packageSize)) - - /** - * An integer amount to represent package size. For example, 1000 here would - * divide usage by 1000 before multiplying by package_amount in rating - */ - fun packageSize(packageSize: JsonField) = apply { - this.packageSize = packageSize - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PackageConfig = - PackageConfig( - checkRequired("packageAmount", packageAmount), - checkRequired("packageSize", packageSize), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PackageConfig && packageAmount == other.packageAmount && packageSize == other.packageSize && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(packageAmount, packageSize, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PackageConfig{packageAmount=$packageAmount, packageSize=$packageSize, additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionPackagePrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && packageConfig == other.packageConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, packageConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionMatrixPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("matrix_config") - @ExcludeMissing - private val matrixConfig: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_config") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("matrix_config") - @ExcludeMissing - fun _matrixConfig(): JsonField = matrixConfig - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionMatrixPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - matrixConfig().validate() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionMatrixPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var matrixConfig: JsonField? = null - private var modelType: JsonField? = null - private var 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 currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newSubscriptionMatrixPrice: NewSubscriptionMatrixPrice) = - apply { - cadence = newSubscriptionMatrixPrice.cadence - itemId = newSubscriptionMatrixPrice.itemId - matrixConfig = newSubscriptionMatrixPrice.matrixConfig - modelType = newSubscriptionMatrixPrice.modelType - name = newSubscriptionMatrixPrice.name - billableMetricId = newSubscriptionMatrixPrice.billableMetricId - billedInAdvance = newSubscriptionMatrixPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionMatrixPrice.billingCycleConfiguration - conversionRate = newSubscriptionMatrixPrice.conversionRate - currency = newSubscriptionMatrixPrice.currency - externalPriceId = newSubscriptionMatrixPrice.externalPriceId - fixedPriceQuantity = newSubscriptionMatrixPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionMatrixPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionMatrixPrice.invoicingCycleConfiguration - metadata = newSubscriptionMatrixPrice.metadata - referenceId = newSubscriptionMatrixPrice.referenceId - additionalProperties = - newSubscriptionMatrixPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun matrixConfig(matrixConfig: MatrixConfig) = - matrixConfig(JsonField.of(matrixConfig)) - - fun matrixConfig(matrixConfig: JsonField) = apply { - this.matrixConfig = matrixConfig - } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionMatrixPrice = - NewSubscriptionMatrixPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("matrixConfig", matrixConfig), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class MatrixConfig - @JsonCreator - private constructor( - @JsonProperty("default_unit_amount") - @ExcludeMissing - private val defaultUnitAmount: JsonField = JsonMissing.of(), - @JsonProperty("dimensions") - @ExcludeMissing - private val dimensions: JsonField> = JsonMissing.of(), - @JsonProperty("matrix_values") - @ExcludeMissing - private val matrixValues: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * Default per unit rate for any usage not bucketed into a specified - * matrix_value - */ - fun defaultUnitAmount(): String = - defaultUnitAmount.getRequired("default_unit_amount") - - /** One or two event property values to evaluate matrix groups by */ - fun dimensions(): List = dimensions.getRequired("dimensions") - - /** Matrix values for specified matrix grouping keys */ - fun matrixValues(): List = - matrixValues.getRequired("matrix_values") - - /** - * Default per unit rate for any usage not bucketed into a specified - * matrix_value - */ - @JsonProperty("default_unit_amount") - @ExcludeMissing - fun _defaultUnitAmount(): JsonField = defaultUnitAmount - - /** One or two event property values to evaluate matrix groups by */ - @JsonProperty("dimensions") - @ExcludeMissing - fun _dimensions(): JsonField> = dimensions - - /** Matrix values for specified matrix grouping keys */ - @JsonProperty("matrix_values") - @ExcludeMissing - fun _matrixValues(): JsonField> = matrixValues - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MatrixConfig = apply { - if (validated) { - return@apply - } - - defaultUnitAmount() - dimensions() - matrixValues().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MatrixConfig]. */ - class Builder internal constructor() { - - private var defaultUnitAmount: JsonField? = null - private var dimensions: JsonField>? = null - private var matrixValues: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(matrixConfig: MatrixConfig) = apply { - defaultUnitAmount = matrixConfig.defaultUnitAmount - dimensions = matrixConfig.dimensions.map { it.toMutableList() } - matrixValues = matrixConfig.matrixValues.map { it.toMutableList() } - additionalProperties = matrixConfig.additionalProperties.toMutableMap() - } - - /** - * Default per unit rate for any usage not bucketed into a specified - * matrix_value - */ - fun defaultUnitAmount(defaultUnitAmount: String) = - defaultUnitAmount(JsonField.of(defaultUnitAmount)) - - /** - * Default per unit rate for any usage not bucketed into a specified - * matrix_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)) - - /** One or two event property values to evaluate matrix groups by */ - fun dimensions(dimensions: JsonField>) = apply { - this.dimensions = dimensions.map { it.toMutableList() } - } - - /** One or two event property values to evaluate matrix groups by */ - fun addDimension(dimension: String) = apply { - dimensions = - (dimensions ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimension) - } - } - - /** Matrix values for specified matrix grouping keys */ - fun matrixValues(matrixValues: List) = - matrixValues(JsonField.of(matrixValues)) - - /** Matrix values for specified matrix grouping keys */ - fun matrixValues(matrixValues: JsonField>) = apply { - this.matrixValues = matrixValues.map { it.toMutableList() } - } - - /** Matrix values for specified matrix grouping keys */ - fun addMatrixValue(matrixValue: MatrixValue) = apply { - matrixValues = - (matrixValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): MatrixConfig = - MatrixConfig( - checkRequired("defaultUnitAmount", defaultUnitAmount), - checkRequired("dimensions", dimensions).map { it.toImmutable() }, - checkRequired("matrixValues", matrixValues).map { - it.toImmutable() - }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class MatrixValue - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - private val unitAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), - ) { - - /** - * One or two matrix keys to filter usage to this Matrix value by. For - * example, ["region", "tier"] could be used to filter cloud usage by a - * cloud region and an instance tier. - */ - fun dimensionValues(): List = - dimensionValues.getRequired("dimension_values") - - /** Unit price for the specified dimension_values */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** - * One or two matrix keys to filter usage to this Matrix value by. For - * example, ["region", "tier"] could be used to filter cloud usage by a - * cloud region and an instance tier. - */ - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - /** Unit price for the specified dimension_values */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MatrixValue = apply { - if (validated) { - return@apply - } - - dimensionValues() - unitAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MatrixValue]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(matrixValue: MatrixValue) = apply { - dimensionValues = - matrixValue.dimensionValues.map { it.toMutableList() } - unitAmount = matrixValue.unitAmount - additionalProperties = - matrixValue.additionalProperties.toMutableMap() - } - - /** - * One or two matrix keys to filter usage to this Matrix value by. For - * example, ["region", "tier"] could be used to filter cloud usage by a - * cloud region and an instance tier. - */ - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - /** - * One or two matrix keys to filter usage to this Matrix value by. For - * example, ["region", "tier"] could be used to filter cloud usage by a - * cloud region and an instance tier. - */ - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - /** - * One or two matrix keys to filter usage to this Matrix value by. For - * example, ["region", "tier"] could be used to filter cloud usage by a - * cloud region and an instance tier. - */ - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - /** Unit price for the specified dimension_values */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) - - /** Unit price for the specified dimension_values */ - 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 build(): MatrixValue = - MatrixValue( - checkRequired("dimensionValues", dimensionValues).map { - it.toImmutable() - }, - checkRequired("unitAmount", unitAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MatrixValue && dimensionValues == other.dimensionValues && unitAmount == other.unitAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, unitAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MatrixValue{dimensionValues=$dimensionValues, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MatrixConfig && defaultUnitAmount == other.defaultUnitAmount && dimensions == other.dimensions && matrixValues == other.matrixValues && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(defaultUnitAmount, dimensions, matrixValues, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MatrixConfig{defaultUnitAmount=$defaultUnitAmount, dimensions=$dimensions, matrixValues=$matrixValues, additionalProperties=$additionalProperties}" - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MATRIX = of("matrix") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MATRIX - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MATRIX, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MATRIX -> Value.MATRIX - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MATRIX -> Known.MATRIX - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionMatrixPrice && cadence == other.cadence && itemId == other.itemId && matrixConfig == other.matrixConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, matrixConfig, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionMatrixPrice{cadence=$cadence, itemId=$itemId, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionTieredPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_config") - @ExcludeMissing - private val tieredConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun tieredConfig(): TieredConfig = tieredConfig.getRequired("tiered_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("tiered_config") - @ExcludeMissing - fun _tieredConfig(): JsonField = tieredConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionTieredPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - tieredConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionTieredPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var tieredConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newSubscriptionTieredPrice: NewSubscriptionTieredPrice) = - apply { - cadence = newSubscriptionTieredPrice.cadence - itemId = newSubscriptionTieredPrice.itemId - modelType = newSubscriptionTieredPrice.modelType - name = newSubscriptionTieredPrice.name - tieredConfig = newSubscriptionTieredPrice.tieredConfig - billableMetricId = newSubscriptionTieredPrice.billableMetricId - billedInAdvance = newSubscriptionTieredPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionTieredPrice.billingCycleConfiguration - conversionRate = newSubscriptionTieredPrice.conversionRate - currency = newSubscriptionTieredPrice.currency - externalPriceId = newSubscriptionTieredPrice.externalPriceId - fixedPriceQuantity = newSubscriptionTieredPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionTieredPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionTieredPrice.invoicingCycleConfiguration - metadata = newSubscriptionTieredPrice.metadata - referenceId = newSubscriptionTieredPrice.referenceId - additionalProperties = - newSubscriptionTieredPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredConfig(tieredConfig: TieredConfig) = - tieredConfig(JsonField.of(tieredConfig)) - - fun tieredConfig(tieredConfig: JsonField) = apply { - this.tieredConfig = tieredConfig - } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionTieredPrice = - NewSubscriptionTieredPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("tieredConfig", tieredConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED = of("tiered") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED -> Value.TIERED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TIERED -> Known.TIERED - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TieredConfig - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - private val tiers: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Tiers for rating based on total usage quantities into the specified tier */ - fun tiers(): List = tiers.getRequired("tiers") - - /** Tiers for rating based on total usage quantities into the specified tier */ - @JsonProperty("tiers") - @ExcludeMissing - fun _tiers(): JsonField> = tiers - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredConfig = apply { - if (validated) { - return@apply - } - - tiers().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tieredConfig: TieredConfig) = apply { - tiers = tieredConfig.tiers.map { it.toMutableList() } - additionalProperties = tieredConfig.additionalProperties.toMutableMap() - } - - /** - * Tiers for rating based on total usage quantities into the specified tier - */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - - /** - * Tiers for rating based on total usage quantities into the specified tier - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** - * Tiers for rating based on total usage quantities into the specified tier - */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): TieredConfig = - TieredConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Tier - @JsonCreator - private constructor( - @JsonProperty("first_unit") - @ExcludeMissing - private val firstUnit: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - private val unitAmount: JsonField = JsonMissing.of(), - @JsonProperty("last_unit") - @ExcludeMissing - private val lastUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), - ) { - - /** Inclusive tier starting value */ - fun firstUnit(): Double = firstUnit.getRequired("first_unit") - - /** Amount per unit */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** - * Exclusive tier ending value. If null, this is treated as the last tier - */ - fun lastUnit(): Optional = - Optional.ofNullable(lastUnit.getNullable("last_unit")) - - /** Inclusive tier starting value */ - @JsonProperty("first_unit") - @ExcludeMissing - fun _firstUnit(): JsonField = firstUnit - - /** Amount per unit */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - /** - * Exclusive tier ending value. If null, this is treated as the last tier - */ - @JsonProperty("last_unit") - @ExcludeMissing - fun _lastUnit(): JsonField = lastUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - firstUnit() - unitAmount() - lastUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var firstUnit: JsonField? = null - private var unitAmount: JsonField? = null - private var lastUnit: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - firstUnit = tier.firstUnit - unitAmount = tier.unitAmount - lastUnit = tier.lastUnit - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Inclusive tier starting value */ - fun firstUnit(firstUnit: Double) = firstUnit(JsonField.of(firstUnit)) - - /** Inclusive tier starting value */ - fun firstUnit(firstUnit: JsonField) = apply { - this.firstUnit = firstUnit - } - - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) - - /** Amount per unit */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - /** - * Exclusive tier ending value. If null, this is treated as the last - * tier - */ - fun lastUnit(lastUnit: Double?) = - lastUnit(JsonField.ofNullable(lastUnit)) - - /** - * Exclusive tier ending value. If null, this is treated as the last - * tier - */ - fun lastUnit(lastUnit: Double) = lastUnit(lastUnit as Double?) - - /** - * Exclusive tier ending value. If null, this is treated as the last - * tier - */ - @Suppress( - "USELESS_CAST" - ) // See https://youtrack.jetbrains.com/issue/KT-74228 - fun lastUnit(lastUnit: Optional) = - lastUnit(lastUnit.orElse(null) as Double?) - - /** - * Exclusive tier ending value. If null, this is treated as the last - * tier - */ - fun lastUnit(lastUnit: JsonField) = apply { - this.lastUnit = lastUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Tier = - Tier( - checkRequired("firstUnit", firstUnit), - checkRequired("unitAmount", unitAmount), - lastUnit, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tier && firstUnit == other.firstUnit && unitAmount == other.unitAmount && lastUnit == other.lastUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(firstUnit, unitAmount, lastUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{firstUnit=$firstUnit, unitAmount=$unitAmount, lastUnit=$lastUnit, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredConfig && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredConfig{tiers=$tiers, additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionTieredPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredConfig == other.tieredConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionTieredPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionTieredBpsPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_bps_config") - @ExcludeMissing - private val tieredBpsConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun tieredBpsConfig(): TieredBpsConfig = - tieredBpsConfig.getRequired("tiered_bps_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("tiered_bps_config") - @ExcludeMissing - fun _tieredBpsConfig(): JsonField = tieredBpsConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionTieredBpsPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - tieredBpsConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionTieredBpsPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var tieredBpsConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionTieredBpsPrice: NewSubscriptionTieredBpsPrice - ) = apply { - cadence = newSubscriptionTieredBpsPrice.cadence - itemId = newSubscriptionTieredBpsPrice.itemId - modelType = newSubscriptionTieredBpsPrice.modelType - name = newSubscriptionTieredBpsPrice.name - tieredBpsConfig = newSubscriptionTieredBpsPrice.tieredBpsConfig - billableMetricId = newSubscriptionTieredBpsPrice.billableMetricId - billedInAdvance = newSubscriptionTieredBpsPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionTieredBpsPrice.billingCycleConfiguration - conversionRate = newSubscriptionTieredBpsPrice.conversionRate - currency = newSubscriptionTieredBpsPrice.currency - externalPriceId = newSubscriptionTieredBpsPrice.externalPriceId - fixedPriceQuantity = newSubscriptionTieredBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionTieredBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionTieredBpsPrice.invoicingCycleConfiguration - metadata = newSubscriptionTieredBpsPrice.metadata - referenceId = newSubscriptionTieredBpsPrice.referenceId - additionalProperties = - newSubscriptionTieredBpsPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredBpsConfig(tieredBpsConfig: TieredBpsConfig) = - tieredBpsConfig(JsonField.of(tieredBpsConfig)) - - fun tieredBpsConfig(tieredBpsConfig: JsonField) = apply { - this.tieredBpsConfig = tieredBpsConfig - } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionTieredBpsPrice = - NewSubscriptionTieredBpsPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("tieredBpsConfig", tieredBpsConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED_BPS = of("tiered_bps") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_BPS -> Value.TIERED_BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TIERED_BPS -> Known.TIERED_BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TieredBpsConfig - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - private val tiers: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into - * specified tiers - */ - fun tiers(): List = tiers.getRequired("tiers") - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into - * specified tiers - */ - @JsonProperty("tiers") - @ExcludeMissing - fun _tiers(): JsonField> = tiers - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredBpsConfig = apply { - if (validated) { - return@apply - } - - tiers().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredBpsConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tieredBpsConfig: TieredBpsConfig) = apply { - tiers = tieredBpsConfig.tiers.map { it.toMutableList() } - additionalProperties = - tieredBpsConfig.additionalProperties.toMutableMap() - } - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into - * specified tiers - */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into - * specified tiers - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into - * specified tiers - */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): TieredBpsConfig = - TieredBpsConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Tier - @JsonCreator - private constructor( - @JsonProperty("bps") - @ExcludeMissing - private val bps: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_maximum") - @ExcludeMissing - private val perUnitMaximum: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), - ) { - - /** Per-event basis point rate */ - fun bps(): Double = bps.getRequired("bps") - - /** Inclusive tier starting value */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** Exclusive tier ending value */ - fun maximumAmount(): Optional = - Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - - /** Per unit maximum to charge */ - fun perUnitMaximum(): Optional = - Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) - - /** Per-event basis point rate */ - @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps - - /** Inclusive tier starting value */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** Exclusive tier ending value */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** Per unit maximum to charge */ - @JsonProperty("per_unit_maximum") - @ExcludeMissing - fun _perUnitMaximum(): JsonField = perUnitMaximum - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - bps() - minimumAmount() - maximumAmount() - perUnitMaximum() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var bps: JsonField? = null - private var minimumAmount: JsonField? = null - private var maximumAmount: JsonField = JsonMissing.of() - private var perUnitMaximum: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - bps = tier.bps - minimumAmount = tier.minimumAmount - maximumAmount = tier.maximumAmount - perUnitMaximum = tier.perUnitMaximum - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Per-event basis point rate */ - fun bps(bps: Double) = bps(JsonField.of(bps)) - - /** Per-event basis point rate */ - fun bps(bps: JsonField) = apply { this.bps = bps } - - /** Inclusive tier starting value */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** Inclusive tier starting value */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** Exclusive tier ending value */ - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - /** Exclusive tier ending value */ - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.orElse(null)) - - /** Exclusive tier ending value */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** Per unit maximum to charge */ - fun perUnitMaximum(perUnitMaximum: String?) = - perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) - - /** Per unit maximum to charge */ - fun perUnitMaximum(perUnitMaximum: Optional) = - perUnitMaximum(perUnitMaximum.orElse(null)) - - /** Per unit maximum to charge */ - fun perUnitMaximum(perUnitMaximum: JsonField) = apply { - this.perUnitMaximum = perUnitMaximum - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): Tier = - Tier( - checkRequired("bps", bps), - checkRequired("minimumAmount", minimumAmount), - maximumAmount, - perUnitMaximum, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tier && bps == other.bps && minimumAmount == other.minimumAmount && maximumAmount == other.maximumAmount && perUnitMaximum == other.perUnitMaximum && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bps, minimumAmount, maximumAmount, perUnitMaximum, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{bps=$bps, minimumAmount=$minimumAmount, maximumAmount=$maximumAmount, perUnitMaximum=$perUnitMaximum, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredBpsConfig && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredBpsConfig{tiers=$tiers, additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionTieredBpsPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredBpsConfig == other.tieredBpsConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredBpsConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionTieredBpsPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredBpsConfig=$tieredBpsConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionBpsPrice - @JsonCreator - private constructor( - @JsonProperty("bps_config") - @ExcludeMissing - private val bpsConfig: JsonField = JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun bpsConfig(): BpsConfig = bpsConfig.getRequired("bps_config") - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - @JsonProperty("bps_config") - @ExcludeMissing - fun _bpsConfig(): JsonField = bpsConfig - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionBpsPrice = apply { - if (validated) { - return@apply - } - - bpsConfig().validate() - cadence() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionBpsPrice]. */ - class Builder internal constructor() { - - private var bpsConfig: JsonField? = null - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newSubscriptionBpsPrice: NewSubscriptionBpsPrice) = apply { - bpsConfig = newSubscriptionBpsPrice.bpsConfig - cadence = newSubscriptionBpsPrice.cadence - itemId = newSubscriptionBpsPrice.itemId - modelType = newSubscriptionBpsPrice.modelType - name = newSubscriptionBpsPrice.name - billableMetricId = newSubscriptionBpsPrice.billableMetricId - billedInAdvance = newSubscriptionBpsPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionBpsPrice.billingCycleConfiguration - conversionRate = newSubscriptionBpsPrice.conversionRate - currency = newSubscriptionBpsPrice.currency - externalPriceId = newSubscriptionBpsPrice.externalPriceId - fixedPriceQuantity = newSubscriptionBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionBpsPrice.invoicingCycleConfiguration - metadata = newSubscriptionBpsPrice.metadata - referenceId = newSubscriptionBpsPrice.referenceId - additionalProperties = - newSubscriptionBpsPrice.additionalProperties.toMutableMap() - } - - fun bpsConfig(bpsConfig: BpsConfig) = bpsConfig(JsonField.of(bpsConfig)) - - fun bpsConfig(bpsConfig: JsonField) = apply { - this.bpsConfig = bpsConfig - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionBpsPrice = - NewSubscriptionBpsPrice( - checkRequired("bpsConfig", bpsConfig), - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BpsConfig - @JsonCreator - private constructor( - @JsonProperty("bps") - @ExcludeMissing - private val bps: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_maximum") - @ExcludeMissing - private val perUnitMaximum: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Basis point take rate per event */ - fun bps(): Double = bps.getRequired("bps") - - /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(): Optional = - Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) - - /** Basis point take rate per event */ - @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps - - /** Optional currency amount maximum to cap spend per event */ - @JsonProperty("per_unit_maximum") - @ExcludeMissing - fun _perUnitMaximum(): JsonField = perUnitMaximum - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BpsConfig = apply { - if (validated) { - return@apply - } - - bps() - perUnitMaximum() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BpsConfig]. */ - class Builder internal constructor() { - - private var bps: JsonField? = null - private var perUnitMaximum: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(bpsConfig: BpsConfig) = apply { - bps = bpsConfig.bps - perUnitMaximum = bpsConfig.perUnitMaximum - additionalProperties = bpsConfig.additionalProperties.toMutableMap() - } - - /** Basis point take rate per event */ - fun bps(bps: Double) = bps(JsonField.of(bps)) - - /** Basis point take rate per event */ - fun bps(bps: JsonField) = apply { this.bps = bps } - - /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(perUnitMaximum: String?) = - perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) - - /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(perUnitMaximum: Optional) = - perUnitMaximum(perUnitMaximum.orElse(null)) - - /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(perUnitMaximum: JsonField) = apply { - this.perUnitMaximum = perUnitMaximum - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): BpsConfig = - BpsConfig( - checkRequired("bps", bps), - perUnitMaximum, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BpsConfig && bps == other.bps && perUnitMaximum == other.perUnitMaximum && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bps, perUnitMaximum, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BpsConfig{bps=$bps, perUnitMaximum=$perUnitMaximum, additionalProperties=$additionalProperties}" - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val BPS = of("bps") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BPS -> Value.BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - BPS -> Known.BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionBpsPrice && bpsConfig == other.bpsConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bpsConfig, cadence, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionBpsPrice{bpsConfig=$bpsConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionBulkBpsPrice - @JsonCreator - private constructor( - @JsonProperty("bulk_bps_config") - @ExcludeMissing - private val bulkBpsConfig: JsonField = JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun bulkBpsConfig(): BulkBpsConfig = bulkBpsConfig.getRequired("bulk_bps_config") - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - @JsonProperty("bulk_bps_config") - @ExcludeMissing - fun _bulkBpsConfig(): JsonField = bulkBpsConfig - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionBulkBpsPrice = apply { - if (validated) { - return@apply - } - - bulkBpsConfig().validate() - cadence() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionBulkBpsPrice]. */ - class Builder internal constructor() { - - private var bulkBpsConfig: JsonField? = null - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newSubscriptionBulkBpsPrice: NewSubscriptionBulkBpsPrice) = - apply { - bulkBpsConfig = newSubscriptionBulkBpsPrice.bulkBpsConfig - cadence = newSubscriptionBulkBpsPrice.cadence - itemId = newSubscriptionBulkBpsPrice.itemId - modelType = newSubscriptionBulkBpsPrice.modelType - name = newSubscriptionBulkBpsPrice.name - billableMetricId = newSubscriptionBulkBpsPrice.billableMetricId - billedInAdvance = newSubscriptionBulkBpsPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionBulkBpsPrice.billingCycleConfiguration - conversionRate = newSubscriptionBulkBpsPrice.conversionRate - currency = newSubscriptionBulkBpsPrice.currency - externalPriceId = newSubscriptionBulkBpsPrice.externalPriceId - fixedPriceQuantity = newSubscriptionBulkBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionBulkBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionBulkBpsPrice.invoicingCycleConfiguration - metadata = newSubscriptionBulkBpsPrice.metadata - referenceId = newSubscriptionBulkBpsPrice.referenceId - additionalProperties = - newSubscriptionBulkBpsPrice.additionalProperties.toMutableMap() - } - - fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfig) = - bulkBpsConfig(JsonField.of(bulkBpsConfig)) - - fun bulkBpsConfig(bulkBpsConfig: JsonField) = apply { - this.bulkBpsConfig = bulkBpsConfig - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionBulkBpsPrice = - NewSubscriptionBulkBpsPrice( - checkRequired("bulkBpsConfig", bulkBpsConfig), - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BulkBpsConfig - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - private val tiers: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a single - * tier based on total volume - */ - fun tiers(): List = tiers.getRequired("tiers") - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a single - * tier based on total volume - */ - @JsonProperty("tiers") - @ExcludeMissing - fun _tiers(): JsonField> = tiers - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BulkBpsConfig = apply { - if (validated) { - return@apply - } - - tiers().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkBpsConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(bulkBpsConfig: BulkBpsConfig) = apply { - tiers = bulkBpsConfig.tiers.map { it.toMutableList() } - additionalProperties = bulkBpsConfig.additionalProperties.toMutableMap() - } - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a - * single tier based on total volume - */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a - * single tier based on total volume - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a - * single tier based on total volume - */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): BulkBpsConfig = - BulkBpsConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Tier - @JsonCreator - private constructor( - @JsonProperty("bps") - @ExcludeMissing - private val bps: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_maximum") - @ExcludeMissing - private val perUnitMaximum: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), - ) { - - /** Basis points to rate on */ - fun bps(): Double = bps.getRequired("bps") - - /** Upper bound for tier */ - fun maximumAmount(): Optional = - Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(): Optional = - Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) - - /** Basis points to rate on */ - @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps - - /** Upper bound for tier */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** The maximum amount to charge for any one event */ - @JsonProperty("per_unit_maximum") - @ExcludeMissing - fun _perUnitMaximum(): JsonField = perUnitMaximum - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - bps() - maximumAmount() - perUnitMaximum() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var bps: JsonField? = null - private var maximumAmount: JsonField = JsonMissing.of() - private var perUnitMaximum: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - bps = tier.bps - maximumAmount = tier.maximumAmount - perUnitMaximum = tier.perUnitMaximum - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Basis points to rate on */ - fun bps(bps: Double) = bps(JsonField.of(bps)) - - /** Basis points to rate on */ - fun bps(bps: JsonField) = apply { this.bps = bps } - - /** Upper bound for tier */ - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - /** Upper bound for tier */ - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.orElse(null)) - - /** Upper bound for tier */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(perUnitMaximum: String?) = - perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) - - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(perUnitMaximum: Optional) = - perUnitMaximum(perUnitMaximum.orElse(null)) - - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(perUnitMaximum: JsonField) = apply { - this.perUnitMaximum = perUnitMaximum - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): Tier = - Tier( - checkRequired("bps", bps), - maximumAmount, - perUnitMaximum, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tier && bps == other.bps && maximumAmount == other.maximumAmount && perUnitMaximum == other.perUnitMaximum && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bps, maximumAmount, perUnitMaximum, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{bps=$bps, maximumAmount=$maximumAmount, perUnitMaximum=$perUnitMaximum, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BulkBpsConfig && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkBpsConfig{tiers=$tiers, additionalProperties=$additionalProperties}" - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val BULK_BPS = of("bulk_bps") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK_BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK_BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK_BPS -> Value.BULK_BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - BULK_BPS -> Known.BULK_BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionBulkBpsPrice && bulkBpsConfig == other.bulkBpsConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bulkBpsConfig, cadence, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionBulkBpsPrice{bulkBpsConfig=$bulkBpsConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionBulkPrice - @JsonCreator - private constructor( - @JsonProperty("bulk_config") - @ExcludeMissing - private val bulkConfig: JsonField = JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun bulkConfig(): BulkConfig = bulkConfig.getRequired("bulk_config") - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - @JsonProperty("bulk_config") - @ExcludeMissing - fun _bulkConfig(): JsonField = bulkConfig - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionBulkPrice = apply { - if (validated) { - return@apply - } - - bulkConfig().validate() - cadence() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionBulkPrice]. */ - class Builder internal constructor() { - - private var bulkConfig: JsonField? = null - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var 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 currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newSubscriptionBulkPrice: NewSubscriptionBulkPrice) = apply { - bulkConfig = newSubscriptionBulkPrice.bulkConfig - cadence = newSubscriptionBulkPrice.cadence - itemId = newSubscriptionBulkPrice.itemId - modelType = newSubscriptionBulkPrice.modelType - name = newSubscriptionBulkPrice.name - billableMetricId = newSubscriptionBulkPrice.billableMetricId - billedInAdvance = newSubscriptionBulkPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionBulkPrice.billingCycleConfiguration - conversionRate = newSubscriptionBulkPrice.conversionRate - currency = newSubscriptionBulkPrice.currency - externalPriceId = newSubscriptionBulkPrice.externalPriceId - fixedPriceQuantity = newSubscriptionBulkPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionBulkPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionBulkPrice.invoicingCycleConfiguration - metadata = newSubscriptionBulkPrice.metadata - referenceId = newSubscriptionBulkPrice.referenceId - additionalProperties = - newSubscriptionBulkPrice.additionalProperties.toMutableMap() - } - - fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) - - fun bulkConfig(bulkConfig: JsonField) = apply { - this.bulkConfig = bulkConfig - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionBulkPrice = - NewSubscriptionBulkPrice( - checkRequired("bulkConfig", bulkConfig), - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BulkConfig - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - private val tiers: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Bulk tiers for rating based on total usage volume */ - fun tiers(): List = tiers.getRequired("tiers") - - /** Bulk tiers for rating based on total usage volume */ - @JsonProperty("tiers") - @ExcludeMissing - fun _tiers(): JsonField> = tiers - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BulkConfig = apply { - if (validated) { - return@apply - } - - tiers().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(bulkConfig: BulkConfig) = apply { - tiers = bulkConfig.tiers.map { it.toMutableList() } - additionalProperties = bulkConfig.additionalProperties.toMutableMap() - } - - /** Bulk tiers for rating based on total usage volume */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - - /** Bulk tiers for rating based on total usage volume */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** Bulk tiers for rating based on total usage volume */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): BulkConfig = - BulkConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Tier - @JsonCreator - private constructor( - @JsonProperty("unit_amount") - @ExcludeMissing - private val unitAmount: JsonField = JsonMissing.of(), - @JsonProperty("maximum_units") - @ExcludeMissing - private val maximumUnits: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), - ) { - - /** Amount per unit */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** Upper bound for this tier */ - fun maximumUnits(): Optional = - Optional.ofNullable(maximumUnits.getNullable("maximum_units")) - - /** Amount per unit */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - /** Upper bound for this tier */ - @JsonProperty("maximum_units") - @ExcludeMissing - fun _maximumUnits(): JsonField = maximumUnits - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - unitAmount() - maximumUnits() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var unitAmount: JsonField? = null - private var maximumUnits: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - unitAmount = tier.unitAmount - maximumUnits = tier.maximumUnits - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) - - /** Amount per unit */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - /** Upper bound for this tier */ - fun maximumUnits(maximumUnits: Double?) = - maximumUnits(JsonField.ofNullable(maximumUnits)) - - /** Upper bound for this tier */ - fun maximumUnits(maximumUnits: Double) = - maximumUnits(maximumUnits as Double?) - - /** Upper bound for this tier */ - @Suppress( - "USELESS_CAST" - ) // See https://youtrack.jetbrains.com/issue/KT-74228 - fun maximumUnits(maximumUnits: Optional) = - maximumUnits(maximumUnits.orElse(null) as Double?) - - /** Upper bound for this tier */ - fun maximumUnits(maximumUnits: JsonField) = apply { - this.maximumUnits = maximumUnits - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Tier = - Tier( - checkRequired("unitAmount", unitAmount), - maximumUnits, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tier && unitAmount == other.unitAmount && maximumUnits == other.maximumUnits && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(unitAmount, maximumUnits, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{unitAmount=$unitAmount, maximumUnits=$maximumUnits, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BulkConfig && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkConfig{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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val BULK = of("bulk") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK -> Value.BULK - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - BULK -> Known.BULK - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionBulkPrice && bulkConfig == other.bulkConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bulkConfig, cadence, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionBulkPrice{bulkConfig=$bulkConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionThresholdTotalAmountPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("threshold_total_amount_config") - @ExcludeMissing - private val thresholdTotalAmountConfig: JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun thresholdTotalAmountConfig(): ThresholdTotalAmountConfig = - thresholdTotalAmountConfig.getRequired("threshold_total_amount_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("threshold_total_amount_config") - @ExcludeMissing - fun _thresholdTotalAmountConfig(): JsonField = - thresholdTotalAmountConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionThresholdTotalAmountPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - thresholdTotalAmountConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionThresholdTotalAmountPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var thresholdTotalAmountConfig: JsonField? = - null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionThresholdTotalAmountPrice: - NewSubscriptionThresholdTotalAmountPrice - ) = apply { - cadence = newSubscriptionThresholdTotalAmountPrice.cadence - itemId = newSubscriptionThresholdTotalAmountPrice.itemId - modelType = newSubscriptionThresholdTotalAmountPrice.modelType - name = newSubscriptionThresholdTotalAmountPrice.name - thresholdTotalAmountConfig = - newSubscriptionThresholdTotalAmountPrice.thresholdTotalAmountConfig - billableMetricId = newSubscriptionThresholdTotalAmountPrice.billableMetricId - billedInAdvance = newSubscriptionThresholdTotalAmountPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionThresholdTotalAmountPrice.billingCycleConfiguration - conversionRate = newSubscriptionThresholdTotalAmountPrice.conversionRate - currency = newSubscriptionThresholdTotalAmountPrice.currency - externalPriceId = newSubscriptionThresholdTotalAmountPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionThresholdTotalAmountPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionThresholdTotalAmountPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionThresholdTotalAmountPrice.invoicingCycleConfiguration - metadata = newSubscriptionThresholdTotalAmountPrice.metadata - referenceId = newSubscriptionThresholdTotalAmountPrice.referenceId - additionalProperties = - newSubscriptionThresholdTotalAmountPrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun thresholdTotalAmountConfig( - thresholdTotalAmountConfig: ThresholdTotalAmountConfig - ) = thresholdTotalAmountConfig(JsonField.of(thresholdTotalAmountConfig)) - - fun thresholdTotalAmountConfig( - thresholdTotalAmountConfig: JsonField - ) = apply { this.thresholdTotalAmountConfig = thresholdTotalAmountConfig } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionThresholdTotalAmountPrice = - NewSubscriptionThresholdTotalAmountPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("thresholdTotalAmountConfig", thresholdTotalAmountConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val THRESHOLD_TOTAL_AMOUNT = of("threshold_total_amount") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - THRESHOLD_TOTAL_AMOUNT - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - THRESHOLD_TOTAL_AMOUNT, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - THRESHOLD_TOTAL_AMOUNT -> Value.THRESHOLD_TOTAL_AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - THRESHOLD_TOTAL_AMOUNT -> Known.THRESHOLD_TOTAL_AMOUNT - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class ThresholdTotalAmountConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): ThresholdTotalAmountConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ThresholdTotalAmountConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(thresholdTotalAmountConfig: ThresholdTotalAmountConfig) = - apply { - additionalProperties = - thresholdTotalAmountConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): ThresholdTotalAmountConfig = - ThresholdTotalAmountConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ThresholdTotalAmountConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ThresholdTotalAmountConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionThresholdTotalAmountPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, thresholdTotalAmountConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionThresholdTotalAmountPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionTieredPackagePrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_package_config") - @ExcludeMissing - private val tieredPackageConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun tieredPackageConfig(): TieredPackageConfig = - tieredPackageConfig.getRequired("tiered_package_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("tiered_package_config") - @ExcludeMissing - fun _tieredPackageConfig(): JsonField = tieredPackageConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionTieredPackagePrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - tieredPackageConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionTieredPackagePrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var tieredPackageConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionTieredPackagePrice: NewSubscriptionTieredPackagePrice - ) = apply { - cadence = newSubscriptionTieredPackagePrice.cadence - itemId = newSubscriptionTieredPackagePrice.itemId - modelType = newSubscriptionTieredPackagePrice.modelType - name = newSubscriptionTieredPackagePrice.name - tieredPackageConfig = newSubscriptionTieredPackagePrice.tieredPackageConfig - billableMetricId = newSubscriptionTieredPackagePrice.billableMetricId - billedInAdvance = newSubscriptionTieredPackagePrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionTieredPackagePrice.billingCycleConfiguration - conversionRate = newSubscriptionTieredPackagePrice.conversionRate - currency = newSubscriptionTieredPackagePrice.currency - externalPriceId = newSubscriptionTieredPackagePrice.externalPriceId - fixedPriceQuantity = newSubscriptionTieredPackagePrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionTieredPackagePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionTieredPackagePrice.invoicingCycleConfiguration - metadata = newSubscriptionTieredPackagePrice.metadata - referenceId = newSubscriptionTieredPackagePrice.referenceId - additionalProperties = - newSubscriptionTieredPackagePrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = - tieredPackageConfig(JsonField.of(tieredPackageConfig)) - - fun tieredPackageConfig(tieredPackageConfig: JsonField) = - apply { - this.tieredPackageConfig = tieredPackageConfig - } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionTieredPackagePrice = - NewSubscriptionTieredPackagePrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("tieredPackageConfig", tieredPackageConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED_PACKAGE = of("tiered_package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_PACKAGE - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_PACKAGE, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_PACKAGE -> Value.TIERED_PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TIERED_PACKAGE -> Known.TIERED_PACKAGE - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TieredPackageConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredPackageConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredPackageConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tieredPackageConfig: TieredPackageConfig) = apply { - additionalProperties = - tieredPackageConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): TieredPackageConfig = - TieredPackageConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredPackageConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionTieredPackagePrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredPackageConfig == other.tieredPackageConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredPackageConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionTieredPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionTieredWithMinimumPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_minimum_config") - @ExcludeMissing - private val tieredWithMinimumConfig: JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun tieredWithMinimumConfig(): TieredWithMinimumConfig = - tieredWithMinimumConfig.getRequired("tiered_with_minimum_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("tiered_with_minimum_config") - @ExcludeMissing - fun _tieredWithMinimumConfig(): JsonField = - tieredWithMinimumConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionTieredWithMinimumPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - tieredWithMinimumConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionTieredWithMinimumPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var tieredWithMinimumConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionTieredWithMinimumPrice: NewSubscriptionTieredWithMinimumPrice - ) = apply { - cadence = newSubscriptionTieredWithMinimumPrice.cadence - itemId = newSubscriptionTieredWithMinimumPrice.itemId - modelType = newSubscriptionTieredWithMinimumPrice.modelType - name = newSubscriptionTieredWithMinimumPrice.name - tieredWithMinimumConfig = - newSubscriptionTieredWithMinimumPrice.tieredWithMinimumConfig - billableMetricId = newSubscriptionTieredWithMinimumPrice.billableMetricId - billedInAdvance = newSubscriptionTieredWithMinimumPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionTieredWithMinimumPrice.billingCycleConfiguration - conversionRate = newSubscriptionTieredWithMinimumPrice.conversionRate - currency = newSubscriptionTieredWithMinimumPrice.currency - externalPriceId = newSubscriptionTieredWithMinimumPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionTieredWithMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionTieredWithMinimumPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionTieredWithMinimumPrice.invoicingCycleConfiguration - metadata = newSubscriptionTieredWithMinimumPrice.metadata - referenceId = newSubscriptionTieredWithMinimumPrice.referenceId - additionalProperties = - newSubscriptionTieredWithMinimumPrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredWithMinimumConfig(tieredWithMinimumConfig: TieredWithMinimumConfig) = - tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) - - fun tieredWithMinimumConfig( - tieredWithMinimumConfig: JsonField - ) = apply { this.tieredWithMinimumConfig = tieredWithMinimumConfig } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionTieredWithMinimumPrice = - NewSubscriptionTieredWithMinimumPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("tieredWithMinimumConfig", tieredWithMinimumConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED_WITH_MINIMUM = of("tiered_with_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_WITH_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_WITH_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_WITH_MINIMUM -> Value.TIERED_WITH_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TIERED_WITH_MINIMUM -> Known.TIERED_WITH_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TieredWithMinimumConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredWithMinimumConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredWithMinimumConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tieredWithMinimumConfig: TieredWithMinimumConfig) = - apply { - additionalProperties = - tieredWithMinimumConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): TieredWithMinimumConfig = - TieredWithMinimumConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredWithMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredWithMinimumConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionTieredWithMinimumPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredWithMinimumConfig == other.tieredWithMinimumConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredWithMinimumConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionTieredWithMinimumPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionUnitWithPercentPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("unit_with_percent_config") - @ExcludeMissing - private val unitWithPercentConfig: JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun unitWithPercentConfig(): UnitWithPercentConfig = - unitWithPercentConfig.getRequired("unit_with_percent_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("unit_with_percent_config") - @ExcludeMissing - fun _unitWithPercentConfig(): JsonField = - unitWithPercentConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionUnitWithPercentPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - unitWithPercentConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionUnitWithPercentPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var unitWithPercentConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionUnitWithPercentPrice: NewSubscriptionUnitWithPercentPrice - ) = apply { - cadence = newSubscriptionUnitWithPercentPrice.cadence - itemId = newSubscriptionUnitWithPercentPrice.itemId - modelType = newSubscriptionUnitWithPercentPrice.modelType - name = newSubscriptionUnitWithPercentPrice.name - unitWithPercentConfig = - newSubscriptionUnitWithPercentPrice.unitWithPercentConfig - billableMetricId = newSubscriptionUnitWithPercentPrice.billableMetricId - billedInAdvance = newSubscriptionUnitWithPercentPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionUnitWithPercentPrice.billingCycleConfiguration - conversionRate = newSubscriptionUnitWithPercentPrice.conversionRate - currency = newSubscriptionUnitWithPercentPrice.currency - externalPriceId = newSubscriptionUnitWithPercentPrice.externalPriceId - fixedPriceQuantity = newSubscriptionUnitWithPercentPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionUnitWithPercentPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionUnitWithPercentPrice.invoicingCycleConfiguration - metadata = newSubscriptionUnitWithPercentPrice.metadata - referenceId = newSubscriptionUnitWithPercentPrice.referenceId - additionalProperties = - newSubscriptionUnitWithPercentPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun unitWithPercentConfig(unitWithPercentConfig: UnitWithPercentConfig) = - unitWithPercentConfig(JsonField.of(unitWithPercentConfig)) - - fun unitWithPercentConfig( - unitWithPercentConfig: JsonField - ) = apply { this.unitWithPercentConfig = unitWithPercentConfig } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionUnitWithPercentPrice = - NewSubscriptionUnitWithPercentPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("unitWithPercentConfig", unitWithPercentConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val UNIT_WITH_PERCENT = of("unit_with_percent") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - UNIT_WITH_PERCENT - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - UNIT_WITH_PERCENT, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - UNIT_WITH_PERCENT -> Value.UNIT_WITH_PERCENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - UNIT_WITH_PERCENT -> Known.UNIT_WITH_PERCENT - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class UnitWithPercentConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): UnitWithPercentConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnitWithPercentConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unitWithPercentConfig: UnitWithPercentConfig) = apply { - additionalProperties = - unitWithPercentConfig.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) - } - - fun build(): UnitWithPercentConfig = - UnitWithPercentConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UnitWithPercentConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnitWithPercentConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionUnitWithPercentPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && unitWithPercentConfig == other.unitWithPercentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, unitWithPercentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionUnitWithPercentPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionPackageWithAllocationPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("package_with_allocation_config") - @ExcludeMissing - private val packageWithAllocationConfig: JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun packageWithAllocationConfig(): PackageWithAllocationConfig = - packageWithAllocationConfig.getRequired("package_with_allocation_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("package_with_allocation_config") - @ExcludeMissing - fun _packageWithAllocationConfig(): JsonField = - packageWithAllocationConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionPackageWithAllocationPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - packageWithAllocationConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionPackageWithAllocationPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var packageWithAllocationConfig: - JsonField? = - null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionPackageWithAllocationPrice: - NewSubscriptionPackageWithAllocationPrice - ) = apply { - cadence = newSubscriptionPackageWithAllocationPrice.cadence - itemId = newSubscriptionPackageWithAllocationPrice.itemId - modelType = newSubscriptionPackageWithAllocationPrice.modelType - name = newSubscriptionPackageWithAllocationPrice.name - packageWithAllocationConfig = - newSubscriptionPackageWithAllocationPrice.packageWithAllocationConfig - billableMetricId = - newSubscriptionPackageWithAllocationPrice.billableMetricId - billedInAdvance = newSubscriptionPackageWithAllocationPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionPackageWithAllocationPrice.billingCycleConfiguration - conversionRate = newSubscriptionPackageWithAllocationPrice.conversionRate - currency = newSubscriptionPackageWithAllocationPrice.currency - externalPriceId = newSubscriptionPackageWithAllocationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionPackageWithAllocationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionPackageWithAllocationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionPackageWithAllocationPrice.invoicingCycleConfiguration - metadata = newSubscriptionPackageWithAllocationPrice.metadata - referenceId = newSubscriptionPackageWithAllocationPrice.referenceId - additionalProperties = - newSubscriptionPackageWithAllocationPrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun packageWithAllocationConfig( - packageWithAllocationConfig: PackageWithAllocationConfig - ) = packageWithAllocationConfig(JsonField.of(packageWithAllocationConfig)) - - fun packageWithAllocationConfig( - packageWithAllocationConfig: JsonField - ) = apply { this.packageWithAllocationConfig = packageWithAllocationConfig } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionPackageWithAllocationPrice = - NewSubscriptionPackageWithAllocationPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired( - "packageWithAllocationConfig", - packageWithAllocationConfig, - ), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val PACKAGE_WITH_ALLOCATION = of("package_with_allocation") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - PACKAGE_WITH_ALLOCATION - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PACKAGE_WITH_ALLOCATION, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PACKAGE_WITH_ALLOCATION -> Value.PACKAGE_WITH_ALLOCATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PACKAGE_WITH_ALLOCATION -> Known.PACKAGE_WITH_ALLOCATION - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class PackageWithAllocationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PackageWithAllocationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PackageWithAllocationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - packageWithAllocationConfig: PackageWithAllocationConfig - ) = apply { - additionalProperties = - packageWithAllocationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): PackageWithAllocationConfig = - PackageWithAllocationConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PackageWithAllocationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PackageWithAllocationConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionPackageWithAllocationPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && packageWithAllocationConfig == other.packageWithAllocationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, packageWithAllocationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionPackageWithAllocationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionTierWithProrationPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - private val tieredWithProrationConfig: JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - 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. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionTierWithProrationPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - tieredWithProrationConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionTierWithProrationPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var tieredWithProrationConfig: JsonField? = - null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionTierWithProrationPrice: NewSubscriptionTierWithProrationPrice - ) = apply { - cadence = newSubscriptionTierWithProrationPrice.cadence - itemId = newSubscriptionTierWithProrationPrice.itemId - modelType = newSubscriptionTierWithProrationPrice.modelType - name = newSubscriptionTierWithProrationPrice.name - tieredWithProrationConfig = - newSubscriptionTierWithProrationPrice.tieredWithProrationConfig - billableMetricId = newSubscriptionTierWithProrationPrice.billableMetricId - billedInAdvance = newSubscriptionTierWithProrationPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionTierWithProrationPrice.billingCycleConfiguration - conversionRate = newSubscriptionTierWithProrationPrice.conversionRate - currency = newSubscriptionTierWithProrationPrice.currency - externalPriceId = newSubscriptionTierWithProrationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionTierWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionTierWithProrationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionTierWithProrationPrice.invoicingCycleConfiguration - metadata = newSubscriptionTierWithProrationPrice.metadata - referenceId = newSubscriptionTierWithProrationPrice.referenceId - additionalProperties = - newSubscriptionTierWithProrationPrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredWithProrationConfig( - tieredWithProrationConfig: TieredWithProrationConfig - ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionTierWithProrationPrice = - NewSubscriptionTierWithProrationPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED_WITH_PRORATION = of("tiered_with_proration") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_WITH_PRORATION - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_WITH_PRORATION, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_WITH_PRORATION -> Value.TIERED_WITH_PRORATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TIERED_WITH_PRORATION -> Known.TIERED_WITH_PRORATION - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TieredWithProrationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredWithProrationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredWithProrationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = - apply { - additionalProperties = - tieredWithProrationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredWithProrationConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionTierWithProrationPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionTierWithProrationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionUnitWithProrationPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("unit_with_proration_config") - @ExcludeMissing - private val unitWithProrationConfig: JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun unitWithProrationConfig(): UnitWithProrationConfig = - unitWithProrationConfig.getRequired("unit_with_proration_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("unit_with_proration_config") - @ExcludeMissing - fun _unitWithProrationConfig(): JsonField = - unitWithProrationConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionUnitWithProrationPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - unitWithProrationConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionUnitWithProrationPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var unitWithProrationConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionUnitWithProrationPrice: NewSubscriptionUnitWithProrationPrice - ) = apply { - cadence = newSubscriptionUnitWithProrationPrice.cadence - itemId = newSubscriptionUnitWithProrationPrice.itemId - modelType = newSubscriptionUnitWithProrationPrice.modelType - name = newSubscriptionUnitWithProrationPrice.name - unitWithProrationConfig = - newSubscriptionUnitWithProrationPrice.unitWithProrationConfig - billableMetricId = newSubscriptionUnitWithProrationPrice.billableMetricId - billedInAdvance = newSubscriptionUnitWithProrationPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionUnitWithProrationPrice.billingCycleConfiguration - conversionRate = newSubscriptionUnitWithProrationPrice.conversionRate - currency = newSubscriptionUnitWithProrationPrice.currency - externalPriceId = newSubscriptionUnitWithProrationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionUnitWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionUnitWithProrationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionUnitWithProrationPrice.invoicingCycleConfiguration - metadata = newSubscriptionUnitWithProrationPrice.metadata - referenceId = newSubscriptionUnitWithProrationPrice.referenceId - additionalProperties = - newSubscriptionUnitWithProrationPrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun unitWithProrationConfig(unitWithProrationConfig: UnitWithProrationConfig) = - unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) - - fun unitWithProrationConfig( - unitWithProrationConfig: JsonField - ) = apply { this.unitWithProrationConfig = unitWithProrationConfig } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionUnitWithProrationPrice = - NewSubscriptionUnitWithProrationPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("unitWithProrationConfig", unitWithProrationConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val UNIT_WITH_PRORATION = of("unit_with_proration") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - UNIT_WITH_PRORATION - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - UNIT_WITH_PRORATION, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - UNIT_WITH_PRORATION -> Value.UNIT_WITH_PRORATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - UNIT_WITH_PRORATION -> Known.UNIT_WITH_PRORATION - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class UnitWithProrationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): UnitWithProrationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnitWithProrationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unitWithProrationConfig: UnitWithProrationConfig) = - apply { - additionalProperties = - unitWithProrationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): UnitWithProrationConfig = - UnitWithProrationConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UnitWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnitWithProrationConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionUnitWithProrationPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && unitWithProrationConfig == other.unitWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, unitWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionUnitWithProrationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionGroupedAllocationPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_allocation_config") - @ExcludeMissing - private val groupedAllocationConfig: JsonField = - JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - fun groupedAllocationConfig(): GroupedAllocationConfig = - groupedAllocationConfig.getRequired("grouped_allocation_config") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - @JsonProperty("grouped_allocation_config") - @ExcludeMissing - fun _groupedAllocationConfig(): JsonField = - groupedAllocationConfig - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionGroupedAllocationPrice = apply { - if (validated) { - return@apply - } - - cadence() - groupedAllocationConfig().validate() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionGroupedAllocationPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var groupedAllocationConfig: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var 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 currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionGroupedAllocationPrice: NewSubscriptionGroupedAllocationPrice - ) = apply { - cadence = newSubscriptionGroupedAllocationPrice.cadence - groupedAllocationConfig = - newSubscriptionGroupedAllocationPrice.groupedAllocationConfig - itemId = newSubscriptionGroupedAllocationPrice.itemId - modelType = newSubscriptionGroupedAllocationPrice.modelType - name = newSubscriptionGroupedAllocationPrice.name - billableMetricId = newSubscriptionGroupedAllocationPrice.billableMetricId - billedInAdvance = newSubscriptionGroupedAllocationPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionGroupedAllocationPrice.billingCycleConfiguration - conversionRate = newSubscriptionGroupedAllocationPrice.conversionRate - currency = newSubscriptionGroupedAllocationPrice.currency - externalPriceId = newSubscriptionGroupedAllocationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionGroupedAllocationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionGroupedAllocationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionGroupedAllocationPrice.invoicingCycleConfiguration - metadata = newSubscriptionGroupedAllocationPrice.metadata - referenceId = newSubscriptionGroupedAllocationPrice.referenceId - additionalProperties = - newSubscriptionGroupedAllocationPrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = - groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) - - fun groupedAllocationConfig( - groupedAllocationConfig: JsonField - ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionGroupedAllocationPrice = - NewSubscriptionGroupedAllocationPrice( - checkRequired("cadence", cadence), - checkRequired("groupedAllocationConfig", groupedAllocationConfig), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class GroupedAllocationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): GroupedAllocationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [GroupedAllocationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(groupedAllocationConfig: GroupedAllocationConfig) = - apply { - additionalProperties = - groupedAllocationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): GroupedAllocationConfig = - GroupedAllocationConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GroupedAllocationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedAllocationConfig{additionalProperties=$additionalProperties}" - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val GROUPED_ALLOCATION = of("grouped_allocation") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_ALLOCATION - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GROUPED_ALLOCATION, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GROUPED_ALLOCATION -> Value.GROUPED_ALLOCATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - GROUPED_ALLOCATION -> Known.GROUPED_ALLOCATION - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionGroupedAllocationPrice && cadence == other.cadence && groupedAllocationConfig == other.groupedAllocationConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, groupedAllocationConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionGroupedAllocationPrice{cadence=$cadence, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionGroupedWithProratedMinimumPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_prorated_minimum_config") - @ExcludeMissing - private val groupedWithProratedMinimumConfig: - JsonField = - JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - fun groupedWithProratedMinimumConfig(): GroupedWithProratedMinimumConfig = - groupedWithProratedMinimumConfig.getRequired( - "grouped_with_prorated_minimum_config" - ) - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - @JsonProperty("grouped_with_prorated_minimum_config") - @ExcludeMissing - fun _groupedWithProratedMinimumConfig(): - JsonField = groupedWithProratedMinimumConfig - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionGroupedWithProratedMinimumPrice = apply { - if (validated) { - return@apply - } - - cadence() - groupedWithProratedMinimumConfig().validate() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionGroupedWithProratedMinimumPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var groupedWithProratedMinimumConfig: - JsonField? = - null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionGroupedWithProratedMinimumPrice: - NewSubscriptionGroupedWithProratedMinimumPrice - ) = apply { - cadence = newSubscriptionGroupedWithProratedMinimumPrice.cadence - groupedWithProratedMinimumConfig = - newSubscriptionGroupedWithProratedMinimumPrice - .groupedWithProratedMinimumConfig - itemId = newSubscriptionGroupedWithProratedMinimumPrice.itemId - modelType = newSubscriptionGroupedWithProratedMinimumPrice.modelType - name = newSubscriptionGroupedWithProratedMinimumPrice.name - billableMetricId = - newSubscriptionGroupedWithProratedMinimumPrice.billableMetricId - billedInAdvance = - newSubscriptionGroupedWithProratedMinimumPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionGroupedWithProratedMinimumPrice.billingCycleConfiguration - conversionRate = - newSubscriptionGroupedWithProratedMinimumPrice.conversionRate - currency = newSubscriptionGroupedWithProratedMinimumPrice.currency - externalPriceId = - newSubscriptionGroupedWithProratedMinimumPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionGroupedWithProratedMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionGroupedWithProratedMinimumPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionGroupedWithProratedMinimumPrice - .invoicingCycleConfiguration - metadata = newSubscriptionGroupedWithProratedMinimumPrice.metadata - referenceId = newSubscriptionGroupedWithProratedMinimumPrice.referenceId - additionalProperties = - newSubscriptionGroupedWithProratedMinimumPrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - fun groupedWithProratedMinimumConfig( - groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig - ) = - groupedWithProratedMinimumConfig( - JsonField.of(groupedWithProratedMinimumConfig) - ) - - fun groupedWithProratedMinimumConfig( - groupedWithProratedMinimumConfig: - JsonField - ) = apply { - this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig - } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionGroupedWithProratedMinimumPrice = - NewSubscriptionGroupedWithProratedMinimumPrice( - checkRequired("cadence", cadence), - checkRequired( - "groupedWithProratedMinimumConfig", - groupedWithProratedMinimumConfig, - ), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class GroupedWithProratedMinimumConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): GroupedWithProratedMinimumConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [GroupedWithProratedMinimumConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig - ) = apply { - additionalProperties = - groupedWithProratedMinimumConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): GroupedWithProratedMinimumConfig = - GroupedWithProratedMinimumConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GroupedWithProratedMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedWithProratedMinimumConfig{additionalProperties=$additionalProperties}" - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField - val GROUPED_WITH_PRORATED_MINIMUM = of("grouped_with_prorated_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_WITH_PRORATED_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GROUPED_WITH_PRORATED_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GROUPED_WITH_PRORATED_MINIMUM -> Value.GROUPED_WITH_PRORATED_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - GROUPED_WITH_PRORATED_MINIMUM -> Known.GROUPED_WITH_PRORATED_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionGroupedWithProratedMinimumPrice && cadence == other.cadence && groupedWithProratedMinimumConfig == other.groupedWithProratedMinimumConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, groupedWithProratedMinimumConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionGroupedWithProratedMinimumPrice{cadence=$cadence, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionBulkWithProrationPrice - @JsonCreator - private constructor( - @JsonProperty("bulk_with_proration_config") - @ExcludeMissing - private val bulkWithProrationConfig: JsonField = - JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun bulkWithProrationConfig(): BulkWithProrationConfig = - bulkWithProrationConfig.getRequired("bulk_with_proration_config") - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - @JsonProperty("bulk_with_proration_config") - @ExcludeMissing - fun _bulkWithProrationConfig(): JsonField = - bulkWithProrationConfig - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionBulkWithProrationPrice = apply { - if (validated) { - return@apply - } - - bulkWithProrationConfig().validate() - cadence() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionBulkWithProrationPrice]. */ - class Builder internal constructor() { - - private var bulkWithProrationConfig: JsonField? = null - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var 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 currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionBulkWithProrationPrice: NewSubscriptionBulkWithProrationPrice - ) = apply { - bulkWithProrationConfig = - newSubscriptionBulkWithProrationPrice.bulkWithProrationConfig - cadence = newSubscriptionBulkWithProrationPrice.cadence - itemId = newSubscriptionBulkWithProrationPrice.itemId - modelType = newSubscriptionBulkWithProrationPrice.modelType - name = newSubscriptionBulkWithProrationPrice.name - billableMetricId = newSubscriptionBulkWithProrationPrice.billableMetricId - billedInAdvance = newSubscriptionBulkWithProrationPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionBulkWithProrationPrice.billingCycleConfiguration - conversionRate = newSubscriptionBulkWithProrationPrice.conversionRate - currency = newSubscriptionBulkWithProrationPrice.currency - externalPriceId = newSubscriptionBulkWithProrationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionBulkWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionBulkWithProrationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionBulkWithProrationPrice.invoicingCycleConfiguration - metadata = newSubscriptionBulkWithProrationPrice.metadata - referenceId = newSubscriptionBulkWithProrationPrice.referenceId - additionalProperties = - newSubscriptionBulkWithProrationPrice.additionalProperties - .toMutableMap() - } - - fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = - bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) - - fun bulkWithProrationConfig( - bulkWithProrationConfig: JsonField - ) = apply { this.bulkWithProrationConfig = bulkWithProrationConfig } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionBulkWithProrationPrice = - NewSubscriptionBulkWithProrationPrice( - checkRequired("bulkWithProrationConfig", bulkWithProrationConfig), - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BulkWithProrationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BulkWithProrationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkWithProrationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(bulkWithProrationConfig: BulkWithProrationConfig) = - apply { - additionalProperties = - bulkWithProrationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): BulkWithProrationConfig = - BulkWithProrationConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BulkWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkWithProrationConfig{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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val BULK_WITH_PRORATION = of("bulk_with_proration") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK_WITH_PRORATION - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK_WITH_PRORATION, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK_WITH_PRORATION -> Value.BULK_WITH_PRORATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - BULK_WITH_PRORATION -> Known.BULK_WITH_PRORATION - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionBulkWithProrationPrice && bulkWithProrationConfig == other.bulkWithProrationConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bulkWithProrationConfig, cadence, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionBulkWithProrationPrice{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ReplacePrice && replacesPriceId == other.replacesPriceId && allocationPrice == other.allocationPrice && discounts == other.discounts && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && maximumAmount == other.maximumAmount && minimumAmount == other.minimumAmount && price == other.price && priceId == other.priceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(replacesPriceId, allocationPrice, discounts, externalPriceId, fixedPriceQuantity, maximumAmount, minimumAmount, price, priceId, additionalProperties) } - /* spotless:on */ - - 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}" + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateResponse.kt deleted file mode 100644 index 37bc79eee..000000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateResponse.kt +++ /dev/null @@ -1,7163 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer -import com.withorb.api.core.Enum -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow -import com.withorb.api.core.immutableEmptyMap -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -@NoAutoDetect -class SubscriptionCreateResponse -@JsonCreator -private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("active_plan_phase_order") - @ExcludeMissing - private val activePlanPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_intervals") - @ExcludeMissing - private val adjustmentIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("auto_collection") - @ExcludeMissing - private val autoCollection: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_anchor_configuration") - @ExcludeMissing - private val billingCycleAnchorConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("billing_cycle_day") - @ExcludeMissing - private val billingCycleDay: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - private val currentBillingPeriodEndDate: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - private val currentBillingPeriodStartDate: JsonField = JsonMissing.of(), - @JsonProperty("customer") - @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), - @JsonProperty("default_invoice_memo") - @ExcludeMissing - private val defaultInvoiceMemo: JsonField = JsonMissing.of(), - @JsonProperty("discount_intervals") - @ExcludeMissing - private val discountIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("fixed_fee_quantity_schedule") - @ExcludeMissing - private val fixedFeeQuantitySchedule: JsonField> = - JsonMissing.of(), - @JsonProperty("invoicing_threshold") - @ExcludeMissing - private val invoicingThreshold: JsonField = JsonMissing.of(), - @JsonProperty("maximum_intervals") - @ExcludeMissing - private val maximumIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("minimum_intervals") - @ExcludeMissing - private val minimumIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("net_terms") - @ExcludeMissing - private val netTerms: JsonField = JsonMissing.of(), - @JsonProperty("plan") @ExcludeMissing private val plan: JsonField = JsonMissing.of(), - @JsonProperty("price_intervals") - @ExcludeMissing - private val priceIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("redeemed_coupon") - @ExcludeMissing - private val redeemedCoupon: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonProperty("status") - @ExcludeMissing - private val status: JsonField = JsonMissing.of(), - @JsonProperty("trial_info") - @ExcludeMissing - private val trialInfo: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun id(): String = id.getRequired("id") - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(): Optional = - Optional.ofNullable(activePlanPhaseOrder.getNullable("active_plan_phase_order")) - - /** The adjustment intervals for this subscription. */ - fun adjustmentIntervals(): List = - adjustmentIntervals.getRequired("adjustment_intervals") - - /** - * Determines whether issued invoices for this subscription will automatically be charged with - * the saved payment method on the due date. This property defaults to the plan's behavior. If - * null, defaults to the customer's setting. - */ - fun autoCollection(): Optional = - Optional.ofNullable(autoCollection.getNullable("auto_collection")) - - fun billingCycleAnchorConfiguration(): BillingCycleAnchorConfiguration = - billingCycleAnchorConfiguration.getRequired("billing_cycle_anchor_configuration") - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of days in - * a month is greater than this value, the last day of the month is the billing cycle day (e.g. - * billing_cycle_day=31 for April means the billing period begins on the 30th. - */ - fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the instant - * returned is not part of the billing period. Set to null for subscriptions that are not - * currently active. - */ - fun currentBillingPeriodEndDate(): Optional = - Optional.ofNullable( - currentBillingPeriodEndDate.getNullable("current_billing_period_end_date") - ) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription is - * not currently active. - */ - fun currentBillingPeriodStartDate(): Optional = - Optional.ofNullable( - currentBillingPeriodStartDate.getNullable("current_billing_period_start_date") - ) - - /** - * 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 customer(): Customer = customer.getRequired("customer") - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(): Optional = - Optional.ofNullable(defaultInvoiceMemo.getNullable("default_invoice_memo")) - - /** The discount intervals for this subscription. */ - fun discountIntervals(): List = - discountIntervals.getRequired("discount_intervals") - - /** The date Orb stops billing for this subscription. */ - fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) - - fun fixedFeeQuantitySchedule(): List = - fixedFeeQuantitySchedule.getRequired("fixed_fee_quantity_schedule") - - fun invoicingThreshold(): Optional = - Optional.ofNullable(invoicingThreshold.getNullable("invoicing_threshold")) - - /** The maximum intervals for this subscription. */ - fun maximumIntervals(): List = - maximumIntervals.getRequired("maximum_intervals") - - /** - * 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.getRequired("metadata") - - /** The minimum intervals for this subscription. */ - fun minimumIntervals(): List = - minimumIntervals.getRequired("minimum_intervals") - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - fun netTerms(): Long = netTerms.getRequired("net_terms") - - /** - * 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 plan(): Plan = plan.getRequired("plan") - - /** The price intervals for this subscription. */ - fun priceIntervals(): List = priceIntervals.getRequired("price_intervals") - - fun redeemedCoupon(): Optional = - Optional.ofNullable(redeemedCoupon.getNullable("redeemed_coupon")) - - /** The date Orb starts billing for this subscription. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - fun status(): Status = status.getRequired("status") - - fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - @JsonProperty("active_plan_phase_order") - @ExcludeMissing - fun _activePlanPhaseOrder(): JsonField = activePlanPhaseOrder - - /** The adjustment intervals for this subscription. */ - @JsonProperty("adjustment_intervals") - @ExcludeMissing - fun _adjustmentIntervals(): JsonField> = adjustmentIntervals - - /** - * Determines whether issued invoices for this subscription will automatically be charged with - * the saved payment method on the due date. This property defaults to the plan's behavior. If - * null, defaults to the customer's setting. - */ - @JsonProperty("auto_collection") - @ExcludeMissing - fun _autoCollection(): JsonField = autoCollection - - @JsonProperty("billing_cycle_anchor_configuration") - @ExcludeMissing - fun _billingCycleAnchorConfiguration(): JsonField = - billingCycleAnchorConfiguration - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of days in - * a month is greater than this value, the last day of the month is the billing cycle day (e.g. - * billing_cycle_day=31 for April means the billing period begins on the 30th. - */ - @JsonProperty("billing_cycle_day") - @ExcludeMissing - fun _billingCycleDay(): JsonField = billingCycleDay - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the instant - * returned is not part of the billing period. Set to null for subscriptions that are not - * currently active. - */ - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription is - * not currently active. - */ - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - fun _currentBillingPeriodStartDate(): JsonField = currentBillingPeriodStartDate - - /** - * 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. - */ - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - @JsonProperty("default_invoice_memo") - @ExcludeMissing - fun _defaultInvoiceMemo(): JsonField = defaultInvoiceMemo - - /** The discount intervals for this subscription. */ - @JsonProperty("discount_intervals") - @ExcludeMissing - fun _discountIntervals(): JsonField> = discountIntervals - - /** The date Orb stops billing for this subscription. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate - - @JsonProperty("fixed_fee_quantity_schedule") - @ExcludeMissing - fun _fixedFeeQuantitySchedule(): JsonField> = - fixedFeeQuantitySchedule - - @JsonProperty("invoicing_threshold") - @ExcludeMissing - fun _invoicingThreshold(): JsonField = invoicingThreshold - - /** The maximum intervals for this subscription. */ - @JsonProperty("maximum_intervals") - @ExcludeMissing - fun _maximumIntervals(): JsonField> = maximumIntervals - - /** - * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - /** The minimum intervals for this subscription. */ - @JsonProperty("minimum_intervals") - @ExcludeMissing - fun _minimumIntervals(): JsonField> = minimumIntervals - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms - - /** - * 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). - */ - @JsonProperty("plan") @ExcludeMissing fun _plan(): JsonField = plan - - /** The price intervals for this subscription. */ - @JsonProperty("price_intervals") - @ExcludeMissing - fun _priceIntervals(): JsonField> = priceIntervals - - @JsonProperty("redeemed_coupon") - @ExcludeMissing - fun _redeemedCoupon(): JsonField = redeemedCoupon - - /** The date Orb starts billing for this subscription. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo(): JsonField = trialInfo - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): SubscriptionCreateResponse = apply { - if (validated) { - return@apply - } - - id() - activePlanPhaseOrder() - adjustmentIntervals().forEach { it.validate() } - autoCollection() - billingCycleAnchorConfiguration().validate() - billingCycleDay() - createdAt() - currentBillingPeriodEndDate() - currentBillingPeriodStartDate() - customer().validate() - defaultInvoiceMemo() - discountIntervals().forEach { it.validate() } - endDate() - fixedFeeQuantitySchedule().forEach { it.validate() } - invoicingThreshold() - maximumIntervals().forEach { it.validate() } - metadata().validate() - minimumIntervals().forEach { it.validate() } - netTerms() - plan().validate() - priceIntervals().forEach { it.validate() } - redeemedCoupon().ifPresent { it.validate() } - startDate() - status() - trialInfo().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SubscriptionCreateResponse]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var activePlanPhaseOrder: JsonField? = null - private var adjustmentIntervals: JsonField>? = null - private var autoCollection: JsonField? = null - private var billingCycleAnchorConfiguration: JsonField? = - null - private var billingCycleDay: JsonField? = null - private var createdAt: JsonField? = null - private var currentBillingPeriodEndDate: JsonField? = null - private var currentBillingPeriodStartDate: JsonField? = null - private var customer: JsonField? = null - private var defaultInvoiceMemo: JsonField? = null - private var discountIntervals: JsonField>? = null - private var endDate: JsonField? = null - private var fixedFeeQuantitySchedule: JsonField>? = - null - private var invoicingThreshold: JsonField? = null - private var maximumIntervals: JsonField>? = null - private var metadata: JsonField? = null - private var minimumIntervals: JsonField>? = null - private var netTerms: JsonField? = null - private var plan: JsonField? = null - private var priceIntervals: JsonField>? = null - private var redeemedCoupon: JsonField? = null - private var startDate: JsonField? = null - private var status: JsonField? = null - private var trialInfo: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(subscriptionCreateResponse: SubscriptionCreateResponse) = apply { - id = subscriptionCreateResponse.id - activePlanPhaseOrder = subscriptionCreateResponse.activePlanPhaseOrder - adjustmentIntervals = - subscriptionCreateResponse.adjustmentIntervals.map { it.toMutableList() } - autoCollection = subscriptionCreateResponse.autoCollection - billingCycleAnchorConfiguration = - subscriptionCreateResponse.billingCycleAnchorConfiguration - billingCycleDay = subscriptionCreateResponse.billingCycleDay - createdAt = subscriptionCreateResponse.createdAt - currentBillingPeriodEndDate = subscriptionCreateResponse.currentBillingPeriodEndDate - currentBillingPeriodStartDate = subscriptionCreateResponse.currentBillingPeriodStartDate - customer = subscriptionCreateResponse.customer - defaultInvoiceMemo = subscriptionCreateResponse.defaultInvoiceMemo - discountIntervals = - subscriptionCreateResponse.discountIntervals.map { it.toMutableList() } - endDate = subscriptionCreateResponse.endDate - fixedFeeQuantitySchedule = - subscriptionCreateResponse.fixedFeeQuantitySchedule.map { it.toMutableList() } - invoicingThreshold = subscriptionCreateResponse.invoicingThreshold - maximumIntervals = - subscriptionCreateResponse.maximumIntervals.map { it.toMutableList() } - metadata = subscriptionCreateResponse.metadata - minimumIntervals = - subscriptionCreateResponse.minimumIntervals.map { it.toMutableList() } - netTerms = subscriptionCreateResponse.netTerms - plan = subscriptionCreateResponse.plan - priceIntervals = subscriptionCreateResponse.priceIntervals.map { it.toMutableList() } - redeemedCoupon = subscriptionCreateResponse.redeemedCoupon - startDate = subscriptionCreateResponse.startDate - status = subscriptionCreateResponse.status - trialInfo = subscriptionCreateResponse.trialInfo - additionalProperties = subscriptionCreateResponse.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(activePlanPhaseOrder: Long?) = - activePlanPhaseOrder(JsonField.ofNullable(activePlanPhaseOrder)) - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(activePlanPhaseOrder: Long) = - activePlanPhaseOrder(activePlanPhaseOrder as Long?) - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun activePlanPhaseOrder(activePlanPhaseOrder: Optional) = - activePlanPhaseOrder(activePlanPhaseOrder.orElse(null) as Long?) - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(activePlanPhaseOrder: JsonField) = apply { - this.activePlanPhaseOrder = activePlanPhaseOrder - } - - /** The adjustment intervals for this subscription. */ - fun adjustmentIntervals(adjustmentIntervals: List) = - adjustmentIntervals(JsonField.of(adjustmentIntervals)) - - /** The adjustment intervals for this subscription. */ - fun adjustmentIntervals(adjustmentIntervals: JsonField>) = apply { - this.adjustmentIntervals = adjustmentIntervals.map { it.toMutableList() } - } - - /** The adjustment intervals for this subscription. */ - fun addAdjustmentInterval(adjustmentInterval: AdjustmentInterval) = apply { - adjustmentIntervals = - (adjustmentIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(adjustmentInterval) - } - } - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - fun autoCollection(autoCollection: Boolean?) = - autoCollection(JsonField.ofNullable(autoCollection)) - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun autoCollection(autoCollection: Optional) = - autoCollection(autoCollection.orElse(null) as Boolean?) - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - fun autoCollection(autoCollection: JsonField) = apply { - this.autoCollection = autoCollection - } - - fun billingCycleAnchorConfiguration( - billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration - ) = billingCycleAnchorConfiguration(JsonField.of(billingCycleAnchorConfiguration)) - - fun billingCycleAnchorConfiguration( - billingCycleAnchorConfiguration: JsonField - ) = apply { this.billingCycleAnchorConfiguration = billingCycleAnchorConfiguration } - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun billingCycleDay(billingCycleDay: Long) = billingCycleDay(JsonField.of(billingCycleDay)) - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun billingCycleDay(billingCycleDay: JsonField) = apply { - this.billingCycleDay = billingCycleDay - } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is not part of the billing period. Set to null for subscriptions that - * are not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = - currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is not part of the billing period. Set to null for subscriptions that - * are not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = - currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is not part of the billing period. Set to null for subscriptions that - * are not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: JsonField) = - apply { - this.currentBillingPeriodEndDate = currentBillingPeriodEndDate - } - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription - * is not currently active. - */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = - currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription - * is not currently active. - */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: Optional) = - currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription - * is not currently active. - */ - fun currentBillingPeriodStartDate( - currentBillingPeriodStartDate: JsonField - ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } - - /** - * 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 customer(customer: Customer) = customer(JsonField.of(customer)) - - /** - * 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 customer(customer: JsonField) = apply { this.customer = customer } - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(defaultInvoiceMemo: String?) = - defaultInvoiceMemo(JsonField.ofNullable(defaultInvoiceMemo)) - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(defaultInvoiceMemo: Optional) = - defaultInvoiceMemo(defaultInvoiceMemo.orElse(null)) - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(defaultInvoiceMemo: JsonField) = apply { - this.defaultInvoiceMemo = defaultInvoiceMemo - } - - /** The discount intervals for this subscription. */ - fun discountIntervals(discountIntervals: List) = - discountIntervals(JsonField.of(discountIntervals)) - - /** The discount intervals for this subscription. */ - fun discountIntervals(discountIntervals: JsonField>) = apply { - this.discountIntervals = discountIntervals.map { it.toMutableList() } - } - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(discountInterval: DiscountInterval) = apply { - discountIntervals = - (discountIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(discountInterval) - } - } - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(amount: DiscountInterval.AmountDiscountInterval) = - addDiscountInterval(DiscountInterval.ofAmount(amount)) - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(percentage: DiscountInterval.PercentageDiscountInterval) = - addDiscountInterval(DiscountInterval.ofPercentage(percentage)) - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(usage: DiscountInterval.UsageDiscountInterval) = - addDiscountInterval(DiscountInterval.ofUsage(usage)) - - /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - fun fixedFeeQuantitySchedule(fixedFeeQuantitySchedule: List) = - fixedFeeQuantitySchedule(JsonField.of(fixedFeeQuantitySchedule)) - - fun fixedFeeQuantitySchedule( - fixedFeeQuantitySchedule: JsonField> - ) = apply { - this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule.map { it.toMutableList() } - } - - fun addFixedFeeQuantitySchedule(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = - apply { - this.fixedFeeQuantitySchedule = - (this.fixedFeeQuantitySchedule ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(fixedFeeQuantitySchedule) - } - } - - fun invoicingThreshold(invoicingThreshold: String?) = - invoicingThreshold(JsonField.ofNullable(invoicingThreshold)) - - fun invoicingThreshold(invoicingThreshold: Optional) = - invoicingThreshold(invoicingThreshold.orElse(null)) - - fun invoicingThreshold(invoicingThreshold: JsonField) = apply { - this.invoicingThreshold = invoicingThreshold - } - - /** The maximum intervals for this subscription. */ - fun maximumIntervals(maximumIntervals: List) = - maximumIntervals(JsonField.of(maximumIntervals)) - - /** The maximum intervals for this subscription. */ - fun maximumIntervals(maximumIntervals: JsonField>) = apply { - this.maximumIntervals = maximumIntervals.map { it.toMutableList() } - } - - /** The maximum intervals for this subscription. */ - fun addMaximumInterval(maximumInterval: MaximumInterval) = apply { - maximumIntervals = - (maximumIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(maximumInterval) - } - } - - /** - * 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - /** The minimum intervals for this subscription. */ - fun minimumIntervals(minimumIntervals: List) = - minimumIntervals(JsonField.of(minimumIntervals)) - - /** The minimum intervals for this subscription. */ - fun minimumIntervals(minimumIntervals: JsonField>) = apply { - this.minimumIntervals = minimumIntervals.map { it.toMutableList() } - } - - /** The minimum intervals for this subscription. */ - fun addMinimumInterval(minimumInterval: MinimumInterval) = apply { - minimumIntervals = - (minimumIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(minimumInterval) - } - } - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - fun netTerms(netTerms: Long) = netTerms(JsonField.of(netTerms)) - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } - - /** - * 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 plan(plan: Plan) = plan(JsonField.of(plan)) - - /** - * 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 plan(plan: JsonField) = apply { this.plan = plan } - - /** The price intervals for this subscription. */ - fun priceIntervals(priceIntervals: List) = - priceIntervals(JsonField.of(priceIntervals)) - - /** The price intervals for this subscription. */ - fun priceIntervals(priceIntervals: JsonField>) = apply { - this.priceIntervals = priceIntervals.map { it.toMutableList() } - } - - /** The price intervals for this subscription. */ - fun addPriceInterval(priceInterval: PriceInterval) = apply { - priceIntervals = - (priceIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(priceInterval) - } - } - - fun redeemedCoupon(redeemedCoupon: RedeemedCoupon?) = - redeemedCoupon(JsonField.ofNullable(redeemedCoupon)) - - fun redeemedCoupon(redeemedCoupon: Optional) = - redeemedCoupon(redeemedCoupon.orElse(null)) - - fun redeemedCoupon(redeemedCoupon: JsonField) = apply { - this.redeemedCoupon = redeemedCoupon - } - - /** The date Orb starts billing for this subscription. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The date Orb starts billing for this subscription. */ - fun startDate(startDate: JsonField) = apply { this.startDate = startDate } - - fun status(status: Status) = status(JsonField.of(status)) - - fun status(status: JsonField) = apply { this.status = status } - - fun trialInfo(trialInfo: TrialInfo) = trialInfo(JsonField.of(trialInfo)) - - fun trialInfo(trialInfo: JsonField) = apply { this.trialInfo = trialInfo } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): SubscriptionCreateResponse = - SubscriptionCreateResponse( - checkRequired("id", id), - checkRequired("activePlanPhaseOrder", activePlanPhaseOrder), - checkRequired("adjustmentIntervals", adjustmentIntervals).map { it.toImmutable() }, - checkRequired("autoCollection", autoCollection), - checkRequired("billingCycleAnchorConfiguration", billingCycleAnchorConfiguration), - checkRequired("billingCycleDay", billingCycleDay), - checkRequired("createdAt", createdAt), - checkRequired("currentBillingPeriodEndDate", currentBillingPeriodEndDate), - checkRequired("currentBillingPeriodStartDate", currentBillingPeriodStartDate), - checkRequired("customer", customer), - checkRequired("defaultInvoiceMemo", defaultInvoiceMemo), - checkRequired("discountIntervals", discountIntervals).map { it.toImmutable() }, - checkRequired("endDate", endDate), - checkRequired("fixedFeeQuantitySchedule", fixedFeeQuantitySchedule).map { - it.toImmutable() - }, - checkRequired("invoicingThreshold", invoicingThreshold), - checkRequired("maximumIntervals", maximumIntervals).map { it.toImmutable() }, - checkRequired("metadata", metadata), - checkRequired("minimumIntervals", minimumIntervals).map { it.toImmutable() }, - checkRequired("netTerms", netTerms), - checkRequired("plan", plan), - checkRequired("priceIntervals", priceIntervals).map { it.toImmutable() }, - checkRequired("redeemedCoupon", redeemedCoupon), - checkRequired("startDate", startDate), - checkRequired("status", status), - checkRequired("trialInfo", trialInfo), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class AdjustmentInterval - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment") - @ExcludeMissing - private val adjustment: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") - - /** The price interval IDs that this adjustment applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - /** The end date of the adjustment interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** The start date of the adjustment interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment - - /** The price interval IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - /** The end date of the adjustment interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** The start date of the adjustment interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AdjustmentInterval = apply { - if (validated) { - return@apply - } - - id() - adjustment().validate() - appliesToPriceIntervalIds() - endDate() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AdjustmentInterval]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustment: JsonField? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(adjustmentInterval: AdjustmentInterval) = apply { - id = adjustmentInterval.id - adjustment = adjustmentInterval.adjustment - appliesToPriceIntervalIds = - adjustmentInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - endDate = adjustmentInterval.endDate - startDate = adjustmentInterval.startDate - additionalProperties = adjustmentInterval.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) - - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } - - fun adjustment(planPhaseUsageDiscount: Adjustment.PlanPhaseUsageDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)) - - fun adjustment(planPhaseAmountDiscount: Adjustment.PlanPhaseAmountDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)) - - fun adjustment( - planPhasePercentageDiscount: Adjustment.PlanPhasePercentageDiscountAdjustment - ) = adjustment(Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)) - - fun adjustment(planPhaseMinimum: Adjustment.PlanPhaseMinimumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)) - - fun adjustment(planPhaseMaximum: Adjustment.PlanPhaseMaximumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)) - - /** The price interval IDs that this adjustment applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval IDs that this adjustment applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval IDs that this adjustment applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - /** The end date of the adjustment interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the adjustment interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the adjustment interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** The start date of the adjustment interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the adjustment interval. */ - 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) - } - - fun build(): AdjustmentInterval = - AdjustmentInterval( - checkRequired("id", id), - checkRequired("adjustment", adjustment), - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment? = null, - private val planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment? = null, - private val planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment? = null, - private val planPhaseMinimum: PlanPhaseMinimumAdjustment? = null, - private val planPhaseMaximum: PlanPhaseMaximumAdjustment? = null, - private val _json: JsonValue? = null, - ) { - - fun planPhaseUsageDiscount(): Optional = - Optional.ofNullable(planPhaseUsageDiscount) - - fun planPhaseAmountDiscount(): Optional = - Optional.ofNullable(planPhaseAmountDiscount) - - fun planPhasePercentageDiscount(): Optional = - Optional.ofNullable(planPhasePercentageDiscount) - - fun planPhaseMinimum(): Optional = - Optional.ofNullable(planPhaseMinimum) - - fun planPhaseMaximum(): Optional = - Optional.ofNullable(planPhaseMaximum) - - fun isPlanPhaseUsageDiscount(): Boolean = planPhaseUsageDiscount != null - - fun isPlanPhaseAmountDiscount(): Boolean = planPhaseAmountDiscount != null - - fun isPlanPhasePercentageDiscount(): Boolean = planPhasePercentageDiscount != null - - fun isPlanPhaseMinimum(): Boolean = planPhaseMinimum != null - - fun isPlanPhaseMaximum(): Boolean = planPhaseMaximum != null - - fun asPlanPhaseUsageDiscount(): PlanPhaseUsageDiscountAdjustment = - planPhaseUsageDiscount.getOrThrow("planPhaseUsageDiscount") - - fun asPlanPhaseAmountDiscount(): PlanPhaseAmountDiscountAdjustment = - planPhaseAmountDiscount.getOrThrow("planPhaseAmountDiscount") - - fun asPlanPhasePercentageDiscount(): PlanPhasePercentageDiscountAdjustment = - planPhasePercentageDiscount.getOrThrow("planPhasePercentageDiscount") - - fun asPlanPhaseMinimum(): PlanPhaseMinimumAdjustment = - planPhaseMinimum.getOrThrow("planPhaseMinimum") - - fun asPlanPhaseMaximum(): PlanPhaseMaximumAdjustment = - planPhaseMaximum.getOrThrow("planPhaseMaximum") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - planPhaseUsageDiscount != null -> - visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) - planPhaseAmountDiscount != null -> - visitor.visitPlanPhaseAmountDiscount(planPhaseAmountDiscount) - planPhasePercentageDiscount != null -> - visitor.visitPlanPhasePercentageDiscount(planPhasePercentageDiscount) - planPhaseMinimum != null -> visitor.visitPlanPhaseMinimum(planPhaseMinimum) - planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) { - planPhaseUsageDiscount.validate() - } - - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) { - planPhaseAmountDiscount.validate() - } - - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) { - planPhasePercentageDiscount.validate() - } - - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) { - planPhaseMinimum.validate() - } - - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) { - planPhaseMaximum.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Adjustment && planPhaseUsageDiscount == other.planPhaseUsageDiscount && planPhaseAmountDiscount == other.planPhaseAmountDiscount && planPhasePercentageDiscount == other.planPhasePercentageDiscount && planPhaseMinimum == other.planPhaseMinimum && planPhaseMaximum == other.planPhaseMaximum /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(planPhaseUsageDiscount, planPhaseAmountDiscount, planPhasePercentageDiscount, planPhaseMinimum, planPhaseMaximum) /* spotless:on */ - - override fun toString(): String = - when { - planPhaseUsageDiscount != null -> - "Adjustment{planPhaseUsageDiscount=$planPhaseUsageDiscount}" - planPhaseAmountDiscount != null -> - "Adjustment{planPhaseAmountDiscount=$planPhaseAmountDiscount}" - planPhasePercentageDiscount != null -> - "Adjustment{planPhasePercentageDiscount=$planPhasePercentageDiscount}" - planPhaseMinimum != null -> "Adjustment{planPhaseMinimum=$planPhaseMinimum}" - planPhaseMaximum != null -> "Adjustment{planPhaseMaximum=$planPhaseMaximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } - - companion object { - - @JvmStatic - fun ofPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = Adjustment(planPhaseUsageDiscount = planPhaseUsageDiscount) - - @JvmStatic - fun ofPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = Adjustment(planPhaseAmountDiscount = planPhaseAmountDiscount) - - @JvmStatic - fun ofPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = Adjustment(planPhasePercentageDiscount = planPhasePercentageDiscount) - - @JvmStatic - fun ofPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment) = - Adjustment(planPhaseMinimum = planPhaseMinimum) - - @JvmStatic - fun ofPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment) = - Adjustment(planPhaseMaximum = planPhaseMaximum) - } - - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { - - fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ): T - - fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ): T - - fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ): T - - fun visitPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment): T - - fun visitPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment): T - - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } - - internal class Deserializer : BaseDeserializer(Adjustment::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = - json.asObject().getOrNull()?.get("adjustment_type")?.asString()?.getOrNull() - - when (adjustmentType) { - "usage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseUsageDiscount = it, _json = json) - } - } - "amount_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseAmountDiscount = it, _json = json) - } - } - "percentage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment( - planPhasePercentageDiscount = it, - _json = json, - ) - } - } - "minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMinimum = it, _json = json) - } - } - "maximum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMaximum = it, _json = json) - } - } - } - - return Adjustment(_json = json) - } - } - - internal class Serializer : BaseSerializer(Adjustment::class) { - - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.planPhaseUsageDiscount != null -> - generator.writeObject(value.planPhaseUsageDiscount) - value.planPhaseAmountDiscount != null -> - generator.writeObject(value.planPhaseAmountDiscount) - value.planPhasePercentageDiscount != null -> - generator.writeObject(value.planPhasePercentageDiscount) - value.planPhaseMinimum != null -> - generator.writeObject(value.planPhaseMinimum) - value.planPhaseMaximum != null -> - generator.writeObject(value.planPhaseMaximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") - } - } - } - - @NoAutoDetect - class PlanPhaseUsageDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonProperty("usage_discount") - @ExcludeMissing - private val usageDiscount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - /** - * The number of usage units by which to discount the price this adjustment applies - * to in a given billing period. - */ - fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - /** - * The number of usage units by which to discount the price this adjustment applies - * to in a given billing period. - */ - @JsonProperty("usage_discount") - @ExcludeMissing - fun _usageDiscount(): JsonField = usageDiscount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseUsageDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - planPhaseOrder() - reason() - usageDiscount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseUsageDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var usageDiscount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - planPhaseUsageDiscountAdjustment: PlanPhaseUsageDiscountAdjustment - ) = apply { - id = planPhaseUsageDiscountAdjustment.id - adjustmentType = planPhaseUsageDiscountAdjustment.adjustmentType - appliesToPriceIds = - planPhaseUsageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseUsageDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseUsageDiscountAdjustment.planPhaseOrder - reason = planPhaseUsageDiscountAdjustment.reason - usageDiscount = planPhaseUsageDiscountAdjustment.usageDiscount - additionalProperties = - planPhaseUsageDiscountAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - /** - * The number of usage units by which to discount the price this adjustment - * applies to in a given billing period. - */ - fun usageDiscount(usageDiscount: Double) = - usageDiscount(JsonField.of(usageDiscount)) - - /** - * The number of usage units by which to discount the price this adjustment - * applies to in a given billing period. - */ - fun usageDiscount(usageDiscount: JsonField) = apply { - this.usageDiscount = usageDiscount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseUsageDiscountAdjustment = - PlanPhaseUsageDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - checkRequired("usageDiscount", usageDiscount), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - USAGE_DISCOUNT -> Known.USAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseUsageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, planPhaseOrder, reason, usageDiscount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseUsageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhaseAmountDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("amount_discount") - @ExcludeMissing - private val amountDiscount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** - * The amount by which to discount the prices this adjustment applies to in a given - * billing period. - */ - fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** - * The amount by which to discount the prices this adjustment applies to in a given - * billing period. - */ - @JsonProperty("amount_discount") - @ExcludeMissing - fun _amountDiscount(): JsonField = amountDiscount - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseAmountDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - amountDiscount() - appliesToPriceIds() - isInvoiceLevel() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseAmountDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var amountDiscount: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - planPhaseAmountDiscountAdjustment: PlanPhaseAmountDiscountAdjustment - ) = apply { - id = planPhaseAmountDiscountAdjustment.id - adjustmentType = planPhaseAmountDiscountAdjustment.adjustmentType - amountDiscount = planPhaseAmountDiscountAdjustment.amountDiscount - appliesToPriceIds = - planPhaseAmountDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseAmountDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseAmountDiscountAdjustment.planPhaseOrder - reason = planPhaseAmountDiscountAdjustment.reason - additionalProperties = - planPhaseAmountDiscountAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** - * The amount by which to discount the prices this adjustment applies to in a - * given billing period. - */ - fun amountDiscount(amountDiscount: String) = - amountDiscount(JsonField.of(amountDiscount)) - - /** - * The amount by which to discount the prices this adjustment applies to in a - * given billing period. - */ - fun amountDiscount(amountDiscount: JsonField) = apply { - this.amountDiscount = amountDiscount - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseAmountDiscountAdjustment = - PlanPhaseAmountDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("amountDiscount", amountDiscount), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseAmountDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, amountDiscount, appliesToPriceIds, isInvoiceLevel, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseAmountDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhasePercentageDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("percentage_discount") - @ExcludeMissing - private val percentageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(): Double = - percentageDiscount.getRequired("percentage_discount") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - @JsonProperty("percentage_discount") - @ExcludeMissing - fun _percentageDiscount(): JsonField = percentageDiscount - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhasePercentageDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - percentageDiscount() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhasePercentageDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var percentageDiscount: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - planPhasePercentageDiscountAdjustment: PlanPhasePercentageDiscountAdjustment - ) = apply { - id = planPhasePercentageDiscountAdjustment.id - adjustmentType = planPhasePercentageDiscountAdjustment.adjustmentType - appliesToPriceIds = - planPhasePercentageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhasePercentageDiscountAdjustment.isInvoiceLevel - percentageDiscount = - planPhasePercentageDiscountAdjustment.percentageDiscount - planPhaseOrder = planPhasePercentageDiscountAdjustment.planPhaseOrder - reason = planPhasePercentageDiscountAdjustment.reason - additionalProperties = - planPhasePercentageDiscountAdjustment.additionalProperties - .toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(percentageDiscount: Double) = - percentageDiscount(JsonField.of(percentageDiscount)) - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(percentageDiscount: JsonField) = apply { - this.percentageDiscount = percentageDiscount - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhasePercentageDiscountAdjustment = - PlanPhasePercentageDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("percentageDiscount", percentageDiscount), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val PERCENTAGE_DISCOUNT = of("percentage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhasePercentageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, percentageDiscount, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhasePercentageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhaseMinimumAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(): String = itemId.getRequired("item_id") - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The item ID that revenue from this minimum will be attributed to. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseMinimumAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - itemId() - minimumAmount() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseMinimumAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var itemId: JsonField? = null - private var minimumAmount: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(planPhaseMinimumAdjustment: PlanPhaseMinimumAdjustment) = - apply { - id = planPhaseMinimumAdjustment.id - adjustmentType = planPhaseMinimumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMinimumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMinimumAdjustment.isInvoiceLevel - itemId = planPhaseMinimumAdjustment.itemId - minimumAmount = planPhaseMinimumAdjustment.minimumAmount - planPhaseOrder = planPhaseMinimumAdjustment.planPhaseOrder - reason = planPhaseMinimumAdjustment.reason - additionalProperties = - planPhaseMinimumAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseMinimumAdjustment = - PlanPhaseMinimumAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("itemId", itemId), - checkRequired("minimumAmount", minimumAmount), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseMinimumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, itemId, minimumAmount, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseMinimumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhaseMaximumAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseMaximumAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - maximumAmount() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseMaximumAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var maximumAmount: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(planPhaseMaximumAdjustment: PlanPhaseMaximumAdjustment) = - apply { - id = planPhaseMaximumAdjustment.id - adjustmentType = planPhaseMaximumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMaximumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMaximumAdjustment.isInvoiceLevel - maximumAmount = planPhaseMaximumAdjustment.maximumAmount - planPhaseOrder = planPhaseMaximumAdjustment.planPhaseOrder - reason = planPhaseMaximumAdjustment.reason - additionalProperties = - planPhaseMaximumAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseMaximumAdjustment = - PlanPhaseMaximumAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("maximumAmount", maximumAmount), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseMaximumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, maximumAmount, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseMaximumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentInterval && id == other.id && adjustment == other.adjustment && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustment, appliesToPriceIntervalIds, endDate, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AdjustmentInterval{id=$id, adjustment=$adjustment, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BillingCycleAnchorConfiguration - @JsonCreator - private constructor( - @JsonProperty("day") @ExcludeMissing private val day: JsonField = JsonMissing.of(), - @JsonProperty("month") - @ExcludeMissing - private val month: JsonField = JsonMissing.of(), - @JsonProperty("year") @ExcludeMissing private val year: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun day(): Long = day.getRequired("day") - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(): Optional = Optional.ofNullable(month.getNullable("month")) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on - * 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(): Optional = Optional.ofNullable(year.getNullable("year")) - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - @JsonProperty("day") @ExcludeMissing fun _day(): JsonField = day - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - @JsonProperty("month") @ExcludeMissing fun _month(): JsonField = month - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on - * 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - @JsonProperty("year") @ExcludeMissing fun _year(): JsonField = year - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleAnchorConfiguration = apply { - if (validated) { - return@apply - } - - day() - month() - year() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleAnchorConfiguration]. */ - class Builder internal constructor() { - - private var day: JsonField? = null - private var month: JsonField = JsonMissing.of() - private var year: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration) = - apply { - day = billingCycleAnchorConfiguration.day - month = billingCycleAnchorConfiguration.month - year = billingCycleAnchorConfiguration.year - additionalProperties = - billingCycleAnchorConfiguration.additionalProperties.toMutableMap() - } - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun day(day: Long) = day(JsonField.of(day)) - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun day(day: JsonField) = apply { this.day = day } - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(month: Long?) = month(JsonField.ofNullable(month)) - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(month: Long) = month(month as Long?) - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun month(month: Optional) = month(month.orElse(null) as Long?) - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(month: JsonField) = apply { this.month = month } - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(year: Long?) = year(JsonField.ofNullable(year)) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(year: Long) = year(year as Long?) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun year(year: Optional) = year(year.orElse(null) as Long?) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(year: JsonField) = apply { this.year = year } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleAnchorConfiguration = - BillingCycleAnchorConfiguration( - checkRequired("day", day), - month, - year, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleAnchorConfiguration && day == other.day && month == other.month && year == other.year && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(day, month, year, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleAnchorConfiguration{day=$day, month=$month, year=$year, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(using = DiscountInterval.Deserializer::class) - @JsonSerialize(using = DiscountInterval.Serializer::class) - class DiscountInterval - private constructor( - private val amount: AmountDiscountInterval? = null, - private val percentage: PercentageDiscountInterval? = null, - private val usage: UsageDiscountInterval? = null, - private val _json: JsonValue? = null, - ) { - - fun amount(): Optional = Optional.ofNullable(amount) - - fun percentage(): Optional = Optional.ofNullable(percentage) - - fun usage(): Optional = Optional.ofNullable(usage) - - fun isAmount(): Boolean = amount != null - - fun isPercentage(): Boolean = percentage != null - - fun isUsage(): Boolean = usage != null - - fun asAmount(): AmountDiscountInterval = amount.getOrThrow("amount") - - fun asPercentage(): PercentageDiscountInterval = percentage.getOrThrow("percentage") - - fun asUsage(): UsageDiscountInterval = usage.getOrThrow("usage") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - amount != null -> visitor.visitAmount(amount) - percentage != null -> visitor.visitPercentage(percentage) - usage != null -> visitor.visitUsage(usage) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): DiscountInterval = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitAmount(amount: AmountDiscountInterval) { - amount.validate() - } - - override fun visitPercentage(percentage: PercentageDiscountInterval) { - percentage.validate() - } - - override fun visitUsage(usage: UsageDiscountInterval) { - usage.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountInterval && amount == other.amount && percentage == other.percentage && usage == other.usage /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(amount, percentage, usage) /* spotless:on */ - - override fun toString(): String = - when { - amount != null -> "DiscountInterval{amount=$amount}" - percentage != null -> "DiscountInterval{percentage=$percentage}" - usage != null -> "DiscountInterval{usage=$usage}" - _json != null -> "DiscountInterval{_unknown=$_json}" - else -> throw IllegalStateException("Invalid DiscountInterval") - } - - companion object { - - @JvmStatic - fun ofAmount(amount: AmountDiscountInterval) = DiscountInterval(amount = amount) - - @JvmStatic - fun ofPercentage(percentage: PercentageDiscountInterval) = - DiscountInterval(percentage = percentage) - - @JvmStatic fun ofUsage(usage: UsageDiscountInterval) = DiscountInterval(usage = usage) - } - - /** - * An interface that defines how to map each variant of [DiscountInterval] to a value of - * type [T]. - */ - interface Visitor { - - fun visitAmount(amount: AmountDiscountInterval): T - - fun visitPercentage(percentage: PercentageDiscountInterval): T - - fun visitUsage(usage: UsageDiscountInterval): T - - /** - * Maps an unknown variant of [DiscountInterval] to a value of type [T]. - * - * An instance of [DiscountInterval] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown DiscountInterval: $json") - } - } - - internal class Deserializer : BaseDeserializer(DiscountInterval::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): DiscountInterval { - val json = JsonValue.fromJsonNode(node) - val discountType = - json.asObject().getOrNull()?.get("discount_type")?.asString()?.getOrNull() - - when (discountType) { - "amount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(amount = it, _json = json) - } - } - "percentage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(percentage = it, _json = json) - } - } - "usage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(usage = it, _json = json) - } - } - } - - return DiscountInterval(_json = json) - } - } - - internal class Serializer : BaseSerializer(DiscountInterval::class) { - - override fun serialize( - value: DiscountInterval, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.amount != null -> generator.writeObject(value.amount) - value.percentage != null -> generator.writeObject(value.percentage) - value.usage != null -> generator.writeObject(value.usage) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid DiscountInterval") - } - } - } - - @NoAutoDetect - class AmountDiscountInterval - @JsonCreator - private constructor( - @JsonProperty("amount_discount") - @ExcludeMissing - private val amountDiscount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("discount_type") - @ExcludeMissing - private val discountType: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - fun discountType(): DiscountType = discountType.getRequired("discount_type") - - /** The end date of the discount interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** The start date of the discount interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** Only available if discount_type is `amount`. */ - @JsonProperty("amount_discount") - @ExcludeMissing - fun _amountDiscount(): JsonField = amountDiscount - - /** The price ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - - /** The end date of the discount interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** The start date of the discount interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AmountDiscountInterval = apply { - if (validated) { - return@apply - } - - amountDiscount() - appliesToPriceIds() - appliesToPriceIntervalIds() - discountType() - endDate() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AmountDiscountInterval]. */ - class Builder internal constructor() { - - private var amountDiscount: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { - amountDiscount = amountDiscountInterval.amountDiscount - appliesToPriceIds = - amountDiscountInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - amountDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = amountDiscountInterval.discountType - endDate = amountDiscountInterval.endDate - startDate = amountDiscountInterval.startDate - additionalProperties = - amountDiscountInterval.additionalProperties.toMutableMap() - } - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(amountDiscount: String) = - amountDiscount(JsonField.of(amountDiscount)) - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(amountDiscount: JsonField) = apply { - this.amountDiscount = amountDiscount - } - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this discount interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this discount interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the discount interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the discount interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** The start date of the discount interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the discount interval. */ - 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) - } - - fun build(): AmountDiscountInterval = - AmountDiscountInterval( - checkRequired("amountDiscount", amountDiscount), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("discountType", discountType), - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val AMOUNT = of("amount") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - AMOUNT - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT -> Value.AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AMOUNT -> Known.AMOUNT - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AmountDiscountInterval && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amountDiscount, appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AmountDiscountInterval{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PercentageDiscountInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("discount_type") - @ExcludeMissing - private val discountType: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("percentage_discount") - @ExcludeMissing - private val percentageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - fun discountType(): DiscountType = discountType.getRequired("discount_type") - - /** The end date of the discount interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ - fun percentageDiscount(): Double = percentageDiscount.getRequired("percentage_discount") - - /** The start date of the discount interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** The price ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - - /** The end date of the discount interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ - @JsonProperty("percentage_discount") - @ExcludeMissing - fun _percentageDiscount(): JsonField = percentageDiscount - - /** The start date of the discount interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PercentageDiscountInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - discountType() - endDate() - percentageDiscount() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PercentageDiscountInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null - private var endDate: JsonField? = null - private var percentageDiscount: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { - appliesToPriceIds = - percentageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - percentageDiscountInterval.appliesToPriceIntervalIds.map { - it.toMutableList() - } - discountType = percentageDiscountInterval.discountType - endDate = percentageDiscountInterval.endDate - percentageDiscount = percentageDiscountInterval.percentageDiscount - startDate = percentageDiscountInterval.startDate - additionalProperties = - percentageDiscountInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this discount interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this discount interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the discount interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the discount interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** - * Only available if discount_type is `percentage`.This is a number between 0 and 1. - */ - fun percentageDiscount(percentageDiscount: Double) = - percentageDiscount(JsonField.of(percentageDiscount)) - - /** - * Only available if discount_type is `percentage`.This is a number between 0 and 1. - */ - fun percentageDiscount(percentageDiscount: JsonField) = apply { - this.percentageDiscount = percentageDiscount - } - - /** The start date of the discount interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the discount interval. */ - 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) - } - - fun build(): PercentageDiscountInterval = - PercentageDiscountInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("discountType", discountType), - checkRequired("endDate", endDate), - checkRequired("percentageDiscount", percentageDiscount), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val PERCENTAGE = of("percentage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - PERCENTAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE -> Value.PERCENTAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PERCENTAGE -> Known.PERCENTAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PercentageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, percentageDiscount, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PercentageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class UsageDiscountInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("discount_type") - @ExcludeMissing - private val discountType: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonProperty("usage_discount") - @ExcludeMissing - private val usageDiscount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - fun discountType(): DiscountType = discountType.getRequired("discount_type") - - /** The end date of the discount interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** The start date of the discount interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** - * Only available if discount_type is `usage`. Number of usage units that this discount - * is for - */ - fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - - /** The price ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - - /** The end date of the discount interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** The start date of the discount interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - /** - * Only available if discount_type is `usage`. Number of usage units that this discount - * is for - */ - @JsonProperty("usage_discount") - @ExcludeMissing - fun _usageDiscount(): JsonField = usageDiscount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): UsageDiscountInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - discountType() - endDate() - startDate() - usageDiscount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UsageDiscountInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var usageDiscount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { - appliesToPriceIds = - usageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - usageDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = usageDiscountInterval.discountType - endDate = usageDiscountInterval.endDate - startDate = usageDiscountInterval.startDate - usageDiscount = usageDiscountInterval.usageDiscount - additionalProperties = usageDiscountInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this discount interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this discount interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the discount interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the discount interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** The start date of the discount interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the discount interval. */ - fun startDate(startDate: JsonField) = apply { - this.startDate = startDate - } - - /** - * Only available if discount_type is `usage`. Number of usage units that this - * discount is for - */ - fun usageDiscount(usageDiscount: Double) = - usageDiscount(JsonField.of(usageDiscount)) - - /** - * Only available if discount_type is `usage`. Number of usage units that this - * discount is for - */ - fun usageDiscount(usageDiscount: JsonField) = apply { - this.usageDiscount = usageDiscount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): UsageDiscountInterval = - UsageDiscountInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("discountType", discountType), - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - checkRequired("usageDiscount", usageDiscount), - additionalProperties.toImmutable(), - ) - } - - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE = of("usage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - USAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE -> Value.USAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE -> Known.USAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UsageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, startDate, usageDiscount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UsageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" - } - } - - @NoAutoDetect - class FixedFeeQuantitySchedule - @JsonCreator - private constructor( - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("price_id") - @ExcludeMissing - private val priceId: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - private val quantity: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - fun priceId(): String = priceId.getRequired("price_id") - - fun quantity(): Double = quantity.getRequired("quantity") - - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - - @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): FixedFeeQuantitySchedule = apply { - if (validated) { - return@apply - } - - endDate() - priceId() - quantity() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FixedFeeQuantitySchedule]. */ - class Builder internal constructor() { - - private var endDate: JsonField? = null - private var priceId: JsonField? = null - private var quantity: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = apply { - endDate = fixedFeeQuantitySchedule.endDate - priceId = fixedFeeQuantitySchedule.priceId - quantity = fixedFeeQuantitySchedule.quantity - startDate = fixedFeeQuantitySchedule.startDate - additionalProperties = fixedFeeQuantitySchedule.additionalProperties.toMutableMap() - } - - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) - - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - 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) - } - - fun build(): FixedFeeQuantitySchedule = - FixedFeeQuantitySchedule( - checkRequired("endDate", endDate), - checkRequired("priceId", priceId), - checkRequired("quantity", quantity), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FixedFeeQuantitySchedule && endDate == other.endDate && priceId == other.priceId && quantity == other.quantity && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(endDate, priceId, quantity, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "FixedFeeQuantitySchedule{endDate=$endDate, priceId=$priceId, quantity=$quantity, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class MaximumInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this maximum interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this maximum interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - /** The end date of the maximum interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** The start date of the maximum interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** The price ids that this maximum interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this maximum interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - /** The end date of the maximum interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** The start date of the maximum interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MaximumInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - endDate() - maximumAmount() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MaximumInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var endDate: JsonField? = null - private var maximumAmount: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximumInterval: MaximumInterval) = apply { - appliesToPriceIds = maximumInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - maximumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - endDate = maximumInterval.endDate - maximumAmount = maximumInterval.maximumAmount - startDate = maximumInterval.startDate - additionalProperties = maximumInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this maximum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this maximum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this maximum interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this maximum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this maximum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this maximum interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - /** The end date of the maximum interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the maximum interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the maximum interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** The start date of the maximum interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the maximum interval. */ - 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) - } - - fun build(): MaximumInterval = - MaximumInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("endDate", endDate), - checkRequired("maximumAmount", maximumAmount), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MaximumInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && maximumAmount == other.maximumAmount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, endDate, maximumAmount, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MaximumInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, maximumAmount=$maximumAmount, startDate=$startDate, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class MinimumInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this minimum interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this minimum interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - /** The end date of the minimum interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** The start date of the minimum interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** The price ids that this minimum interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this minimum interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - /** The end date of the minimum interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** The start date of the minimum interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MinimumInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - endDate() - minimumAmount() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MinimumInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var endDate: JsonField? = null - private var minimumAmount: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(minimumInterval: MinimumInterval) = apply { - appliesToPriceIds = minimumInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - minimumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - endDate = minimumInterval.endDate - minimumAmount = minimumInterval.minimumAmount - startDate = minimumInterval.startDate - additionalProperties = minimumInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this minimum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this minimum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this minimum interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this minimum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this minimum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this minimum interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - /** The end date of the minimum interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the minimum interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the minimum interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** The start date of the minimum interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the minimum interval. */ - 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) - } - - fun build(): MinimumInterval = - MinimumInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("endDate", endDate), - checkRequired("minimumAmount", minimumAmount), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MinimumInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && minimumAmount == other.minimumAmount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, endDate, minimumAmount, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MinimumInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, minimumAmount=$minimumAmount, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - /** - * The Price Interval resource represents a period of time for which a price will bill on a - * subscription. A subscription’s price intervals define its billing behavior. - */ - @NoAutoDetect - class PriceInterval - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_day") - @ExcludeMissing - private val billingCycleDay: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - private val currentBillingPeriodEndDate: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - private val currentBillingPeriodStartDate: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("filter") - @ExcludeMissing - private val filter: JsonField = JsonMissing.of(), - @JsonProperty("fixed_fee_quantity_transitions") - @ExcludeMissing - private val fixedFeeQuantityTransitions: JsonField> = - JsonMissing.of(), - @JsonProperty("price") - @ExcludeMissing - private val price: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonProperty("usage_customer_ids") - @ExcludeMissing - private val usageCustomerIds: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - /** The day of the month that Orb bills for this price */ - fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate(): Optional = - Optional.ofNullable( - currentBillingPeriodEndDate.getNullable("current_billing_period_end_date") - ) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodStartDate(): Optional = - Optional.ofNullable( - currentBillingPeriodStartDate.getNullable("current_billing_period_start_date") - ) - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** An additional filter to apply to usage queries. */ - fun filter(): Optional = Optional.ofNullable(filter.getNullable("filter")) - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions(): Optional> = - Optional.ofNullable( - fixedFeeQuantityTransitions.getNullable("fixed_fee_quantity_transitions") - ) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting in - * a charge on an invoice in the form of an invoice line item. Prices take a quantity and - * determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the key - * for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(): Price = price.getRequired("price") - - /** - * The start date of the price interval. This is the date that Orb starts billing for this - * price. - */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this price - * interval. - */ - fun usageCustomerIds(): Optional> = - Optional.ofNullable(usageCustomerIds.getNullable("usage_customer_ids")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** The day of the month that Orb bills for this price */ - @JsonProperty("billing_cycle_day") - @ExcludeMissing - fun _billingCycleDay(): JsonField = billingCycleDay - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if this price - * interval is not currently active. - */ - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - fun _currentBillingPeriodStartDate(): JsonField = - currentBillingPeriodStartDate - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** An additional filter to apply to usage queries. */ - @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField = filter - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - @JsonProperty("fixed_fee_quantity_transitions") - @ExcludeMissing - fun _fixedFeeQuantityTransitions(): JsonField> = - fixedFeeQuantityTransitions - - /** - * 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) - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - - /** - * The start date of the price interval. This is the date that Orb starts billing for this - * price. - */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this price - * interval. - */ - @JsonProperty("usage_customer_ids") - @ExcludeMissing - fun _usageCustomerIds(): JsonField> = usageCustomerIds - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PriceInterval = apply { - if (validated) { - return@apply - } - - id() - billingCycleDay() - currentBillingPeriodEndDate() - currentBillingPeriodStartDate() - endDate() - filter() - fixedFeeQuantityTransitions().ifPresent { it.forEach { it.validate() } } - price().validate() - startDate() - usageCustomerIds() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PriceInterval]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var billingCycleDay: JsonField? = null - private var currentBillingPeriodEndDate: JsonField? = null - private var currentBillingPeriodStartDate: JsonField? = null - private var endDate: JsonField? = null - private var filter: JsonField? = null - private var fixedFeeQuantityTransitions: - JsonField>? = - null - private var price: JsonField? = null - private var startDate: JsonField? = null - private var usageCustomerIds: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(priceInterval: PriceInterval) = apply { - id = priceInterval.id - billingCycleDay = priceInterval.billingCycleDay - currentBillingPeriodEndDate = priceInterval.currentBillingPeriodEndDate - currentBillingPeriodStartDate = priceInterval.currentBillingPeriodStartDate - endDate = priceInterval.endDate - filter = priceInterval.filter - fixedFeeQuantityTransitions = - priceInterval.fixedFeeQuantityTransitions.map { it.toMutableList() } - price = priceInterval.price - startDate = priceInterval.startDate - usageCustomerIds = priceInterval.usageCustomerIds.map { it.toMutableList() } - additionalProperties = priceInterval.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - /** The day of the month that Orb bills for this price */ - fun billingCycleDay(billingCycleDay: Long) = - billingCycleDay(JsonField.of(billingCycleDay)) - - /** The day of the month that Orb bills for this price */ - fun billingCycleDay(billingCycleDay: JsonField) = apply { - this.billingCycleDay = billingCycleDay - } - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = - currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = - currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate( - currentBillingPeriodEndDate: JsonField - ) = apply { this.currentBillingPeriodEndDate = currentBillingPeriodEndDate } - - /** - * The start date of the current billing period. This is an inclusive timestamp; the - * instant returned is exactly the beginning of the billing period. Set to null if this - * price interval is not currently active. - */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = - currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the - * instant returned is exactly the beginning of the billing period. Set to null if this - * price interval is not currently active. - */ - fun currentBillingPeriodStartDate( - currentBillingPeriodStartDate: Optional - ) = currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the - * instant returned is exactly the beginning of the billing period. Set to null if this - * price interval is not currently active. - */ - fun currentBillingPeriodStartDate( - currentBillingPeriodStartDate: JsonField - ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** An additional filter to apply to usage queries. */ - fun filter(filter: String?) = filter(JsonField.ofNullable(filter)) - - /** An additional filter to apply to usage queries. */ - fun filter(filter: Optional) = filter(filter.orElse(null)) - - /** An additional filter to apply to usage queries. */ - fun filter(filter: JsonField) = apply { this.filter = filter } - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: List? - ) = fixedFeeQuantityTransitions(JsonField.ofNullable(fixedFeeQuantityTransitions)) - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: Optional> - ) = fixedFeeQuantityTransitions(fixedFeeQuantityTransitions.orElse(null)) - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: JsonField> - ) = apply { - this.fixedFeeQuantityTransitions = - fixedFeeQuantityTransitions.map { it.toMutableList() } - } - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun addFixedFeeQuantityTransition( - fixedFeeQuantityTransition: FixedFeeQuantityTransition - ) = apply { - fixedFeeQuantityTransitions = - (fixedFeeQuantityTransitions ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(fixedFeeQuantityTransition) - } - } - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(price: Price) = price(JsonField.of(price)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(price: JsonField) = apply { this.price = price } - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(matrix: Price.MatrixPrice) = price(Price.ofMatrix(matrix)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredPackage: Price.TieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedTiered: Price.GroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(unitWithPercent: Price.UnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredWithProration: Price.TieredWithProrationPrice) = - price(Price.ofTieredWithProration(tieredWithProration)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(unitWithProration: Price.UnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedAllocation: Price.GroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bulkWithProration: Price.BulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = - price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice) = - price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - - /** - * The start date of the price interval. This is the date that Orb starts billing for - * this price. - */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** - * The start date of the price interval. This is the date that Orb starts billing for - * this price. - */ - fun startDate(startDate: JsonField) = apply { - this.startDate = startDate - } - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun usageCustomerIds(usageCustomerIds: List?) = - usageCustomerIds(JsonField.ofNullable(usageCustomerIds)) - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun usageCustomerIds(usageCustomerIds: Optional>) = - usageCustomerIds(usageCustomerIds.orElse(null)) - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun usageCustomerIds(usageCustomerIds: JsonField>) = apply { - this.usageCustomerIds = usageCustomerIds.map { it.toMutableList() } - } - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun addUsageCustomerId(usageCustomerId: String) = apply { - usageCustomerIds = - (usageCustomerIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(usageCustomerId) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): PriceInterval = - PriceInterval( - checkRequired("id", id), - checkRequired("billingCycleDay", billingCycleDay), - checkRequired("currentBillingPeriodEndDate", currentBillingPeriodEndDate), - checkRequired("currentBillingPeriodStartDate", currentBillingPeriodStartDate), - checkRequired("endDate", endDate), - checkRequired("filter", filter), - checkRequired("fixedFeeQuantityTransitions", fixedFeeQuantityTransitions).map { - it.toImmutable() - }, - checkRequired("price", price), - checkRequired("startDate", startDate), - checkRequired("usageCustomerIds", usageCustomerIds).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class FixedFeeQuantityTransition - @JsonCreator - private constructor( - @JsonProperty("effective_date") - @ExcludeMissing - private val effectiveDate: JsonField = JsonMissing.of(), - @JsonProperty("price_id") - @ExcludeMissing - private val priceId: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - private val quantity: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun effectiveDate(): OffsetDateTime = effectiveDate.getRequired("effective_date") - - fun priceId(): String = priceId.getRequired("price_id") - - fun quantity(): Long = quantity.getRequired("quantity") - - @JsonProperty("effective_date") - @ExcludeMissing - fun _effectiveDate(): JsonField = effectiveDate - - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - - @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): FixedFeeQuantityTransition = apply { - if (validated) { - return@apply - } - - effectiveDate() - priceId() - quantity() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FixedFeeQuantityTransition]. */ - class Builder internal constructor() { - - private var effectiveDate: JsonField? = null - private var priceId: JsonField? = null - private var quantity: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(fixedFeeQuantityTransition: FixedFeeQuantityTransition) = apply { - effectiveDate = fixedFeeQuantityTransition.effectiveDate - priceId = fixedFeeQuantityTransition.priceId - quantity = fixedFeeQuantityTransition.quantity - additionalProperties = - fixedFeeQuantityTransition.additionalProperties.toMutableMap() - } - - fun effectiveDate(effectiveDate: OffsetDateTime) = - effectiveDate(JsonField.of(effectiveDate)) - - fun effectiveDate(effectiveDate: JsonField) = apply { - this.effectiveDate = effectiveDate - } - - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) - - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - - fun quantity(quantity: Long) = quantity(JsonField.of(quantity)) - - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): FixedFeeQuantityTransition = - FixedFeeQuantityTransition( - checkRequired("effectiveDate", effectiveDate), - checkRequired("priceId", priceId), - checkRequired("quantity", quantity), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FixedFeeQuantityTransition && effectiveDate == other.effectiveDate && priceId == other.priceId && quantity == other.quantity && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(effectiveDate, priceId, quantity, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "FixedFeeQuantityTransition{effectiveDate=$effectiveDate, priceId=$priceId, quantity=$quantity, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PriceInterval && id == other.id && billingCycleDay == other.billingCycleDay && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && endDate == other.endDate && filter == other.filter && fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && price == other.price && startDate == other.startDate && usageCustomerIds == other.usageCustomerIds && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billingCycleDay, currentBillingPeriodEndDate, currentBillingPeriodStartDate, endDate, filter, fixedFeeQuantityTransitions, price, startDate, usageCustomerIds, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PriceInterval{id=$id, billingCycleDay=$billingCycleDay, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, endDate=$endDate, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, price=$price, startDate=$startDate, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class RedeemedCoupon - @JsonCreator - private constructor( - @JsonProperty("coupon_id") - @ExcludeMissing - private val couponId: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun couponId(): String = couponId.getRequired("coupon_id") - - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - @JsonProperty("coupon_id") @ExcludeMissing fun _couponId(): JsonField = couponId - - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): RedeemedCoupon = apply { - if (validated) { - return@apply - } - - couponId() - endDate() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RedeemedCoupon]. */ - class Builder internal constructor() { - - private var couponId: JsonField? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(redeemedCoupon: RedeemedCoupon) = apply { - couponId = redeemedCoupon.couponId - endDate = redeemedCoupon.endDate - startDate = redeemedCoupon.startDate - additionalProperties = redeemedCoupon.additionalProperties.toMutableMap() - } - - fun couponId(couponId: String) = couponId(JsonField.of(couponId)) - - fun couponId(couponId: JsonField) = apply { this.couponId = couponId } - - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - 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) - } - - fun build(): RedeemedCoupon = - RedeemedCoupon( - checkRequired("couponId", couponId), - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RedeemedCoupon && couponId == other.couponId && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(couponId, endDate, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RedeemedCoupon{couponId=$couponId, endDate=$endDate, startDate=$startDate, 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 ENDED = of("ended") - - @JvmField val UPCOMING = of("upcoming") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - ACTIVE, - ENDED, - UPCOMING, - } - - /** - * 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, - ENDED, - UPCOMING, - /** 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 - ENDED -> Value.ENDED - UPCOMING -> Value.UPCOMING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to 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 - ENDED -> Known.ENDED - UPCOMING -> Known.UPCOMING - 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TrialInfo - @JsonCreator - private constructor( - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TrialInfo = apply { - if (validated) { - return@apply - } - - endDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TrialInfo]. */ - class Builder internal constructor() { - - private var endDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(trialInfo: TrialInfo) = apply { - endDate = trialInfo.endDate - additionalProperties = trialInfo.additionalProperties.toMutableMap() - } - - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - 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) - } - - fun build(): TrialInfo = - TrialInfo(checkRequired("endDate", endDate), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TrialInfo && endDate == other.endDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(endDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TrialInfo{endDate=$endDate, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is SubscriptionCreateResponse && id == other.id && activePlanPhaseOrder == other.activePlanPhaseOrder && adjustmentIntervals == other.adjustmentIntervals && autoCollection == other.autoCollection && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && billingCycleDay == other.billingCycleDay && createdAt == other.createdAt && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && customer == other.customer && defaultInvoiceMemo == other.defaultInvoiceMemo && discountIntervals == other.discountIntervals && endDate == other.endDate && fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && invoicingThreshold == other.invoicingThreshold && maximumIntervals == other.maximumIntervals && metadata == other.metadata && minimumIntervals == other.minimumIntervals && netTerms == other.netTerms && plan == other.plan && priceIntervals == other.priceIntervals && redeemedCoupon == other.redeemedCoupon && startDate == other.startDate && status == other.status && trialInfo == other.trialInfo && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, activePlanPhaseOrder, adjustmentIntervals, autoCollection, billingCycleAnchorConfiguration, billingCycleDay, createdAt, currentBillingPeriodEndDate, currentBillingPeriodStartDate, customer, defaultInvoiceMemo, discountIntervals, endDate, fixedFeeQuantitySchedule, invoicingThreshold, maximumIntervals, metadata, minimumIntervals, netTerms, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SubscriptionCreateResponse{id=$id, activePlanPhaseOrder=$activePlanPhaseOrder, adjustmentIntervals=$adjustmentIntervals, autoCollection=$autoCollection, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, billingCycleDay=$billingCycleDay, createdAt=$createdAt, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, customer=$customer, defaultInvoiceMemo=$defaultInvoiceMemo, discountIntervals=$discountIntervals, endDate=$endDate, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, invoicingThreshold=$invoicingThreshold, maximumIntervals=$maximumIntervals, metadata=$metadata, minimumIntervals=$minimumIntervals, netTerms=$netTerms, plan=$plan, priceIntervals=$priceIntervals, redeemedCoupon=$redeemedCoupon, startDate=$startDate, status=$status, trialInfo=$trialInfo, additionalProperties=$additionalProperties}" -} 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 e778e7d74..fbfbb12a2 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 @@ -93,6 +93,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [SubscriptionFetchCostsParams]. + * + * The following fields are required: + * ```java + * .subscriptionId() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 34865071a..11eb28834 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 @@ -11,12 +11,11 @@ import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.immutableEmptyMap import com.withorb.api.core.toImmutable -import java.time.OffsetDateTime import java.util.Objects -import java.util.Optional @NoAutoDetect class SubscriptionFetchCostsResponse @@ -24,13 +23,13 @@ class SubscriptionFetchCostsResponse private constructor( @JsonProperty("data") @ExcludeMissing - private val data: JsonField> = JsonMissing.of(), + private val data: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = data.getRequired("data") + fun data(): List = data.getRequired("data") - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data @JsonAnyGetter @ExcludeMissing @@ -51,13 +50,22 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [SubscriptionFetchCostsResponse]. + * + * The following fields are required: + * ```java + * .data() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [SubscriptionFetchCostsResponse]. */ class Builder internal constructor() { - private var data: JsonField>? = null + private var data: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -67,22 +75,16 @@ private constructor( subscriptionFetchCostsResponse.additionalProperties.toMutableMap() } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { + fun data(data: JsonField>) = apply { this.data = data.map { it.toMutableList() } } - fun addData(data: Data) = apply { + fun addData(data: AggregatedCostModel) = apply { this.data = - (this.data ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(data) + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) } } @@ -112,497 +114,6 @@ private constructor( ) } - @NoAutoDetect - class Data - @JsonCreator - private constructor( - @JsonProperty("per_price_costs") - @ExcludeMissing - private val perPriceCosts: JsonField> = JsonMissing.of(), - @JsonProperty("subtotal") - @ExcludeMissing - private val subtotal: JsonField = JsonMissing.of(), - @JsonProperty("timeframe_end") - @ExcludeMissing - private val timeframeEnd: JsonField = JsonMissing.of(), - @JsonProperty("timeframe_start") - @ExcludeMissing - private val timeframeStart: JsonField = JsonMissing.of(), - @JsonProperty("total") - @ExcludeMissing - private val total: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun perPriceCosts(): List = perPriceCosts.getRequired("per_price_costs") - - /** Total costs for the timeframe, excluding any minimums and discounts. */ - fun subtotal(): String = subtotal.getRequired("subtotal") - - fun timeframeEnd(): OffsetDateTime = timeframeEnd.getRequired("timeframe_end") - - fun timeframeStart(): OffsetDateTime = timeframeStart.getRequired("timeframe_start") - - /** Total costs for the timeframe, including any minimums and discounts. */ - fun total(): String = total.getRequired("total") - - @JsonProperty("per_price_costs") - @ExcludeMissing - fun _perPriceCosts(): JsonField> = perPriceCosts - - /** Total costs for the timeframe, excluding any minimums and discounts. */ - @JsonProperty("subtotal") @ExcludeMissing fun _subtotal(): JsonField = subtotal - - @JsonProperty("timeframe_end") - @ExcludeMissing - fun _timeframeEnd(): JsonField = timeframeEnd - - @JsonProperty("timeframe_start") - @ExcludeMissing - fun _timeframeStart(): JsonField = timeframeStart - - /** Total costs for the timeframe, including any minimums and discounts. */ - @JsonProperty("total") @ExcludeMissing fun _total(): JsonField = total - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - perPriceCosts().forEach { it.validate() } - subtotal() - timeframeEnd() - timeframeStart() - total() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Data]. */ - class Builder internal constructor() { - - private var perPriceCosts: JsonField>? = null - private var subtotal: JsonField? = null - private var timeframeEnd: JsonField? = null - private var timeframeStart: JsonField? = null - private var total: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - perPriceCosts = data.perPriceCosts.map { it.toMutableList() } - subtotal = data.subtotal - timeframeEnd = data.timeframeEnd - timeframeStart = data.timeframeStart - total = data.total - additionalProperties = data.additionalProperties.toMutableMap() - } - - fun perPriceCosts(perPriceCosts: List) = - perPriceCosts(JsonField.of(perPriceCosts)) - - fun perPriceCosts(perPriceCosts: JsonField>) = apply { - this.perPriceCosts = perPriceCosts.map { it.toMutableList() } - } - - fun addPerPriceCost(perPriceCost: PerPriceCost) = apply { - perPriceCosts = - (perPriceCosts ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(perPriceCost) - } - } - - /** Total costs for the timeframe, excluding any minimums and discounts. */ - fun subtotal(subtotal: String) = subtotal(JsonField.of(subtotal)) - - /** Total costs for the timeframe, excluding any minimums and discounts. */ - fun subtotal(subtotal: JsonField) = apply { this.subtotal = subtotal } - - fun timeframeEnd(timeframeEnd: OffsetDateTime) = - timeframeEnd(JsonField.of(timeframeEnd)) - - fun timeframeEnd(timeframeEnd: JsonField) = apply { - this.timeframeEnd = timeframeEnd - } - - fun timeframeStart(timeframeStart: OffsetDateTime) = - timeframeStart(JsonField.of(timeframeStart)) - - fun timeframeStart(timeframeStart: JsonField) = apply { - this.timeframeStart = timeframeStart - } - - /** Total costs for the timeframe, including any minimums and discounts. */ - fun total(total: String) = total(JsonField.of(total)) - - /** Total costs for the timeframe, including any minimums and discounts. */ - fun total(total: JsonField) = apply { this.total = total } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Data = - Data( - checkRequired("perPriceCosts", perPriceCosts).map { it.toImmutable() }, - checkRequired("subtotal", subtotal), - checkRequired("timeframeEnd", timeframeEnd), - checkRequired("timeframeStart", timeframeStart), - checkRequired("total", total), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class PerPriceCost - @JsonCreator - private constructor( - @JsonProperty("price") - @ExcludeMissing - private val price: JsonField = JsonMissing.of(), - @JsonProperty("price_id") - @ExcludeMissing - private val priceId: JsonField = JsonMissing.of(), - @JsonProperty("subtotal") - @ExcludeMissing - private val subtotal: JsonField = JsonMissing.of(), - @JsonProperty("total") - @ExcludeMissing - private val total: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - private val quantity: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price object */ - fun price(): Price = price.getRequired("price") - - /** The price the cost is associated with */ - fun priceId(): String = priceId.getRequired("price_id") - - /** Price's contributions for the timeframe, excluding any minimums and discounts. */ - fun subtotal(): String = subtotal.getRequired("subtotal") - - /** Price's contributions for the timeframe, including minimums and discounts. */ - fun total(): String = total.getRequired("total") - - /** The price's quantity for the timeframe */ - fun quantity(): Optional = Optional.ofNullable(quantity.getNullable("quantity")) - - /** The price object */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - - /** The price the cost is associated with */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - - /** Price's contributions for the timeframe, excluding any minimums and discounts. */ - @JsonProperty("subtotal") @ExcludeMissing fun _subtotal(): JsonField = subtotal - - /** Price's contributions for the timeframe, including minimums and discounts. */ - @JsonProperty("total") @ExcludeMissing fun _total(): JsonField = total - - /** The price's quantity for the timeframe */ - @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PerPriceCost = apply { - if (validated) { - return@apply - } - - price().validate() - priceId() - subtotal() - total() - quantity() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PerPriceCost]. */ - class Builder internal constructor() { - - private var price: JsonField? = null - private var priceId: JsonField? = null - private var subtotal: JsonField? = null - private var total: JsonField? = null - private var quantity: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(perPriceCost: PerPriceCost) = apply { - price = perPriceCost.price - priceId = perPriceCost.priceId - subtotal = perPriceCost.subtotal - total = perPriceCost.total - quantity = perPriceCost.quantity - additionalProperties = perPriceCost.additionalProperties.toMutableMap() - } - - /** The price object */ - fun price(price: Price) = price(JsonField.of(price)) - - /** The price object */ - fun price(price: JsonField) = apply { this.price = price } - - /** The price object */ - fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) - - /** The price object */ - fun price(packagePrice: Price.PackagePrice) = - price(Price.ofPackagePrice(packagePrice)) - - /** The price object */ - fun price(matrix: Price.MatrixPrice) = price(Price.ofMatrix(matrix)) - - /** The price object */ - fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) - - /** The price object */ - fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) - - /** The price object */ - fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) - - /** The price object */ - fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) - - /** The price object */ - fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) - - /** The price object */ - fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - - /** The price object */ - fun price(tieredPackage: Price.TieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) - - /** The price object */ - fun price(groupedTiered: Price.GroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) - - /** The price object */ - fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) - - /** The price object */ - fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - - /** The price object */ - fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) - - /** The price object */ - fun price(unitWithPercent: Price.UnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) - - /** The price object */ - fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - - /** The price object */ - fun price(tieredWithProration: Price.TieredWithProrationPrice) = - price(Price.ofTieredWithProration(tieredWithProration)) - - /** The price object */ - fun price(unitWithProration: Price.UnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) - - /** The price object */ - fun price(groupedAllocation: Price.GroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) - - /** The price object */ - fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - - /** The price object */ - fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - - /** The price object */ - fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - - /** The price object */ - fun price(bulkWithProration: Price.BulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) - - /** The price object */ - fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) - - /** The price object */ - fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - - /** The price object */ - fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = - price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - - /** The price object */ - fun price( - scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - - /** The price object */ - fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - - /** The price the cost is associated with */ - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) - - /** The price the cost is associated with */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - - /** - * Price's contributions for the timeframe, excluding any minimums and discounts. - */ - fun subtotal(subtotal: String) = subtotal(JsonField.of(subtotal)) - - /** - * Price's contributions for the timeframe, excluding any minimums and discounts. - */ - fun subtotal(subtotal: JsonField) = apply { this.subtotal = subtotal } - - /** Price's contributions for the timeframe, including minimums and discounts. */ - fun total(total: String) = total(JsonField.of(total)) - - /** Price's contributions for the timeframe, including minimums and discounts. */ - fun total(total: JsonField) = apply { this.total = total } - - /** The price's quantity for the timeframe */ - fun quantity(quantity: Double?) = quantity(JsonField.ofNullable(quantity)) - - /** The price's quantity for the timeframe */ - fun quantity(quantity: Double) = quantity(quantity as Double?) - - /** The price's quantity for the timeframe */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun quantity(quantity: Optional) = - quantity(quantity.orElse(null) as Double?) - - /** The price's quantity for the timeframe */ - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PerPriceCost = - PerPriceCost( - checkRequired("price", price), - checkRequired("priceId", priceId), - checkRequired("subtotal", subtotal), - checkRequired("total", total), - quantity, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PerPriceCost && price == other.price && priceId == other.priceId && subtotal == other.subtotal && total == other.total && quantity == other.quantity && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(price, priceId, subtotal, total, quantity, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PerPriceCost{price=$price, priceId=$priceId, subtotal=$subtotal, total=$total, quantity=$quantity, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Data && perPriceCosts == other.perPriceCosts && subtotal == other.subtotal && timeframeEnd == other.timeframeEnd && timeframeStart == other.timeframeStart && total == other.total && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(perPriceCosts, subtotal, timeframeEnd, timeframeStart, total, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Data{perPriceCosts=$perPriceCosts, subtotal=$subtotal, timeframeEnd=$timeframeEnd, timeframeStart=$timeframeStart, total=$total, 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/SubscriptionFetchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchParams.kt index b06df7640..c1662c2e3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchParams.kt @@ -41,6 +41,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [SubscriptionFetchParams]. + * + * The following fields are required: + * ```java + * .subscriptionId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePage.kt index 1240b0843..199aad8ab 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePage.kt @@ -145,6 +145,10 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [SubscriptionFetchSchedulePage]. + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePageAsync.kt index 7900afaac..60adae2bc 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchSchedulePageAsync.kt @@ -148,6 +148,10 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [SubscriptionFetchSchedulePageAsync]. + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleParams.kt index 5db99de4b..c373fd899 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleParams.kt @@ -98,6 +98,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [SubscriptionFetchScheduleParams]. + * + * The following fields are required: + * ```java + * .subscriptionId() + * ``` + */ @JvmStatic fun builder() = Builder() } 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 cac402532..68c06ed25 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 @@ -28,7 +28,9 @@ private constructor( @JsonProperty("end_date") @ExcludeMissing private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("plan") @ExcludeMissing private val plan: JsonField = JsonMissing.of(), + @JsonProperty("plan") + @ExcludeMissing + private val plan: JsonField = JsonMissing.of(), @JsonProperty("start_date") @ExcludeMissing private val startDate: JsonField = JsonMissing.of(), @@ -39,7 +41,7 @@ private constructor( fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) - fun plan(): Plan = plan.getRequired("plan") + fun plan(): PlanMinifiedModel = plan.getRequired("plan") fun startDate(): OffsetDateTime = startDate.getRequired("start_date") @@ -49,7 +51,7 @@ private constructor( @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate - @JsonProperty("plan") @ExcludeMissing fun _plan(): JsonField = plan + @JsonProperty("plan") @ExcludeMissing fun _plan(): JsonField = plan @JsonProperty("start_date") @ExcludeMissing @@ -77,6 +79,18 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [SubscriptionFetchScheduleResponse]. + * + * The following fields are required: + * ```java + * .createdAt() + * .endDate() + * .plan() + * .startDate() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -85,7 +99,7 @@ private constructor( private var createdAt: JsonField? = null private var endDate: JsonField? = null - private var plan: JsonField? = null + private var plan: JsonField? = null private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -110,9 +124,9 @@ private constructor( fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - fun plan(plan: Plan) = plan(JsonField.of(plan)) + fun plan(plan: PlanMinifiedModel) = plan(JsonField.of(plan)) - fun plan(plan: JsonField) = apply { this.plan = plan } + fun plan(plan: JsonField) = apply { this.plan = plan } fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) @@ -147,169 +161,6 @@ private constructor( ) } - @NoAutoDetect - class Plan - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("external_plan_id") - @ExcludeMissing - private val externalPlanId: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): Optional = Optional.ofNullable(id.getNullable("id")) - - /** - * An optional user-defined ID for this plan resource, used throughout the system as an - * alias for this Plan. Use this field to identify a plan by an existing identifier in your - * system. - */ - fun externalPlanId(): Optional = - Optional.ofNullable(externalPlanId.getNullable("external_plan_id")) - - fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * An optional user-defined ID for this plan resource, used throughout the system as an - * alias for this Plan. Use this field to identify a plan by an existing identifier in your - * system. - */ - @JsonProperty("external_plan_id") - @ExcludeMissing - fun _externalPlanId(): JsonField = externalPlanId - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Plan = apply { - if (validated) { - return@apply - } - - id() - externalPlanId() - name() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Plan]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var externalPlanId: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(plan: Plan) = apply { - id = plan.id - externalPlanId = plan.externalPlanId - name = plan.name - additionalProperties = plan.additionalProperties.toMutableMap() - } - - fun id(id: String?) = id(JsonField.ofNullable(id)) - - fun id(id: Optional) = id(id.orElse(null)) - - fun id(id: JsonField) = apply { this.id = id } - - /** - * An optional user-defined ID for this plan resource, used throughout the system as an - * alias for this Plan. Use this field to identify a plan by an existing identifier in - * your system. - */ - fun externalPlanId(externalPlanId: String?) = - externalPlanId(JsonField.ofNullable(externalPlanId)) - - /** - * An optional user-defined ID for this plan resource, used throughout the system as an - * alias for this Plan. Use this field to identify a plan by an existing identifier in - * your system. - */ - fun externalPlanId(externalPlanId: Optional) = - externalPlanId(externalPlanId.orElse(null)) - - /** - * An optional user-defined ID for this plan resource, used throughout the system as an - * alias for this Plan. Use this field to identify a plan by an existing identifier in - * your system. - */ - fun externalPlanId(externalPlanId: JsonField) = apply { - this.externalPlanId = externalPlanId - } - - fun name(name: String?) = name(JsonField.ofNullable(name)) - - fun name(name: Optional) = name(name.orElse(null)) - - 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) - } - - fun build(): Plan = - Plan( - checkRequired("id", id), - checkRequired("externalPlanId", externalPlanId), - checkRequired("name", name), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Plan && id == other.id && externalPlanId == other.externalPlanId && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, externalPlanId, name, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Plan{id=$id, externalPlanId=$externalPlanId, name=$name, 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/SubscriptionFetchUsageParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchUsageParams.kt index 6731d14ab..feafc4752 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 @@ -296,6 +296,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [SubscriptionFetchUsageParams]. + * + * The following fields are required: + * ```java + * .subscriptionId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPage.kt index 75ddfb250..7b31297df 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPage.kt @@ -38,7 +38,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -96,20 +96,21 @@ private constructor( class Response @JsonCreator constructor( - @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), + @JsonProperty("data") + private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = Optional.ofNullable(data) + fun _data(): Optional>> = Optional.ofNullable(data) @JsonProperty("pagination_metadata") fun _paginationMetadata(): Optional> = @@ -148,12 +149,13 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [SubscriptionListPage]. */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -164,9 +166,9 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { this.data = data } fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) @@ -183,9 +185,9 @@ private constructor( } } - class AutoPager(private val firstPage: SubscriptionListPage) : Iterable { + class AutoPager(private val firstPage: SubscriptionListPage) : Iterable { - override fun iterator(): Iterator = iterator { + override fun iterator(): Iterator = iterator { var page = firstPage var index = 0 while (true) { @@ -197,7 +199,7 @@ private constructor( } } - fun stream(): Stream { + fun stream(): Stream { return StreamSupport.stream(spliterator(), false) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPageAsync.kt index 9aedec604..8cb5f175f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPageAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListPageAsync.kt @@ -39,7 +39,7 @@ private constructor( fun response(): Response = response - fun data(): List = response().data() + fun data(): List = response().data() fun paginationMetadata(): PaginationMetadata = response().paginationMetadata() @@ -99,20 +99,21 @@ private constructor( class Response @JsonCreator constructor( - @JsonProperty("data") private val data: JsonField> = JsonMissing.of(), + @JsonProperty("data") + private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = data.getNullable("data") ?: listOf() + fun data(): List = data.getNullable("data") ?: listOf() fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") @JsonProperty("data") - fun _data(): Optional>> = Optional.ofNullable(data) + fun _data(): Optional>> = Optional.ofNullable(data) @JsonProperty("pagination_metadata") fun _paginationMetadata(): Optional> = @@ -151,12 +152,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [SubscriptionListPageAsync]. + */ @JvmStatic fun builder() = Builder() } class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField> = JsonMissing.of() private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -167,9 +172,9 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { this.data = data } fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) @@ -188,9 +193,12 @@ private constructor( class AutoPager(private val firstPage: SubscriptionListPageAsync) { - fun forEach(action: Predicate, executor: Executor): CompletableFuture { + fun forEach( + action: Predicate, + executor: Executor, + ): CompletableFuture { fun CompletableFuture>.forEach( - action: (Subscription) -> Boolean, + action: (SubscriptionModel) -> Boolean, executor: Executor, ): CompletableFuture = thenComposeAsync( @@ -206,8 +214,8 @@ private constructor( .forEach(action::test, executor) } - fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() + fun toList(executor: Executor): CompletableFuture> { + val values = mutableListOf() return forEach(values::add, executor).thenApply { values } } } 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 3496f358a..c82f0e4ac 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 @@ -113,6 +113,7 @@ private constructor( @JvmStatic fun none(): SubscriptionListParams = builder().build() + /** Returns a mutable builder for constructing an instance of [SubscriptionListParams]. */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionMinifiedModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionMinifiedModel.kt new file mode 100644 index 000000000..aa51d246f --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionMinifiedModel.kt @@ -0,0 +1,116 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects + +@NoAutoDetect +class SubscriptionMinifiedModel +@JsonCreator +private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun id(): String = id.getRequired("id") + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): SubscriptionMinifiedModel = apply { + if (validated) { + return@apply + } + + id() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SubscriptionMinifiedModel]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SubscriptionMinifiedModel]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(subscriptionMinifiedModel: SubscriptionMinifiedModel) = apply { + id = subscriptionMinifiedModel.id + additionalProperties = subscriptionMinifiedModel.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + 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) + } + + fun build(): SubscriptionMinifiedModel = + SubscriptionMinifiedModel(checkRequired("id", id), additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SubscriptionMinifiedModel && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SubscriptionMinifiedModel{id=$id, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionModel.kt new file mode 100644 index 000000000..c128ef1c4 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionModel.kt @@ -0,0 +1,1443 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.withorb.api.core.BaseDeserializer +import com.withorb.api.core.BaseSerializer +import com.withorb.api.core.Enum +import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing +import com.withorb.api.core.JsonValue +import com.withorb.api.core.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.getOrThrow +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * A [subscription](/core-concepts#subscription) represents the purchase of a plan by a customer. + * + * By default, subscriptions begin on the day that they're created and renew automatically for each + * billing cycle at the cadence that's configured in the plan definition. + * + * Subscriptions also default to **beginning of month alignment**, which means the first invoice + * issued for the subscription will have pro-rated charges between the `start_date` and the first of + * the following month. Subsequent billing periods will always start and end on a month boundary + * (e.g. subsequent month starts for monthly billing). + * + * Depending on the plan configuration, any _flat_ recurring fees will be billed either at the + * beginning (in-advance) or end (in-arrears) of each billing cycle. Plans default to **in-advance + * billing**. Usage-based fees are billed in arrears as usage is accumulated. In the normal course + * of events, you can expect an invoice to contain usage-based charges for the previous period, and + * a recurring fee for the following period. + */ +@NoAutoDetect +class SubscriptionModel +@JsonCreator +private constructor( + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("active_plan_phase_order") + @ExcludeMissing + private val activePlanPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("adjustment_intervals") + @ExcludeMissing + private val adjustmentIntervals: JsonField> = JsonMissing.of(), + @JsonProperty("auto_collection") + @ExcludeMissing + private val autoCollection: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_anchor_configuration") + @ExcludeMissing + private val billingCycleAnchorConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("billing_cycle_day") + @ExcludeMissing + private val billingCycleDay: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + private val createdAt: JsonField = JsonMissing.of(), + @JsonProperty("current_billing_period_end_date") + @ExcludeMissing + private val currentBillingPeriodEndDate: JsonField = JsonMissing.of(), + @JsonProperty("current_billing_period_start_date") + @ExcludeMissing + private val currentBillingPeriodStartDate: JsonField = JsonMissing.of(), + @JsonProperty("customer") + @ExcludeMissing + private val customer: JsonField = JsonMissing.of(), + @JsonProperty("default_invoice_memo") + @ExcludeMissing + private val defaultInvoiceMemo: JsonField = JsonMissing.of(), + @JsonProperty("discount_intervals") + @ExcludeMissing + private val discountIntervals: JsonField> = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + private val endDate: JsonField = JsonMissing.of(), + @JsonProperty("fixed_fee_quantity_schedule") + @ExcludeMissing + private val fixedFeeQuantitySchedule: JsonField> = + JsonMissing.of(), + @JsonProperty("invoicing_threshold") + @ExcludeMissing + private val invoicingThreshold: JsonField = JsonMissing.of(), + @JsonProperty("maximum_intervals") + @ExcludeMissing + private val maximumIntervals: JsonField> = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("minimum_intervals") + @ExcludeMissing + private val minimumIntervals: JsonField> = JsonMissing.of(), + @JsonProperty("net_terms") + @ExcludeMissing + private val netTerms: JsonField = JsonMissing.of(), + @JsonProperty("plan") @ExcludeMissing private val plan: JsonField = JsonMissing.of(), + @JsonProperty("price_intervals") + @ExcludeMissing + private val priceIntervals: JsonField> = JsonMissing.of(), + @JsonProperty("redeemed_coupon") + @ExcludeMissing + private val redeemedCoupon: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + private val startDate: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + private val status: JsonField = JsonMissing.of(), + @JsonProperty("trial_info") + @ExcludeMissing + private val trialInfo: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun id(): String = id.getRequired("id") + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + fun activePlanPhaseOrder(): Optional = + Optional.ofNullable(activePlanPhaseOrder.getNullable("active_plan_phase_order")) + + /** The adjustment intervals for this subscription. */ + fun adjustmentIntervals(): List = + adjustmentIntervals.getRequired("adjustment_intervals") + + /** + * Determines whether issued invoices for this subscription will automatically be charged with + * the saved payment method on the due date. This property defaults to the plan's behavior. If + * null, defaults to the customer's setting. + */ + fun autoCollection(): Optional = + Optional.ofNullable(autoCollection.getNullable("auto_collection")) + + fun billingCycleAnchorConfiguration(): BillingCycleAnchorConfigurationModel = + billingCycleAnchorConfiguration.getRequired("billing_cycle_anchor_configuration") + + /** + * The day of the month on which the billing cycle is anchored. If the maximum number of days in + * a month is greater than this value, the last day of the month is the billing cycle day (e.g. + * billing_cycle_day=31 for April means the billing period begins on the 30th. + */ + fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") + + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the instant + * returned is not part of the billing period. Set to null for subscriptions that are not + * currently active. + */ + fun currentBillingPeriodEndDate(): Optional = + Optional.ofNullable( + currentBillingPeriodEndDate.getNullable("current_billing_period_end_date") + ) + + /** + * The start date of the current billing period. This is an inclusive timestamp; the instant + * returned is exactly the beginning of the billing period. Set to null if the subscription is + * not currently active. + */ + fun currentBillingPeriodStartDate(): Optional = + Optional.ofNullable( + currentBillingPeriodStartDate.getNullable("current_billing_period_start_date") + ) + + /** + * 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 customer(): CustomerModel = customer.getRequired("customer") + + /** + * Determines the default memo on this subscriptions' invoices. Note that if this is not + * provided, it is determined by the plan configuration. + */ + fun defaultInvoiceMemo(): Optional = + Optional.ofNullable(defaultInvoiceMemo.getNullable("default_invoice_memo")) + + /** The discount intervals for this subscription. */ + fun discountIntervals(): List = + discountIntervals.getRequired("discount_intervals") + + /** The date Orb stops billing for this subscription. */ + fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) + + fun fixedFeeQuantitySchedule(): List = + fixedFeeQuantitySchedule.getRequired("fixed_fee_quantity_schedule") + + fun invoicingThreshold(): Optional = + Optional.ofNullable(invoicingThreshold.getNullable("invoicing_threshold")) + + /** The maximum intervals for this subscription. */ + fun maximumIntervals(): List = + maximumIntervals.getRequired("maximum_intervals") + + /** + * 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.getRequired("metadata") + + /** The minimum intervals for this subscription. */ + fun minimumIntervals(): List = + minimumIntervals.getRequired("minimum_intervals") + + /** + * Determines the difference between the invoice issue date for subscription invoices as the + * date that they are due. A value of `0` here represents that the invoice is due on issue, + * whereas a value of `30` represents that the customer has a month to pay the invoice. + */ + fun netTerms(): Long = netTerms.getRequired("net_terms") + + /** + * 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 plan(): PlanModel = plan.getRequired("plan") + + /** The price intervals for this subscription. */ + fun priceIntervals(): List = priceIntervals.getRequired("price_intervals") + + fun redeemedCoupon(): Optional = + Optional.ofNullable(redeemedCoupon.getNullable("redeemed_coupon")) + + /** The date Orb starts billing for this subscription. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + fun status(): Status = status.getRequired("status") + + fun trialInfo(): SubscriptionTrialInfoModel = trialInfo.getRequired("trial_info") + + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + @JsonProperty("active_plan_phase_order") + @ExcludeMissing + fun _activePlanPhaseOrder(): JsonField = activePlanPhaseOrder + + /** The adjustment intervals for this subscription. */ + @JsonProperty("adjustment_intervals") + @ExcludeMissing + fun _adjustmentIntervals(): JsonField> = adjustmentIntervals + + /** + * Determines whether issued invoices for this subscription will automatically be charged with + * the saved payment method on the due date. This property defaults to the plan's behavior. If + * null, defaults to the customer's setting. + */ + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection + + @JsonProperty("billing_cycle_anchor_configuration") + @ExcludeMissing + fun _billingCycleAnchorConfiguration(): JsonField = + billingCycleAnchorConfiguration + + /** + * The day of the month on which the billing cycle is anchored. If the maximum number of days in + * a month is greater than this value, the last day of the month is the billing cycle day (e.g. + * billing_cycle_day=31 for April means the billing period begins on the 30th. + */ + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun _billingCycleDay(): JsonField = billingCycleDay + + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the instant + * returned is not part of the billing period. Set to null for subscriptions that are not + * currently active. + */ + @JsonProperty("current_billing_period_end_date") + @ExcludeMissing + fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate + + /** + * The start date of the current billing period. This is an inclusive timestamp; the instant + * returned is exactly the beginning of the billing period. Set to null if the subscription is + * not currently active. + */ + @JsonProperty("current_billing_period_start_date") + @ExcludeMissing + fun _currentBillingPeriodStartDate(): JsonField = currentBillingPeriodStartDate + + /** + * 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. + */ + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer + + /** + * Determines the default memo on this subscriptions' invoices. Note that if this is not + * provided, it is determined by the plan configuration. + */ + @JsonProperty("default_invoice_memo") + @ExcludeMissing + fun _defaultInvoiceMemo(): JsonField = defaultInvoiceMemo + + /** The discount intervals for this subscription. */ + @JsonProperty("discount_intervals") + @ExcludeMissing + fun _discountIntervals(): JsonField> = discountIntervals + + /** The date Orb stops billing for this subscription. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + @JsonProperty("fixed_fee_quantity_schedule") + @ExcludeMissing + fun _fixedFeeQuantitySchedule(): JsonField> = + fixedFeeQuantitySchedule + + @JsonProperty("invoicing_threshold") + @ExcludeMissing + fun _invoicingThreshold(): JsonField = invoicingThreshold + + /** The maximum intervals for this subscription. */ + @JsonProperty("maximum_intervals") + @ExcludeMissing + fun _maximumIntervals(): JsonField> = maximumIntervals + + /** + * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** The minimum intervals for this subscription. */ + @JsonProperty("minimum_intervals") + @ExcludeMissing + fun _minimumIntervals(): JsonField> = minimumIntervals + + /** + * Determines the difference between the invoice issue date for subscription invoices as the + * date that they are due. A value of `0` here represents that the invoice is due on issue, + * whereas a value of `30` represents that the customer has a month to pay the invoice. + */ + @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms + + /** + * 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). + */ + @JsonProperty("plan") @ExcludeMissing fun _plan(): JsonField = plan + + /** The price intervals for this subscription. */ + @JsonProperty("price_intervals") + @ExcludeMissing + fun _priceIntervals(): JsonField> = priceIntervals + + @JsonProperty("redeemed_coupon") + @ExcludeMissing + fun _redeemedCoupon(): JsonField = redeemedCoupon + + /** The date Orb starts billing for this subscription. */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + @JsonProperty("trial_info") + @ExcludeMissing + fun _trialInfo(): JsonField = trialInfo + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): SubscriptionModel = apply { + if (validated) { + return@apply + } + + id() + activePlanPhaseOrder() + adjustmentIntervals().forEach { it.validate() } + autoCollection() + billingCycleAnchorConfiguration().validate() + billingCycleDay() + createdAt() + currentBillingPeriodEndDate() + currentBillingPeriodStartDate() + customer().validate() + defaultInvoiceMemo() + discountIntervals().forEach { it.validate() } + endDate() + fixedFeeQuantitySchedule().forEach { it.validate() } + invoicingThreshold() + maximumIntervals().forEach { it.validate() } + metadata().validate() + minimumIntervals().forEach { it.validate() } + netTerms() + plan().validate() + priceIntervals().forEach { it.validate() } + redeemedCoupon().ifPresent { it.validate() } + startDate() + status() + trialInfo().validate() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SubscriptionModel]. + * + * The following fields are required: + * ```java + * .id() + * .activePlanPhaseOrder() + * .adjustmentIntervals() + * .autoCollection() + * .billingCycleAnchorConfiguration() + * .billingCycleDay() + * .createdAt() + * .currentBillingPeriodEndDate() + * .currentBillingPeriodStartDate() + * .customer() + * .defaultInvoiceMemo() + * .discountIntervals() + * .endDate() + * .fixedFeeQuantitySchedule() + * .invoicingThreshold() + * .maximumIntervals() + * .metadata() + * .minimumIntervals() + * .netTerms() + * .plan() + * .priceIntervals() + * .redeemedCoupon() + * .startDate() + * .status() + * .trialInfo() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SubscriptionModel]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var activePlanPhaseOrder: JsonField? = null + private var adjustmentIntervals: JsonField>? = null + private var autoCollection: JsonField? = null + private var billingCycleAnchorConfiguration: + JsonField? = + null + private var billingCycleDay: JsonField? = null + private var createdAt: JsonField? = null + private var currentBillingPeriodEndDate: JsonField? = null + private var currentBillingPeriodStartDate: JsonField? = null + private var customer: JsonField? = null + private var defaultInvoiceMemo: JsonField? = null + private var discountIntervals: JsonField>? = null + private var endDate: JsonField? = null + private var fixedFeeQuantitySchedule: + JsonField>? = + null + private var invoicingThreshold: JsonField? = null + private var maximumIntervals: JsonField>? = null + private var metadata: JsonField? = null + private var minimumIntervals: JsonField>? = null + private var netTerms: JsonField? = null + private var plan: JsonField? = null + private var priceIntervals: JsonField>? = null + private var redeemedCoupon: JsonField? = null + private var startDate: JsonField? = null + private var status: JsonField? = null + private var trialInfo: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(subscriptionModel: SubscriptionModel) = apply { + id = subscriptionModel.id + activePlanPhaseOrder = subscriptionModel.activePlanPhaseOrder + adjustmentIntervals = subscriptionModel.adjustmentIntervals.map { it.toMutableList() } + autoCollection = subscriptionModel.autoCollection + billingCycleAnchorConfiguration = subscriptionModel.billingCycleAnchorConfiguration + billingCycleDay = subscriptionModel.billingCycleDay + createdAt = subscriptionModel.createdAt + currentBillingPeriodEndDate = subscriptionModel.currentBillingPeriodEndDate + currentBillingPeriodStartDate = subscriptionModel.currentBillingPeriodStartDate + customer = subscriptionModel.customer + defaultInvoiceMemo = subscriptionModel.defaultInvoiceMemo + discountIntervals = subscriptionModel.discountIntervals.map { it.toMutableList() } + endDate = subscriptionModel.endDate + fixedFeeQuantitySchedule = + subscriptionModel.fixedFeeQuantitySchedule.map { it.toMutableList() } + invoicingThreshold = subscriptionModel.invoicingThreshold + maximumIntervals = subscriptionModel.maximumIntervals.map { it.toMutableList() } + metadata = subscriptionModel.metadata + minimumIntervals = subscriptionModel.minimumIntervals.map { it.toMutableList() } + netTerms = subscriptionModel.netTerms + plan = subscriptionModel.plan + priceIntervals = subscriptionModel.priceIntervals.map { it.toMutableList() } + redeemedCoupon = subscriptionModel.redeemedCoupon + startDate = subscriptionModel.startDate + status = subscriptionModel.status + trialInfo = subscriptionModel.trialInfo + additionalProperties = subscriptionModel.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + fun id(id: JsonField) = apply { this.id = id } + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + fun activePlanPhaseOrder(activePlanPhaseOrder: Long?) = + activePlanPhaseOrder(JsonField.ofNullable(activePlanPhaseOrder)) + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + fun activePlanPhaseOrder(activePlanPhaseOrder: Long) = + activePlanPhaseOrder(activePlanPhaseOrder as Long?) + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun activePlanPhaseOrder(activePlanPhaseOrder: Optional) = + activePlanPhaseOrder(activePlanPhaseOrder.orElse(null) as Long?) + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + fun activePlanPhaseOrder(activePlanPhaseOrder: JsonField) = apply { + this.activePlanPhaseOrder = activePlanPhaseOrder + } + + /** The adjustment intervals for this subscription. */ + fun adjustmentIntervals(adjustmentIntervals: List) = + adjustmentIntervals(JsonField.of(adjustmentIntervals)) + + /** The adjustment intervals for this subscription. */ + fun adjustmentIntervals(adjustmentIntervals: JsonField>) = + apply { + this.adjustmentIntervals = adjustmentIntervals.map { it.toMutableList() } + } + + /** The adjustment intervals for this subscription. */ + fun addAdjustmentInterval(adjustmentInterval: AdjustmentIntervalModel) = apply { + adjustmentIntervals = + (adjustmentIntervals ?: JsonField.of(mutableListOf())).also { + checkKnown("adjustmentIntervals", it).add(adjustmentInterval) + } + } + + /** + * Determines whether issued invoices for this subscription will automatically be charged + * with the saved payment method on the due date. This property defaults to the plan's + * behavior. If null, defaults to the customer's setting. + */ + fun autoCollection(autoCollection: Boolean?) = + autoCollection(JsonField.ofNullable(autoCollection)) + + /** + * Determines whether issued invoices for this subscription will automatically be charged + * with the saved payment method on the due date. This property defaults to the plan's + * behavior. If null, defaults to the customer's setting. + */ + fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) + + /** + * Determines whether issued invoices for this subscription will automatically be charged + * with the saved payment method on the due date. This property defaults to the plan's + * behavior. If null, defaults to the customer's setting. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun autoCollection(autoCollection: Optional) = + autoCollection(autoCollection.orElse(null) as Boolean?) + + /** + * Determines whether issued invoices for this subscription will automatically be charged + * with the saved payment method on the due date. This property defaults to the plan's + * behavior. If null, defaults to the customer's setting. + */ + fun autoCollection(autoCollection: JsonField) = apply { + this.autoCollection = autoCollection + } + + fun billingCycleAnchorConfiguration( + billingCycleAnchorConfiguration: BillingCycleAnchorConfigurationModel + ) = billingCycleAnchorConfiguration(JsonField.of(billingCycleAnchorConfiguration)) + + fun billingCycleAnchorConfiguration( + billingCycleAnchorConfiguration: JsonField + ) = apply { this.billingCycleAnchorConfiguration = billingCycleAnchorConfiguration } + + /** + * The day of the month on which the billing cycle is anchored. If the maximum number of + * days in a month is greater than this value, the last day of the month is the billing + * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the + * 30th. + */ + fun billingCycleDay(billingCycleDay: Long) = billingCycleDay(JsonField.of(billingCycleDay)) + + /** + * The day of the month on which the billing cycle is anchored. If the maximum number of + * days in a month is greater than this value, the last day of the month is the billing + * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the + * 30th. + */ + fun billingCycleDay(billingCycleDay: JsonField) = apply { + this.billingCycleDay = billingCycleDay + } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is not part of the billing period. Set to null for subscriptions that + * are not currently active. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = + currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is not part of the billing period. Set to null for subscriptions that + * are not currently active. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = + currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is not part of the billing period. Set to null for subscriptions that + * are not currently active. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: JsonField) = + apply { + this.currentBillingPeriodEndDate = currentBillingPeriodEndDate + } + + /** + * The start date of the current billing period. This is an inclusive timestamp; the instant + * returned is exactly the beginning of the billing period. Set to null if the subscription + * is not currently active. + */ + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = + currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) + + /** + * The start date of the current billing period. This is an inclusive timestamp; the instant + * returned is exactly the beginning of the billing period. Set to null if the subscription + * is not currently active. + */ + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: Optional) = + currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) + + /** + * The start date of the current billing period. This is an inclusive timestamp; the instant + * returned is exactly the beginning of the billing period. Set to null if the subscription + * is not currently active. + */ + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: JsonField + ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } + + /** + * 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 customer(customer: CustomerModel) = customer(JsonField.of(customer)) + + /** + * 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 customer(customer: JsonField) = apply { this.customer = customer } + + /** + * Determines the default memo on this subscriptions' invoices. Note that if this is not + * provided, it is determined by the plan configuration. + */ + fun defaultInvoiceMemo(defaultInvoiceMemo: String?) = + defaultInvoiceMemo(JsonField.ofNullable(defaultInvoiceMemo)) + + /** + * Determines the default memo on this subscriptions' invoices. Note that if this is not + * provided, it is determined by the plan configuration. + */ + fun defaultInvoiceMemo(defaultInvoiceMemo: Optional) = + defaultInvoiceMemo(defaultInvoiceMemo.orElse(null)) + + /** + * Determines the default memo on this subscriptions' invoices. Note that if this is not + * provided, it is determined by the plan configuration. + */ + fun defaultInvoiceMemo(defaultInvoiceMemo: JsonField) = apply { + this.defaultInvoiceMemo = defaultInvoiceMemo + } + + /** The discount intervals for this subscription. */ + fun discountIntervals(discountIntervals: List) = + discountIntervals(JsonField.of(discountIntervals)) + + /** The discount intervals for this subscription. */ + fun discountIntervals(discountIntervals: JsonField>) = apply { + this.discountIntervals = discountIntervals.map { it.toMutableList() } + } + + /** The discount intervals for this subscription. */ + fun addDiscountInterval(discountInterval: DiscountInterval) = apply { + discountIntervals = + (discountIntervals ?: JsonField.of(mutableListOf())).also { + checkKnown("discountIntervals", it).add(discountInterval) + } + } + + /** The discount intervals for this subscription. */ + fun addDiscountInterval(amountDiscountIntervalModel: AmountDiscountIntervalModel) = + addDiscountInterval( + DiscountInterval.ofAmountDiscountIntervalModel(amountDiscountIntervalModel) + ) + + /** The discount intervals for this subscription. */ + fun addDiscountInterval(percentageDiscountIntervalModel: PercentageDiscountIntervalModel) = + addDiscountInterval( + DiscountInterval.ofPercentageDiscountIntervalModel(percentageDiscountIntervalModel) + ) + + /** The discount intervals for this subscription. */ + fun addDiscountInterval(usageDiscountIntervalModel: UsageDiscountIntervalModel) = + addDiscountInterval( + DiscountInterval.ofUsageDiscountIntervalModel(usageDiscountIntervalModel) + ) + + /** The date Orb stops billing for this subscription. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The date Orb stops billing for this subscription. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) + + /** The date Orb stops billing for this subscription. */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun fixedFeeQuantitySchedule( + fixedFeeQuantitySchedule: List + ) = fixedFeeQuantitySchedule(JsonField.of(fixedFeeQuantitySchedule)) + + fun fixedFeeQuantitySchedule( + fixedFeeQuantitySchedule: JsonField> + ) = apply { + this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule.map { it.toMutableList() } + } + + fun addFixedFeeQuantitySchedule( + fixedFeeQuantitySchedule: FixedFeeQuantityScheduleEntryModel + ) = apply { + this.fixedFeeQuantitySchedule = + (this.fixedFeeQuantitySchedule ?: JsonField.of(mutableListOf())).also { + checkKnown("fixedFeeQuantitySchedule", it).add(fixedFeeQuantitySchedule) + } + } + + fun invoicingThreshold(invoicingThreshold: String?) = + invoicingThreshold(JsonField.ofNullable(invoicingThreshold)) + + fun invoicingThreshold(invoicingThreshold: Optional) = + invoicingThreshold(invoicingThreshold.orElse(null)) + + fun invoicingThreshold(invoicingThreshold: JsonField) = apply { + this.invoicingThreshold = invoicingThreshold + } + + /** The maximum intervals for this subscription. */ + fun maximumIntervals(maximumIntervals: List) = + maximumIntervals(JsonField.of(maximumIntervals)) + + /** The maximum intervals for this subscription. */ + fun maximumIntervals(maximumIntervals: JsonField>) = apply { + this.maximumIntervals = maximumIntervals.map { it.toMutableList() } + } + + /** The maximum intervals for this subscription. */ + fun addMaximumInterval(maximumInterval: MaximumIntervalModel) = apply { + maximumIntervals = + (maximumIntervals ?: JsonField.of(mutableListOf())).also { + checkKnown("maximumIntervals", it).add(maximumInterval) + } + } + + /** + * 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)) + + /** + * 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: JsonField) = apply { this.metadata = metadata } + + /** The minimum intervals for this subscription. */ + fun minimumIntervals(minimumIntervals: List) = + minimumIntervals(JsonField.of(minimumIntervals)) + + /** The minimum intervals for this subscription. */ + fun minimumIntervals(minimumIntervals: JsonField>) = apply { + this.minimumIntervals = minimumIntervals.map { it.toMutableList() } + } + + /** The minimum intervals for this subscription. */ + fun addMinimumInterval(minimumInterval: MinimumIntervalModel) = apply { + minimumIntervals = + (minimumIntervals ?: JsonField.of(mutableListOf())).also { + checkKnown("minimumIntervals", it).add(minimumInterval) + } + } + + /** + * Determines the difference between the invoice issue date for subscription invoices as the + * date that they are due. A value of `0` here represents that the invoice is due on issue, + * whereas a value of `30` represents that the customer has a month to pay the invoice. + */ + fun netTerms(netTerms: Long) = netTerms(JsonField.of(netTerms)) + + /** + * Determines the difference between the invoice issue date for subscription invoices as the + * date that they are due. A value of `0` here represents that the invoice is due on issue, + * whereas a value of `30` represents that the customer has a month to pay the invoice. + */ + fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } + + /** + * 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 plan(plan: PlanModel) = plan(JsonField.of(plan)) + + /** + * 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 plan(plan: JsonField) = apply { this.plan = plan } + + /** The price intervals for this subscription. */ + fun priceIntervals(priceIntervals: List) = + priceIntervals(JsonField.of(priceIntervals)) + + /** The price intervals for this subscription. */ + fun priceIntervals(priceIntervals: JsonField>) = apply { + this.priceIntervals = priceIntervals.map { it.toMutableList() } + } + + /** The price intervals for this subscription. */ + fun addPriceInterval(priceInterval: PriceIntervalModel) = apply { + priceIntervals = + (priceIntervals ?: JsonField.of(mutableListOf())).also { + checkKnown("priceIntervals", it).add(priceInterval) + } + } + + fun redeemedCoupon(redeemedCoupon: CouponRedemptionModel?) = + redeemedCoupon(JsonField.ofNullable(redeemedCoupon)) + + fun redeemedCoupon(redeemedCoupon: Optional) = + redeemedCoupon(redeemedCoupon.orElse(null)) + + fun redeemedCoupon(redeemedCoupon: JsonField) = apply { + this.redeemedCoupon = redeemedCoupon + } + + /** The date Orb starts billing for this subscription. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The date Orb starts billing for this subscription. */ + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + fun status(status: Status) = status(JsonField.of(status)) + + fun status(status: JsonField) = apply { this.status = status } + + fun trialInfo(trialInfo: SubscriptionTrialInfoModel) = trialInfo(JsonField.of(trialInfo)) + + fun trialInfo(trialInfo: JsonField) = apply { + this.trialInfo = trialInfo + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): SubscriptionModel = + SubscriptionModel( + checkRequired("id", id), + checkRequired("activePlanPhaseOrder", activePlanPhaseOrder), + checkRequired("adjustmentIntervals", adjustmentIntervals).map { it.toImmutable() }, + checkRequired("autoCollection", autoCollection), + checkRequired("billingCycleAnchorConfiguration", billingCycleAnchorConfiguration), + checkRequired("billingCycleDay", billingCycleDay), + checkRequired("createdAt", createdAt), + checkRequired("currentBillingPeriodEndDate", currentBillingPeriodEndDate), + checkRequired("currentBillingPeriodStartDate", currentBillingPeriodStartDate), + checkRequired("customer", customer), + checkRequired("defaultInvoiceMemo", defaultInvoiceMemo), + checkRequired("discountIntervals", discountIntervals).map { it.toImmutable() }, + checkRequired("endDate", endDate), + checkRequired("fixedFeeQuantitySchedule", fixedFeeQuantitySchedule).map { + it.toImmutable() + }, + checkRequired("invoicingThreshold", invoicingThreshold), + checkRequired("maximumIntervals", maximumIntervals).map { it.toImmutable() }, + checkRequired("metadata", metadata), + checkRequired("minimumIntervals", minimumIntervals).map { it.toImmutable() }, + checkRequired("netTerms", netTerms), + checkRequired("plan", plan), + checkRequired("priceIntervals", priceIntervals).map { it.toImmutable() }, + checkRequired("redeemedCoupon", redeemedCoupon), + checkRequired("startDate", startDate), + checkRequired("status", status), + checkRequired("trialInfo", trialInfo), + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(using = DiscountInterval.Deserializer::class) + @JsonSerialize(using = DiscountInterval.Serializer::class) + class DiscountInterval + private constructor( + private val amountDiscountIntervalModel: AmountDiscountIntervalModel? = null, + private val percentageDiscountIntervalModel: PercentageDiscountIntervalModel? = null, + private val usageDiscountIntervalModel: UsageDiscountIntervalModel? = null, + private val _json: JsonValue? = null, + ) { + + fun amountDiscountIntervalModel(): Optional = + Optional.ofNullable(amountDiscountIntervalModel) + + fun percentageDiscountIntervalModel(): Optional = + Optional.ofNullable(percentageDiscountIntervalModel) + + fun usageDiscountIntervalModel(): Optional = + Optional.ofNullable(usageDiscountIntervalModel) + + fun isAmountDiscountIntervalModel(): Boolean = amountDiscountIntervalModel != null + + fun isPercentageDiscountIntervalModel(): Boolean = percentageDiscountIntervalModel != null + + fun isUsageDiscountIntervalModel(): Boolean = usageDiscountIntervalModel != null + + fun asAmountDiscountIntervalModel(): AmountDiscountIntervalModel = + amountDiscountIntervalModel.getOrThrow("amountDiscountIntervalModel") + + fun asPercentageDiscountIntervalModel(): PercentageDiscountIntervalModel = + percentageDiscountIntervalModel.getOrThrow("percentageDiscountIntervalModel") + + fun asUsageDiscountIntervalModel(): UsageDiscountIntervalModel = + usageDiscountIntervalModel.getOrThrow("usageDiscountIntervalModel") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + amountDiscountIntervalModel != null -> + visitor.visitAmountDiscountIntervalModel(amountDiscountIntervalModel) + percentageDiscountIntervalModel != null -> + visitor.visitPercentageDiscountIntervalModel(percentageDiscountIntervalModel) + usageDiscountIntervalModel != null -> + visitor.visitUsageDiscountIntervalModel(usageDiscountIntervalModel) + else -> visitor.unknown(_json) + } + } + + private var validated: Boolean = false + + fun validate(): DiscountInterval = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitAmountDiscountIntervalModel( + amountDiscountIntervalModel: AmountDiscountIntervalModel + ) { + amountDiscountIntervalModel.validate() + } + + override fun visitPercentageDiscountIntervalModel( + percentageDiscountIntervalModel: PercentageDiscountIntervalModel + ) { + percentageDiscountIntervalModel.validate() + } + + override fun visitUsageDiscountIntervalModel( + usageDiscountIntervalModel: UsageDiscountIntervalModel + ) { + usageDiscountIntervalModel.validate() + } + } + ) + validated = true + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountInterval && amountDiscountIntervalModel == other.amountDiscountIntervalModel && percentageDiscountIntervalModel == other.percentageDiscountIntervalModel && usageDiscountIntervalModel == other.usageDiscountIntervalModel /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(amountDiscountIntervalModel, percentageDiscountIntervalModel, usageDiscountIntervalModel) /* spotless:on */ + + override fun toString(): String = + when { + amountDiscountIntervalModel != null -> + "DiscountInterval{amountDiscountIntervalModel=$amountDiscountIntervalModel}" + percentageDiscountIntervalModel != null -> + "DiscountInterval{percentageDiscountIntervalModel=$percentageDiscountIntervalModel}" + usageDiscountIntervalModel != null -> + "DiscountInterval{usageDiscountIntervalModel=$usageDiscountIntervalModel}" + _json != null -> "DiscountInterval{_unknown=$_json}" + else -> throw IllegalStateException("Invalid DiscountInterval") + } + + companion object { + + @JvmStatic + fun ofAmountDiscountIntervalModel( + amountDiscountIntervalModel: AmountDiscountIntervalModel + ) = DiscountInterval(amountDiscountIntervalModel = amountDiscountIntervalModel) + + @JvmStatic + fun ofPercentageDiscountIntervalModel( + percentageDiscountIntervalModel: PercentageDiscountIntervalModel + ) = DiscountInterval(percentageDiscountIntervalModel = percentageDiscountIntervalModel) + + @JvmStatic + fun ofUsageDiscountIntervalModel( + usageDiscountIntervalModel: UsageDiscountIntervalModel + ) = DiscountInterval(usageDiscountIntervalModel = usageDiscountIntervalModel) + } + + /** + * An interface that defines how to map each variant of [DiscountInterval] to a value of + * type [T]. + */ + interface Visitor { + + fun visitAmountDiscountIntervalModel( + amountDiscountIntervalModel: AmountDiscountIntervalModel + ): T + + fun visitPercentageDiscountIntervalModel( + percentageDiscountIntervalModel: PercentageDiscountIntervalModel + ): T + + fun visitUsageDiscountIntervalModel( + usageDiscountIntervalModel: UsageDiscountIntervalModel + ): T + + /** + * Maps an unknown variant of [DiscountInterval] to a value of type [T]. + * + * An instance of [DiscountInterval] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the SDK + * is on an older version than the API, then the API may respond with new variants that + * the SDK is unaware of. + * + * @throws OrbInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OrbInvalidDataException("Unknown DiscountInterval: $json") + } + } + + internal class Deserializer : BaseDeserializer(DiscountInterval::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): DiscountInterval { + val json = JsonValue.fromJsonNode(node) + val discountType = + json.asObject().getOrNull()?.get("discount_type")?.asString()?.getOrNull() + + when (discountType) { + "amount" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return DiscountInterval( + amountDiscountIntervalModel = it, + _json = json, + ) + } + } + "percentage" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return DiscountInterval( + percentageDiscountIntervalModel = it, + _json = json, + ) + } + } + "usage" -> { + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return DiscountInterval( + usageDiscountIntervalModel = it, + _json = json, + ) + } + } + } + + return DiscountInterval(_json = json) + } + } + + internal class Serializer : BaseSerializer(DiscountInterval::class) { + + override fun serialize( + value: DiscountInterval, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.amountDiscountIntervalModel != null -> + generator.writeObject(value.amountDiscountIntervalModel) + value.percentageDiscountIntervalModel != null -> + generator.writeObject(value.percentageDiscountIntervalModel) + value.usageDiscountIntervalModel != null -> + generator.writeObject(value.usageDiscountIntervalModel) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid DiscountInterval") + } + } + } + } + + /** + * 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`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + class 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 ENDED = of("ended") + + @JvmField val UPCOMING = of("upcoming") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + ENDED, + UPCOMING, + } + + /** + * 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, + ENDED, + UPCOMING, + /** 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 + ENDED -> Value.ENDED + UPCOMING -> Value.UPCOMING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to 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 + ENDED -> Known.ENDED + UPCOMING -> Known.UPCOMING + 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") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SubscriptionModel && id == other.id && activePlanPhaseOrder == other.activePlanPhaseOrder && adjustmentIntervals == other.adjustmentIntervals && autoCollection == other.autoCollection && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && billingCycleDay == other.billingCycleDay && createdAt == other.createdAt && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && customer == other.customer && defaultInvoiceMemo == other.defaultInvoiceMemo && discountIntervals == other.discountIntervals && endDate == other.endDate && fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && invoicingThreshold == other.invoicingThreshold && maximumIntervals == other.maximumIntervals && metadata == other.metadata && minimumIntervals == other.minimumIntervals && netTerms == other.netTerms && plan == other.plan && priceIntervals == other.priceIntervals && redeemedCoupon == other.redeemedCoupon && startDate == other.startDate && status == other.status && trialInfo == other.trialInfo && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, activePlanPhaseOrder, adjustmentIntervals, autoCollection, billingCycleAnchorConfiguration, billingCycleDay, createdAt, currentBillingPeriodEndDate, currentBillingPeriodStartDate, customer, defaultInvoiceMemo, discountIntervals, endDate, fixedFeeQuantitySchedule, invoicingThreshold, maximumIntervals, metadata, minimumIntervals, netTerms, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SubscriptionModel{id=$id, activePlanPhaseOrder=$activePlanPhaseOrder, adjustmentIntervals=$adjustmentIntervals, autoCollection=$autoCollection, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, billingCycleDay=$billingCycleDay, createdAt=$createdAt, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, customer=$customer, defaultInvoiceMemo=$defaultInvoiceMemo, discountIntervals=$discountIntervals, endDate=$endDate, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, invoicingThreshold=$invoicingThreshold, maximumIntervals=$maximumIntervals, metadata=$metadata, minimumIntervals=$minimumIntervals, netTerms=$netTerms, plan=$plan, priceIntervals=$priceIntervals, redeemedCoupon=$redeemedCoupon, startDate=$startDate, status=$status, trialInfo=$trialInfo, additionalProperties=$additionalProperties}" +} 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 3dcd19925..dea67ce2c 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 @@ -22,6 +22,7 @@ import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.Params +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.getOrThrow import com.withorb.api.core.http.Headers @@ -261,6 +262,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Body]. */ @JvmStatic fun builder() = Builder() } @@ -293,14 +295,8 @@ private constructor( /** A list of price intervals to add to the subscription. */ fun addAdd(add: Add) = apply { this.add = - (this.add ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(add) + (this.add ?: JsonField.of(mutableListOf())).also { + checkKnown("add", it).add(add) } } @@ -316,14 +312,8 @@ private constructor( /** A list of adjustments to add to the subscription. */ fun addAddAdjustment(addAdjustment: AddAdjustment) = apply { addAdjustments = - (addAdjustments ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(addAdjustment) + (addAdjustments ?: JsonField.of(mutableListOf())).also { + checkKnown("addAdjustments", it).add(addAdjustment) } } @@ -372,14 +362,8 @@ private constructor( /** A list of price intervals to edit on the subscription. */ fun addEdit(edit: Edit) = apply { this.edit = - (this.edit ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(edit) + (this.edit ?: JsonField.of(mutableListOf())).also { + checkKnown("edit", it).add(edit) } } @@ -395,14 +379,8 @@ private constructor( /** A list of adjustments to edit on the subscription. */ fun addEditAdjustment(editAdjustment: EditAdjustment) = apply { editAdjustments = - (editAdjustments ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(editAdjustment) + (editAdjustments ?: JsonField.of(mutableListOf())).also { + checkKnown("editAdjustments", it).add(editAdjustment) } } @@ -458,6 +436,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [SubscriptionPriceIntervalsParams]. + * + * The following fields are required: + * ```java + * .subscriptionId() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -700,7 +687,7 @@ private constructor( private val startDate: JsonField = JsonMissing.of(), @JsonProperty("allocation_price") @ExcludeMissing - private val allocationPrice: JsonField = JsonMissing.of(), + private val allocationPrice: JsonField = JsonMissing.of(), @JsonProperty("discounts") @ExcludeMissing private val discounts: JsonField> = JsonMissing.of(), @@ -715,7 +702,8 @@ private constructor( private val filter: JsonField = JsonMissing.of(), @JsonProperty("fixed_fee_quantity_transitions") @ExcludeMissing - private val fixedFeeQuantityTransitions: JsonField> = + private val fixedFeeQuantityTransitions: + JsonField> = JsonMissing.of(), @JsonProperty("maximum_amount") @ExcludeMissing @@ -725,7 +713,7 @@ private constructor( private val minimumAmount: JsonField = JsonMissing.of(), @JsonProperty("price") @ExcludeMissing - private val price: JsonField = JsonMissing.of(), + private val price: JsonField = JsonMissing.of(), @JsonProperty("price_id") @ExcludeMissing private val priceId: JsonField = JsonMissing.of(), @@ -743,7 +731,7 @@ private constructor( fun startDate(): StartDate = startDate.getRequired("start_date") /** The definition of a new allocation price to create and add to the subscription. */ - fun allocationPrice(): Optional = + fun allocationPrice(): Optional = Optional.ofNullable(allocationPrice.getNullable("allocation_price")) /** A list of discounts to initialize on the price interval. */ @@ -768,7 +756,8 @@ private constructor( fun filter(): Optional = Optional.ofNullable(filter.getNullable("filter")) /** A list of fixed fee quantity transitions to initialize on the price interval. */ - fun fixedFeeQuantityTransitions(): Optional> = + fun fixedFeeQuantityTransitions(): + Optional> = Optional.ofNullable( fixedFeeQuantityTransitions.getNullable("fixed_fee_quantity_transitions") ) @@ -788,7 +777,8 @@ private constructor( Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) /** The definition of a new price to create and add to the subscription. */ - fun price(): Optional = Optional.ofNullable(price.getNullable("price")) + fun price(): Optional = + Optional.ofNullable(price.getNullable("price")) /** The id of the price to add to the subscription. */ fun priceId(): Optional = Optional.ofNullable(priceId.getNullable("price_id")) @@ -814,7 +804,7 @@ private constructor( /** The definition of a new allocation price to create and add to the subscription. */ @JsonProperty("allocation_price") @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice + fun _allocationPrice(): JsonField = allocationPrice /** A list of discounts to initialize on the price interval. */ @JsonProperty("discounts") @@ -842,7 +832,8 @@ private constructor( /** A list of fixed fee quantity transitions to initialize on the price interval. */ @JsonProperty("fixed_fee_quantity_transitions") @ExcludeMissing - fun _fixedFeeQuantityTransitions(): JsonField> = + fun _fixedFeeQuantityTransitions(): + JsonField> = fixedFeeQuantityTransitions /** @@ -862,7 +853,9 @@ private constructor( fun _minimumAmount(): JsonField = minimumAmount /** The definition of a new price to create and add to the subscription. */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + @JsonProperty("price") + @ExcludeMissing + fun _price(): JsonField = price /** The id of the price to add to the subscription. */ @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId @@ -908,6 +901,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Add]. + * + * The following fields are required: + * ```java + * .startDate() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -915,17 +916,17 @@ private constructor( class Builder internal constructor() { private var startDate: JsonField? = null - private var allocationPrice: JsonField = JsonMissing.of() + private var allocationPrice: JsonField = JsonMissing.of() private var discounts: JsonField>? = null private var endDate: JsonField = JsonMissing.of() private var externalPriceId: JsonField = JsonMissing.of() private var filter: JsonField = JsonMissing.of() private var fixedFeeQuantityTransitions: - JsonField>? = + JsonField>? = null private var maximumAmount: JsonField = JsonMissing.of() private var minimumAmount: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() private var priceId: JsonField = JsonMissing.of() private var usageCustomerIds: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -974,15 +975,15 @@ private constructor( startDate(StartDate.ofBillingCycleRelative(billingCycleRelative)) /** The definition of a new allocation price to create and add to the subscription. */ - fun allocationPrice(allocationPrice: AllocationPrice?) = + fun allocationPrice(allocationPrice: NewAllocationPriceModel?) = allocationPrice(JsonField.ofNullable(allocationPrice)) /** The definition of a new allocation price to create and add to the subscription. */ - fun allocationPrice(allocationPrice: Optional) = + fun allocationPrice(allocationPrice: Optional) = allocationPrice(allocationPrice.orElse(null)) /** The definition of a new allocation price to create and add to the subscription. */ - fun allocationPrice(allocationPrice: JsonField) = apply { + fun allocationPrice(allocationPrice: JsonField) = apply { this.allocationPrice = allocationPrice } @@ -1000,14 +1001,8 @@ private constructor( /** A list of discounts to initialize on the price interval. */ fun addDiscount(discount: Discount) = apply { discounts = - (discounts ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(discount) + (discounts ?: JsonField.of(mutableListOf())).also { + checkKnown("discounts", it).add(discount) } } @@ -1136,17 +1131,19 @@ private constructor( /** A list of fixed fee quantity transitions to initialize on the price interval. */ fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: List? + fixedFeeQuantityTransitions: List? ) = fixedFeeQuantityTransitions(JsonField.ofNullable(fixedFeeQuantityTransitions)) /** A list of fixed fee quantity transitions to initialize on the price interval. */ fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: Optional> + fixedFeeQuantityTransitions: + Optional> ) = fixedFeeQuantityTransitions(fixedFeeQuantityTransitions.orElse(null)) /** A list of fixed fee quantity transitions to initialize on the price interval. */ fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: JsonField> + fixedFeeQuantityTransitions: + JsonField> ) = apply { this.fixedFeeQuantityTransitions = fixedFeeQuantityTransitions.map { it.toMutableList() } @@ -1154,16 +1151,11 @@ private constructor( /** A list of fixed fee quantity transitions to initialize on the price interval. */ fun addFixedFeeQuantityTransition( - fixedFeeQuantityTransition: FixedFeeQuantityTransition + fixedFeeQuantityTransition: PriceIntervalFixedFeeQuantityTransitionModel ) = apply { fixedFeeQuantityTransitions = - (fixedFeeQuantityTransitions ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } + (fixedFeeQuantityTransitions ?: JsonField.of(mutableListOf())).also { + checkKnown("fixedFeeQuantityTransitions", it) .add(fixedFeeQuantityTransition) } } @@ -1227,161 +1219,191 @@ private constructor( } /** The definition of a new price to create and add to the subscription. */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) + fun price(price: NewFloatingPriceModel?) = price(JsonField.ofNullable(price)) /** The definition of a new price to create and add to the subscription. */ - fun price(price: Optional) = price(price.orElse(null)) + fun price(price: Optional) = price(price.orElse(null)) /** The definition of a new price to create and add to the subscription. */ - fun price(price: JsonField) = apply { this.price = price } + fun price(price: JsonField) = apply { this.price = price } /** The definition of a new price to create and add to the subscription. */ - fun price(newFloatingUnit: Price.NewFloatingUnitPrice) = - price(Price.ofNewFloatingUnit(newFloatingUnit)) + fun price(unitPrice: NewFloatingPriceModel.NewFloatingUnitPrice) = + price(NewFloatingPriceModel.ofUnitPrice(unitPrice)) /** The definition of a new price to create and add to the subscription. */ - fun price(newFloatingPackage: Price.NewFloatingPackagePrice) = - price(Price.ofNewFloatingPackage(newFloatingPackage)) + fun price(packagePrice: NewFloatingPriceModel.NewFloatingPackagePrice) = + price(NewFloatingPriceModel.ofPackagePrice(packagePrice)) /** The definition of a new price to create and add to the subscription. */ - fun price(newFloatingMatrix: Price.NewFloatingMatrixPrice) = - price(Price.ofNewFloatingMatrix(newFloatingMatrix)) + fun price(matrixPrice: NewFloatingPriceModel.NewFloatingMatrixPrice) = + price(NewFloatingPriceModel.ofMatrixPrice(matrixPrice)) /** The definition of a new price to create and add to the subscription. */ - fun price(newFloatingMatrixWithAllocation: Price.NewFloatingMatrixWithAllocationPrice) = - price(Price.ofNewFloatingMatrixWithAllocation(newFloatingMatrixWithAllocation)) + fun price( + matrixWithAllocationPrice: + NewFloatingPriceModel.NewFloatingMatrixWithAllocationPrice + ) = price(NewFloatingPriceModel.ofMatrixWithAllocationPrice(matrixWithAllocationPrice)) /** The definition of a new price to create and add to the subscription. */ - fun price(newFloatingTiered: Price.NewFloatingTieredPrice) = - price(Price.ofNewFloatingTiered(newFloatingTiered)) + fun price(tieredPrice: NewFloatingPriceModel.NewFloatingTieredPrice) = + price(NewFloatingPriceModel.ofTieredPrice(tieredPrice)) /** The definition of a new price to create and add to the subscription. */ - fun price(newFloatingTieredBps: Price.NewFloatingTieredBpsPrice) = - price(Price.ofNewFloatingTieredBps(newFloatingTieredBps)) + fun price(tieredBpsPrice: NewFloatingPriceModel.NewFloatingTieredBpsPrice) = + price(NewFloatingPriceModel.ofTieredBpsPrice(tieredBpsPrice)) /** The definition of a new price to create and add to the subscription. */ - fun price(newFloatingBps: Price.NewFloatingBpsPrice) = - price(Price.ofNewFloatingBps(newFloatingBps)) + fun price(bpsPrice: NewFloatingPriceModel.NewFloatingBpsPrice) = + price(NewFloatingPriceModel.ofBpsPrice(bpsPrice)) /** The definition of a new price to create and add to the subscription. */ - fun price(newFloatingBulkBps: Price.NewFloatingBulkBpsPrice) = - price(Price.ofNewFloatingBulkBps(newFloatingBulkBps)) + fun price(bulkBpsPrice: NewFloatingPriceModel.NewFloatingBulkBpsPrice) = + price(NewFloatingPriceModel.ofBulkBpsPrice(bulkBpsPrice)) /** The definition of a new price to create and add to the subscription. */ - fun price(newFloatingBulk: Price.NewFloatingBulkPrice) = - price(Price.ofNewFloatingBulk(newFloatingBulk)) + fun price(bulkPrice: NewFloatingPriceModel.NewFloatingBulkPrice) = + price(NewFloatingPriceModel.ofBulkPrice(bulkPrice)) /** The definition of a new price to create and add to the subscription. */ - fun price(newFloatingThresholdTotalAmount: Price.NewFloatingThresholdTotalAmountPrice) = - price(Price.ofNewFloatingThresholdTotalAmount(newFloatingThresholdTotalAmount)) + fun price( + thresholdTotalAmountPrice: + NewFloatingPriceModel.NewFloatingThresholdTotalAmountPrice + ) = price(NewFloatingPriceModel.ofThresholdTotalAmountPrice(thresholdTotalAmountPrice)) /** The definition of a new price to create and add to the subscription. */ - fun price(newFloatingTieredPackage: Price.NewFloatingTieredPackagePrice) = - price(Price.ofNewFloatingTieredPackage(newFloatingTieredPackage)) + fun price(tieredPackagePrice: NewFloatingPriceModel.NewFloatingTieredPackagePrice) = + price(NewFloatingPriceModel.ofTieredPackagePrice(tieredPackagePrice)) /** The definition of a new price to create and add to the subscription. */ - fun price(newFloatingGroupedTiered: Price.NewFloatingGroupedTieredPrice) = - price(Price.ofNewFloatingGroupedTiered(newFloatingGroupedTiered)) + fun price(groupedTieredPrice: NewFloatingPriceModel.NewFloatingGroupedTieredPrice) = + price(NewFloatingPriceModel.ofGroupedTieredPrice(groupedTieredPrice)) /** The definition of a new price to create and add to the subscription. */ fun price( - newFloatingMaxGroupTieredPackage: Price.NewFloatingMaxGroupTieredPackagePrice - ) = price(Price.ofNewFloatingMaxGroupTieredPackage(newFloatingMaxGroupTieredPackage)) + maxGroupTieredPackagePrice: + NewFloatingPriceModel.NewFloatingMaxGroupTieredPackagePrice + ) = + price( + NewFloatingPriceModel.ofMaxGroupTieredPackagePrice(maxGroupTieredPackagePrice) + ) /** The definition of a new price to create and add to the subscription. */ - fun price(newFloatingTieredWithMinimum: Price.NewFloatingTieredWithMinimumPrice) = - price(Price.ofNewFloatingTieredWithMinimum(newFloatingTieredWithMinimum)) + fun price( + tieredWithMinimumPrice: NewFloatingPriceModel.NewFloatingTieredWithMinimumPrice + ) = price(NewFloatingPriceModel.ofTieredWithMinimumPrice(tieredWithMinimumPrice)) /** The definition of a new price to create and add to the subscription. */ fun price( - newFloatingPackageWithAllocation: Price.NewFloatingPackageWithAllocationPrice - ) = price(Price.ofNewFloatingPackageWithAllocation(newFloatingPackageWithAllocation)) + packageWithAllocationPrice: + NewFloatingPriceModel.NewFloatingPackageWithAllocationPrice + ) = + price( + NewFloatingPriceModel.ofPackageWithAllocationPrice(packageWithAllocationPrice) + ) /** The definition of a new price to create and add to the subscription. */ fun price( - newFloatingTieredPackageWithMinimum: Price.NewFloatingTieredPackageWithMinimumPrice + tieredPackageWithMinimumPrice: + NewFloatingPriceModel.NewFloatingTieredPackageWithMinimumPrice ) = price( - Price.ofNewFloatingTieredPackageWithMinimum(newFloatingTieredPackageWithMinimum) + NewFloatingPriceModel.ofTieredPackageWithMinimumPrice( + tieredPackageWithMinimumPrice + ) ) /** The definition of a new price to create and add to the subscription. */ - fun price(newFloatingUnitWithPercent: Price.NewFloatingUnitWithPercentPrice) = - price(Price.ofNewFloatingUnitWithPercent(newFloatingUnitWithPercent)) + fun price(unitWithPercentPrice: NewFloatingPriceModel.NewFloatingUnitWithPercentPrice) = + price(NewFloatingPriceModel.ofUnitWithPercentPrice(unitWithPercentPrice)) /** The definition of a new price to create and add to the subscription. */ - fun price(newFloatingTieredWithProration: Price.NewFloatingTieredWithProrationPrice) = - price(Price.ofNewFloatingTieredWithProration(newFloatingTieredWithProration)) + fun price( + tieredWithProrationPrice: NewFloatingPriceModel.NewFloatingTieredWithProrationPrice + ) = price(NewFloatingPriceModel.ofTieredWithProrationPrice(tieredWithProrationPrice)) /** The definition of a new price to create and add to the subscription. */ - fun price(newFloatingUnitWithProration: Price.NewFloatingUnitWithProrationPrice) = - price(Price.ofNewFloatingUnitWithProration(newFloatingUnitWithProration)) + fun price( + unitWithProrationPrice: NewFloatingPriceModel.NewFloatingUnitWithProrationPrice + ) = price(NewFloatingPriceModel.ofUnitWithProrationPrice(unitWithProrationPrice)) /** The definition of a new price to create and add to the subscription. */ - fun price(newFloatingGroupedAllocation: Price.NewFloatingGroupedAllocationPrice) = - price(Price.ofNewFloatingGroupedAllocation(newFloatingGroupedAllocation)) + fun price( + groupedAllocationPrice: NewFloatingPriceModel.NewFloatingGroupedAllocationPrice + ) = price(NewFloatingPriceModel.ofGroupedAllocationPrice(groupedAllocationPrice)) /** The definition of a new price to create and add to the subscription. */ fun price( - newFloatingGroupedWithProratedMinimum: - Price.NewFloatingGroupedWithProratedMinimumPrice + groupedWithProratedMinimumPrice: + NewFloatingPriceModel.NewFloatingGroupedWithProratedMinimumPrice ) = price( - Price.ofNewFloatingGroupedWithProratedMinimum( - newFloatingGroupedWithProratedMinimum + NewFloatingPriceModel.ofGroupedWithProratedMinimumPrice( + groupedWithProratedMinimumPrice ) ) /** The definition of a new price to create and add to the subscription. */ fun price( - newFloatingGroupedWithMeteredMinimum: - Price.NewFloatingGroupedWithMeteredMinimumPrice + groupedWithMeteredMinimumPrice: + NewFloatingPriceModel.NewFloatingGroupedWithMeteredMinimumPrice ) = price( - Price.ofNewFloatingGroupedWithMeteredMinimum( - newFloatingGroupedWithMeteredMinimum + NewFloatingPriceModel.ofGroupedWithMeteredMinimumPrice( + groupedWithMeteredMinimumPrice ) ) /** The definition of a new price to create and add to the subscription. */ fun price( - newFloatingMatrixWithDisplayName: Price.NewFloatingMatrixWithDisplayNamePrice - ) = price(Price.ofNewFloatingMatrixWithDisplayName(newFloatingMatrixWithDisplayName)) + matrixWithDisplayNamePrice: + NewFloatingPriceModel.NewFloatingMatrixWithDisplayNamePrice + ) = + price( + NewFloatingPriceModel.ofMatrixWithDisplayNamePrice(matrixWithDisplayNamePrice) + ) /** The definition of a new price to create and add to the subscription. */ - fun price(newFloatingBulkWithProration: Price.NewFloatingBulkWithProrationPrice) = - price(Price.ofNewFloatingBulkWithProration(newFloatingBulkWithProration)) + fun price( + bulkWithProrationPrice: NewFloatingPriceModel.NewFloatingBulkWithProrationPrice + ) = price(NewFloatingPriceModel.ofBulkWithProrationPrice(bulkWithProrationPrice)) /** The definition of a new price to create and add to the subscription. */ - fun price(newFloatingGroupedTieredPackage: Price.NewFloatingGroupedTieredPackagePrice) = - price(Price.ofNewFloatingGroupedTieredPackage(newFloatingGroupedTieredPackage)) + fun price( + groupedTieredPackagePrice: + NewFloatingPriceModel.NewFloatingGroupedTieredPackagePrice + ) = price(NewFloatingPriceModel.ofGroupedTieredPackagePrice(groupedTieredPackagePrice)) /** The definition of a new price to create and add to the subscription. */ fun price( - newFloatingScalableMatrixWithUnitPricing: - Price.NewFloatingScalableMatrixWithUnitPricingPrice + scalableMatrixWithUnitPricingPrice: + NewFloatingPriceModel.NewFloatingScalableMatrixWithUnitPricingPrice ) = price( - Price.ofNewFloatingScalableMatrixWithUnitPricing( - newFloatingScalableMatrixWithUnitPricing + NewFloatingPriceModel.ofScalableMatrixWithUnitPricingPrice( + scalableMatrixWithUnitPricingPrice ) ) /** The definition of a new price to create and add to the subscription. */ fun price( - newFloatingScalableMatrixWithTieredPricing: - Price.NewFloatingScalableMatrixWithTieredPricingPrice + scalableMatrixWithTieredPricingPrice: + NewFloatingPriceModel.NewFloatingScalableMatrixWithTieredPricingPrice ) = price( - Price.ofNewFloatingScalableMatrixWithTieredPricing( - newFloatingScalableMatrixWithTieredPricing + NewFloatingPriceModel.ofScalableMatrixWithTieredPricingPrice( + scalableMatrixWithTieredPricingPrice ) ) /** The definition of a new price to create and add to the subscription. */ fun price( - newFloatingCumulativeGroupedBulk: Price.NewFloatingCumulativeGroupedBulkPrice - ) = price(Price.ofNewFloatingCumulativeGroupedBulk(newFloatingCumulativeGroupedBulk)) + cumulativeGroupedBulkPrice: + NewFloatingPriceModel.NewFloatingCumulativeGroupedBulkPrice + ) = + price( + NewFloatingPriceModel.ofCumulativeGroupedBulkPrice(cumulativeGroupedBulkPrice) + ) /** The id of the price to add to the subscription. */ fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) @@ -1436,14 +1458,8 @@ private constructor( */ fun addUsageCustomerId(usageCustomerId: String) = apply { usageCustomerIds = - (usageCustomerIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(usageCustomerId) + (usageCustomerIds ?: JsonField.of(mutableListOf())).also { + checkKnown("usageCustomerIds", it).add(usageCustomerId) } } @@ -1628,331 +1644,6 @@ private constructor( } } - /** The definition of a new allocation price to create and add to the subscription. */ - @NoAutoDetect - class AllocationPrice - @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("expires_at_end_of_cadence") - @ExcludeMissing - private val expiresAtEndOfCadence: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** An amount of the currency to allocate to the customer at the specified cadence. */ - fun amount(): String = amount.getRequired("amount") - - /** The cadence at which to allocate the amount to the customer. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** - * An ISO 4217 currency string or a custom pricing unit identifier in which to bill this - * price. - */ - fun currency(): String = currency.getRequired("currency") - - /** - * Whether the allocated amount should expire at the end of the cadence or roll over to - * the next period. - */ - fun expiresAtEndOfCadence(): Boolean = - expiresAtEndOfCadence.getRequired("expires_at_end_of_cadence") - - /** An amount of the currency to allocate to the customer at the specified cadence. */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** The cadence at which to allocate the amount to the customer. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** - * An ISO 4217 currency string or a custom pricing unit identifier in which to bill this - * price. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** - * Whether the allocated amount should expire at the end of the cadence or roll over to - * the next period. - */ - @JsonProperty("expires_at_end_of_cadence") - @ExcludeMissing - fun _expiresAtEndOfCadence(): JsonField = expiresAtEndOfCadence - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AllocationPrice = apply { - if (validated) { - return@apply - } - - amount() - cadence() - currency() - expiresAtEndOfCadence() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AllocationPrice]. */ - class Builder internal constructor() { - - private var amount: JsonField? = null - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var expiresAtEndOfCadence: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(allocationPrice: AllocationPrice) = apply { - amount = allocationPrice.amount - cadence = allocationPrice.cadence - currency = allocationPrice.currency - expiresAtEndOfCadence = allocationPrice.expiresAtEndOfCadence - additionalProperties = allocationPrice.additionalProperties.toMutableMap() - } - - /** - * An amount of the currency to allocate to the customer at the specified cadence. - */ - fun amount(amount: String) = amount(JsonField.of(amount)) - - /** - * An amount of the currency to allocate to the customer at the specified cadence. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** The cadence at which to allocate the amount to the customer. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence at which to allocate the amount to the customer. */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - /** - * An ISO 4217 currency string or a custom pricing unit identifier in which to bill - * this price. - */ - fun currency(currency: String) = currency(JsonField.of(currency)) - - /** - * An ISO 4217 currency string or a custom pricing unit identifier in which to bill - * this price. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** - * Whether the allocated amount should expire at the end of the cadence or roll over - * to the next period. - */ - fun expiresAtEndOfCadence(expiresAtEndOfCadence: Boolean) = - expiresAtEndOfCadence(JsonField.of(expiresAtEndOfCadence)) - - /** - * Whether the allocated amount should expire at the end of the cadence or roll over - * to the next period. - */ - fun expiresAtEndOfCadence(expiresAtEndOfCadence: JsonField) = apply { - this.expiresAtEndOfCadence = expiresAtEndOfCadence - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): AllocationPrice = - AllocationPrice( - checkRequired("amount", amount), - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("expiresAtEndOfCadence", expiresAtEndOfCadence), - additionalProperties.toImmutable(), - ) - } - - /** The cadence at which to allocate the amount to the customer. */ - 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AllocationPrice && amount == other.amount && cadence == other.cadence && currency == other.currency && expiresAtEndOfCadence == other.expiresAtEndOfCadence && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, cadence, currency, expiresAtEndOfCadence, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AllocationPrice{amount=$amount, cadence=$cadence, currency=$currency, expiresAtEndOfCadence=$expiresAtEndOfCadence, additionalProperties=$additionalProperties}" - } - @JsonDeserialize(using = Discount.Deserializer::class) @JsonSerialize(using = Discount.Serializer::class) class Discount @@ -2220,6 +1911,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [AmountDiscountCreationParams]. + * + * The following fields are required: + * ```java + * .amountDiscount() + * .discountType() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -2460,6 +2161,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [PercentageDiscountCreationParams]. + * + * The following fields are required: + * ```java + * .discountType() + * .percentageDiscount() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -2706,6 +2417,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [UsageDiscountCreationParams]. + * + * The following fields are required: + * ```java + * .discountType() + * .usageDiscount() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -3042,47512 +2763,234 @@ private constructor( } } - @NoAutoDetect - class FixedFeeQuantityTransition - @JsonCreator - private constructor( - @JsonProperty("effective_date") - @ExcludeMissing - private val effectiveDate: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - private val quantity: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The date that the fixed fee quantity transition should take effect. */ - fun effectiveDate(): OffsetDateTime = effectiveDate.getRequired("effective_date") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** The quantity of the fixed fee quantity transition. */ - fun quantity(): Long = quantity.getRequired("quantity") + return /* spotless:off */ other is Add && startDate == other.startDate && allocationPrice == other.allocationPrice && discounts == other.discounts && endDate == other.endDate && externalPriceId == other.externalPriceId && filter == other.filter && fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && maximumAmount == other.maximumAmount && minimumAmount == other.minimumAmount && price == other.price && priceId == other.priceId && usageCustomerIds == other.usageCustomerIds && additionalProperties == other.additionalProperties /* spotless:on */ + } - /** The date that the fixed fee quantity transition should take effect. */ - @JsonProperty("effective_date") - @ExcludeMissing - fun _effectiveDate(): JsonField = effectiveDate + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(startDate, allocationPrice, discounts, endDate, externalPriceId, filter, fixedFeeQuantityTransitions, maximumAmount, minimumAmount, price, priceId, usageCustomerIds, additionalProperties) } + /* spotless:on */ - /** The quantity of the fixed fee quantity transition. */ - @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity + override fun hashCode(): Int = hashCode - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + override fun toString() = + "Add{startDate=$startDate, allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, price=$price, priceId=$priceId, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" + } - private var validated: Boolean = false + @NoAutoDetect + class AddAdjustment + @JsonCreator + private constructor( + @JsonProperty("adjustment") + @ExcludeMissing + private val adjustment: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + private val startDate: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + private val endDate: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { - fun validate(): FixedFeeQuantityTransition = apply { - if (validated) { - return@apply - } + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(): NewAdjustmentModel = adjustment.getRequired("adjustment") - effectiveDate() - quantity() - validated = true - } + /** + * The start date of the adjustment interval. This is the date that the adjustment will + * start affecting prices on the subscription. + */ + fun startDate(): StartDate = startDate.getRequired("start_date") - fun toBuilder() = Builder().from(this) + /** + * The end date of the adjustment interval. This is the date that the adjustment will stop + * affecting prices on the subscription. + */ + fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) - companion object { + /** The definition of a new adjustment to create and add to the subscription. */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment - @JvmStatic fun builder() = Builder() - } + /** + * The start date of the adjustment interval. This is the date that the adjustment will + * start affecting prices on the subscription. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate - /** A builder for [FixedFeeQuantityTransition]. */ - class Builder internal constructor() { + /** + * The end date of the adjustment interval. This is the date that the adjustment will stop + * affecting prices on the subscription. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate - private var effectiveDate: JsonField? = null - private var quantity: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - @JvmSynthetic - internal fun from(fixedFeeQuantityTransition: FixedFeeQuantityTransition) = apply { - effectiveDate = fixedFeeQuantityTransition.effectiveDate - quantity = fixedFeeQuantityTransition.quantity - additionalProperties = - fixedFeeQuantityTransition.additionalProperties.toMutableMap() - } + private var validated: Boolean = false - /** The date that the fixed fee quantity transition should take effect. */ - fun effectiveDate(effectiveDate: OffsetDateTime) = - effectiveDate(JsonField.of(effectiveDate)) + fun validate(): AddAdjustment = apply { + if (validated) { + return@apply + } - /** The date that the fixed fee quantity transition should take effect. */ - fun effectiveDate(effectiveDate: JsonField) = apply { - this.effectiveDate = effectiveDate - } + adjustment().validate() + startDate().validate() + endDate().ifPresent { it.validate() } + validated = true + } - /** The quantity of the fixed fee quantity transition. */ - fun quantity(quantity: Long) = quantity(JsonField.of(quantity)) + fun toBuilder() = Builder().from(this) - /** The quantity of the fixed fee quantity transition. */ - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + companion object { - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns a mutable builder for constructing an instance of [AddAdjustment]. + * + * The following fields are required: + * ```java + * .adjustment() + * .startDate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): FixedFeeQuantityTransition = - FixedFeeQuantityTransition( - checkRequired("effectiveDate", effectiveDate), - checkRequired("quantity", quantity), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FixedFeeQuantityTransition && effectiveDate == other.effectiveDate && quantity == other.quantity && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(effectiveDate, quantity, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "FixedFeeQuantityTransition{effectiveDate=$effectiveDate, quantity=$quantity, additionalProperties=$additionalProperties}" - } - - /** The definition of a new price to create and add to the subscription. */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price - private constructor( - private val newFloatingUnit: NewFloatingUnitPrice? = null, - private val newFloatingPackage: NewFloatingPackagePrice? = null, - private val newFloatingMatrix: NewFloatingMatrixPrice? = null, - private val newFloatingMatrixWithAllocation: NewFloatingMatrixWithAllocationPrice? = - null, - private val newFloatingTiered: NewFloatingTieredPrice? = null, - private val newFloatingTieredBps: NewFloatingTieredBpsPrice? = null, - private val newFloatingBps: NewFloatingBpsPrice? = null, - private val newFloatingBulkBps: NewFloatingBulkBpsPrice? = null, - private val newFloatingBulk: NewFloatingBulkPrice? = null, - private val newFloatingThresholdTotalAmount: NewFloatingThresholdTotalAmountPrice? = - null, - private val newFloatingTieredPackage: NewFloatingTieredPackagePrice? = null, - private val newFloatingGroupedTiered: NewFloatingGroupedTieredPrice? = null, - private val newFloatingMaxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice? = - null, - private val newFloatingTieredWithMinimum: NewFloatingTieredWithMinimumPrice? = null, - private val newFloatingPackageWithAllocation: NewFloatingPackageWithAllocationPrice? = - null, - private val newFloatingTieredPackageWithMinimum: - NewFloatingTieredPackageWithMinimumPrice? = - null, - private val newFloatingUnitWithPercent: NewFloatingUnitWithPercentPrice? = null, - private val newFloatingTieredWithProration: NewFloatingTieredWithProrationPrice? = null, - private val newFloatingUnitWithProration: NewFloatingUnitWithProrationPrice? = null, - private val newFloatingGroupedAllocation: NewFloatingGroupedAllocationPrice? = null, - private val newFloatingGroupedWithProratedMinimum: - NewFloatingGroupedWithProratedMinimumPrice? = - null, - private val newFloatingGroupedWithMeteredMinimum: - NewFloatingGroupedWithMeteredMinimumPrice? = - null, - private val newFloatingMatrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice? = - null, - private val newFloatingBulkWithProration: NewFloatingBulkWithProrationPrice? = null, - private val newFloatingGroupedTieredPackage: NewFloatingGroupedTieredPackagePrice? = - null, - private val newFloatingScalableMatrixWithUnitPricing: - NewFloatingScalableMatrixWithUnitPricingPrice? = - null, - private val newFloatingScalableMatrixWithTieredPricing: - NewFloatingScalableMatrixWithTieredPricingPrice? = - null, - private val newFloatingCumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice? = - null, - private val _json: JsonValue? = null, - ) { - - fun newFloatingUnit(): Optional = - Optional.ofNullable(newFloatingUnit) - - fun newFloatingPackage(): Optional = - Optional.ofNullable(newFloatingPackage) - - fun newFloatingMatrix(): Optional = - Optional.ofNullable(newFloatingMatrix) - - fun newFloatingMatrixWithAllocation(): Optional = - Optional.ofNullable(newFloatingMatrixWithAllocation) - - fun newFloatingTiered(): Optional = - Optional.ofNullable(newFloatingTiered) - - fun newFloatingTieredBps(): Optional = - Optional.ofNullable(newFloatingTieredBps) - - fun newFloatingBps(): Optional = - Optional.ofNullable(newFloatingBps) - - fun newFloatingBulkBps(): Optional = - Optional.ofNullable(newFloatingBulkBps) - - fun newFloatingBulk(): Optional = - Optional.ofNullable(newFloatingBulk) - - fun newFloatingThresholdTotalAmount(): Optional = - Optional.ofNullable(newFloatingThresholdTotalAmount) - - fun newFloatingTieredPackage(): Optional = - Optional.ofNullable(newFloatingTieredPackage) - - fun newFloatingGroupedTiered(): Optional = - Optional.ofNullable(newFloatingGroupedTiered) - - fun newFloatingMaxGroupTieredPackage(): - Optional = - Optional.ofNullable(newFloatingMaxGroupTieredPackage) - - fun newFloatingTieredWithMinimum(): Optional = - Optional.ofNullable(newFloatingTieredWithMinimum) - - fun newFloatingPackageWithAllocation(): - Optional = - Optional.ofNullable(newFloatingPackageWithAllocation) - - fun newFloatingTieredPackageWithMinimum(): - Optional = - Optional.ofNullable(newFloatingTieredPackageWithMinimum) - - fun newFloatingUnitWithPercent(): Optional = - Optional.ofNullable(newFloatingUnitWithPercent) - - fun newFloatingTieredWithProration(): Optional = - Optional.ofNullable(newFloatingTieredWithProration) - - fun newFloatingUnitWithProration(): Optional = - Optional.ofNullable(newFloatingUnitWithProration) - - fun newFloatingGroupedAllocation(): Optional = - Optional.ofNullable(newFloatingGroupedAllocation) - - fun newFloatingGroupedWithProratedMinimum(): - Optional = - Optional.ofNullable(newFloatingGroupedWithProratedMinimum) - - fun newFloatingGroupedWithMeteredMinimum(): - Optional = - Optional.ofNullable(newFloatingGroupedWithMeteredMinimum) - - fun newFloatingMatrixWithDisplayName(): - Optional = - Optional.ofNullable(newFloatingMatrixWithDisplayName) - - fun newFloatingBulkWithProration(): Optional = - Optional.ofNullable(newFloatingBulkWithProration) - - fun newFloatingGroupedTieredPackage(): Optional = - Optional.ofNullable(newFloatingGroupedTieredPackage) - - fun newFloatingScalableMatrixWithUnitPricing(): - Optional = - Optional.ofNullable(newFloatingScalableMatrixWithUnitPricing) - - fun newFloatingScalableMatrixWithTieredPricing(): - Optional = - Optional.ofNullable(newFloatingScalableMatrixWithTieredPricing) - - fun newFloatingCumulativeGroupedBulk(): - Optional = - Optional.ofNullable(newFloatingCumulativeGroupedBulk) - - fun isNewFloatingUnit(): Boolean = newFloatingUnit != null - - fun isNewFloatingPackage(): Boolean = newFloatingPackage != null - - fun isNewFloatingMatrix(): Boolean = newFloatingMatrix != null - - fun isNewFloatingMatrixWithAllocation(): Boolean = - newFloatingMatrixWithAllocation != null - - fun isNewFloatingTiered(): Boolean = newFloatingTiered != null - - fun isNewFloatingTieredBps(): Boolean = newFloatingTieredBps != null - - fun isNewFloatingBps(): Boolean = newFloatingBps != null - - fun isNewFloatingBulkBps(): Boolean = newFloatingBulkBps != null - - fun isNewFloatingBulk(): Boolean = newFloatingBulk != null - - fun isNewFloatingThresholdTotalAmount(): Boolean = - newFloatingThresholdTotalAmount != null - - fun isNewFloatingTieredPackage(): Boolean = newFloatingTieredPackage != null - - fun isNewFloatingGroupedTiered(): Boolean = newFloatingGroupedTiered != null - - fun isNewFloatingMaxGroupTieredPackage(): Boolean = - newFloatingMaxGroupTieredPackage != null - - fun isNewFloatingTieredWithMinimum(): Boolean = newFloatingTieredWithMinimum != null - - fun isNewFloatingPackageWithAllocation(): Boolean = - newFloatingPackageWithAllocation != null - - fun isNewFloatingTieredPackageWithMinimum(): Boolean = - newFloatingTieredPackageWithMinimum != null - - fun isNewFloatingUnitWithPercent(): Boolean = newFloatingUnitWithPercent != null - - fun isNewFloatingTieredWithProration(): Boolean = newFloatingTieredWithProration != null - - fun isNewFloatingUnitWithProration(): Boolean = newFloatingUnitWithProration != null - - fun isNewFloatingGroupedAllocation(): Boolean = newFloatingGroupedAllocation != null - - fun isNewFloatingGroupedWithProratedMinimum(): Boolean = - newFloatingGroupedWithProratedMinimum != null - - fun isNewFloatingGroupedWithMeteredMinimum(): Boolean = - newFloatingGroupedWithMeteredMinimum != null - - fun isNewFloatingMatrixWithDisplayName(): Boolean = - newFloatingMatrixWithDisplayName != null - - fun isNewFloatingBulkWithProration(): Boolean = newFloatingBulkWithProration != null - - fun isNewFloatingGroupedTieredPackage(): Boolean = - newFloatingGroupedTieredPackage != null - - fun isNewFloatingScalableMatrixWithUnitPricing(): Boolean = - newFloatingScalableMatrixWithUnitPricing != null - - fun isNewFloatingScalableMatrixWithTieredPricing(): Boolean = - newFloatingScalableMatrixWithTieredPricing != null - - fun isNewFloatingCumulativeGroupedBulk(): Boolean = - newFloatingCumulativeGroupedBulk != null - - fun asNewFloatingUnit(): NewFloatingUnitPrice = - newFloatingUnit.getOrThrow("newFloatingUnit") - - fun asNewFloatingPackage(): NewFloatingPackagePrice = - newFloatingPackage.getOrThrow("newFloatingPackage") - - fun asNewFloatingMatrix(): NewFloatingMatrixPrice = - newFloatingMatrix.getOrThrow("newFloatingMatrix") - - fun asNewFloatingMatrixWithAllocation(): NewFloatingMatrixWithAllocationPrice = - newFloatingMatrixWithAllocation.getOrThrow("newFloatingMatrixWithAllocation") - - fun asNewFloatingTiered(): NewFloatingTieredPrice = - newFloatingTiered.getOrThrow("newFloatingTiered") - - fun asNewFloatingTieredBps(): NewFloatingTieredBpsPrice = - newFloatingTieredBps.getOrThrow("newFloatingTieredBps") - - fun asNewFloatingBps(): NewFloatingBpsPrice = - newFloatingBps.getOrThrow("newFloatingBps") - - fun asNewFloatingBulkBps(): NewFloatingBulkBpsPrice = - newFloatingBulkBps.getOrThrow("newFloatingBulkBps") - - fun asNewFloatingBulk(): NewFloatingBulkPrice = - newFloatingBulk.getOrThrow("newFloatingBulk") - - fun asNewFloatingThresholdTotalAmount(): NewFloatingThresholdTotalAmountPrice = - newFloatingThresholdTotalAmount.getOrThrow("newFloatingThresholdTotalAmount") - - fun asNewFloatingTieredPackage(): NewFloatingTieredPackagePrice = - newFloatingTieredPackage.getOrThrow("newFloatingTieredPackage") - - fun asNewFloatingGroupedTiered(): NewFloatingGroupedTieredPrice = - newFloatingGroupedTiered.getOrThrow("newFloatingGroupedTiered") - - fun asNewFloatingMaxGroupTieredPackage(): NewFloatingMaxGroupTieredPackagePrice = - newFloatingMaxGroupTieredPackage.getOrThrow("newFloatingMaxGroupTieredPackage") - - fun asNewFloatingTieredWithMinimum(): NewFloatingTieredWithMinimumPrice = - newFloatingTieredWithMinimum.getOrThrow("newFloatingTieredWithMinimum") - - fun asNewFloatingPackageWithAllocation(): NewFloatingPackageWithAllocationPrice = - newFloatingPackageWithAllocation.getOrThrow("newFloatingPackageWithAllocation") - - fun asNewFloatingTieredPackageWithMinimum(): NewFloatingTieredPackageWithMinimumPrice = - newFloatingTieredPackageWithMinimum.getOrThrow( - "newFloatingTieredPackageWithMinimum" - ) - - fun asNewFloatingUnitWithPercent(): NewFloatingUnitWithPercentPrice = - newFloatingUnitWithPercent.getOrThrow("newFloatingUnitWithPercent") - - fun asNewFloatingTieredWithProration(): NewFloatingTieredWithProrationPrice = - newFloatingTieredWithProration.getOrThrow("newFloatingTieredWithProration") - - fun asNewFloatingUnitWithProration(): NewFloatingUnitWithProrationPrice = - newFloatingUnitWithProration.getOrThrow("newFloatingUnitWithProration") - - fun asNewFloatingGroupedAllocation(): NewFloatingGroupedAllocationPrice = - newFloatingGroupedAllocation.getOrThrow("newFloatingGroupedAllocation") - - fun asNewFloatingGroupedWithProratedMinimum(): - NewFloatingGroupedWithProratedMinimumPrice = - newFloatingGroupedWithProratedMinimum.getOrThrow( - "newFloatingGroupedWithProratedMinimum" - ) - - fun asNewFloatingGroupedWithMeteredMinimum(): - NewFloatingGroupedWithMeteredMinimumPrice = - newFloatingGroupedWithMeteredMinimum.getOrThrow( - "newFloatingGroupedWithMeteredMinimum" - ) - - fun asNewFloatingMatrixWithDisplayName(): NewFloatingMatrixWithDisplayNamePrice = - newFloatingMatrixWithDisplayName.getOrThrow("newFloatingMatrixWithDisplayName") - - fun asNewFloatingBulkWithProration(): NewFloatingBulkWithProrationPrice = - newFloatingBulkWithProration.getOrThrow("newFloatingBulkWithProration") - - fun asNewFloatingGroupedTieredPackage(): NewFloatingGroupedTieredPackagePrice = - newFloatingGroupedTieredPackage.getOrThrow("newFloatingGroupedTieredPackage") - - fun asNewFloatingScalableMatrixWithUnitPricing(): - NewFloatingScalableMatrixWithUnitPricingPrice = - newFloatingScalableMatrixWithUnitPricing.getOrThrow( - "newFloatingScalableMatrixWithUnitPricing" - ) - - fun asNewFloatingScalableMatrixWithTieredPricing(): - NewFloatingScalableMatrixWithTieredPricingPrice = - newFloatingScalableMatrixWithTieredPricing.getOrThrow( - "newFloatingScalableMatrixWithTieredPricing" - ) - - fun asNewFloatingCumulativeGroupedBulk(): NewFloatingCumulativeGroupedBulkPrice = - newFloatingCumulativeGroupedBulk.getOrThrow("newFloatingCumulativeGroupedBulk") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - newFloatingUnit != null -> visitor.visitNewFloatingUnit(newFloatingUnit) - newFloatingPackage != null -> - visitor.visitNewFloatingPackage(newFloatingPackage) - newFloatingMatrix != null -> visitor.visitNewFloatingMatrix(newFloatingMatrix) - newFloatingMatrixWithAllocation != null -> - visitor.visitNewFloatingMatrixWithAllocation( - newFloatingMatrixWithAllocation - ) - newFloatingTiered != null -> visitor.visitNewFloatingTiered(newFloatingTiered) - newFloatingTieredBps != null -> - visitor.visitNewFloatingTieredBps(newFloatingTieredBps) - newFloatingBps != null -> visitor.visitNewFloatingBps(newFloatingBps) - newFloatingBulkBps != null -> - visitor.visitNewFloatingBulkBps(newFloatingBulkBps) - newFloatingBulk != null -> visitor.visitNewFloatingBulk(newFloatingBulk) - newFloatingThresholdTotalAmount != null -> - visitor.visitNewFloatingThresholdTotalAmount( - newFloatingThresholdTotalAmount - ) - newFloatingTieredPackage != null -> - visitor.visitNewFloatingTieredPackage(newFloatingTieredPackage) - newFloatingGroupedTiered != null -> - visitor.visitNewFloatingGroupedTiered(newFloatingGroupedTiered) - newFloatingMaxGroupTieredPackage != null -> - visitor.visitNewFloatingMaxGroupTieredPackage( - newFloatingMaxGroupTieredPackage - ) - newFloatingTieredWithMinimum != null -> - visitor.visitNewFloatingTieredWithMinimum(newFloatingTieredWithMinimum) - newFloatingPackageWithAllocation != null -> - visitor.visitNewFloatingPackageWithAllocation( - newFloatingPackageWithAllocation - ) - newFloatingTieredPackageWithMinimum != null -> - visitor.visitNewFloatingTieredPackageWithMinimum( - newFloatingTieredPackageWithMinimum - ) - newFloatingUnitWithPercent != null -> - visitor.visitNewFloatingUnitWithPercent(newFloatingUnitWithPercent) - newFloatingTieredWithProration != null -> - visitor.visitNewFloatingTieredWithProration(newFloatingTieredWithProration) - newFloatingUnitWithProration != null -> - visitor.visitNewFloatingUnitWithProration(newFloatingUnitWithProration) - newFloatingGroupedAllocation != null -> - visitor.visitNewFloatingGroupedAllocation(newFloatingGroupedAllocation) - newFloatingGroupedWithProratedMinimum != null -> - visitor.visitNewFloatingGroupedWithProratedMinimum( - newFloatingGroupedWithProratedMinimum - ) - newFloatingGroupedWithMeteredMinimum != null -> - visitor.visitNewFloatingGroupedWithMeteredMinimum( - newFloatingGroupedWithMeteredMinimum - ) - newFloatingMatrixWithDisplayName != null -> - visitor.visitNewFloatingMatrixWithDisplayName( - newFloatingMatrixWithDisplayName - ) - newFloatingBulkWithProration != null -> - visitor.visitNewFloatingBulkWithProration(newFloatingBulkWithProration) - newFloatingGroupedTieredPackage != null -> - visitor.visitNewFloatingGroupedTieredPackage( - newFloatingGroupedTieredPackage - ) - newFloatingScalableMatrixWithUnitPricing != null -> - visitor.visitNewFloatingScalableMatrixWithUnitPricing( - newFloatingScalableMatrixWithUnitPricing - ) - newFloatingScalableMatrixWithTieredPricing != null -> - visitor.visitNewFloatingScalableMatrixWithTieredPricing( - newFloatingScalableMatrixWithTieredPricing - ) - newFloatingCumulativeGroupedBulk != null -> - visitor.visitNewFloatingCumulativeGroupedBulk( - newFloatingCumulativeGroupedBulk - ) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): Price = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitNewFloatingUnit(newFloatingUnit: NewFloatingUnitPrice) { - newFloatingUnit.validate() - } - - override fun visitNewFloatingPackage( - newFloatingPackage: NewFloatingPackagePrice - ) { - newFloatingPackage.validate() - } - - override fun visitNewFloatingMatrix( - newFloatingMatrix: NewFloatingMatrixPrice - ) { - newFloatingMatrix.validate() - } - - override fun visitNewFloatingMatrixWithAllocation( - newFloatingMatrixWithAllocation: NewFloatingMatrixWithAllocationPrice - ) { - newFloatingMatrixWithAllocation.validate() - } - - override fun visitNewFloatingTiered( - newFloatingTiered: NewFloatingTieredPrice - ) { - newFloatingTiered.validate() - } - - override fun visitNewFloatingTieredBps( - newFloatingTieredBps: NewFloatingTieredBpsPrice - ) { - newFloatingTieredBps.validate() - } - - override fun visitNewFloatingBps(newFloatingBps: NewFloatingBpsPrice) { - newFloatingBps.validate() - } - - override fun visitNewFloatingBulkBps( - newFloatingBulkBps: NewFloatingBulkBpsPrice - ) { - newFloatingBulkBps.validate() - } - - override fun visitNewFloatingBulk(newFloatingBulk: NewFloatingBulkPrice) { - newFloatingBulk.validate() - } - - override fun visitNewFloatingThresholdTotalAmount( - newFloatingThresholdTotalAmount: NewFloatingThresholdTotalAmountPrice - ) { - newFloatingThresholdTotalAmount.validate() - } - - override fun visitNewFloatingTieredPackage( - newFloatingTieredPackage: NewFloatingTieredPackagePrice - ) { - newFloatingTieredPackage.validate() - } - - override fun visitNewFloatingGroupedTiered( - newFloatingGroupedTiered: NewFloatingGroupedTieredPrice - ) { - newFloatingGroupedTiered.validate() - } - - override fun visitNewFloatingMaxGroupTieredPackage( - newFloatingMaxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice - ) { - newFloatingMaxGroupTieredPackage.validate() - } - - override fun visitNewFloatingTieredWithMinimum( - newFloatingTieredWithMinimum: NewFloatingTieredWithMinimumPrice - ) { - newFloatingTieredWithMinimum.validate() - } - - override fun visitNewFloatingPackageWithAllocation( - newFloatingPackageWithAllocation: NewFloatingPackageWithAllocationPrice - ) { - newFloatingPackageWithAllocation.validate() - } - - override fun visitNewFloatingTieredPackageWithMinimum( - newFloatingTieredPackageWithMinimum: - NewFloatingTieredPackageWithMinimumPrice - ) { - newFloatingTieredPackageWithMinimum.validate() - } - - override fun visitNewFloatingUnitWithPercent( - newFloatingUnitWithPercent: NewFloatingUnitWithPercentPrice - ) { - newFloatingUnitWithPercent.validate() - } - - override fun visitNewFloatingTieredWithProration( - newFloatingTieredWithProration: NewFloatingTieredWithProrationPrice - ) { - newFloatingTieredWithProration.validate() - } - - override fun visitNewFloatingUnitWithProration( - newFloatingUnitWithProration: NewFloatingUnitWithProrationPrice - ) { - newFloatingUnitWithProration.validate() - } - - override fun visitNewFloatingGroupedAllocation( - newFloatingGroupedAllocation: NewFloatingGroupedAllocationPrice - ) { - newFloatingGroupedAllocation.validate() - } - - override fun visitNewFloatingGroupedWithProratedMinimum( - newFloatingGroupedWithProratedMinimum: - NewFloatingGroupedWithProratedMinimumPrice - ) { - newFloatingGroupedWithProratedMinimum.validate() - } - - override fun visitNewFloatingGroupedWithMeteredMinimum( - newFloatingGroupedWithMeteredMinimum: - NewFloatingGroupedWithMeteredMinimumPrice - ) { - newFloatingGroupedWithMeteredMinimum.validate() - } - - override fun visitNewFloatingMatrixWithDisplayName( - newFloatingMatrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice - ) { - newFloatingMatrixWithDisplayName.validate() - } - - override fun visitNewFloatingBulkWithProration( - newFloatingBulkWithProration: NewFloatingBulkWithProrationPrice - ) { - newFloatingBulkWithProration.validate() - } - - override fun visitNewFloatingGroupedTieredPackage( - newFloatingGroupedTieredPackage: NewFloatingGroupedTieredPackagePrice - ) { - newFloatingGroupedTieredPackage.validate() - } - - override fun visitNewFloatingScalableMatrixWithUnitPricing( - newFloatingScalableMatrixWithUnitPricing: - NewFloatingScalableMatrixWithUnitPricingPrice - ) { - newFloatingScalableMatrixWithUnitPricing.validate() - } - - override fun visitNewFloatingScalableMatrixWithTieredPricing( - newFloatingScalableMatrixWithTieredPricing: - NewFloatingScalableMatrixWithTieredPricingPrice - ) { - newFloatingScalableMatrixWithTieredPricing.validate() - } - - override fun visitNewFloatingCumulativeGroupedBulk( - newFloatingCumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice - ) { - newFloatingCumulativeGroupedBulk.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Price && newFloatingUnit == other.newFloatingUnit && newFloatingPackage == other.newFloatingPackage && newFloatingMatrix == other.newFloatingMatrix && newFloatingMatrixWithAllocation == other.newFloatingMatrixWithAllocation && newFloatingTiered == other.newFloatingTiered && newFloatingTieredBps == other.newFloatingTieredBps && newFloatingBps == other.newFloatingBps && newFloatingBulkBps == other.newFloatingBulkBps && newFloatingBulk == other.newFloatingBulk && newFloatingThresholdTotalAmount == other.newFloatingThresholdTotalAmount && newFloatingTieredPackage == other.newFloatingTieredPackage && newFloatingGroupedTiered == other.newFloatingGroupedTiered && newFloatingMaxGroupTieredPackage == other.newFloatingMaxGroupTieredPackage && newFloatingTieredWithMinimum == other.newFloatingTieredWithMinimum && newFloatingPackageWithAllocation == other.newFloatingPackageWithAllocation && newFloatingTieredPackageWithMinimum == other.newFloatingTieredPackageWithMinimum && newFloatingUnitWithPercent == other.newFloatingUnitWithPercent && newFloatingTieredWithProration == other.newFloatingTieredWithProration && newFloatingUnitWithProration == other.newFloatingUnitWithProration && newFloatingGroupedAllocation == other.newFloatingGroupedAllocation && newFloatingGroupedWithProratedMinimum == other.newFloatingGroupedWithProratedMinimum && newFloatingGroupedWithMeteredMinimum == other.newFloatingGroupedWithMeteredMinimum && newFloatingMatrixWithDisplayName == other.newFloatingMatrixWithDisplayName && newFloatingBulkWithProration == other.newFloatingBulkWithProration && newFloatingGroupedTieredPackage == other.newFloatingGroupedTieredPackage && newFloatingScalableMatrixWithUnitPricing == other.newFloatingScalableMatrixWithUnitPricing && newFloatingScalableMatrixWithTieredPricing == other.newFloatingScalableMatrixWithTieredPricing && newFloatingCumulativeGroupedBulk == other.newFloatingCumulativeGroupedBulk /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(newFloatingUnit, newFloatingPackage, newFloatingMatrix, newFloatingMatrixWithAllocation, newFloatingTiered, newFloatingTieredBps, newFloatingBps, newFloatingBulkBps, newFloatingBulk, newFloatingThresholdTotalAmount, newFloatingTieredPackage, newFloatingGroupedTiered, newFloatingMaxGroupTieredPackage, newFloatingTieredWithMinimum, newFloatingPackageWithAllocation, newFloatingTieredPackageWithMinimum, newFloatingUnitWithPercent, newFloatingTieredWithProration, newFloatingUnitWithProration, newFloatingGroupedAllocation, newFloatingGroupedWithProratedMinimum, newFloatingGroupedWithMeteredMinimum, newFloatingMatrixWithDisplayName, newFloatingBulkWithProration, newFloatingGroupedTieredPackage, newFloatingScalableMatrixWithUnitPricing, newFloatingScalableMatrixWithTieredPricing, newFloatingCumulativeGroupedBulk) /* spotless:on */ - - override fun toString(): String = - when { - newFloatingUnit != null -> "Price{newFloatingUnit=$newFloatingUnit}" - newFloatingPackage != null -> "Price{newFloatingPackage=$newFloatingPackage}" - newFloatingMatrix != null -> "Price{newFloatingMatrix=$newFloatingMatrix}" - newFloatingMatrixWithAllocation != null -> - "Price{newFloatingMatrixWithAllocation=$newFloatingMatrixWithAllocation}" - newFloatingTiered != null -> "Price{newFloatingTiered=$newFloatingTiered}" - newFloatingTieredBps != null -> - "Price{newFloatingTieredBps=$newFloatingTieredBps}" - newFloatingBps != null -> "Price{newFloatingBps=$newFloatingBps}" - newFloatingBulkBps != null -> "Price{newFloatingBulkBps=$newFloatingBulkBps}" - newFloatingBulk != null -> "Price{newFloatingBulk=$newFloatingBulk}" - newFloatingThresholdTotalAmount != null -> - "Price{newFloatingThresholdTotalAmount=$newFloatingThresholdTotalAmount}" - newFloatingTieredPackage != null -> - "Price{newFloatingTieredPackage=$newFloatingTieredPackage}" - newFloatingGroupedTiered != null -> - "Price{newFloatingGroupedTiered=$newFloatingGroupedTiered}" - newFloatingMaxGroupTieredPackage != null -> - "Price{newFloatingMaxGroupTieredPackage=$newFloatingMaxGroupTieredPackage}" - newFloatingTieredWithMinimum != null -> - "Price{newFloatingTieredWithMinimum=$newFloatingTieredWithMinimum}" - newFloatingPackageWithAllocation != null -> - "Price{newFloatingPackageWithAllocation=$newFloatingPackageWithAllocation}" - newFloatingTieredPackageWithMinimum != null -> - "Price{newFloatingTieredPackageWithMinimum=$newFloatingTieredPackageWithMinimum}" - newFloatingUnitWithPercent != null -> - "Price{newFloatingUnitWithPercent=$newFloatingUnitWithPercent}" - newFloatingTieredWithProration != null -> - "Price{newFloatingTieredWithProration=$newFloatingTieredWithProration}" - newFloatingUnitWithProration != null -> - "Price{newFloatingUnitWithProration=$newFloatingUnitWithProration}" - newFloatingGroupedAllocation != null -> - "Price{newFloatingGroupedAllocation=$newFloatingGroupedAllocation}" - newFloatingGroupedWithProratedMinimum != null -> - "Price{newFloatingGroupedWithProratedMinimum=$newFloatingGroupedWithProratedMinimum}" - newFloatingGroupedWithMeteredMinimum != null -> - "Price{newFloatingGroupedWithMeteredMinimum=$newFloatingGroupedWithMeteredMinimum}" - newFloatingMatrixWithDisplayName != null -> - "Price{newFloatingMatrixWithDisplayName=$newFloatingMatrixWithDisplayName}" - newFloatingBulkWithProration != null -> - "Price{newFloatingBulkWithProration=$newFloatingBulkWithProration}" - newFloatingGroupedTieredPackage != null -> - "Price{newFloatingGroupedTieredPackage=$newFloatingGroupedTieredPackage}" - newFloatingScalableMatrixWithUnitPricing != null -> - "Price{newFloatingScalableMatrixWithUnitPricing=$newFloatingScalableMatrixWithUnitPricing}" - newFloatingScalableMatrixWithTieredPricing != null -> - "Price{newFloatingScalableMatrixWithTieredPricing=$newFloatingScalableMatrixWithTieredPricing}" - newFloatingCumulativeGroupedBulk != null -> - "Price{newFloatingCumulativeGroupedBulk=$newFloatingCumulativeGroupedBulk}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") - } - - companion object { - - @JvmStatic - fun ofNewFloatingUnit(newFloatingUnit: NewFloatingUnitPrice) = - Price(newFloatingUnit = newFloatingUnit) - - @JvmStatic - fun ofNewFloatingPackage(newFloatingPackage: NewFloatingPackagePrice) = - Price(newFloatingPackage = newFloatingPackage) - - @JvmStatic - fun ofNewFloatingMatrix(newFloatingMatrix: NewFloatingMatrixPrice) = - Price(newFloatingMatrix = newFloatingMatrix) - - @JvmStatic - fun ofNewFloatingMatrixWithAllocation( - newFloatingMatrixWithAllocation: NewFloatingMatrixWithAllocationPrice - ) = Price(newFloatingMatrixWithAllocation = newFloatingMatrixWithAllocation) - - @JvmStatic - fun ofNewFloatingTiered(newFloatingTiered: NewFloatingTieredPrice) = - Price(newFloatingTiered = newFloatingTiered) - - @JvmStatic - fun ofNewFloatingTieredBps(newFloatingTieredBps: NewFloatingTieredBpsPrice) = - Price(newFloatingTieredBps = newFloatingTieredBps) - - @JvmStatic - fun ofNewFloatingBps(newFloatingBps: NewFloatingBpsPrice) = - Price(newFloatingBps = newFloatingBps) - - @JvmStatic - fun ofNewFloatingBulkBps(newFloatingBulkBps: NewFloatingBulkBpsPrice) = - Price(newFloatingBulkBps = newFloatingBulkBps) - - @JvmStatic - fun ofNewFloatingBulk(newFloatingBulk: NewFloatingBulkPrice) = - Price(newFloatingBulk = newFloatingBulk) - - @JvmStatic - fun ofNewFloatingThresholdTotalAmount( - newFloatingThresholdTotalAmount: NewFloatingThresholdTotalAmountPrice - ) = Price(newFloatingThresholdTotalAmount = newFloatingThresholdTotalAmount) - - @JvmStatic - fun ofNewFloatingTieredPackage( - newFloatingTieredPackage: NewFloatingTieredPackagePrice - ) = Price(newFloatingTieredPackage = newFloatingTieredPackage) - - @JvmStatic - fun ofNewFloatingGroupedTiered( - newFloatingGroupedTiered: NewFloatingGroupedTieredPrice - ) = Price(newFloatingGroupedTiered = newFloatingGroupedTiered) - - @JvmStatic - fun ofNewFloatingMaxGroupTieredPackage( - newFloatingMaxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice - ) = Price(newFloatingMaxGroupTieredPackage = newFloatingMaxGroupTieredPackage) - - @JvmStatic - fun ofNewFloatingTieredWithMinimum( - newFloatingTieredWithMinimum: NewFloatingTieredWithMinimumPrice - ) = Price(newFloatingTieredWithMinimum = newFloatingTieredWithMinimum) - - @JvmStatic - fun ofNewFloatingPackageWithAllocation( - newFloatingPackageWithAllocation: NewFloatingPackageWithAllocationPrice - ) = Price(newFloatingPackageWithAllocation = newFloatingPackageWithAllocation) - - @JvmStatic - fun ofNewFloatingTieredPackageWithMinimum( - newFloatingTieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice - ) = Price(newFloatingTieredPackageWithMinimum = newFloatingTieredPackageWithMinimum) - - @JvmStatic - fun ofNewFloatingUnitWithPercent( - newFloatingUnitWithPercent: NewFloatingUnitWithPercentPrice - ) = Price(newFloatingUnitWithPercent = newFloatingUnitWithPercent) - - @JvmStatic - fun ofNewFloatingTieredWithProration( - newFloatingTieredWithProration: NewFloatingTieredWithProrationPrice - ) = Price(newFloatingTieredWithProration = newFloatingTieredWithProration) - - @JvmStatic - fun ofNewFloatingUnitWithProration( - newFloatingUnitWithProration: NewFloatingUnitWithProrationPrice - ) = Price(newFloatingUnitWithProration = newFloatingUnitWithProration) - - @JvmStatic - fun ofNewFloatingGroupedAllocation( - newFloatingGroupedAllocation: NewFloatingGroupedAllocationPrice - ) = Price(newFloatingGroupedAllocation = newFloatingGroupedAllocation) - - @JvmStatic - fun ofNewFloatingGroupedWithProratedMinimum( - newFloatingGroupedWithProratedMinimum: - NewFloatingGroupedWithProratedMinimumPrice - ) = - Price( - newFloatingGroupedWithProratedMinimum = - newFloatingGroupedWithProratedMinimum - ) - - @JvmStatic - fun ofNewFloatingGroupedWithMeteredMinimum( - newFloatingGroupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice - ) = - Price( - newFloatingGroupedWithMeteredMinimum = newFloatingGroupedWithMeteredMinimum - ) - - @JvmStatic - fun ofNewFloatingMatrixWithDisplayName( - newFloatingMatrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice - ) = Price(newFloatingMatrixWithDisplayName = newFloatingMatrixWithDisplayName) - - @JvmStatic - fun ofNewFloatingBulkWithProration( - newFloatingBulkWithProration: NewFloatingBulkWithProrationPrice - ) = Price(newFloatingBulkWithProration = newFloatingBulkWithProration) - - @JvmStatic - fun ofNewFloatingGroupedTieredPackage( - newFloatingGroupedTieredPackage: NewFloatingGroupedTieredPackagePrice - ) = Price(newFloatingGroupedTieredPackage = newFloatingGroupedTieredPackage) - - @JvmStatic - fun ofNewFloatingScalableMatrixWithUnitPricing( - newFloatingScalableMatrixWithUnitPricing: - NewFloatingScalableMatrixWithUnitPricingPrice - ) = - Price( - newFloatingScalableMatrixWithUnitPricing = - newFloatingScalableMatrixWithUnitPricing - ) - - @JvmStatic - fun ofNewFloatingScalableMatrixWithTieredPricing( - newFloatingScalableMatrixWithTieredPricing: - NewFloatingScalableMatrixWithTieredPricingPrice - ) = - Price( - newFloatingScalableMatrixWithTieredPricing = - newFloatingScalableMatrixWithTieredPricing - ) - - @JvmStatic - fun ofNewFloatingCumulativeGroupedBulk( - newFloatingCumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice - ) = Price(newFloatingCumulativeGroupedBulk = newFloatingCumulativeGroupedBulk) - } - - /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. - */ - interface Visitor { - - fun visitNewFloatingUnit(newFloatingUnit: NewFloatingUnitPrice): T - - fun visitNewFloatingPackage(newFloatingPackage: NewFloatingPackagePrice): T - - fun visitNewFloatingMatrix(newFloatingMatrix: NewFloatingMatrixPrice): T - - fun visitNewFloatingMatrixWithAllocation( - newFloatingMatrixWithAllocation: NewFloatingMatrixWithAllocationPrice - ): T - - fun visitNewFloatingTiered(newFloatingTiered: NewFloatingTieredPrice): T - - fun visitNewFloatingTieredBps(newFloatingTieredBps: NewFloatingTieredBpsPrice): T - - fun visitNewFloatingBps(newFloatingBps: NewFloatingBpsPrice): T - - fun visitNewFloatingBulkBps(newFloatingBulkBps: NewFloatingBulkBpsPrice): T - - fun visitNewFloatingBulk(newFloatingBulk: NewFloatingBulkPrice): T - - fun visitNewFloatingThresholdTotalAmount( - newFloatingThresholdTotalAmount: NewFloatingThresholdTotalAmountPrice - ): T - - fun visitNewFloatingTieredPackage( - newFloatingTieredPackage: NewFloatingTieredPackagePrice - ): T - - fun visitNewFloatingGroupedTiered( - newFloatingGroupedTiered: NewFloatingGroupedTieredPrice - ): T - - fun visitNewFloatingMaxGroupTieredPackage( - newFloatingMaxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice - ): T - - fun visitNewFloatingTieredWithMinimum( - newFloatingTieredWithMinimum: NewFloatingTieredWithMinimumPrice - ): T - - fun visitNewFloatingPackageWithAllocation( - newFloatingPackageWithAllocation: NewFloatingPackageWithAllocationPrice - ): T - - fun visitNewFloatingTieredPackageWithMinimum( - newFloatingTieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice - ): T - - fun visitNewFloatingUnitWithPercent( - newFloatingUnitWithPercent: NewFloatingUnitWithPercentPrice - ): T - - fun visitNewFloatingTieredWithProration( - newFloatingTieredWithProration: NewFloatingTieredWithProrationPrice - ): T - - fun visitNewFloatingUnitWithProration( - newFloatingUnitWithProration: NewFloatingUnitWithProrationPrice - ): T - - fun visitNewFloatingGroupedAllocation( - newFloatingGroupedAllocation: NewFloatingGroupedAllocationPrice - ): T - - fun visitNewFloatingGroupedWithProratedMinimum( - newFloatingGroupedWithProratedMinimum: - NewFloatingGroupedWithProratedMinimumPrice - ): T - - fun visitNewFloatingGroupedWithMeteredMinimum( - newFloatingGroupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice - ): T - - fun visitNewFloatingMatrixWithDisplayName( - newFloatingMatrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice - ): T - - fun visitNewFloatingBulkWithProration( - newFloatingBulkWithProration: NewFloatingBulkWithProrationPrice - ): T - - fun visitNewFloatingGroupedTieredPackage( - newFloatingGroupedTieredPackage: NewFloatingGroupedTieredPackagePrice - ): T - - fun visitNewFloatingScalableMatrixWithUnitPricing( - newFloatingScalableMatrixWithUnitPricing: - NewFloatingScalableMatrixWithUnitPricingPrice - ): T - - fun visitNewFloatingScalableMatrixWithTieredPricing( - newFloatingScalableMatrixWithTieredPricing: - NewFloatingScalableMatrixWithTieredPricingPrice - ): T - - fun visitNewFloatingCumulativeGroupedBulk( - newFloatingCumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice - ): 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" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newFloatingUnit = it, _json = json) - } - } - "package" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newFloatingPackage = it, _json = json) - } - } - "matrix" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newFloatingMatrix = it, _json = json) - } - } - "matrix_with_allocation" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price(newFloatingMatrixWithAllocation = it, _json = json) - } - } - "tiered" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newFloatingTiered = it, _json = json) - } - } - "tiered_bps" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newFloatingTieredBps = it, _json = json) - } - } - "bps" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newFloatingBps = it, _json = json) - } - } - "bulk_bps" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newFloatingBulkBps = it, _json = json) - } - } - "bulk" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newFloatingBulk = it, _json = json) - } - } - "threshold_total_amount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price(newFloatingThresholdTotalAmount = it, _json = json) - } - } - "tiered_package" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newFloatingTieredPackage = it, _json = json) - } - } - "grouped_tiered" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newFloatingGroupedTiered = it, _json = json) - } - } - "max_group_tiered_package" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newFloatingMaxGroupTieredPackage = it, - _json = json, - ) - } - } - "tiered_with_minimum" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price(newFloatingTieredWithMinimum = it, _json = json) - } - } - "package_with_allocation" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newFloatingPackageWithAllocation = it, - _json = json, - ) - } - } - "tiered_package_with_minimum" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newFloatingTieredPackageWithMinimum = it, - _json = json, - ) - } - } - "unit_with_percent" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price(newFloatingUnitWithPercent = it, _json = json) - } - } - "tiered_with_proration" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price(newFloatingTieredWithProration = it, _json = json) - } - } - "unit_with_proration" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price(newFloatingUnitWithProration = it, _json = json) - } - } - "grouped_allocation" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price(newFloatingGroupedAllocation = it, _json = json) - } - } - "grouped_with_prorated_minimum" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newFloatingGroupedWithProratedMinimum = it, - _json = json, - ) - } - } - "grouped_with_metered_minimum" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newFloatingGroupedWithMeteredMinimum = it, - _json = json, - ) - } - } - "matrix_with_display_name" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newFloatingMatrixWithDisplayName = it, - _json = json, - ) - } - } - "bulk_with_proration" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price(newFloatingBulkWithProration = it, _json = json) - } - } - "grouped_tiered_package" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price(newFloatingGroupedTieredPackage = it, _json = json) - } - } - "scalable_matrix_with_unit_pricing" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newFloatingScalableMatrixWithUnitPricing = it, - _json = json, - ) - } - } - "scalable_matrix_with_tiered_pricing" -> { - tryDeserialize( - node, - jacksonTypeRef< - NewFloatingScalableMatrixWithTieredPricingPrice - >(), - ) { - it.validate() - } - ?.let { - return Price( - newFloatingScalableMatrixWithTieredPricing = it, - _json = json, - ) - } - } - "cumulative_grouped_bulk" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newFloatingCumulativeGroupedBulk = it, - _json = json, - ) - } - } - } - - return Price(_json = json) - } - } - - internal class Serializer : BaseSerializer(Price::class) { - - override fun serialize( - value: Price, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.newFloatingUnit != null -> - generator.writeObject(value.newFloatingUnit) - value.newFloatingPackage != null -> - generator.writeObject(value.newFloatingPackage) - value.newFloatingMatrix != null -> - generator.writeObject(value.newFloatingMatrix) - value.newFloatingMatrixWithAllocation != null -> - generator.writeObject(value.newFloatingMatrixWithAllocation) - value.newFloatingTiered != null -> - generator.writeObject(value.newFloatingTiered) - value.newFloatingTieredBps != null -> - generator.writeObject(value.newFloatingTieredBps) - value.newFloatingBps != null -> generator.writeObject(value.newFloatingBps) - value.newFloatingBulkBps != null -> - generator.writeObject(value.newFloatingBulkBps) - value.newFloatingBulk != null -> - generator.writeObject(value.newFloatingBulk) - value.newFloatingThresholdTotalAmount != null -> - generator.writeObject(value.newFloatingThresholdTotalAmount) - value.newFloatingTieredPackage != null -> - generator.writeObject(value.newFloatingTieredPackage) - value.newFloatingGroupedTiered != null -> - generator.writeObject(value.newFloatingGroupedTiered) - value.newFloatingMaxGroupTieredPackage != null -> - generator.writeObject(value.newFloatingMaxGroupTieredPackage) - value.newFloatingTieredWithMinimum != null -> - generator.writeObject(value.newFloatingTieredWithMinimum) - value.newFloatingPackageWithAllocation != null -> - generator.writeObject(value.newFloatingPackageWithAllocation) - value.newFloatingTieredPackageWithMinimum != null -> - generator.writeObject(value.newFloatingTieredPackageWithMinimum) - value.newFloatingUnitWithPercent != null -> - generator.writeObject(value.newFloatingUnitWithPercent) - value.newFloatingTieredWithProration != null -> - generator.writeObject(value.newFloatingTieredWithProration) - value.newFloatingUnitWithProration != null -> - generator.writeObject(value.newFloatingUnitWithProration) - value.newFloatingGroupedAllocation != null -> - generator.writeObject(value.newFloatingGroupedAllocation) - value.newFloatingGroupedWithProratedMinimum != null -> - generator.writeObject(value.newFloatingGroupedWithProratedMinimum) - value.newFloatingGroupedWithMeteredMinimum != null -> - generator.writeObject(value.newFloatingGroupedWithMeteredMinimum) - value.newFloatingMatrixWithDisplayName != null -> - generator.writeObject(value.newFloatingMatrixWithDisplayName) - value.newFloatingBulkWithProration != null -> - generator.writeObject(value.newFloatingBulkWithProration) - value.newFloatingGroupedTieredPackage != null -> - generator.writeObject(value.newFloatingGroupedTieredPackage) - value.newFloatingScalableMatrixWithUnitPricing != null -> - generator.writeObject(value.newFloatingScalableMatrixWithUnitPricing) - value.newFloatingScalableMatrixWithTieredPricing != null -> - generator.writeObject(value.newFloatingScalableMatrixWithTieredPricing) - value.newFloatingCumulativeGroupedBulk != null -> - generator.writeObject(value.newFloatingCumulativeGroupedBulk) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") - } - } - } - - @NoAutoDetect - class NewFloatingUnitPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("unit_config") - @ExcludeMissing - private val unitConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun unitConfig(): UnitConfig = unitConfig.getRequired("unit_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("unit_config") - @ExcludeMissing - fun _unitConfig(): JsonField = unitConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingUnitPrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - itemId() - modelType() - name() - unitConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingUnitPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var 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 externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newFloatingUnitPrice: NewFloatingUnitPrice) = apply { - cadence = newFloatingUnitPrice.cadence - currency = newFloatingUnitPrice.currency - itemId = newFloatingUnitPrice.itemId - modelType = newFloatingUnitPrice.modelType - name = newFloatingUnitPrice.name - unitConfig = newFloatingUnitPrice.unitConfig - billableMetricId = newFloatingUnitPrice.billableMetricId - billedInAdvance = newFloatingUnitPrice.billedInAdvance - billingCycleConfiguration = newFloatingUnitPrice.billingCycleConfiguration - conversionRate = newFloatingUnitPrice.conversionRate - externalPriceId = newFloatingUnitPrice.externalPriceId - fixedPriceQuantity = newFloatingUnitPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingUnitPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingUnitPrice.invoicingCycleConfiguration - metadata = newFloatingUnitPrice.metadata - additionalProperties = - newFloatingUnitPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) - - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingUnitPrice = - NewFloatingUnitPrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("unitConfig", unitConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class UnitConfig - @JsonCreator - private constructor( - @JsonProperty("unit_amount") - @ExcludeMissing - private val unitAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Rate per unit of usage */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** Rate per unit of usage */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): UnitConfig = apply { - if (validated) { - return@apply - } - - unitAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnitConfig]. */ - class Builder internal constructor() { - - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unitConfig: UnitConfig) = apply { - unitAmount = unitConfig.unitAmount - additionalProperties = unitConfig.additionalProperties.toMutableMap() - } - - /** Rate per unit of usage */ - fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - - /** Rate per unit of usage */ - 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 build(): UnitConfig = - UnitConfig( - checkRequired("unitAmount", unitAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UnitConfig && unitAmount == other.unitAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(unitAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnitConfig{unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingUnitPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && unitConfig == other.unitConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, unitConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingUnitPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingPackagePrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("package_config") - @ExcludeMissing - private val packageConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun packageConfig(): PackageConfig = packageConfig.getRequired("package_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("package_config") - @ExcludeMissing - fun _packageConfig(): JsonField = packageConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingPackagePrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - itemId() - modelType() - name() - packageConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingPackagePrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var packageConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newFloatingPackagePrice: NewFloatingPackagePrice) = apply { - cadence = newFloatingPackagePrice.cadence - currency = newFloatingPackagePrice.currency - itemId = newFloatingPackagePrice.itemId - modelType = newFloatingPackagePrice.modelType - name = newFloatingPackagePrice.name - packageConfig = newFloatingPackagePrice.packageConfig - billableMetricId = newFloatingPackagePrice.billableMetricId - billedInAdvance = newFloatingPackagePrice.billedInAdvance - billingCycleConfiguration = - newFloatingPackagePrice.billingCycleConfiguration - conversionRate = newFloatingPackagePrice.conversionRate - externalPriceId = newFloatingPackagePrice.externalPriceId - fixedPriceQuantity = newFloatingPackagePrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingPackagePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingPackagePrice.invoicingCycleConfiguration - metadata = newFloatingPackagePrice.metadata - additionalProperties = - newFloatingPackagePrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun packageConfig(packageConfig: PackageConfig) = - packageConfig(JsonField.of(packageConfig)) - - fun packageConfig(packageConfig: JsonField) = apply { - this.packageConfig = packageConfig - } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingPackagePrice = - NewFloatingPackagePrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("packageConfig", packageConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val PACKAGE = of("package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - PACKAGE - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PACKAGE, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PACKAGE -> Value.PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PACKAGE -> Known.PACKAGE - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class PackageConfig - @JsonCreator - private constructor( - @JsonProperty("package_amount") - @ExcludeMissing - private val packageAmount: JsonField = JsonMissing.of(), - @JsonProperty("package_size") - @ExcludeMissing - private val packageSize: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** A currency amount to rate usage by */ - fun packageAmount(): String = packageAmount.getRequired("package_amount") - - /** - * An integer amount to represent package size. For example, 1000 here would - * divide usage by 1000 before multiplying by package_amount in rating - */ - fun packageSize(): Long = packageSize.getRequired("package_size") - - /** A currency amount to rate usage by */ - @JsonProperty("package_amount") - @ExcludeMissing - fun _packageAmount(): JsonField = packageAmount - - /** - * An integer amount to represent package size. For example, 1000 here would - * divide usage by 1000 before multiplying by package_amount in rating - */ - @JsonProperty("package_size") - @ExcludeMissing - fun _packageSize(): JsonField = packageSize - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PackageConfig = apply { - if (validated) { - return@apply - } - - packageAmount() - packageSize() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PackageConfig]. */ - class Builder internal constructor() { - - private var packageAmount: JsonField? = null - private var packageSize: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(packageConfig: PackageConfig) = apply { - packageAmount = packageConfig.packageAmount - packageSize = packageConfig.packageSize - additionalProperties = packageConfig.additionalProperties.toMutableMap() - } - - /** A currency amount to rate usage by */ - fun packageAmount(packageAmount: String) = - packageAmount(JsonField.of(packageAmount)) - - /** A currency amount to rate usage by */ - fun packageAmount(packageAmount: JsonField) = apply { - this.packageAmount = packageAmount - } - - /** - * An integer amount to represent package size. For example, 1000 here would - * divide usage by 1000 before multiplying by package_amount in rating - */ - fun packageSize(packageSize: Long) = packageSize(JsonField.of(packageSize)) - - /** - * An integer amount to represent package size. For example, 1000 here would - * divide usage by 1000 before multiplying by package_amount in rating - */ - fun packageSize(packageSize: JsonField) = apply { - this.packageSize = packageSize - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PackageConfig = - PackageConfig( - checkRequired("packageAmount", packageAmount), - checkRequired("packageSize", packageSize), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PackageConfig && packageAmount == other.packageAmount && packageSize == other.packageSize && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(packageAmount, packageSize, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PackageConfig{packageAmount=$packageAmount, packageSize=$packageSize, additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingPackagePrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && packageConfig == other.packageConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, packageConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingPackagePrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingMatrixPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("matrix_config") - @ExcludeMissing - private val matrixConfig: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_config") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("matrix_config") - @ExcludeMissing - fun _matrixConfig(): JsonField = matrixConfig - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingMatrixPrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - itemId() - matrixConfig().validate() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingMatrixPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var matrixConfig: JsonField? = null - private var modelType: JsonField? = null - private var 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 externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newFloatingMatrixPrice: NewFloatingMatrixPrice) = apply { - cadence = newFloatingMatrixPrice.cadence - currency = newFloatingMatrixPrice.currency - itemId = newFloatingMatrixPrice.itemId - matrixConfig = newFloatingMatrixPrice.matrixConfig - modelType = newFloatingMatrixPrice.modelType - name = newFloatingMatrixPrice.name - billableMetricId = newFloatingMatrixPrice.billableMetricId - billedInAdvance = newFloatingMatrixPrice.billedInAdvance - billingCycleConfiguration = newFloatingMatrixPrice.billingCycleConfiguration - conversionRate = newFloatingMatrixPrice.conversionRate - externalPriceId = newFloatingMatrixPrice.externalPriceId - fixedPriceQuantity = newFloatingMatrixPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingMatrixPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingMatrixPrice.invoicingCycleConfiguration - metadata = newFloatingMatrixPrice.metadata - additionalProperties = - newFloatingMatrixPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun matrixConfig(matrixConfig: MatrixConfig) = - matrixConfig(JsonField.of(matrixConfig)) - - fun matrixConfig(matrixConfig: JsonField) = apply { - this.matrixConfig = matrixConfig - } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingMatrixPrice = - NewFloatingMatrixPrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("matrixConfig", matrixConfig), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class MatrixConfig - @JsonCreator - private constructor( - @JsonProperty("default_unit_amount") - @ExcludeMissing - private val defaultUnitAmount: JsonField = JsonMissing.of(), - @JsonProperty("dimensions") - @ExcludeMissing - private val dimensions: JsonField> = JsonMissing.of(), - @JsonProperty("matrix_values") - @ExcludeMissing - private val matrixValues: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * Default per unit rate for any usage not bucketed into a specified - * matrix_value - */ - fun defaultUnitAmount(): String = - defaultUnitAmount.getRequired("default_unit_amount") - - /** One or two event property values to evaluate matrix groups by */ - fun dimensions(): List = dimensions.getRequired("dimensions") - - /** Matrix values for specified matrix grouping keys */ - fun matrixValues(): List = - matrixValues.getRequired("matrix_values") - - /** - * Default per unit rate for any usage not bucketed into a specified - * matrix_value - */ - @JsonProperty("default_unit_amount") - @ExcludeMissing - fun _defaultUnitAmount(): JsonField = defaultUnitAmount - - /** One or two event property values to evaluate matrix groups by */ - @JsonProperty("dimensions") - @ExcludeMissing - fun _dimensions(): JsonField> = dimensions - - /** Matrix values for specified matrix grouping keys */ - @JsonProperty("matrix_values") - @ExcludeMissing - fun _matrixValues(): JsonField> = matrixValues - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MatrixConfig = apply { - if (validated) { - return@apply - } - - defaultUnitAmount() - dimensions() - matrixValues().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MatrixConfig]. */ - class Builder internal constructor() { - - private var defaultUnitAmount: JsonField? = null - private var dimensions: JsonField>? = null - private var matrixValues: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(matrixConfig: MatrixConfig) = apply { - defaultUnitAmount = matrixConfig.defaultUnitAmount - dimensions = matrixConfig.dimensions.map { it.toMutableList() } - matrixValues = matrixConfig.matrixValues.map { it.toMutableList() } - additionalProperties = matrixConfig.additionalProperties.toMutableMap() - } - - /** - * Default per unit rate for any usage not bucketed into a specified - * matrix_value - */ - fun defaultUnitAmount(defaultUnitAmount: String) = - defaultUnitAmount(JsonField.of(defaultUnitAmount)) - - /** - * Default per unit rate for any usage not bucketed into a specified - * matrix_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)) - - /** One or two event property values to evaluate matrix groups by */ - fun dimensions(dimensions: JsonField>) = apply { - this.dimensions = dimensions.map { it.toMutableList() } - } - - /** One or two event property values to evaluate matrix groups by */ - fun addDimension(dimension: String) = apply { - dimensions = - (dimensions ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimension) - } - } - - /** Matrix values for specified matrix grouping keys */ - fun matrixValues(matrixValues: List) = - matrixValues(JsonField.of(matrixValues)) - - /** Matrix values for specified matrix grouping keys */ - fun matrixValues(matrixValues: JsonField>) = apply { - this.matrixValues = matrixValues.map { it.toMutableList() } - } - - /** Matrix values for specified matrix grouping keys */ - fun addMatrixValue(matrixValue: MatrixValue) = apply { - matrixValues = - (matrixValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): MatrixConfig = - MatrixConfig( - checkRequired("defaultUnitAmount", defaultUnitAmount), - checkRequired("dimensions", dimensions).map { it.toImmutable() }, - checkRequired("matrixValues", matrixValues).map { - it.toImmutable() - }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class MatrixValue - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - private val unitAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), - ) { - - /** - * One or two matrix keys to filter usage to this Matrix value by. For - * example, ["region", "tier"] could be used to filter cloud usage by a - * cloud region and an instance tier. - */ - fun dimensionValues(): List = - dimensionValues.getRequired("dimension_values") - - /** Unit price for the specified dimension_values */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** - * One or two matrix keys to filter usage to this Matrix value by. For - * example, ["region", "tier"] could be used to filter cloud usage by a - * cloud region and an instance tier. - */ - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - /** Unit price for the specified dimension_values */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MatrixValue = apply { - if (validated) { - return@apply - } - - dimensionValues() - unitAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MatrixValue]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(matrixValue: MatrixValue) = apply { - dimensionValues = - matrixValue.dimensionValues.map { it.toMutableList() } - unitAmount = matrixValue.unitAmount - additionalProperties = - matrixValue.additionalProperties.toMutableMap() - } - - /** - * One or two matrix keys to filter usage to this Matrix value by. For - * example, ["region", "tier"] could be used to filter cloud usage by a - * cloud region and an instance tier. - */ - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - /** - * One or two matrix keys to filter usage to this Matrix value by. For - * example, ["region", "tier"] could be used to filter cloud usage by a - * cloud region and an instance tier. - */ - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - /** - * One or two matrix keys to filter usage to this Matrix value by. For - * example, ["region", "tier"] could be used to filter cloud usage by a - * cloud region and an instance tier. - */ - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - /** Unit price for the specified dimension_values */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) - - /** Unit price for the specified dimension_values */ - 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 build(): MatrixValue = - MatrixValue( - checkRequired("dimensionValues", dimensionValues).map { - it.toImmutable() - }, - checkRequired("unitAmount", unitAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MatrixValue && dimensionValues == other.dimensionValues && unitAmount == other.unitAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, unitAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MatrixValue{dimensionValues=$dimensionValues, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MatrixConfig && defaultUnitAmount == other.defaultUnitAmount && dimensions == other.dimensions && matrixValues == other.matrixValues && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(defaultUnitAmount, dimensions, matrixValues, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MatrixConfig{defaultUnitAmount=$defaultUnitAmount, dimensions=$dimensions, matrixValues=$matrixValues, additionalProperties=$additionalProperties}" - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MATRIX = of("matrix") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MATRIX - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MATRIX, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MATRIX -> Value.MATRIX - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MATRIX -> Known.MATRIX - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingMatrixPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && matrixConfig == other.matrixConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, matrixConfig, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingMatrixPrice{cadence=$cadence, currency=$currency, itemId=$itemId, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingMatrixWithAllocationPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("matrix_with_allocation_config") - @ExcludeMissing - private val matrixWithAllocationConfig: JsonField = - JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun matrixWithAllocationConfig(): MatrixWithAllocationConfig = - matrixWithAllocationConfig.getRequired("matrix_with_allocation_config") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("matrix_with_allocation_config") - @ExcludeMissing - fun _matrixWithAllocationConfig(): JsonField = - matrixWithAllocationConfig - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingMatrixWithAllocationPrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - itemId() - matrixWithAllocationConfig().validate() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingMatrixWithAllocationPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var matrixWithAllocationConfig: JsonField? = - null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newFloatingMatrixWithAllocationPrice: NewFloatingMatrixWithAllocationPrice - ) = apply { - cadence = newFloatingMatrixWithAllocationPrice.cadence - currency = newFloatingMatrixWithAllocationPrice.currency - itemId = newFloatingMatrixWithAllocationPrice.itemId - matrixWithAllocationConfig = - newFloatingMatrixWithAllocationPrice.matrixWithAllocationConfig - modelType = newFloatingMatrixWithAllocationPrice.modelType - name = newFloatingMatrixWithAllocationPrice.name - billableMetricId = newFloatingMatrixWithAllocationPrice.billableMetricId - billedInAdvance = newFloatingMatrixWithAllocationPrice.billedInAdvance - billingCycleConfiguration = - newFloatingMatrixWithAllocationPrice.billingCycleConfiguration - conversionRate = newFloatingMatrixWithAllocationPrice.conversionRate - externalPriceId = newFloatingMatrixWithAllocationPrice.externalPriceId - fixedPriceQuantity = newFloatingMatrixWithAllocationPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingMatrixWithAllocationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingMatrixWithAllocationPrice.invoicingCycleConfiguration - metadata = newFloatingMatrixWithAllocationPrice.metadata - additionalProperties = - newFloatingMatrixWithAllocationPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun matrixWithAllocationConfig( - matrixWithAllocationConfig: MatrixWithAllocationConfig - ) = matrixWithAllocationConfig(JsonField.of(matrixWithAllocationConfig)) - - fun matrixWithAllocationConfig( - matrixWithAllocationConfig: JsonField - ) = apply { this.matrixWithAllocationConfig = matrixWithAllocationConfig } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingMatrixWithAllocationPrice = - NewFloatingMatrixWithAllocationPrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("matrixWithAllocationConfig", matrixWithAllocationConfig), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class MatrixWithAllocationConfig - @JsonCreator - private constructor( - @JsonProperty("allocation") - @ExcludeMissing - private val allocation: JsonField = JsonMissing.of(), - @JsonProperty("default_unit_amount") - @ExcludeMissing - private val defaultUnitAmount: JsonField = JsonMissing.of(), - @JsonProperty("dimensions") - @ExcludeMissing - private val dimensions: JsonField> = JsonMissing.of(), - @JsonProperty("matrix_values") - @ExcludeMissing - private val matrixValues: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Allocation to be used to calculate the price */ - fun allocation(): Double = allocation.getRequired("allocation") - - /** - * Default per unit rate for any usage not bucketed into a specified - * matrix_value - */ - fun defaultUnitAmount(): String = - defaultUnitAmount.getRequired("default_unit_amount") - - /** One or two event property values to evaluate matrix groups by */ - fun dimensions(): List = dimensions.getRequired("dimensions") - - /** Matrix values for specified matrix grouping keys */ - fun matrixValues(): List = - matrixValues.getRequired("matrix_values") - - /** Allocation to be used to calculate the price */ - @JsonProperty("allocation") - @ExcludeMissing - fun _allocation(): JsonField = allocation - - /** - * Default per unit rate for any usage not bucketed into a specified - * matrix_value - */ - @JsonProperty("default_unit_amount") - @ExcludeMissing - fun _defaultUnitAmount(): JsonField = defaultUnitAmount - - /** One or two event property values to evaluate matrix groups by */ - @JsonProperty("dimensions") - @ExcludeMissing - fun _dimensions(): JsonField> = dimensions - - /** Matrix values for specified matrix grouping keys */ - @JsonProperty("matrix_values") - @ExcludeMissing - fun _matrixValues(): JsonField> = matrixValues - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MatrixWithAllocationConfig = apply { - if (validated) { - return@apply - } - - allocation() - defaultUnitAmount() - dimensions() - matrixValues().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MatrixWithAllocationConfig]. */ - class Builder internal constructor() { - - private var allocation: JsonField? = null - private var defaultUnitAmount: JsonField? = null - private var dimensions: JsonField>? = null - private var matrixValues: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(matrixWithAllocationConfig: MatrixWithAllocationConfig) = - apply { - allocation = matrixWithAllocationConfig.allocation - defaultUnitAmount = matrixWithAllocationConfig.defaultUnitAmount - dimensions = - matrixWithAllocationConfig.dimensions.map { it.toMutableList() } - matrixValues = - matrixWithAllocationConfig.matrixValues.map { - it.toMutableList() - } - additionalProperties = - matrixWithAllocationConfig.additionalProperties.toMutableMap() - } - - /** Allocation to be used to calculate the price */ - fun allocation(allocation: Double) = allocation(JsonField.of(allocation)) - - /** Allocation to be used to calculate the price */ - fun allocation(allocation: JsonField) = apply { - this.allocation = allocation - } - - /** - * Default per unit rate for any usage not bucketed into a specified - * matrix_value - */ - fun defaultUnitAmount(defaultUnitAmount: String) = - defaultUnitAmount(JsonField.of(defaultUnitAmount)) - - /** - * Default per unit rate for any usage not bucketed into a specified - * matrix_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)) - - /** One or two event property values to evaluate matrix groups by */ - fun dimensions(dimensions: JsonField>) = apply { - this.dimensions = dimensions.map { it.toMutableList() } - } - - /** One or two event property values to evaluate matrix groups by */ - fun addDimension(dimension: String) = apply { - dimensions = - (dimensions ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimension) - } - } - - /** Matrix values for specified matrix grouping keys */ - fun matrixValues(matrixValues: List) = - matrixValues(JsonField.of(matrixValues)) - - /** Matrix values for specified matrix grouping keys */ - fun matrixValues(matrixValues: JsonField>) = apply { - this.matrixValues = matrixValues.map { it.toMutableList() } - } - - /** Matrix values for specified matrix grouping keys */ - fun addMatrixValue(matrixValue: MatrixValue) = apply { - matrixValues = - (matrixValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): MatrixWithAllocationConfig = - MatrixWithAllocationConfig( - checkRequired("allocation", allocation), - checkRequired("defaultUnitAmount", defaultUnitAmount), - checkRequired("dimensions", dimensions).map { it.toImmutable() }, - checkRequired("matrixValues", matrixValues).map { - it.toImmutable() - }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class MatrixValue - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - private val unitAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), - ) { - - /** - * One or two matrix keys to filter usage to this Matrix value by. For - * example, ["region", "tier"] could be used to filter cloud usage by a - * cloud region and an instance tier. - */ - fun dimensionValues(): List = - dimensionValues.getRequired("dimension_values") - - /** Unit price for the specified dimension_values */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** - * One or two matrix keys to filter usage to this Matrix value by. For - * example, ["region", "tier"] could be used to filter cloud usage by a - * cloud region and an instance tier. - */ - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - /** Unit price for the specified dimension_values */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MatrixValue = apply { - if (validated) { - return@apply - } - - dimensionValues() - unitAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MatrixValue]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(matrixValue: MatrixValue) = apply { - dimensionValues = - matrixValue.dimensionValues.map { it.toMutableList() } - unitAmount = matrixValue.unitAmount - additionalProperties = - matrixValue.additionalProperties.toMutableMap() - } - - /** - * One or two matrix keys to filter usage to this Matrix value by. For - * example, ["region", "tier"] could be used to filter cloud usage by a - * cloud region and an instance tier. - */ - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - /** - * One or two matrix keys to filter usage to this Matrix value by. For - * example, ["region", "tier"] could be used to filter cloud usage by a - * cloud region and an instance tier. - */ - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - /** - * One or two matrix keys to filter usage to this Matrix value by. For - * example, ["region", "tier"] could be used to filter cloud usage by a - * cloud region and an instance tier. - */ - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - /** Unit price for the specified dimension_values */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) - - /** Unit price for the specified dimension_values */ - 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 build(): MatrixValue = - MatrixValue( - checkRequired("dimensionValues", dimensionValues).map { - it.toImmutable() - }, - checkRequired("unitAmount", unitAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MatrixValue && dimensionValues == other.dimensionValues && unitAmount == other.unitAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, unitAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MatrixValue{dimensionValues=$dimensionValues, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MatrixWithAllocationConfig && allocation == other.allocation && defaultUnitAmount == other.defaultUnitAmount && dimensions == other.dimensions && matrixValues == other.matrixValues && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allocation, defaultUnitAmount, dimensions, matrixValues, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MatrixWithAllocationConfig{allocation=$allocation, defaultUnitAmount=$defaultUnitAmount, dimensions=$dimensions, matrixValues=$matrixValues, additionalProperties=$additionalProperties}" - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MATRIX_WITH_ALLOCATION = of("matrix_with_allocation") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MATRIX_WITH_ALLOCATION - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MATRIX_WITH_ALLOCATION, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MATRIX_WITH_ALLOCATION -> Value.MATRIX_WITH_ALLOCATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MATRIX_WITH_ALLOCATION -> Known.MATRIX_WITH_ALLOCATION - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingMatrixWithAllocationPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && matrixWithAllocationConfig == other.matrixWithAllocationConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, matrixWithAllocationConfig, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingMatrixWithAllocationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, matrixWithAllocationConfig=$matrixWithAllocationConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingTieredPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_config") - @ExcludeMissing - private val tieredConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun tieredConfig(): TieredConfig = tieredConfig.getRequired("tiered_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("tiered_config") - @ExcludeMissing - fun _tieredConfig(): JsonField = tieredConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingTieredPrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - itemId() - modelType() - name() - tieredConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingTieredPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var tieredConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newFloatingTieredPrice: NewFloatingTieredPrice) = apply { - cadence = newFloatingTieredPrice.cadence - currency = newFloatingTieredPrice.currency - itemId = newFloatingTieredPrice.itemId - modelType = newFloatingTieredPrice.modelType - name = newFloatingTieredPrice.name - tieredConfig = newFloatingTieredPrice.tieredConfig - billableMetricId = newFloatingTieredPrice.billableMetricId - billedInAdvance = newFloatingTieredPrice.billedInAdvance - billingCycleConfiguration = newFloatingTieredPrice.billingCycleConfiguration - conversionRate = newFloatingTieredPrice.conversionRate - externalPriceId = newFloatingTieredPrice.externalPriceId - fixedPriceQuantity = newFloatingTieredPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingTieredPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingTieredPrice.invoicingCycleConfiguration - metadata = newFloatingTieredPrice.metadata - additionalProperties = - newFloatingTieredPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredConfig(tieredConfig: TieredConfig) = - tieredConfig(JsonField.of(tieredConfig)) - - fun tieredConfig(tieredConfig: JsonField) = apply { - this.tieredConfig = tieredConfig - } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingTieredPrice = - NewFloatingTieredPrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("tieredConfig", tieredConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED = of("tiered") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED -> Value.TIERED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TIERED -> Known.TIERED - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TieredConfig - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - private val tiers: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Tiers for rating based on total usage quantities into the specified tier */ - fun tiers(): List = tiers.getRequired("tiers") - - /** Tiers for rating based on total usage quantities into the specified tier */ - @JsonProperty("tiers") - @ExcludeMissing - fun _tiers(): JsonField> = tiers - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredConfig = apply { - if (validated) { - return@apply - } - - tiers().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tieredConfig: TieredConfig) = apply { - tiers = tieredConfig.tiers.map { it.toMutableList() } - additionalProperties = tieredConfig.additionalProperties.toMutableMap() - } - - /** - * Tiers for rating based on total usage quantities into the specified tier - */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - - /** - * Tiers for rating based on total usage quantities into the specified tier - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** - * Tiers for rating based on total usage quantities into the specified tier - */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): TieredConfig = - TieredConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Tier - @JsonCreator - private constructor( - @JsonProperty("first_unit") - @ExcludeMissing - private val firstUnit: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - private val unitAmount: JsonField = JsonMissing.of(), - @JsonProperty("last_unit") - @ExcludeMissing - private val lastUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), - ) { - - /** Inclusive tier starting value */ - fun firstUnit(): Double = firstUnit.getRequired("first_unit") - - /** Amount per unit */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** - * Exclusive tier ending value. If null, this is treated as the last tier - */ - fun lastUnit(): Optional = - Optional.ofNullable(lastUnit.getNullable("last_unit")) - - /** Inclusive tier starting value */ - @JsonProperty("first_unit") - @ExcludeMissing - fun _firstUnit(): JsonField = firstUnit - - /** Amount per unit */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - /** - * Exclusive tier ending value. If null, this is treated as the last tier - */ - @JsonProperty("last_unit") - @ExcludeMissing - fun _lastUnit(): JsonField = lastUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - firstUnit() - unitAmount() - lastUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var firstUnit: JsonField? = null - private var unitAmount: JsonField? = null - private var lastUnit: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - firstUnit = tier.firstUnit - unitAmount = tier.unitAmount - lastUnit = tier.lastUnit - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Inclusive tier starting value */ - fun firstUnit(firstUnit: Double) = firstUnit(JsonField.of(firstUnit)) - - /** Inclusive tier starting value */ - fun firstUnit(firstUnit: JsonField) = apply { - this.firstUnit = firstUnit - } - - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) - - /** Amount per unit */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - /** - * Exclusive tier ending value. If null, this is treated as the last - * tier - */ - fun lastUnit(lastUnit: Double?) = - lastUnit(JsonField.ofNullable(lastUnit)) - - /** - * Exclusive tier ending value. If null, this is treated as the last - * tier - */ - fun lastUnit(lastUnit: Double) = lastUnit(lastUnit as Double?) - - /** - * Exclusive tier ending value. If null, this is treated as the last - * tier - */ - @Suppress( - "USELESS_CAST" - ) // See https://youtrack.jetbrains.com/issue/KT-74228 - fun lastUnit(lastUnit: Optional) = - lastUnit(lastUnit.orElse(null) as Double?) - - /** - * Exclusive tier ending value. If null, this is treated as the last - * tier - */ - fun lastUnit(lastUnit: JsonField) = apply { - this.lastUnit = lastUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Tier = - Tier( - checkRequired("firstUnit", firstUnit), - checkRequired("unitAmount", unitAmount), - lastUnit, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tier && firstUnit == other.firstUnit && unitAmount == other.unitAmount && lastUnit == other.lastUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(firstUnit, unitAmount, lastUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{firstUnit=$firstUnit, unitAmount=$unitAmount, lastUnit=$lastUnit, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredConfig && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredConfig{tiers=$tiers, additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingTieredPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredConfig == other.tieredConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, tieredConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingTieredPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingTieredBpsPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_bps_config") - @ExcludeMissing - private val tieredBpsConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun tieredBpsConfig(): TieredBpsConfig = - tieredBpsConfig.getRequired("tiered_bps_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("tiered_bps_config") - @ExcludeMissing - fun _tieredBpsConfig(): JsonField = tieredBpsConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingTieredBpsPrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - itemId() - modelType() - name() - tieredBpsConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingTieredBpsPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var tieredBpsConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newFloatingTieredBpsPrice: NewFloatingTieredBpsPrice) = - apply { - cadence = newFloatingTieredBpsPrice.cadence - currency = newFloatingTieredBpsPrice.currency - itemId = newFloatingTieredBpsPrice.itemId - modelType = newFloatingTieredBpsPrice.modelType - name = newFloatingTieredBpsPrice.name - tieredBpsConfig = newFloatingTieredBpsPrice.tieredBpsConfig - billableMetricId = newFloatingTieredBpsPrice.billableMetricId - billedInAdvance = newFloatingTieredBpsPrice.billedInAdvance - billingCycleConfiguration = - newFloatingTieredBpsPrice.billingCycleConfiguration - conversionRate = newFloatingTieredBpsPrice.conversionRate - externalPriceId = newFloatingTieredBpsPrice.externalPriceId - fixedPriceQuantity = newFloatingTieredBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingTieredBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingTieredBpsPrice.invoicingCycleConfiguration - metadata = newFloatingTieredBpsPrice.metadata - additionalProperties = - newFloatingTieredBpsPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredBpsConfig(tieredBpsConfig: TieredBpsConfig) = - tieredBpsConfig(JsonField.of(tieredBpsConfig)) - - fun tieredBpsConfig(tieredBpsConfig: JsonField) = apply { - this.tieredBpsConfig = tieredBpsConfig - } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingTieredBpsPrice = - NewFloatingTieredBpsPrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("tieredBpsConfig", tieredBpsConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED_BPS = of("tiered_bps") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_BPS -> Value.TIERED_BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TIERED_BPS -> Known.TIERED_BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TieredBpsConfig - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - private val tiers: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into - * specified tiers - */ - fun tiers(): List = tiers.getRequired("tiers") - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into - * specified tiers - */ - @JsonProperty("tiers") - @ExcludeMissing - fun _tiers(): JsonField> = tiers - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredBpsConfig = apply { - if (validated) { - return@apply - } - - tiers().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredBpsConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tieredBpsConfig: TieredBpsConfig) = apply { - tiers = tieredBpsConfig.tiers.map { it.toMutableList() } - additionalProperties = - tieredBpsConfig.additionalProperties.toMutableMap() - } - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into - * specified tiers - */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into - * specified tiers - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into - * specified tiers - */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): TieredBpsConfig = - TieredBpsConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Tier - @JsonCreator - private constructor( - @JsonProperty("bps") - @ExcludeMissing - private val bps: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_maximum") - @ExcludeMissing - private val perUnitMaximum: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), - ) { - - /** Per-event basis point rate */ - fun bps(): Double = bps.getRequired("bps") - - /** Inclusive tier starting value */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** Exclusive tier ending value */ - fun maximumAmount(): Optional = - Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - - /** Per unit maximum to charge */ - fun perUnitMaximum(): Optional = - Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) - - /** Per-event basis point rate */ - @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps - - /** Inclusive tier starting value */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** Exclusive tier ending value */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** Per unit maximum to charge */ - @JsonProperty("per_unit_maximum") - @ExcludeMissing - fun _perUnitMaximum(): JsonField = perUnitMaximum - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - bps() - minimumAmount() - maximumAmount() - perUnitMaximum() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var bps: JsonField? = null - private var minimumAmount: JsonField? = null - private var maximumAmount: JsonField = JsonMissing.of() - private var perUnitMaximum: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - bps = tier.bps - minimumAmount = tier.minimumAmount - maximumAmount = tier.maximumAmount - perUnitMaximum = tier.perUnitMaximum - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Per-event basis point rate */ - fun bps(bps: Double) = bps(JsonField.of(bps)) - - /** Per-event basis point rate */ - fun bps(bps: JsonField) = apply { this.bps = bps } - - /** Inclusive tier starting value */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** Inclusive tier starting value */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** Exclusive tier ending value */ - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - /** Exclusive tier ending value */ - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.orElse(null)) - - /** Exclusive tier ending value */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** Per unit maximum to charge */ - fun perUnitMaximum(perUnitMaximum: String?) = - perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) - - /** Per unit maximum to charge */ - fun perUnitMaximum(perUnitMaximum: Optional) = - perUnitMaximum(perUnitMaximum.orElse(null)) - - /** Per unit maximum to charge */ - fun perUnitMaximum(perUnitMaximum: JsonField) = apply { - this.perUnitMaximum = perUnitMaximum - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): Tier = - Tier( - checkRequired("bps", bps), - checkRequired("minimumAmount", minimumAmount), - maximumAmount, - perUnitMaximum, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tier && bps == other.bps && minimumAmount == other.minimumAmount && maximumAmount == other.maximumAmount && perUnitMaximum == other.perUnitMaximum && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bps, minimumAmount, maximumAmount, perUnitMaximum, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{bps=$bps, minimumAmount=$minimumAmount, maximumAmount=$maximumAmount, perUnitMaximum=$perUnitMaximum, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredBpsConfig && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredBpsConfig{tiers=$tiers, additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingTieredBpsPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredBpsConfig == other.tieredBpsConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, tieredBpsConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingTieredBpsPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredBpsConfig=$tieredBpsConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingBpsPrice - @JsonCreator - private constructor( - @JsonProperty("bps_config") - @ExcludeMissing - private val bpsConfig: JsonField = JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun bpsConfig(): BpsConfig = bpsConfig.getRequired("bps_config") - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - @JsonProperty("bps_config") - @ExcludeMissing - fun _bpsConfig(): JsonField = bpsConfig - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingBpsPrice = apply { - if (validated) { - return@apply - } - - bpsConfig().validate() - cadence() - currency() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingBpsPrice]. */ - class Builder internal constructor() { - - private var bpsConfig: JsonField? = null - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newFloatingBpsPrice: NewFloatingBpsPrice) = apply { - bpsConfig = newFloatingBpsPrice.bpsConfig - cadence = newFloatingBpsPrice.cadence - currency = newFloatingBpsPrice.currency - itemId = newFloatingBpsPrice.itemId - modelType = newFloatingBpsPrice.modelType - name = newFloatingBpsPrice.name - billableMetricId = newFloatingBpsPrice.billableMetricId - billedInAdvance = newFloatingBpsPrice.billedInAdvance - billingCycleConfiguration = newFloatingBpsPrice.billingCycleConfiguration - conversionRate = newFloatingBpsPrice.conversionRate - externalPriceId = newFloatingBpsPrice.externalPriceId - fixedPriceQuantity = newFloatingBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingBpsPrice.invoicingCycleConfiguration - metadata = newFloatingBpsPrice.metadata - additionalProperties = - newFloatingBpsPrice.additionalProperties.toMutableMap() - } - - fun bpsConfig(bpsConfig: BpsConfig) = bpsConfig(JsonField.of(bpsConfig)) - - fun bpsConfig(bpsConfig: JsonField) = apply { - this.bpsConfig = bpsConfig - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingBpsPrice = - NewFloatingBpsPrice( - checkRequired("bpsConfig", bpsConfig), - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BpsConfig - @JsonCreator - private constructor( - @JsonProperty("bps") - @ExcludeMissing - private val bps: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_maximum") - @ExcludeMissing - private val perUnitMaximum: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Basis point take rate per event */ - fun bps(): Double = bps.getRequired("bps") - - /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(): Optional = - Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) - - /** Basis point take rate per event */ - @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps - - /** Optional currency amount maximum to cap spend per event */ - @JsonProperty("per_unit_maximum") - @ExcludeMissing - fun _perUnitMaximum(): JsonField = perUnitMaximum - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BpsConfig = apply { - if (validated) { - return@apply - } - - bps() - perUnitMaximum() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BpsConfig]. */ - class Builder internal constructor() { - - private var bps: JsonField? = null - private var perUnitMaximum: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(bpsConfig: BpsConfig) = apply { - bps = bpsConfig.bps - perUnitMaximum = bpsConfig.perUnitMaximum - additionalProperties = bpsConfig.additionalProperties.toMutableMap() - } - - /** Basis point take rate per event */ - fun bps(bps: Double) = bps(JsonField.of(bps)) - - /** Basis point take rate per event */ - fun bps(bps: JsonField) = apply { this.bps = bps } - - /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(perUnitMaximum: String?) = - perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) - - /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(perUnitMaximum: Optional) = - perUnitMaximum(perUnitMaximum.orElse(null)) - - /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(perUnitMaximum: JsonField) = apply { - this.perUnitMaximum = perUnitMaximum - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): BpsConfig = - BpsConfig( - checkRequired("bps", bps), - perUnitMaximum, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BpsConfig && bps == other.bps && perUnitMaximum == other.perUnitMaximum && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bps, perUnitMaximum, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BpsConfig{bps=$bps, perUnitMaximum=$perUnitMaximum, additionalProperties=$additionalProperties}" - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val BPS = of("bps") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BPS -> Value.BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - BPS -> Known.BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingBpsPrice && bpsConfig == other.bpsConfig && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bpsConfig, cadence, currency, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingBpsPrice{bpsConfig=$bpsConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingBulkBpsPrice - @JsonCreator - private constructor( - @JsonProperty("bulk_bps_config") - @ExcludeMissing - private val bulkBpsConfig: JsonField = JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun bulkBpsConfig(): BulkBpsConfig = bulkBpsConfig.getRequired("bulk_bps_config") - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - @JsonProperty("bulk_bps_config") - @ExcludeMissing - fun _bulkBpsConfig(): JsonField = bulkBpsConfig - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingBulkBpsPrice = apply { - if (validated) { - return@apply - } - - bulkBpsConfig().validate() - cadence() - currency() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingBulkBpsPrice]. */ - class Builder internal constructor() { - - private var bulkBpsConfig: JsonField? = null - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newFloatingBulkBpsPrice: NewFloatingBulkBpsPrice) = apply { - bulkBpsConfig = newFloatingBulkBpsPrice.bulkBpsConfig - cadence = newFloatingBulkBpsPrice.cadence - currency = newFloatingBulkBpsPrice.currency - itemId = newFloatingBulkBpsPrice.itemId - modelType = newFloatingBulkBpsPrice.modelType - name = newFloatingBulkBpsPrice.name - billableMetricId = newFloatingBulkBpsPrice.billableMetricId - billedInAdvance = newFloatingBulkBpsPrice.billedInAdvance - billingCycleConfiguration = - newFloatingBulkBpsPrice.billingCycleConfiguration - conversionRate = newFloatingBulkBpsPrice.conversionRate - externalPriceId = newFloatingBulkBpsPrice.externalPriceId - fixedPriceQuantity = newFloatingBulkBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingBulkBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingBulkBpsPrice.invoicingCycleConfiguration - metadata = newFloatingBulkBpsPrice.metadata - additionalProperties = - newFloatingBulkBpsPrice.additionalProperties.toMutableMap() - } - - fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfig) = - bulkBpsConfig(JsonField.of(bulkBpsConfig)) - - fun bulkBpsConfig(bulkBpsConfig: JsonField) = apply { - this.bulkBpsConfig = bulkBpsConfig - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingBulkBpsPrice = - NewFloatingBulkBpsPrice( - checkRequired("bulkBpsConfig", bulkBpsConfig), - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BulkBpsConfig - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - private val tiers: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a single - * tier based on total volume - */ - fun tiers(): List = tiers.getRequired("tiers") - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a single - * tier based on total volume - */ - @JsonProperty("tiers") - @ExcludeMissing - fun _tiers(): JsonField> = tiers - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BulkBpsConfig = apply { - if (validated) { - return@apply - } - - tiers().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkBpsConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(bulkBpsConfig: BulkBpsConfig) = apply { - tiers = bulkBpsConfig.tiers.map { it.toMutableList() } - additionalProperties = bulkBpsConfig.additionalProperties.toMutableMap() - } - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a - * single tier based on total volume - */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a - * single tier based on total volume - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a - * single tier based on total volume - */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): BulkBpsConfig = - BulkBpsConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Tier - @JsonCreator - private constructor( - @JsonProperty("bps") - @ExcludeMissing - private val bps: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_maximum") - @ExcludeMissing - private val perUnitMaximum: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), - ) { - - /** Basis points to rate on */ - fun bps(): Double = bps.getRequired("bps") - - /** Upper bound for tier */ - fun maximumAmount(): Optional = - Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(): Optional = - Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) - - /** Basis points to rate on */ - @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps - - /** Upper bound for tier */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** The maximum amount to charge for any one event */ - @JsonProperty("per_unit_maximum") - @ExcludeMissing - fun _perUnitMaximum(): JsonField = perUnitMaximum - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - bps() - maximumAmount() - perUnitMaximum() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var bps: JsonField? = null - private var maximumAmount: JsonField = JsonMissing.of() - private var perUnitMaximum: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - bps = tier.bps - maximumAmount = tier.maximumAmount - perUnitMaximum = tier.perUnitMaximum - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Basis points to rate on */ - fun bps(bps: Double) = bps(JsonField.of(bps)) - - /** Basis points to rate on */ - fun bps(bps: JsonField) = apply { this.bps = bps } - - /** Upper bound for tier */ - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - /** Upper bound for tier */ - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.orElse(null)) - - /** Upper bound for tier */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(perUnitMaximum: String?) = - perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) - - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(perUnitMaximum: Optional) = - perUnitMaximum(perUnitMaximum.orElse(null)) - - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(perUnitMaximum: JsonField) = apply { - this.perUnitMaximum = perUnitMaximum - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): Tier = - Tier( - checkRequired("bps", bps), - maximumAmount, - perUnitMaximum, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tier && bps == other.bps && maximumAmount == other.maximumAmount && perUnitMaximum == other.perUnitMaximum && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bps, maximumAmount, perUnitMaximum, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{bps=$bps, maximumAmount=$maximumAmount, perUnitMaximum=$perUnitMaximum, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BulkBpsConfig && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkBpsConfig{tiers=$tiers, additionalProperties=$additionalProperties}" - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val BULK_BPS = of("bulk_bps") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK_BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK_BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK_BPS -> Value.BULK_BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - BULK_BPS -> Known.BULK_BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingBulkBpsPrice && bulkBpsConfig == other.bulkBpsConfig && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bulkBpsConfig, cadence, currency, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingBulkBpsPrice{bulkBpsConfig=$bulkBpsConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingBulkPrice - @JsonCreator - private constructor( - @JsonProperty("bulk_config") - @ExcludeMissing - private val bulkConfig: JsonField = JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun bulkConfig(): BulkConfig = bulkConfig.getRequired("bulk_config") - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - @JsonProperty("bulk_config") - @ExcludeMissing - fun _bulkConfig(): JsonField = bulkConfig - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingBulkPrice = apply { - if (validated) { - return@apply - } - - bulkConfig().validate() - cadence() - currency() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingBulkPrice]. */ - class Builder internal constructor() { - - private var bulkConfig: JsonField? = null - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var 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 externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newFloatingBulkPrice: NewFloatingBulkPrice) = apply { - bulkConfig = newFloatingBulkPrice.bulkConfig - cadence = newFloatingBulkPrice.cadence - currency = newFloatingBulkPrice.currency - itemId = newFloatingBulkPrice.itemId - modelType = newFloatingBulkPrice.modelType - name = newFloatingBulkPrice.name - billableMetricId = newFloatingBulkPrice.billableMetricId - billedInAdvance = newFloatingBulkPrice.billedInAdvance - billingCycleConfiguration = newFloatingBulkPrice.billingCycleConfiguration - conversionRate = newFloatingBulkPrice.conversionRate - externalPriceId = newFloatingBulkPrice.externalPriceId - fixedPriceQuantity = newFloatingBulkPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingBulkPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingBulkPrice.invoicingCycleConfiguration - metadata = newFloatingBulkPrice.metadata - additionalProperties = - newFloatingBulkPrice.additionalProperties.toMutableMap() - } - - fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) - - fun bulkConfig(bulkConfig: JsonField) = apply { - this.bulkConfig = bulkConfig - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingBulkPrice = - NewFloatingBulkPrice( - checkRequired("bulkConfig", bulkConfig), - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BulkConfig - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - private val tiers: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Bulk tiers for rating based on total usage volume */ - fun tiers(): List = tiers.getRequired("tiers") - - /** Bulk tiers for rating based on total usage volume */ - @JsonProperty("tiers") - @ExcludeMissing - fun _tiers(): JsonField> = tiers - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BulkConfig = apply { - if (validated) { - return@apply - } - - tiers().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(bulkConfig: BulkConfig) = apply { - tiers = bulkConfig.tiers.map { it.toMutableList() } - additionalProperties = bulkConfig.additionalProperties.toMutableMap() - } - - /** Bulk tiers for rating based on total usage volume */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - - /** Bulk tiers for rating based on total usage volume */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** Bulk tiers for rating based on total usage volume */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): BulkConfig = - BulkConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Tier - @JsonCreator - private constructor( - @JsonProperty("unit_amount") - @ExcludeMissing - private val unitAmount: JsonField = JsonMissing.of(), - @JsonProperty("maximum_units") - @ExcludeMissing - private val maximumUnits: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), - ) { - - /** Amount per unit */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** Upper bound for this tier */ - fun maximumUnits(): Optional = - Optional.ofNullable(maximumUnits.getNullable("maximum_units")) - - /** Amount per unit */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - /** Upper bound for this tier */ - @JsonProperty("maximum_units") - @ExcludeMissing - fun _maximumUnits(): JsonField = maximumUnits - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - unitAmount() - maximumUnits() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var unitAmount: JsonField? = null - private var maximumUnits: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - unitAmount = tier.unitAmount - maximumUnits = tier.maximumUnits - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) - - /** Amount per unit */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - /** Upper bound for this tier */ - fun maximumUnits(maximumUnits: Double?) = - maximumUnits(JsonField.ofNullable(maximumUnits)) - - /** Upper bound for this tier */ - fun maximumUnits(maximumUnits: Double) = - maximumUnits(maximumUnits as Double?) - - /** Upper bound for this tier */ - @Suppress( - "USELESS_CAST" - ) // See https://youtrack.jetbrains.com/issue/KT-74228 - fun maximumUnits(maximumUnits: Optional) = - maximumUnits(maximumUnits.orElse(null) as Double?) - - /** Upper bound for this tier */ - fun maximumUnits(maximumUnits: JsonField) = apply { - this.maximumUnits = maximumUnits - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Tier = - Tier( - checkRequired("unitAmount", unitAmount), - maximumUnits, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tier && unitAmount == other.unitAmount && maximumUnits == other.maximumUnits && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(unitAmount, maximumUnits, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{unitAmount=$unitAmount, maximumUnits=$maximumUnits, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BulkConfig && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkConfig{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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val BULK = of("bulk") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK -> Value.BULK - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - BULK -> Known.BULK - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingBulkPrice && bulkConfig == other.bulkConfig && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bulkConfig, cadence, currency, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingBulkPrice{bulkConfig=$bulkConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingThresholdTotalAmountPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("threshold_total_amount_config") - @ExcludeMissing - private val thresholdTotalAmountConfig: JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun thresholdTotalAmountConfig(): ThresholdTotalAmountConfig = - thresholdTotalAmountConfig.getRequired("threshold_total_amount_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("threshold_total_amount_config") - @ExcludeMissing - fun _thresholdTotalAmountConfig(): JsonField = - thresholdTotalAmountConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingThresholdTotalAmountPrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - itemId() - modelType() - name() - thresholdTotalAmountConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingThresholdTotalAmountPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var thresholdTotalAmountConfig: JsonField? = - null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newFloatingThresholdTotalAmountPrice: NewFloatingThresholdTotalAmountPrice - ) = apply { - cadence = newFloatingThresholdTotalAmountPrice.cadence - currency = newFloatingThresholdTotalAmountPrice.currency - itemId = newFloatingThresholdTotalAmountPrice.itemId - modelType = newFloatingThresholdTotalAmountPrice.modelType - name = newFloatingThresholdTotalAmountPrice.name - thresholdTotalAmountConfig = - newFloatingThresholdTotalAmountPrice.thresholdTotalAmountConfig - billableMetricId = newFloatingThresholdTotalAmountPrice.billableMetricId - billedInAdvance = newFloatingThresholdTotalAmountPrice.billedInAdvance - billingCycleConfiguration = - newFloatingThresholdTotalAmountPrice.billingCycleConfiguration - conversionRate = newFloatingThresholdTotalAmountPrice.conversionRate - externalPriceId = newFloatingThresholdTotalAmountPrice.externalPriceId - fixedPriceQuantity = newFloatingThresholdTotalAmountPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingThresholdTotalAmountPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingThresholdTotalAmountPrice.invoicingCycleConfiguration - metadata = newFloatingThresholdTotalAmountPrice.metadata - additionalProperties = - newFloatingThresholdTotalAmountPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun thresholdTotalAmountConfig( - thresholdTotalAmountConfig: ThresholdTotalAmountConfig - ) = thresholdTotalAmountConfig(JsonField.of(thresholdTotalAmountConfig)) - - fun thresholdTotalAmountConfig( - thresholdTotalAmountConfig: JsonField - ) = apply { this.thresholdTotalAmountConfig = thresholdTotalAmountConfig } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingThresholdTotalAmountPrice = - NewFloatingThresholdTotalAmountPrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("thresholdTotalAmountConfig", thresholdTotalAmountConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val THRESHOLD_TOTAL_AMOUNT = of("threshold_total_amount") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - THRESHOLD_TOTAL_AMOUNT - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - THRESHOLD_TOTAL_AMOUNT, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - THRESHOLD_TOTAL_AMOUNT -> Value.THRESHOLD_TOTAL_AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - THRESHOLD_TOTAL_AMOUNT -> Known.THRESHOLD_TOTAL_AMOUNT - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class ThresholdTotalAmountConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): ThresholdTotalAmountConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ThresholdTotalAmountConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(thresholdTotalAmountConfig: ThresholdTotalAmountConfig) = - apply { - additionalProperties = - thresholdTotalAmountConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): ThresholdTotalAmountConfig = - ThresholdTotalAmountConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ThresholdTotalAmountConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ThresholdTotalAmountConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingThresholdTotalAmountPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, thresholdTotalAmountConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingThresholdTotalAmountPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingTieredPackagePrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_package_config") - @ExcludeMissing - private val tieredPackageConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun tieredPackageConfig(): TieredPackageConfig = - tieredPackageConfig.getRequired("tiered_package_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("tiered_package_config") - @ExcludeMissing - fun _tieredPackageConfig(): JsonField = tieredPackageConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingTieredPackagePrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - itemId() - modelType() - name() - tieredPackageConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingTieredPackagePrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var tieredPackageConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newFloatingTieredPackagePrice: NewFloatingTieredPackagePrice - ) = apply { - cadence = newFloatingTieredPackagePrice.cadence - currency = newFloatingTieredPackagePrice.currency - itemId = newFloatingTieredPackagePrice.itemId - modelType = newFloatingTieredPackagePrice.modelType - name = newFloatingTieredPackagePrice.name - tieredPackageConfig = newFloatingTieredPackagePrice.tieredPackageConfig - billableMetricId = newFloatingTieredPackagePrice.billableMetricId - billedInAdvance = newFloatingTieredPackagePrice.billedInAdvance - billingCycleConfiguration = - newFloatingTieredPackagePrice.billingCycleConfiguration - conversionRate = newFloatingTieredPackagePrice.conversionRate - externalPriceId = newFloatingTieredPackagePrice.externalPriceId - fixedPriceQuantity = newFloatingTieredPackagePrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingTieredPackagePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingTieredPackagePrice.invoicingCycleConfiguration - metadata = newFloatingTieredPackagePrice.metadata - additionalProperties = - newFloatingTieredPackagePrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = - tieredPackageConfig(JsonField.of(tieredPackageConfig)) - - fun tieredPackageConfig(tieredPackageConfig: JsonField) = - apply { - this.tieredPackageConfig = tieredPackageConfig - } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingTieredPackagePrice = - NewFloatingTieredPackagePrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("tieredPackageConfig", tieredPackageConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED_PACKAGE = of("tiered_package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_PACKAGE - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_PACKAGE, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_PACKAGE -> Value.TIERED_PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TIERED_PACKAGE -> Known.TIERED_PACKAGE - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TieredPackageConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredPackageConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredPackageConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tieredPackageConfig: TieredPackageConfig) = apply { - additionalProperties = - tieredPackageConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): TieredPackageConfig = - TieredPackageConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredPackageConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingTieredPackagePrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredPackageConfig == other.tieredPackageConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, tieredPackageConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingTieredPackagePrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingGroupedTieredPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("grouped_tiered_config") - @ExcludeMissing - private val groupedTieredConfig: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - fun groupedTieredConfig(): GroupedTieredConfig = - groupedTieredConfig.getRequired("grouped_tiered_config") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - @JsonProperty("grouped_tiered_config") - @ExcludeMissing - fun _groupedTieredConfig(): JsonField = groupedTieredConfig - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingGroupedTieredPrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - groupedTieredConfig().validate() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingGroupedTieredPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var groupedTieredConfig: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var 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 externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newFloatingGroupedTieredPrice: NewFloatingGroupedTieredPrice - ) = apply { - cadence = newFloatingGroupedTieredPrice.cadence - currency = newFloatingGroupedTieredPrice.currency - groupedTieredConfig = newFloatingGroupedTieredPrice.groupedTieredConfig - itemId = newFloatingGroupedTieredPrice.itemId - modelType = newFloatingGroupedTieredPrice.modelType - name = newFloatingGroupedTieredPrice.name - billableMetricId = newFloatingGroupedTieredPrice.billableMetricId - billedInAdvance = newFloatingGroupedTieredPrice.billedInAdvance - billingCycleConfiguration = - newFloatingGroupedTieredPrice.billingCycleConfiguration - conversionRate = newFloatingGroupedTieredPrice.conversionRate - externalPriceId = newFloatingGroupedTieredPrice.externalPriceId - fixedPriceQuantity = newFloatingGroupedTieredPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingGroupedTieredPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingGroupedTieredPrice.invoicingCycleConfiguration - metadata = newFloatingGroupedTieredPrice.metadata - additionalProperties = - newFloatingGroupedTieredPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun groupedTieredConfig(groupedTieredConfig: GroupedTieredConfig) = - groupedTieredConfig(JsonField.of(groupedTieredConfig)) - - fun groupedTieredConfig(groupedTieredConfig: JsonField) = - apply { - this.groupedTieredConfig = groupedTieredConfig - } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingGroupedTieredPrice = - NewFloatingGroupedTieredPrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("groupedTieredConfig", groupedTieredConfig), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class GroupedTieredConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): GroupedTieredConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [GroupedTieredConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(groupedTieredConfig: GroupedTieredConfig) = apply { - additionalProperties = - groupedTieredConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): GroupedTieredConfig = - GroupedTieredConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GroupedTieredConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedTieredConfig{additionalProperties=$additionalProperties}" - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val GROUPED_TIERED = of("grouped_tiered") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_TIERED - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GROUPED_TIERED, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GROUPED_TIERED -> Value.GROUPED_TIERED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - GROUPED_TIERED -> Known.GROUPED_TIERED - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingGroupedTieredPrice && cadence == other.cadence && currency == other.currency && groupedTieredConfig == other.groupedTieredConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, groupedTieredConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingGroupedTieredPrice{cadence=$cadence, currency=$currency, groupedTieredConfig=$groupedTieredConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingMaxGroupTieredPackagePrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("max_group_tiered_package_config") - @ExcludeMissing - private val maxGroupTieredPackageConfig: JsonField = - JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun maxGroupTieredPackageConfig(): MaxGroupTieredPackageConfig = - maxGroupTieredPackageConfig.getRequired("max_group_tiered_package_config") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("max_group_tiered_package_config") - @ExcludeMissing - fun _maxGroupTieredPackageConfig(): JsonField = - maxGroupTieredPackageConfig - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingMaxGroupTieredPackagePrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - itemId() - maxGroupTieredPackageConfig().validate() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingMaxGroupTieredPackagePrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var maxGroupTieredPackageConfig: - JsonField? = - null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newFloatingMaxGroupTieredPackagePrice: NewFloatingMaxGroupTieredPackagePrice - ) = apply { - cadence = newFloatingMaxGroupTieredPackagePrice.cadence - currency = newFloatingMaxGroupTieredPackagePrice.currency - itemId = newFloatingMaxGroupTieredPackagePrice.itemId - maxGroupTieredPackageConfig = - newFloatingMaxGroupTieredPackagePrice.maxGroupTieredPackageConfig - modelType = newFloatingMaxGroupTieredPackagePrice.modelType - name = newFloatingMaxGroupTieredPackagePrice.name - billableMetricId = newFloatingMaxGroupTieredPackagePrice.billableMetricId - billedInAdvance = newFloatingMaxGroupTieredPackagePrice.billedInAdvance - billingCycleConfiguration = - newFloatingMaxGroupTieredPackagePrice.billingCycleConfiguration - conversionRate = newFloatingMaxGroupTieredPackagePrice.conversionRate - externalPriceId = newFloatingMaxGroupTieredPackagePrice.externalPriceId - fixedPriceQuantity = - newFloatingMaxGroupTieredPackagePrice.fixedPriceQuantity - invoiceGroupingKey = - newFloatingMaxGroupTieredPackagePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingMaxGroupTieredPackagePrice.invoicingCycleConfiguration - metadata = newFloatingMaxGroupTieredPackagePrice.metadata - additionalProperties = - newFloatingMaxGroupTieredPackagePrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun maxGroupTieredPackageConfig( - maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig - ) = maxGroupTieredPackageConfig(JsonField.of(maxGroupTieredPackageConfig)) - - fun maxGroupTieredPackageConfig( - maxGroupTieredPackageConfig: JsonField - ) = apply { this.maxGroupTieredPackageConfig = maxGroupTieredPackageConfig } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingMaxGroupTieredPackagePrice = - NewFloatingMaxGroupTieredPackagePrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired( - "maxGroupTieredPackageConfig", - maxGroupTieredPackageConfig, - ), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class MaxGroupTieredPackageConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MaxGroupTieredPackageConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MaxGroupTieredPackageConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - maxGroupTieredPackageConfig: MaxGroupTieredPackageConfig - ) = apply { - additionalProperties = - maxGroupTieredPackageConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): MaxGroupTieredPackageConfig = - MaxGroupTieredPackageConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MaxGroupTieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MaxGroupTieredPackageConfig{additionalProperties=$additionalProperties}" - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MAX_GROUP_TIERED_PACKAGE = of("max_group_tiered_package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MAX_GROUP_TIERED_PACKAGE - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAX_GROUP_TIERED_PACKAGE, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAX_GROUP_TIERED_PACKAGE -> Value.MAX_GROUP_TIERED_PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAX_GROUP_TIERED_PACKAGE -> Known.MAX_GROUP_TIERED_PACKAGE - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingMaxGroupTieredPackagePrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && maxGroupTieredPackageConfig == other.maxGroupTieredPackageConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, maxGroupTieredPackageConfig, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingMaxGroupTieredPackagePrice{cadence=$cadence, currency=$currency, itemId=$itemId, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingTieredWithMinimumPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_minimum_config") - @ExcludeMissing - private val tieredWithMinimumConfig: JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun tieredWithMinimumConfig(): TieredWithMinimumConfig = - tieredWithMinimumConfig.getRequired("tiered_with_minimum_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("tiered_with_minimum_config") - @ExcludeMissing - fun _tieredWithMinimumConfig(): JsonField = - tieredWithMinimumConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingTieredWithMinimumPrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - itemId() - modelType() - name() - tieredWithMinimumConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingTieredWithMinimumPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var tieredWithMinimumConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newFloatingTieredWithMinimumPrice: NewFloatingTieredWithMinimumPrice - ) = apply { - cadence = newFloatingTieredWithMinimumPrice.cadence - currency = newFloatingTieredWithMinimumPrice.currency - itemId = newFloatingTieredWithMinimumPrice.itemId - modelType = newFloatingTieredWithMinimumPrice.modelType - name = newFloatingTieredWithMinimumPrice.name - tieredWithMinimumConfig = - newFloatingTieredWithMinimumPrice.tieredWithMinimumConfig - billableMetricId = newFloatingTieredWithMinimumPrice.billableMetricId - billedInAdvance = newFloatingTieredWithMinimumPrice.billedInAdvance - billingCycleConfiguration = - newFloatingTieredWithMinimumPrice.billingCycleConfiguration - conversionRate = newFloatingTieredWithMinimumPrice.conversionRate - externalPriceId = newFloatingTieredWithMinimumPrice.externalPriceId - fixedPriceQuantity = newFloatingTieredWithMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingTieredWithMinimumPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingTieredWithMinimumPrice.invoicingCycleConfiguration - metadata = newFloatingTieredWithMinimumPrice.metadata - additionalProperties = - newFloatingTieredWithMinimumPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredWithMinimumConfig(tieredWithMinimumConfig: TieredWithMinimumConfig) = - tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) - - fun tieredWithMinimumConfig( - tieredWithMinimumConfig: JsonField - ) = apply { this.tieredWithMinimumConfig = tieredWithMinimumConfig } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingTieredWithMinimumPrice = - NewFloatingTieredWithMinimumPrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("tieredWithMinimumConfig", tieredWithMinimumConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED_WITH_MINIMUM = of("tiered_with_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_WITH_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_WITH_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_WITH_MINIMUM -> Value.TIERED_WITH_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TIERED_WITH_MINIMUM -> Known.TIERED_WITH_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TieredWithMinimumConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredWithMinimumConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredWithMinimumConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tieredWithMinimumConfig: TieredWithMinimumConfig) = - apply { - additionalProperties = - tieredWithMinimumConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): TieredWithMinimumConfig = - TieredWithMinimumConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredWithMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredWithMinimumConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingTieredWithMinimumPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredWithMinimumConfig == other.tieredWithMinimumConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, tieredWithMinimumConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingTieredWithMinimumPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingPackageWithAllocationPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("package_with_allocation_config") - @ExcludeMissing - private val packageWithAllocationConfig: JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun packageWithAllocationConfig(): PackageWithAllocationConfig = - packageWithAllocationConfig.getRequired("package_with_allocation_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("package_with_allocation_config") - @ExcludeMissing - fun _packageWithAllocationConfig(): JsonField = - packageWithAllocationConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingPackageWithAllocationPrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - itemId() - modelType() - name() - packageWithAllocationConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingPackageWithAllocationPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var packageWithAllocationConfig: - JsonField? = - null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newFloatingPackageWithAllocationPrice: NewFloatingPackageWithAllocationPrice - ) = apply { - cadence = newFloatingPackageWithAllocationPrice.cadence - currency = newFloatingPackageWithAllocationPrice.currency - itemId = newFloatingPackageWithAllocationPrice.itemId - modelType = newFloatingPackageWithAllocationPrice.modelType - name = newFloatingPackageWithAllocationPrice.name - packageWithAllocationConfig = - newFloatingPackageWithAllocationPrice.packageWithAllocationConfig - billableMetricId = newFloatingPackageWithAllocationPrice.billableMetricId - billedInAdvance = newFloatingPackageWithAllocationPrice.billedInAdvance - billingCycleConfiguration = - newFloatingPackageWithAllocationPrice.billingCycleConfiguration - conversionRate = newFloatingPackageWithAllocationPrice.conversionRate - externalPriceId = newFloatingPackageWithAllocationPrice.externalPriceId - fixedPriceQuantity = - newFloatingPackageWithAllocationPrice.fixedPriceQuantity - invoiceGroupingKey = - newFloatingPackageWithAllocationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingPackageWithAllocationPrice.invoicingCycleConfiguration - metadata = newFloatingPackageWithAllocationPrice.metadata - additionalProperties = - newFloatingPackageWithAllocationPrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun packageWithAllocationConfig( - packageWithAllocationConfig: PackageWithAllocationConfig - ) = packageWithAllocationConfig(JsonField.of(packageWithAllocationConfig)) - - fun packageWithAllocationConfig( - packageWithAllocationConfig: JsonField - ) = apply { this.packageWithAllocationConfig = packageWithAllocationConfig } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingPackageWithAllocationPrice = - NewFloatingPackageWithAllocationPrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired( - "packageWithAllocationConfig", - packageWithAllocationConfig, - ), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val PACKAGE_WITH_ALLOCATION = of("package_with_allocation") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - PACKAGE_WITH_ALLOCATION - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PACKAGE_WITH_ALLOCATION, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PACKAGE_WITH_ALLOCATION -> Value.PACKAGE_WITH_ALLOCATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PACKAGE_WITH_ALLOCATION -> Known.PACKAGE_WITH_ALLOCATION - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class PackageWithAllocationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PackageWithAllocationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PackageWithAllocationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - packageWithAllocationConfig: PackageWithAllocationConfig - ) = apply { - additionalProperties = - packageWithAllocationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): PackageWithAllocationConfig = - PackageWithAllocationConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PackageWithAllocationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PackageWithAllocationConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingPackageWithAllocationPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && packageWithAllocationConfig == other.packageWithAllocationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, packageWithAllocationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingPackageWithAllocationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingTieredPackageWithMinimumPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_package_with_minimum_config") - @ExcludeMissing - private val tieredPackageWithMinimumConfig: - JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun tieredPackageWithMinimumConfig(): TieredPackageWithMinimumConfig = - tieredPackageWithMinimumConfig.getRequired("tiered_package_with_minimum_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("tiered_package_with_minimum_config") - @ExcludeMissing - fun _tieredPackageWithMinimumConfig(): JsonField = - tieredPackageWithMinimumConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingTieredPackageWithMinimumPrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - itemId() - modelType() - name() - tieredPackageWithMinimumConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingTieredPackageWithMinimumPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var tieredPackageWithMinimumConfig: - JsonField? = - null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newFloatingTieredPackageWithMinimumPrice: - NewFloatingTieredPackageWithMinimumPrice - ) = apply { - cadence = newFloatingTieredPackageWithMinimumPrice.cadence - currency = newFloatingTieredPackageWithMinimumPrice.currency - itemId = newFloatingTieredPackageWithMinimumPrice.itemId - modelType = newFloatingTieredPackageWithMinimumPrice.modelType - name = newFloatingTieredPackageWithMinimumPrice.name - tieredPackageWithMinimumConfig = - newFloatingTieredPackageWithMinimumPrice.tieredPackageWithMinimumConfig - billableMetricId = newFloatingTieredPackageWithMinimumPrice.billableMetricId - billedInAdvance = newFloatingTieredPackageWithMinimumPrice.billedInAdvance - billingCycleConfiguration = - newFloatingTieredPackageWithMinimumPrice.billingCycleConfiguration - conversionRate = newFloatingTieredPackageWithMinimumPrice.conversionRate - externalPriceId = newFloatingTieredPackageWithMinimumPrice.externalPriceId - fixedPriceQuantity = - newFloatingTieredPackageWithMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = - newFloatingTieredPackageWithMinimumPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingTieredPackageWithMinimumPrice.invoicingCycleConfiguration - metadata = newFloatingTieredPackageWithMinimumPrice.metadata - additionalProperties = - newFloatingTieredPackageWithMinimumPrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredPackageWithMinimumConfig( - tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig - ) = tieredPackageWithMinimumConfig(JsonField.of(tieredPackageWithMinimumConfig)) - - fun tieredPackageWithMinimumConfig( - tieredPackageWithMinimumConfig: JsonField - ) = apply { - this.tieredPackageWithMinimumConfig = tieredPackageWithMinimumConfig - } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingTieredPackageWithMinimumPrice = - NewFloatingTieredPackageWithMinimumPrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired( - "tieredPackageWithMinimumConfig", - tieredPackageWithMinimumConfig, - ), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField - val TIERED_PACKAGE_WITH_MINIMUM = of("tiered_package_with_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_PACKAGE_WITH_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_PACKAGE_WITH_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_PACKAGE_WITH_MINIMUM -> Value.TIERED_PACKAGE_WITH_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TIERED_PACKAGE_WITH_MINIMUM -> Known.TIERED_PACKAGE_WITH_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TieredPackageWithMinimumConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredPackageWithMinimumConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredPackageWithMinimumConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig - ) = apply { - additionalProperties = - tieredPackageWithMinimumConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): TieredPackageWithMinimumConfig = - TieredPackageWithMinimumConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredPackageWithMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredPackageWithMinimumConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingTieredPackageWithMinimumPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredPackageWithMinimumConfig == other.tieredPackageWithMinimumConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, tieredPackageWithMinimumConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingTieredPackageWithMinimumPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingUnitWithPercentPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("unit_with_percent_config") - @ExcludeMissing - private val unitWithPercentConfig: JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun unitWithPercentConfig(): UnitWithPercentConfig = - unitWithPercentConfig.getRequired("unit_with_percent_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("unit_with_percent_config") - @ExcludeMissing - fun _unitWithPercentConfig(): JsonField = - unitWithPercentConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingUnitWithPercentPrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - itemId() - modelType() - name() - unitWithPercentConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingUnitWithPercentPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var unitWithPercentConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newFloatingUnitWithPercentPrice: NewFloatingUnitWithPercentPrice - ) = apply { - cadence = newFloatingUnitWithPercentPrice.cadence - currency = newFloatingUnitWithPercentPrice.currency - itemId = newFloatingUnitWithPercentPrice.itemId - modelType = newFloatingUnitWithPercentPrice.modelType - name = newFloatingUnitWithPercentPrice.name - unitWithPercentConfig = - newFloatingUnitWithPercentPrice.unitWithPercentConfig - billableMetricId = newFloatingUnitWithPercentPrice.billableMetricId - billedInAdvance = newFloatingUnitWithPercentPrice.billedInAdvance - billingCycleConfiguration = - newFloatingUnitWithPercentPrice.billingCycleConfiguration - conversionRate = newFloatingUnitWithPercentPrice.conversionRate - externalPriceId = newFloatingUnitWithPercentPrice.externalPriceId - fixedPriceQuantity = newFloatingUnitWithPercentPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingUnitWithPercentPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingUnitWithPercentPrice.invoicingCycleConfiguration - metadata = newFloatingUnitWithPercentPrice.metadata - additionalProperties = - newFloatingUnitWithPercentPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun unitWithPercentConfig(unitWithPercentConfig: UnitWithPercentConfig) = - unitWithPercentConfig(JsonField.of(unitWithPercentConfig)) - - fun unitWithPercentConfig( - unitWithPercentConfig: JsonField - ) = apply { this.unitWithPercentConfig = unitWithPercentConfig } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingUnitWithPercentPrice = - NewFloatingUnitWithPercentPrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("unitWithPercentConfig", unitWithPercentConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val UNIT_WITH_PERCENT = of("unit_with_percent") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - UNIT_WITH_PERCENT - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - UNIT_WITH_PERCENT, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - UNIT_WITH_PERCENT -> Value.UNIT_WITH_PERCENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - UNIT_WITH_PERCENT -> Known.UNIT_WITH_PERCENT - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class UnitWithPercentConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): UnitWithPercentConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnitWithPercentConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unitWithPercentConfig: UnitWithPercentConfig) = apply { - additionalProperties = - unitWithPercentConfig.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) - } - - fun build(): UnitWithPercentConfig = - UnitWithPercentConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UnitWithPercentConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnitWithPercentConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingUnitWithPercentPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && unitWithPercentConfig == other.unitWithPercentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, unitWithPercentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingUnitWithPercentPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingTieredWithProrationPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - private val tieredWithProrationConfig: JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - 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. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingTieredWithProrationPrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - itemId() - modelType() - name() - tieredWithProrationConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingTieredWithProrationPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var 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 externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newFloatingTieredWithProrationPrice: NewFloatingTieredWithProrationPrice - ) = apply { - cadence = newFloatingTieredWithProrationPrice.cadence - currency = newFloatingTieredWithProrationPrice.currency - itemId = newFloatingTieredWithProrationPrice.itemId - modelType = newFloatingTieredWithProrationPrice.modelType - name = newFloatingTieredWithProrationPrice.name - tieredWithProrationConfig = - newFloatingTieredWithProrationPrice.tieredWithProrationConfig - billableMetricId = newFloatingTieredWithProrationPrice.billableMetricId - billedInAdvance = newFloatingTieredWithProrationPrice.billedInAdvance - billingCycleConfiguration = - newFloatingTieredWithProrationPrice.billingCycleConfiguration - conversionRate = newFloatingTieredWithProrationPrice.conversionRate - externalPriceId = newFloatingTieredWithProrationPrice.externalPriceId - fixedPriceQuantity = newFloatingTieredWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingTieredWithProrationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingTieredWithProrationPrice.invoicingCycleConfiguration - metadata = newFloatingTieredWithProrationPrice.metadata - additionalProperties = - newFloatingTieredWithProrationPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredWithProrationConfig( - tieredWithProrationConfig: TieredWithProrationConfig - ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingTieredWithProrationPrice = - NewFloatingTieredWithProrationPrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED_WITH_PRORATION = of("tiered_with_proration") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_WITH_PRORATION - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_WITH_PRORATION, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_WITH_PRORATION -> Value.TIERED_WITH_PRORATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TIERED_WITH_PRORATION -> Known.TIERED_WITH_PRORATION - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TieredWithProrationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredWithProrationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredWithProrationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = - apply { - additionalProperties = - tieredWithProrationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredWithProrationConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingTieredWithProrationPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingTieredWithProrationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingUnitWithProrationPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("unit_with_proration_config") - @ExcludeMissing - private val unitWithProrationConfig: JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun unitWithProrationConfig(): UnitWithProrationConfig = - unitWithProrationConfig.getRequired("unit_with_proration_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("unit_with_proration_config") - @ExcludeMissing - fun _unitWithProrationConfig(): JsonField = - unitWithProrationConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingUnitWithProrationPrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - itemId() - modelType() - name() - unitWithProrationConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingUnitWithProrationPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var unitWithProrationConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newFloatingUnitWithProrationPrice: NewFloatingUnitWithProrationPrice - ) = apply { - cadence = newFloatingUnitWithProrationPrice.cadence - currency = newFloatingUnitWithProrationPrice.currency - itemId = newFloatingUnitWithProrationPrice.itemId - modelType = newFloatingUnitWithProrationPrice.modelType - name = newFloatingUnitWithProrationPrice.name - unitWithProrationConfig = - newFloatingUnitWithProrationPrice.unitWithProrationConfig - billableMetricId = newFloatingUnitWithProrationPrice.billableMetricId - billedInAdvance = newFloatingUnitWithProrationPrice.billedInAdvance - billingCycleConfiguration = - newFloatingUnitWithProrationPrice.billingCycleConfiguration - conversionRate = newFloatingUnitWithProrationPrice.conversionRate - externalPriceId = newFloatingUnitWithProrationPrice.externalPriceId - fixedPriceQuantity = newFloatingUnitWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingUnitWithProrationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingUnitWithProrationPrice.invoicingCycleConfiguration - metadata = newFloatingUnitWithProrationPrice.metadata - additionalProperties = - newFloatingUnitWithProrationPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun unitWithProrationConfig(unitWithProrationConfig: UnitWithProrationConfig) = - unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) - - fun unitWithProrationConfig( - unitWithProrationConfig: JsonField - ) = apply { this.unitWithProrationConfig = unitWithProrationConfig } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingUnitWithProrationPrice = - NewFloatingUnitWithProrationPrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("unitWithProrationConfig", unitWithProrationConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val UNIT_WITH_PRORATION = of("unit_with_proration") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - UNIT_WITH_PRORATION - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - UNIT_WITH_PRORATION, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - UNIT_WITH_PRORATION -> Value.UNIT_WITH_PRORATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - UNIT_WITH_PRORATION -> Known.UNIT_WITH_PRORATION - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class UnitWithProrationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): UnitWithProrationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnitWithProrationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unitWithProrationConfig: UnitWithProrationConfig) = - apply { - additionalProperties = - unitWithProrationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): UnitWithProrationConfig = - UnitWithProrationConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UnitWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnitWithProrationConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingUnitWithProrationPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && unitWithProrationConfig == other.unitWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, unitWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingUnitWithProrationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingGroupedAllocationPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("grouped_allocation_config") - @ExcludeMissing - private val groupedAllocationConfig: JsonField = - JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - fun groupedAllocationConfig(): GroupedAllocationConfig = - groupedAllocationConfig.getRequired("grouped_allocation_config") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - @JsonProperty("grouped_allocation_config") - @ExcludeMissing - fun _groupedAllocationConfig(): JsonField = - groupedAllocationConfig - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingGroupedAllocationPrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - groupedAllocationConfig().validate() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingGroupedAllocationPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var groupedAllocationConfig: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var 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 externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newFloatingGroupedAllocationPrice: NewFloatingGroupedAllocationPrice - ) = apply { - cadence = newFloatingGroupedAllocationPrice.cadence - currency = newFloatingGroupedAllocationPrice.currency - groupedAllocationConfig = - newFloatingGroupedAllocationPrice.groupedAllocationConfig - itemId = newFloatingGroupedAllocationPrice.itemId - modelType = newFloatingGroupedAllocationPrice.modelType - name = newFloatingGroupedAllocationPrice.name - billableMetricId = newFloatingGroupedAllocationPrice.billableMetricId - billedInAdvance = newFloatingGroupedAllocationPrice.billedInAdvance - billingCycleConfiguration = - newFloatingGroupedAllocationPrice.billingCycleConfiguration - conversionRate = newFloatingGroupedAllocationPrice.conversionRate - externalPriceId = newFloatingGroupedAllocationPrice.externalPriceId - fixedPriceQuantity = newFloatingGroupedAllocationPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingGroupedAllocationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingGroupedAllocationPrice.invoicingCycleConfiguration - metadata = newFloatingGroupedAllocationPrice.metadata - additionalProperties = - newFloatingGroupedAllocationPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = - groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) - - fun groupedAllocationConfig( - groupedAllocationConfig: JsonField - ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingGroupedAllocationPrice = - NewFloatingGroupedAllocationPrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("groupedAllocationConfig", groupedAllocationConfig), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class GroupedAllocationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): GroupedAllocationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [GroupedAllocationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(groupedAllocationConfig: GroupedAllocationConfig) = - apply { - additionalProperties = - groupedAllocationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): GroupedAllocationConfig = - GroupedAllocationConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GroupedAllocationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedAllocationConfig{additionalProperties=$additionalProperties}" - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val GROUPED_ALLOCATION = of("grouped_allocation") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_ALLOCATION - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GROUPED_ALLOCATION, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GROUPED_ALLOCATION -> Value.GROUPED_ALLOCATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - GROUPED_ALLOCATION -> Known.GROUPED_ALLOCATION - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingGroupedAllocationPrice && cadence == other.cadence && currency == other.currency && groupedAllocationConfig == other.groupedAllocationConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, groupedAllocationConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingGroupedAllocationPrice{cadence=$cadence, currency=$currency, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingGroupedWithProratedMinimumPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_prorated_minimum_config") - @ExcludeMissing - private val groupedWithProratedMinimumConfig: - JsonField = - JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - fun groupedWithProratedMinimumConfig(): GroupedWithProratedMinimumConfig = - groupedWithProratedMinimumConfig.getRequired( - "grouped_with_prorated_minimum_config" - ) - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - @JsonProperty("grouped_with_prorated_minimum_config") - @ExcludeMissing - fun _groupedWithProratedMinimumConfig(): - JsonField = groupedWithProratedMinimumConfig - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingGroupedWithProratedMinimumPrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - groupedWithProratedMinimumConfig().validate() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingGroupedWithProratedMinimumPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var groupedWithProratedMinimumConfig: - JsonField? = - null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newFloatingGroupedWithProratedMinimumPrice: - NewFloatingGroupedWithProratedMinimumPrice - ) = apply { - cadence = newFloatingGroupedWithProratedMinimumPrice.cadence - currency = newFloatingGroupedWithProratedMinimumPrice.currency - groupedWithProratedMinimumConfig = - newFloatingGroupedWithProratedMinimumPrice - .groupedWithProratedMinimumConfig - itemId = newFloatingGroupedWithProratedMinimumPrice.itemId - modelType = newFloatingGroupedWithProratedMinimumPrice.modelType - name = newFloatingGroupedWithProratedMinimumPrice.name - billableMetricId = - newFloatingGroupedWithProratedMinimumPrice.billableMetricId - billedInAdvance = newFloatingGroupedWithProratedMinimumPrice.billedInAdvance - billingCycleConfiguration = - newFloatingGroupedWithProratedMinimumPrice.billingCycleConfiguration - conversionRate = newFloatingGroupedWithProratedMinimumPrice.conversionRate - externalPriceId = newFloatingGroupedWithProratedMinimumPrice.externalPriceId - fixedPriceQuantity = - newFloatingGroupedWithProratedMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = - newFloatingGroupedWithProratedMinimumPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingGroupedWithProratedMinimumPrice.invoicingCycleConfiguration - metadata = newFloatingGroupedWithProratedMinimumPrice.metadata - additionalProperties = - newFloatingGroupedWithProratedMinimumPrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun groupedWithProratedMinimumConfig( - groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig - ) = - groupedWithProratedMinimumConfig( - JsonField.of(groupedWithProratedMinimumConfig) - ) - - fun groupedWithProratedMinimumConfig( - groupedWithProratedMinimumConfig: - JsonField - ) = apply { - this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig - } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingGroupedWithProratedMinimumPrice = - NewFloatingGroupedWithProratedMinimumPrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired( - "groupedWithProratedMinimumConfig", - groupedWithProratedMinimumConfig, - ), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class GroupedWithProratedMinimumConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): GroupedWithProratedMinimumConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [GroupedWithProratedMinimumConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig - ) = apply { - additionalProperties = - groupedWithProratedMinimumConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): GroupedWithProratedMinimumConfig = - GroupedWithProratedMinimumConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GroupedWithProratedMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedWithProratedMinimumConfig{additionalProperties=$additionalProperties}" - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField - val GROUPED_WITH_PRORATED_MINIMUM = of("grouped_with_prorated_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_WITH_PRORATED_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GROUPED_WITH_PRORATED_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GROUPED_WITH_PRORATED_MINIMUM -> Value.GROUPED_WITH_PRORATED_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - GROUPED_WITH_PRORATED_MINIMUM -> Known.GROUPED_WITH_PRORATED_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingGroupedWithProratedMinimumPrice && cadence == other.cadence && currency == other.currency && groupedWithProratedMinimumConfig == other.groupedWithProratedMinimumConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, groupedWithProratedMinimumConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingGroupedWithProratedMinimumPrice{cadence=$cadence, currency=$currency, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingGroupedWithMeteredMinimumPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_metered_minimum_config") - @ExcludeMissing - private val groupedWithMeteredMinimumConfig: - JsonField = - JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - fun groupedWithMeteredMinimumConfig(): GroupedWithMeteredMinimumConfig = - groupedWithMeteredMinimumConfig.getRequired( - "grouped_with_metered_minimum_config" - ) - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - @JsonProperty("grouped_with_metered_minimum_config") - @ExcludeMissing - fun _groupedWithMeteredMinimumConfig(): JsonField = - groupedWithMeteredMinimumConfig - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingGroupedWithMeteredMinimumPrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - groupedWithMeteredMinimumConfig().validate() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingGroupedWithMeteredMinimumPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var groupedWithMeteredMinimumConfig: - JsonField? = - null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newFloatingGroupedWithMeteredMinimumPrice: - NewFloatingGroupedWithMeteredMinimumPrice - ) = apply { - cadence = newFloatingGroupedWithMeteredMinimumPrice.cadence - currency = newFloatingGroupedWithMeteredMinimumPrice.currency - groupedWithMeteredMinimumConfig = - newFloatingGroupedWithMeteredMinimumPrice - .groupedWithMeteredMinimumConfig - itemId = newFloatingGroupedWithMeteredMinimumPrice.itemId - modelType = newFloatingGroupedWithMeteredMinimumPrice.modelType - name = newFloatingGroupedWithMeteredMinimumPrice.name - billableMetricId = - newFloatingGroupedWithMeteredMinimumPrice.billableMetricId - billedInAdvance = newFloatingGroupedWithMeteredMinimumPrice.billedInAdvance - billingCycleConfiguration = - newFloatingGroupedWithMeteredMinimumPrice.billingCycleConfiguration - conversionRate = newFloatingGroupedWithMeteredMinimumPrice.conversionRate - externalPriceId = newFloatingGroupedWithMeteredMinimumPrice.externalPriceId - fixedPriceQuantity = - newFloatingGroupedWithMeteredMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = - newFloatingGroupedWithMeteredMinimumPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingGroupedWithMeteredMinimumPrice.invoicingCycleConfiguration - metadata = newFloatingGroupedWithMeteredMinimumPrice.metadata - additionalProperties = - newFloatingGroupedWithMeteredMinimumPrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun groupedWithMeteredMinimumConfig( - groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig - ) = - groupedWithMeteredMinimumConfig( - JsonField.of(groupedWithMeteredMinimumConfig) - ) - - fun groupedWithMeteredMinimumConfig( - groupedWithMeteredMinimumConfig: JsonField - ) = apply { - this.groupedWithMeteredMinimumConfig = groupedWithMeteredMinimumConfig - } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingGroupedWithMeteredMinimumPrice = - NewFloatingGroupedWithMeteredMinimumPrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired( - "groupedWithMeteredMinimumConfig", - groupedWithMeteredMinimumConfig, - ), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class GroupedWithMeteredMinimumConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): GroupedWithMeteredMinimumConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [GroupedWithMeteredMinimumConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig - ) = apply { - additionalProperties = - groupedWithMeteredMinimumConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): GroupedWithMeteredMinimumConfig = - GroupedWithMeteredMinimumConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GroupedWithMeteredMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedWithMeteredMinimumConfig{additionalProperties=$additionalProperties}" - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField - val GROUPED_WITH_METERED_MINIMUM = of("grouped_with_metered_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_WITH_METERED_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GROUPED_WITH_METERED_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GROUPED_WITH_METERED_MINIMUM -> Value.GROUPED_WITH_METERED_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - GROUPED_WITH_METERED_MINIMUM -> Known.GROUPED_WITH_METERED_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingGroupedWithMeteredMinimumPrice && cadence == other.cadence && currency == other.currency && groupedWithMeteredMinimumConfig == other.groupedWithMeteredMinimumConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, groupedWithMeteredMinimumConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingGroupedWithMeteredMinimumPrice{cadence=$cadence, currency=$currency, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingMatrixWithDisplayNamePrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("matrix_with_display_name_config") - @ExcludeMissing - private val matrixWithDisplayNameConfig: JsonField = - JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun matrixWithDisplayNameConfig(): MatrixWithDisplayNameConfig = - matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_config") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("matrix_with_display_name_config") - @ExcludeMissing - fun _matrixWithDisplayNameConfig(): JsonField = - matrixWithDisplayNameConfig - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingMatrixWithDisplayNamePrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - itemId() - matrixWithDisplayNameConfig().validate() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingMatrixWithDisplayNamePrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var matrixWithDisplayNameConfig: - JsonField? = - null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newFloatingMatrixWithDisplayNamePrice: NewFloatingMatrixWithDisplayNamePrice - ) = apply { - cadence = newFloatingMatrixWithDisplayNamePrice.cadence - currency = newFloatingMatrixWithDisplayNamePrice.currency - itemId = newFloatingMatrixWithDisplayNamePrice.itemId - matrixWithDisplayNameConfig = - newFloatingMatrixWithDisplayNamePrice.matrixWithDisplayNameConfig - modelType = newFloatingMatrixWithDisplayNamePrice.modelType - name = newFloatingMatrixWithDisplayNamePrice.name - billableMetricId = newFloatingMatrixWithDisplayNamePrice.billableMetricId - billedInAdvance = newFloatingMatrixWithDisplayNamePrice.billedInAdvance - billingCycleConfiguration = - newFloatingMatrixWithDisplayNamePrice.billingCycleConfiguration - conversionRate = newFloatingMatrixWithDisplayNamePrice.conversionRate - externalPriceId = newFloatingMatrixWithDisplayNamePrice.externalPriceId - fixedPriceQuantity = - newFloatingMatrixWithDisplayNamePrice.fixedPriceQuantity - invoiceGroupingKey = - newFloatingMatrixWithDisplayNamePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingMatrixWithDisplayNamePrice.invoicingCycleConfiguration - metadata = newFloatingMatrixWithDisplayNamePrice.metadata - additionalProperties = - newFloatingMatrixWithDisplayNamePrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun matrixWithDisplayNameConfig( - matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig - ) = matrixWithDisplayNameConfig(JsonField.of(matrixWithDisplayNameConfig)) - - fun matrixWithDisplayNameConfig( - matrixWithDisplayNameConfig: JsonField - ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingMatrixWithDisplayNamePrice = - NewFloatingMatrixWithDisplayNamePrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired( - "matrixWithDisplayNameConfig", - matrixWithDisplayNameConfig, - ), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class MatrixWithDisplayNameConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MatrixWithDisplayNameConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MatrixWithDisplayNameConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig - ) = apply { - additionalProperties = - matrixWithDisplayNameConfig.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) - } - - fun build(): MatrixWithDisplayNameConfig = - MatrixWithDisplayNameConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MatrixWithDisplayNameConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MatrixWithDisplayNameConfig{additionalProperties=$additionalProperties}" - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MATRIX_WITH_DISPLAY_NAME = of("matrix_with_display_name") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MATRIX_WITH_DISPLAY_NAME - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MATRIX_WITH_DISPLAY_NAME, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MATRIX_WITH_DISPLAY_NAME -> Value.MATRIX_WITH_DISPLAY_NAME - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MATRIX_WITH_DISPLAY_NAME -> Known.MATRIX_WITH_DISPLAY_NAME - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingMatrixWithDisplayNamePrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && matrixWithDisplayNameConfig == other.matrixWithDisplayNameConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, matrixWithDisplayNameConfig, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingMatrixWithDisplayNamePrice{cadence=$cadence, currency=$currency, itemId=$itemId, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingBulkWithProrationPrice - @JsonCreator - private constructor( - @JsonProperty("bulk_with_proration_config") - @ExcludeMissing - private val bulkWithProrationConfig: JsonField = - JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun bulkWithProrationConfig(): BulkWithProrationConfig = - bulkWithProrationConfig.getRequired("bulk_with_proration_config") - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - @JsonProperty("bulk_with_proration_config") - @ExcludeMissing - fun _bulkWithProrationConfig(): JsonField = - bulkWithProrationConfig - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingBulkWithProrationPrice = apply { - if (validated) { - return@apply - } - - bulkWithProrationConfig().validate() - cadence() - currency() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingBulkWithProrationPrice]. */ - class Builder internal constructor() { - - private var bulkWithProrationConfig: JsonField? = null - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var 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 externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newFloatingBulkWithProrationPrice: NewFloatingBulkWithProrationPrice - ) = apply { - bulkWithProrationConfig = - newFloatingBulkWithProrationPrice.bulkWithProrationConfig - cadence = newFloatingBulkWithProrationPrice.cadence - currency = newFloatingBulkWithProrationPrice.currency - itemId = newFloatingBulkWithProrationPrice.itemId - modelType = newFloatingBulkWithProrationPrice.modelType - name = newFloatingBulkWithProrationPrice.name - billableMetricId = newFloatingBulkWithProrationPrice.billableMetricId - billedInAdvance = newFloatingBulkWithProrationPrice.billedInAdvance - billingCycleConfiguration = - newFloatingBulkWithProrationPrice.billingCycleConfiguration - conversionRate = newFloatingBulkWithProrationPrice.conversionRate - externalPriceId = newFloatingBulkWithProrationPrice.externalPriceId - fixedPriceQuantity = newFloatingBulkWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingBulkWithProrationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingBulkWithProrationPrice.invoicingCycleConfiguration - metadata = newFloatingBulkWithProrationPrice.metadata - additionalProperties = - newFloatingBulkWithProrationPrice.additionalProperties.toMutableMap() - } - - fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = - bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) - - fun bulkWithProrationConfig( - bulkWithProrationConfig: JsonField - ) = apply { this.bulkWithProrationConfig = bulkWithProrationConfig } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingBulkWithProrationPrice = - NewFloatingBulkWithProrationPrice( - checkRequired("bulkWithProrationConfig", bulkWithProrationConfig), - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BulkWithProrationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BulkWithProrationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkWithProrationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(bulkWithProrationConfig: BulkWithProrationConfig) = - apply { - additionalProperties = - bulkWithProrationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): BulkWithProrationConfig = - BulkWithProrationConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BulkWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkWithProrationConfig{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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val BULK_WITH_PRORATION = of("bulk_with_proration") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK_WITH_PRORATION - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK_WITH_PRORATION, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK_WITH_PRORATION -> Value.BULK_WITH_PRORATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - BULK_WITH_PRORATION -> Known.BULK_WITH_PRORATION - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingBulkWithProrationPrice && bulkWithProrationConfig == other.bulkWithProrationConfig && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bulkWithProrationConfig, cadence, currency, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingBulkWithProrationPrice{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingGroupedTieredPackagePrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("grouped_tiered_package_config") - @ExcludeMissing - private val groupedTieredPackageConfig: JsonField = - JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - fun groupedTieredPackageConfig(): GroupedTieredPackageConfig = - groupedTieredPackageConfig.getRequired("grouped_tiered_package_config") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - @JsonProperty("grouped_tiered_package_config") - @ExcludeMissing - fun _groupedTieredPackageConfig(): JsonField = - groupedTieredPackageConfig - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingGroupedTieredPackagePrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - groupedTieredPackageConfig().validate() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingGroupedTieredPackagePrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var groupedTieredPackageConfig: JsonField? = - null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newFloatingGroupedTieredPackagePrice: NewFloatingGroupedTieredPackagePrice - ) = apply { - cadence = newFloatingGroupedTieredPackagePrice.cadence - currency = newFloatingGroupedTieredPackagePrice.currency - groupedTieredPackageConfig = - newFloatingGroupedTieredPackagePrice.groupedTieredPackageConfig - itemId = newFloatingGroupedTieredPackagePrice.itemId - modelType = newFloatingGroupedTieredPackagePrice.modelType - name = newFloatingGroupedTieredPackagePrice.name - billableMetricId = newFloatingGroupedTieredPackagePrice.billableMetricId - billedInAdvance = newFloatingGroupedTieredPackagePrice.billedInAdvance - billingCycleConfiguration = - newFloatingGroupedTieredPackagePrice.billingCycleConfiguration - conversionRate = newFloatingGroupedTieredPackagePrice.conversionRate - externalPriceId = newFloatingGroupedTieredPackagePrice.externalPriceId - fixedPriceQuantity = newFloatingGroupedTieredPackagePrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingGroupedTieredPackagePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingGroupedTieredPackagePrice.invoicingCycleConfiguration - metadata = newFloatingGroupedTieredPackagePrice.metadata - additionalProperties = - newFloatingGroupedTieredPackagePrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - fun groupedTieredPackageConfig( - groupedTieredPackageConfig: GroupedTieredPackageConfig - ) = groupedTieredPackageConfig(JsonField.of(groupedTieredPackageConfig)) - - fun groupedTieredPackageConfig( - groupedTieredPackageConfig: JsonField - ) = apply { this.groupedTieredPackageConfig = groupedTieredPackageConfig } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingGroupedTieredPackagePrice = - NewFloatingGroupedTieredPackagePrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("groupedTieredPackageConfig", groupedTieredPackageConfig), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class GroupedTieredPackageConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): GroupedTieredPackageConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [GroupedTieredPackageConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(groupedTieredPackageConfig: GroupedTieredPackageConfig) = - apply { - additionalProperties = - groupedTieredPackageConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): GroupedTieredPackageConfig = - GroupedTieredPackageConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GroupedTieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedTieredPackageConfig{additionalProperties=$additionalProperties}" - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val GROUPED_TIERED_PACKAGE = of("grouped_tiered_package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_TIERED_PACKAGE - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GROUPED_TIERED_PACKAGE, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GROUPED_TIERED_PACKAGE -> Value.GROUPED_TIERED_PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - GROUPED_TIERED_PACKAGE -> Known.GROUPED_TIERED_PACKAGE - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingGroupedTieredPackagePrice && cadence == other.cadence && currency == other.currency && groupedTieredPackageConfig == other.groupedTieredPackageConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, groupedTieredPackageConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingGroupedTieredPackagePrice{cadence=$cadence, currency=$currency, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingScalableMatrixWithUnitPricingPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("scalable_matrix_with_unit_pricing_config") - @ExcludeMissing - private val scalableMatrixWithUnitPricingConfig: - JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun scalableMatrixWithUnitPricingConfig(): ScalableMatrixWithUnitPricingConfig = - scalableMatrixWithUnitPricingConfig.getRequired( - "scalable_matrix_with_unit_pricing_config" - ) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("scalable_matrix_with_unit_pricing_config") - @ExcludeMissing - fun _scalableMatrixWithUnitPricingConfig(): - JsonField = - scalableMatrixWithUnitPricingConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingScalableMatrixWithUnitPricingPrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - itemId() - modelType() - name() - scalableMatrixWithUnitPricingConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingScalableMatrixWithUnitPricingPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var scalableMatrixWithUnitPricingConfig: - JsonField? = - null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newFloatingScalableMatrixWithUnitPricingPrice: - NewFloatingScalableMatrixWithUnitPricingPrice - ) = apply { - cadence = newFloatingScalableMatrixWithUnitPricingPrice.cadence - currency = newFloatingScalableMatrixWithUnitPricingPrice.currency - itemId = newFloatingScalableMatrixWithUnitPricingPrice.itemId - modelType = newFloatingScalableMatrixWithUnitPricingPrice.modelType - name = newFloatingScalableMatrixWithUnitPricingPrice.name - scalableMatrixWithUnitPricingConfig = - newFloatingScalableMatrixWithUnitPricingPrice - .scalableMatrixWithUnitPricingConfig - billableMetricId = - newFloatingScalableMatrixWithUnitPricingPrice.billableMetricId - billedInAdvance = - newFloatingScalableMatrixWithUnitPricingPrice.billedInAdvance - billingCycleConfiguration = - newFloatingScalableMatrixWithUnitPricingPrice.billingCycleConfiguration - conversionRate = - newFloatingScalableMatrixWithUnitPricingPrice.conversionRate - externalPriceId = - newFloatingScalableMatrixWithUnitPricingPrice.externalPriceId - fixedPriceQuantity = - newFloatingScalableMatrixWithUnitPricingPrice.fixedPriceQuantity - invoiceGroupingKey = - newFloatingScalableMatrixWithUnitPricingPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingScalableMatrixWithUnitPricingPrice - .invoicingCycleConfiguration - metadata = newFloatingScalableMatrixWithUnitPricingPrice.metadata - additionalProperties = - newFloatingScalableMatrixWithUnitPricingPrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun scalableMatrixWithUnitPricingConfig( - scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig - ) = - scalableMatrixWithUnitPricingConfig( - JsonField.of(scalableMatrixWithUnitPricingConfig) - ) - - fun scalableMatrixWithUnitPricingConfig( - scalableMatrixWithUnitPricingConfig: - JsonField - ) = apply { - this.scalableMatrixWithUnitPricingConfig = - scalableMatrixWithUnitPricingConfig - } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingScalableMatrixWithUnitPricingPrice = - NewFloatingScalableMatrixWithUnitPricingPrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired( - "scalableMatrixWithUnitPricingConfig", - scalableMatrixWithUnitPricingConfig, - ), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField - val SCALABLE_MATRIX_WITH_UNIT_PRICING = - of("scalable_matrix_with_unit_pricing") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - SCALABLE_MATRIX_WITH_UNIT_PRICING - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - SCALABLE_MATRIX_WITH_UNIT_PRICING, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - SCALABLE_MATRIX_WITH_UNIT_PRICING -> - Value.SCALABLE_MATRIX_WITH_UNIT_PRICING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - SCALABLE_MATRIX_WITH_UNIT_PRICING -> - Known.SCALABLE_MATRIX_WITH_UNIT_PRICING - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class ScalableMatrixWithUnitPricingConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): ScalableMatrixWithUnitPricingConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ScalableMatrixWithUnitPricingConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - scalableMatrixWithUnitPricingConfig: ScalableMatrixWithUnitPricingConfig - ) = apply { - additionalProperties = - scalableMatrixWithUnitPricingConfig.additionalProperties - .toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): ScalableMatrixWithUnitPricingConfig = - ScalableMatrixWithUnitPricingConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ScalableMatrixWithUnitPricingConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ScalableMatrixWithUnitPricingConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingScalableMatrixWithUnitPricingPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && scalableMatrixWithUnitPricingConfig == other.scalableMatrixWithUnitPricingConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, scalableMatrixWithUnitPricingConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingScalableMatrixWithUnitPricingPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingScalableMatrixWithTieredPricingPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("scalable_matrix_with_tiered_pricing_config") - @ExcludeMissing - private val scalableMatrixWithTieredPricingConfig: - JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun scalableMatrixWithTieredPricingConfig(): ScalableMatrixWithTieredPricingConfig = - scalableMatrixWithTieredPricingConfig.getRequired( - "scalable_matrix_with_tiered_pricing_config" - ) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("scalable_matrix_with_tiered_pricing_config") - @ExcludeMissing - fun _scalableMatrixWithTieredPricingConfig(): - JsonField = - scalableMatrixWithTieredPricingConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingScalableMatrixWithTieredPricingPrice = apply { - if (validated) { - return@apply - } - - cadence() - currency() - itemId() - modelType() - name() - scalableMatrixWithTieredPricingConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingScalableMatrixWithTieredPricingPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var scalableMatrixWithTieredPricingConfig: - JsonField? = - null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newFloatingScalableMatrixWithTieredPricingPrice: - NewFloatingScalableMatrixWithTieredPricingPrice - ) = apply { - cadence = newFloatingScalableMatrixWithTieredPricingPrice.cadence - currency = newFloatingScalableMatrixWithTieredPricingPrice.currency - itemId = newFloatingScalableMatrixWithTieredPricingPrice.itemId - modelType = newFloatingScalableMatrixWithTieredPricingPrice.modelType - name = newFloatingScalableMatrixWithTieredPricingPrice.name - scalableMatrixWithTieredPricingConfig = - newFloatingScalableMatrixWithTieredPricingPrice - .scalableMatrixWithTieredPricingConfig - billableMetricId = - newFloatingScalableMatrixWithTieredPricingPrice.billableMetricId - billedInAdvance = - newFloatingScalableMatrixWithTieredPricingPrice.billedInAdvance - billingCycleConfiguration = - newFloatingScalableMatrixWithTieredPricingPrice - .billingCycleConfiguration - conversionRate = - newFloatingScalableMatrixWithTieredPricingPrice.conversionRate - externalPriceId = - newFloatingScalableMatrixWithTieredPricingPrice.externalPriceId - fixedPriceQuantity = - newFloatingScalableMatrixWithTieredPricingPrice.fixedPriceQuantity - invoiceGroupingKey = - newFloatingScalableMatrixWithTieredPricingPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingScalableMatrixWithTieredPricingPrice - .invoicingCycleConfiguration - metadata = newFloatingScalableMatrixWithTieredPricingPrice.metadata - additionalProperties = - newFloatingScalableMatrixWithTieredPricingPrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun scalableMatrixWithTieredPricingConfig( - scalableMatrixWithTieredPricingConfig: ScalableMatrixWithTieredPricingConfig - ) = - scalableMatrixWithTieredPricingConfig( - JsonField.of(scalableMatrixWithTieredPricingConfig) - ) - - fun scalableMatrixWithTieredPricingConfig( - scalableMatrixWithTieredPricingConfig: - JsonField - ) = apply { - this.scalableMatrixWithTieredPricingConfig = - scalableMatrixWithTieredPricingConfig - } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingScalableMatrixWithTieredPricingPrice = - NewFloatingScalableMatrixWithTieredPricingPrice( - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired( - "scalableMatrixWithTieredPricingConfig", - scalableMatrixWithTieredPricingConfig, - ), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField - val SCALABLE_MATRIX_WITH_TIERED_PRICING = - of("scalable_matrix_with_tiered_pricing") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - SCALABLE_MATRIX_WITH_TIERED_PRICING - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - SCALABLE_MATRIX_WITH_TIERED_PRICING, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - SCALABLE_MATRIX_WITH_TIERED_PRICING -> - Value.SCALABLE_MATRIX_WITH_TIERED_PRICING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - SCALABLE_MATRIX_WITH_TIERED_PRICING -> - Known.SCALABLE_MATRIX_WITH_TIERED_PRICING - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class ScalableMatrixWithTieredPricingConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): ScalableMatrixWithTieredPricingConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ScalableMatrixWithTieredPricingConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - scalableMatrixWithTieredPricingConfig: - ScalableMatrixWithTieredPricingConfig - ) = apply { - additionalProperties = - scalableMatrixWithTieredPricingConfig.additionalProperties - .toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): ScalableMatrixWithTieredPricingConfig = - ScalableMatrixWithTieredPricingConfig( - additionalProperties.toImmutable() - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ScalableMatrixWithTieredPricingConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ScalableMatrixWithTieredPricingConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingScalableMatrixWithTieredPricingPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && scalableMatrixWithTieredPricingConfig == other.scalableMatrixWithTieredPricingConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, scalableMatrixWithTieredPricingConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingScalableMatrixWithTieredPricingPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewFloatingCumulativeGroupedBulkPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("cumulative_grouped_bulk_config") - @ExcludeMissing - private val cumulativeGroupedBulkConfig: JsonField = - JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - fun cumulativeGroupedBulkConfig(): CumulativeGroupedBulkConfig = - cumulativeGroupedBulkConfig.getRequired("cumulative_grouped_bulk_config") - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(): String = currency.getRequired("currency") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - @JsonProperty("cumulative_grouped_bulk_config") - @ExcludeMissing - fun _cumulativeGroupedBulkConfig(): JsonField = - cumulativeGroupedBulkConfig - - /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewFloatingCumulativeGroupedBulkPrice = apply { - if (validated) { - return@apply - } - - cadence() - cumulativeGroupedBulkConfig().validate() - currency() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewFloatingCumulativeGroupedBulkPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var cumulativeGroupedBulkConfig: - JsonField? = - null - private var currency: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newFloatingCumulativeGroupedBulkPrice: NewFloatingCumulativeGroupedBulkPrice - ) = apply { - cadence = newFloatingCumulativeGroupedBulkPrice.cadence - cumulativeGroupedBulkConfig = - newFloatingCumulativeGroupedBulkPrice.cumulativeGroupedBulkConfig - currency = newFloatingCumulativeGroupedBulkPrice.currency - itemId = newFloatingCumulativeGroupedBulkPrice.itemId - modelType = newFloatingCumulativeGroupedBulkPrice.modelType - name = newFloatingCumulativeGroupedBulkPrice.name - billableMetricId = newFloatingCumulativeGroupedBulkPrice.billableMetricId - billedInAdvance = newFloatingCumulativeGroupedBulkPrice.billedInAdvance - billingCycleConfiguration = - newFloatingCumulativeGroupedBulkPrice.billingCycleConfiguration - conversionRate = newFloatingCumulativeGroupedBulkPrice.conversionRate - externalPriceId = newFloatingCumulativeGroupedBulkPrice.externalPriceId - fixedPriceQuantity = - newFloatingCumulativeGroupedBulkPrice.fixedPriceQuantity - invoiceGroupingKey = - newFloatingCumulativeGroupedBulkPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingCumulativeGroupedBulkPrice.invoicingCycleConfiguration - metadata = newFloatingCumulativeGroupedBulkPrice.metadata - additionalProperties = - newFloatingCumulativeGroupedBulkPrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - fun cumulativeGroupedBulkConfig( - cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig - ) = cumulativeGroupedBulkConfig(JsonField.of(cumulativeGroupedBulkConfig)) - - fun cumulativeGroupedBulkConfig( - cumulativeGroupedBulkConfig: JsonField - ) = apply { this.cumulativeGroupedBulkConfig = cumulativeGroupedBulkConfig } - - /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = currency(JsonField.of(currency)) - - /** An ISO 4217 currency string for which this price is billed in. */ - 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)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) - } - - fun build(): NewFloatingCumulativeGroupedBulkPrice = - NewFloatingCumulativeGroupedBulkPrice( - checkRequired("cadence", cadence), - checkRequired( - "cumulativeGroupedBulkConfig", - cumulativeGroupedBulkConfig, - ), - checkRequired("currency", currency), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class CumulativeGroupedBulkConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): CumulativeGroupedBulkConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CumulativeGroupedBulkConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - cumulativeGroupedBulkConfig: CumulativeGroupedBulkConfig - ) = apply { - additionalProperties = - cumulativeGroupedBulkConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): CumulativeGroupedBulkConfig = - CumulativeGroupedBulkConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CumulativeGroupedBulkConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CumulativeGroupedBulkConfig{additionalProperties=$additionalProperties}" - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val CUMULATIVE_GROUPED_BULK = of("cumulative_grouped_bulk") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - CUMULATIVE_GROUPED_BULK - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - CUMULATIVE_GROUPED_BULK, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - CUMULATIVE_GROUPED_BULK -> Value.CUMULATIVE_GROUPED_BULK - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - CUMULATIVE_GROUPED_BULK -> Known.CUMULATIVE_GROUPED_BULK - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewFloatingCumulativeGroupedBulkPrice && cadence == other.cadence && cumulativeGroupedBulkConfig == other.cumulativeGroupedBulkConfig && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, cumulativeGroupedBulkConfig, currency, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewFloatingCumulativeGroupedBulkPrice{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Add && startDate == other.startDate && allocationPrice == other.allocationPrice && discounts == other.discounts && endDate == other.endDate && externalPriceId == other.externalPriceId && filter == other.filter && fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && maximumAmount == other.maximumAmount && minimumAmount == other.minimumAmount && price == other.price && priceId == other.priceId && usageCustomerIds == other.usageCustomerIds && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(startDate, allocationPrice, discounts, endDate, externalPriceId, filter, fixedFeeQuantityTransitions, maximumAmount, minimumAmount, price, priceId, usageCustomerIds, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Add{startDate=$startDate, allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, price=$price, priceId=$priceId, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class AddAdjustment - @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - private val adjustment: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") - - /** - * The start date of the adjustment interval. This is the date that the adjustment will - * start affecting prices on the subscription. - */ - fun startDate(): StartDate = startDate.getRequired("start_date") - - /** - * The end date of the adjustment interval. This is the date that the adjustment will stop - * affecting prices on the subscription. - */ - fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) - - /** The definition of a new adjustment to create and add to the subscription. */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment - - /** - * The start date of the adjustment interval. This is the date that the adjustment will - * start affecting prices on the subscription. - */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - /** - * The end date of the adjustment interval. This is the date that the adjustment will stop - * affecting prices on the subscription. - */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AddAdjustment = apply { - if (validated) { - return@apply - } - - adjustment().validate() - startDate().validate() - endDate().ifPresent { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AddAdjustment]. */ - class Builder internal constructor() { - - private var adjustment: JsonField? = null - private var startDate: JsonField? = null - private var endDate: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(addAdjustment: AddAdjustment) = apply { - adjustment = addAdjustment.adjustment - startDate = addAdjustment.startDate - endDate = addAdjustment.endDate - additionalProperties = addAdjustment.additionalProperties.toMutableMap() - } - - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) - - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } - - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(newPercentageDiscount: Adjustment.NewPercentageDiscount) = - adjustment(Adjustment.ofNewPercentageDiscount(newPercentageDiscount)) - - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(newUsageDiscount: Adjustment.NewUsageDiscount) = - adjustment(Adjustment.ofNewUsageDiscount(newUsageDiscount)) - - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(newAmountDiscount: Adjustment.NewAmountDiscount) = - adjustment(Adjustment.ofNewAmountDiscount(newAmountDiscount)) - - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(newMinimum: Adjustment.NewMinimum) = - adjustment(Adjustment.ofNewMinimum(newMinimum)) - - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(newMaximum: Adjustment.NewMaximum) = - adjustment(Adjustment.ofNewMaximum(newMaximum)) - - /** - * The start date of the adjustment interval. This is the date that the adjustment will - * start affecting prices on the subscription. - */ - fun startDate(startDate: StartDate) = startDate(JsonField.of(startDate)) - - /** - * The start date of the adjustment interval. This is the date that the adjustment will - * start affecting prices on the subscription. - */ - fun startDate(startDate: JsonField) = apply { this.startDate = startDate } - - /** - * The start date of the adjustment interval. This is the date that the adjustment will - * start affecting prices on the subscription. - */ - fun startDate(dateTime: OffsetDateTime) = startDate(StartDate.ofDateTime(dateTime)) - - /** - * The start date of the adjustment interval. This is the date that the adjustment will - * start affecting prices on the subscription. - */ - fun startDate(billingCycleRelative: BillingCycleRelativeDate) = - startDate(StartDate.ofBillingCycleRelative(billingCycleRelative)) - - /** - * The end date of the adjustment interval. This is the date that the adjustment will - * stop affecting prices on the subscription. - */ - fun endDate(endDate: EndDate?) = endDate(JsonField.ofNullable(endDate)) - - /** - * The end date of the adjustment interval. This is the date that the adjustment will - * stop affecting prices on the subscription. - */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** - * The end date of the adjustment interval. This is the date that the adjustment will - * stop affecting prices on the subscription. - */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** - * The end date of the adjustment interval. This is the date that the adjustment will - * stop affecting prices on the subscription. - */ - fun endDate(dateTime: OffsetDateTime) = endDate(EndDate.ofDateTime(dateTime)) - - /** - * The end date of the adjustment interval. This is the date that the adjustment will - * stop affecting prices on the subscription. - */ - fun endDate(billingCycleRelative: BillingCycleRelativeDate) = - endDate(EndDate.ofBillingCycleRelative(billingCycleRelative)) - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): AddAdjustment = - AddAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("startDate", startDate), - endDate, - additionalProperties.toImmutable(), - ) - } - - /** The definition of a new adjustment to create and add to the subscription. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val newPercentageDiscount: NewPercentageDiscount? = null, - private val newUsageDiscount: NewUsageDiscount? = null, - private val newAmountDiscount: NewAmountDiscount? = null, - private val newMinimum: NewMinimum? = null, - private val newMaximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { - - fun newPercentageDiscount(): Optional = - Optional.ofNullable(newPercentageDiscount) - - fun newUsageDiscount(): Optional = - Optional.ofNullable(newUsageDiscount) - - fun newAmountDiscount(): Optional = - Optional.ofNullable(newAmountDiscount) - - fun newMinimum(): Optional = Optional.ofNullable(newMinimum) - - fun newMaximum(): Optional = Optional.ofNullable(newMaximum) - - fun isNewPercentageDiscount(): Boolean = newPercentageDiscount != null - - fun isNewUsageDiscount(): Boolean = newUsageDiscount != null - - fun isNewAmountDiscount(): Boolean = newAmountDiscount != null - - fun isNewMinimum(): Boolean = newMinimum != null - - fun isNewMaximum(): Boolean = newMaximum != null - - fun asNewPercentageDiscount(): NewPercentageDiscount = - newPercentageDiscount.getOrThrow("newPercentageDiscount") - - fun asNewUsageDiscount(): NewUsageDiscount = - newUsageDiscount.getOrThrow("newUsageDiscount") - - fun asNewAmountDiscount(): NewAmountDiscount = - newAmountDiscount.getOrThrow("newAmountDiscount") - - fun asNewMinimum(): NewMinimum = newMinimum.getOrThrow("newMinimum") - - fun asNewMaximum(): NewMaximum = newMaximum.getOrThrow("newMaximum") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - newPercentageDiscount != null -> - visitor.visitNewPercentageDiscount(newPercentageDiscount) - newUsageDiscount != null -> visitor.visitNewUsageDiscount(newUsageDiscount) - newAmountDiscount != null -> visitor.visitNewAmountDiscount(newAmountDiscount) - newMinimum != null -> visitor.visitNewMinimum(newMinimum) - newMaximum != null -> visitor.visitNewMaximum(newMaximum) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitNewPercentageDiscount( - newPercentageDiscount: NewPercentageDiscount - ) { - newPercentageDiscount.validate() - } - - override fun visitNewUsageDiscount(newUsageDiscount: NewUsageDiscount) { - newUsageDiscount.validate() - } - - override fun visitNewAmountDiscount(newAmountDiscount: NewAmountDiscount) { - newAmountDiscount.validate() - } - - override fun visitNewMinimum(newMinimum: NewMinimum) { - newMinimum.validate() - } - - override fun visitNewMaximum(newMaximum: NewMaximum) { - newMaximum.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Adjustment && newPercentageDiscount == other.newPercentageDiscount && newUsageDiscount == other.newUsageDiscount && newAmountDiscount == other.newAmountDiscount && newMinimum == other.newMinimum && newMaximum == other.newMaximum /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(newPercentageDiscount, newUsageDiscount, newAmountDiscount, newMinimum, newMaximum) /* spotless:on */ - - override fun toString(): String = - when { - newPercentageDiscount != null -> - "Adjustment{newPercentageDiscount=$newPercentageDiscount}" - newUsageDiscount != null -> "Adjustment{newUsageDiscount=$newUsageDiscount}" - newAmountDiscount != null -> "Adjustment{newAmountDiscount=$newAmountDiscount}" - newMinimum != null -> "Adjustment{newMinimum=$newMinimum}" - newMaximum != null -> "Adjustment{newMaximum=$newMaximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } - - companion object { - - @JvmStatic - fun ofNewPercentageDiscount(newPercentageDiscount: NewPercentageDiscount) = - Adjustment(newPercentageDiscount = newPercentageDiscount) - - @JvmStatic - fun ofNewUsageDiscount(newUsageDiscount: NewUsageDiscount) = - Adjustment(newUsageDiscount = newUsageDiscount) - - @JvmStatic - fun ofNewAmountDiscount(newAmountDiscount: NewAmountDiscount) = - Adjustment(newAmountDiscount = newAmountDiscount) - - @JvmStatic - fun ofNewMinimum(newMinimum: NewMinimum) = Adjustment(newMinimum = newMinimum) - - @JvmStatic - fun ofNewMaximum(newMaximum: NewMaximum) = Adjustment(newMaximum = newMaximum) - } - - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { - - fun visitNewPercentageDiscount(newPercentageDiscount: NewPercentageDiscount): T - - fun visitNewUsageDiscount(newUsageDiscount: NewUsageDiscount): T - - fun visitNewAmountDiscount(newAmountDiscount: NewAmountDiscount): T - - fun visitNewMinimum(newMinimum: NewMinimum): T - - fun visitNewMaximum(newMaximum: 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" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(newPercentageDiscount = it, _json = json) - } - } - "usage_discount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(newUsageDiscount = it, _json = json) - } - } - "amount_discount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(newAmountDiscount = it, _json = json) - } - } - "minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Adjustment(newMinimum = it, _json = json) - } - } - "maximum" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Adjustment(newMaximum = it, _json = json) - } - } - } - - return Adjustment(_json = json) - } - } - - internal class Serializer : BaseSerializer(Adjustment::class) { - - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.newPercentageDiscount != null -> - generator.writeObject(value.newPercentageDiscount) - value.newUsageDiscount != null -> - generator.writeObject(value.newUsageDiscount) - value.newAmountDiscount != null -> - generator.writeObject(value.newAmountDiscount) - value.newMinimum != null -> generator.writeObject(value.newMinimum) - value.newMaximum != null -> generator.writeObject(value.newMaximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") - } - } - } - - @NoAutoDetect - class NewPercentageDiscount - @JsonCreator - private constructor( - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("percentage_discount") - @ExcludeMissing - private val percentageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - fun percentageDiscount(): Double = - percentageDiscount.getRequired("percentage_discount") - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(): Optional = - Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The set of price IDs to which this adjustment applies. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - @JsonProperty("percentage_discount") - @ExcludeMissing - fun _percentageDiscount(): JsonField = percentageDiscount - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewPercentageDiscount = apply { - if (validated) { - return@apply - } - - adjustmentType() - appliesToPriceIds() - percentageDiscount() - isInvoiceLevel() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewPercentageDiscount]. */ - class Builder internal constructor() { - - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var percentageDiscount: JsonField? = null - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newPercentageDiscount: NewPercentageDiscount) = apply { - adjustmentType = newPercentageDiscount.adjustmentType - appliesToPriceIds = - newPercentageDiscount.appliesToPriceIds.map { it.toMutableList() } - percentageDiscount = newPercentageDiscount.percentageDiscount - isInvoiceLevel = newPercentageDiscount.isInvoiceLevel - additionalProperties = - newPercentageDiscount.additionalProperties.toMutableMap() - } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The set of price IDs to which this adjustment applies. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - fun percentageDiscount(percentageDiscount: Double) = - percentageDiscount(JsonField.of(percentageDiscount)) - - fun percentageDiscount(percentageDiscount: JsonField) = apply { - this.percentageDiscount = percentageDiscount - } - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): NewPercentageDiscount = - NewPercentageDiscount( - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("percentageDiscount", percentageDiscount), - isInvoiceLevel, - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val PERCENTAGE_DISCOUNT = of("percentage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewPercentageDiscount && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && percentageDiscount == other.percentageDiscount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustmentType, appliesToPriceIds, percentageDiscount, isInvoiceLevel, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewPercentageDiscount{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, percentageDiscount=$percentageDiscount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewUsageDiscount - @JsonCreator - private constructor( - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("usage_discount") - @ExcludeMissing - private val usageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(): Optional = - Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The set of price IDs to which this adjustment applies. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - @JsonProperty("usage_discount") - @ExcludeMissing - fun _usageDiscount(): JsonField = usageDiscount - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewUsageDiscount = apply { - if (validated) { - return@apply - } - - adjustmentType() - appliesToPriceIds() - usageDiscount() - isInvoiceLevel() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewUsageDiscount]. */ - class Builder internal constructor() { - - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var usageDiscount: JsonField? = null - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newUsageDiscount: NewUsageDiscount) = apply { - adjustmentType = newUsageDiscount.adjustmentType - appliesToPriceIds = - newUsageDiscount.appliesToPriceIds.map { it.toMutableList() } - usageDiscount = newUsageDiscount.usageDiscount - isInvoiceLevel = newUsageDiscount.isInvoiceLevel - additionalProperties = newUsageDiscount.additionalProperties.toMutableMap() - } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The set of price IDs to which this adjustment applies. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - fun usageDiscount(usageDiscount: Double) = - usageDiscount(JsonField.of(usageDiscount)) - - fun usageDiscount(usageDiscount: JsonField) = apply { - this.usageDiscount = usageDiscount - } - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): NewUsageDiscount = - NewUsageDiscount( - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("usageDiscount", usageDiscount), - isInvoiceLevel, - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - USAGE_DISCOUNT -> Known.USAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewUsageDiscount && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && usageDiscount == other.usageDiscount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustmentType, appliesToPriceIds, usageDiscount, isInvoiceLevel, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewUsageDiscount{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, usageDiscount=$usageDiscount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewAmountDiscount - @JsonCreator - private constructor( - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("amount_discount") - @ExcludeMissing - private val amountDiscount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(): Optional = - Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - @JsonProperty("amount_discount") - @ExcludeMissing - fun _amountDiscount(): JsonField = amountDiscount - - /** The set of price IDs to which this adjustment applies. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewAmountDiscount = apply { - if (validated) { - return@apply - } - - adjustmentType() - amountDiscount() - appliesToPriceIds() - isInvoiceLevel() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewAmountDiscount]. */ - class Builder internal constructor() { - - private var adjustmentType: JsonField? = null - private var amountDiscount: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newAmountDiscount: NewAmountDiscount) = apply { - adjustmentType = newAmountDiscount.adjustmentType - amountDiscount = newAmountDiscount.amountDiscount - appliesToPriceIds = - newAmountDiscount.appliesToPriceIds.map { it.toMutableList() } - isInvoiceLevel = newAmountDiscount.isInvoiceLevel - additionalProperties = newAmountDiscount.additionalProperties.toMutableMap() - } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - fun amountDiscount(amountDiscount: String) = - amountDiscount(JsonField.of(amountDiscount)) - - fun amountDiscount(amountDiscount: JsonField) = apply { - this.amountDiscount = amountDiscount - } - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The set of price IDs to which this adjustment applies. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): NewAmountDiscount = - NewAmountDiscount( - checkRequired("adjustmentType", adjustmentType), - checkRequired("amountDiscount", amountDiscount), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - isInvoiceLevel, - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewAmountDiscount && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustmentType, amountDiscount, appliesToPriceIds, isInvoiceLevel, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewAmountDiscount{adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewMinimum - @JsonCreator - private constructor( - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(): Optional = - Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The set of price IDs to which this adjustment applies. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The item ID that revenue from this minimum will be attributed to. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewMinimum = apply { - if (validated) { - return@apply - } - - adjustmentType() - appliesToPriceIds() - itemId() - minimumAmount() - isInvoiceLevel() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewMinimum]. */ - class Builder internal constructor() { - - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var itemId: JsonField? = null - private var minimumAmount: JsonField? = null - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newMinimum: NewMinimum) = apply { - adjustmentType = newMinimum.adjustmentType - appliesToPriceIds = newMinimum.appliesToPriceIds.map { it.toMutableList() } - itemId = newMinimum.itemId - minimumAmount = newMinimum.minimumAmount - isInvoiceLevel = newMinimum.isInvoiceLevel - additionalProperties = newMinimum.additionalProperties.toMutableMap() - } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The set of price IDs to which this adjustment applies. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): NewMinimum = - NewMinimum( - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("itemId", itemId), - checkRequired("minimumAmount", minimumAmount), - isInvoiceLevel, - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewMinimum && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && itemId == other.itemId && minimumAmount == other.minimumAmount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustmentType, appliesToPriceIds, itemId, minimumAmount, isInvoiceLevel, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewMinimum{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, itemId=$itemId, minimumAmount=$minimumAmount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewMaximum - @JsonCreator - private constructor( - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(): Optional = - Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The set of price IDs to which this adjustment applies. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewMaximum = apply { - if (validated) { - return@apply - } - - adjustmentType() - appliesToPriceIds() - maximumAmount() - isInvoiceLevel() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewMaximum]. */ - class Builder internal constructor() { - - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newMaximum: NewMaximum) = apply { - adjustmentType = newMaximum.adjustmentType - appliesToPriceIds = newMaximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = newMaximum.maximumAmount - isInvoiceLevel = newMaximum.isInvoiceLevel - additionalProperties = newMaximum.additionalProperties.toMutableMap() - } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The set of price IDs to which this adjustment applies. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** A builder for [AddAdjustment]. */ + class Builder internal constructor() { - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + private var adjustment: JsonField? = null + private var startDate: JsonField? = null + private var endDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JvmSynthetic + internal fun from(addAdjustment: AddAdjustment) = apply { + adjustment = addAdjustment.adjustment + startDate = addAdjustment.startDate + endDate = addAdjustment.endDate + additionalProperties = addAdjustment.additionalProperties.toMutableMap() + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(adjustment: NewAdjustmentModel) = adjustment(JsonField.of(adjustment)) - fun build(): NewMaximum = - NewMaximum( - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("maximumAmount", maximumAmount), - isInvoiceLevel, - additionalProperties.toImmutable(), - ) - } + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment + } - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(percentageDiscount: NewAdjustmentModel.NewPercentageDiscount) = + adjustment(NewAdjustmentModel.ofPercentageDiscount(percentageDiscount)) - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(usageDiscount: NewAdjustmentModel.NewUsageDiscount) = + adjustment(NewAdjustmentModel.ofUsageDiscount(usageDiscount)) - companion object { + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(amountDiscount: NewAdjustmentModel.NewAmountDiscount) = + adjustment(NewAdjustmentModel.ofAmountDiscount(amountDiscount)) - @JvmField val MAXIMUM = of("maximum") + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(minimum: NewAdjustmentModel.NewMinimum) = + adjustment(NewAdjustmentModel.ofMinimum(minimum)) - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(maximum: NewAdjustmentModel.NewMaximum) = + adjustment(NewAdjustmentModel.ofMaximum(maximum)) - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } + /** + * The start date of the adjustment interval. This is the date that the adjustment will + * start affecting prices on the subscription. + */ + fun startDate(startDate: StartDate) = startDate(JsonField.of(startDate)) - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + /** + * The start date of the adjustment interval. This is the date that the adjustment will + * start affecting prices on the subscription. + */ + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } + /** + * The start date of the adjustment interval. This is the date that the adjustment will + * start affecting prices on the subscription. + */ + fun startDate(dateTime: OffsetDateTime) = startDate(StartDate.ofDateTime(dateTime)) - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } + /** + * The start date of the adjustment interval. This is the date that the adjustment will + * start affecting prices on the subscription. + */ + fun startDate(billingCycleRelative: BillingCycleRelativeDate) = + startDate(StartDate.ofBillingCycleRelative(billingCycleRelative)) - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 end date of the adjustment interval. This is the date that the adjustment will + * stop affecting prices on the subscription. + */ + fun endDate(endDate: EndDate?) = endDate(JsonField.ofNullable(endDate)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * The end date of the adjustment interval. This is the date that the adjustment will + * stop affecting prices on the subscription. + */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } + /** + * The end date of the adjustment interval. This is the date that the adjustment will + * stop affecting prices on the subscription. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - override fun hashCode() = value.hashCode() + /** + * The end date of the adjustment interval. This is the date that the adjustment will + * stop affecting prices on the subscription. + */ + fun endDate(dateTime: OffsetDateTime) = endDate(EndDate.ofDateTime(dateTime)) - override fun toString() = value.toString() - } + /** + * The end date of the adjustment interval. This is the date that the adjustment will + * stop affecting prices on the subscription. + */ + fun endDate(billingCycleRelative: BillingCycleRelativeDate) = + endDate(EndDate.ofBillingCycleRelative(billingCycleRelative)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - return /* spotless:off */ other is NewMaximum && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustmentType, appliesToPriceIds, maximumAmount, isInvoiceLevel, additionalProperties) } - /* spotless:on */ + 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() = - "NewMaximum{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + + fun build(): AddAdjustment = + AddAdjustment( + checkRequired("adjustment", adjustment), + checkRequired("startDate", startDate), + endDate, + additionalProperties.toImmutable(), + ) } /** @@ -50874,7 +3317,8 @@ private constructor( private val filter: JsonField = JsonMissing.of(), @JsonProperty("fixed_fee_quantity_transitions") @ExcludeMissing - private val fixedFeeQuantityTransitions: JsonField> = + private val fixedFeeQuantityTransitions: + JsonField> = JsonMissing.of(), @JsonProperty("start_date") @ExcludeMissing @@ -50914,7 +3358,8 @@ private constructor( * A list of fixed fee quantity transitions to use for this price interval. Note that this * list will overwrite all existing fixed fee quantity transitions on the price interval. */ - fun fixedFeeQuantityTransitions(): Optional> = + fun fixedFeeQuantityTransitions(): + Optional> = Optional.ofNullable( fixedFeeQuantityTransitions.getNullable("fixed_fee_quantity_transitions") ) @@ -50969,7 +3414,8 @@ private constructor( */ @JsonProperty("fixed_fee_quantity_transitions") @ExcludeMissing - fun _fixedFeeQuantityTransitions(): JsonField> = + fun _fixedFeeQuantityTransitions(): + JsonField> = fixedFeeQuantityTransitions /** @@ -51016,6 +3462,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Edit]. + * + * The following fields are required: + * ```java + * .priceIntervalId() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -51027,7 +3481,7 @@ private constructor( private var endDate: JsonField = JsonMissing.of() private var filter: JsonField = JsonMissing.of() private var fixedFeeQuantityTransitions: - JsonField>? = + JsonField>? = null private var startDate: JsonField = JsonMissing.of() private var usageCustomerIds: JsonField>? = null @@ -51146,7 +3600,7 @@ private constructor( * interval. */ fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: List? + fixedFeeQuantityTransitions: List? ) = fixedFeeQuantityTransitions(JsonField.ofNullable(fixedFeeQuantityTransitions)) /** @@ -51155,7 +3609,8 @@ private constructor( * interval. */ fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: Optional> + fixedFeeQuantityTransitions: + Optional> ) = fixedFeeQuantityTransitions(fixedFeeQuantityTransitions.orElse(null)) /** @@ -51164,7 +3619,8 @@ private constructor( * interval. */ fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: JsonField> + fixedFeeQuantityTransitions: + JsonField> ) = apply { this.fixedFeeQuantityTransitions = fixedFeeQuantityTransitions.map { it.toMutableList() } @@ -51176,16 +3632,11 @@ private constructor( * interval. */ fun addFixedFeeQuantityTransition( - fixedFeeQuantityTransition: FixedFeeQuantityTransition + fixedFeeQuantityTransition: PriceIntervalFixedFeeQuantityTransitionModel ) = apply { fixedFeeQuantityTransitions = - (fixedFeeQuantityTransitions ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } + (fixedFeeQuantityTransitions ?: JsonField.of(mutableListOf())).also { + checkKnown("fixedFeeQuantityTransitions", it) .add(fixedFeeQuantityTransition) } } @@ -51259,14 +3710,8 @@ private constructor( */ fun addUsageCustomerId(usageCustomerId: String) = apply { usageCustomerIds = - (usageCustomerIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(usageCustomerId) + (usageCustomerIds ?: JsonField.of(mutableListOf())).also { + checkKnown("usageCustomerIds", it).add(usageCustomerId) } } @@ -51446,135 +3891,6 @@ private constructor( } } - @NoAutoDetect - class FixedFeeQuantityTransition - @JsonCreator - private constructor( - @JsonProperty("effective_date") - @ExcludeMissing - private val effectiveDate: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - private val quantity: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The date that the fixed fee quantity transition should take effect. */ - fun effectiveDate(): OffsetDateTime = effectiveDate.getRequired("effective_date") - - /** The quantity of the fixed fee quantity transition. */ - fun quantity(): Long = quantity.getRequired("quantity") - - /** The date that the fixed fee quantity transition should take effect. */ - @JsonProperty("effective_date") - @ExcludeMissing - fun _effectiveDate(): JsonField = effectiveDate - - /** The quantity of the fixed fee quantity transition. */ - @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): FixedFeeQuantityTransition = apply { - if (validated) { - return@apply - } - - effectiveDate() - quantity() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FixedFeeQuantityTransition]. */ - class Builder internal constructor() { - - private var effectiveDate: JsonField? = null - private var quantity: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(fixedFeeQuantityTransition: FixedFeeQuantityTransition) = apply { - effectiveDate = fixedFeeQuantityTransition.effectiveDate - quantity = fixedFeeQuantityTransition.quantity - additionalProperties = - fixedFeeQuantityTransition.additionalProperties.toMutableMap() - } - - /** The date that the fixed fee quantity transition should take effect. */ - fun effectiveDate(effectiveDate: OffsetDateTime) = - effectiveDate(JsonField.of(effectiveDate)) - - /** The date that the fixed fee quantity transition should take effect. */ - fun effectiveDate(effectiveDate: JsonField) = apply { - this.effectiveDate = effectiveDate - } - - /** The quantity of the fixed fee quantity transition. */ - fun quantity(quantity: Long) = quantity(JsonField.of(quantity)) - - /** The quantity of the fixed fee quantity transition. */ - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): FixedFeeQuantityTransition = - FixedFeeQuantityTransition( - checkRequired("effectiveDate", effectiveDate), - checkRequired("quantity", quantity), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FixedFeeQuantityTransition && effectiveDate == other.effectiveDate && quantity == other.quantity && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(effectiveDate, quantity, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "FixedFeeQuantityTransition{effectiveDate=$effectiveDate, quantity=$quantity, additionalProperties=$additionalProperties}" - } - /** * The updated start date of this price interval. If not specified, the start date will not * be updated. @@ -51811,6 +4127,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [EditAdjustment]. + * + * The following fields are required: + * ```java + * .adjustmentIntervalId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsResponse.kt deleted file mode 100644 index 836dbef24..000000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsResponse.kt +++ /dev/null @@ -1,7172 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer -import com.withorb.api.core.Enum -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow -import com.withorb.api.core.immutableEmptyMap -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -@NoAutoDetect -class SubscriptionPriceIntervalsResponse -@JsonCreator -private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("active_plan_phase_order") - @ExcludeMissing - private val activePlanPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_intervals") - @ExcludeMissing - private val adjustmentIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("auto_collection") - @ExcludeMissing - private val autoCollection: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_anchor_configuration") - @ExcludeMissing - private val billingCycleAnchorConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("billing_cycle_day") - @ExcludeMissing - private val billingCycleDay: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - private val currentBillingPeriodEndDate: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - private val currentBillingPeriodStartDate: JsonField = JsonMissing.of(), - @JsonProperty("customer") - @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), - @JsonProperty("default_invoice_memo") - @ExcludeMissing - private val defaultInvoiceMemo: JsonField = JsonMissing.of(), - @JsonProperty("discount_intervals") - @ExcludeMissing - private val discountIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("fixed_fee_quantity_schedule") - @ExcludeMissing - private val fixedFeeQuantitySchedule: JsonField> = - JsonMissing.of(), - @JsonProperty("invoicing_threshold") - @ExcludeMissing - private val invoicingThreshold: JsonField = JsonMissing.of(), - @JsonProperty("maximum_intervals") - @ExcludeMissing - private val maximumIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("minimum_intervals") - @ExcludeMissing - private val minimumIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("net_terms") - @ExcludeMissing - private val netTerms: JsonField = JsonMissing.of(), - @JsonProperty("plan") @ExcludeMissing private val plan: JsonField = JsonMissing.of(), - @JsonProperty("price_intervals") - @ExcludeMissing - private val priceIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("redeemed_coupon") - @ExcludeMissing - private val redeemedCoupon: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonProperty("status") - @ExcludeMissing - private val status: JsonField = JsonMissing.of(), - @JsonProperty("trial_info") - @ExcludeMissing - private val trialInfo: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun id(): String = id.getRequired("id") - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(): Optional = - Optional.ofNullable(activePlanPhaseOrder.getNullable("active_plan_phase_order")) - - /** The adjustment intervals for this subscription. */ - fun adjustmentIntervals(): List = - adjustmentIntervals.getRequired("adjustment_intervals") - - /** - * Determines whether issued invoices for this subscription will automatically be charged with - * the saved payment method on the due date. This property defaults to the plan's behavior. If - * null, defaults to the customer's setting. - */ - fun autoCollection(): Optional = - Optional.ofNullable(autoCollection.getNullable("auto_collection")) - - fun billingCycleAnchorConfiguration(): BillingCycleAnchorConfiguration = - billingCycleAnchorConfiguration.getRequired("billing_cycle_anchor_configuration") - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of days in - * a month is greater than this value, the last day of the month is the billing cycle day (e.g. - * billing_cycle_day=31 for April means the billing period begins on the 30th. - */ - fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the instant - * returned is not part of the billing period. Set to null for subscriptions that are not - * currently active. - */ - fun currentBillingPeriodEndDate(): Optional = - Optional.ofNullable( - currentBillingPeriodEndDate.getNullable("current_billing_period_end_date") - ) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription is - * not currently active. - */ - fun currentBillingPeriodStartDate(): Optional = - Optional.ofNullable( - currentBillingPeriodStartDate.getNullable("current_billing_period_start_date") - ) - - /** - * 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 customer(): Customer = customer.getRequired("customer") - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(): Optional = - Optional.ofNullable(defaultInvoiceMemo.getNullable("default_invoice_memo")) - - /** The discount intervals for this subscription. */ - fun discountIntervals(): List = - discountIntervals.getRequired("discount_intervals") - - /** The date Orb stops billing for this subscription. */ - fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) - - fun fixedFeeQuantitySchedule(): List = - fixedFeeQuantitySchedule.getRequired("fixed_fee_quantity_schedule") - - fun invoicingThreshold(): Optional = - Optional.ofNullable(invoicingThreshold.getNullable("invoicing_threshold")) - - /** The maximum intervals for this subscription. */ - fun maximumIntervals(): List = - maximumIntervals.getRequired("maximum_intervals") - - /** - * 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.getRequired("metadata") - - /** The minimum intervals for this subscription. */ - fun minimumIntervals(): List = - minimumIntervals.getRequired("minimum_intervals") - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - fun netTerms(): Long = netTerms.getRequired("net_terms") - - /** - * 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 plan(): Plan = plan.getRequired("plan") - - /** The price intervals for this subscription. */ - fun priceIntervals(): List = priceIntervals.getRequired("price_intervals") - - fun redeemedCoupon(): Optional = - Optional.ofNullable(redeemedCoupon.getNullable("redeemed_coupon")) - - /** The date Orb starts billing for this subscription. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - fun status(): Status = status.getRequired("status") - - fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - @JsonProperty("active_plan_phase_order") - @ExcludeMissing - fun _activePlanPhaseOrder(): JsonField = activePlanPhaseOrder - - /** The adjustment intervals for this subscription. */ - @JsonProperty("adjustment_intervals") - @ExcludeMissing - fun _adjustmentIntervals(): JsonField> = adjustmentIntervals - - /** - * Determines whether issued invoices for this subscription will automatically be charged with - * the saved payment method on the due date. This property defaults to the plan's behavior. If - * null, defaults to the customer's setting. - */ - @JsonProperty("auto_collection") - @ExcludeMissing - fun _autoCollection(): JsonField = autoCollection - - @JsonProperty("billing_cycle_anchor_configuration") - @ExcludeMissing - fun _billingCycleAnchorConfiguration(): JsonField = - billingCycleAnchorConfiguration - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of days in - * a month is greater than this value, the last day of the month is the billing cycle day (e.g. - * billing_cycle_day=31 for April means the billing period begins on the 30th. - */ - @JsonProperty("billing_cycle_day") - @ExcludeMissing - fun _billingCycleDay(): JsonField = billingCycleDay - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the instant - * returned is not part of the billing period. Set to null for subscriptions that are not - * currently active. - */ - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription is - * not currently active. - */ - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - fun _currentBillingPeriodStartDate(): JsonField = currentBillingPeriodStartDate - - /** - * 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. - */ - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - @JsonProperty("default_invoice_memo") - @ExcludeMissing - fun _defaultInvoiceMemo(): JsonField = defaultInvoiceMemo - - /** The discount intervals for this subscription. */ - @JsonProperty("discount_intervals") - @ExcludeMissing - fun _discountIntervals(): JsonField> = discountIntervals - - /** The date Orb stops billing for this subscription. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate - - @JsonProperty("fixed_fee_quantity_schedule") - @ExcludeMissing - fun _fixedFeeQuantitySchedule(): JsonField> = - fixedFeeQuantitySchedule - - @JsonProperty("invoicing_threshold") - @ExcludeMissing - fun _invoicingThreshold(): JsonField = invoicingThreshold - - /** The maximum intervals for this subscription. */ - @JsonProperty("maximum_intervals") - @ExcludeMissing - fun _maximumIntervals(): JsonField> = maximumIntervals - - /** - * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - /** The minimum intervals for this subscription. */ - @JsonProperty("minimum_intervals") - @ExcludeMissing - fun _minimumIntervals(): JsonField> = minimumIntervals - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms - - /** - * 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). - */ - @JsonProperty("plan") @ExcludeMissing fun _plan(): JsonField = plan - - /** The price intervals for this subscription. */ - @JsonProperty("price_intervals") - @ExcludeMissing - fun _priceIntervals(): JsonField> = priceIntervals - - @JsonProperty("redeemed_coupon") - @ExcludeMissing - fun _redeemedCoupon(): JsonField = redeemedCoupon - - /** The date Orb starts billing for this subscription. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo(): JsonField = trialInfo - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): SubscriptionPriceIntervalsResponse = apply { - if (validated) { - return@apply - } - - id() - activePlanPhaseOrder() - adjustmentIntervals().forEach { it.validate() } - autoCollection() - billingCycleAnchorConfiguration().validate() - billingCycleDay() - createdAt() - currentBillingPeriodEndDate() - currentBillingPeriodStartDate() - customer().validate() - defaultInvoiceMemo() - discountIntervals().forEach { it.validate() } - endDate() - fixedFeeQuantitySchedule().forEach { it.validate() } - invoicingThreshold() - maximumIntervals().forEach { it.validate() } - metadata().validate() - minimumIntervals().forEach { it.validate() } - netTerms() - plan().validate() - priceIntervals().forEach { it.validate() } - redeemedCoupon().ifPresent { it.validate() } - startDate() - status() - trialInfo().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SubscriptionPriceIntervalsResponse]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var activePlanPhaseOrder: JsonField? = null - private var adjustmentIntervals: JsonField>? = null - private var autoCollection: JsonField? = null - private var billingCycleAnchorConfiguration: JsonField? = - null - private var billingCycleDay: JsonField? = null - private var createdAt: JsonField? = null - private var currentBillingPeriodEndDate: JsonField? = null - private var currentBillingPeriodStartDate: JsonField? = null - private var customer: JsonField? = null - private var defaultInvoiceMemo: JsonField? = null - private var discountIntervals: JsonField>? = null - private var endDate: JsonField? = null - private var fixedFeeQuantitySchedule: JsonField>? = - null - private var invoicingThreshold: JsonField? = null - private var maximumIntervals: JsonField>? = null - private var metadata: JsonField? = null - private var minimumIntervals: JsonField>? = null - private var netTerms: JsonField? = null - private var plan: JsonField? = null - private var priceIntervals: JsonField>? = null - private var redeemedCoupon: JsonField? = null - private var startDate: JsonField? = null - private var status: JsonField? = null - private var trialInfo: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(subscriptionPriceIntervalsResponse: SubscriptionPriceIntervalsResponse) = - apply { - id = subscriptionPriceIntervalsResponse.id - activePlanPhaseOrder = subscriptionPriceIntervalsResponse.activePlanPhaseOrder - adjustmentIntervals = - subscriptionPriceIntervalsResponse.adjustmentIntervals.map { - it.toMutableList() - } - autoCollection = subscriptionPriceIntervalsResponse.autoCollection - billingCycleAnchorConfiguration = - subscriptionPriceIntervalsResponse.billingCycleAnchorConfiguration - billingCycleDay = subscriptionPriceIntervalsResponse.billingCycleDay - createdAt = subscriptionPriceIntervalsResponse.createdAt - currentBillingPeriodEndDate = - subscriptionPriceIntervalsResponse.currentBillingPeriodEndDate - currentBillingPeriodStartDate = - subscriptionPriceIntervalsResponse.currentBillingPeriodStartDate - customer = subscriptionPriceIntervalsResponse.customer - defaultInvoiceMemo = subscriptionPriceIntervalsResponse.defaultInvoiceMemo - discountIntervals = - subscriptionPriceIntervalsResponse.discountIntervals.map { it.toMutableList() } - endDate = subscriptionPriceIntervalsResponse.endDate - fixedFeeQuantitySchedule = - subscriptionPriceIntervalsResponse.fixedFeeQuantitySchedule.map { - it.toMutableList() - } - invoicingThreshold = subscriptionPriceIntervalsResponse.invoicingThreshold - maximumIntervals = - subscriptionPriceIntervalsResponse.maximumIntervals.map { it.toMutableList() } - metadata = subscriptionPriceIntervalsResponse.metadata - minimumIntervals = - subscriptionPriceIntervalsResponse.minimumIntervals.map { it.toMutableList() } - netTerms = subscriptionPriceIntervalsResponse.netTerms - plan = subscriptionPriceIntervalsResponse.plan - priceIntervals = - subscriptionPriceIntervalsResponse.priceIntervals.map { it.toMutableList() } - redeemedCoupon = subscriptionPriceIntervalsResponse.redeemedCoupon - startDate = subscriptionPriceIntervalsResponse.startDate - status = subscriptionPriceIntervalsResponse.status - trialInfo = subscriptionPriceIntervalsResponse.trialInfo - additionalProperties = - subscriptionPriceIntervalsResponse.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(activePlanPhaseOrder: Long?) = - activePlanPhaseOrder(JsonField.ofNullable(activePlanPhaseOrder)) - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(activePlanPhaseOrder: Long) = - activePlanPhaseOrder(activePlanPhaseOrder as Long?) - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun activePlanPhaseOrder(activePlanPhaseOrder: Optional) = - activePlanPhaseOrder(activePlanPhaseOrder.orElse(null) as Long?) - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(activePlanPhaseOrder: JsonField) = apply { - this.activePlanPhaseOrder = activePlanPhaseOrder - } - - /** The adjustment intervals for this subscription. */ - fun adjustmentIntervals(adjustmentIntervals: List) = - adjustmentIntervals(JsonField.of(adjustmentIntervals)) - - /** The adjustment intervals for this subscription. */ - fun adjustmentIntervals(adjustmentIntervals: JsonField>) = apply { - this.adjustmentIntervals = adjustmentIntervals.map { it.toMutableList() } - } - - /** The adjustment intervals for this subscription. */ - fun addAdjustmentInterval(adjustmentInterval: AdjustmentInterval) = apply { - adjustmentIntervals = - (adjustmentIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(adjustmentInterval) - } - } - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - fun autoCollection(autoCollection: Boolean?) = - autoCollection(JsonField.ofNullable(autoCollection)) - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun autoCollection(autoCollection: Optional) = - autoCollection(autoCollection.orElse(null) as Boolean?) - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - fun autoCollection(autoCollection: JsonField) = apply { - this.autoCollection = autoCollection - } - - fun billingCycleAnchorConfiguration( - billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration - ) = billingCycleAnchorConfiguration(JsonField.of(billingCycleAnchorConfiguration)) - - fun billingCycleAnchorConfiguration( - billingCycleAnchorConfiguration: JsonField - ) = apply { this.billingCycleAnchorConfiguration = billingCycleAnchorConfiguration } - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun billingCycleDay(billingCycleDay: Long) = billingCycleDay(JsonField.of(billingCycleDay)) - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun billingCycleDay(billingCycleDay: JsonField) = apply { - this.billingCycleDay = billingCycleDay - } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is not part of the billing period. Set to null for subscriptions that - * are not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = - currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is not part of the billing period. Set to null for subscriptions that - * are not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = - currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is not part of the billing period. Set to null for subscriptions that - * are not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: JsonField) = - apply { - this.currentBillingPeriodEndDate = currentBillingPeriodEndDate - } - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription - * is not currently active. - */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = - currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription - * is not currently active. - */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: Optional) = - currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription - * is not currently active. - */ - fun currentBillingPeriodStartDate( - currentBillingPeriodStartDate: JsonField - ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } - - /** - * 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 customer(customer: Customer) = customer(JsonField.of(customer)) - - /** - * 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 customer(customer: JsonField) = apply { this.customer = customer } - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(defaultInvoiceMemo: String?) = - defaultInvoiceMemo(JsonField.ofNullable(defaultInvoiceMemo)) - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(defaultInvoiceMemo: Optional) = - defaultInvoiceMemo(defaultInvoiceMemo.orElse(null)) - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(defaultInvoiceMemo: JsonField) = apply { - this.defaultInvoiceMemo = defaultInvoiceMemo - } - - /** The discount intervals for this subscription. */ - fun discountIntervals(discountIntervals: List) = - discountIntervals(JsonField.of(discountIntervals)) - - /** The discount intervals for this subscription. */ - fun discountIntervals(discountIntervals: JsonField>) = apply { - this.discountIntervals = discountIntervals.map { it.toMutableList() } - } - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(discountInterval: DiscountInterval) = apply { - discountIntervals = - (discountIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(discountInterval) - } - } - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(amount: DiscountInterval.AmountDiscountInterval) = - addDiscountInterval(DiscountInterval.ofAmount(amount)) - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(percentage: DiscountInterval.PercentageDiscountInterval) = - addDiscountInterval(DiscountInterval.ofPercentage(percentage)) - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(usage: DiscountInterval.UsageDiscountInterval) = - addDiscountInterval(DiscountInterval.ofUsage(usage)) - - /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - fun fixedFeeQuantitySchedule(fixedFeeQuantitySchedule: List) = - fixedFeeQuantitySchedule(JsonField.of(fixedFeeQuantitySchedule)) - - fun fixedFeeQuantitySchedule( - fixedFeeQuantitySchedule: JsonField> - ) = apply { - this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule.map { it.toMutableList() } - } - - fun addFixedFeeQuantitySchedule(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = - apply { - this.fixedFeeQuantitySchedule = - (this.fixedFeeQuantitySchedule ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(fixedFeeQuantitySchedule) - } - } - - fun invoicingThreshold(invoicingThreshold: String?) = - invoicingThreshold(JsonField.ofNullable(invoicingThreshold)) - - fun invoicingThreshold(invoicingThreshold: Optional) = - invoicingThreshold(invoicingThreshold.orElse(null)) - - fun invoicingThreshold(invoicingThreshold: JsonField) = apply { - this.invoicingThreshold = invoicingThreshold - } - - /** The maximum intervals for this subscription. */ - fun maximumIntervals(maximumIntervals: List) = - maximumIntervals(JsonField.of(maximumIntervals)) - - /** The maximum intervals for this subscription. */ - fun maximumIntervals(maximumIntervals: JsonField>) = apply { - this.maximumIntervals = maximumIntervals.map { it.toMutableList() } - } - - /** The maximum intervals for this subscription. */ - fun addMaximumInterval(maximumInterval: MaximumInterval) = apply { - maximumIntervals = - (maximumIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(maximumInterval) - } - } - - /** - * 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - /** The minimum intervals for this subscription. */ - fun minimumIntervals(minimumIntervals: List) = - minimumIntervals(JsonField.of(minimumIntervals)) - - /** The minimum intervals for this subscription. */ - fun minimumIntervals(minimumIntervals: JsonField>) = apply { - this.minimumIntervals = minimumIntervals.map { it.toMutableList() } - } - - /** The minimum intervals for this subscription. */ - fun addMinimumInterval(minimumInterval: MinimumInterval) = apply { - minimumIntervals = - (minimumIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(minimumInterval) - } - } - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - fun netTerms(netTerms: Long) = netTerms(JsonField.of(netTerms)) - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } - - /** - * 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 plan(plan: Plan) = plan(JsonField.of(plan)) - - /** - * 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 plan(plan: JsonField) = apply { this.plan = plan } - - /** The price intervals for this subscription. */ - fun priceIntervals(priceIntervals: List) = - priceIntervals(JsonField.of(priceIntervals)) - - /** The price intervals for this subscription. */ - fun priceIntervals(priceIntervals: JsonField>) = apply { - this.priceIntervals = priceIntervals.map { it.toMutableList() } - } - - /** The price intervals for this subscription. */ - fun addPriceInterval(priceInterval: PriceInterval) = apply { - priceIntervals = - (priceIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(priceInterval) - } - } - - fun redeemedCoupon(redeemedCoupon: RedeemedCoupon?) = - redeemedCoupon(JsonField.ofNullable(redeemedCoupon)) - - fun redeemedCoupon(redeemedCoupon: Optional) = - redeemedCoupon(redeemedCoupon.orElse(null)) - - fun redeemedCoupon(redeemedCoupon: JsonField) = apply { - this.redeemedCoupon = redeemedCoupon - } - - /** The date Orb starts billing for this subscription. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The date Orb starts billing for this subscription. */ - fun startDate(startDate: JsonField) = apply { this.startDate = startDate } - - fun status(status: Status) = status(JsonField.of(status)) - - fun status(status: JsonField) = apply { this.status = status } - - fun trialInfo(trialInfo: TrialInfo) = trialInfo(JsonField.of(trialInfo)) - - fun trialInfo(trialInfo: JsonField) = apply { this.trialInfo = trialInfo } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): SubscriptionPriceIntervalsResponse = - SubscriptionPriceIntervalsResponse( - checkRequired("id", id), - checkRequired("activePlanPhaseOrder", activePlanPhaseOrder), - checkRequired("adjustmentIntervals", adjustmentIntervals).map { it.toImmutable() }, - checkRequired("autoCollection", autoCollection), - checkRequired("billingCycleAnchorConfiguration", billingCycleAnchorConfiguration), - checkRequired("billingCycleDay", billingCycleDay), - checkRequired("createdAt", createdAt), - checkRequired("currentBillingPeriodEndDate", currentBillingPeriodEndDate), - checkRequired("currentBillingPeriodStartDate", currentBillingPeriodStartDate), - checkRequired("customer", customer), - checkRequired("defaultInvoiceMemo", defaultInvoiceMemo), - checkRequired("discountIntervals", discountIntervals).map { it.toImmutable() }, - checkRequired("endDate", endDate), - checkRequired("fixedFeeQuantitySchedule", fixedFeeQuantitySchedule).map { - it.toImmutable() - }, - checkRequired("invoicingThreshold", invoicingThreshold), - checkRequired("maximumIntervals", maximumIntervals).map { it.toImmutable() }, - checkRequired("metadata", metadata), - checkRequired("minimumIntervals", minimumIntervals).map { it.toImmutable() }, - checkRequired("netTerms", netTerms), - checkRequired("plan", plan), - checkRequired("priceIntervals", priceIntervals).map { it.toImmutable() }, - checkRequired("redeemedCoupon", redeemedCoupon), - checkRequired("startDate", startDate), - checkRequired("status", status), - checkRequired("trialInfo", trialInfo), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class AdjustmentInterval - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment") - @ExcludeMissing - private val adjustment: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") - - /** The price interval IDs that this adjustment applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - /** The end date of the adjustment interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** The start date of the adjustment interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment - - /** The price interval IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - /** The end date of the adjustment interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** The start date of the adjustment interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AdjustmentInterval = apply { - if (validated) { - return@apply - } - - id() - adjustment().validate() - appliesToPriceIntervalIds() - endDate() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AdjustmentInterval]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustment: JsonField? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(adjustmentInterval: AdjustmentInterval) = apply { - id = adjustmentInterval.id - adjustment = adjustmentInterval.adjustment - appliesToPriceIntervalIds = - adjustmentInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - endDate = adjustmentInterval.endDate - startDate = adjustmentInterval.startDate - additionalProperties = adjustmentInterval.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) - - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } - - fun adjustment(planPhaseUsageDiscount: Adjustment.PlanPhaseUsageDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)) - - fun adjustment(planPhaseAmountDiscount: Adjustment.PlanPhaseAmountDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)) - - fun adjustment( - planPhasePercentageDiscount: Adjustment.PlanPhasePercentageDiscountAdjustment - ) = adjustment(Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)) - - fun adjustment(planPhaseMinimum: Adjustment.PlanPhaseMinimumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)) - - fun adjustment(planPhaseMaximum: Adjustment.PlanPhaseMaximumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)) - - /** The price interval IDs that this adjustment applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval IDs that this adjustment applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval IDs that this adjustment applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - /** The end date of the adjustment interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the adjustment interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the adjustment interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** The start date of the adjustment interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the adjustment interval. */ - 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) - } - - fun build(): AdjustmentInterval = - AdjustmentInterval( - checkRequired("id", id), - checkRequired("adjustment", adjustment), - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment? = null, - private val planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment? = null, - private val planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment? = null, - private val planPhaseMinimum: PlanPhaseMinimumAdjustment? = null, - private val planPhaseMaximum: PlanPhaseMaximumAdjustment? = null, - private val _json: JsonValue? = null, - ) { - - fun planPhaseUsageDiscount(): Optional = - Optional.ofNullable(planPhaseUsageDiscount) - - fun planPhaseAmountDiscount(): Optional = - Optional.ofNullable(planPhaseAmountDiscount) - - fun planPhasePercentageDiscount(): Optional = - Optional.ofNullable(planPhasePercentageDiscount) - - fun planPhaseMinimum(): Optional = - Optional.ofNullable(planPhaseMinimum) - - fun planPhaseMaximum(): Optional = - Optional.ofNullable(planPhaseMaximum) - - fun isPlanPhaseUsageDiscount(): Boolean = planPhaseUsageDiscount != null - - fun isPlanPhaseAmountDiscount(): Boolean = planPhaseAmountDiscount != null - - fun isPlanPhasePercentageDiscount(): Boolean = planPhasePercentageDiscount != null - - fun isPlanPhaseMinimum(): Boolean = planPhaseMinimum != null - - fun isPlanPhaseMaximum(): Boolean = planPhaseMaximum != null - - fun asPlanPhaseUsageDiscount(): PlanPhaseUsageDiscountAdjustment = - planPhaseUsageDiscount.getOrThrow("planPhaseUsageDiscount") - - fun asPlanPhaseAmountDiscount(): PlanPhaseAmountDiscountAdjustment = - planPhaseAmountDiscount.getOrThrow("planPhaseAmountDiscount") - - fun asPlanPhasePercentageDiscount(): PlanPhasePercentageDiscountAdjustment = - planPhasePercentageDiscount.getOrThrow("planPhasePercentageDiscount") - - fun asPlanPhaseMinimum(): PlanPhaseMinimumAdjustment = - planPhaseMinimum.getOrThrow("planPhaseMinimum") - - fun asPlanPhaseMaximum(): PlanPhaseMaximumAdjustment = - planPhaseMaximum.getOrThrow("planPhaseMaximum") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - planPhaseUsageDiscount != null -> - visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) - planPhaseAmountDiscount != null -> - visitor.visitPlanPhaseAmountDiscount(planPhaseAmountDiscount) - planPhasePercentageDiscount != null -> - visitor.visitPlanPhasePercentageDiscount(planPhasePercentageDiscount) - planPhaseMinimum != null -> visitor.visitPlanPhaseMinimum(planPhaseMinimum) - planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) { - planPhaseUsageDiscount.validate() - } - - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) { - planPhaseAmountDiscount.validate() - } - - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) { - planPhasePercentageDiscount.validate() - } - - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) { - planPhaseMinimum.validate() - } - - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) { - planPhaseMaximum.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Adjustment && planPhaseUsageDiscount == other.planPhaseUsageDiscount && planPhaseAmountDiscount == other.planPhaseAmountDiscount && planPhasePercentageDiscount == other.planPhasePercentageDiscount && planPhaseMinimum == other.planPhaseMinimum && planPhaseMaximum == other.planPhaseMaximum /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(planPhaseUsageDiscount, planPhaseAmountDiscount, planPhasePercentageDiscount, planPhaseMinimum, planPhaseMaximum) /* spotless:on */ - - override fun toString(): String = - when { - planPhaseUsageDiscount != null -> - "Adjustment{planPhaseUsageDiscount=$planPhaseUsageDiscount}" - planPhaseAmountDiscount != null -> - "Adjustment{planPhaseAmountDiscount=$planPhaseAmountDiscount}" - planPhasePercentageDiscount != null -> - "Adjustment{planPhasePercentageDiscount=$planPhasePercentageDiscount}" - planPhaseMinimum != null -> "Adjustment{planPhaseMinimum=$planPhaseMinimum}" - planPhaseMaximum != null -> "Adjustment{planPhaseMaximum=$planPhaseMaximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } - - companion object { - - @JvmStatic - fun ofPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = Adjustment(planPhaseUsageDiscount = planPhaseUsageDiscount) - - @JvmStatic - fun ofPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = Adjustment(planPhaseAmountDiscount = planPhaseAmountDiscount) - - @JvmStatic - fun ofPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = Adjustment(planPhasePercentageDiscount = planPhasePercentageDiscount) - - @JvmStatic - fun ofPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment) = - Adjustment(planPhaseMinimum = planPhaseMinimum) - - @JvmStatic - fun ofPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment) = - Adjustment(planPhaseMaximum = planPhaseMaximum) - } - - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { - - fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ): T - - fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ): T - - fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ): T - - fun visitPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment): T - - fun visitPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment): T - - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } - - internal class Deserializer : BaseDeserializer(Adjustment::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = - json.asObject().getOrNull()?.get("adjustment_type")?.asString()?.getOrNull() - - when (adjustmentType) { - "usage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseUsageDiscount = it, _json = json) - } - } - "amount_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseAmountDiscount = it, _json = json) - } - } - "percentage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment( - planPhasePercentageDiscount = it, - _json = json, - ) - } - } - "minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMinimum = it, _json = json) - } - } - "maximum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMaximum = it, _json = json) - } - } - } - - return Adjustment(_json = json) - } - } - - internal class Serializer : BaseSerializer(Adjustment::class) { - - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.planPhaseUsageDiscount != null -> - generator.writeObject(value.planPhaseUsageDiscount) - value.planPhaseAmountDiscount != null -> - generator.writeObject(value.planPhaseAmountDiscount) - value.planPhasePercentageDiscount != null -> - generator.writeObject(value.planPhasePercentageDiscount) - value.planPhaseMinimum != null -> - generator.writeObject(value.planPhaseMinimum) - value.planPhaseMaximum != null -> - generator.writeObject(value.planPhaseMaximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") - } - } - } - - @NoAutoDetect - class PlanPhaseUsageDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonProperty("usage_discount") - @ExcludeMissing - private val usageDiscount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - /** - * The number of usage units by which to discount the price this adjustment applies - * to in a given billing period. - */ - fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - /** - * The number of usage units by which to discount the price this adjustment applies - * to in a given billing period. - */ - @JsonProperty("usage_discount") - @ExcludeMissing - fun _usageDiscount(): JsonField = usageDiscount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseUsageDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - planPhaseOrder() - reason() - usageDiscount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseUsageDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var usageDiscount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - planPhaseUsageDiscountAdjustment: PlanPhaseUsageDiscountAdjustment - ) = apply { - id = planPhaseUsageDiscountAdjustment.id - adjustmentType = planPhaseUsageDiscountAdjustment.adjustmentType - appliesToPriceIds = - planPhaseUsageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseUsageDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseUsageDiscountAdjustment.planPhaseOrder - reason = planPhaseUsageDiscountAdjustment.reason - usageDiscount = planPhaseUsageDiscountAdjustment.usageDiscount - additionalProperties = - planPhaseUsageDiscountAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - /** - * The number of usage units by which to discount the price this adjustment - * applies to in a given billing period. - */ - fun usageDiscount(usageDiscount: Double) = - usageDiscount(JsonField.of(usageDiscount)) - - /** - * The number of usage units by which to discount the price this adjustment - * applies to in a given billing period. - */ - fun usageDiscount(usageDiscount: JsonField) = apply { - this.usageDiscount = usageDiscount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseUsageDiscountAdjustment = - PlanPhaseUsageDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - checkRequired("usageDiscount", usageDiscount), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - USAGE_DISCOUNT -> Known.USAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseUsageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, planPhaseOrder, reason, usageDiscount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseUsageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhaseAmountDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("amount_discount") - @ExcludeMissing - private val amountDiscount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** - * The amount by which to discount the prices this adjustment applies to in a given - * billing period. - */ - fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** - * The amount by which to discount the prices this adjustment applies to in a given - * billing period. - */ - @JsonProperty("amount_discount") - @ExcludeMissing - fun _amountDiscount(): JsonField = amountDiscount - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseAmountDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - amountDiscount() - appliesToPriceIds() - isInvoiceLevel() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseAmountDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var amountDiscount: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - planPhaseAmountDiscountAdjustment: PlanPhaseAmountDiscountAdjustment - ) = apply { - id = planPhaseAmountDiscountAdjustment.id - adjustmentType = planPhaseAmountDiscountAdjustment.adjustmentType - amountDiscount = planPhaseAmountDiscountAdjustment.amountDiscount - appliesToPriceIds = - planPhaseAmountDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseAmountDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseAmountDiscountAdjustment.planPhaseOrder - reason = planPhaseAmountDiscountAdjustment.reason - additionalProperties = - planPhaseAmountDiscountAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** - * The amount by which to discount the prices this adjustment applies to in a - * given billing period. - */ - fun amountDiscount(amountDiscount: String) = - amountDiscount(JsonField.of(amountDiscount)) - - /** - * The amount by which to discount the prices this adjustment applies to in a - * given billing period. - */ - fun amountDiscount(amountDiscount: JsonField) = apply { - this.amountDiscount = amountDiscount - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseAmountDiscountAdjustment = - PlanPhaseAmountDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("amountDiscount", amountDiscount), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseAmountDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, amountDiscount, appliesToPriceIds, isInvoiceLevel, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseAmountDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhasePercentageDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("percentage_discount") - @ExcludeMissing - private val percentageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(): Double = - percentageDiscount.getRequired("percentage_discount") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - @JsonProperty("percentage_discount") - @ExcludeMissing - fun _percentageDiscount(): JsonField = percentageDiscount - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhasePercentageDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - percentageDiscount() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhasePercentageDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var percentageDiscount: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - planPhasePercentageDiscountAdjustment: PlanPhasePercentageDiscountAdjustment - ) = apply { - id = planPhasePercentageDiscountAdjustment.id - adjustmentType = planPhasePercentageDiscountAdjustment.adjustmentType - appliesToPriceIds = - planPhasePercentageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhasePercentageDiscountAdjustment.isInvoiceLevel - percentageDiscount = - planPhasePercentageDiscountAdjustment.percentageDiscount - planPhaseOrder = planPhasePercentageDiscountAdjustment.planPhaseOrder - reason = planPhasePercentageDiscountAdjustment.reason - additionalProperties = - planPhasePercentageDiscountAdjustment.additionalProperties - .toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(percentageDiscount: Double) = - percentageDiscount(JsonField.of(percentageDiscount)) - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(percentageDiscount: JsonField) = apply { - this.percentageDiscount = percentageDiscount - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhasePercentageDiscountAdjustment = - PlanPhasePercentageDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("percentageDiscount", percentageDiscount), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val PERCENTAGE_DISCOUNT = of("percentage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhasePercentageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, percentageDiscount, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhasePercentageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhaseMinimumAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(): String = itemId.getRequired("item_id") - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The item ID that revenue from this minimum will be attributed to. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseMinimumAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - itemId() - minimumAmount() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseMinimumAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var itemId: JsonField? = null - private var minimumAmount: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(planPhaseMinimumAdjustment: PlanPhaseMinimumAdjustment) = - apply { - id = planPhaseMinimumAdjustment.id - adjustmentType = planPhaseMinimumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMinimumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMinimumAdjustment.isInvoiceLevel - itemId = planPhaseMinimumAdjustment.itemId - minimumAmount = planPhaseMinimumAdjustment.minimumAmount - planPhaseOrder = planPhaseMinimumAdjustment.planPhaseOrder - reason = planPhaseMinimumAdjustment.reason - additionalProperties = - planPhaseMinimumAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseMinimumAdjustment = - PlanPhaseMinimumAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("itemId", itemId), - checkRequired("minimumAmount", minimumAmount), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseMinimumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, itemId, minimumAmount, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseMinimumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhaseMaximumAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseMaximumAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - maximumAmount() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseMaximumAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var maximumAmount: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(planPhaseMaximumAdjustment: PlanPhaseMaximumAdjustment) = - apply { - id = planPhaseMaximumAdjustment.id - adjustmentType = planPhaseMaximumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMaximumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMaximumAdjustment.isInvoiceLevel - maximumAmount = planPhaseMaximumAdjustment.maximumAmount - planPhaseOrder = planPhaseMaximumAdjustment.planPhaseOrder - reason = planPhaseMaximumAdjustment.reason - additionalProperties = - planPhaseMaximumAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseMaximumAdjustment = - PlanPhaseMaximumAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("maximumAmount", maximumAmount), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseMaximumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, maximumAmount, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseMaximumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentInterval && id == other.id && adjustment == other.adjustment && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustment, appliesToPriceIntervalIds, endDate, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AdjustmentInterval{id=$id, adjustment=$adjustment, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BillingCycleAnchorConfiguration - @JsonCreator - private constructor( - @JsonProperty("day") @ExcludeMissing private val day: JsonField = JsonMissing.of(), - @JsonProperty("month") - @ExcludeMissing - private val month: JsonField = JsonMissing.of(), - @JsonProperty("year") @ExcludeMissing private val year: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun day(): Long = day.getRequired("day") - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(): Optional = Optional.ofNullable(month.getNullable("month")) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on - * 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(): Optional = Optional.ofNullable(year.getNullable("year")) - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - @JsonProperty("day") @ExcludeMissing fun _day(): JsonField = day - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - @JsonProperty("month") @ExcludeMissing fun _month(): JsonField = month - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on - * 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - @JsonProperty("year") @ExcludeMissing fun _year(): JsonField = year - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleAnchorConfiguration = apply { - if (validated) { - return@apply - } - - day() - month() - year() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleAnchorConfiguration]. */ - class Builder internal constructor() { - - private var day: JsonField? = null - private var month: JsonField = JsonMissing.of() - private var year: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration) = - apply { - day = billingCycleAnchorConfiguration.day - month = billingCycleAnchorConfiguration.month - year = billingCycleAnchorConfiguration.year - additionalProperties = - billingCycleAnchorConfiguration.additionalProperties.toMutableMap() - } - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun day(day: Long) = day(JsonField.of(day)) - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun day(day: JsonField) = apply { this.day = day } - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(month: Long?) = month(JsonField.ofNullable(month)) - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(month: Long) = month(month as Long?) - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun month(month: Optional) = month(month.orElse(null) as Long?) - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(month: JsonField) = apply { this.month = month } - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(year: Long?) = year(JsonField.ofNullable(year)) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(year: Long) = year(year as Long?) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun year(year: Optional) = year(year.orElse(null) as Long?) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(year: JsonField) = apply { this.year = year } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleAnchorConfiguration = - BillingCycleAnchorConfiguration( - checkRequired("day", day), - month, - year, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleAnchorConfiguration && day == other.day && month == other.month && year == other.year && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(day, month, year, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleAnchorConfiguration{day=$day, month=$month, year=$year, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(using = DiscountInterval.Deserializer::class) - @JsonSerialize(using = DiscountInterval.Serializer::class) - class DiscountInterval - private constructor( - private val amount: AmountDiscountInterval? = null, - private val percentage: PercentageDiscountInterval? = null, - private val usage: UsageDiscountInterval? = null, - private val _json: JsonValue? = null, - ) { - - fun amount(): Optional = Optional.ofNullable(amount) - - fun percentage(): Optional = Optional.ofNullable(percentage) - - fun usage(): Optional = Optional.ofNullable(usage) - - fun isAmount(): Boolean = amount != null - - fun isPercentage(): Boolean = percentage != null - - fun isUsage(): Boolean = usage != null - - fun asAmount(): AmountDiscountInterval = amount.getOrThrow("amount") - - fun asPercentage(): PercentageDiscountInterval = percentage.getOrThrow("percentage") - - fun asUsage(): UsageDiscountInterval = usage.getOrThrow("usage") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - amount != null -> visitor.visitAmount(amount) - percentage != null -> visitor.visitPercentage(percentage) - usage != null -> visitor.visitUsage(usage) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): DiscountInterval = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitAmount(amount: AmountDiscountInterval) { - amount.validate() - } - - override fun visitPercentage(percentage: PercentageDiscountInterval) { - percentage.validate() - } - - override fun visitUsage(usage: UsageDiscountInterval) { - usage.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountInterval && amount == other.amount && percentage == other.percentage && usage == other.usage /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(amount, percentage, usage) /* spotless:on */ - - override fun toString(): String = - when { - amount != null -> "DiscountInterval{amount=$amount}" - percentage != null -> "DiscountInterval{percentage=$percentage}" - usage != null -> "DiscountInterval{usage=$usage}" - _json != null -> "DiscountInterval{_unknown=$_json}" - else -> throw IllegalStateException("Invalid DiscountInterval") - } - - companion object { - - @JvmStatic - fun ofAmount(amount: AmountDiscountInterval) = DiscountInterval(amount = amount) - - @JvmStatic - fun ofPercentage(percentage: PercentageDiscountInterval) = - DiscountInterval(percentage = percentage) - - @JvmStatic fun ofUsage(usage: UsageDiscountInterval) = DiscountInterval(usage = usage) - } - - /** - * An interface that defines how to map each variant of [DiscountInterval] to a value of - * type [T]. - */ - interface Visitor { - - fun visitAmount(amount: AmountDiscountInterval): T - - fun visitPercentage(percentage: PercentageDiscountInterval): T - - fun visitUsage(usage: UsageDiscountInterval): T - - /** - * Maps an unknown variant of [DiscountInterval] to a value of type [T]. - * - * An instance of [DiscountInterval] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown DiscountInterval: $json") - } - } - - internal class Deserializer : BaseDeserializer(DiscountInterval::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): DiscountInterval { - val json = JsonValue.fromJsonNode(node) - val discountType = - json.asObject().getOrNull()?.get("discount_type")?.asString()?.getOrNull() - - when (discountType) { - "amount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(amount = it, _json = json) - } - } - "percentage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(percentage = it, _json = json) - } - } - "usage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(usage = it, _json = json) - } - } - } - - return DiscountInterval(_json = json) - } - } - - internal class Serializer : BaseSerializer(DiscountInterval::class) { - - override fun serialize( - value: DiscountInterval, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.amount != null -> generator.writeObject(value.amount) - value.percentage != null -> generator.writeObject(value.percentage) - value.usage != null -> generator.writeObject(value.usage) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid DiscountInterval") - } - } - } - - @NoAutoDetect - class AmountDiscountInterval - @JsonCreator - private constructor( - @JsonProperty("amount_discount") - @ExcludeMissing - private val amountDiscount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("discount_type") - @ExcludeMissing - private val discountType: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - fun discountType(): DiscountType = discountType.getRequired("discount_type") - - /** The end date of the discount interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** The start date of the discount interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** Only available if discount_type is `amount`. */ - @JsonProperty("amount_discount") - @ExcludeMissing - fun _amountDiscount(): JsonField = amountDiscount - - /** The price ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - - /** The end date of the discount interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** The start date of the discount interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AmountDiscountInterval = apply { - if (validated) { - return@apply - } - - amountDiscount() - appliesToPriceIds() - appliesToPriceIntervalIds() - discountType() - endDate() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AmountDiscountInterval]. */ - class Builder internal constructor() { - - private var amountDiscount: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { - amountDiscount = amountDiscountInterval.amountDiscount - appliesToPriceIds = - amountDiscountInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - amountDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = amountDiscountInterval.discountType - endDate = amountDiscountInterval.endDate - startDate = amountDiscountInterval.startDate - additionalProperties = - amountDiscountInterval.additionalProperties.toMutableMap() - } - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(amountDiscount: String) = - amountDiscount(JsonField.of(amountDiscount)) - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(amountDiscount: JsonField) = apply { - this.amountDiscount = amountDiscount - } - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this discount interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this discount interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the discount interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the discount interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** The start date of the discount interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the discount interval. */ - 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) - } - - fun build(): AmountDiscountInterval = - AmountDiscountInterval( - checkRequired("amountDiscount", amountDiscount), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("discountType", discountType), - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val AMOUNT = of("amount") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - AMOUNT - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT -> Value.AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AMOUNT -> Known.AMOUNT - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AmountDiscountInterval && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amountDiscount, appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AmountDiscountInterval{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PercentageDiscountInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("discount_type") - @ExcludeMissing - private val discountType: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("percentage_discount") - @ExcludeMissing - private val percentageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - fun discountType(): DiscountType = discountType.getRequired("discount_type") - - /** The end date of the discount interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ - fun percentageDiscount(): Double = percentageDiscount.getRequired("percentage_discount") - - /** The start date of the discount interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** The price ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - - /** The end date of the discount interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ - @JsonProperty("percentage_discount") - @ExcludeMissing - fun _percentageDiscount(): JsonField = percentageDiscount - - /** The start date of the discount interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PercentageDiscountInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - discountType() - endDate() - percentageDiscount() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PercentageDiscountInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null - private var endDate: JsonField? = null - private var percentageDiscount: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { - appliesToPriceIds = - percentageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - percentageDiscountInterval.appliesToPriceIntervalIds.map { - it.toMutableList() - } - discountType = percentageDiscountInterval.discountType - endDate = percentageDiscountInterval.endDate - percentageDiscount = percentageDiscountInterval.percentageDiscount - startDate = percentageDiscountInterval.startDate - additionalProperties = - percentageDiscountInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this discount interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this discount interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the discount interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the discount interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** - * Only available if discount_type is `percentage`.This is a number between 0 and 1. - */ - fun percentageDiscount(percentageDiscount: Double) = - percentageDiscount(JsonField.of(percentageDiscount)) - - /** - * Only available if discount_type is `percentage`.This is a number between 0 and 1. - */ - fun percentageDiscount(percentageDiscount: JsonField) = apply { - this.percentageDiscount = percentageDiscount - } - - /** The start date of the discount interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the discount interval. */ - 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) - } - - fun build(): PercentageDiscountInterval = - PercentageDiscountInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("discountType", discountType), - checkRequired("endDate", endDate), - checkRequired("percentageDiscount", percentageDiscount), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val PERCENTAGE = of("percentage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - PERCENTAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE -> Value.PERCENTAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PERCENTAGE -> Known.PERCENTAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PercentageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, percentageDiscount, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PercentageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class UsageDiscountInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("discount_type") - @ExcludeMissing - private val discountType: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonProperty("usage_discount") - @ExcludeMissing - private val usageDiscount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - fun discountType(): DiscountType = discountType.getRequired("discount_type") - - /** The end date of the discount interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** The start date of the discount interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** - * Only available if discount_type is `usage`. Number of usage units that this discount - * is for - */ - fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - - /** The price ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - - /** The end date of the discount interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** The start date of the discount interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - /** - * Only available if discount_type is `usage`. Number of usage units that this discount - * is for - */ - @JsonProperty("usage_discount") - @ExcludeMissing - fun _usageDiscount(): JsonField = usageDiscount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): UsageDiscountInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - discountType() - endDate() - startDate() - usageDiscount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UsageDiscountInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var usageDiscount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { - appliesToPriceIds = - usageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - usageDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = usageDiscountInterval.discountType - endDate = usageDiscountInterval.endDate - startDate = usageDiscountInterval.startDate - usageDiscount = usageDiscountInterval.usageDiscount - additionalProperties = usageDiscountInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this discount interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this discount interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the discount interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the discount interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** The start date of the discount interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the discount interval. */ - fun startDate(startDate: JsonField) = apply { - this.startDate = startDate - } - - /** - * Only available if discount_type is `usage`. Number of usage units that this - * discount is for - */ - fun usageDiscount(usageDiscount: Double) = - usageDiscount(JsonField.of(usageDiscount)) - - /** - * Only available if discount_type is `usage`. Number of usage units that this - * discount is for - */ - fun usageDiscount(usageDiscount: JsonField) = apply { - this.usageDiscount = usageDiscount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): UsageDiscountInterval = - UsageDiscountInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("discountType", discountType), - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - checkRequired("usageDiscount", usageDiscount), - additionalProperties.toImmutable(), - ) - } - - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE = of("usage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - USAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE -> Value.USAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE -> Known.USAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UsageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, startDate, usageDiscount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UsageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" - } - } - - @NoAutoDetect - class FixedFeeQuantitySchedule - @JsonCreator - private constructor( - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("price_id") - @ExcludeMissing - private val priceId: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - private val quantity: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - fun priceId(): String = priceId.getRequired("price_id") - - fun quantity(): Double = quantity.getRequired("quantity") - - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - - @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): FixedFeeQuantitySchedule = apply { - if (validated) { - return@apply - } - - endDate() - priceId() - quantity() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FixedFeeQuantitySchedule]. */ - class Builder internal constructor() { - - private var endDate: JsonField? = null - private var priceId: JsonField? = null - private var quantity: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = apply { - endDate = fixedFeeQuantitySchedule.endDate - priceId = fixedFeeQuantitySchedule.priceId - quantity = fixedFeeQuantitySchedule.quantity - startDate = fixedFeeQuantitySchedule.startDate - additionalProperties = fixedFeeQuantitySchedule.additionalProperties.toMutableMap() - } - - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) - - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - 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) - } - - fun build(): FixedFeeQuantitySchedule = - FixedFeeQuantitySchedule( - checkRequired("endDate", endDate), - checkRequired("priceId", priceId), - checkRequired("quantity", quantity), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FixedFeeQuantitySchedule && endDate == other.endDate && priceId == other.priceId && quantity == other.quantity && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(endDate, priceId, quantity, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "FixedFeeQuantitySchedule{endDate=$endDate, priceId=$priceId, quantity=$quantity, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class MaximumInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this maximum interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this maximum interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - /** The end date of the maximum interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** The start date of the maximum interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** The price ids that this maximum interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this maximum interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - /** The end date of the maximum interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** The start date of the maximum interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MaximumInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - endDate() - maximumAmount() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MaximumInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var endDate: JsonField? = null - private var maximumAmount: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximumInterval: MaximumInterval) = apply { - appliesToPriceIds = maximumInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - maximumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - endDate = maximumInterval.endDate - maximumAmount = maximumInterval.maximumAmount - startDate = maximumInterval.startDate - additionalProperties = maximumInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this maximum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this maximum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this maximum interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this maximum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this maximum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this maximum interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - /** The end date of the maximum interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the maximum interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the maximum interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** The start date of the maximum interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the maximum interval. */ - 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) - } - - fun build(): MaximumInterval = - MaximumInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("endDate", endDate), - checkRequired("maximumAmount", maximumAmount), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MaximumInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && maximumAmount == other.maximumAmount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, endDate, maximumAmount, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MaximumInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, maximumAmount=$maximumAmount, startDate=$startDate, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class MinimumInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this minimum interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this minimum interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - /** The end date of the minimum interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** The start date of the minimum interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** The price ids that this minimum interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this minimum interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - /** The end date of the minimum interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** The start date of the minimum interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MinimumInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - endDate() - minimumAmount() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MinimumInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var endDate: JsonField? = null - private var minimumAmount: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(minimumInterval: MinimumInterval) = apply { - appliesToPriceIds = minimumInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - minimumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - endDate = minimumInterval.endDate - minimumAmount = minimumInterval.minimumAmount - startDate = minimumInterval.startDate - additionalProperties = minimumInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this minimum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this minimum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this minimum interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this minimum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this minimum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this minimum interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - /** The end date of the minimum interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the minimum interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the minimum interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** The start date of the minimum interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the minimum interval. */ - 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) - } - - fun build(): MinimumInterval = - MinimumInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("endDate", endDate), - checkRequired("minimumAmount", minimumAmount), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MinimumInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && minimumAmount == other.minimumAmount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, endDate, minimumAmount, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MinimumInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, minimumAmount=$minimumAmount, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - /** - * The Price Interval resource represents a period of time for which a price will bill on a - * subscription. A subscription’s price intervals define its billing behavior. - */ - @NoAutoDetect - class PriceInterval - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_day") - @ExcludeMissing - private val billingCycleDay: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - private val currentBillingPeriodEndDate: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - private val currentBillingPeriodStartDate: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("filter") - @ExcludeMissing - private val filter: JsonField = JsonMissing.of(), - @JsonProperty("fixed_fee_quantity_transitions") - @ExcludeMissing - private val fixedFeeQuantityTransitions: JsonField> = - JsonMissing.of(), - @JsonProperty("price") - @ExcludeMissing - private val price: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonProperty("usage_customer_ids") - @ExcludeMissing - private val usageCustomerIds: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - /** The day of the month that Orb bills for this price */ - fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate(): Optional = - Optional.ofNullable( - currentBillingPeriodEndDate.getNullable("current_billing_period_end_date") - ) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodStartDate(): Optional = - Optional.ofNullable( - currentBillingPeriodStartDate.getNullable("current_billing_period_start_date") - ) - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** An additional filter to apply to usage queries. */ - fun filter(): Optional = Optional.ofNullable(filter.getNullable("filter")) - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions(): Optional> = - Optional.ofNullable( - fixedFeeQuantityTransitions.getNullable("fixed_fee_quantity_transitions") - ) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting in - * a charge on an invoice in the form of an invoice line item. Prices take a quantity and - * determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the key - * for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(): Price = price.getRequired("price") - - /** - * The start date of the price interval. This is the date that Orb starts billing for this - * price. - */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this price - * interval. - */ - fun usageCustomerIds(): Optional> = - Optional.ofNullable(usageCustomerIds.getNullable("usage_customer_ids")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** The day of the month that Orb bills for this price */ - @JsonProperty("billing_cycle_day") - @ExcludeMissing - fun _billingCycleDay(): JsonField = billingCycleDay - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if this price - * interval is not currently active. - */ - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - fun _currentBillingPeriodStartDate(): JsonField = - currentBillingPeriodStartDate - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** An additional filter to apply to usage queries. */ - @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField = filter - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - @JsonProperty("fixed_fee_quantity_transitions") - @ExcludeMissing - fun _fixedFeeQuantityTransitions(): JsonField> = - fixedFeeQuantityTransitions - - /** - * 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) - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - - /** - * The start date of the price interval. This is the date that Orb starts billing for this - * price. - */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this price - * interval. - */ - @JsonProperty("usage_customer_ids") - @ExcludeMissing - fun _usageCustomerIds(): JsonField> = usageCustomerIds - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PriceInterval = apply { - if (validated) { - return@apply - } - - id() - billingCycleDay() - currentBillingPeriodEndDate() - currentBillingPeriodStartDate() - endDate() - filter() - fixedFeeQuantityTransitions().ifPresent { it.forEach { it.validate() } } - price().validate() - startDate() - usageCustomerIds() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PriceInterval]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var billingCycleDay: JsonField? = null - private var currentBillingPeriodEndDate: JsonField? = null - private var currentBillingPeriodStartDate: JsonField? = null - private var endDate: JsonField? = null - private var filter: JsonField? = null - private var fixedFeeQuantityTransitions: - JsonField>? = - null - private var price: JsonField? = null - private var startDate: JsonField? = null - private var usageCustomerIds: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(priceInterval: PriceInterval) = apply { - id = priceInterval.id - billingCycleDay = priceInterval.billingCycleDay - currentBillingPeriodEndDate = priceInterval.currentBillingPeriodEndDate - currentBillingPeriodStartDate = priceInterval.currentBillingPeriodStartDate - endDate = priceInterval.endDate - filter = priceInterval.filter - fixedFeeQuantityTransitions = - priceInterval.fixedFeeQuantityTransitions.map { it.toMutableList() } - price = priceInterval.price - startDate = priceInterval.startDate - usageCustomerIds = priceInterval.usageCustomerIds.map { it.toMutableList() } - additionalProperties = priceInterval.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - /** The day of the month that Orb bills for this price */ - fun billingCycleDay(billingCycleDay: Long) = - billingCycleDay(JsonField.of(billingCycleDay)) - - /** The day of the month that Orb bills for this price */ - fun billingCycleDay(billingCycleDay: JsonField) = apply { - this.billingCycleDay = billingCycleDay - } - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = - currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = - currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate( - currentBillingPeriodEndDate: JsonField - ) = apply { this.currentBillingPeriodEndDate = currentBillingPeriodEndDate } - - /** - * The start date of the current billing period. This is an inclusive timestamp; the - * instant returned is exactly the beginning of the billing period. Set to null if this - * price interval is not currently active. - */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = - currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the - * instant returned is exactly the beginning of the billing period. Set to null if this - * price interval is not currently active. - */ - fun currentBillingPeriodStartDate( - currentBillingPeriodStartDate: Optional - ) = currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the - * instant returned is exactly the beginning of the billing period. Set to null if this - * price interval is not currently active. - */ - fun currentBillingPeriodStartDate( - currentBillingPeriodStartDate: JsonField - ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** An additional filter to apply to usage queries. */ - fun filter(filter: String?) = filter(JsonField.ofNullable(filter)) - - /** An additional filter to apply to usage queries. */ - fun filter(filter: Optional) = filter(filter.orElse(null)) - - /** An additional filter to apply to usage queries. */ - fun filter(filter: JsonField) = apply { this.filter = filter } - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: List? - ) = fixedFeeQuantityTransitions(JsonField.ofNullable(fixedFeeQuantityTransitions)) - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: Optional> - ) = fixedFeeQuantityTransitions(fixedFeeQuantityTransitions.orElse(null)) - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: JsonField> - ) = apply { - this.fixedFeeQuantityTransitions = - fixedFeeQuantityTransitions.map { it.toMutableList() } - } - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun addFixedFeeQuantityTransition( - fixedFeeQuantityTransition: FixedFeeQuantityTransition - ) = apply { - fixedFeeQuantityTransitions = - (fixedFeeQuantityTransitions ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(fixedFeeQuantityTransition) - } - } - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(price: Price) = price(JsonField.of(price)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(price: JsonField) = apply { this.price = price } - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(matrix: Price.MatrixPrice) = price(Price.ofMatrix(matrix)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredPackage: Price.TieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedTiered: Price.GroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(unitWithPercent: Price.UnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredWithProration: Price.TieredWithProrationPrice) = - price(Price.ofTieredWithProration(tieredWithProration)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(unitWithProration: Price.UnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedAllocation: Price.GroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bulkWithProration: Price.BulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = - price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice) = - price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - - /** - * The start date of the price interval. This is the date that Orb starts billing for - * this price. - */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** - * The start date of the price interval. This is the date that Orb starts billing for - * this price. - */ - fun startDate(startDate: JsonField) = apply { - this.startDate = startDate - } - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun usageCustomerIds(usageCustomerIds: List?) = - usageCustomerIds(JsonField.ofNullable(usageCustomerIds)) - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun usageCustomerIds(usageCustomerIds: Optional>) = - usageCustomerIds(usageCustomerIds.orElse(null)) - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun usageCustomerIds(usageCustomerIds: JsonField>) = apply { - this.usageCustomerIds = usageCustomerIds.map { it.toMutableList() } - } - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun addUsageCustomerId(usageCustomerId: String) = apply { - usageCustomerIds = - (usageCustomerIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(usageCustomerId) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): PriceInterval = - PriceInterval( - checkRequired("id", id), - checkRequired("billingCycleDay", billingCycleDay), - checkRequired("currentBillingPeriodEndDate", currentBillingPeriodEndDate), - checkRequired("currentBillingPeriodStartDate", currentBillingPeriodStartDate), - checkRequired("endDate", endDate), - checkRequired("filter", filter), - checkRequired("fixedFeeQuantityTransitions", fixedFeeQuantityTransitions).map { - it.toImmutable() - }, - checkRequired("price", price), - checkRequired("startDate", startDate), - checkRequired("usageCustomerIds", usageCustomerIds).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class FixedFeeQuantityTransition - @JsonCreator - private constructor( - @JsonProperty("effective_date") - @ExcludeMissing - private val effectiveDate: JsonField = JsonMissing.of(), - @JsonProperty("price_id") - @ExcludeMissing - private val priceId: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - private val quantity: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun effectiveDate(): OffsetDateTime = effectiveDate.getRequired("effective_date") - - fun priceId(): String = priceId.getRequired("price_id") - - fun quantity(): Long = quantity.getRequired("quantity") - - @JsonProperty("effective_date") - @ExcludeMissing - fun _effectiveDate(): JsonField = effectiveDate - - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - - @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): FixedFeeQuantityTransition = apply { - if (validated) { - return@apply - } - - effectiveDate() - priceId() - quantity() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FixedFeeQuantityTransition]. */ - class Builder internal constructor() { - - private var effectiveDate: JsonField? = null - private var priceId: JsonField? = null - private var quantity: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(fixedFeeQuantityTransition: FixedFeeQuantityTransition) = apply { - effectiveDate = fixedFeeQuantityTransition.effectiveDate - priceId = fixedFeeQuantityTransition.priceId - quantity = fixedFeeQuantityTransition.quantity - additionalProperties = - fixedFeeQuantityTransition.additionalProperties.toMutableMap() - } - - fun effectiveDate(effectiveDate: OffsetDateTime) = - effectiveDate(JsonField.of(effectiveDate)) - - fun effectiveDate(effectiveDate: JsonField) = apply { - this.effectiveDate = effectiveDate - } - - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) - - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - - fun quantity(quantity: Long) = quantity(JsonField.of(quantity)) - - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): FixedFeeQuantityTransition = - FixedFeeQuantityTransition( - checkRequired("effectiveDate", effectiveDate), - checkRequired("priceId", priceId), - checkRequired("quantity", quantity), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FixedFeeQuantityTransition && effectiveDate == other.effectiveDate && priceId == other.priceId && quantity == other.quantity && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(effectiveDate, priceId, quantity, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "FixedFeeQuantityTransition{effectiveDate=$effectiveDate, priceId=$priceId, quantity=$quantity, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PriceInterval && id == other.id && billingCycleDay == other.billingCycleDay && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && endDate == other.endDate && filter == other.filter && fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && price == other.price && startDate == other.startDate && usageCustomerIds == other.usageCustomerIds && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billingCycleDay, currentBillingPeriodEndDate, currentBillingPeriodStartDate, endDate, filter, fixedFeeQuantityTransitions, price, startDate, usageCustomerIds, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PriceInterval{id=$id, billingCycleDay=$billingCycleDay, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, endDate=$endDate, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, price=$price, startDate=$startDate, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class RedeemedCoupon - @JsonCreator - private constructor( - @JsonProperty("coupon_id") - @ExcludeMissing - private val couponId: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun couponId(): String = couponId.getRequired("coupon_id") - - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - @JsonProperty("coupon_id") @ExcludeMissing fun _couponId(): JsonField = couponId - - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): RedeemedCoupon = apply { - if (validated) { - return@apply - } - - couponId() - endDate() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RedeemedCoupon]. */ - class Builder internal constructor() { - - private var couponId: JsonField? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(redeemedCoupon: RedeemedCoupon) = apply { - couponId = redeemedCoupon.couponId - endDate = redeemedCoupon.endDate - startDate = redeemedCoupon.startDate - additionalProperties = redeemedCoupon.additionalProperties.toMutableMap() - } - - fun couponId(couponId: String) = couponId(JsonField.of(couponId)) - - fun couponId(couponId: JsonField) = apply { this.couponId = couponId } - - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - 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) - } - - fun build(): RedeemedCoupon = - RedeemedCoupon( - checkRequired("couponId", couponId), - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RedeemedCoupon && couponId == other.couponId && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(couponId, endDate, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RedeemedCoupon{couponId=$couponId, endDate=$endDate, startDate=$startDate, 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 ENDED = of("ended") - - @JvmField val UPCOMING = of("upcoming") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - ACTIVE, - ENDED, - UPCOMING, - } - - /** - * 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, - ENDED, - UPCOMING, - /** 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 - ENDED -> Value.ENDED - UPCOMING -> Value.UPCOMING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to 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 - ENDED -> Known.ENDED - UPCOMING -> Known.UPCOMING - 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TrialInfo - @JsonCreator - private constructor( - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TrialInfo = apply { - if (validated) { - return@apply - } - - endDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TrialInfo]. */ - class Builder internal constructor() { - - private var endDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(trialInfo: TrialInfo) = apply { - endDate = trialInfo.endDate - additionalProperties = trialInfo.additionalProperties.toMutableMap() - } - - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - 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) - } - - fun build(): TrialInfo = - TrialInfo(checkRequired("endDate", endDate), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TrialInfo && endDate == other.endDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(endDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TrialInfo{endDate=$endDate, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is SubscriptionPriceIntervalsResponse && id == other.id && activePlanPhaseOrder == other.activePlanPhaseOrder && adjustmentIntervals == other.adjustmentIntervals && autoCollection == other.autoCollection && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && billingCycleDay == other.billingCycleDay && createdAt == other.createdAt && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && customer == other.customer && defaultInvoiceMemo == other.defaultInvoiceMemo && discountIntervals == other.discountIntervals && endDate == other.endDate && fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && invoicingThreshold == other.invoicingThreshold && maximumIntervals == other.maximumIntervals && metadata == other.metadata && minimumIntervals == other.minimumIntervals && netTerms == other.netTerms && plan == other.plan && priceIntervals == other.priceIntervals && redeemedCoupon == other.redeemedCoupon && startDate == other.startDate && status == other.status && trialInfo == other.trialInfo && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, activePlanPhaseOrder, adjustmentIntervals, autoCollection, billingCycleAnchorConfiguration, billingCycleDay, createdAt, currentBillingPeriodEndDate, currentBillingPeriodStartDate, customer, defaultInvoiceMemo, discountIntervals, endDate, fixedFeeQuantitySchedule, invoicingThreshold, maximumIntervals, metadata, minimumIntervals, netTerms, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SubscriptionPriceIntervalsResponse{id=$id, activePlanPhaseOrder=$activePlanPhaseOrder, adjustmentIntervals=$adjustmentIntervals, autoCollection=$autoCollection, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, billingCycleDay=$billingCycleDay, createdAt=$createdAt, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, customer=$customer, defaultInvoiceMemo=$defaultInvoiceMemo, discountIntervals=$discountIntervals, endDate=$endDate, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, invoicingThreshold=$invoicingThreshold, maximumIntervals=$maximumIntervals, metadata=$metadata, minimumIntervals=$minimumIntervals, netTerms=$netTerms, plan=$plan, priceIntervals=$priceIntervals, redeemedCoupon=$redeemedCoupon, startDate=$startDate, status=$status, trialInfo=$trialInfo, additionalProperties=$additionalProperties}" -} 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 1c777dcc3..4b5a0503d 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 @@ -6,15 +6,6 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField @@ -22,8 +13,8 @@ import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.Params +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import com.withorb.api.core.immutableEmptyMap @@ -32,7 +23,6 @@ import com.withorb.api.errors.OrbInvalidDataException import java.time.OffsetDateTime import java.util.Objects import java.util.Optional -import kotlin.jvm.optionals.getOrNull /** * This endpoint can be used to change an existing subscription's plan. It returns the serialized @@ -210,13 +200,13 @@ private constructor( * Additional adjustments to be added to the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun addAdjustments(): Optional> = body.addAdjustments() + fun addAdjustments(): Optional> = body.addAdjustments() /** * Additional prices to be added to the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) */ - fun addPrices(): Optional> = body.addPrices() + fun addPrices(): Optional> = body.addPrices() /** * [DEPRECATED] Use billing_cycle_alignment instead. Reset billing periods to be aligned with @@ -237,7 +227,7 @@ private constructor( */ fun billingCycleAlignment(): Optional = body.billingCycleAlignment() - fun billingCycleAnchorConfiguration(): Optional = + fun billingCycleAnchorConfiguration(): Optional = body.billingCycleAnchorConfiguration() /** @@ -314,25 +304,27 @@ private constructor( * Plan adjustments to be removed from the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) */ - fun removeAdjustments(): Optional> = body.removeAdjustments() + fun removeAdjustments(): Optional> = + body.removeAdjustments() /** * Plan prices to be removed from the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) */ - fun removePrices(): Optional> = body.removePrices() + fun removePrices(): Optional> = body.removePrices() /** * Plan adjustments to be replaced with additional adjustments on the subscription. (Only * available for accounts that have migrated off of legacy subscription overrides) */ - fun replaceAdjustments(): Optional> = body.replaceAdjustments() + fun replaceAdjustments(): Optional> = + body.replaceAdjustments() /** * Plan prices to be replaced with additional prices on the subscription. (Only available for * accounts that have migrated off of legacy subscription overrides) */ - fun replacePrices(): Optional> = body.replacePrices() + fun replacePrices(): Optional> = body.replacePrices() /** * The duration of the trial period in days. If not provided, this defaults to the value @@ -355,13 +347,13 @@ private constructor( * Additional adjustments to be added to the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun _addAdjustments(): JsonField> = body._addAdjustments() + fun _addAdjustments(): JsonField> = body._addAdjustments() /** * Additional prices to be added to the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) */ - fun _addPrices(): JsonField> = body._addPrices() + fun _addPrices(): JsonField> = body._addPrices() /** * [DEPRECATED] Use billing_cycle_alignment instead. Reset billing periods to be aligned with @@ -383,7 +375,7 @@ private constructor( */ fun _billingCycleAlignment(): JsonField = body._billingCycleAlignment() - fun _billingCycleAnchorConfiguration(): JsonField = + fun _billingCycleAnchorConfiguration(): JsonField = body._billingCycleAnchorConfiguration() /** @@ -461,25 +453,27 @@ private constructor( * Plan adjustments to be removed from the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) */ - fun _removeAdjustments(): JsonField> = body._removeAdjustments() + fun _removeAdjustments(): JsonField> = + body._removeAdjustments() /** * Plan prices to be removed from the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) */ - fun _removePrices(): JsonField> = body._removePrices() + fun _removePrices(): JsonField> = body._removePrices() /** * Plan adjustments to be replaced with additional adjustments on the subscription. (Only * available for accounts that have migrated off of legacy subscription overrides) */ - fun _replaceAdjustments(): JsonField> = body._replaceAdjustments() + fun _replaceAdjustments(): JsonField> = + body._replaceAdjustments() /** * Plan prices to be replaced with additional prices on the subscription. (Only available for * accounts that have migrated off of legacy subscription overrides) */ - fun _replacePrices(): JsonField> = body._replacePrices() + fun _replacePrices(): JsonField> = body._replacePrices() /** * The duration of the trial period in days. If not provided, this defaults to the value @@ -524,10 +518,11 @@ private constructor( private val changeOption: JsonField = JsonMissing.of(), @JsonProperty("add_adjustments") @ExcludeMissing - private val addAdjustments: JsonField> = JsonMissing.of(), + private val addAdjustments: JsonField> = + JsonMissing.of(), @JsonProperty("add_prices") @ExcludeMissing - private val addPrices: JsonField> = JsonMissing.of(), + private val addPrices: JsonField> = JsonMissing.of(), @JsonProperty("align_billing_with_plan_change_date") @ExcludeMissing private val alignBillingWithPlanChangeDate: JsonField = JsonMissing.of(), @@ -539,7 +534,8 @@ private constructor( private val billingCycleAlignment: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_anchor_configuration") @ExcludeMissing - private val billingCycleAnchorConfiguration: JsonField = + private val billingCycleAnchorConfiguration: + JsonField = JsonMissing.of(), @JsonProperty("change_date") @ExcludeMissing @@ -582,16 +578,19 @@ private constructor( private val priceOverrides: JsonField> = JsonMissing.of(), @JsonProperty("remove_adjustments") @ExcludeMissing - private val removeAdjustments: JsonField> = JsonMissing.of(), + private val removeAdjustments: JsonField> = + JsonMissing.of(), @JsonProperty("remove_prices") @ExcludeMissing - private val removePrices: JsonField> = JsonMissing.of(), + private val removePrices: JsonField> = JsonMissing.of(), @JsonProperty("replace_adjustments") @ExcludeMissing - private val replaceAdjustments: JsonField> = JsonMissing.of(), + private val replaceAdjustments: JsonField> = + JsonMissing.of(), @JsonProperty("replace_prices") @ExcludeMissing - private val replacePrices: JsonField> = JsonMissing.of(), + private val replacePrices: JsonField> = + JsonMissing.of(), @JsonProperty("trial_duration_days") @ExcludeMissing private val trialDurationDays: JsonField = JsonMissing.of(), @@ -608,14 +607,14 @@ private constructor( * Additional adjustments to be added to the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun addAdjustments(): Optional> = + fun addAdjustments(): Optional> = Optional.ofNullable(addAdjustments.getNullable("add_adjustments")) /** * Additional prices to be added to the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) */ - fun addPrices(): Optional> = + fun addPrices(): Optional> = Optional.ofNullable(addPrices.getNullable("add_prices")) /** @@ -643,7 +642,7 @@ private constructor( fun billingCycleAlignment(): Optional = Optional.ofNullable(billingCycleAlignment.getNullable("billing_cycle_alignment")) - fun billingCycleAnchorConfiguration(): Optional = + fun billingCycleAnchorConfiguration(): Optional = Optional.ofNullable( billingCycleAnchorConfiguration.getNullable("billing_cycle_anchor_configuration") ) @@ -734,28 +733,28 @@ private constructor( * Plan adjustments to be removed from the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun removeAdjustments(): Optional> = + fun removeAdjustments(): Optional> = Optional.ofNullable(removeAdjustments.getNullable("remove_adjustments")) /** * Plan prices to be removed from the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) */ - fun removePrices(): Optional> = + fun removePrices(): Optional> = Optional.ofNullable(removePrices.getNullable("remove_prices")) /** * Plan adjustments to be replaced with additional adjustments on the subscription. (Only * available for accounts that have migrated off of legacy subscription overrides) */ - fun replaceAdjustments(): Optional> = + fun replaceAdjustments(): Optional> = Optional.ofNullable(replaceAdjustments.getNullable("replace_adjustments")) /** * Plan prices to be replaced with additional prices on the subscription. (Only available * for accounts that have migrated off of legacy subscription overrides) */ - fun replacePrices(): Optional> = + fun replacePrices(): Optional> = Optional.ofNullable(replacePrices.getNullable("replace_prices")) /** @@ -785,7 +784,7 @@ private constructor( */ @JsonProperty("add_adjustments") @ExcludeMissing - fun _addAdjustments(): JsonField> = addAdjustments + fun _addAdjustments(): JsonField> = addAdjustments /** * Additional prices to be added to the subscription. (Only available for accounts that have @@ -793,7 +792,7 @@ private constructor( */ @JsonProperty("add_prices") @ExcludeMissing - fun _addPrices(): JsonField> = addPrices + fun _addPrices(): JsonField> = addPrices /** * [DEPRECATED] Use billing_cycle_alignment instead. Reset billing periods to be aligned @@ -823,7 +822,7 @@ private constructor( @JsonProperty("billing_cycle_anchor_configuration") @ExcludeMissing - fun _billingCycleAnchorConfiguration(): JsonField = + fun _billingCycleAnchorConfiguration(): JsonField = billingCycleAnchorConfiguration /** @@ -924,7 +923,8 @@ private constructor( */ @JsonProperty("remove_adjustments") @ExcludeMissing - fun _removeAdjustments(): JsonField> = removeAdjustments + fun _removeAdjustments(): JsonField> = + removeAdjustments /** * Plan prices to be removed from the subscription. (Only available for accounts that have @@ -932,7 +932,7 @@ private constructor( */ @JsonProperty("remove_prices") @ExcludeMissing - fun _removePrices(): JsonField> = removePrices + fun _removePrices(): JsonField> = removePrices /** * Plan adjustments to be replaced with additional adjustments on the subscription. (Only @@ -940,7 +940,8 @@ private constructor( */ @JsonProperty("replace_adjustments") @ExcludeMissing - fun _replaceAdjustments(): JsonField> = replaceAdjustments + fun _replaceAdjustments(): JsonField> = + replaceAdjustments /** * Plan prices to be replaced with additional prices on the subscription. (Only available @@ -948,7 +949,7 @@ private constructor( */ @JsonProperty("replace_prices") @ExcludeMissing - fun _replacePrices(): JsonField> = replacePrices + fun _replacePrices(): JsonField> = replacePrices /** * The duration of the trial period in days. If not provided, this defaults to the value @@ -1013,6 +1014,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .changeOption() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1020,13 +1029,14 @@ private constructor( class Builder internal constructor() { private var changeOption: JsonField? = null - private var addAdjustments: JsonField>? = null - private var addPrices: JsonField>? = null + private var addAdjustments: JsonField>? = + null + private var addPrices: JsonField>? = null private var alignBillingWithPlanChangeDate: JsonField = JsonMissing.of() private var autoCollection: JsonField = JsonMissing.of() private var billingCycleAlignment: JsonField = JsonMissing.of() private var billingCycleAnchorConfiguration: - JsonField = + JsonField = JsonMissing.of() private var changeDate: JsonField = JsonMissing.of() private var couponRedemptionCode: JsonField = JsonMissing.of() @@ -1041,10 +1051,15 @@ private constructor( private var planId: JsonField = JsonMissing.of() private var planVersionNumber: JsonField = JsonMissing.of() private var priceOverrides: JsonField>? = null - private var removeAdjustments: JsonField>? = null - private var removePrices: JsonField>? = null - private var replaceAdjustments: JsonField>? = null - private var replacePrices: JsonField>? = null + private var removeAdjustments: + JsonField>? = + null + private var removePrices: JsonField>? = null + private var replaceAdjustments: + JsonField>? = + null + private var replacePrices: JsonField>? = + null private var trialDurationDays: JsonField = JsonMissing.of() private var usageCustomerIds: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -1090,38 +1105,33 @@ private constructor( * Additional adjustments to be added to the subscription. (Only available for accounts * that have migrated off of legacy subscription overrides) */ - fun addAdjustments(addAdjustments: List?) = + fun addAdjustments(addAdjustments: List?) = addAdjustments(JsonField.ofNullable(addAdjustments)) /** * Additional adjustments to be added to the subscription. (Only available for accounts * that have migrated off of legacy subscription overrides) */ - fun addAdjustments(addAdjustments: Optional>) = + fun addAdjustments(addAdjustments: Optional>) = addAdjustments(addAdjustments.orElse(null)) /** * Additional adjustments to be added to the subscription. (Only available for accounts * that have migrated off of legacy subscription overrides) */ - fun addAdjustments(addAdjustments: JsonField>) = apply { - this.addAdjustments = addAdjustments.map { it.toMutableList() } - } + fun addAdjustments(addAdjustments: JsonField>) = + apply { + this.addAdjustments = addAdjustments.map { it.toMutableList() } + } /** * Additional adjustments to be added to the subscription. (Only available for accounts * that have migrated off of legacy subscription overrides) */ - fun addAddAdjustment(addAdjustment: AddAdjustment) = apply { + fun addAddAdjustment(addAdjustment: AddSubscriptionAdjustmentParams) = apply { addAdjustments = - (addAdjustments ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(addAdjustment) + (addAdjustments ?: JsonField.of(mutableListOf())).also { + checkKnown("addAdjustments", it).add(addAdjustment) } } @@ -1129,19 +1139,21 @@ private constructor( * Additional prices to be added to the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun addPrices(addPrices: List?) = addPrices(JsonField.ofNullable(addPrices)) + fun addPrices(addPrices: List?) = + addPrices(JsonField.ofNullable(addPrices)) /** * Additional prices to be added to the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun addPrices(addPrices: Optional>) = addPrices(addPrices.orElse(null)) + fun addPrices(addPrices: Optional>) = + addPrices(addPrices.orElse(null)) /** * Additional prices to be added to the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun addPrices(addPrices: JsonField>) = apply { + fun addPrices(addPrices: JsonField>) = apply { this.addPrices = addPrices.map { it.toMutableList() } } @@ -1149,16 +1161,10 @@ private constructor( * Additional prices to be added to the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun addAddPrice(addPrice: AddPrice) = apply { + fun addAddPrice(addPrice: AddSubscriptionPriceParams) = apply { addPrices = - (addPrices ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(addPrice) + (addPrices ?: JsonField.of(mutableListOf())).also { + checkKnown("addPrices", it).add(addPrice) } } @@ -1255,18 +1261,18 @@ private constructor( } fun billingCycleAnchorConfiguration( - billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration? + billingCycleAnchorConfiguration: BillingCycleAnchorConfigurationModel? ) = billingCycleAnchorConfiguration( JsonField.ofNullable(billingCycleAnchorConfiguration) ) fun billingCycleAnchorConfiguration( - billingCycleAnchorConfiguration: Optional + billingCycleAnchorConfiguration: Optional ) = billingCycleAnchorConfiguration(billingCycleAnchorConfiguration.orElse(null)) fun billingCycleAnchorConfiguration( - billingCycleAnchorConfiguration: JsonField + billingCycleAnchorConfiguration: JsonField ) = apply { this.billingCycleAnchorConfiguration = billingCycleAnchorConfiguration } /** @@ -1560,14 +1566,8 @@ private constructor( @Deprecated("deprecated") fun addPriceOverride(priceOverride: JsonValue) = apply { priceOverrides = - (priceOverrides ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(priceOverride) + (priceOverrides ?: JsonField.of(mutableListOf())).also { + checkKnown("priceOverrides", it).add(priceOverride) } } @@ -1575,38 +1575,33 @@ private constructor( * Plan adjustments to be removed from the subscription. (Only available for accounts * that have migrated off of legacy subscription overrides) */ - fun removeAdjustments(removeAdjustments: List?) = + fun removeAdjustments(removeAdjustments: List?) = removeAdjustments(JsonField.ofNullable(removeAdjustments)) /** * Plan adjustments to be removed from the subscription. (Only available for accounts * that have migrated off of legacy subscription overrides) */ - fun removeAdjustments(removeAdjustments: Optional>) = - removeAdjustments(removeAdjustments.orElse(null)) + fun removeAdjustments( + removeAdjustments: Optional> + ) = removeAdjustments(removeAdjustments.orElse(null)) /** * Plan adjustments to be removed from the subscription. (Only available for accounts * that have migrated off of legacy subscription overrides) */ - fun removeAdjustments(removeAdjustments: JsonField>) = apply { - this.removeAdjustments = removeAdjustments.map { it.toMutableList() } - } + fun removeAdjustments( + removeAdjustments: JsonField> + ) = apply { this.removeAdjustments = removeAdjustments.map { it.toMutableList() } } /** * Plan adjustments to be removed from the subscription. (Only available for accounts * that have migrated off of legacy subscription overrides) */ - fun addRemoveAdjustment(removeAdjustment: RemoveAdjustment) = apply { + fun addRemoveAdjustment(removeAdjustment: RemoveSubscriptionAdjustmentParams) = apply { removeAdjustments = - (removeAdjustments ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(removeAdjustment) + (removeAdjustments ?: JsonField.of(mutableListOf())).also { + checkKnown("removeAdjustments", it).add(removeAdjustment) } } @@ -1614,21 +1609,21 @@ private constructor( * Plan prices to be removed from the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun removePrices(removePrices: List?) = + fun removePrices(removePrices: List?) = removePrices(JsonField.ofNullable(removePrices)) /** * Plan prices to be removed from the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun removePrices(removePrices: Optional>) = + fun removePrices(removePrices: Optional>) = removePrices(removePrices.orElse(null)) /** * Plan prices to be removed from the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun removePrices(removePrices: JsonField>) = apply { + fun removePrices(removePrices: JsonField>) = apply { this.removePrices = removePrices.map { it.toMutableList() } } @@ -1636,16 +1631,10 @@ private constructor( * Plan prices to be removed from the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun addRemovePrice(removePrice: RemovePrice) = apply { + fun addRemovePrice(removePrice: RemoveSubscriptionPriceParams) = apply { removePrices = - (removePrices ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(removePrice) + (removePrices ?: JsonField.of(mutableListOf())).also { + checkKnown("removePrices", it).add(removePrice) } } @@ -1653,77 +1642,68 @@ private constructor( * Plan adjustments to be replaced with additional adjustments on the subscription. * (Only available for accounts that have migrated off of legacy subscription overrides) */ - fun replaceAdjustments(replaceAdjustments: List?) = + fun replaceAdjustments(replaceAdjustments: List?) = replaceAdjustments(JsonField.ofNullable(replaceAdjustments)) /** * Plan adjustments to be replaced with additional adjustments on the subscription. * (Only available for accounts that have migrated off of legacy subscription overrides) */ - fun replaceAdjustments(replaceAdjustments: Optional>) = - replaceAdjustments(replaceAdjustments.orElse(null)) + fun replaceAdjustments( + replaceAdjustments: Optional> + ) = replaceAdjustments(replaceAdjustments.orElse(null)) /** * Plan adjustments to be replaced with additional adjustments on the subscription. * (Only available for accounts that have migrated off of legacy subscription overrides) */ - fun replaceAdjustments(replaceAdjustments: JsonField>) = apply { - this.replaceAdjustments = replaceAdjustments.map { it.toMutableList() } - } + fun replaceAdjustments( + replaceAdjustments: JsonField> + ) = apply { this.replaceAdjustments = replaceAdjustments.map { it.toMutableList() } } /** * Plan adjustments to be replaced with additional adjustments on the subscription. * (Only available for accounts that have migrated off of legacy subscription overrides) */ - fun addReplaceAdjustment(replaceAdjustment: ReplaceAdjustment) = apply { - replaceAdjustments = - (replaceAdjustments ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(replaceAdjustment) - } - } + fun addReplaceAdjustment(replaceAdjustment: ReplaceSubscriptionAdjustmentParams) = + apply { + replaceAdjustments = + (replaceAdjustments ?: JsonField.of(mutableListOf())).also { + checkKnown("replaceAdjustments", it).add(replaceAdjustment) + } + } /** * Plan prices to be replaced with additional prices on the subscription. (Only * available for accounts that have migrated off of legacy subscription overrides) */ - fun replacePrices(replacePrices: List?) = + fun replacePrices(replacePrices: List?) = replacePrices(JsonField.ofNullable(replacePrices)) /** * Plan prices to be replaced with additional prices on the subscription. (Only * available for accounts that have migrated off of legacy subscription overrides) */ - fun replacePrices(replacePrices: Optional>) = + fun replacePrices(replacePrices: Optional>) = replacePrices(replacePrices.orElse(null)) /** * Plan prices to be replaced with additional prices on the subscription. (Only * available for accounts that have migrated off of legacy subscription overrides) */ - fun replacePrices(replacePrices: JsonField>) = apply { - this.replacePrices = replacePrices.map { it.toMutableList() } - } + fun replacePrices(replacePrices: JsonField>) = + apply { + this.replacePrices = replacePrices.map { it.toMutableList() } + } /** * Plan prices to be replaced with additional prices on the subscription. (Only * available for accounts that have migrated off of legacy subscription overrides) */ - fun addReplacePrice(replacePrice: ReplacePrice) = apply { + fun addReplacePrice(replacePrice: ReplaceSubscriptionPriceParams) = apply { replacePrices = - (replacePrices ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(replacePrice) + (replacePrices ?: JsonField.of(mutableListOf())).also { + checkKnown("replacePrices", it).add(replacePrice) } } @@ -1801,14 +1781,8 @@ private constructor( */ fun addUsageCustomerId(usageCustomerId: String) = apply { usageCustomerIds = - (usageCustomerIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(usageCustomerId) + (usageCustomerIds ?: JsonField.of(mutableListOf())).also { + checkKnown("usageCustomerIds", it).add(usageCustomerId) } } @@ -1885,6 +1859,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [SubscriptionSchedulePlanChangeParams]. + * + * The following fields are required: + * ```java + * .subscriptionId() + * .changeOption() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1920,7 +1904,7 @@ private constructor( * Additional adjustments to be added to the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun addAdjustments(addAdjustments: List?) = apply { + fun addAdjustments(addAdjustments: List?) = apply { body.addAdjustments(addAdjustments) } @@ -1928,22 +1912,23 @@ private constructor( * Additional adjustments to be added to the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun addAdjustments(addAdjustments: Optional>) = + fun addAdjustments(addAdjustments: Optional>) = addAdjustments(addAdjustments.orElse(null)) /** * Additional adjustments to be added to the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun addAdjustments(addAdjustments: JsonField>) = apply { - body.addAdjustments(addAdjustments) - } + fun addAdjustments(addAdjustments: JsonField>) = + apply { + body.addAdjustments(addAdjustments) + } /** * Additional adjustments to be added to the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun addAddAdjustment(addAdjustment: AddAdjustment) = apply { + fun addAddAdjustment(addAdjustment: AddSubscriptionAdjustmentParams) = apply { body.addAddAdjustment(addAdjustment) } @@ -1951,25 +1936,30 @@ private constructor( * Additional prices to be added to the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) */ - fun addPrices(addPrices: List?) = apply { body.addPrices(addPrices) } + fun addPrices(addPrices: List?) = apply { + body.addPrices(addPrices) + } /** * Additional prices to be added to the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) */ - fun addPrices(addPrices: Optional>) = addPrices(addPrices.orElse(null)) + fun addPrices(addPrices: Optional>) = + addPrices(addPrices.orElse(null)) /** * Additional prices to be added to the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) */ - fun addPrices(addPrices: JsonField>) = apply { body.addPrices(addPrices) } + fun addPrices(addPrices: JsonField>) = apply { + body.addPrices(addPrices) + } /** * Additional prices to be added to the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) */ - fun addAddPrice(addPrice: AddPrice) = apply { body.addAddPrice(addPrice) } + fun addAddPrice(addPrice: AddSubscriptionPriceParams) = apply { body.addAddPrice(addPrice) } /** * [DEPRECATED] Use billing_cycle_alignment instead. Reset billing periods to be aligned @@ -2062,15 +2052,15 @@ private constructor( } fun billingCycleAnchorConfiguration( - billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration? + billingCycleAnchorConfiguration: BillingCycleAnchorConfigurationModel? ) = apply { body.billingCycleAnchorConfiguration(billingCycleAnchorConfiguration) } fun billingCycleAnchorConfiguration( - billingCycleAnchorConfiguration: Optional + billingCycleAnchorConfiguration: Optional ) = billingCycleAnchorConfiguration(billingCycleAnchorConfiguration.orElse(null)) fun billingCycleAnchorConfiguration( - billingCycleAnchorConfiguration: JsonField + billingCycleAnchorConfiguration: JsonField ) = apply { body.billingCycleAnchorConfiguration(billingCycleAnchorConfiguration) } /** @@ -2375,30 +2365,32 @@ private constructor( * Plan adjustments to be removed from the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun removeAdjustments(removeAdjustments: List?) = apply { - body.removeAdjustments(removeAdjustments) - } + fun removeAdjustments(removeAdjustments: List?) = + apply { + body.removeAdjustments(removeAdjustments) + } /** * Plan adjustments to be removed from the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun removeAdjustments(removeAdjustments: Optional>) = - removeAdjustments(removeAdjustments.orElse(null)) + fun removeAdjustments( + removeAdjustments: Optional> + ) = removeAdjustments(removeAdjustments.orElse(null)) /** * Plan adjustments to be removed from the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun removeAdjustments(removeAdjustments: JsonField>) = apply { - body.removeAdjustments(removeAdjustments) - } + fun removeAdjustments( + removeAdjustments: JsonField> + ) = apply { body.removeAdjustments(removeAdjustments) } /** * Plan adjustments to be removed from the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun addRemoveAdjustment(removeAdjustment: RemoveAdjustment) = apply { + fun addRemoveAdjustment(removeAdjustment: RemoveSubscriptionAdjustmentParams) = apply { body.addRemoveAdjustment(removeAdjustment) } @@ -2406,7 +2398,7 @@ private constructor( * Plan prices to be removed from the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) */ - fun removePrices(removePrices: List?) = apply { + fun removePrices(removePrices: List?) = apply { body.removePrices(removePrices) } @@ -2414,14 +2406,14 @@ private constructor( * Plan prices to be removed from the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) */ - fun removePrices(removePrices: Optional>) = + fun removePrices(removePrices: Optional>) = removePrices(removePrices.orElse(null)) /** * Plan prices to be removed from the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) */ - fun removePrices(removePrices: JsonField>) = apply { + fun removePrices(removePrices: JsonField>) = apply { body.removePrices(removePrices) } @@ -2429,36 +2421,40 @@ private constructor( * Plan prices to be removed from the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) */ - fun addRemovePrice(removePrice: RemovePrice) = apply { body.addRemovePrice(removePrice) } + fun addRemovePrice(removePrice: RemoveSubscriptionPriceParams) = apply { + body.addRemovePrice(removePrice) + } /** * Plan adjustments to be replaced with additional adjustments on the subscription. (Only * available for accounts that have migrated off of legacy subscription overrides) */ - fun replaceAdjustments(replaceAdjustments: List?) = apply { - body.replaceAdjustments(replaceAdjustments) - } + fun replaceAdjustments(replaceAdjustments: List?) = + apply { + body.replaceAdjustments(replaceAdjustments) + } /** * Plan adjustments to be replaced with additional adjustments on the subscription. (Only * available for accounts that have migrated off of legacy subscription overrides) */ - fun replaceAdjustments(replaceAdjustments: Optional>) = - replaceAdjustments(replaceAdjustments.orElse(null)) + fun replaceAdjustments( + replaceAdjustments: Optional> + ) = replaceAdjustments(replaceAdjustments.orElse(null)) /** * Plan adjustments to be replaced with additional adjustments on the subscription. (Only * available for accounts that have migrated off of legacy subscription overrides) */ - fun replaceAdjustments(replaceAdjustments: JsonField>) = apply { - body.replaceAdjustments(replaceAdjustments) - } + fun replaceAdjustments( + replaceAdjustments: JsonField> + ) = apply { body.replaceAdjustments(replaceAdjustments) } /** * Plan adjustments to be replaced with additional adjustments on the subscription. (Only * available for accounts that have migrated off of legacy subscription overrides) */ - fun addReplaceAdjustment(replaceAdjustment: ReplaceAdjustment) = apply { + fun addReplaceAdjustment(replaceAdjustment: ReplaceSubscriptionAdjustmentParams) = apply { body.addReplaceAdjustment(replaceAdjustment) } @@ -2466,7 +2462,7 @@ private constructor( * Plan prices to be replaced with additional prices on the subscription. (Only available * for accounts that have migrated off of legacy subscription overrides) */ - fun replacePrices(replacePrices: List?) = apply { + fun replacePrices(replacePrices: List?) = apply { body.replacePrices(replacePrices) } @@ -2474,14 +2470,14 @@ private constructor( * Plan prices to be replaced with additional prices on the subscription. (Only available * for accounts that have migrated off of legacy subscription overrides) */ - fun replacePrices(replacePrices: Optional>) = + fun replacePrices(replacePrices: Optional>) = replacePrices(replacePrices.orElse(null)) /** * Plan prices to be replaced with additional prices on the subscription. (Only available * for accounts that have migrated off of legacy subscription overrides) */ - fun replacePrices(replacePrices: JsonField>) = apply { + fun replacePrices(replacePrices: JsonField>) = apply { body.replacePrices(replacePrices) } @@ -2489,7 +2485,7 @@ private constructor( * Plan prices to be replaced with additional prices on the subscription. (Only available * for accounts that have migrated off of legacy subscription overrides) */ - fun addReplacePrice(replacePrice: ReplacePrice) = apply { + fun addReplacePrice(replacePrice: ReplaceSubscriptionPriceParams) = apply { body.addReplacePrice(replacePrice) } @@ -2799,68005 +2795,117 @@ private constructor( override fun toString() = value.toString() } - @NoAutoDetect - class AddAdjustment + /** + * 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( - @JsonProperty("adjustment") - @ExcludeMissing - private val adjustment: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") - - /** - * The end date of the adjustment interval. This is the date that the adjustment will stop - * affecting prices on the subscription. - */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** The phase to add this adjustment to. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** - * The start date of the adjustment interval. This is the date that the adjustment will - * start affecting prices on the subscription. If null, the adjustment will start when the - * phase or subscription starts. - */ - fun startDate(): Optional = - Optional.ofNullable(startDate.getNullable("start_date")) - - /** The definition of a new adjustment to create and add to the subscription. */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment + private constructor(private val value: JsonField) : Enum { /** - * The end date of the adjustment interval. This is the date that the adjustment will stop - * affecting prices on the subscription. + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** The phase to add this adjustment to. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** - * The start date of the adjustment interval. This is the date that the adjustment will - * start affecting prices on the subscription. If null, the adjustment will start when the - * phase or subscription starts. - */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate + companion object { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + @JvmField val UNCHANGED = of("unchanged") - private var validated: Boolean = false + @JvmField val PLAN_CHANGE_DATE = of("plan_change_date") - fun validate(): AddAdjustment = apply { - if (validated) { - return@apply - } + @JvmField val START_OF_MONTH = of("start_of_month") - adjustment().validate() - endDate() - planPhaseOrder() - startDate() - validated = true + @JvmStatic fun of(value: String) = BillingCycleAlignment(JsonField.of(value)) } - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() + /** An enum containing [BillingCycleAlignment]'s known values. */ + enum class Known { + UNCHANGED, + PLAN_CHANGE_DATE, + START_OF_MONTH, } - /** A builder for [AddAdjustment]. */ - class Builder internal constructor() { - - private var adjustment: JsonField? = null - private var endDate: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(addAdjustment: AddAdjustment) = apply { - adjustment = addAdjustment.adjustment - endDate = addAdjustment.endDate - planPhaseOrder = addAdjustment.planPhaseOrder - startDate = addAdjustment.startDate - additionalProperties = addAdjustment.additionalProperties.toMutableMap() - } - - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) - - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } - - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(newPercentageDiscount: Adjustment.NewPercentageDiscount) = - adjustment(Adjustment.ofNewPercentageDiscount(newPercentageDiscount)) - - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(newUsageDiscount: Adjustment.NewUsageDiscount) = - adjustment(Adjustment.ofNewUsageDiscount(newUsageDiscount)) - - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(newAmountDiscount: Adjustment.NewAmountDiscount) = - adjustment(Adjustment.ofNewAmountDiscount(newAmountDiscount)) - - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(newMinimum: Adjustment.NewMinimum) = - adjustment(Adjustment.ofNewMinimum(newMinimum)) - - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(newMaximum: Adjustment.NewMaximum) = - adjustment(Adjustment.ofNewMaximum(newMaximum)) - - /** - * The end date of the adjustment interval. This is the date that the adjustment will - * stop affecting prices on the subscription. - */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** - * The end date of the adjustment interval. This is the date that the adjustment will - * stop affecting prices on the subscription. - */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** - * The end date of the adjustment interval. This is the date that the adjustment will - * stop affecting prices on the subscription. - */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** The phase to add this adjustment to. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The phase to add this adjustment to. */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - - /** The phase to add this adjustment to. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The phase to add this adjustment to. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** - * The start date of the adjustment interval. This is the date that the adjustment will - * start affecting prices on the subscription. If null, the adjustment will start when - * the phase or subscription starts. - */ - fun startDate(startDate: OffsetDateTime?) = startDate(JsonField.ofNullable(startDate)) - - /** - * The start date of the adjustment interval. This is the date that the adjustment will - * start affecting prices on the subscription. If null, the adjustment will start when - * the phase or subscription starts. - */ - fun startDate(startDate: Optional) = startDate(startDate.orElse(null)) - + /** + * 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, /** - * The start date of the adjustment interval. This is the date that the adjustment will - * start affecting prices on the subscription. If null, the adjustment will start when - * the phase or subscription starts. + * An enum member indicating that [BillingCycleAlignment] was instantiated with an + * unknown 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) - } - - fun build(): AddAdjustment = - AddAdjustment( - checkRequired("adjustment", adjustment), - endDate, - planPhaseOrder, - startDate, - additionalProperties.toImmutable(), - ) + _UNKNOWN, } - /** 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 newPercentageDiscount: NewPercentageDiscount? = null, - private val newUsageDiscount: NewUsageDiscount? = null, - private val newAmountDiscount: NewAmountDiscount? = null, - private val newMinimum: NewMinimum? = null, - private val newMaximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { - - fun newPercentageDiscount(): Optional = - Optional.ofNullable(newPercentageDiscount) - - fun newUsageDiscount(): Optional = - Optional.ofNullable(newUsageDiscount) - - fun newAmountDiscount(): Optional = - Optional.ofNullable(newAmountDiscount) - - fun newMinimum(): Optional = Optional.ofNullable(newMinimum) - - fun newMaximum(): Optional = Optional.ofNullable(newMaximum) - - fun isNewPercentageDiscount(): Boolean = newPercentageDiscount != null - - fun isNewUsageDiscount(): Boolean = newUsageDiscount != null - - fun isNewAmountDiscount(): Boolean = newAmountDiscount != null - - fun isNewMinimum(): Boolean = newMinimum != null - - fun isNewMaximum(): Boolean = newMaximum != null - - fun asNewPercentageDiscount(): NewPercentageDiscount = - newPercentageDiscount.getOrThrow("newPercentageDiscount") - - fun asNewUsageDiscount(): NewUsageDiscount = - newUsageDiscount.getOrThrow("newUsageDiscount") - - fun asNewAmountDiscount(): NewAmountDiscount = - newAmountDiscount.getOrThrow("newAmountDiscount") - - fun asNewMinimum(): NewMinimum = newMinimum.getOrThrow("newMinimum") - - fun asNewMaximum(): NewMaximum = newMaximum.getOrThrow("newMaximum") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - newPercentageDiscount != null -> - visitor.visitNewPercentageDiscount(newPercentageDiscount) - newUsageDiscount != null -> visitor.visitNewUsageDiscount(newUsageDiscount) - newAmountDiscount != null -> visitor.visitNewAmountDiscount(newAmountDiscount) - newMinimum != null -> visitor.visitNewMinimum(newMinimum) - newMaximum != null -> visitor.visitNewMaximum(newMaximum) - else -> visitor.unknown(_json) - } + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + UNCHANGED -> Value.UNCHANGED + PLAN_CHANGE_DATE -> Value.PLAN_CHANGE_DATE + START_OF_MONTH -> Value.START_OF_MONTH + else -> Value._UNKNOWN } - private var validated: Boolean = false - - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitNewPercentageDiscount( - newPercentageDiscount: NewPercentageDiscount - ) { - newPercentageDiscount.validate() - } - - override fun visitNewUsageDiscount(newUsageDiscount: NewUsageDiscount) { - newUsageDiscount.validate() - } - - override fun visitNewAmountDiscount(newAmountDiscount: NewAmountDiscount) { - newAmountDiscount.validate() - } - - override fun visitNewMinimum(newMinimum: NewMinimum) { - newMinimum.validate() - } - - override fun visitNewMaximum(newMaximum: NewMaximum) { - newMaximum.validate() - } - } - ) - 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) { + UNCHANGED -> Known.UNCHANGED + PLAN_CHANGE_DATE -> Known.PLAN_CHANGE_DATE + START_OF_MONTH -> Known.START_OF_MONTH + else -> throw OrbInvalidDataException("Unknown BillingCycleAlignment: $value") } - override fun equals(other: Any?): Boolean { - if (this === other) { - return 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") } - return /* spotless:off */ other is Adjustment && newPercentageDiscount == other.newPercentageDiscount && newUsageDiscount == other.newUsageDiscount && newAmountDiscount == other.newAmountDiscount && newMinimum == other.newMinimum && newMaximum == other.newMaximum /* spotless:on */ + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(newPercentageDiscount, newUsageDiscount, newAmountDiscount, newMinimum, newMaximum) /* spotless:on */ - - override fun toString(): String = - when { - newPercentageDiscount != null -> - "Adjustment{newPercentageDiscount=$newPercentageDiscount}" - newUsageDiscount != null -> "Adjustment{newUsageDiscount=$newUsageDiscount}" - newAmountDiscount != null -> "Adjustment{newAmountDiscount=$newAmountDiscount}" - newMinimum != null -> "Adjustment{newMinimum=$newMinimum}" - newMaximum != null -> "Adjustment{newMaximum=$newMaximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } - - companion object { - - @JvmStatic - fun ofNewPercentageDiscount(newPercentageDiscount: NewPercentageDiscount) = - Adjustment(newPercentageDiscount = newPercentageDiscount) - - @JvmStatic - fun ofNewUsageDiscount(newUsageDiscount: NewUsageDiscount) = - Adjustment(newUsageDiscount = newUsageDiscount) + return /* spotless:off */ other is BillingCycleAlignment && value == other.value /* spotless:on */ + } - @JvmStatic - fun ofNewAmountDiscount(newAmountDiscount: NewAmountDiscount) = - Adjustment(newAmountDiscount = newAmountDiscount) + override fun hashCode() = value.hashCode() - @JvmStatic - fun ofNewMinimum(newMinimum: NewMinimum) = Adjustment(newMinimum = newMinimum) - - @JvmStatic - fun ofNewMaximum(newMaximum: NewMaximum) = Adjustment(newMaximum = newMaximum) - } - - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { - - fun visitNewPercentageDiscount(newPercentageDiscount: NewPercentageDiscount): T - - fun visitNewUsageDiscount(newUsageDiscount: NewUsageDiscount): T - - fun visitNewAmountDiscount(newAmountDiscount: NewAmountDiscount): T - - fun visitNewMinimum(newMinimum: NewMinimum): T - - fun visitNewMaximum(newMaximum: 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" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(newPercentageDiscount = it, _json = json) - } - } - "usage_discount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(newUsageDiscount = it, _json = json) - } - } - "amount_discount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(newAmountDiscount = it, _json = json) - } - } - "minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Adjustment(newMinimum = it, _json = json) - } - } - "maximum" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Adjustment(newMaximum = it, _json = json) - } - } - } - - return Adjustment(_json = json) - } - } - - internal class Serializer : BaseSerializer(Adjustment::class) { - - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.newPercentageDiscount != null -> - generator.writeObject(value.newPercentageDiscount) - value.newUsageDiscount != null -> - generator.writeObject(value.newUsageDiscount) - value.newAmountDiscount != null -> - generator.writeObject(value.newAmountDiscount) - value.newMinimum != null -> generator.writeObject(value.newMinimum) - value.newMaximum != null -> generator.writeObject(value.newMaximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") - } - } - } - - @NoAutoDetect - class NewPercentageDiscount - @JsonCreator - private constructor( - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("percentage_discount") - @ExcludeMissing - private val percentageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - fun percentageDiscount(): Double = - percentageDiscount.getRequired("percentage_discount") - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(): Optional = - Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The set of price IDs to which this adjustment applies. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - @JsonProperty("percentage_discount") - @ExcludeMissing - fun _percentageDiscount(): JsonField = percentageDiscount - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewPercentageDiscount = apply { - if (validated) { - return@apply - } - - adjustmentType() - appliesToPriceIds() - percentageDiscount() - isInvoiceLevel() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewPercentageDiscount]. */ - class Builder internal constructor() { - - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var percentageDiscount: JsonField? = null - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newPercentageDiscount: NewPercentageDiscount) = apply { - adjustmentType = newPercentageDiscount.adjustmentType - appliesToPriceIds = - newPercentageDiscount.appliesToPriceIds.map { it.toMutableList() } - percentageDiscount = newPercentageDiscount.percentageDiscount - isInvoiceLevel = newPercentageDiscount.isInvoiceLevel - additionalProperties = - newPercentageDiscount.additionalProperties.toMutableMap() - } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The set of price IDs to which this adjustment applies. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - fun percentageDiscount(percentageDiscount: Double) = - percentageDiscount(JsonField.of(percentageDiscount)) - - fun percentageDiscount(percentageDiscount: JsonField) = apply { - this.percentageDiscount = percentageDiscount - } - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): NewPercentageDiscount = - NewPercentageDiscount( - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("percentageDiscount", percentageDiscount), - isInvoiceLevel, - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val PERCENTAGE_DISCOUNT = of("percentage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewPercentageDiscount && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && percentageDiscount == other.percentageDiscount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustmentType, appliesToPriceIds, percentageDiscount, isInvoiceLevel, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewPercentageDiscount{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, percentageDiscount=$percentageDiscount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewUsageDiscount - @JsonCreator - private constructor( - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("usage_discount") - @ExcludeMissing - private val usageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(): Optional = - Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The set of price IDs to which this adjustment applies. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - @JsonProperty("usage_discount") - @ExcludeMissing - fun _usageDiscount(): JsonField = usageDiscount - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewUsageDiscount = apply { - if (validated) { - return@apply - } - - adjustmentType() - appliesToPriceIds() - usageDiscount() - isInvoiceLevel() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewUsageDiscount]. */ - class Builder internal constructor() { - - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var usageDiscount: JsonField? = null - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newUsageDiscount: NewUsageDiscount) = apply { - adjustmentType = newUsageDiscount.adjustmentType - appliesToPriceIds = - newUsageDiscount.appliesToPriceIds.map { it.toMutableList() } - usageDiscount = newUsageDiscount.usageDiscount - isInvoiceLevel = newUsageDiscount.isInvoiceLevel - additionalProperties = newUsageDiscount.additionalProperties.toMutableMap() - } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The set of price IDs to which this adjustment applies. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - fun usageDiscount(usageDiscount: Double) = - usageDiscount(JsonField.of(usageDiscount)) - - fun usageDiscount(usageDiscount: JsonField) = apply { - this.usageDiscount = usageDiscount - } - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): NewUsageDiscount = - NewUsageDiscount( - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("usageDiscount", usageDiscount), - isInvoiceLevel, - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - USAGE_DISCOUNT -> Known.USAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewUsageDiscount && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && usageDiscount == other.usageDiscount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustmentType, appliesToPriceIds, usageDiscount, isInvoiceLevel, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewUsageDiscount{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, usageDiscount=$usageDiscount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewAmountDiscount - @JsonCreator - private constructor( - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("amount_discount") - @ExcludeMissing - private val amountDiscount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(): Optional = - Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - @JsonProperty("amount_discount") - @ExcludeMissing - fun _amountDiscount(): JsonField = amountDiscount - - /** The set of price IDs to which this adjustment applies. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewAmountDiscount = apply { - if (validated) { - return@apply - } - - adjustmentType() - amountDiscount() - appliesToPriceIds() - isInvoiceLevel() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewAmountDiscount]. */ - class Builder internal constructor() { - - private var adjustmentType: JsonField? = null - private var amountDiscount: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newAmountDiscount: NewAmountDiscount) = apply { - adjustmentType = newAmountDiscount.adjustmentType - amountDiscount = newAmountDiscount.amountDiscount - appliesToPriceIds = - newAmountDiscount.appliesToPriceIds.map { it.toMutableList() } - isInvoiceLevel = newAmountDiscount.isInvoiceLevel - additionalProperties = newAmountDiscount.additionalProperties.toMutableMap() - } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - fun amountDiscount(amountDiscount: String) = - amountDiscount(JsonField.of(amountDiscount)) - - fun amountDiscount(amountDiscount: JsonField) = apply { - this.amountDiscount = amountDiscount - } - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The set of price IDs to which this adjustment applies. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): NewAmountDiscount = - NewAmountDiscount( - checkRequired("adjustmentType", adjustmentType), - checkRequired("amountDiscount", amountDiscount), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - isInvoiceLevel, - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewAmountDiscount && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustmentType, amountDiscount, appliesToPriceIds, isInvoiceLevel, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewAmountDiscount{adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewMinimum - @JsonCreator - private constructor( - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(): Optional = - Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The set of price IDs to which this adjustment applies. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The item ID that revenue from this minimum will be attributed to. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewMinimum = apply { - if (validated) { - return@apply - } - - adjustmentType() - appliesToPriceIds() - itemId() - minimumAmount() - isInvoiceLevel() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewMinimum]. */ - class Builder internal constructor() { - - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var itemId: JsonField? = null - private var minimumAmount: JsonField? = null - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newMinimum: NewMinimum) = apply { - adjustmentType = newMinimum.adjustmentType - appliesToPriceIds = newMinimum.appliesToPriceIds.map { it.toMutableList() } - itemId = newMinimum.itemId - minimumAmount = newMinimum.minimumAmount - isInvoiceLevel = newMinimum.isInvoiceLevel - additionalProperties = newMinimum.additionalProperties.toMutableMap() - } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The set of price IDs to which this adjustment applies. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): NewMinimum = - NewMinimum( - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("itemId", itemId), - checkRequired("minimumAmount", minimumAmount), - isInvoiceLevel, - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewMinimum && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && itemId == other.itemId && minimumAmount == other.minimumAmount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustmentType, appliesToPriceIds, itemId, minimumAmount, isInvoiceLevel, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewMinimum{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, itemId=$itemId, minimumAmount=$minimumAmount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewMaximum - @JsonCreator - private constructor( - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(): Optional = - Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The set of price IDs to which this adjustment applies. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewMaximum = apply { - if (validated) { - return@apply - } - - adjustmentType() - appliesToPriceIds() - maximumAmount() - isInvoiceLevel() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewMaximum]. */ - class Builder internal constructor() { - - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newMaximum: NewMaximum) = apply { - adjustmentType = newMaximum.adjustmentType - appliesToPriceIds = newMaximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = newMaximum.maximumAmount - isInvoiceLevel = newMaximum.isInvoiceLevel - additionalProperties = newMaximum.additionalProperties.toMutableMap() - } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The set of price IDs to which this adjustment applies. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): NewMaximum = - NewMaximum( - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("maximumAmount", maximumAmount), - isInvoiceLevel, - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewMaximum && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustmentType, appliesToPriceIds, maximumAmount, isInvoiceLevel, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewMaximum{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AddAdjustment && adjustment == other.adjustment && endDate == other.endDate && planPhaseOrder == other.planPhaseOrder && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustment, endDate, planPhaseOrder, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AddAdjustment{adjustment=$adjustment, endDate=$endDate, planPhaseOrder=$planPhaseOrder, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class AddPrice - @JsonCreator - private constructor( - @JsonProperty("allocation_price") - @ExcludeMissing - private val allocationPrice: JsonField = JsonMissing.of(), - @JsonProperty("discounts") - @ExcludeMissing - private val discounts: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("price") - @ExcludeMissing - private val price: JsonField = JsonMissing.of(), - @JsonProperty("price_id") - @ExcludeMissing - private val priceId: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The definition of a new allocation price to create and add to the subscription. */ - fun allocationPrice(): Optional = - Optional.ofNullable(allocationPrice.getNullable("allocation_price")) - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for this price. - */ - @Deprecated("deprecated") - fun discounts(): Optional> = - Optional.ofNullable(discounts.getNullable("discounts")) - - /** - * The end date of the price interval. This is the date that the price will stop billing on - * the subscription. If null, billing will end when the phase or subscription ends. - */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** The external price id of the price to add to the subscription. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for this - * price. - */ - @Deprecated("deprecated") - fun maximumAmount(): Optional = - Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for this - * price. - */ - @Deprecated("deprecated") - fun minimumAmount(): Optional = - Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) - - /** The phase to add this price to. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The definition of a new price to create and add to the subscription. */ - fun price(): Optional = Optional.ofNullable(price.getNullable("price")) - - /** The id of the price to add to the subscription. */ - fun priceId(): Optional = Optional.ofNullable(priceId.getNullable("price_id")) - - /** - * The start date of the price interval. This is the date that the price will start billing - * on the subscription. If null, billing will start when the phase or subscription starts. - */ - fun startDate(): Optional = - Optional.ofNullable(startDate.getNullable("start_date")) - - /** The definition of a new allocation price to create and add to the subscription. */ - @JsonProperty("allocation_price") - @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for this price. - */ - @Deprecated("deprecated") - @JsonProperty("discounts") - @ExcludeMissing - fun _discounts(): JsonField> = discounts - - /** - * The end date of the price interval. This is the date that the price will stop billing on - * the subscription. If null, billing will end when the phase or subscription ends. - */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** The external price id of the price to add to the subscription. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for this - * price. - */ - @Deprecated("deprecated") - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for this - * price. - */ - @Deprecated("deprecated") - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** The phase to add this price to. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The definition of a new price to create and add to the subscription. */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - - /** The id of the price to add to the subscription. */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - - /** - * The start date of the price interval. This is the date that the price will start billing - * on the subscription. If null, billing will start when the phase or subscription starts. - */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AddPrice = apply { - if (validated) { - return@apply - } - - allocationPrice().ifPresent { it.validate() } - discounts().ifPresent { it.forEach { it.validate() } } - endDate() - externalPriceId() - maximumAmount() - minimumAmount() - planPhaseOrder() - price().ifPresent { it.validate() } - priceId() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AddPrice]. */ - class Builder internal constructor() { - - private var allocationPrice: JsonField = JsonMissing.of() - private var discounts: JsonField>? = null - private var endDate: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(addPrice: AddPrice) = apply { - allocationPrice = addPrice.allocationPrice - discounts = addPrice.discounts.map { it.toMutableList() } - endDate = addPrice.endDate - externalPriceId = addPrice.externalPriceId - maximumAmount = addPrice.maximumAmount - minimumAmount = addPrice.minimumAmount - planPhaseOrder = addPrice.planPhaseOrder - price = addPrice.price - priceId = addPrice.priceId - startDate = addPrice.startDate - additionalProperties = addPrice.additionalProperties.toMutableMap() - } - - /** The definition of a new allocation price to create and add to the subscription. */ - fun allocationPrice(allocationPrice: AllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) - - /** The definition of a new allocation price to create and add to the subscription. */ - fun allocationPrice(allocationPrice: Optional) = - allocationPrice(allocationPrice.orElse(null)) - - /** The definition of a new allocation price to create and add to the subscription. */ - fun allocationPrice(allocationPrice: JsonField) = apply { - this.allocationPrice = allocationPrice - } - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for this - * price. - */ - @Deprecated("deprecated") - fun discounts(discounts: List?) = discounts(JsonField.ofNullable(discounts)) - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for this - * price. - */ - @Deprecated("deprecated") - fun discounts(discounts: Optional>) = discounts(discounts.orElse(null)) - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for this - * price. - */ - @Deprecated("deprecated") - fun discounts(discounts: JsonField>) = apply { - this.discounts = discounts.map { it.toMutableList() } - } - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for this - * price. - */ - @Deprecated("deprecated") - fun addDiscount(discount: Discount) = apply { - discounts = - (discounts ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(discount) - } - } - - /** - * The end date of the price interval. This is the date that the price will stop billing - * on the subscription. If null, billing will end when the phase or subscription ends. - */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** - * The end date of the price interval. This is the date that the price will stop billing - * on the subscription. If null, billing will end when the phase or subscription ends. - */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** - * The end date of the price interval. This is the date that the price will stop billing - * on the subscription. If null, billing will end when the phase or subscription ends. - */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** The external price id of the price to add to the subscription. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** The external price id of the price to add to the subscription. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** The external price id of the price to add to the subscription. */ - fun externalPriceId(externalPriceId: JsonField) = apply { - this.externalPriceId = externalPriceId - } - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for this - * price. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for this - * price. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.orElse(null)) - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for this - * price. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for this - * price. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for this - * price. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: Optional) = - minimumAmount(minimumAmount.orElse(null)) - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for this - * price. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** The phase to add this price to. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The phase to add this price to. */ - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) - - /** The phase to add this price to. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The phase to add this price to. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The definition of a new price to create and add to the subscription. */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(price: Optional) = price(price.orElse(null)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(price: JsonField) = apply { this.price = price } - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionUnit: Price.NewSubscriptionUnitPrice) = - price(Price.ofNewSubscriptionUnit(newSubscriptionUnit)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionPackage: Price.NewSubscriptionPackagePrice) = - price(Price.ofNewSubscriptionPackage(newSubscriptionPackage)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionMatrix: Price.NewSubscriptionMatrixPrice) = - price(Price.ofNewSubscriptionMatrix(newSubscriptionMatrix)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionTiered: Price.NewSubscriptionTieredPrice) = - price(Price.ofNewSubscriptionTiered(newSubscriptionTiered)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionTieredBps: Price.NewSubscriptionTieredBpsPrice) = - price(Price.ofNewSubscriptionTieredBps(newSubscriptionTieredBps)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionBps: Price.NewSubscriptionBpsPrice) = - price(Price.ofNewSubscriptionBps(newSubscriptionBps)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionBulkBps: Price.NewSubscriptionBulkBpsPrice) = - price(Price.ofNewSubscriptionBulkBps(newSubscriptionBulkBps)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionBulk: Price.NewSubscriptionBulkPrice) = - price(Price.ofNewSubscriptionBulk(newSubscriptionBulk)) - - /** The definition of a new price to create and add to the subscription. */ - fun price( - newSubscriptionThresholdTotalAmount: Price.NewSubscriptionThresholdTotalAmountPrice - ) = - price( - Price.ofNewSubscriptionThresholdTotalAmount(newSubscriptionThresholdTotalAmount) - ) - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionTieredPackage: Price.NewSubscriptionTieredPackagePrice) = - price(Price.ofNewSubscriptionTieredPackage(newSubscriptionTieredPackage)) - - /** The definition of a new price to create and add to the subscription. */ - fun price( - newSubscriptionTieredWithMinimum: Price.NewSubscriptionTieredWithMinimumPrice - ) = price(Price.ofNewSubscriptionTieredWithMinimum(newSubscriptionTieredWithMinimum)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionUnitWithPercent: Price.NewSubscriptionUnitWithPercentPrice) = - price(Price.ofNewSubscriptionUnitWithPercent(newSubscriptionUnitWithPercent)) - - /** The definition of a new price to create and add to the subscription. */ - fun price( - newSubscriptionPackageWithAllocation: - Price.NewSubscriptionPackageWithAllocationPrice - ) = - price( - Price.ofNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation - ) - ) - - /** The definition of a new price to create and add to the subscription. */ - fun price( - newSubscriptionTierWithProration: Price.NewSubscriptionTierWithProrationPrice - ) = price(Price.ofNewSubscriptionTierWithProration(newSubscriptionTierWithProration)) - - /** The definition of a new price to create and add to the subscription. */ - fun price( - newSubscriptionUnitWithProration: Price.NewSubscriptionUnitWithProrationPrice - ) = price(Price.ofNewSubscriptionUnitWithProration(newSubscriptionUnitWithProration)) - - /** The definition of a new price to create and add to the subscription. */ - fun price( - newSubscriptionGroupedAllocation: Price.NewSubscriptionGroupedAllocationPrice - ) = price(Price.ofNewSubscriptionGroupedAllocation(newSubscriptionGroupedAllocation)) - - /** The definition of a new price to create and add to the subscription. */ - fun price( - newSubscriptionGroupedWithProratedMinimum: - Price.NewSubscriptionGroupedWithProratedMinimumPrice - ) = - price( - Price.ofNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum - ) - ) - - /** The definition of a new price to create and add to the subscription. */ - fun price( - newSubscriptionBulkWithProration: Price.NewSubscriptionBulkWithProrationPrice - ) = price(Price.ofNewSubscriptionBulkWithProration(newSubscriptionBulkWithProration)) - - /** The id of the price to add to the subscription. */ - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) - - /** The id of the price to add to the subscription. */ - fun priceId(priceId: Optional) = priceId(priceId.orElse(null)) - - /** The id of the price to add to the subscription. */ - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - - /** - * The start date of the price interval. This is the date that the price will start - * billing on the subscription. If null, billing will start when the phase or - * subscription starts. - */ - fun startDate(startDate: OffsetDateTime?) = startDate(JsonField.ofNullable(startDate)) - - /** - * The start date of the price interval. This is the date that the price will start - * billing on the subscription. If null, billing will start when the phase or - * subscription starts. - */ - fun startDate(startDate: Optional) = startDate(startDate.orElse(null)) - - /** - * The start date of the price interval. This is the date that the price will start - * billing on the subscription. If null, billing will start when the phase or - * subscription starts. - */ - 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) - } - - fun build(): AddPrice = - AddPrice( - allocationPrice, - (discounts ?: JsonMissing.of()).map { it.toImmutable() }, - endDate, - externalPriceId, - maximumAmount, - minimumAmount, - planPhaseOrder, - price, - priceId, - startDate, - additionalProperties.toImmutable(), - ) - } - - /** The definition of a new allocation price to create and add to the subscription. */ - @NoAutoDetect - class AllocationPrice - @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("expires_at_end_of_cadence") - @ExcludeMissing - private val expiresAtEndOfCadence: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** An amount of the currency to allocate to the customer at the specified cadence. */ - fun amount(): String = amount.getRequired("amount") - - /** The cadence at which to allocate the amount to the customer. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** - * An ISO 4217 currency string or a custom pricing unit identifier in which to bill this - * price. - */ - fun currency(): String = currency.getRequired("currency") - - /** - * Whether the allocated amount should expire at the end of the cadence or roll over to - * the next period. - */ - fun expiresAtEndOfCadence(): Boolean = - expiresAtEndOfCadence.getRequired("expires_at_end_of_cadence") - - /** An amount of the currency to allocate to the customer at the specified cadence. */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** The cadence at which to allocate the amount to the customer. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** - * An ISO 4217 currency string or a custom pricing unit identifier in which to bill this - * price. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** - * Whether the allocated amount should expire at the end of the cadence or roll over to - * the next period. - */ - @JsonProperty("expires_at_end_of_cadence") - @ExcludeMissing - fun _expiresAtEndOfCadence(): JsonField = expiresAtEndOfCadence - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AllocationPrice = apply { - if (validated) { - return@apply - } - - amount() - cadence() - currency() - expiresAtEndOfCadence() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AllocationPrice]. */ - class Builder internal constructor() { - - private var amount: JsonField? = null - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var expiresAtEndOfCadence: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(allocationPrice: AllocationPrice) = apply { - amount = allocationPrice.amount - cadence = allocationPrice.cadence - currency = allocationPrice.currency - expiresAtEndOfCadence = allocationPrice.expiresAtEndOfCadence - additionalProperties = allocationPrice.additionalProperties.toMutableMap() - } - - /** - * An amount of the currency to allocate to the customer at the specified cadence. - */ - fun amount(amount: String) = amount(JsonField.of(amount)) - - /** - * An amount of the currency to allocate to the customer at the specified cadence. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** The cadence at which to allocate the amount to the customer. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence at which to allocate the amount to the customer. */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - /** - * An ISO 4217 currency string or a custom pricing unit identifier in which to bill - * this price. - */ - fun currency(currency: String) = currency(JsonField.of(currency)) - - /** - * An ISO 4217 currency string or a custom pricing unit identifier in which to bill - * this price. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** - * Whether the allocated amount should expire at the end of the cadence or roll over - * to the next period. - */ - fun expiresAtEndOfCadence(expiresAtEndOfCadence: Boolean) = - expiresAtEndOfCadence(JsonField.of(expiresAtEndOfCadence)) - - /** - * Whether the allocated amount should expire at the end of the cadence or roll over - * to the next period. - */ - fun expiresAtEndOfCadence(expiresAtEndOfCadence: JsonField) = apply { - this.expiresAtEndOfCadence = expiresAtEndOfCadence - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): AllocationPrice = - AllocationPrice( - checkRequired("amount", amount), - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("expiresAtEndOfCadence", expiresAtEndOfCadence), - additionalProperties.toImmutable(), - ) - } - - /** The cadence at which to allocate the amount to the customer. */ - 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AllocationPrice && amount == other.amount && cadence == other.cadence && currency == other.currency && expiresAtEndOfCadence == other.expiresAtEndOfCadence && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, cadence, currency, expiresAtEndOfCadence, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AllocationPrice{amount=$amount, cadence=$cadence, currency=$currency, expiresAtEndOfCadence=$expiresAtEndOfCadence, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Discount - @JsonCreator - private constructor( - @JsonProperty("discount_type") - @ExcludeMissing - private val discountType: JsonField = JsonMissing.of(), - @JsonProperty("amount_discount") - @ExcludeMissing - private val amountDiscount: JsonField = JsonMissing.of(), - @JsonProperty("percentage_discount") - @ExcludeMissing - private val percentageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("usage_discount") - @ExcludeMissing - private val usageDiscount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun discountType(): DiscountType = discountType.getRequired("discount_type") - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(): Optional = - Optional.ofNullable(amountDiscount.getNullable("amount_discount")) - - /** - * Only available if discount_type is `percentage`. This is a number between 0 and 1. - */ - fun percentageDiscount(): Optional = - Optional.ofNullable(percentageDiscount.getNullable("percentage_discount")) - - /** - * Only available if discount_type is `usage`. Number of usage units that this discount - * is for - */ - fun usageDiscount(): Optional = - Optional.ofNullable(usageDiscount.getNullable("usage_discount")) - - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - - /** Only available if discount_type is `amount`. */ - @JsonProperty("amount_discount") - @ExcludeMissing - fun _amountDiscount(): JsonField = amountDiscount - - /** - * Only available if discount_type is `percentage`. This is a number between 0 and 1. - */ - @JsonProperty("percentage_discount") - @ExcludeMissing - fun _percentageDiscount(): JsonField = percentageDiscount - - /** - * Only available if discount_type is `usage`. Number of usage units that this discount - * is for - */ - @JsonProperty("usage_discount") - @ExcludeMissing - fun _usageDiscount(): JsonField = usageDiscount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Discount = apply { - if (validated) { - return@apply - } - - discountType() - amountDiscount() - percentageDiscount() - usageDiscount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Discount]. */ - class Builder internal constructor() { - - private var discountType: JsonField? = null - private var amountDiscount: JsonField = JsonMissing.of() - private var percentageDiscount: JsonField = JsonMissing.of() - private var usageDiscount: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(discount: Discount) = apply { - discountType = discount.discountType - amountDiscount = discount.amountDiscount - percentageDiscount = discount.percentageDiscount - usageDiscount = discount.usageDiscount - additionalProperties = discount.additionalProperties.toMutableMap() - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(amountDiscount: String?) = - amountDiscount(JsonField.ofNullable(amountDiscount)) - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(amountDiscount: Optional) = - amountDiscount(amountDiscount.orElse(null)) - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(amountDiscount: JsonField) = apply { - this.amountDiscount = amountDiscount - } - - /** - * Only available if discount_type is `percentage`. This is a number between 0 - * and 1. - */ - fun percentageDiscount(percentageDiscount: Double?) = - percentageDiscount(JsonField.ofNullable(percentageDiscount)) - - /** - * Only available if discount_type is `percentage`. This is a number between 0 - * and 1. - */ - fun percentageDiscount(percentageDiscount: Double) = - percentageDiscount(percentageDiscount as Double?) - - /** - * Only available if discount_type is `percentage`. This is a number between 0 - * and 1. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun percentageDiscount(percentageDiscount: Optional) = - percentageDiscount(percentageDiscount.orElse(null) as Double?) - - /** - * Only available if discount_type is `percentage`. This is a number between 0 - * and 1. - */ - fun percentageDiscount(percentageDiscount: JsonField) = apply { - this.percentageDiscount = percentageDiscount - } - - /** - * Only available if discount_type is `usage`. Number of usage units that this - * discount is for - */ - fun usageDiscount(usageDiscount: Double?) = - usageDiscount(JsonField.ofNullable(usageDiscount)) - - /** - * Only available if discount_type is `usage`. Number of usage units that this - * discount is for - */ - fun usageDiscount(usageDiscount: Double) = usageDiscount(usageDiscount as Double?) - - /** - * Only available if discount_type is `usage`. Number of usage units that this - * discount is for - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun usageDiscount(usageDiscount: Optional) = - usageDiscount(usageDiscount.orElse(null) as Double?) - - /** - * Only available if discount_type is `usage`. Number of usage units that this - * discount is for - */ - fun usageDiscount(usageDiscount: JsonField) = apply { - this.usageDiscount = usageDiscount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Discount = - Discount( - checkRequired("discountType", discountType), - amountDiscount, - percentageDiscount, - usageDiscount, - additionalProperties.toImmutable(), - ) - } - - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val PERCENTAGE = of("percentage") - - @JvmField val USAGE = of("usage") - - @JvmField val AMOUNT = of("amount") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - PERCENTAGE, - USAGE, - AMOUNT, - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE, - USAGE, - AMOUNT, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE -> Value.PERCENTAGE - USAGE -> Value.USAGE - AMOUNT -> Value.AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PERCENTAGE -> Known.PERCENTAGE - USAGE -> Known.USAGE - AMOUNT -> Known.AMOUNT - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Discount && discountType == other.discountType && amountDiscount == other.amountDiscount && percentageDiscount == other.percentageDiscount && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(discountType, amountDiscount, percentageDiscount, usageDiscount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Discount{discountType=$discountType, amountDiscount=$amountDiscount, percentageDiscount=$percentageDiscount, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" - } - - /** The definition of a new price to create and add to the subscription. */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price - private constructor( - private val newSubscriptionUnit: NewSubscriptionUnitPrice? = null, - private val newSubscriptionPackage: NewSubscriptionPackagePrice? = null, - private val newSubscriptionMatrix: NewSubscriptionMatrixPrice? = null, - private val newSubscriptionTiered: NewSubscriptionTieredPrice? = null, - private val newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice? = null, - private val newSubscriptionBps: NewSubscriptionBpsPrice? = null, - private val newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice? = null, - private val newSubscriptionBulk: NewSubscriptionBulkPrice? = null, - private val newSubscriptionThresholdTotalAmount: - NewSubscriptionThresholdTotalAmountPrice? = - null, - private val newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice? = null, - private val newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = - null, - private val newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, - private val newSubscriptionPackageWithAllocation: - NewSubscriptionPackageWithAllocationPrice? = - null, - private val newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice? = - null, - private val newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice? = - null, - private val newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice? = - null, - private val newSubscriptionGroupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice? = - null, - private val newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice? = - null, - private val _json: JsonValue? = null, - ) { - - fun newSubscriptionUnit(): Optional = - Optional.ofNullable(newSubscriptionUnit) - - fun newSubscriptionPackage(): Optional = - Optional.ofNullable(newSubscriptionPackage) - - fun newSubscriptionMatrix(): Optional = - Optional.ofNullable(newSubscriptionMatrix) - - fun newSubscriptionTiered(): Optional = - Optional.ofNullable(newSubscriptionTiered) - - fun newSubscriptionTieredBps(): Optional = - Optional.ofNullable(newSubscriptionTieredBps) - - fun newSubscriptionBps(): Optional = - Optional.ofNullable(newSubscriptionBps) - - fun newSubscriptionBulkBps(): Optional = - Optional.ofNullable(newSubscriptionBulkBps) - - fun newSubscriptionBulk(): Optional = - Optional.ofNullable(newSubscriptionBulk) - - fun newSubscriptionThresholdTotalAmount(): - Optional = - Optional.ofNullable(newSubscriptionThresholdTotalAmount) - - fun newSubscriptionTieredPackage(): Optional = - Optional.ofNullable(newSubscriptionTieredPackage) - - fun newSubscriptionTieredWithMinimum(): - Optional = - Optional.ofNullable(newSubscriptionTieredWithMinimum) - - fun newSubscriptionUnitWithPercent(): Optional = - Optional.ofNullable(newSubscriptionUnitWithPercent) - - fun newSubscriptionPackageWithAllocation(): - Optional = - Optional.ofNullable(newSubscriptionPackageWithAllocation) - - fun newSubscriptionTierWithProration(): - Optional = - Optional.ofNullable(newSubscriptionTierWithProration) - - fun newSubscriptionUnitWithProration(): - Optional = - Optional.ofNullable(newSubscriptionUnitWithProration) - - fun newSubscriptionGroupedAllocation(): - Optional = - Optional.ofNullable(newSubscriptionGroupedAllocation) - - fun newSubscriptionGroupedWithProratedMinimum(): - Optional = - Optional.ofNullable(newSubscriptionGroupedWithProratedMinimum) - - fun newSubscriptionBulkWithProration(): - Optional = - Optional.ofNullable(newSubscriptionBulkWithProration) - - fun isNewSubscriptionUnit(): Boolean = newSubscriptionUnit != null - - fun isNewSubscriptionPackage(): Boolean = newSubscriptionPackage != null - - fun isNewSubscriptionMatrix(): Boolean = newSubscriptionMatrix != null - - fun isNewSubscriptionTiered(): Boolean = newSubscriptionTiered != null - - fun isNewSubscriptionTieredBps(): Boolean = newSubscriptionTieredBps != null - - fun isNewSubscriptionBps(): Boolean = newSubscriptionBps != null - - fun isNewSubscriptionBulkBps(): Boolean = newSubscriptionBulkBps != null - - fun isNewSubscriptionBulk(): Boolean = newSubscriptionBulk != null - - fun isNewSubscriptionThresholdTotalAmount(): Boolean = - newSubscriptionThresholdTotalAmount != null - - fun isNewSubscriptionTieredPackage(): Boolean = newSubscriptionTieredPackage != null - - fun isNewSubscriptionTieredWithMinimum(): Boolean = - newSubscriptionTieredWithMinimum != null - - fun isNewSubscriptionUnitWithPercent(): Boolean = newSubscriptionUnitWithPercent != null - - fun isNewSubscriptionPackageWithAllocation(): Boolean = - newSubscriptionPackageWithAllocation != null - - fun isNewSubscriptionTierWithProration(): Boolean = - newSubscriptionTierWithProration != null - - fun isNewSubscriptionUnitWithProration(): Boolean = - newSubscriptionUnitWithProration != null - - fun isNewSubscriptionGroupedAllocation(): Boolean = - newSubscriptionGroupedAllocation != null - - fun isNewSubscriptionGroupedWithProratedMinimum(): Boolean = - newSubscriptionGroupedWithProratedMinimum != null - - fun isNewSubscriptionBulkWithProration(): Boolean = - newSubscriptionBulkWithProration != null - - fun asNewSubscriptionUnit(): NewSubscriptionUnitPrice = - newSubscriptionUnit.getOrThrow("newSubscriptionUnit") - - fun asNewSubscriptionPackage(): NewSubscriptionPackagePrice = - newSubscriptionPackage.getOrThrow("newSubscriptionPackage") - - fun asNewSubscriptionMatrix(): NewSubscriptionMatrixPrice = - newSubscriptionMatrix.getOrThrow("newSubscriptionMatrix") - - fun asNewSubscriptionTiered(): NewSubscriptionTieredPrice = - newSubscriptionTiered.getOrThrow("newSubscriptionTiered") - - fun asNewSubscriptionTieredBps(): NewSubscriptionTieredBpsPrice = - newSubscriptionTieredBps.getOrThrow("newSubscriptionTieredBps") - - fun asNewSubscriptionBps(): NewSubscriptionBpsPrice = - newSubscriptionBps.getOrThrow("newSubscriptionBps") - - fun asNewSubscriptionBulkBps(): NewSubscriptionBulkBpsPrice = - newSubscriptionBulkBps.getOrThrow("newSubscriptionBulkBps") - - fun asNewSubscriptionBulk(): NewSubscriptionBulkPrice = - newSubscriptionBulk.getOrThrow("newSubscriptionBulk") - - fun asNewSubscriptionThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = - newSubscriptionThresholdTotalAmount.getOrThrow( - "newSubscriptionThresholdTotalAmount" - ) - - fun asNewSubscriptionTieredPackage(): NewSubscriptionTieredPackagePrice = - newSubscriptionTieredPackage.getOrThrow("newSubscriptionTieredPackage") - - fun asNewSubscriptionTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = - newSubscriptionTieredWithMinimum.getOrThrow("newSubscriptionTieredWithMinimum") - - fun asNewSubscriptionUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = - newSubscriptionUnitWithPercent.getOrThrow("newSubscriptionUnitWithPercent") - - fun asNewSubscriptionPackageWithAllocation(): - NewSubscriptionPackageWithAllocationPrice = - newSubscriptionPackageWithAllocation.getOrThrow( - "newSubscriptionPackageWithAllocation" - ) - - fun asNewSubscriptionTierWithProration(): NewSubscriptionTierWithProrationPrice = - newSubscriptionTierWithProration.getOrThrow("newSubscriptionTierWithProration") - - fun asNewSubscriptionUnitWithProration(): NewSubscriptionUnitWithProrationPrice = - newSubscriptionUnitWithProration.getOrThrow("newSubscriptionUnitWithProration") - - fun asNewSubscriptionGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = - newSubscriptionGroupedAllocation.getOrThrow("newSubscriptionGroupedAllocation") - - fun asNewSubscriptionGroupedWithProratedMinimum(): - NewSubscriptionGroupedWithProratedMinimumPrice = - newSubscriptionGroupedWithProratedMinimum.getOrThrow( - "newSubscriptionGroupedWithProratedMinimum" - ) - - fun asNewSubscriptionBulkWithProration(): NewSubscriptionBulkWithProrationPrice = - newSubscriptionBulkWithProration.getOrThrow("newSubscriptionBulkWithProration") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - newSubscriptionUnit != null -> - visitor.visitNewSubscriptionUnit(newSubscriptionUnit) - newSubscriptionPackage != null -> - visitor.visitNewSubscriptionPackage(newSubscriptionPackage) - newSubscriptionMatrix != null -> - visitor.visitNewSubscriptionMatrix(newSubscriptionMatrix) - newSubscriptionTiered != null -> - visitor.visitNewSubscriptionTiered(newSubscriptionTiered) - newSubscriptionTieredBps != null -> - visitor.visitNewSubscriptionTieredBps(newSubscriptionTieredBps) - newSubscriptionBps != null -> - visitor.visitNewSubscriptionBps(newSubscriptionBps) - newSubscriptionBulkBps != null -> - visitor.visitNewSubscriptionBulkBps(newSubscriptionBulkBps) - newSubscriptionBulk != null -> - visitor.visitNewSubscriptionBulk(newSubscriptionBulk) - newSubscriptionThresholdTotalAmount != null -> - visitor.visitNewSubscriptionThresholdTotalAmount( - newSubscriptionThresholdTotalAmount - ) - newSubscriptionTieredPackage != null -> - visitor.visitNewSubscriptionTieredPackage(newSubscriptionTieredPackage) - newSubscriptionTieredWithMinimum != null -> - visitor.visitNewSubscriptionTieredWithMinimum( - newSubscriptionTieredWithMinimum - ) - newSubscriptionUnitWithPercent != null -> - visitor.visitNewSubscriptionUnitWithPercent(newSubscriptionUnitWithPercent) - newSubscriptionPackageWithAllocation != null -> - visitor.visitNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation - ) - newSubscriptionTierWithProration != null -> - visitor.visitNewSubscriptionTierWithProration( - newSubscriptionTierWithProration - ) - newSubscriptionUnitWithProration != null -> - visitor.visitNewSubscriptionUnitWithProration( - newSubscriptionUnitWithProration - ) - newSubscriptionGroupedAllocation != null -> - visitor.visitNewSubscriptionGroupedAllocation( - newSubscriptionGroupedAllocation - ) - newSubscriptionGroupedWithProratedMinimum != null -> - visitor.visitNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum - ) - newSubscriptionBulkWithProration != null -> - visitor.visitNewSubscriptionBulkWithProration( - newSubscriptionBulkWithProration - ) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): Price = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitNewSubscriptionUnit( - newSubscriptionUnit: NewSubscriptionUnitPrice - ) { - newSubscriptionUnit.validate() - } - - override fun visitNewSubscriptionPackage( - newSubscriptionPackage: NewSubscriptionPackagePrice - ) { - newSubscriptionPackage.validate() - } - - override fun visitNewSubscriptionMatrix( - newSubscriptionMatrix: NewSubscriptionMatrixPrice - ) { - newSubscriptionMatrix.validate() - } - - override fun visitNewSubscriptionTiered( - newSubscriptionTiered: NewSubscriptionTieredPrice - ) { - newSubscriptionTiered.validate() - } - - override fun visitNewSubscriptionTieredBps( - newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice - ) { - newSubscriptionTieredBps.validate() - } - - override fun visitNewSubscriptionBps( - newSubscriptionBps: NewSubscriptionBpsPrice - ) { - newSubscriptionBps.validate() - } - - override fun visitNewSubscriptionBulkBps( - newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice - ) { - newSubscriptionBulkBps.validate() - } - - override fun visitNewSubscriptionBulk( - newSubscriptionBulk: NewSubscriptionBulkPrice - ) { - newSubscriptionBulk.validate() - } - - override fun visitNewSubscriptionThresholdTotalAmount( - newSubscriptionThresholdTotalAmount: - NewSubscriptionThresholdTotalAmountPrice - ) { - newSubscriptionThresholdTotalAmount.validate() - } - - override fun visitNewSubscriptionTieredPackage( - newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice - ) { - newSubscriptionTieredPackage.validate() - } - - override fun visitNewSubscriptionTieredWithMinimum( - newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) { - newSubscriptionTieredWithMinimum.validate() - } - - override fun visitNewSubscriptionUnitWithPercent( - newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice - ) { - newSubscriptionUnitWithPercent.validate() - } - - override fun visitNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation: - NewSubscriptionPackageWithAllocationPrice - ) { - newSubscriptionPackageWithAllocation.validate() - } - - override fun visitNewSubscriptionTierWithProration( - newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice - ) { - newSubscriptionTierWithProration.validate() - } - - override fun visitNewSubscriptionUnitWithProration( - newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice - ) { - newSubscriptionUnitWithProration.validate() - } - - override fun visitNewSubscriptionGroupedAllocation( - newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice - ) { - newSubscriptionGroupedAllocation.validate() - } - - override fun visitNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) { - newSubscriptionGroupedWithProratedMinimum.validate() - } - - override fun visitNewSubscriptionBulkWithProration( - newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice - ) { - newSubscriptionBulkWithProration.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Price && newSubscriptionUnit == other.newSubscriptionUnit && newSubscriptionPackage == other.newSubscriptionPackage && newSubscriptionMatrix == other.newSubscriptionMatrix && newSubscriptionTiered == other.newSubscriptionTiered && newSubscriptionTieredBps == other.newSubscriptionTieredBps && newSubscriptionBps == other.newSubscriptionBps && newSubscriptionBulkBps == other.newSubscriptionBulkBps && newSubscriptionBulk == other.newSubscriptionBulk && newSubscriptionThresholdTotalAmount == other.newSubscriptionThresholdTotalAmount && newSubscriptionTieredPackage == other.newSubscriptionTieredPackage && newSubscriptionTieredWithMinimum == other.newSubscriptionTieredWithMinimum && newSubscriptionUnitWithPercent == other.newSubscriptionUnitWithPercent && newSubscriptionPackageWithAllocation == other.newSubscriptionPackageWithAllocation && newSubscriptionTierWithProration == other.newSubscriptionTierWithProration && newSubscriptionUnitWithProration == other.newSubscriptionUnitWithProration && newSubscriptionGroupedAllocation == other.newSubscriptionGroupedAllocation && newSubscriptionGroupedWithProratedMinimum == other.newSubscriptionGroupedWithProratedMinimum && newSubscriptionBulkWithProration == other.newSubscriptionBulkWithProration /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(newSubscriptionUnit, newSubscriptionPackage, newSubscriptionMatrix, newSubscriptionTiered, newSubscriptionTieredBps, newSubscriptionBps, newSubscriptionBulkBps, newSubscriptionBulk, newSubscriptionThresholdTotalAmount, newSubscriptionTieredPackage, newSubscriptionTieredWithMinimum, newSubscriptionUnitWithPercent, newSubscriptionPackageWithAllocation, newSubscriptionTierWithProration, newSubscriptionUnitWithProration, newSubscriptionGroupedAllocation, newSubscriptionGroupedWithProratedMinimum, newSubscriptionBulkWithProration) /* spotless:on */ - - override fun toString(): String = - when { - newSubscriptionUnit != null -> "Price{newSubscriptionUnit=$newSubscriptionUnit}" - newSubscriptionPackage != null -> - "Price{newSubscriptionPackage=$newSubscriptionPackage}" - newSubscriptionMatrix != null -> - "Price{newSubscriptionMatrix=$newSubscriptionMatrix}" - newSubscriptionTiered != null -> - "Price{newSubscriptionTiered=$newSubscriptionTiered}" - newSubscriptionTieredBps != null -> - "Price{newSubscriptionTieredBps=$newSubscriptionTieredBps}" - newSubscriptionBps != null -> "Price{newSubscriptionBps=$newSubscriptionBps}" - newSubscriptionBulkBps != null -> - "Price{newSubscriptionBulkBps=$newSubscriptionBulkBps}" - newSubscriptionBulk != null -> "Price{newSubscriptionBulk=$newSubscriptionBulk}" - newSubscriptionThresholdTotalAmount != null -> - "Price{newSubscriptionThresholdTotalAmount=$newSubscriptionThresholdTotalAmount}" - newSubscriptionTieredPackage != null -> - "Price{newSubscriptionTieredPackage=$newSubscriptionTieredPackage}" - newSubscriptionTieredWithMinimum != null -> - "Price{newSubscriptionTieredWithMinimum=$newSubscriptionTieredWithMinimum}" - newSubscriptionUnitWithPercent != null -> - "Price{newSubscriptionUnitWithPercent=$newSubscriptionUnitWithPercent}" - newSubscriptionPackageWithAllocation != null -> - "Price{newSubscriptionPackageWithAllocation=$newSubscriptionPackageWithAllocation}" - newSubscriptionTierWithProration != null -> - "Price{newSubscriptionTierWithProration=$newSubscriptionTierWithProration}" - newSubscriptionUnitWithProration != null -> - "Price{newSubscriptionUnitWithProration=$newSubscriptionUnitWithProration}" - newSubscriptionGroupedAllocation != null -> - "Price{newSubscriptionGroupedAllocation=$newSubscriptionGroupedAllocation}" - newSubscriptionGroupedWithProratedMinimum != null -> - "Price{newSubscriptionGroupedWithProratedMinimum=$newSubscriptionGroupedWithProratedMinimum}" - newSubscriptionBulkWithProration != null -> - "Price{newSubscriptionBulkWithProration=$newSubscriptionBulkWithProration}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") - } - - companion object { - - @JvmStatic - fun ofNewSubscriptionUnit(newSubscriptionUnit: NewSubscriptionUnitPrice) = - Price(newSubscriptionUnit = newSubscriptionUnit) - - @JvmStatic - fun ofNewSubscriptionPackage(newSubscriptionPackage: NewSubscriptionPackagePrice) = - Price(newSubscriptionPackage = newSubscriptionPackage) - - @JvmStatic - fun ofNewSubscriptionMatrix(newSubscriptionMatrix: NewSubscriptionMatrixPrice) = - Price(newSubscriptionMatrix = newSubscriptionMatrix) - - @JvmStatic - fun ofNewSubscriptionTiered(newSubscriptionTiered: NewSubscriptionTieredPrice) = - Price(newSubscriptionTiered = newSubscriptionTiered) - - @JvmStatic - fun ofNewSubscriptionTieredBps( - newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice - ) = Price(newSubscriptionTieredBps = newSubscriptionTieredBps) - - @JvmStatic - fun ofNewSubscriptionBps(newSubscriptionBps: NewSubscriptionBpsPrice) = - Price(newSubscriptionBps = newSubscriptionBps) - - @JvmStatic - fun ofNewSubscriptionBulkBps(newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice) = - Price(newSubscriptionBulkBps = newSubscriptionBulkBps) - - @JvmStatic - fun ofNewSubscriptionBulk(newSubscriptionBulk: NewSubscriptionBulkPrice) = - Price(newSubscriptionBulk = newSubscriptionBulk) - - @JvmStatic - fun ofNewSubscriptionThresholdTotalAmount( - newSubscriptionThresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = Price(newSubscriptionThresholdTotalAmount = newSubscriptionThresholdTotalAmount) - - @JvmStatic - fun ofNewSubscriptionTieredPackage( - newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice - ) = Price(newSubscriptionTieredPackage = newSubscriptionTieredPackage) - - @JvmStatic - fun ofNewSubscriptionTieredWithMinimum( - newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) = Price(newSubscriptionTieredWithMinimum = newSubscriptionTieredWithMinimum) - - @JvmStatic - fun ofNewSubscriptionUnitWithPercent( - newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice - ) = Price(newSubscriptionUnitWithPercent = newSubscriptionUnitWithPercent) - - @JvmStatic - fun ofNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = - Price( - newSubscriptionPackageWithAllocation = newSubscriptionPackageWithAllocation - ) - - @JvmStatic - fun ofNewSubscriptionTierWithProration( - newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice - ) = Price(newSubscriptionTierWithProration = newSubscriptionTierWithProration) - - @JvmStatic - fun ofNewSubscriptionUnitWithProration( - newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice - ) = Price(newSubscriptionUnitWithProration = newSubscriptionUnitWithProration) - - @JvmStatic - fun ofNewSubscriptionGroupedAllocation( - newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice - ) = Price(newSubscriptionGroupedAllocation = newSubscriptionGroupedAllocation) - - @JvmStatic - fun ofNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) = - Price( - newSubscriptionGroupedWithProratedMinimum = - newSubscriptionGroupedWithProratedMinimum - ) - - @JvmStatic - fun ofNewSubscriptionBulkWithProration( - newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice - ) = Price(newSubscriptionBulkWithProration = newSubscriptionBulkWithProration) - } - - /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. - */ - interface Visitor { - - fun visitNewSubscriptionUnit(newSubscriptionUnit: NewSubscriptionUnitPrice): T - - fun visitNewSubscriptionPackage( - newSubscriptionPackage: NewSubscriptionPackagePrice - ): T - - fun visitNewSubscriptionMatrix(newSubscriptionMatrix: NewSubscriptionMatrixPrice): T - - fun visitNewSubscriptionTiered(newSubscriptionTiered: NewSubscriptionTieredPrice): T - - fun visitNewSubscriptionTieredBps( - newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice - ): T - - fun visitNewSubscriptionBps(newSubscriptionBps: NewSubscriptionBpsPrice): T - - fun visitNewSubscriptionBulkBps( - newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice - ): T - - fun visitNewSubscriptionBulk(newSubscriptionBulk: NewSubscriptionBulkPrice): T - - fun visitNewSubscriptionThresholdTotalAmount( - newSubscriptionThresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ): T - - fun visitNewSubscriptionTieredPackage( - newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice - ): T - - fun visitNewSubscriptionTieredWithMinimum( - newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ): T - - fun visitNewSubscriptionUnitWithPercent( - newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice - ): T - - fun visitNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ): T - - fun visitNewSubscriptionTierWithProration( - newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice - ): T - - fun visitNewSubscriptionUnitWithProration( - newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice - ): T - - fun visitNewSubscriptionGroupedAllocation( - newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice - ): T - - fun visitNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ): T - - fun visitNewSubscriptionBulkWithProration( - newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice - ): 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" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionUnit = it, _json = json) - } - } - "package" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionPackage = it, _json = json) - } - } - "matrix" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionMatrix = it, _json = json) - } - } - "tiered" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionTiered = it, _json = json) - } - } - "tiered_bps" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionTieredBps = it, _json = json) - } - } - "bps" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionBps = it, _json = json) - } - } - "bulk_bps" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionBulkBps = it, _json = json) - } - } - "bulk" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionBulk = it, _json = json) - } - } - "threshold_total_amount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionThresholdTotalAmount = it, - _json = json, - ) - } - } - "tiered_package" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price(newSubscriptionTieredPackage = it, _json = json) - } - } - "tiered_with_minimum" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionTieredWithMinimum = it, - _json = json, - ) - } - } - "unit_with_percent" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price(newSubscriptionUnitWithPercent = it, _json = json) - } - } - "package_with_allocation" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionPackageWithAllocation = it, - _json = json, - ) - } - } - "tiered_with_proration" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionTierWithProration = it, - _json = json, - ) - } - } - "unit_with_proration" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionUnitWithProration = it, - _json = json, - ) - } - } - "grouped_allocation" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionGroupedAllocation = it, - _json = json, - ) - } - } - "grouped_with_prorated_minimum" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionGroupedWithProratedMinimum = it, - _json = json, - ) - } - } - "bulk_with_proration" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionBulkWithProration = it, - _json = json, - ) - } - } - } - - return Price(_json = json) - } - } - - internal class Serializer : BaseSerializer(Price::class) { - - override fun serialize( - value: Price, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.newSubscriptionUnit != null -> - generator.writeObject(value.newSubscriptionUnit) - value.newSubscriptionPackage != null -> - generator.writeObject(value.newSubscriptionPackage) - value.newSubscriptionMatrix != null -> - generator.writeObject(value.newSubscriptionMatrix) - value.newSubscriptionTiered != null -> - generator.writeObject(value.newSubscriptionTiered) - value.newSubscriptionTieredBps != null -> - generator.writeObject(value.newSubscriptionTieredBps) - value.newSubscriptionBps != null -> - generator.writeObject(value.newSubscriptionBps) - value.newSubscriptionBulkBps != null -> - generator.writeObject(value.newSubscriptionBulkBps) - value.newSubscriptionBulk != null -> - generator.writeObject(value.newSubscriptionBulk) - value.newSubscriptionThresholdTotalAmount != null -> - generator.writeObject(value.newSubscriptionThresholdTotalAmount) - value.newSubscriptionTieredPackage != null -> - generator.writeObject(value.newSubscriptionTieredPackage) - value.newSubscriptionTieredWithMinimum != null -> - generator.writeObject(value.newSubscriptionTieredWithMinimum) - value.newSubscriptionUnitWithPercent != null -> - generator.writeObject(value.newSubscriptionUnitWithPercent) - value.newSubscriptionPackageWithAllocation != null -> - generator.writeObject(value.newSubscriptionPackageWithAllocation) - value.newSubscriptionTierWithProration != null -> - generator.writeObject(value.newSubscriptionTierWithProration) - value.newSubscriptionUnitWithProration != null -> - generator.writeObject(value.newSubscriptionUnitWithProration) - value.newSubscriptionGroupedAllocation != null -> - generator.writeObject(value.newSubscriptionGroupedAllocation) - value.newSubscriptionGroupedWithProratedMinimum != null -> - generator.writeObject(value.newSubscriptionGroupedWithProratedMinimum) - value.newSubscriptionBulkWithProration != null -> - generator.writeObject(value.newSubscriptionBulkWithProration) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") - } - } - } - - @NoAutoDetect - class NewSubscriptionUnitPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("unit_config") - @ExcludeMissing - private val unitConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun unitConfig(): UnitConfig = unitConfig.getRequired("unit_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("unit_config") - @ExcludeMissing - fun _unitConfig(): JsonField = unitConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionUnitPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - unitConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionUnitPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var 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 currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newSubscriptionUnitPrice: NewSubscriptionUnitPrice) = apply { - cadence = newSubscriptionUnitPrice.cadence - itemId = newSubscriptionUnitPrice.itemId - modelType = newSubscriptionUnitPrice.modelType - name = newSubscriptionUnitPrice.name - unitConfig = newSubscriptionUnitPrice.unitConfig - billableMetricId = newSubscriptionUnitPrice.billableMetricId - billedInAdvance = newSubscriptionUnitPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionUnitPrice.billingCycleConfiguration - conversionRate = newSubscriptionUnitPrice.conversionRate - currency = newSubscriptionUnitPrice.currency - externalPriceId = newSubscriptionUnitPrice.externalPriceId - fixedPriceQuantity = newSubscriptionUnitPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionUnitPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionUnitPrice.invoicingCycleConfiguration - metadata = newSubscriptionUnitPrice.metadata - referenceId = newSubscriptionUnitPrice.referenceId - additionalProperties = - newSubscriptionUnitPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) - - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionUnitPrice = - NewSubscriptionUnitPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("unitConfig", unitConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class UnitConfig - @JsonCreator - private constructor( - @JsonProperty("unit_amount") - @ExcludeMissing - private val unitAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Rate per unit of usage */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** Rate per unit of usage */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): UnitConfig = apply { - if (validated) { - return@apply - } - - unitAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnitConfig]. */ - class Builder internal constructor() { - - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unitConfig: UnitConfig) = apply { - unitAmount = unitConfig.unitAmount - additionalProperties = unitConfig.additionalProperties.toMutableMap() - } - - /** Rate per unit of usage */ - fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - - /** Rate per unit of usage */ - 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 build(): UnitConfig = - UnitConfig( - checkRequired("unitAmount", unitAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UnitConfig && unitAmount == other.unitAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(unitAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnitConfig{unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionUnitPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && unitConfig == other.unitConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, unitConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionUnitPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionPackagePrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("package_config") - @ExcludeMissing - private val packageConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun packageConfig(): PackageConfig = packageConfig.getRequired("package_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("package_config") - @ExcludeMissing - fun _packageConfig(): JsonField = packageConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionPackagePrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - packageConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionPackagePrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var packageConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newSubscriptionPackagePrice: NewSubscriptionPackagePrice) = - apply { - cadence = newSubscriptionPackagePrice.cadence - itemId = newSubscriptionPackagePrice.itemId - modelType = newSubscriptionPackagePrice.modelType - name = newSubscriptionPackagePrice.name - packageConfig = newSubscriptionPackagePrice.packageConfig - billableMetricId = newSubscriptionPackagePrice.billableMetricId - billedInAdvance = newSubscriptionPackagePrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionPackagePrice.billingCycleConfiguration - conversionRate = newSubscriptionPackagePrice.conversionRate - currency = newSubscriptionPackagePrice.currency - externalPriceId = newSubscriptionPackagePrice.externalPriceId - fixedPriceQuantity = newSubscriptionPackagePrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionPackagePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionPackagePrice.invoicingCycleConfiguration - metadata = newSubscriptionPackagePrice.metadata - referenceId = newSubscriptionPackagePrice.referenceId - additionalProperties = - newSubscriptionPackagePrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun packageConfig(packageConfig: PackageConfig) = - packageConfig(JsonField.of(packageConfig)) - - fun packageConfig(packageConfig: JsonField) = apply { - this.packageConfig = packageConfig - } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionPackagePrice = - NewSubscriptionPackagePrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("packageConfig", packageConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val PACKAGE = of("package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - PACKAGE - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PACKAGE, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PACKAGE -> Value.PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PACKAGE -> Known.PACKAGE - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class PackageConfig - @JsonCreator - private constructor( - @JsonProperty("package_amount") - @ExcludeMissing - private val packageAmount: JsonField = JsonMissing.of(), - @JsonProperty("package_size") - @ExcludeMissing - private val packageSize: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** A currency amount to rate usage by */ - fun packageAmount(): String = packageAmount.getRequired("package_amount") - - /** - * An integer amount to represent package size. For example, 1000 here would - * divide usage by 1000 before multiplying by package_amount in rating - */ - fun packageSize(): Long = packageSize.getRequired("package_size") - - /** A currency amount to rate usage by */ - @JsonProperty("package_amount") - @ExcludeMissing - fun _packageAmount(): JsonField = packageAmount - - /** - * An integer amount to represent package size. For example, 1000 here would - * divide usage by 1000 before multiplying by package_amount in rating - */ - @JsonProperty("package_size") - @ExcludeMissing - fun _packageSize(): JsonField = packageSize - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PackageConfig = apply { - if (validated) { - return@apply - } - - packageAmount() - packageSize() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PackageConfig]. */ - class Builder internal constructor() { - - private var packageAmount: JsonField? = null - private var packageSize: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(packageConfig: PackageConfig) = apply { - packageAmount = packageConfig.packageAmount - packageSize = packageConfig.packageSize - additionalProperties = packageConfig.additionalProperties.toMutableMap() - } - - /** A currency amount to rate usage by */ - fun packageAmount(packageAmount: String) = - packageAmount(JsonField.of(packageAmount)) - - /** A currency amount to rate usage by */ - fun packageAmount(packageAmount: JsonField) = apply { - this.packageAmount = packageAmount - } - - /** - * An integer amount to represent package size. For example, 1000 here would - * divide usage by 1000 before multiplying by package_amount in rating - */ - fun packageSize(packageSize: Long) = packageSize(JsonField.of(packageSize)) - - /** - * An integer amount to represent package size. For example, 1000 here would - * divide usage by 1000 before multiplying by package_amount in rating - */ - fun packageSize(packageSize: JsonField) = apply { - this.packageSize = packageSize - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PackageConfig = - PackageConfig( - checkRequired("packageAmount", packageAmount), - checkRequired("packageSize", packageSize), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PackageConfig && packageAmount == other.packageAmount && packageSize == other.packageSize && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(packageAmount, packageSize, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PackageConfig{packageAmount=$packageAmount, packageSize=$packageSize, additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionPackagePrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && packageConfig == other.packageConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, packageConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionMatrixPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("matrix_config") - @ExcludeMissing - private val matrixConfig: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_config") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("matrix_config") - @ExcludeMissing - fun _matrixConfig(): JsonField = matrixConfig - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionMatrixPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - matrixConfig().validate() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionMatrixPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var matrixConfig: JsonField? = null - private var modelType: JsonField? = null - private var 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 currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newSubscriptionMatrixPrice: NewSubscriptionMatrixPrice) = - apply { - cadence = newSubscriptionMatrixPrice.cadence - itemId = newSubscriptionMatrixPrice.itemId - matrixConfig = newSubscriptionMatrixPrice.matrixConfig - modelType = newSubscriptionMatrixPrice.modelType - name = newSubscriptionMatrixPrice.name - billableMetricId = newSubscriptionMatrixPrice.billableMetricId - billedInAdvance = newSubscriptionMatrixPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionMatrixPrice.billingCycleConfiguration - conversionRate = newSubscriptionMatrixPrice.conversionRate - currency = newSubscriptionMatrixPrice.currency - externalPriceId = newSubscriptionMatrixPrice.externalPriceId - fixedPriceQuantity = newSubscriptionMatrixPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionMatrixPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionMatrixPrice.invoicingCycleConfiguration - metadata = newSubscriptionMatrixPrice.metadata - referenceId = newSubscriptionMatrixPrice.referenceId - additionalProperties = - newSubscriptionMatrixPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun matrixConfig(matrixConfig: MatrixConfig) = - matrixConfig(JsonField.of(matrixConfig)) - - fun matrixConfig(matrixConfig: JsonField) = apply { - this.matrixConfig = matrixConfig - } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionMatrixPrice = - NewSubscriptionMatrixPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("matrixConfig", matrixConfig), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class MatrixConfig - @JsonCreator - private constructor( - @JsonProperty("default_unit_amount") - @ExcludeMissing - private val defaultUnitAmount: JsonField = JsonMissing.of(), - @JsonProperty("dimensions") - @ExcludeMissing - private val dimensions: JsonField> = JsonMissing.of(), - @JsonProperty("matrix_values") - @ExcludeMissing - private val matrixValues: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * Default per unit rate for any usage not bucketed into a specified - * matrix_value - */ - fun defaultUnitAmount(): String = - defaultUnitAmount.getRequired("default_unit_amount") - - /** One or two event property values to evaluate matrix groups by */ - fun dimensions(): List = dimensions.getRequired("dimensions") - - /** Matrix values for specified matrix grouping keys */ - fun matrixValues(): List = - matrixValues.getRequired("matrix_values") - - /** - * Default per unit rate for any usage not bucketed into a specified - * matrix_value - */ - @JsonProperty("default_unit_amount") - @ExcludeMissing - fun _defaultUnitAmount(): JsonField = defaultUnitAmount - - /** One or two event property values to evaluate matrix groups by */ - @JsonProperty("dimensions") - @ExcludeMissing - fun _dimensions(): JsonField> = dimensions - - /** Matrix values for specified matrix grouping keys */ - @JsonProperty("matrix_values") - @ExcludeMissing - fun _matrixValues(): JsonField> = matrixValues - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MatrixConfig = apply { - if (validated) { - return@apply - } - - defaultUnitAmount() - dimensions() - matrixValues().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MatrixConfig]. */ - class Builder internal constructor() { - - private var defaultUnitAmount: JsonField? = null - private var dimensions: JsonField>? = null - private var matrixValues: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(matrixConfig: MatrixConfig) = apply { - defaultUnitAmount = matrixConfig.defaultUnitAmount - dimensions = matrixConfig.dimensions.map { it.toMutableList() } - matrixValues = matrixConfig.matrixValues.map { it.toMutableList() } - additionalProperties = matrixConfig.additionalProperties.toMutableMap() - } - - /** - * Default per unit rate for any usage not bucketed into a specified - * matrix_value - */ - fun defaultUnitAmount(defaultUnitAmount: String) = - defaultUnitAmount(JsonField.of(defaultUnitAmount)) - - /** - * Default per unit rate for any usage not bucketed into a specified - * matrix_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)) - - /** One or two event property values to evaluate matrix groups by */ - fun dimensions(dimensions: JsonField>) = apply { - this.dimensions = dimensions.map { it.toMutableList() } - } - - /** One or two event property values to evaluate matrix groups by */ - fun addDimension(dimension: String) = apply { - dimensions = - (dimensions ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimension) - } - } - - /** Matrix values for specified matrix grouping keys */ - fun matrixValues(matrixValues: List) = - matrixValues(JsonField.of(matrixValues)) - - /** Matrix values for specified matrix grouping keys */ - fun matrixValues(matrixValues: JsonField>) = apply { - this.matrixValues = matrixValues.map { it.toMutableList() } - } - - /** Matrix values for specified matrix grouping keys */ - fun addMatrixValue(matrixValue: MatrixValue) = apply { - matrixValues = - (matrixValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): MatrixConfig = - MatrixConfig( - checkRequired("defaultUnitAmount", defaultUnitAmount), - checkRequired("dimensions", dimensions).map { it.toImmutable() }, - checkRequired("matrixValues", matrixValues).map { - it.toImmutable() - }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class MatrixValue - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - private val unitAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), - ) { - - /** - * One or two matrix keys to filter usage to this Matrix value by. For - * example, ["region", "tier"] could be used to filter cloud usage by a - * cloud region and an instance tier. - */ - fun dimensionValues(): List = - dimensionValues.getRequired("dimension_values") - - /** Unit price for the specified dimension_values */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** - * One or two matrix keys to filter usage to this Matrix value by. For - * example, ["region", "tier"] could be used to filter cloud usage by a - * cloud region and an instance tier. - */ - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - /** Unit price for the specified dimension_values */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MatrixValue = apply { - if (validated) { - return@apply - } - - dimensionValues() - unitAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MatrixValue]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(matrixValue: MatrixValue) = apply { - dimensionValues = - matrixValue.dimensionValues.map { it.toMutableList() } - unitAmount = matrixValue.unitAmount - additionalProperties = - matrixValue.additionalProperties.toMutableMap() - } - - /** - * One or two matrix keys to filter usage to this Matrix value by. For - * example, ["region", "tier"] could be used to filter cloud usage by a - * cloud region and an instance tier. - */ - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - /** - * One or two matrix keys to filter usage to this Matrix value by. For - * example, ["region", "tier"] could be used to filter cloud usage by a - * cloud region and an instance tier. - */ - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - /** - * One or two matrix keys to filter usage to this Matrix value by. For - * example, ["region", "tier"] could be used to filter cloud usage by a - * cloud region and an instance tier. - */ - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - /** Unit price for the specified dimension_values */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) - - /** Unit price for the specified dimension_values */ - 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 build(): MatrixValue = - MatrixValue( - checkRequired("dimensionValues", dimensionValues).map { - it.toImmutable() - }, - checkRequired("unitAmount", unitAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MatrixValue && dimensionValues == other.dimensionValues && unitAmount == other.unitAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, unitAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MatrixValue{dimensionValues=$dimensionValues, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MatrixConfig && defaultUnitAmount == other.defaultUnitAmount && dimensions == other.dimensions && matrixValues == other.matrixValues && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(defaultUnitAmount, dimensions, matrixValues, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MatrixConfig{defaultUnitAmount=$defaultUnitAmount, dimensions=$dimensions, matrixValues=$matrixValues, additionalProperties=$additionalProperties}" - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MATRIX = of("matrix") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MATRIX - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MATRIX, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MATRIX -> Value.MATRIX - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MATRIX -> Known.MATRIX - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionMatrixPrice && cadence == other.cadence && itemId == other.itemId && matrixConfig == other.matrixConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, matrixConfig, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionMatrixPrice{cadence=$cadence, itemId=$itemId, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionTieredPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_config") - @ExcludeMissing - private val tieredConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun tieredConfig(): TieredConfig = tieredConfig.getRequired("tiered_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("tiered_config") - @ExcludeMissing - fun _tieredConfig(): JsonField = tieredConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionTieredPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - tieredConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionTieredPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var tieredConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newSubscriptionTieredPrice: NewSubscriptionTieredPrice) = - apply { - cadence = newSubscriptionTieredPrice.cadence - itemId = newSubscriptionTieredPrice.itemId - modelType = newSubscriptionTieredPrice.modelType - name = newSubscriptionTieredPrice.name - tieredConfig = newSubscriptionTieredPrice.tieredConfig - billableMetricId = newSubscriptionTieredPrice.billableMetricId - billedInAdvance = newSubscriptionTieredPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionTieredPrice.billingCycleConfiguration - conversionRate = newSubscriptionTieredPrice.conversionRate - currency = newSubscriptionTieredPrice.currency - externalPriceId = newSubscriptionTieredPrice.externalPriceId - fixedPriceQuantity = newSubscriptionTieredPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionTieredPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionTieredPrice.invoicingCycleConfiguration - metadata = newSubscriptionTieredPrice.metadata - referenceId = newSubscriptionTieredPrice.referenceId - additionalProperties = - newSubscriptionTieredPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredConfig(tieredConfig: TieredConfig) = - tieredConfig(JsonField.of(tieredConfig)) - - fun tieredConfig(tieredConfig: JsonField) = apply { - this.tieredConfig = tieredConfig - } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionTieredPrice = - NewSubscriptionTieredPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("tieredConfig", tieredConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED = of("tiered") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED -> Value.TIERED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TIERED -> Known.TIERED - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TieredConfig - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - private val tiers: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Tiers for rating based on total usage quantities into the specified tier */ - fun tiers(): List = tiers.getRequired("tiers") - - /** Tiers for rating based on total usage quantities into the specified tier */ - @JsonProperty("tiers") - @ExcludeMissing - fun _tiers(): JsonField> = tiers - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredConfig = apply { - if (validated) { - return@apply - } - - tiers().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tieredConfig: TieredConfig) = apply { - tiers = tieredConfig.tiers.map { it.toMutableList() } - additionalProperties = tieredConfig.additionalProperties.toMutableMap() - } - - /** - * Tiers for rating based on total usage quantities into the specified tier - */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - - /** - * Tiers for rating based on total usage quantities into the specified tier - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** - * Tiers for rating based on total usage quantities into the specified tier - */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): TieredConfig = - TieredConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Tier - @JsonCreator - private constructor( - @JsonProperty("first_unit") - @ExcludeMissing - private val firstUnit: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - private val unitAmount: JsonField = JsonMissing.of(), - @JsonProperty("last_unit") - @ExcludeMissing - private val lastUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), - ) { - - /** Inclusive tier starting value */ - fun firstUnit(): Double = firstUnit.getRequired("first_unit") - - /** Amount per unit */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** - * Exclusive tier ending value. If null, this is treated as the last tier - */ - fun lastUnit(): Optional = - Optional.ofNullable(lastUnit.getNullable("last_unit")) - - /** Inclusive tier starting value */ - @JsonProperty("first_unit") - @ExcludeMissing - fun _firstUnit(): JsonField = firstUnit - - /** Amount per unit */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - /** - * Exclusive tier ending value. If null, this is treated as the last tier - */ - @JsonProperty("last_unit") - @ExcludeMissing - fun _lastUnit(): JsonField = lastUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - firstUnit() - unitAmount() - lastUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var firstUnit: JsonField? = null - private var unitAmount: JsonField? = null - private var lastUnit: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - firstUnit = tier.firstUnit - unitAmount = tier.unitAmount - lastUnit = tier.lastUnit - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Inclusive tier starting value */ - fun firstUnit(firstUnit: Double) = firstUnit(JsonField.of(firstUnit)) - - /** Inclusive tier starting value */ - fun firstUnit(firstUnit: JsonField) = apply { - this.firstUnit = firstUnit - } - - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) - - /** Amount per unit */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - /** - * Exclusive tier ending value. If null, this is treated as the last - * tier - */ - fun lastUnit(lastUnit: Double?) = - lastUnit(JsonField.ofNullable(lastUnit)) - - /** - * Exclusive tier ending value. If null, this is treated as the last - * tier - */ - fun lastUnit(lastUnit: Double) = lastUnit(lastUnit as Double?) - - /** - * Exclusive tier ending value. If null, this is treated as the last - * tier - */ - @Suppress( - "USELESS_CAST" - ) // See https://youtrack.jetbrains.com/issue/KT-74228 - fun lastUnit(lastUnit: Optional) = - lastUnit(lastUnit.orElse(null) as Double?) - - /** - * Exclusive tier ending value. If null, this is treated as the last - * tier - */ - fun lastUnit(lastUnit: JsonField) = apply { - this.lastUnit = lastUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Tier = - Tier( - checkRequired("firstUnit", firstUnit), - checkRequired("unitAmount", unitAmount), - lastUnit, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tier && firstUnit == other.firstUnit && unitAmount == other.unitAmount && lastUnit == other.lastUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(firstUnit, unitAmount, lastUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{firstUnit=$firstUnit, unitAmount=$unitAmount, lastUnit=$lastUnit, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredConfig && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredConfig{tiers=$tiers, additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionTieredPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredConfig == other.tieredConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionTieredPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionTieredBpsPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_bps_config") - @ExcludeMissing - private val tieredBpsConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun tieredBpsConfig(): TieredBpsConfig = - tieredBpsConfig.getRequired("tiered_bps_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("tiered_bps_config") - @ExcludeMissing - fun _tieredBpsConfig(): JsonField = tieredBpsConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionTieredBpsPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - tieredBpsConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionTieredBpsPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var tieredBpsConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionTieredBpsPrice: NewSubscriptionTieredBpsPrice - ) = apply { - cadence = newSubscriptionTieredBpsPrice.cadence - itemId = newSubscriptionTieredBpsPrice.itemId - modelType = newSubscriptionTieredBpsPrice.modelType - name = newSubscriptionTieredBpsPrice.name - tieredBpsConfig = newSubscriptionTieredBpsPrice.tieredBpsConfig - billableMetricId = newSubscriptionTieredBpsPrice.billableMetricId - billedInAdvance = newSubscriptionTieredBpsPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionTieredBpsPrice.billingCycleConfiguration - conversionRate = newSubscriptionTieredBpsPrice.conversionRate - currency = newSubscriptionTieredBpsPrice.currency - externalPriceId = newSubscriptionTieredBpsPrice.externalPriceId - fixedPriceQuantity = newSubscriptionTieredBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionTieredBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionTieredBpsPrice.invoicingCycleConfiguration - metadata = newSubscriptionTieredBpsPrice.metadata - referenceId = newSubscriptionTieredBpsPrice.referenceId - additionalProperties = - newSubscriptionTieredBpsPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredBpsConfig(tieredBpsConfig: TieredBpsConfig) = - tieredBpsConfig(JsonField.of(tieredBpsConfig)) - - fun tieredBpsConfig(tieredBpsConfig: JsonField) = apply { - this.tieredBpsConfig = tieredBpsConfig - } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionTieredBpsPrice = - NewSubscriptionTieredBpsPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("tieredBpsConfig", tieredBpsConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED_BPS = of("tiered_bps") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_BPS -> Value.TIERED_BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TIERED_BPS -> Known.TIERED_BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TieredBpsConfig - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - private val tiers: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into - * specified tiers - */ - fun tiers(): List = tiers.getRequired("tiers") - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into - * specified tiers - */ - @JsonProperty("tiers") - @ExcludeMissing - fun _tiers(): JsonField> = tiers - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredBpsConfig = apply { - if (validated) { - return@apply - } - - tiers().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredBpsConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tieredBpsConfig: TieredBpsConfig) = apply { - tiers = tieredBpsConfig.tiers.map { it.toMutableList() } - additionalProperties = - tieredBpsConfig.additionalProperties.toMutableMap() - } - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into - * specified tiers - */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into - * specified tiers - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into - * specified tiers - */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): TieredBpsConfig = - TieredBpsConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Tier - @JsonCreator - private constructor( - @JsonProperty("bps") - @ExcludeMissing - private val bps: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_maximum") - @ExcludeMissing - private val perUnitMaximum: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), - ) { - - /** Per-event basis point rate */ - fun bps(): Double = bps.getRequired("bps") - - /** Inclusive tier starting value */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** Exclusive tier ending value */ - fun maximumAmount(): Optional = - Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - - /** Per unit maximum to charge */ - fun perUnitMaximum(): Optional = - Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) - - /** Per-event basis point rate */ - @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps - - /** Inclusive tier starting value */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** Exclusive tier ending value */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** Per unit maximum to charge */ - @JsonProperty("per_unit_maximum") - @ExcludeMissing - fun _perUnitMaximum(): JsonField = perUnitMaximum - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - bps() - minimumAmount() - maximumAmount() - perUnitMaximum() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var bps: JsonField? = null - private var minimumAmount: JsonField? = null - private var maximumAmount: JsonField = JsonMissing.of() - private var perUnitMaximum: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - bps = tier.bps - minimumAmount = tier.minimumAmount - maximumAmount = tier.maximumAmount - perUnitMaximum = tier.perUnitMaximum - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Per-event basis point rate */ - fun bps(bps: Double) = bps(JsonField.of(bps)) - - /** Per-event basis point rate */ - fun bps(bps: JsonField) = apply { this.bps = bps } - - /** Inclusive tier starting value */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** Inclusive tier starting value */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** Exclusive tier ending value */ - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - /** Exclusive tier ending value */ - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.orElse(null)) - - /** Exclusive tier ending value */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** Per unit maximum to charge */ - fun perUnitMaximum(perUnitMaximum: String?) = - perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) - - /** Per unit maximum to charge */ - fun perUnitMaximum(perUnitMaximum: Optional) = - perUnitMaximum(perUnitMaximum.orElse(null)) - - /** Per unit maximum to charge */ - fun perUnitMaximum(perUnitMaximum: JsonField) = apply { - this.perUnitMaximum = perUnitMaximum - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): Tier = - Tier( - checkRequired("bps", bps), - checkRequired("minimumAmount", minimumAmount), - maximumAmount, - perUnitMaximum, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tier && bps == other.bps && minimumAmount == other.minimumAmount && maximumAmount == other.maximumAmount && perUnitMaximum == other.perUnitMaximum && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bps, minimumAmount, maximumAmount, perUnitMaximum, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{bps=$bps, minimumAmount=$minimumAmount, maximumAmount=$maximumAmount, perUnitMaximum=$perUnitMaximum, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredBpsConfig && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredBpsConfig{tiers=$tiers, additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionTieredBpsPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredBpsConfig == other.tieredBpsConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredBpsConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionTieredBpsPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredBpsConfig=$tieredBpsConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionBpsPrice - @JsonCreator - private constructor( - @JsonProperty("bps_config") - @ExcludeMissing - private val bpsConfig: JsonField = JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun bpsConfig(): BpsConfig = bpsConfig.getRequired("bps_config") - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - @JsonProperty("bps_config") - @ExcludeMissing - fun _bpsConfig(): JsonField = bpsConfig - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionBpsPrice = apply { - if (validated) { - return@apply - } - - bpsConfig().validate() - cadence() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionBpsPrice]. */ - class Builder internal constructor() { - - private var bpsConfig: JsonField? = null - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newSubscriptionBpsPrice: NewSubscriptionBpsPrice) = apply { - bpsConfig = newSubscriptionBpsPrice.bpsConfig - cadence = newSubscriptionBpsPrice.cadence - itemId = newSubscriptionBpsPrice.itemId - modelType = newSubscriptionBpsPrice.modelType - name = newSubscriptionBpsPrice.name - billableMetricId = newSubscriptionBpsPrice.billableMetricId - billedInAdvance = newSubscriptionBpsPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionBpsPrice.billingCycleConfiguration - conversionRate = newSubscriptionBpsPrice.conversionRate - currency = newSubscriptionBpsPrice.currency - externalPriceId = newSubscriptionBpsPrice.externalPriceId - fixedPriceQuantity = newSubscriptionBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionBpsPrice.invoicingCycleConfiguration - metadata = newSubscriptionBpsPrice.metadata - referenceId = newSubscriptionBpsPrice.referenceId - additionalProperties = - newSubscriptionBpsPrice.additionalProperties.toMutableMap() - } - - fun bpsConfig(bpsConfig: BpsConfig) = bpsConfig(JsonField.of(bpsConfig)) - - fun bpsConfig(bpsConfig: JsonField) = apply { - this.bpsConfig = bpsConfig - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionBpsPrice = - NewSubscriptionBpsPrice( - checkRequired("bpsConfig", bpsConfig), - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BpsConfig - @JsonCreator - private constructor( - @JsonProperty("bps") - @ExcludeMissing - private val bps: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_maximum") - @ExcludeMissing - private val perUnitMaximum: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Basis point take rate per event */ - fun bps(): Double = bps.getRequired("bps") - - /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(): Optional = - Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) - - /** Basis point take rate per event */ - @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps - - /** Optional currency amount maximum to cap spend per event */ - @JsonProperty("per_unit_maximum") - @ExcludeMissing - fun _perUnitMaximum(): JsonField = perUnitMaximum - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BpsConfig = apply { - if (validated) { - return@apply - } - - bps() - perUnitMaximum() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BpsConfig]. */ - class Builder internal constructor() { - - private var bps: JsonField? = null - private var perUnitMaximum: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(bpsConfig: BpsConfig) = apply { - bps = bpsConfig.bps - perUnitMaximum = bpsConfig.perUnitMaximum - additionalProperties = bpsConfig.additionalProperties.toMutableMap() - } - - /** Basis point take rate per event */ - fun bps(bps: Double) = bps(JsonField.of(bps)) - - /** Basis point take rate per event */ - fun bps(bps: JsonField) = apply { this.bps = bps } - - /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(perUnitMaximum: String?) = - perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) - - /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(perUnitMaximum: Optional) = - perUnitMaximum(perUnitMaximum.orElse(null)) - - /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(perUnitMaximum: JsonField) = apply { - this.perUnitMaximum = perUnitMaximum - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): BpsConfig = - BpsConfig( - checkRequired("bps", bps), - perUnitMaximum, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BpsConfig && bps == other.bps && perUnitMaximum == other.perUnitMaximum && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bps, perUnitMaximum, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BpsConfig{bps=$bps, perUnitMaximum=$perUnitMaximum, additionalProperties=$additionalProperties}" - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val BPS = of("bps") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BPS -> Value.BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - BPS -> Known.BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionBpsPrice && bpsConfig == other.bpsConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bpsConfig, cadence, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionBpsPrice{bpsConfig=$bpsConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionBulkBpsPrice - @JsonCreator - private constructor( - @JsonProperty("bulk_bps_config") - @ExcludeMissing - private val bulkBpsConfig: JsonField = JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun bulkBpsConfig(): BulkBpsConfig = bulkBpsConfig.getRequired("bulk_bps_config") - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - @JsonProperty("bulk_bps_config") - @ExcludeMissing - fun _bulkBpsConfig(): JsonField = bulkBpsConfig - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionBulkBpsPrice = apply { - if (validated) { - return@apply - } - - bulkBpsConfig().validate() - cadence() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionBulkBpsPrice]. */ - class Builder internal constructor() { - - private var bulkBpsConfig: JsonField? = null - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newSubscriptionBulkBpsPrice: NewSubscriptionBulkBpsPrice) = - apply { - bulkBpsConfig = newSubscriptionBulkBpsPrice.bulkBpsConfig - cadence = newSubscriptionBulkBpsPrice.cadence - itemId = newSubscriptionBulkBpsPrice.itemId - modelType = newSubscriptionBulkBpsPrice.modelType - name = newSubscriptionBulkBpsPrice.name - billableMetricId = newSubscriptionBulkBpsPrice.billableMetricId - billedInAdvance = newSubscriptionBulkBpsPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionBulkBpsPrice.billingCycleConfiguration - conversionRate = newSubscriptionBulkBpsPrice.conversionRate - currency = newSubscriptionBulkBpsPrice.currency - externalPriceId = newSubscriptionBulkBpsPrice.externalPriceId - fixedPriceQuantity = newSubscriptionBulkBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionBulkBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionBulkBpsPrice.invoicingCycleConfiguration - metadata = newSubscriptionBulkBpsPrice.metadata - referenceId = newSubscriptionBulkBpsPrice.referenceId - additionalProperties = - newSubscriptionBulkBpsPrice.additionalProperties.toMutableMap() - } - - fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfig) = - bulkBpsConfig(JsonField.of(bulkBpsConfig)) - - fun bulkBpsConfig(bulkBpsConfig: JsonField) = apply { - this.bulkBpsConfig = bulkBpsConfig - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionBulkBpsPrice = - NewSubscriptionBulkBpsPrice( - checkRequired("bulkBpsConfig", bulkBpsConfig), - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BulkBpsConfig - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - private val tiers: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a single - * tier based on total volume - */ - fun tiers(): List = tiers.getRequired("tiers") - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a single - * tier based on total volume - */ - @JsonProperty("tiers") - @ExcludeMissing - fun _tiers(): JsonField> = tiers - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BulkBpsConfig = apply { - if (validated) { - return@apply - } - - tiers().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkBpsConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(bulkBpsConfig: BulkBpsConfig) = apply { - tiers = bulkBpsConfig.tiers.map { it.toMutableList() } - additionalProperties = bulkBpsConfig.additionalProperties.toMutableMap() - } - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a - * single tier based on total volume - */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a - * single tier based on total volume - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a - * single tier based on total volume - */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): BulkBpsConfig = - BulkBpsConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Tier - @JsonCreator - private constructor( - @JsonProperty("bps") - @ExcludeMissing - private val bps: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_maximum") - @ExcludeMissing - private val perUnitMaximum: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), - ) { - - /** Basis points to rate on */ - fun bps(): Double = bps.getRequired("bps") - - /** Upper bound for tier */ - fun maximumAmount(): Optional = - Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(): Optional = - Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) - - /** Basis points to rate on */ - @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps - - /** Upper bound for tier */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** The maximum amount to charge for any one event */ - @JsonProperty("per_unit_maximum") - @ExcludeMissing - fun _perUnitMaximum(): JsonField = perUnitMaximum - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - bps() - maximumAmount() - perUnitMaximum() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var bps: JsonField? = null - private var maximumAmount: JsonField = JsonMissing.of() - private var perUnitMaximum: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - bps = tier.bps - maximumAmount = tier.maximumAmount - perUnitMaximum = tier.perUnitMaximum - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Basis points to rate on */ - fun bps(bps: Double) = bps(JsonField.of(bps)) - - /** Basis points to rate on */ - fun bps(bps: JsonField) = apply { this.bps = bps } - - /** Upper bound for tier */ - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - /** Upper bound for tier */ - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.orElse(null)) - - /** Upper bound for tier */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(perUnitMaximum: String?) = - perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) - - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(perUnitMaximum: Optional) = - perUnitMaximum(perUnitMaximum.orElse(null)) - - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(perUnitMaximum: JsonField) = apply { - this.perUnitMaximum = perUnitMaximum - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): Tier = - Tier( - checkRequired("bps", bps), - maximumAmount, - perUnitMaximum, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tier && bps == other.bps && maximumAmount == other.maximumAmount && perUnitMaximum == other.perUnitMaximum && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bps, maximumAmount, perUnitMaximum, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{bps=$bps, maximumAmount=$maximumAmount, perUnitMaximum=$perUnitMaximum, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BulkBpsConfig && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkBpsConfig{tiers=$tiers, additionalProperties=$additionalProperties}" - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val BULK_BPS = of("bulk_bps") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK_BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK_BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK_BPS -> Value.BULK_BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - BULK_BPS -> Known.BULK_BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionBulkBpsPrice && bulkBpsConfig == other.bulkBpsConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bulkBpsConfig, cadence, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionBulkBpsPrice{bulkBpsConfig=$bulkBpsConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionBulkPrice - @JsonCreator - private constructor( - @JsonProperty("bulk_config") - @ExcludeMissing - private val bulkConfig: JsonField = JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun bulkConfig(): BulkConfig = bulkConfig.getRequired("bulk_config") - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - @JsonProperty("bulk_config") - @ExcludeMissing - fun _bulkConfig(): JsonField = bulkConfig - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionBulkPrice = apply { - if (validated) { - return@apply - } - - bulkConfig().validate() - cadence() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionBulkPrice]. */ - class Builder internal constructor() { - - private var bulkConfig: JsonField? = null - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var 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 currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newSubscriptionBulkPrice: NewSubscriptionBulkPrice) = apply { - bulkConfig = newSubscriptionBulkPrice.bulkConfig - cadence = newSubscriptionBulkPrice.cadence - itemId = newSubscriptionBulkPrice.itemId - modelType = newSubscriptionBulkPrice.modelType - name = newSubscriptionBulkPrice.name - billableMetricId = newSubscriptionBulkPrice.billableMetricId - billedInAdvance = newSubscriptionBulkPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionBulkPrice.billingCycleConfiguration - conversionRate = newSubscriptionBulkPrice.conversionRate - currency = newSubscriptionBulkPrice.currency - externalPriceId = newSubscriptionBulkPrice.externalPriceId - fixedPriceQuantity = newSubscriptionBulkPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionBulkPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionBulkPrice.invoicingCycleConfiguration - metadata = newSubscriptionBulkPrice.metadata - referenceId = newSubscriptionBulkPrice.referenceId - additionalProperties = - newSubscriptionBulkPrice.additionalProperties.toMutableMap() - } - - fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) - - fun bulkConfig(bulkConfig: JsonField) = apply { - this.bulkConfig = bulkConfig - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionBulkPrice = - NewSubscriptionBulkPrice( - checkRequired("bulkConfig", bulkConfig), - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BulkConfig - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - private val tiers: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Bulk tiers for rating based on total usage volume */ - fun tiers(): List = tiers.getRequired("tiers") - - /** Bulk tiers for rating based on total usage volume */ - @JsonProperty("tiers") - @ExcludeMissing - fun _tiers(): JsonField> = tiers - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BulkConfig = apply { - if (validated) { - return@apply - } - - tiers().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(bulkConfig: BulkConfig) = apply { - tiers = bulkConfig.tiers.map { it.toMutableList() } - additionalProperties = bulkConfig.additionalProperties.toMutableMap() - } - - /** Bulk tiers for rating based on total usage volume */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - - /** Bulk tiers for rating based on total usage volume */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** Bulk tiers for rating based on total usage volume */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): BulkConfig = - BulkConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Tier - @JsonCreator - private constructor( - @JsonProperty("unit_amount") - @ExcludeMissing - private val unitAmount: JsonField = JsonMissing.of(), - @JsonProperty("maximum_units") - @ExcludeMissing - private val maximumUnits: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), - ) { - - /** Amount per unit */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** Upper bound for this tier */ - fun maximumUnits(): Optional = - Optional.ofNullable(maximumUnits.getNullable("maximum_units")) - - /** Amount per unit */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - /** Upper bound for this tier */ - @JsonProperty("maximum_units") - @ExcludeMissing - fun _maximumUnits(): JsonField = maximumUnits - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - unitAmount() - maximumUnits() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var unitAmount: JsonField? = null - private var maximumUnits: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - unitAmount = tier.unitAmount - maximumUnits = tier.maximumUnits - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) - - /** Amount per unit */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - /** Upper bound for this tier */ - fun maximumUnits(maximumUnits: Double?) = - maximumUnits(JsonField.ofNullable(maximumUnits)) - - /** Upper bound for this tier */ - fun maximumUnits(maximumUnits: Double) = - maximumUnits(maximumUnits as Double?) - - /** Upper bound for this tier */ - @Suppress( - "USELESS_CAST" - ) // See https://youtrack.jetbrains.com/issue/KT-74228 - fun maximumUnits(maximumUnits: Optional) = - maximumUnits(maximumUnits.orElse(null) as Double?) - - /** Upper bound for this tier */ - fun maximumUnits(maximumUnits: JsonField) = apply { - this.maximumUnits = maximumUnits - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Tier = - Tier( - checkRequired("unitAmount", unitAmount), - maximumUnits, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tier && unitAmount == other.unitAmount && maximumUnits == other.maximumUnits && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(unitAmount, maximumUnits, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{unitAmount=$unitAmount, maximumUnits=$maximumUnits, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BulkConfig && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkConfig{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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val BULK = of("bulk") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK -> Value.BULK - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - BULK -> Known.BULK - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionBulkPrice && bulkConfig == other.bulkConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bulkConfig, cadence, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionBulkPrice{bulkConfig=$bulkConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionThresholdTotalAmountPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("threshold_total_amount_config") - @ExcludeMissing - private val thresholdTotalAmountConfig: JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun thresholdTotalAmountConfig(): ThresholdTotalAmountConfig = - thresholdTotalAmountConfig.getRequired("threshold_total_amount_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("threshold_total_amount_config") - @ExcludeMissing - fun _thresholdTotalAmountConfig(): JsonField = - thresholdTotalAmountConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionThresholdTotalAmountPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - thresholdTotalAmountConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionThresholdTotalAmountPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var thresholdTotalAmountConfig: JsonField? = - null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionThresholdTotalAmountPrice: - NewSubscriptionThresholdTotalAmountPrice - ) = apply { - cadence = newSubscriptionThresholdTotalAmountPrice.cadence - itemId = newSubscriptionThresholdTotalAmountPrice.itemId - modelType = newSubscriptionThresholdTotalAmountPrice.modelType - name = newSubscriptionThresholdTotalAmountPrice.name - thresholdTotalAmountConfig = - newSubscriptionThresholdTotalAmountPrice.thresholdTotalAmountConfig - billableMetricId = newSubscriptionThresholdTotalAmountPrice.billableMetricId - billedInAdvance = newSubscriptionThresholdTotalAmountPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionThresholdTotalAmountPrice.billingCycleConfiguration - conversionRate = newSubscriptionThresholdTotalAmountPrice.conversionRate - currency = newSubscriptionThresholdTotalAmountPrice.currency - externalPriceId = newSubscriptionThresholdTotalAmountPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionThresholdTotalAmountPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionThresholdTotalAmountPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionThresholdTotalAmountPrice.invoicingCycleConfiguration - metadata = newSubscriptionThresholdTotalAmountPrice.metadata - referenceId = newSubscriptionThresholdTotalAmountPrice.referenceId - additionalProperties = - newSubscriptionThresholdTotalAmountPrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun thresholdTotalAmountConfig( - thresholdTotalAmountConfig: ThresholdTotalAmountConfig - ) = thresholdTotalAmountConfig(JsonField.of(thresholdTotalAmountConfig)) - - fun thresholdTotalAmountConfig( - thresholdTotalAmountConfig: JsonField - ) = apply { this.thresholdTotalAmountConfig = thresholdTotalAmountConfig } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionThresholdTotalAmountPrice = - NewSubscriptionThresholdTotalAmountPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("thresholdTotalAmountConfig", thresholdTotalAmountConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val THRESHOLD_TOTAL_AMOUNT = of("threshold_total_amount") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - THRESHOLD_TOTAL_AMOUNT - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - THRESHOLD_TOTAL_AMOUNT, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - THRESHOLD_TOTAL_AMOUNT -> Value.THRESHOLD_TOTAL_AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - THRESHOLD_TOTAL_AMOUNT -> Known.THRESHOLD_TOTAL_AMOUNT - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class ThresholdTotalAmountConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): ThresholdTotalAmountConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ThresholdTotalAmountConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(thresholdTotalAmountConfig: ThresholdTotalAmountConfig) = - apply { - additionalProperties = - thresholdTotalAmountConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): ThresholdTotalAmountConfig = - ThresholdTotalAmountConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ThresholdTotalAmountConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ThresholdTotalAmountConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionThresholdTotalAmountPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, thresholdTotalAmountConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionThresholdTotalAmountPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionTieredPackagePrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_package_config") - @ExcludeMissing - private val tieredPackageConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun tieredPackageConfig(): TieredPackageConfig = - tieredPackageConfig.getRequired("tiered_package_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("tiered_package_config") - @ExcludeMissing - fun _tieredPackageConfig(): JsonField = tieredPackageConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionTieredPackagePrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - tieredPackageConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionTieredPackagePrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var tieredPackageConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionTieredPackagePrice: NewSubscriptionTieredPackagePrice - ) = apply { - cadence = newSubscriptionTieredPackagePrice.cadence - itemId = newSubscriptionTieredPackagePrice.itemId - modelType = newSubscriptionTieredPackagePrice.modelType - name = newSubscriptionTieredPackagePrice.name - tieredPackageConfig = newSubscriptionTieredPackagePrice.tieredPackageConfig - billableMetricId = newSubscriptionTieredPackagePrice.billableMetricId - billedInAdvance = newSubscriptionTieredPackagePrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionTieredPackagePrice.billingCycleConfiguration - conversionRate = newSubscriptionTieredPackagePrice.conversionRate - currency = newSubscriptionTieredPackagePrice.currency - externalPriceId = newSubscriptionTieredPackagePrice.externalPriceId - fixedPriceQuantity = newSubscriptionTieredPackagePrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionTieredPackagePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionTieredPackagePrice.invoicingCycleConfiguration - metadata = newSubscriptionTieredPackagePrice.metadata - referenceId = newSubscriptionTieredPackagePrice.referenceId - additionalProperties = - newSubscriptionTieredPackagePrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = - tieredPackageConfig(JsonField.of(tieredPackageConfig)) - - fun tieredPackageConfig(tieredPackageConfig: JsonField) = - apply { - this.tieredPackageConfig = tieredPackageConfig - } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionTieredPackagePrice = - NewSubscriptionTieredPackagePrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("tieredPackageConfig", tieredPackageConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED_PACKAGE = of("tiered_package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_PACKAGE - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_PACKAGE, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_PACKAGE -> Value.TIERED_PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TIERED_PACKAGE -> Known.TIERED_PACKAGE - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TieredPackageConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredPackageConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredPackageConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tieredPackageConfig: TieredPackageConfig) = apply { - additionalProperties = - tieredPackageConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): TieredPackageConfig = - TieredPackageConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredPackageConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionTieredPackagePrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredPackageConfig == other.tieredPackageConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredPackageConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionTieredPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionTieredWithMinimumPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_minimum_config") - @ExcludeMissing - private val tieredWithMinimumConfig: JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun tieredWithMinimumConfig(): TieredWithMinimumConfig = - tieredWithMinimumConfig.getRequired("tiered_with_minimum_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("tiered_with_minimum_config") - @ExcludeMissing - fun _tieredWithMinimumConfig(): JsonField = - tieredWithMinimumConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionTieredWithMinimumPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - tieredWithMinimumConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionTieredWithMinimumPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var tieredWithMinimumConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionTieredWithMinimumPrice: NewSubscriptionTieredWithMinimumPrice - ) = apply { - cadence = newSubscriptionTieredWithMinimumPrice.cadence - itemId = newSubscriptionTieredWithMinimumPrice.itemId - modelType = newSubscriptionTieredWithMinimumPrice.modelType - name = newSubscriptionTieredWithMinimumPrice.name - tieredWithMinimumConfig = - newSubscriptionTieredWithMinimumPrice.tieredWithMinimumConfig - billableMetricId = newSubscriptionTieredWithMinimumPrice.billableMetricId - billedInAdvance = newSubscriptionTieredWithMinimumPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionTieredWithMinimumPrice.billingCycleConfiguration - conversionRate = newSubscriptionTieredWithMinimumPrice.conversionRate - currency = newSubscriptionTieredWithMinimumPrice.currency - externalPriceId = newSubscriptionTieredWithMinimumPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionTieredWithMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionTieredWithMinimumPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionTieredWithMinimumPrice.invoicingCycleConfiguration - metadata = newSubscriptionTieredWithMinimumPrice.metadata - referenceId = newSubscriptionTieredWithMinimumPrice.referenceId - additionalProperties = - newSubscriptionTieredWithMinimumPrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredWithMinimumConfig(tieredWithMinimumConfig: TieredWithMinimumConfig) = - tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) - - fun tieredWithMinimumConfig( - tieredWithMinimumConfig: JsonField - ) = apply { this.tieredWithMinimumConfig = tieredWithMinimumConfig } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionTieredWithMinimumPrice = - NewSubscriptionTieredWithMinimumPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("tieredWithMinimumConfig", tieredWithMinimumConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED_WITH_MINIMUM = of("tiered_with_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_WITH_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_WITH_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_WITH_MINIMUM -> Value.TIERED_WITH_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TIERED_WITH_MINIMUM -> Known.TIERED_WITH_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TieredWithMinimumConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredWithMinimumConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredWithMinimumConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tieredWithMinimumConfig: TieredWithMinimumConfig) = - apply { - additionalProperties = - tieredWithMinimumConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): TieredWithMinimumConfig = - TieredWithMinimumConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredWithMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredWithMinimumConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionTieredWithMinimumPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredWithMinimumConfig == other.tieredWithMinimumConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredWithMinimumConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionTieredWithMinimumPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionUnitWithPercentPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("unit_with_percent_config") - @ExcludeMissing - private val unitWithPercentConfig: JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun unitWithPercentConfig(): UnitWithPercentConfig = - unitWithPercentConfig.getRequired("unit_with_percent_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("unit_with_percent_config") - @ExcludeMissing - fun _unitWithPercentConfig(): JsonField = - unitWithPercentConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionUnitWithPercentPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - unitWithPercentConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionUnitWithPercentPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var unitWithPercentConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionUnitWithPercentPrice: NewSubscriptionUnitWithPercentPrice - ) = apply { - cadence = newSubscriptionUnitWithPercentPrice.cadence - itemId = newSubscriptionUnitWithPercentPrice.itemId - modelType = newSubscriptionUnitWithPercentPrice.modelType - name = newSubscriptionUnitWithPercentPrice.name - unitWithPercentConfig = - newSubscriptionUnitWithPercentPrice.unitWithPercentConfig - billableMetricId = newSubscriptionUnitWithPercentPrice.billableMetricId - billedInAdvance = newSubscriptionUnitWithPercentPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionUnitWithPercentPrice.billingCycleConfiguration - conversionRate = newSubscriptionUnitWithPercentPrice.conversionRate - currency = newSubscriptionUnitWithPercentPrice.currency - externalPriceId = newSubscriptionUnitWithPercentPrice.externalPriceId - fixedPriceQuantity = newSubscriptionUnitWithPercentPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionUnitWithPercentPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionUnitWithPercentPrice.invoicingCycleConfiguration - metadata = newSubscriptionUnitWithPercentPrice.metadata - referenceId = newSubscriptionUnitWithPercentPrice.referenceId - additionalProperties = - newSubscriptionUnitWithPercentPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun unitWithPercentConfig(unitWithPercentConfig: UnitWithPercentConfig) = - unitWithPercentConfig(JsonField.of(unitWithPercentConfig)) - - fun unitWithPercentConfig( - unitWithPercentConfig: JsonField - ) = apply { this.unitWithPercentConfig = unitWithPercentConfig } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionUnitWithPercentPrice = - NewSubscriptionUnitWithPercentPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("unitWithPercentConfig", unitWithPercentConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val UNIT_WITH_PERCENT = of("unit_with_percent") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - UNIT_WITH_PERCENT - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - UNIT_WITH_PERCENT, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - UNIT_WITH_PERCENT -> Value.UNIT_WITH_PERCENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - UNIT_WITH_PERCENT -> Known.UNIT_WITH_PERCENT - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class UnitWithPercentConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): UnitWithPercentConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnitWithPercentConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unitWithPercentConfig: UnitWithPercentConfig) = apply { - additionalProperties = - unitWithPercentConfig.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) - } - - fun build(): UnitWithPercentConfig = - UnitWithPercentConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UnitWithPercentConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnitWithPercentConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionUnitWithPercentPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && unitWithPercentConfig == other.unitWithPercentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, unitWithPercentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionUnitWithPercentPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionPackageWithAllocationPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("package_with_allocation_config") - @ExcludeMissing - private val packageWithAllocationConfig: JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun packageWithAllocationConfig(): PackageWithAllocationConfig = - packageWithAllocationConfig.getRequired("package_with_allocation_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("package_with_allocation_config") - @ExcludeMissing - fun _packageWithAllocationConfig(): JsonField = - packageWithAllocationConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionPackageWithAllocationPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - packageWithAllocationConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionPackageWithAllocationPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var packageWithAllocationConfig: - JsonField? = - null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionPackageWithAllocationPrice: - NewSubscriptionPackageWithAllocationPrice - ) = apply { - cadence = newSubscriptionPackageWithAllocationPrice.cadence - itemId = newSubscriptionPackageWithAllocationPrice.itemId - modelType = newSubscriptionPackageWithAllocationPrice.modelType - name = newSubscriptionPackageWithAllocationPrice.name - packageWithAllocationConfig = - newSubscriptionPackageWithAllocationPrice.packageWithAllocationConfig - billableMetricId = - newSubscriptionPackageWithAllocationPrice.billableMetricId - billedInAdvance = newSubscriptionPackageWithAllocationPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionPackageWithAllocationPrice.billingCycleConfiguration - conversionRate = newSubscriptionPackageWithAllocationPrice.conversionRate - currency = newSubscriptionPackageWithAllocationPrice.currency - externalPriceId = newSubscriptionPackageWithAllocationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionPackageWithAllocationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionPackageWithAllocationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionPackageWithAllocationPrice.invoicingCycleConfiguration - metadata = newSubscriptionPackageWithAllocationPrice.metadata - referenceId = newSubscriptionPackageWithAllocationPrice.referenceId - additionalProperties = - newSubscriptionPackageWithAllocationPrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun packageWithAllocationConfig( - packageWithAllocationConfig: PackageWithAllocationConfig - ) = packageWithAllocationConfig(JsonField.of(packageWithAllocationConfig)) - - fun packageWithAllocationConfig( - packageWithAllocationConfig: JsonField - ) = apply { this.packageWithAllocationConfig = packageWithAllocationConfig } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionPackageWithAllocationPrice = - NewSubscriptionPackageWithAllocationPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired( - "packageWithAllocationConfig", - packageWithAllocationConfig, - ), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val PACKAGE_WITH_ALLOCATION = of("package_with_allocation") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - PACKAGE_WITH_ALLOCATION - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PACKAGE_WITH_ALLOCATION, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PACKAGE_WITH_ALLOCATION -> Value.PACKAGE_WITH_ALLOCATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PACKAGE_WITH_ALLOCATION -> Known.PACKAGE_WITH_ALLOCATION - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class PackageWithAllocationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PackageWithAllocationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PackageWithAllocationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - packageWithAllocationConfig: PackageWithAllocationConfig - ) = apply { - additionalProperties = - packageWithAllocationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): PackageWithAllocationConfig = - PackageWithAllocationConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PackageWithAllocationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PackageWithAllocationConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionPackageWithAllocationPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && packageWithAllocationConfig == other.packageWithAllocationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, packageWithAllocationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionPackageWithAllocationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionTierWithProrationPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - private val tieredWithProrationConfig: JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - 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. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionTierWithProrationPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - tieredWithProrationConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionTierWithProrationPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var tieredWithProrationConfig: JsonField? = - null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionTierWithProrationPrice: NewSubscriptionTierWithProrationPrice - ) = apply { - cadence = newSubscriptionTierWithProrationPrice.cadence - itemId = newSubscriptionTierWithProrationPrice.itemId - modelType = newSubscriptionTierWithProrationPrice.modelType - name = newSubscriptionTierWithProrationPrice.name - tieredWithProrationConfig = - newSubscriptionTierWithProrationPrice.tieredWithProrationConfig - billableMetricId = newSubscriptionTierWithProrationPrice.billableMetricId - billedInAdvance = newSubscriptionTierWithProrationPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionTierWithProrationPrice.billingCycleConfiguration - conversionRate = newSubscriptionTierWithProrationPrice.conversionRate - currency = newSubscriptionTierWithProrationPrice.currency - externalPriceId = newSubscriptionTierWithProrationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionTierWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionTierWithProrationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionTierWithProrationPrice.invoicingCycleConfiguration - metadata = newSubscriptionTierWithProrationPrice.metadata - referenceId = newSubscriptionTierWithProrationPrice.referenceId - additionalProperties = - newSubscriptionTierWithProrationPrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredWithProrationConfig( - tieredWithProrationConfig: TieredWithProrationConfig - ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionTierWithProrationPrice = - NewSubscriptionTierWithProrationPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED_WITH_PRORATION = of("tiered_with_proration") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_WITH_PRORATION - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_WITH_PRORATION, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_WITH_PRORATION -> Value.TIERED_WITH_PRORATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TIERED_WITH_PRORATION -> Known.TIERED_WITH_PRORATION - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TieredWithProrationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredWithProrationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredWithProrationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = - apply { - additionalProperties = - tieredWithProrationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredWithProrationConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionTierWithProrationPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionTierWithProrationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionUnitWithProrationPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("unit_with_proration_config") - @ExcludeMissing - private val unitWithProrationConfig: JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun unitWithProrationConfig(): UnitWithProrationConfig = - unitWithProrationConfig.getRequired("unit_with_proration_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("unit_with_proration_config") - @ExcludeMissing - fun _unitWithProrationConfig(): JsonField = - unitWithProrationConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionUnitWithProrationPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - unitWithProrationConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionUnitWithProrationPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var unitWithProrationConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionUnitWithProrationPrice: NewSubscriptionUnitWithProrationPrice - ) = apply { - cadence = newSubscriptionUnitWithProrationPrice.cadence - itemId = newSubscriptionUnitWithProrationPrice.itemId - modelType = newSubscriptionUnitWithProrationPrice.modelType - name = newSubscriptionUnitWithProrationPrice.name - unitWithProrationConfig = - newSubscriptionUnitWithProrationPrice.unitWithProrationConfig - billableMetricId = newSubscriptionUnitWithProrationPrice.billableMetricId - billedInAdvance = newSubscriptionUnitWithProrationPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionUnitWithProrationPrice.billingCycleConfiguration - conversionRate = newSubscriptionUnitWithProrationPrice.conversionRate - currency = newSubscriptionUnitWithProrationPrice.currency - externalPriceId = newSubscriptionUnitWithProrationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionUnitWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionUnitWithProrationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionUnitWithProrationPrice.invoicingCycleConfiguration - metadata = newSubscriptionUnitWithProrationPrice.metadata - referenceId = newSubscriptionUnitWithProrationPrice.referenceId - additionalProperties = - newSubscriptionUnitWithProrationPrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun unitWithProrationConfig(unitWithProrationConfig: UnitWithProrationConfig) = - unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) - - fun unitWithProrationConfig( - unitWithProrationConfig: JsonField - ) = apply { this.unitWithProrationConfig = unitWithProrationConfig } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionUnitWithProrationPrice = - NewSubscriptionUnitWithProrationPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("unitWithProrationConfig", unitWithProrationConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val UNIT_WITH_PRORATION = of("unit_with_proration") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - UNIT_WITH_PRORATION - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - UNIT_WITH_PRORATION, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - UNIT_WITH_PRORATION -> Value.UNIT_WITH_PRORATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - UNIT_WITH_PRORATION -> Known.UNIT_WITH_PRORATION - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class UnitWithProrationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): UnitWithProrationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnitWithProrationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unitWithProrationConfig: UnitWithProrationConfig) = - apply { - additionalProperties = - unitWithProrationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): UnitWithProrationConfig = - UnitWithProrationConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UnitWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnitWithProrationConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionUnitWithProrationPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && unitWithProrationConfig == other.unitWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, unitWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionUnitWithProrationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionGroupedAllocationPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_allocation_config") - @ExcludeMissing - private val groupedAllocationConfig: JsonField = - JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - fun groupedAllocationConfig(): GroupedAllocationConfig = - groupedAllocationConfig.getRequired("grouped_allocation_config") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - @JsonProperty("grouped_allocation_config") - @ExcludeMissing - fun _groupedAllocationConfig(): JsonField = - groupedAllocationConfig - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionGroupedAllocationPrice = apply { - if (validated) { - return@apply - } - - cadence() - groupedAllocationConfig().validate() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionGroupedAllocationPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var groupedAllocationConfig: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var 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 currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionGroupedAllocationPrice: NewSubscriptionGroupedAllocationPrice - ) = apply { - cadence = newSubscriptionGroupedAllocationPrice.cadence - groupedAllocationConfig = - newSubscriptionGroupedAllocationPrice.groupedAllocationConfig - itemId = newSubscriptionGroupedAllocationPrice.itemId - modelType = newSubscriptionGroupedAllocationPrice.modelType - name = newSubscriptionGroupedAllocationPrice.name - billableMetricId = newSubscriptionGroupedAllocationPrice.billableMetricId - billedInAdvance = newSubscriptionGroupedAllocationPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionGroupedAllocationPrice.billingCycleConfiguration - conversionRate = newSubscriptionGroupedAllocationPrice.conversionRate - currency = newSubscriptionGroupedAllocationPrice.currency - externalPriceId = newSubscriptionGroupedAllocationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionGroupedAllocationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionGroupedAllocationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionGroupedAllocationPrice.invoicingCycleConfiguration - metadata = newSubscriptionGroupedAllocationPrice.metadata - referenceId = newSubscriptionGroupedAllocationPrice.referenceId - additionalProperties = - newSubscriptionGroupedAllocationPrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = - groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) - - fun groupedAllocationConfig( - groupedAllocationConfig: JsonField - ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionGroupedAllocationPrice = - NewSubscriptionGroupedAllocationPrice( - checkRequired("cadence", cadence), - checkRequired("groupedAllocationConfig", groupedAllocationConfig), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class GroupedAllocationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): GroupedAllocationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [GroupedAllocationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(groupedAllocationConfig: GroupedAllocationConfig) = - apply { - additionalProperties = - groupedAllocationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): GroupedAllocationConfig = - GroupedAllocationConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GroupedAllocationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedAllocationConfig{additionalProperties=$additionalProperties}" - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val GROUPED_ALLOCATION = of("grouped_allocation") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_ALLOCATION - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GROUPED_ALLOCATION, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GROUPED_ALLOCATION -> Value.GROUPED_ALLOCATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - GROUPED_ALLOCATION -> Known.GROUPED_ALLOCATION - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionGroupedAllocationPrice && cadence == other.cadence && groupedAllocationConfig == other.groupedAllocationConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, groupedAllocationConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionGroupedAllocationPrice{cadence=$cadence, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionGroupedWithProratedMinimumPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_prorated_minimum_config") - @ExcludeMissing - private val groupedWithProratedMinimumConfig: - JsonField = - JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - fun groupedWithProratedMinimumConfig(): GroupedWithProratedMinimumConfig = - groupedWithProratedMinimumConfig.getRequired( - "grouped_with_prorated_minimum_config" - ) - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - @JsonProperty("grouped_with_prorated_minimum_config") - @ExcludeMissing - fun _groupedWithProratedMinimumConfig(): - JsonField = groupedWithProratedMinimumConfig - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionGroupedWithProratedMinimumPrice = apply { - if (validated) { - return@apply - } - - cadence() - groupedWithProratedMinimumConfig().validate() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionGroupedWithProratedMinimumPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var groupedWithProratedMinimumConfig: - JsonField? = - null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionGroupedWithProratedMinimumPrice: - NewSubscriptionGroupedWithProratedMinimumPrice - ) = apply { - cadence = newSubscriptionGroupedWithProratedMinimumPrice.cadence - groupedWithProratedMinimumConfig = - newSubscriptionGroupedWithProratedMinimumPrice - .groupedWithProratedMinimumConfig - itemId = newSubscriptionGroupedWithProratedMinimumPrice.itemId - modelType = newSubscriptionGroupedWithProratedMinimumPrice.modelType - name = newSubscriptionGroupedWithProratedMinimumPrice.name - billableMetricId = - newSubscriptionGroupedWithProratedMinimumPrice.billableMetricId - billedInAdvance = - newSubscriptionGroupedWithProratedMinimumPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionGroupedWithProratedMinimumPrice.billingCycleConfiguration - conversionRate = - newSubscriptionGroupedWithProratedMinimumPrice.conversionRate - currency = newSubscriptionGroupedWithProratedMinimumPrice.currency - externalPriceId = - newSubscriptionGroupedWithProratedMinimumPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionGroupedWithProratedMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionGroupedWithProratedMinimumPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionGroupedWithProratedMinimumPrice - .invoicingCycleConfiguration - metadata = newSubscriptionGroupedWithProratedMinimumPrice.metadata - referenceId = newSubscriptionGroupedWithProratedMinimumPrice.referenceId - additionalProperties = - newSubscriptionGroupedWithProratedMinimumPrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - fun groupedWithProratedMinimumConfig( - groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig - ) = - groupedWithProratedMinimumConfig( - JsonField.of(groupedWithProratedMinimumConfig) - ) - - fun groupedWithProratedMinimumConfig( - groupedWithProratedMinimumConfig: - JsonField - ) = apply { - this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig - } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionGroupedWithProratedMinimumPrice = - NewSubscriptionGroupedWithProratedMinimumPrice( - checkRequired("cadence", cadence), - checkRequired( - "groupedWithProratedMinimumConfig", - groupedWithProratedMinimumConfig, - ), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class GroupedWithProratedMinimumConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): GroupedWithProratedMinimumConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [GroupedWithProratedMinimumConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig - ) = apply { - additionalProperties = - groupedWithProratedMinimumConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): GroupedWithProratedMinimumConfig = - GroupedWithProratedMinimumConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GroupedWithProratedMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedWithProratedMinimumConfig{additionalProperties=$additionalProperties}" - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField - val GROUPED_WITH_PRORATED_MINIMUM = of("grouped_with_prorated_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_WITH_PRORATED_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GROUPED_WITH_PRORATED_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GROUPED_WITH_PRORATED_MINIMUM -> Value.GROUPED_WITH_PRORATED_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - GROUPED_WITH_PRORATED_MINIMUM -> Known.GROUPED_WITH_PRORATED_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionGroupedWithProratedMinimumPrice && cadence == other.cadence && groupedWithProratedMinimumConfig == other.groupedWithProratedMinimumConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, groupedWithProratedMinimumConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionGroupedWithProratedMinimumPrice{cadence=$cadence, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionBulkWithProrationPrice - @JsonCreator - private constructor( - @JsonProperty("bulk_with_proration_config") - @ExcludeMissing - private val bulkWithProrationConfig: JsonField = - JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun bulkWithProrationConfig(): BulkWithProrationConfig = - bulkWithProrationConfig.getRequired("bulk_with_proration_config") - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - @JsonProperty("bulk_with_proration_config") - @ExcludeMissing - fun _bulkWithProrationConfig(): JsonField = - bulkWithProrationConfig - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionBulkWithProrationPrice = apply { - if (validated) { - return@apply - } - - bulkWithProrationConfig().validate() - cadence() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionBulkWithProrationPrice]. */ - class Builder internal constructor() { - - private var bulkWithProrationConfig: JsonField? = null - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var 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 currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionBulkWithProrationPrice: NewSubscriptionBulkWithProrationPrice - ) = apply { - bulkWithProrationConfig = - newSubscriptionBulkWithProrationPrice.bulkWithProrationConfig - cadence = newSubscriptionBulkWithProrationPrice.cadence - itemId = newSubscriptionBulkWithProrationPrice.itemId - modelType = newSubscriptionBulkWithProrationPrice.modelType - name = newSubscriptionBulkWithProrationPrice.name - billableMetricId = newSubscriptionBulkWithProrationPrice.billableMetricId - billedInAdvance = newSubscriptionBulkWithProrationPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionBulkWithProrationPrice.billingCycleConfiguration - conversionRate = newSubscriptionBulkWithProrationPrice.conversionRate - currency = newSubscriptionBulkWithProrationPrice.currency - externalPriceId = newSubscriptionBulkWithProrationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionBulkWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionBulkWithProrationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionBulkWithProrationPrice.invoicingCycleConfiguration - metadata = newSubscriptionBulkWithProrationPrice.metadata - referenceId = newSubscriptionBulkWithProrationPrice.referenceId - additionalProperties = - newSubscriptionBulkWithProrationPrice.additionalProperties - .toMutableMap() - } - - fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = - bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) - - fun bulkWithProrationConfig( - bulkWithProrationConfig: JsonField - ) = apply { this.bulkWithProrationConfig = bulkWithProrationConfig } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionBulkWithProrationPrice = - NewSubscriptionBulkWithProrationPrice( - checkRequired("bulkWithProrationConfig", bulkWithProrationConfig), - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BulkWithProrationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BulkWithProrationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkWithProrationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(bulkWithProrationConfig: BulkWithProrationConfig) = - apply { - additionalProperties = - bulkWithProrationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): BulkWithProrationConfig = - BulkWithProrationConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BulkWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkWithProrationConfig{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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val BULK_WITH_PRORATION = of("bulk_with_proration") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK_WITH_PRORATION - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK_WITH_PRORATION, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK_WITH_PRORATION -> Value.BULK_WITH_PRORATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - BULK_WITH_PRORATION -> Known.BULK_WITH_PRORATION - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionBulkWithProrationPrice && bulkWithProrationConfig == other.bulkWithProrationConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bulkWithProrationConfig, cadence, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionBulkWithProrationPrice{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AddPrice && allocationPrice == other.allocationPrice && discounts == other.discounts && endDate == other.endDate && externalPriceId == other.externalPriceId && maximumAmount == other.maximumAmount && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && price == other.price && priceId == other.priceId && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(allocationPrice, discounts, endDate, externalPriceId, maximumAmount, minimumAmount, planPhaseOrder, price, priceId, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AddPrice{allocationPrice=$allocationPrice, discounts=$discounts, endDate=$endDate, externalPriceId=$externalPriceId, maximumAmount=$maximumAmount, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, price=$price, priceId=$priceId, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - /** - * Reset billing periods to be aligned with the plan change's effective date or start of the - * month. Defaults to `unchanged` which keeps subscription's existing billing cycle alignment. - */ - class BillingCycleAlignment - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val UNCHANGED = of("unchanged") - - @JvmField val PLAN_CHANGE_DATE = of("plan_change_date") - - @JvmField val START_OF_MONTH = of("start_of_month") - - @JvmStatic fun of(value: String) = BillingCycleAlignment(JsonField.of(value)) - } - - /** An enum containing [BillingCycleAlignment]'s known values. */ - enum class Known { - UNCHANGED, - PLAN_CHANGE_DATE, - START_OF_MONTH, - } - - /** - * An enum containing [BillingCycleAlignment]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [BillingCycleAlignment] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - UNCHANGED, - PLAN_CHANGE_DATE, - START_OF_MONTH, - /** - * An enum member indicating that [BillingCycleAlignment] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - UNCHANGED -> Value.UNCHANGED - PLAN_CHANGE_DATE -> Value.PLAN_CHANGE_DATE - START_OF_MONTH -> Value.START_OF_MONTH - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - UNCHANGED -> Known.UNCHANGED - PLAN_CHANGE_DATE -> Known.PLAN_CHANGE_DATE - START_OF_MONTH -> Known.START_OF_MONTH - else -> throw OrbInvalidDataException("Unknown BillingCycleAlignment: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleAlignment && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class BillingCycleAnchorConfiguration - @JsonCreator - private constructor( - @JsonProperty("day") @ExcludeMissing private val day: JsonField = JsonMissing.of(), - @JsonProperty("month") - @ExcludeMissing - private val month: JsonField = JsonMissing.of(), - @JsonProperty("year") @ExcludeMissing private val year: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun day(): Long = day.getRequired("day") - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(): Optional = Optional.ofNullable(month.getNullable("month")) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on - * 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(): Optional = Optional.ofNullable(year.getNullable("year")) - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - @JsonProperty("day") @ExcludeMissing fun _day(): JsonField = day - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - @JsonProperty("month") @ExcludeMissing fun _month(): JsonField = month - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on - * 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - @JsonProperty("year") @ExcludeMissing fun _year(): JsonField = year - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleAnchorConfiguration = apply { - if (validated) { - return@apply - } - - day() - month() - year() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleAnchorConfiguration]. */ - class Builder internal constructor() { - - private var day: JsonField? = null - private var month: JsonField = JsonMissing.of() - private var year: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration) = - apply { - day = billingCycleAnchorConfiguration.day - month = billingCycleAnchorConfiguration.month - year = billingCycleAnchorConfiguration.year - additionalProperties = - billingCycleAnchorConfiguration.additionalProperties.toMutableMap() - } - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun day(day: Long) = day(JsonField.of(day)) - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun day(day: JsonField) = apply { this.day = day } - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(month: Long?) = month(JsonField.ofNullable(month)) - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(month: Long) = month(month as Long?) - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun month(month: Optional) = month(month.orElse(null) as Long?) - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(month: JsonField) = apply { this.month = month } - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(year: Long?) = year(JsonField.ofNullable(year)) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(year: Long) = year(year as Long?) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun year(year: Optional) = year(year.orElse(null) as Long?) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(year: JsonField) = apply { this.year = year } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleAnchorConfiguration = - BillingCycleAnchorConfiguration( - checkRequired("day", day), - month, - year, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleAnchorConfiguration && day == other.day && month == other.month && year == other.year && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(day, month, year, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleAnchorConfiguration{day=$day, month=$month, year=$year, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class RemoveAdjustment - @JsonCreator - private constructor( - @JsonProperty("adjustment_id") - @ExcludeMissing - private val adjustmentId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The id of the adjustment to remove on the subscription. */ - fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") - - /** The id of the adjustment to remove on the subscription. */ - @JsonProperty("adjustment_id") - @ExcludeMissing - fun _adjustmentId(): JsonField = adjustmentId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): RemoveAdjustment = apply { - if (validated) { - return@apply - } - - adjustmentId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - /** The id of the adjustment to remove on the subscription. */ - 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) - } - - fun build(): RemoveAdjustment = - RemoveAdjustment( - checkRequired("adjustmentId", adjustmentId), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RemoveAdjustment && adjustmentId == other.adjustmentId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustmentId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RemoveAdjustment{adjustmentId=$adjustmentId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class RemovePrice - @JsonCreator - private constructor( - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("price_id") - @ExcludeMissing - private val priceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The external price id of the price to remove on the subscription. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** The id of the price to remove on the subscription. */ - fun priceId(): Optional = Optional.ofNullable(priceId.getNullable("price_id")) - - /** The external price id of the price to remove on the subscription. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** The id of the price to remove on the subscription. */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): RemovePrice = apply { - if (validated) { - return@apply - } - - externalPriceId() - priceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - /** The external price id of the price to remove on the subscription. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** The external price id of the price to remove on the subscription. */ - 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)) - - /** The id of the price to remove on the subscription. */ - fun priceId(priceId: Optional) = priceId(priceId.orElse(null)) - - /** The id of the price to remove on the subscription. */ - 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) - } - - fun build(): RemovePrice = - RemovePrice(externalPriceId, priceId, additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RemovePrice && externalPriceId == other.externalPriceId && priceId == other.priceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(externalPriceId, priceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RemovePrice{externalPriceId=$externalPriceId, priceId=$priceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class ReplaceAdjustment - @JsonCreator - private constructor( - @JsonProperty("adjustment") - @ExcludeMissing - private val adjustment: JsonField = JsonMissing.of(), - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - private val replacesAdjustmentId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") - - /** The id of the adjustment on the plan to replace in the subscription. */ - fun replacesAdjustmentId(): String = - replacesAdjustmentId.getRequired("replaces_adjustment_id") - - /** The definition of a new adjustment to create and add to the subscription. */ - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment - - /** The id of the adjustment on the plan to replace in the subscription. */ - @JsonProperty("replaces_adjustment_id") - @ExcludeMissing - fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): ReplaceAdjustment = apply { - if (validated) { - return@apply - } - - adjustment().validate() - replacesAdjustmentId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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)) - - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } - - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(newPercentageDiscount: Adjustment.NewPercentageDiscount) = - adjustment(Adjustment.ofNewPercentageDiscount(newPercentageDiscount)) - - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(newUsageDiscount: Adjustment.NewUsageDiscount) = - adjustment(Adjustment.ofNewUsageDiscount(newUsageDiscount)) - - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(newAmountDiscount: Adjustment.NewAmountDiscount) = - adjustment(Adjustment.ofNewAmountDiscount(newAmountDiscount)) - - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(newMinimum: Adjustment.NewMinimum) = - adjustment(Adjustment.ofNewMinimum(newMinimum)) - - /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(newMaximum: Adjustment.NewMaximum) = - adjustment(Adjustment.ofNewMaximum(newMaximum)) - - /** The id of the adjustment on the plan to replace in the subscription. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = - replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) - - /** The id of the adjustment on the plan to replace in the subscription. */ - 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) - } - - fun build(): ReplaceAdjustment = - ReplaceAdjustment( - checkRequired("adjustment", adjustment), - checkRequired("replacesAdjustmentId", replacesAdjustmentId), - additionalProperties.toImmutable(), - ) - } - - /** The definition of a new adjustment to create and add to the subscription. */ - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val newPercentageDiscount: NewPercentageDiscount? = null, - private val newUsageDiscount: NewUsageDiscount? = null, - private val newAmountDiscount: NewAmountDiscount? = null, - private val newMinimum: NewMinimum? = null, - private val newMaximum: NewMaximum? = null, - private val _json: JsonValue? = null, - ) { - - fun newPercentageDiscount(): Optional = - Optional.ofNullable(newPercentageDiscount) - - fun newUsageDiscount(): Optional = - Optional.ofNullable(newUsageDiscount) - - fun newAmountDiscount(): Optional = - Optional.ofNullable(newAmountDiscount) - - fun newMinimum(): Optional = Optional.ofNullable(newMinimum) - - fun newMaximum(): Optional = Optional.ofNullable(newMaximum) - - fun isNewPercentageDiscount(): Boolean = newPercentageDiscount != null - - fun isNewUsageDiscount(): Boolean = newUsageDiscount != null - - fun isNewAmountDiscount(): Boolean = newAmountDiscount != null - - fun isNewMinimum(): Boolean = newMinimum != null - - fun isNewMaximum(): Boolean = newMaximum != null - - fun asNewPercentageDiscount(): NewPercentageDiscount = - newPercentageDiscount.getOrThrow("newPercentageDiscount") - - fun asNewUsageDiscount(): NewUsageDiscount = - newUsageDiscount.getOrThrow("newUsageDiscount") - - fun asNewAmountDiscount(): NewAmountDiscount = - newAmountDiscount.getOrThrow("newAmountDiscount") - - fun asNewMinimum(): NewMinimum = newMinimum.getOrThrow("newMinimum") - - fun asNewMaximum(): NewMaximum = newMaximum.getOrThrow("newMaximum") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - newPercentageDiscount != null -> - visitor.visitNewPercentageDiscount(newPercentageDiscount) - newUsageDiscount != null -> visitor.visitNewUsageDiscount(newUsageDiscount) - newAmountDiscount != null -> visitor.visitNewAmountDiscount(newAmountDiscount) - newMinimum != null -> visitor.visitNewMinimum(newMinimum) - newMaximum != null -> visitor.visitNewMaximum(newMaximum) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitNewPercentageDiscount( - newPercentageDiscount: NewPercentageDiscount - ) { - newPercentageDiscount.validate() - } - - override fun visitNewUsageDiscount(newUsageDiscount: NewUsageDiscount) { - newUsageDiscount.validate() - } - - override fun visitNewAmountDiscount(newAmountDiscount: NewAmountDiscount) { - newAmountDiscount.validate() - } - - override fun visitNewMinimum(newMinimum: NewMinimum) { - newMinimum.validate() - } - - override fun visitNewMaximum(newMaximum: NewMaximum) { - newMaximum.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Adjustment && newPercentageDiscount == other.newPercentageDiscount && newUsageDiscount == other.newUsageDiscount && newAmountDiscount == other.newAmountDiscount && newMinimum == other.newMinimum && newMaximum == other.newMaximum /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(newPercentageDiscount, newUsageDiscount, newAmountDiscount, newMinimum, newMaximum) /* spotless:on */ - - override fun toString(): String = - when { - newPercentageDiscount != null -> - "Adjustment{newPercentageDiscount=$newPercentageDiscount}" - newUsageDiscount != null -> "Adjustment{newUsageDiscount=$newUsageDiscount}" - newAmountDiscount != null -> "Adjustment{newAmountDiscount=$newAmountDiscount}" - newMinimum != null -> "Adjustment{newMinimum=$newMinimum}" - newMaximum != null -> "Adjustment{newMaximum=$newMaximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } - - companion object { - - @JvmStatic - fun ofNewPercentageDiscount(newPercentageDiscount: NewPercentageDiscount) = - Adjustment(newPercentageDiscount = newPercentageDiscount) - - @JvmStatic - fun ofNewUsageDiscount(newUsageDiscount: NewUsageDiscount) = - Adjustment(newUsageDiscount = newUsageDiscount) - - @JvmStatic - fun ofNewAmountDiscount(newAmountDiscount: NewAmountDiscount) = - Adjustment(newAmountDiscount = newAmountDiscount) - - @JvmStatic - fun ofNewMinimum(newMinimum: NewMinimum) = Adjustment(newMinimum = newMinimum) - - @JvmStatic - fun ofNewMaximum(newMaximum: NewMaximum) = Adjustment(newMaximum = newMaximum) - } - - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { - - fun visitNewPercentageDiscount(newPercentageDiscount: NewPercentageDiscount): T - - fun visitNewUsageDiscount(newUsageDiscount: NewUsageDiscount): T - - fun visitNewAmountDiscount(newAmountDiscount: NewAmountDiscount): T - - fun visitNewMinimum(newMinimum: NewMinimum): T - - fun visitNewMaximum(newMaximum: 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" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(newPercentageDiscount = it, _json = json) - } - } - "usage_discount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(newUsageDiscount = it, _json = json) - } - } - "amount_discount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(newAmountDiscount = it, _json = json) - } - } - "minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Adjustment(newMinimum = it, _json = json) - } - } - "maximum" -> { - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Adjustment(newMaximum = it, _json = json) - } - } - } - - return Adjustment(_json = json) - } - } - - internal class Serializer : BaseSerializer(Adjustment::class) { - - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.newPercentageDiscount != null -> - generator.writeObject(value.newPercentageDiscount) - value.newUsageDiscount != null -> - generator.writeObject(value.newUsageDiscount) - value.newAmountDiscount != null -> - generator.writeObject(value.newAmountDiscount) - value.newMinimum != null -> generator.writeObject(value.newMinimum) - value.newMaximum != null -> generator.writeObject(value.newMaximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") - } - } - } - - @NoAutoDetect - class NewPercentageDiscount - @JsonCreator - private constructor( - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("percentage_discount") - @ExcludeMissing - private val percentageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - fun percentageDiscount(): Double = - percentageDiscount.getRequired("percentage_discount") - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(): Optional = - Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The set of price IDs to which this adjustment applies. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - @JsonProperty("percentage_discount") - @ExcludeMissing - fun _percentageDiscount(): JsonField = percentageDiscount - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewPercentageDiscount = apply { - if (validated) { - return@apply - } - - adjustmentType() - appliesToPriceIds() - percentageDiscount() - isInvoiceLevel() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewPercentageDiscount]. */ - class Builder internal constructor() { - - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var percentageDiscount: JsonField? = null - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newPercentageDiscount: NewPercentageDiscount) = apply { - adjustmentType = newPercentageDiscount.adjustmentType - appliesToPriceIds = - newPercentageDiscount.appliesToPriceIds.map { it.toMutableList() } - percentageDiscount = newPercentageDiscount.percentageDiscount - isInvoiceLevel = newPercentageDiscount.isInvoiceLevel - additionalProperties = - newPercentageDiscount.additionalProperties.toMutableMap() - } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The set of price IDs to which this adjustment applies. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - fun percentageDiscount(percentageDiscount: Double) = - percentageDiscount(JsonField.of(percentageDiscount)) - - fun percentageDiscount(percentageDiscount: JsonField) = apply { - this.percentageDiscount = percentageDiscount - } - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): NewPercentageDiscount = - NewPercentageDiscount( - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("percentageDiscount", percentageDiscount), - isInvoiceLevel, - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val PERCENTAGE_DISCOUNT = of("percentage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewPercentageDiscount && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && percentageDiscount == other.percentageDiscount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustmentType, appliesToPriceIds, percentageDiscount, isInvoiceLevel, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewPercentageDiscount{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, percentageDiscount=$percentageDiscount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewUsageDiscount - @JsonCreator - private constructor( - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("usage_discount") - @ExcludeMissing - private val usageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(): Optional = - Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The set of price IDs to which this adjustment applies. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - @JsonProperty("usage_discount") - @ExcludeMissing - fun _usageDiscount(): JsonField = usageDiscount - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewUsageDiscount = apply { - if (validated) { - return@apply - } - - adjustmentType() - appliesToPriceIds() - usageDiscount() - isInvoiceLevel() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewUsageDiscount]. */ - class Builder internal constructor() { - - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var usageDiscount: JsonField? = null - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newUsageDiscount: NewUsageDiscount) = apply { - adjustmentType = newUsageDiscount.adjustmentType - appliesToPriceIds = - newUsageDiscount.appliesToPriceIds.map { it.toMutableList() } - usageDiscount = newUsageDiscount.usageDiscount - isInvoiceLevel = newUsageDiscount.isInvoiceLevel - additionalProperties = newUsageDiscount.additionalProperties.toMutableMap() - } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The set of price IDs to which this adjustment applies. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - fun usageDiscount(usageDiscount: Double) = - usageDiscount(JsonField.of(usageDiscount)) - - fun usageDiscount(usageDiscount: JsonField) = apply { - this.usageDiscount = usageDiscount - } - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): NewUsageDiscount = - NewUsageDiscount( - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("usageDiscount", usageDiscount), - isInvoiceLevel, - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - USAGE_DISCOUNT -> Known.USAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewUsageDiscount && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && usageDiscount == other.usageDiscount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustmentType, appliesToPriceIds, usageDiscount, isInvoiceLevel, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewUsageDiscount{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, usageDiscount=$usageDiscount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewAmountDiscount - @JsonCreator - private constructor( - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("amount_discount") - @ExcludeMissing - private val amountDiscount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(): Optional = - Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - @JsonProperty("amount_discount") - @ExcludeMissing - fun _amountDiscount(): JsonField = amountDiscount - - /** The set of price IDs to which this adjustment applies. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewAmountDiscount = apply { - if (validated) { - return@apply - } - - adjustmentType() - amountDiscount() - appliesToPriceIds() - isInvoiceLevel() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewAmountDiscount]. */ - class Builder internal constructor() { - - private var adjustmentType: JsonField? = null - private var amountDiscount: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newAmountDiscount: NewAmountDiscount) = apply { - adjustmentType = newAmountDiscount.adjustmentType - amountDiscount = newAmountDiscount.amountDiscount - appliesToPriceIds = - newAmountDiscount.appliesToPriceIds.map { it.toMutableList() } - isInvoiceLevel = newAmountDiscount.isInvoiceLevel - additionalProperties = newAmountDiscount.additionalProperties.toMutableMap() - } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - fun amountDiscount(amountDiscount: String) = - amountDiscount(JsonField.of(amountDiscount)) - - fun amountDiscount(amountDiscount: JsonField) = apply { - this.amountDiscount = amountDiscount - } - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The set of price IDs to which this adjustment applies. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): NewAmountDiscount = - NewAmountDiscount( - checkRequired("adjustmentType", adjustmentType), - checkRequired("amountDiscount", amountDiscount), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - isInvoiceLevel, - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewAmountDiscount && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustmentType, amountDiscount, appliesToPriceIds, isInvoiceLevel, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewAmountDiscount{adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewMinimum - @JsonCreator - private constructor( - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(): Optional = - Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The set of price IDs to which this adjustment applies. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The item ID that revenue from this minimum will be attributed to. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewMinimum = apply { - if (validated) { - return@apply - } - - adjustmentType() - appliesToPriceIds() - itemId() - minimumAmount() - isInvoiceLevel() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewMinimum]. */ - class Builder internal constructor() { - - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var itemId: JsonField? = null - private var minimumAmount: JsonField? = null - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newMinimum: NewMinimum) = apply { - adjustmentType = newMinimum.adjustmentType - appliesToPriceIds = newMinimum.appliesToPriceIds.map { it.toMutableList() } - itemId = newMinimum.itemId - minimumAmount = newMinimum.minimumAmount - isInvoiceLevel = newMinimum.isInvoiceLevel - additionalProperties = newMinimum.additionalProperties.toMutableMap() - } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The set of price IDs to which this adjustment applies. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): NewMinimum = - NewMinimum( - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("itemId", itemId), - checkRequired("minimumAmount", minimumAmount), - isInvoiceLevel, - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewMinimum && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && itemId == other.itemId && minimumAmount == other.minimumAmount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustmentType, appliesToPriceIds, itemId, minimumAmount, isInvoiceLevel, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewMinimum{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, itemId=$itemId, minimumAmount=$minimumAmount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewMaximum - @JsonCreator - private constructor( - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(): Optional = - Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The set of price IDs to which this adjustment applies. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it will - * be applied at the invoice level, possibly to multiple prices. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewMaximum = apply { - if (validated) { - return@apply - } - - adjustmentType() - appliesToPriceIds() - maximumAmount() - isInvoiceLevel() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewMaximum]. */ - class Builder internal constructor() { - - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var maximumAmount: JsonField? = null - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newMaximum: NewMaximum) = apply { - adjustmentType = newMaximum.adjustmentType - appliesToPriceIds = newMaximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = newMaximum.maximumAmount - isInvoiceLevel = newMaximum.isInvoiceLevel - additionalProperties = newMaximum.additionalProperties.toMutableMap() - } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The set of price IDs to which this adjustment applies. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): NewMaximum = - NewMaximum( - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("maximumAmount", maximumAmount), - isInvoiceLevel, - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewMaximum && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustmentType, appliesToPriceIds, maximumAmount, isInvoiceLevel, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewMaximum{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ReplaceAdjustment && adjustment == other.adjustment && replacesAdjustmentId == other.replacesAdjustmentId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(adjustment, replacesAdjustmentId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ReplaceAdjustment{adjustment=$adjustment, replacesAdjustmentId=$replacesAdjustmentId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class ReplacePrice - @JsonCreator - private constructor( - @JsonProperty("replaces_price_id") - @ExcludeMissing - private val replacesPriceId: JsonField = JsonMissing.of(), - @JsonProperty("allocation_price") - @ExcludeMissing - private val allocationPrice: JsonField = JsonMissing.of(), - @JsonProperty("discounts") - @ExcludeMissing - private val discounts: JsonField> = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("price") - @ExcludeMissing - private val price: JsonField = JsonMissing.of(), - @JsonProperty("price_id") - @ExcludeMissing - private val priceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The id of the price on the plan to replace in the subscription. */ - fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") - - /** The definition of a new allocation price to create and add to the subscription. */ - fun allocationPrice(): Optional = - Optional.ofNullable(allocationPrice.getNullable("allocation_price")) - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - */ - @Deprecated("deprecated") - fun discounts(): Optional> = - Optional.ofNullable(discounts.getNullable("discounts")) - - /** The external price id of the price to add to the subscription. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** The new quantity of the price, if the price is a fixed price. */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun maximumAmount(): Optional = - Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun minimumAmount(): Optional = - Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) - - /** The definition of a new price to create and add to the subscription. */ - fun price(): Optional = Optional.ofNullable(price.getNullable("price")) - - /** The id of the price to add to the subscription. */ - fun priceId(): Optional = Optional.ofNullable(priceId.getNullable("price_id")) - - /** The id of the price on the plan to replace in the subscription. */ - @JsonProperty("replaces_price_id") - @ExcludeMissing - fun _replacesPriceId(): JsonField = replacesPriceId - - /** The definition of a new allocation price to create and add to the subscription. */ - @JsonProperty("allocation_price") - @ExcludeMissing - fun _allocationPrice(): JsonField = allocationPrice - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - */ - @Deprecated("deprecated") - @JsonProperty("discounts") - @ExcludeMissing - fun _discounts(): JsonField> = discounts - - /** The external price id of the price to add to the subscription. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** The new quantity of the price, if the price is a fixed price. */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. - */ - @Deprecated("deprecated") - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - */ - @Deprecated("deprecated") - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** The definition of a new price to create and add to the subscription. */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - - /** The id of the price to add to the subscription. */ - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): ReplacePrice = apply { - if (validated) { - return@apply - } - - replacesPriceId() - allocationPrice().ifPresent { it.validate() } - discounts().ifPresent { it.forEach { it.validate() } } - externalPriceId() - fixedPriceQuantity() - maximumAmount() - minimumAmount() - price().ifPresent { it.validate() } - priceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ReplacePrice]. */ - class Builder internal constructor() { - - private var replacesPriceId: JsonField? = null - private var allocationPrice: JsonField = JsonMissing.of() - private var discounts: JsonField>? = null - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(replacePrice: ReplacePrice) = apply { - replacesPriceId = replacePrice.replacesPriceId - allocationPrice = replacePrice.allocationPrice - discounts = replacePrice.discounts.map { it.toMutableList() } - externalPriceId = replacePrice.externalPriceId - fixedPriceQuantity = replacePrice.fixedPriceQuantity - maximumAmount = replacePrice.maximumAmount - minimumAmount = replacePrice.minimumAmount - price = replacePrice.price - priceId = replacePrice.priceId - additionalProperties = replacePrice.additionalProperties.toMutableMap() - } - - /** The id of the price on the plan to replace in the subscription. */ - fun replacesPriceId(replacesPriceId: String) = - replacesPriceId(JsonField.of(replacesPriceId)) - - /** The id of the price on the plan to replace in the subscription. */ - 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: AllocationPrice?) = - allocationPrice(JsonField.ofNullable(allocationPrice)) - - /** The definition of a new allocation price to create and add to the subscription. */ - fun allocationPrice(allocationPrice: Optional) = - allocationPrice(allocationPrice.orElse(null)) - - /** The definition of a new allocation price to create and add to the subscription. */ - 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)) - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - */ - @Deprecated("deprecated") - fun discounts(discounts: Optional>) = discounts(discounts.orElse(null)) - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - */ - @Deprecated("deprecated") - fun discounts(discounts: JsonField>) = apply { - this.discounts = discounts.map { it.toMutableList() } - } - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the - * replacement price. - */ - @Deprecated("deprecated") - fun addDiscount(discount: Discount) = apply { - discounts = - (discounts ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(discount) - } - } - - /** The external price id of the price to add to the subscription. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** The external price id of the price to add to the subscription. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** The external price id of the price to add to the subscription. */ - 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)) - - /** The new quantity of the price, if the price is a fixed price. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** The new quantity of the price, if the price is a fixed price. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** The new quantity of the price, if the price is a fixed price. */ - 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)) - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.orElse(null)) - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: String?) = - minimumAmount(JsonField.ofNullable(minimumAmount)) - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: Optional) = - minimumAmount(minimumAmount.orElse(null)) - - /** - * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the - * replacement price. - */ - @Deprecated("deprecated") - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** The definition of a new price to create and add to the subscription. */ - fun price(price: Price?) = price(JsonField.ofNullable(price)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(price: Optional) = price(price.orElse(null)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(price: JsonField) = apply { this.price = price } - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionUnit: Price.NewSubscriptionUnitPrice) = - price(Price.ofNewSubscriptionUnit(newSubscriptionUnit)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionPackage: Price.NewSubscriptionPackagePrice) = - price(Price.ofNewSubscriptionPackage(newSubscriptionPackage)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionMatrix: Price.NewSubscriptionMatrixPrice) = - price(Price.ofNewSubscriptionMatrix(newSubscriptionMatrix)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionTiered: Price.NewSubscriptionTieredPrice) = - price(Price.ofNewSubscriptionTiered(newSubscriptionTiered)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionTieredBps: Price.NewSubscriptionTieredBpsPrice) = - price(Price.ofNewSubscriptionTieredBps(newSubscriptionTieredBps)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionBps: Price.NewSubscriptionBpsPrice) = - price(Price.ofNewSubscriptionBps(newSubscriptionBps)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionBulkBps: Price.NewSubscriptionBulkBpsPrice) = - price(Price.ofNewSubscriptionBulkBps(newSubscriptionBulkBps)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionBulk: Price.NewSubscriptionBulkPrice) = - price(Price.ofNewSubscriptionBulk(newSubscriptionBulk)) - - /** The definition of a new price to create and add to the subscription. */ - fun price( - newSubscriptionThresholdTotalAmount: Price.NewSubscriptionThresholdTotalAmountPrice - ) = - price( - Price.ofNewSubscriptionThresholdTotalAmount(newSubscriptionThresholdTotalAmount) - ) - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionTieredPackage: Price.NewSubscriptionTieredPackagePrice) = - price(Price.ofNewSubscriptionTieredPackage(newSubscriptionTieredPackage)) - - /** The definition of a new price to create and add to the subscription. */ - fun price( - newSubscriptionTieredWithMinimum: Price.NewSubscriptionTieredWithMinimumPrice - ) = price(Price.ofNewSubscriptionTieredWithMinimum(newSubscriptionTieredWithMinimum)) - - /** The definition of a new price to create and add to the subscription. */ - fun price(newSubscriptionUnitWithPercent: Price.NewSubscriptionUnitWithPercentPrice) = - price(Price.ofNewSubscriptionUnitWithPercent(newSubscriptionUnitWithPercent)) - - /** The definition of a new price to create and add to the subscription. */ - fun price( - newSubscriptionPackageWithAllocation: - Price.NewSubscriptionPackageWithAllocationPrice - ) = - price( - Price.ofNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation - ) - ) - - /** The definition of a new price to create and add to the subscription. */ - fun price( - newSubscriptionTierWithProration: Price.NewSubscriptionTierWithProrationPrice - ) = price(Price.ofNewSubscriptionTierWithProration(newSubscriptionTierWithProration)) - - /** The definition of a new price to create and add to the subscription. */ - fun price( - newSubscriptionUnitWithProration: Price.NewSubscriptionUnitWithProrationPrice - ) = price(Price.ofNewSubscriptionUnitWithProration(newSubscriptionUnitWithProration)) - - /** The definition of a new price to create and add to the subscription. */ - fun price( - newSubscriptionGroupedAllocation: Price.NewSubscriptionGroupedAllocationPrice - ) = price(Price.ofNewSubscriptionGroupedAllocation(newSubscriptionGroupedAllocation)) - - /** The definition of a new price to create and add to the subscription. */ - fun price( - newSubscriptionGroupedWithProratedMinimum: - Price.NewSubscriptionGroupedWithProratedMinimumPrice - ) = - price( - Price.ofNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum - ) - ) - - /** The definition of a new price to create and add to the subscription. */ - fun price( - newSubscriptionBulkWithProration: Price.NewSubscriptionBulkWithProrationPrice - ) = price(Price.ofNewSubscriptionBulkWithProration(newSubscriptionBulkWithProration)) - - /** The id of the price to add to the subscription. */ - fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) - - /** The id of the price to add to the subscription. */ - fun priceId(priceId: Optional) = priceId(priceId.orElse(null)) - - /** The id of the price to add to the subscription. */ - 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) - } - - fun build(): ReplacePrice = - ReplacePrice( - checkRequired("replacesPriceId", replacesPriceId), - allocationPrice, - (discounts ?: JsonMissing.of()).map { it.toImmutable() }, - externalPriceId, - fixedPriceQuantity, - maximumAmount, - minimumAmount, - price, - priceId, - additionalProperties.toImmutable(), - ) - } - - /** The definition of a new allocation price to create and add to the subscription. */ - @NoAutoDetect - class AllocationPrice - @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - private val amount: JsonField = JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("expires_at_end_of_cadence") - @ExcludeMissing - private val expiresAtEndOfCadence: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** An amount of the currency to allocate to the customer at the specified cadence. */ - fun amount(): String = amount.getRequired("amount") - - /** The cadence at which to allocate the amount to the customer. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** - * An ISO 4217 currency string or a custom pricing unit identifier in which to bill this - * price. - */ - fun currency(): String = currency.getRequired("currency") - - /** - * Whether the allocated amount should expire at the end of the cadence or roll over to - * the next period. - */ - fun expiresAtEndOfCadence(): Boolean = - expiresAtEndOfCadence.getRequired("expires_at_end_of_cadence") - - /** An amount of the currency to allocate to the customer at the specified cadence. */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** The cadence at which to allocate the amount to the customer. */ - @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - - /** - * An ISO 4217 currency string or a custom pricing unit identifier in which to bill this - * price. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** - * Whether the allocated amount should expire at the end of the cadence or roll over to - * the next period. - */ - @JsonProperty("expires_at_end_of_cadence") - @ExcludeMissing - fun _expiresAtEndOfCadence(): JsonField = expiresAtEndOfCadence - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AllocationPrice = apply { - if (validated) { - return@apply - } - - amount() - cadence() - currency() - expiresAtEndOfCadence() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AllocationPrice]. */ - class Builder internal constructor() { - - private var amount: JsonField? = null - private var cadence: JsonField? = null - private var currency: JsonField? = null - private var expiresAtEndOfCadence: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(allocationPrice: AllocationPrice) = apply { - amount = allocationPrice.amount - cadence = allocationPrice.cadence - currency = allocationPrice.currency - expiresAtEndOfCadence = allocationPrice.expiresAtEndOfCadence - additionalProperties = allocationPrice.additionalProperties.toMutableMap() - } - - /** - * An amount of the currency to allocate to the customer at the specified cadence. - */ - fun amount(amount: String) = amount(JsonField.of(amount)) - - /** - * An amount of the currency to allocate to the customer at the specified cadence. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** The cadence at which to allocate the amount to the customer. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence at which to allocate the amount to the customer. */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - /** - * An ISO 4217 currency string or a custom pricing unit identifier in which to bill - * this price. - */ - fun currency(currency: String) = currency(JsonField.of(currency)) - - /** - * An ISO 4217 currency string or a custom pricing unit identifier in which to bill - * this price. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** - * Whether the allocated amount should expire at the end of the cadence or roll over - * to the next period. - */ - fun expiresAtEndOfCadence(expiresAtEndOfCadence: Boolean) = - expiresAtEndOfCadence(JsonField.of(expiresAtEndOfCadence)) - - /** - * Whether the allocated amount should expire at the end of the cadence or roll over - * to the next period. - */ - fun expiresAtEndOfCadence(expiresAtEndOfCadence: JsonField) = apply { - this.expiresAtEndOfCadence = expiresAtEndOfCadence - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): AllocationPrice = - AllocationPrice( - checkRequired("amount", amount), - checkRequired("cadence", cadence), - checkRequired("currency", currency), - checkRequired("expiresAtEndOfCadence", expiresAtEndOfCadence), - additionalProperties.toImmutable(), - ) - } - - /** The cadence at which to allocate the amount to the customer. */ - 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AllocationPrice && amount == other.amount && cadence == other.cadence && currency == other.currency && expiresAtEndOfCadence == other.expiresAtEndOfCadence && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, cadence, currency, expiresAtEndOfCadence, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AllocationPrice{amount=$amount, cadence=$cadence, currency=$currency, expiresAtEndOfCadence=$expiresAtEndOfCadence, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Discount - @JsonCreator - private constructor( - @JsonProperty("discount_type") - @ExcludeMissing - private val discountType: JsonField = JsonMissing.of(), - @JsonProperty("amount_discount") - @ExcludeMissing - private val amountDiscount: JsonField = JsonMissing.of(), - @JsonProperty("percentage_discount") - @ExcludeMissing - private val percentageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("usage_discount") - @ExcludeMissing - private val usageDiscount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun discountType(): DiscountType = discountType.getRequired("discount_type") - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(): Optional = - Optional.ofNullable(amountDiscount.getNullable("amount_discount")) - - /** - * Only available if discount_type is `percentage`. This is a number between 0 and 1. - */ - fun percentageDiscount(): Optional = - Optional.ofNullable(percentageDiscount.getNullable("percentage_discount")) - - /** - * Only available if discount_type is `usage`. Number of usage units that this discount - * is for - */ - fun usageDiscount(): Optional = - Optional.ofNullable(usageDiscount.getNullable("usage_discount")) - - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - - /** Only available if discount_type is `amount`. */ - @JsonProperty("amount_discount") - @ExcludeMissing - fun _amountDiscount(): JsonField = amountDiscount - - /** - * Only available if discount_type is `percentage`. This is a number between 0 and 1. - */ - @JsonProperty("percentage_discount") - @ExcludeMissing - fun _percentageDiscount(): JsonField = percentageDiscount - - /** - * Only available if discount_type is `usage`. Number of usage units that this discount - * is for - */ - @JsonProperty("usage_discount") - @ExcludeMissing - fun _usageDiscount(): JsonField = usageDiscount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Discount = apply { - if (validated) { - return@apply - } - - discountType() - amountDiscount() - percentageDiscount() - usageDiscount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Discount]. */ - class Builder internal constructor() { - - private var discountType: JsonField? = null - private var amountDiscount: JsonField = JsonMissing.of() - private var percentageDiscount: JsonField = JsonMissing.of() - private var usageDiscount: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(discount: Discount) = apply { - discountType = discount.discountType - amountDiscount = discount.amountDiscount - percentageDiscount = discount.percentageDiscount - usageDiscount = discount.usageDiscount - additionalProperties = discount.additionalProperties.toMutableMap() - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(amountDiscount: String?) = - amountDiscount(JsonField.ofNullable(amountDiscount)) - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(amountDiscount: Optional) = - amountDiscount(amountDiscount.orElse(null)) - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(amountDiscount: JsonField) = apply { - this.amountDiscount = amountDiscount - } - - /** - * Only available if discount_type is `percentage`. This is a number between 0 - * and 1. - */ - fun percentageDiscount(percentageDiscount: Double?) = - percentageDiscount(JsonField.ofNullable(percentageDiscount)) - - /** - * Only available if discount_type is `percentage`. This is a number between 0 - * and 1. - */ - fun percentageDiscount(percentageDiscount: Double) = - percentageDiscount(percentageDiscount as Double?) - - /** - * Only available if discount_type is `percentage`. This is a number between 0 - * and 1. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun percentageDiscount(percentageDiscount: Optional) = - percentageDiscount(percentageDiscount.orElse(null) as Double?) - - /** - * Only available if discount_type is `percentage`. This is a number between 0 - * and 1. - */ - fun percentageDiscount(percentageDiscount: JsonField) = apply { - this.percentageDiscount = percentageDiscount - } - - /** - * Only available if discount_type is `usage`. Number of usage units that this - * discount is for - */ - fun usageDiscount(usageDiscount: Double?) = - usageDiscount(JsonField.ofNullable(usageDiscount)) - - /** - * Only available if discount_type is `usage`. Number of usage units that this - * discount is for - */ - fun usageDiscount(usageDiscount: Double) = usageDiscount(usageDiscount as Double?) - - /** - * Only available if discount_type is `usage`. Number of usage units that this - * discount is for - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun usageDiscount(usageDiscount: Optional) = - usageDiscount(usageDiscount.orElse(null) as Double?) - - /** - * Only available if discount_type is `usage`. Number of usage units that this - * discount is for - */ - fun usageDiscount(usageDiscount: JsonField) = apply { - this.usageDiscount = usageDiscount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Discount = - Discount( - checkRequired("discountType", discountType), - amountDiscount, - percentageDiscount, - usageDiscount, - additionalProperties.toImmutable(), - ) - } - - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val PERCENTAGE = of("percentage") - - @JvmField val USAGE = of("usage") - - @JvmField val AMOUNT = of("amount") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - PERCENTAGE, - USAGE, - AMOUNT, - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE, - USAGE, - AMOUNT, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE -> Value.PERCENTAGE - USAGE -> Value.USAGE - AMOUNT -> Value.AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PERCENTAGE -> Known.PERCENTAGE - USAGE -> Known.USAGE - AMOUNT -> Known.AMOUNT - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Discount && discountType == other.discountType && amountDiscount == other.amountDiscount && percentageDiscount == other.percentageDiscount && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(discountType, amountDiscount, percentageDiscount, usageDiscount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Discount{discountType=$discountType, amountDiscount=$amountDiscount, percentageDiscount=$percentageDiscount, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" - } - - /** The definition of a new price to create and add to the subscription. */ - @JsonDeserialize(using = Price.Deserializer::class) - @JsonSerialize(using = Price.Serializer::class) - class Price - private constructor( - private val newSubscriptionUnit: NewSubscriptionUnitPrice? = null, - private val newSubscriptionPackage: NewSubscriptionPackagePrice? = null, - private val newSubscriptionMatrix: NewSubscriptionMatrixPrice? = null, - private val newSubscriptionTiered: NewSubscriptionTieredPrice? = null, - private val newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice? = null, - private val newSubscriptionBps: NewSubscriptionBpsPrice? = null, - private val newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice? = null, - private val newSubscriptionBulk: NewSubscriptionBulkPrice? = null, - private val newSubscriptionThresholdTotalAmount: - NewSubscriptionThresholdTotalAmountPrice? = - null, - private val newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice? = null, - private val newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = - null, - private val newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, - private val newSubscriptionPackageWithAllocation: - NewSubscriptionPackageWithAllocationPrice? = - null, - private val newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice? = - null, - private val newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice? = - null, - private val newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice? = - null, - private val newSubscriptionGroupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice? = - null, - private val newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice? = - null, - private val _json: JsonValue? = null, - ) { - - fun newSubscriptionUnit(): Optional = - Optional.ofNullable(newSubscriptionUnit) - - fun newSubscriptionPackage(): Optional = - Optional.ofNullable(newSubscriptionPackage) - - fun newSubscriptionMatrix(): Optional = - Optional.ofNullable(newSubscriptionMatrix) - - fun newSubscriptionTiered(): Optional = - Optional.ofNullable(newSubscriptionTiered) - - fun newSubscriptionTieredBps(): Optional = - Optional.ofNullable(newSubscriptionTieredBps) - - fun newSubscriptionBps(): Optional = - Optional.ofNullable(newSubscriptionBps) - - fun newSubscriptionBulkBps(): Optional = - Optional.ofNullable(newSubscriptionBulkBps) - - fun newSubscriptionBulk(): Optional = - Optional.ofNullable(newSubscriptionBulk) - - fun newSubscriptionThresholdTotalAmount(): - Optional = - Optional.ofNullable(newSubscriptionThresholdTotalAmount) - - fun newSubscriptionTieredPackage(): Optional = - Optional.ofNullable(newSubscriptionTieredPackage) - - fun newSubscriptionTieredWithMinimum(): - Optional = - Optional.ofNullable(newSubscriptionTieredWithMinimum) - - fun newSubscriptionUnitWithPercent(): Optional = - Optional.ofNullable(newSubscriptionUnitWithPercent) - - fun newSubscriptionPackageWithAllocation(): - Optional = - Optional.ofNullable(newSubscriptionPackageWithAllocation) - - fun newSubscriptionTierWithProration(): - Optional = - Optional.ofNullable(newSubscriptionTierWithProration) - - fun newSubscriptionUnitWithProration(): - Optional = - Optional.ofNullable(newSubscriptionUnitWithProration) - - fun newSubscriptionGroupedAllocation(): - Optional = - Optional.ofNullable(newSubscriptionGroupedAllocation) - - fun newSubscriptionGroupedWithProratedMinimum(): - Optional = - Optional.ofNullable(newSubscriptionGroupedWithProratedMinimum) - - fun newSubscriptionBulkWithProration(): - Optional = - Optional.ofNullable(newSubscriptionBulkWithProration) - - fun isNewSubscriptionUnit(): Boolean = newSubscriptionUnit != null - - fun isNewSubscriptionPackage(): Boolean = newSubscriptionPackage != null - - fun isNewSubscriptionMatrix(): Boolean = newSubscriptionMatrix != null - - fun isNewSubscriptionTiered(): Boolean = newSubscriptionTiered != null - - fun isNewSubscriptionTieredBps(): Boolean = newSubscriptionTieredBps != null - - fun isNewSubscriptionBps(): Boolean = newSubscriptionBps != null - - fun isNewSubscriptionBulkBps(): Boolean = newSubscriptionBulkBps != null - - fun isNewSubscriptionBulk(): Boolean = newSubscriptionBulk != null - - fun isNewSubscriptionThresholdTotalAmount(): Boolean = - newSubscriptionThresholdTotalAmount != null - - fun isNewSubscriptionTieredPackage(): Boolean = newSubscriptionTieredPackage != null - - fun isNewSubscriptionTieredWithMinimum(): Boolean = - newSubscriptionTieredWithMinimum != null - - fun isNewSubscriptionUnitWithPercent(): Boolean = newSubscriptionUnitWithPercent != null - - fun isNewSubscriptionPackageWithAllocation(): Boolean = - newSubscriptionPackageWithAllocation != null - - fun isNewSubscriptionTierWithProration(): Boolean = - newSubscriptionTierWithProration != null - - fun isNewSubscriptionUnitWithProration(): Boolean = - newSubscriptionUnitWithProration != null - - fun isNewSubscriptionGroupedAllocation(): Boolean = - newSubscriptionGroupedAllocation != null - - fun isNewSubscriptionGroupedWithProratedMinimum(): Boolean = - newSubscriptionGroupedWithProratedMinimum != null - - fun isNewSubscriptionBulkWithProration(): Boolean = - newSubscriptionBulkWithProration != null - - fun asNewSubscriptionUnit(): NewSubscriptionUnitPrice = - newSubscriptionUnit.getOrThrow("newSubscriptionUnit") - - fun asNewSubscriptionPackage(): NewSubscriptionPackagePrice = - newSubscriptionPackage.getOrThrow("newSubscriptionPackage") - - fun asNewSubscriptionMatrix(): NewSubscriptionMatrixPrice = - newSubscriptionMatrix.getOrThrow("newSubscriptionMatrix") - - fun asNewSubscriptionTiered(): NewSubscriptionTieredPrice = - newSubscriptionTiered.getOrThrow("newSubscriptionTiered") - - fun asNewSubscriptionTieredBps(): NewSubscriptionTieredBpsPrice = - newSubscriptionTieredBps.getOrThrow("newSubscriptionTieredBps") - - fun asNewSubscriptionBps(): NewSubscriptionBpsPrice = - newSubscriptionBps.getOrThrow("newSubscriptionBps") - - fun asNewSubscriptionBulkBps(): NewSubscriptionBulkBpsPrice = - newSubscriptionBulkBps.getOrThrow("newSubscriptionBulkBps") - - fun asNewSubscriptionBulk(): NewSubscriptionBulkPrice = - newSubscriptionBulk.getOrThrow("newSubscriptionBulk") - - fun asNewSubscriptionThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = - newSubscriptionThresholdTotalAmount.getOrThrow( - "newSubscriptionThresholdTotalAmount" - ) - - fun asNewSubscriptionTieredPackage(): NewSubscriptionTieredPackagePrice = - newSubscriptionTieredPackage.getOrThrow("newSubscriptionTieredPackage") - - fun asNewSubscriptionTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = - newSubscriptionTieredWithMinimum.getOrThrow("newSubscriptionTieredWithMinimum") - - fun asNewSubscriptionUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = - newSubscriptionUnitWithPercent.getOrThrow("newSubscriptionUnitWithPercent") - - fun asNewSubscriptionPackageWithAllocation(): - NewSubscriptionPackageWithAllocationPrice = - newSubscriptionPackageWithAllocation.getOrThrow( - "newSubscriptionPackageWithAllocation" - ) - - fun asNewSubscriptionTierWithProration(): NewSubscriptionTierWithProrationPrice = - newSubscriptionTierWithProration.getOrThrow("newSubscriptionTierWithProration") - - fun asNewSubscriptionUnitWithProration(): NewSubscriptionUnitWithProrationPrice = - newSubscriptionUnitWithProration.getOrThrow("newSubscriptionUnitWithProration") - - fun asNewSubscriptionGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = - newSubscriptionGroupedAllocation.getOrThrow("newSubscriptionGroupedAllocation") - - fun asNewSubscriptionGroupedWithProratedMinimum(): - NewSubscriptionGroupedWithProratedMinimumPrice = - newSubscriptionGroupedWithProratedMinimum.getOrThrow( - "newSubscriptionGroupedWithProratedMinimum" - ) - - fun asNewSubscriptionBulkWithProration(): NewSubscriptionBulkWithProrationPrice = - newSubscriptionBulkWithProration.getOrThrow("newSubscriptionBulkWithProration") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - newSubscriptionUnit != null -> - visitor.visitNewSubscriptionUnit(newSubscriptionUnit) - newSubscriptionPackage != null -> - visitor.visitNewSubscriptionPackage(newSubscriptionPackage) - newSubscriptionMatrix != null -> - visitor.visitNewSubscriptionMatrix(newSubscriptionMatrix) - newSubscriptionTiered != null -> - visitor.visitNewSubscriptionTiered(newSubscriptionTiered) - newSubscriptionTieredBps != null -> - visitor.visitNewSubscriptionTieredBps(newSubscriptionTieredBps) - newSubscriptionBps != null -> - visitor.visitNewSubscriptionBps(newSubscriptionBps) - newSubscriptionBulkBps != null -> - visitor.visitNewSubscriptionBulkBps(newSubscriptionBulkBps) - newSubscriptionBulk != null -> - visitor.visitNewSubscriptionBulk(newSubscriptionBulk) - newSubscriptionThresholdTotalAmount != null -> - visitor.visitNewSubscriptionThresholdTotalAmount( - newSubscriptionThresholdTotalAmount - ) - newSubscriptionTieredPackage != null -> - visitor.visitNewSubscriptionTieredPackage(newSubscriptionTieredPackage) - newSubscriptionTieredWithMinimum != null -> - visitor.visitNewSubscriptionTieredWithMinimum( - newSubscriptionTieredWithMinimum - ) - newSubscriptionUnitWithPercent != null -> - visitor.visitNewSubscriptionUnitWithPercent(newSubscriptionUnitWithPercent) - newSubscriptionPackageWithAllocation != null -> - visitor.visitNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation - ) - newSubscriptionTierWithProration != null -> - visitor.visitNewSubscriptionTierWithProration( - newSubscriptionTierWithProration - ) - newSubscriptionUnitWithProration != null -> - visitor.visitNewSubscriptionUnitWithProration( - newSubscriptionUnitWithProration - ) - newSubscriptionGroupedAllocation != null -> - visitor.visitNewSubscriptionGroupedAllocation( - newSubscriptionGroupedAllocation - ) - newSubscriptionGroupedWithProratedMinimum != null -> - visitor.visitNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum - ) - newSubscriptionBulkWithProration != null -> - visitor.visitNewSubscriptionBulkWithProration( - newSubscriptionBulkWithProration - ) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): Price = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitNewSubscriptionUnit( - newSubscriptionUnit: NewSubscriptionUnitPrice - ) { - newSubscriptionUnit.validate() - } - - override fun visitNewSubscriptionPackage( - newSubscriptionPackage: NewSubscriptionPackagePrice - ) { - newSubscriptionPackage.validate() - } - - override fun visitNewSubscriptionMatrix( - newSubscriptionMatrix: NewSubscriptionMatrixPrice - ) { - newSubscriptionMatrix.validate() - } - - override fun visitNewSubscriptionTiered( - newSubscriptionTiered: NewSubscriptionTieredPrice - ) { - newSubscriptionTiered.validate() - } - - override fun visitNewSubscriptionTieredBps( - newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice - ) { - newSubscriptionTieredBps.validate() - } - - override fun visitNewSubscriptionBps( - newSubscriptionBps: NewSubscriptionBpsPrice - ) { - newSubscriptionBps.validate() - } - - override fun visitNewSubscriptionBulkBps( - newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice - ) { - newSubscriptionBulkBps.validate() - } - - override fun visitNewSubscriptionBulk( - newSubscriptionBulk: NewSubscriptionBulkPrice - ) { - newSubscriptionBulk.validate() - } - - override fun visitNewSubscriptionThresholdTotalAmount( - newSubscriptionThresholdTotalAmount: - NewSubscriptionThresholdTotalAmountPrice - ) { - newSubscriptionThresholdTotalAmount.validate() - } - - override fun visitNewSubscriptionTieredPackage( - newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice - ) { - newSubscriptionTieredPackage.validate() - } - - override fun visitNewSubscriptionTieredWithMinimum( - newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) { - newSubscriptionTieredWithMinimum.validate() - } - - override fun visitNewSubscriptionUnitWithPercent( - newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice - ) { - newSubscriptionUnitWithPercent.validate() - } - - override fun visitNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation: - NewSubscriptionPackageWithAllocationPrice - ) { - newSubscriptionPackageWithAllocation.validate() - } - - override fun visitNewSubscriptionTierWithProration( - newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice - ) { - newSubscriptionTierWithProration.validate() - } - - override fun visitNewSubscriptionUnitWithProration( - newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice - ) { - newSubscriptionUnitWithProration.validate() - } - - override fun visitNewSubscriptionGroupedAllocation( - newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice - ) { - newSubscriptionGroupedAllocation.validate() - } - - override fun visitNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) { - newSubscriptionGroupedWithProratedMinimum.validate() - } - - override fun visitNewSubscriptionBulkWithProration( - newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice - ) { - newSubscriptionBulkWithProration.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Price && newSubscriptionUnit == other.newSubscriptionUnit && newSubscriptionPackage == other.newSubscriptionPackage && newSubscriptionMatrix == other.newSubscriptionMatrix && newSubscriptionTiered == other.newSubscriptionTiered && newSubscriptionTieredBps == other.newSubscriptionTieredBps && newSubscriptionBps == other.newSubscriptionBps && newSubscriptionBulkBps == other.newSubscriptionBulkBps && newSubscriptionBulk == other.newSubscriptionBulk && newSubscriptionThresholdTotalAmount == other.newSubscriptionThresholdTotalAmount && newSubscriptionTieredPackage == other.newSubscriptionTieredPackage && newSubscriptionTieredWithMinimum == other.newSubscriptionTieredWithMinimum && newSubscriptionUnitWithPercent == other.newSubscriptionUnitWithPercent && newSubscriptionPackageWithAllocation == other.newSubscriptionPackageWithAllocation && newSubscriptionTierWithProration == other.newSubscriptionTierWithProration && newSubscriptionUnitWithProration == other.newSubscriptionUnitWithProration && newSubscriptionGroupedAllocation == other.newSubscriptionGroupedAllocation && newSubscriptionGroupedWithProratedMinimum == other.newSubscriptionGroupedWithProratedMinimum && newSubscriptionBulkWithProration == other.newSubscriptionBulkWithProration /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(newSubscriptionUnit, newSubscriptionPackage, newSubscriptionMatrix, newSubscriptionTiered, newSubscriptionTieredBps, newSubscriptionBps, newSubscriptionBulkBps, newSubscriptionBulk, newSubscriptionThresholdTotalAmount, newSubscriptionTieredPackage, newSubscriptionTieredWithMinimum, newSubscriptionUnitWithPercent, newSubscriptionPackageWithAllocation, newSubscriptionTierWithProration, newSubscriptionUnitWithProration, newSubscriptionGroupedAllocation, newSubscriptionGroupedWithProratedMinimum, newSubscriptionBulkWithProration) /* spotless:on */ - - override fun toString(): String = - when { - newSubscriptionUnit != null -> "Price{newSubscriptionUnit=$newSubscriptionUnit}" - newSubscriptionPackage != null -> - "Price{newSubscriptionPackage=$newSubscriptionPackage}" - newSubscriptionMatrix != null -> - "Price{newSubscriptionMatrix=$newSubscriptionMatrix}" - newSubscriptionTiered != null -> - "Price{newSubscriptionTiered=$newSubscriptionTiered}" - newSubscriptionTieredBps != null -> - "Price{newSubscriptionTieredBps=$newSubscriptionTieredBps}" - newSubscriptionBps != null -> "Price{newSubscriptionBps=$newSubscriptionBps}" - newSubscriptionBulkBps != null -> - "Price{newSubscriptionBulkBps=$newSubscriptionBulkBps}" - newSubscriptionBulk != null -> "Price{newSubscriptionBulk=$newSubscriptionBulk}" - newSubscriptionThresholdTotalAmount != null -> - "Price{newSubscriptionThresholdTotalAmount=$newSubscriptionThresholdTotalAmount}" - newSubscriptionTieredPackage != null -> - "Price{newSubscriptionTieredPackage=$newSubscriptionTieredPackage}" - newSubscriptionTieredWithMinimum != null -> - "Price{newSubscriptionTieredWithMinimum=$newSubscriptionTieredWithMinimum}" - newSubscriptionUnitWithPercent != null -> - "Price{newSubscriptionUnitWithPercent=$newSubscriptionUnitWithPercent}" - newSubscriptionPackageWithAllocation != null -> - "Price{newSubscriptionPackageWithAllocation=$newSubscriptionPackageWithAllocation}" - newSubscriptionTierWithProration != null -> - "Price{newSubscriptionTierWithProration=$newSubscriptionTierWithProration}" - newSubscriptionUnitWithProration != null -> - "Price{newSubscriptionUnitWithProration=$newSubscriptionUnitWithProration}" - newSubscriptionGroupedAllocation != null -> - "Price{newSubscriptionGroupedAllocation=$newSubscriptionGroupedAllocation}" - newSubscriptionGroupedWithProratedMinimum != null -> - "Price{newSubscriptionGroupedWithProratedMinimum=$newSubscriptionGroupedWithProratedMinimum}" - newSubscriptionBulkWithProration != null -> - "Price{newSubscriptionBulkWithProration=$newSubscriptionBulkWithProration}" - _json != null -> "Price{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Price") - } - - companion object { - - @JvmStatic - fun ofNewSubscriptionUnit(newSubscriptionUnit: NewSubscriptionUnitPrice) = - Price(newSubscriptionUnit = newSubscriptionUnit) - - @JvmStatic - fun ofNewSubscriptionPackage(newSubscriptionPackage: NewSubscriptionPackagePrice) = - Price(newSubscriptionPackage = newSubscriptionPackage) - - @JvmStatic - fun ofNewSubscriptionMatrix(newSubscriptionMatrix: NewSubscriptionMatrixPrice) = - Price(newSubscriptionMatrix = newSubscriptionMatrix) - - @JvmStatic - fun ofNewSubscriptionTiered(newSubscriptionTiered: NewSubscriptionTieredPrice) = - Price(newSubscriptionTiered = newSubscriptionTiered) - - @JvmStatic - fun ofNewSubscriptionTieredBps( - newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice - ) = Price(newSubscriptionTieredBps = newSubscriptionTieredBps) - - @JvmStatic - fun ofNewSubscriptionBps(newSubscriptionBps: NewSubscriptionBpsPrice) = - Price(newSubscriptionBps = newSubscriptionBps) - - @JvmStatic - fun ofNewSubscriptionBulkBps(newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice) = - Price(newSubscriptionBulkBps = newSubscriptionBulkBps) - - @JvmStatic - fun ofNewSubscriptionBulk(newSubscriptionBulk: NewSubscriptionBulkPrice) = - Price(newSubscriptionBulk = newSubscriptionBulk) - - @JvmStatic - fun ofNewSubscriptionThresholdTotalAmount( - newSubscriptionThresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = Price(newSubscriptionThresholdTotalAmount = newSubscriptionThresholdTotalAmount) - - @JvmStatic - fun ofNewSubscriptionTieredPackage( - newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice - ) = Price(newSubscriptionTieredPackage = newSubscriptionTieredPackage) - - @JvmStatic - fun ofNewSubscriptionTieredWithMinimum( - newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) = Price(newSubscriptionTieredWithMinimum = newSubscriptionTieredWithMinimum) - - @JvmStatic - fun ofNewSubscriptionUnitWithPercent( - newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice - ) = Price(newSubscriptionUnitWithPercent = newSubscriptionUnitWithPercent) - - @JvmStatic - fun ofNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = - Price( - newSubscriptionPackageWithAllocation = newSubscriptionPackageWithAllocation - ) - - @JvmStatic - fun ofNewSubscriptionTierWithProration( - newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice - ) = Price(newSubscriptionTierWithProration = newSubscriptionTierWithProration) - - @JvmStatic - fun ofNewSubscriptionUnitWithProration( - newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice - ) = Price(newSubscriptionUnitWithProration = newSubscriptionUnitWithProration) - - @JvmStatic - fun ofNewSubscriptionGroupedAllocation( - newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice - ) = Price(newSubscriptionGroupedAllocation = newSubscriptionGroupedAllocation) - - @JvmStatic - fun ofNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) = - Price( - newSubscriptionGroupedWithProratedMinimum = - newSubscriptionGroupedWithProratedMinimum - ) - - @JvmStatic - fun ofNewSubscriptionBulkWithProration( - newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice - ) = Price(newSubscriptionBulkWithProration = newSubscriptionBulkWithProration) - } - - /** - * An interface that defines how to map each variant of [Price] to a value of type [T]. - */ - interface Visitor { - - fun visitNewSubscriptionUnit(newSubscriptionUnit: NewSubscriptionUnitPrice): T - - fun visitNewSubscriptionPackage( - newSubscriptionPackage: NewSubscriptionPackagePrice - ): T - - fun visitNewSubscriptionMatrix(newSubscriptionMatrix: NewSubscriptionMatrixPrice): T - - fun visitNewSubscriptionTiered(newSubscriptionTiered: NewSubscriptionTieredPrice): T - - fun visitNewSubscriptionTieredBps( - newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice - ): T - - fun visitNewSubscriptionBps(newSubscriptionBps: NewSubscriptionBpsPrice): T - - fun visitNewSubscriptionBulkBps( - newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice - ): T - - fun visitNewSubscriptionBulk(newSubscriptionBulk: NewSubscriptionBulkPrice): T - - fun visitNewSubscriptionThresholdTotalAmount( - newSubscriptionThresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ): T - - fun visitNewSubscriptionTieredPackage( - newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice - ): T - - fun visitNewSubscriptionTieredWithMinimum( - newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ): T - - fun visitNewSubscriptionUnitWithPercent( - newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice - ): T - - fun visitNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ): T - - fun visitNewSubscriptionTierWithProration( - newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice - ): T - - fun visitNewSubscriptionUnitWithProration( - newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice - ): T - - fun visitNewSubscriptionGroupedAllocation( - newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice - ): T - - fun visitNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ): T - - fun visitNewSubscriptionBulkWithProration( - newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice - ): 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" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionUnit = it, _json = json) - } - } - "package" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionPackage = it, _json = json) - } - } - "matrix" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionMatrix = it, _json = json) - } - } - "tiered" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionTiered = it, _json = json) - } - } - "tiered_bps" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionTieredBps = it, _json = json) - } - } - "bps" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionBps = it, _json = json) - } - } - "bulk_bps" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionBulkBps = it, _json = json) - } - } - "bulk" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Price(newSubscriptionBulk = it, _json = json) - } - } - "threshold_total_amount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionThresholdTotalAmount = it, - _json = json, - ) - } - } - "tiered_package" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price(newSubscriptionTieredPackage = it, _json = json) - } - } - "tiered_with_minimum" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionTieredWithMinimum = it, - _json = json, - ) - } - } - "unit_with_percent" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price(newSubscriptionUnitWithPercent = it, _json = json) - } - } - "package_with_allocation" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionPackageWithAllocation = it, - _json = json, - ) - } - } - "tiered_with_proration" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionTierWithProration = it, - _json = json, - ) - } - } - "unit_with_proration" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionUnitWithProration = it, - _json = json, - ) - } - } - "grouped_allocation" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionGroupedAllocation = it, - _json = json, - ) - } - } - "grouped_with_prorated_minimum" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionGroupedWithProratedMinimum = it, - _json = json, - ) - } - } - "bulk_with_proration" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Price( - newSubscriptionBulkWithProration = it, - _json = json, - ) - } - } - } - - return Price(_json = json) - } - } - - internal class Serializer : BaseSerializer(Price::class) { - - override fun serialize( - value: Price, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.newSubscriptionUnit != null -> - generator.writeObject(value.newSubscriptionUnit) - value.newSubscriptionPackage != null -> - generator.writeObject(value.newSubscriptionPackage) - value.newSubscriptionMatrix != null -> - generator.writeObject(value.newSubscriptionMatrix) - value.newSubscriptionTiered != null -> - generator.writeObject(value.newSubscriptionTiered) - value.newSubscriptionTieredBps != null -> - generator.writeObject(value.newSubscriptionTieredBps) - value.newSubscriptionBps != null -> - generator.writeObject(value.newSubscriptionBps) - value.newSubscriptionBulkBps != null -> - generator.writeObject(value.newSubscriptionBulkBps) - value.newSubscriptionBulk != null -> - generator.writeObject(value.newSubscriptionBulk) - value.newSubscriptionThresholdTotalAmount != null -> - generator.writeObject(value.newSubscriptionThresholdTotalAmount) - value.newSubscriptionTieredPackage != null -> - generator.writeObject(value.newSubscriptionTieredPackage) - value.newSubscriptionTieredWithMinimum != null -> - generator.writeObject(value.newSubscriptionTieredWithMinimum) - value.newSubscriptionUnitWithPercent != null -> - generator.writeObject(value.newSubscriptionUnitWithPercent) - value.newSubscriptionPackageWithAllocation != null -> - generator.writeObject(value.newSubscriptionPackageWithAllocation) - value.newSubscriptionTierWithProration != null -> - generator.writeObject(value.newSubscriptionTierWithProration) - value.newSubscriptionUnitWithProration != null -> - generator.writeObject(value.newSubscriptionUnitWithProration) - value.newSubscriptionGroupedAllocation != null -> - generator.writeObject(value.newSubscriptionGroupedAllocation) - value.newSubscriptionGroupedWithProratedMinimum != null -> - generator.writeObject(value.newSubscriptionGroupedWithProratedMinimum) - value.newSubscriptionBulkWithProration != null -> - generator.writeObject(value.newSubscriptionBulkWithProration) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Price") - } - } - } - - @NoAutoDetect - class NewSubscriptionUnitPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("unit_config") - @ExcludeMissing - private val unitConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun unitConfig(): UnitConfig = unitConfig.getRequired("unit_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("unit_config") - @ExcludeMissing - fun _unitConfig(): JsonField = unitConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionUnitPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - unitConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionUnitPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var 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 currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newSubscriptionUnitPrice: NewSubscriptionUnitPrice) = apply { - cadence = newSubscriptionUnitPrice.cadence - itemId = newSubscriptionUnitPrice.itemId - modelType = newSubscriptionUnitPrice.modelType - name = newSubscriptionUnitPrice.name - unitConfig = newSubscriptionUnitPrice.unitConfig - billableMetricId = newSubscriptionUnitPrice.billableMetricId - billedInAdvance = newSubscriptionUnitPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionUnitPrice.billingCycleConfiguration - conversionRate = newSubscriptionUnitPrice.conversionRate - currency = newSubscriptionUnitPrice.currency - externalPriceId = newSubscriptionUnitPrice.externalPriceId - fixedPriceQuantity = newSubscriptionUnitPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionUnitPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionUnitPrice.invoicingCycleConfiguration - metadata = newSubscriptionUnitPrice.metadata - referenceId = newSubscriptionUnitPrice.referenceId - additionalProperties = - newSubscriptionUnitPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) - - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionUnitPrice = - NewSubscriptionUnitPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("unitConfig", unitConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class UnitConfig - @JsonCreator - private constructor( - @JsonProperty("unit_amount") - @ExcludeMissing - private val unitAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Rate per unit of usage */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** Rate per unit of usage */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): UnitConfig = apply { - if (validated) { - return@apply - } - - unitAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnitConfig]. */ - class Builder internal constructor() { - - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unitConfig: UnitConfig) = apply { - unitAmount = unitConfig.unitAmount - additionalProperties = unitConfig.additionalProperties.toMutableMap() - } - - /** Rate per unit of usage */ - fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - - /** Rate per unit of usage */ - 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 build(): UnitConfig = - UnitConfig( - checkRequired("unitAmount", unitAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UnitConfig && unitAmount == other.unitAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(unitAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnitConfig{unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionUnitPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && unitConfig == other.unitConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, unitConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionUnitPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionPackagePrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("package_config") - @ExcludeMissing - private val packageConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun packageConfig(): PackageConfig = packageConfig.getRequired("package_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("package_config") - @ExcludeMissing - fun _packageConfig(): JsonField = packageConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionPackagePrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - packageConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionPackagePrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var packageConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newSubscriptionPackagePrice: NewSubscriptionPackagePrice) = - apply { - cadence = newSubscriptionPackagePrice.cadence - itemId = newSubscriptionPackagePrice.itemId - modelType = newSubscriptionPackagePrice.modelType - name = newSubscriptionPackagePrice.name - packageConfig = newSubscriptionPackagePrice.packageConfig - billableMetricId = newSubscriptionPackagePrice.billableMetricId - billedInAdvance = newSubscriptionPackagePrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionPackagePrice.billingCycleConfiguration - conversionRate = newSubscriptionPackagePrice.conversionRate - currency = newSubscriptionPackagePrice.currency - externalPriceId = newSubscriptionPackagePrice.externalPriceId - fixedPriceQuantity = newSubscriptionPackagePrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionPackagePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionPackagePrice.invoicingCycleConfiguration - metadata = newSubscriptionPackagePrice.metadata - referenceId = newSubscriptionPackagePrice.referenceId - additionalProperties = - newSubscriptionPackagePrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun packageConfig(packageConfig: PackageConfig) = - packageConfig(JsonField.of(packageConfig)) - - fun packageConfig(packageConfig: JsonField) = apply { - this.packageConfig = packageConfig - } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionPackagePrice = - NewSubscriptionPackagePrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("packageConfig", packageConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val PACKAGE = of("package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - PACKAGE - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PACKAGE, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PACKAGE -> Value.PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PACKAGE -> Known.PACKAGE - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class PackageConfig - @JsonCreator - private constructor( - @JsonProperty("package_amount") - @ExcludeMissing - private val packageAmount: JsonField = JsonMissing.of(), - @JsonProperty("package_size") - @ExcludeMissing - private val packageSize: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** A currency amount to rate usage by */ - fun packageAmount(): String = packageAmount.getRequired("package_amount") - - /** - * An integer amount to represent package size. For example, 1000 here would - * divide usage by 1000 before multiplying by package_amount in rating - */ - fun packageSize(): Long = packageSize.getRequired("package_size") - - /** A currency amount to rate usage by */ - @JsonProperty("package_amount") - @ExcludeMissing - fun _packageAmount(): JsonField = packageAmount - - /** - * An integer amount to represent package size. For example, 1000 here would - * divide usage by 1000 before multiplying by package_amount in rating - */ - @JsonProperty("package_size") - @ExcludeMissing - fun _packageSize(): JsonField = packageSize - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PackageConfig = apply { - if (validated) { - return@apply - } - - packageAmount() - packageSize() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PackageConfig]. */ - class Builder internal constructor() { - - private var packageAmount: JsonField? = null - private var packageSize: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(packageConfig: PackageConfig) = apply { - packageAmount = packageConfig.packageAmount - packageSize = packageConfig.packageSize - additionalProperties = packageConfig.additionalProperties.toMutableMap() - } - - /** A currency amount to rate usage by */ - fun packageAmount(packageAmount: String) = - packageAmount(JsonField.of(packageAmount)) - - /** A currency amount to rate usage by */ - fun packageAmount(packageAmount: JsonField) = apply { - this.packageAmount = packageAmount - } - - /** - * An integer amount to represent package size. For example, 1000 here would - * divide usage by 1000 before multiplying by package_amount in rating - */ - fun packageSize(packageSize: Long) = packageSize(JsonField.of(packageSize)) - - /** - * An integer amount to represent package size. For example, 1000 here would - * divide usage by 1000 before multiplying by package_amount in rating - */ - fun packageSize(packageSize: JsonField) = apply { - this.packageSize = packageSize - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PackageConfig = - PackageConfig( - checkRequired("packageAmount", packageAmount), - checkRequired("packageSize", packageSize), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PackageConfig && packageAmount == other.packageAmount && packageSize == other.packageSize && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(packageAmount, packageSize, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PackageConfig{packageAmount=$packageAmount, packageSize=$packageSize, additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionPackagePrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && packageConfig == other.packageConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, packageConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionMatrixPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("matrix_config") - @ExcludeMissing - private val matrixConfig: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_config") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("matrix_config") - @ExcludeMissing - fun _matrixConfig(): JsonField = matrixConfig - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionMatrixPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - matrixConfig().validate() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionMatrixPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var matrixConfig: JsonField? = null - private var modelType: JsonField? = null - private var 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 currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newSubscriptionMatrixPrice: NewSubscriptionMatrixPrice) = - apply { - cadence = newSubscriptionMatrixPrice.cadence - itemId = newSubscriptionMatrixPrice.itemId - matrixConfig = newSubscriptionMatrixPrice.matrixConfig - modelType = newSubscriptionMatrixPrice.modelType - name = newSubscriptionMatrixPrice.name - billableMetricId = newSubscriptionMatrixPrice.billableMetricId - billedInAdvance = newSubscriptionMatrixPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionMatrixPrice.billingCycleConfiguration - conversionRate = newSubscriptionMatrixPrice.conversionRate - currency = newSubscriptionMatrixPrice.currency - externalPriceId = newSubscriptionMatrixPrice.externalPriceId - fixedPriceQuantity = newSubscriptionMatrixPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionMatrixPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionMatrixPrice.invoicingCycleConfiguration - metadata = newSubscriptionMatrixPrice.metadata - referenceId = newSubscriptionMatrixPrice.referenceId - additionalProperties = - newSubscriptionMatrixPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun matrixConfig(matrixConfig: MatrixConfig) = - matrixConfig(JsonField.of(matrixConfig)) - - fun matrixConfig(matrixConfig: JsonField) = apply { - this.matrixConfig = matrixConfig - } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionMatrixPrice = - NewSubscriptionMatrixPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("matrixConfig", matrixConfig), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class MatrixConfig - @JsonCreator - private constructor( - @JsonProperty("default_unit_amount") - @ExcludeMissing - private val defaultUnitAmount: JsonField = JsonMissing.of(), - @JsonProperty("dimensions") - @ExcludeMissing - private val dimensions: JsonField> = JsonMissing.of(), - @JsonProperty("matrix_values") - @ExcludeMissing - private val matrixValues: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * Default per unit rate for any usage not bucketed into a specified - * matrix_value - */ - fun defaultUnitAmount(): String = - defaultUnitAmount.getRequired("default_unit_amount") - - /** One or two event property values to evaluate matrix groups by */ - fun dimensions(): List = dimensions.getRequired("dimensions") - - /** Matrix values for specified matrix grouping keys */ - fun matrixValues(): List = - matrixValues.getRequired("matrix_values") - - /** - * Default per unit rate for any usage not bucketed into a specified - * matrix_value - */ - @JsonProperty("default_unit_amount") - @ExcludeMissing - fun _defaultUnitAmount(): JsonField = defaultUnitAmount - - /** One or two event property values to evaluate matrix groups by */ - @JsonProperty("dimensions") - @ExcludeMissing - fun _dimensions(): JsonField> = dimensions - - /** Matrix values for specified matrix grouping keys */ - @JsonProperty("matrix_values") - @ExcludeMissing - fun _matrixValues(): JsonField> = matrixValues - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MatrixConfig = apply { - if (validated) { - return@apply - } - - defaultUnitAmount() - dimensions() - matrixValues().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MatrixConfig]. */ - class Builder internal constructor() { - - private var defaultUnitAmount: JsonField? = null - private var dimensions: JsonField>? = null - private var matrixValues: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(matrixConfig: MatrixConfig) = apply { - defaultUnitAmount = matrixConfig.defaultUnitAmount - dimensions = matrixConfig.dimensions.map { it.toMutableList() } - matrixValues = matrixConfig.matrixValues.map { it.toMutableList() } - additionalProperties = matrixConfig.additionalProperties.toMutableMap() - } - - /** - * Default per unit rate for any usage not bucketed into a specified - * matrix_value - */ - fun defaultUnitAmount(defaultUnitAmount: String) = - defaultUnitAmount(JsonField.of(defaultUnitAmount)) - - /** - * Default per unit rate for any usage not bucketed into a specified - * matrix_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)) - - /** One or two event property values to evaluate matrix groups by */ - fun dimensions(dimensions: JsonField>) = apply { - this.dimensions = dimensions.map { it.toMutableList() } - } - - /** One or two event property values to evaluate matrix groups by */ - fun addDimension(dimension: String) = apply { - dimensions = - (dimensions ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimension) - } - } - - /** Matrix values for specified matrix grouping keys */ - fun matrixValues(matrixValues: List) = - matrixValues(JsonField.of(matrixValues)) - - /** Matrix values for specified matrix grouping keys */ - fun matrixValues(matrixValues: JsonField>) = apply { - this.matrixValues = matrixValues.map { it.toMutableList() } - } - - /** Matrix values for specified matrix grouping keys */ - fun addMatrixValue(matrixValue: MatrixValue) = apply { - matrixValues = - (matrixValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): MatrixConfig = - MatrixConfig( - checkRequired("defaultUnitAmount", defaultUnitAmount), - checkRequired("dimensions", dimensions).map { it.toImmutable() }, - checkRequired("matrixValues", matrixValues).map { - it.toImmutable() - }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class MatrixValue - @JsonCreator - private constructor( - @JsonProperty("dimension_values") - @ExcludeMissing - private val dimensionValues: JsonField> = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - private val unitAmount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), - ) { - - /** - * One or two matrix keys to filter usage to this Matrix value by. For - * example, ["region", "tier"] could be used to filter cloud usage by a - * cloud region and an instance tier. - */ - fun dimensionValues(): List = - dimensionValues.getRequired("dimension_values") - - /** Unit price for the specified dimension_values */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** - * One or two matrix keys to filter usage to this Matrix value by. For - * example, ["region", "tier"] could be used to filter cloud usage by a - * cloud region and an instance tier. - */ - @JsonProperty("dimension_values") - @ExcludeMissing - fun _dimensionValues(): JsonField> = dimensionValues - - /** Unit price for the specified dimension_values */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MatrixValue = apply { - if (validated) { - return@apply - } - - dimensionValues() - unitAmount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MatrixValue]. */ - class Builder internal constructor() { - - private var dimensionValues: JsonField>? = null - private var unitAmount: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(matrixValue: MatrixValue) = apply { - dimensionValues = - matrixValue.dimensionValues.map { it.toMutableList() } - unitAmount = matrixValue.unitAmount - additionalProperties = - matrixValue.additionalProperties.toMutableMap() - } - - /** - * One or two matrix keys to filter usage to this Matrix value by. For - * example, ["region", "tier"] could be used to filter cloud usage by a - * cloud region and an instance tier. - */ - fun dimensionValues(dimensionValues: List) = - dimensionValues(JsonField.of(dimensionValues)) - - /** - * One or two matrix keys to filter usage to this Matrix value by. For - * example, ["region", "tier"] could be used to filter cloud usage by a - * cloud region and an instance tier. - */ - fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues.map { it.toMutableList() } - } - - /** - * One or two matrix keys to filter usage to this Matrix value by. For - * example, ["region", "tier"] could be used to filter cloud usage by a - * cloud region and an instance tier. - */ - fun addDimensionValue(dimensionValue: String) = apply { - dimensionValues = - (dimensionValues ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(dimensionValue) - } - } - - /** Unit price for the specified dimension_values */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) - - /** Unit price for the specified dimension_values */ - 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 build(): MatrixValue = - MatrixValue( - checkRequired("dimensionValues", dimensionValues).map { - it.toImmutable() - }, - checkRequired("unitAmount", unitAmount), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MatrixValue && dimensionValues == other.dimensionValues && unitAmount == other.unitAmount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dimensionValues, unitAmount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MatrixValue{dimensionValues=$dimensionValues, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MatrixConfig && defaultUnitAmount == other.defaultUnitAmount && dimensions == other.dimensions && matrixValues == other.matrixValues && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(defaultUnitAmount, dimensions, matrixValues, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MatrixConfig{defaultUnitAmount=$defaultUnitAmount, dimensions=$dimensions, matrixValues=$matrixValues, additionalProperties=$additionalProperties}" - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MATRIX = of("matrix") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MATRIX - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MATRIX, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MATRIX -> Value.MATRIX - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MATRIX -> Known.MATRIX - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionMatrixPrice && cadence == other.cadence && itemId == other.itemId && matrixConfig == other.matrixConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, matrixConfig, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionMatrixPrice{cadence=$cadence, itemId=$itemId, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionTieredPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_config") - @ExcludeMissing - private val tieredConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun tieredConfig(): TieredConfig = tieredConfig.getRequired("tiered_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("tiered_config") - @ExcludeMissing - fun _tieredConfig(): JsonField = tieredConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionTieredPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - tieredConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionTieredPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var tieredConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newSubscriptionTieredPrice: NewSubscriptionTieredPrice) = - apply { - cadence = newSubscriptionTieredPrice.cadence - itemId = newSubscriptionTieredPrice.itemId - modelType = newSubscriptionTieredPrice.modelType - name = newSubscriptionTieredPrice.name - tieredConfig = newSubscriptionTieredPrice.tieredConfig - billableMetricId = newSubscriptionTieredPrice.billableMetricId - billedInAdvance = newSubscriptionTieredPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionTieredPrice.billingCycleConfiguration - conversionRate = newSubscriptionTieredPrice.conversionRate - currency = newSubscriptionTieredPrice.currency - externalPriceId = newSubscriptionTieredPrice.externalPriceId - fixedPriceQuantity = newSubscriptionTieredPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionTieredPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionTieredPrice.invoicingCycleConfiguration - metadata = newSubscriptionTieredPrice.metadata - referenceId = newSubscriptionTieredPrice.referenceId - additionalProperties = - newSubscriptionTieredPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredConfig(tieredConfig: TieredConfig) = - tieredConfig(JsonField.of(tieredConfig)) - - fun tieredConfig(tieredConfig: JsonField) = apply { - this.tieredConfig = tieredConfig - } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionTieredPrice = - NewSubscriptionTieredPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("tieredConfig", tieredConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED = of("tiered") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED -> Value.TIERED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TIERED -> Known.TIERED - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TieredConfig - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - private val tiers: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Tiers for rating based on total usage quantities into the specified tier */ - fun tiers(): List = tiers.getRequired("tiers") - - /** Tiers for rating based on total usage quantities into the specified tier */ - @JsonProperty("tiers") - @ExcludeMissing - fun _tiers(): JsonField> = tiers - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredConfig = apply { - if (validated) { - return@apply - } - - tiers().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tieredConfig: TieredConfig) = apply { - tiers = tieredConfig.tiers.map { it.toMutableList() } - additionalProperties = tieredConfig.additionalProperties.toMutableMap() - } - - /** - * Tiers for rating based on total usage quantities into the specified tier - */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - - /** - * Tiers for rating based on total usage quantities into the specified tier - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** - * Tiers for rating based on total usage quantities into the specified tier - */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): TieredConfig = - TieredConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Tier - @JsonCreator - private constructor( - @JsonProperty("first_unit") - @ExcludeMissing - private val firstUnit: JsonField = JsonMissing.of(), - @JsonProperty("unit_amount") - @ExcludeMissing - private val unitAmount: JsonField = JsonMissing.of(), - @JsonProperty("last_unit") - @ExcludeMissing - private val lastUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), - ) { - - /** Inclusive tier starting value */ - fun firstUnit(): Double = firstUnit.getRequired("first_unit") - - /** Amount per unit */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** - * Exclusive tier ending value. If null, this is treated as the last tier - */ - fun lastUnit(): Optional = - Optional.ofNullable(lastUnit.getNullable("last_unit")) - - /** Inclusive tier starting value */ - @JsonProperty("first_unit") - @ExcludeMissing - fun _firstUnit(): JsonField = firstUnit - - /** Amount per unit */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - /** - * Exclusive tier ending value. If null, this is treated as the last tier - */ - @JsonProperty("last_unit") - @ExcludeMissing - fun _lastUnit(): JsonField = lastUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - firstUnit() - unitAmount() - lastUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var firstUnit: JsonField? = null - private var unitAmount: JsonField? = null - private var lastUnit: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - firstUnit = tier.firstUnit - unitAmount = tier.unitAmount - lastUnit = tier.lastUnit - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Inclusive tier starting value */ - fun firstUnit(firstUnit: Double) = firstUnit(JsonField.of(firstUnit)) - - /** Inclusive tier starting value */ - fun firstUnit(firstUnit: JsonField) = apply { - this.firstUnit = firstUnit - } - - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) - - /** Amount per unit */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - /** - * Exclusive tier ending value. If null, this is treated as the last - * tier - */ - fun lastUnit(lastUnit: Double?) = - lastUnit(JsonField.ofNullable(lastUnit)) - - /** - * Exclusive tier ending value. If null, this is treated as the last - * tier - */ - fun lastUnit(lastUnit: Double) = lastUnit(lastUnit as Double?) - - /** - * Exclusive tier ending value. If null, this is treated as the last - * tier - */ - @Suppress( - "USELESS_CAST" - ) // See https://youtrack.jetbrains.com/issue/KT-74228 - fun lastUnit(lastUnit: Optional) = - lastUnit(lastUnit.orElse(null) as Double?) - - /** - * Exclusive tier ending value. If null, this is treated as the last - * tier - */ - fun lastUnit(lastUnit: JsonField) = apply { - this.lastUnit = lastUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Tier = - Tier( - checkRequired("firstUnit", firstUnit), - checkRequired("unitAmount", unitAmount), - lastUnit, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tier && firstUnit == other.firstUnit && unitAmount == other.unitAmount && lastUnit == other.lastUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(firstUnit, unitAmount, lastUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{firstUnit=$firstUnit, unitAmount=$unitAmount, lastUnit=$lastUnit, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredConfig && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredConfig{tiers=$tiers, additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionTieredPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredConfig == other.tieredConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionTieredPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionTieredBpsPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_bps_config") - @ExcludeMissing - private val tieredBpsConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun tieredBpsConfig(): TieredBpsConfig = - tieredBpsConfig.getRequired("tiered_bps_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("tiered_bps_config") - @ExcludeMissing - fun _tieredBpsConfig(): JsonField = tieredBpsConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionTieredBpsPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - tieredBpsConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionTieredBpsPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var tieredBpsConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionTieredBpsPrice: NewSubscriptionTieredBpsPrice - ) = apply { - cadence = newSubscriptionTieredBpsPrice.cadence - itemId = newSubscriptionTieredBpsPrice.itemId - modelType = newSubscriptionTieredBpsPrice.modelType - name = newSubscriptionTieredBpsPrice.name - tieredBpsConfig = newSubscriptionTieredBpsPrice.tieredBpsConfig - billableMetricId = newSubscriptionTieredBpsPrice.billableMetricId - billedInAdvance = newSubscriptionTieredBpsPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionTieredBpsPrice.billingCycleConfiguration - conversionRate = newSubscriptionTieredBpsPrice.conversionRate - currency = newSubscriptionTieredBpsPrice.currency - externalPriceId = newSubscriptionTieredBpsPrice.externalPriceId - fixedPriceQuantity = newSubscriptionTieredBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionTieredBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionTieredBpsPrice.invoicingCycleConfiguration - metadata = newSubscriptionTieredBpsPrice.metadata - referenceId = newSubscriptionTieredBpsPrice.referenceId - additionalProperties = - newSubscriptionTieredBpsPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredBpsConfig(tieredBpsConfig: TieredBpsConfig) = - tieredBpsConfig(JsonField.of(tieredBpsConfig)) - - fun tieredBpsConfig(tieredBpsConfig: JsonField) = apply { - this.tieredBpsConfig = tieredBpsConfig - } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionTieredBpsPrice = - NewSubscriptionTieredBpsPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("tieredBpsConfig", tieredBpsConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED_BPS = of("tiered_bps") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_BPS -> Value.TIERED_BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TIERED_BPS -> Known.TIERED_BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TieredBpsConfig - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - private val tiers: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into - * specified tiers - */ - fun tiers(): List = tiers.getRequired("tiers") - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into - * specified tiers - */ - @JsonProperty("tiers") - @ExcludeMissing - fun _tiers(): JsonField> = tiers - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredBpsConfig = apply { - if (validated) { - return@apply - } - - tiers().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredBpsConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tieredBpsConfig: TieredBpsConfig) = apply { - tiers = tieredBpsConfig.tiers.map { it.toMutableList() } - additionalProperties = - tieredBpsConfig.additionalProperties.toMutableMap() - } - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into - * specified tiers - */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into - * specified tiers - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** - * Tiers for a Graduated BPS pricing model, where usage is bucketed into - * specified tiers - */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): TieredBpsConfig = - TieredBpsConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Tier - @JsonCreator - private constructor( - @JsonProperty("bps") - @ExcludeMissing - private val bps: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_maximum") - @ExcludeMissing - private val perUnitMaximum: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), - ) { - - /** Per-event basis point rate */ - fun bps(): Double = bps.getRequired("bps") - - /** Inclusive tier starting value */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** Exclusive tier ending value */ - fun maximumAmount(): Optional = - Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - - /** Per unit maximum to charge */ - fun perUnitMaximum(): Optional = - Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) - - /** Per-event basis point rate */ - @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps - - /** Inclusive tier starting value */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** Exclusive tier ending value */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** Per unit maximum to charge */ - @JsonProperty("per_unit_maximum") - @ExcludeMissing - fun _perUnitMaximum(): JsonField = perUnitMaximum - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - bps() - minimumAmount() - maximumAmount() - perUnitMaximum() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var bps: JsonField? = null - private var minimumAmount: JsonField? = null - private var maximumAmount: JsonField = JsonMissing.of() - private var perUnitMaximum: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - bps = tier.bps - minimumAmount = tier.minimumAmount - maximumAmount = tier.maximumAmount - perUnitMaximum = tier.perUnitMaximum - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Per-event basis point rate */ - fun bps(bps: Double) = bps(JsonField.of(bps)) - - /** Per-event basis point rate */ - fun bps(bps: JsonField) = apply { this.bps = bps } - - /** Inclusive tier starting value */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** Inclusive tier starting value */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** Exclusive tier ending value */ - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - /** Exclusive tier ending value */ - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.orElse(null)) - - /** Exclusive tier ending value */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** Per unit maximum to charge */ - fun perUnitMaximum(perUnitMaximum: String?) = - perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) - - /** Per unit maximum to charge */ - fun perUnitMaximum(perUnitMaximum: Optional) = - perUnitMaximum(perUnitMaximum.orElse(null)) - - /** Per unit maximum to charge */ - fun perUnitMaximum(perUnitMaximum: JsonField) = apply { - this.perUnitMaximum = perUnitMaximum - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): Tier = - Tier( - checkRequired("bps", bps), - checkRequired("minimumAmount", minimumAmount), - maximumAmount, - perUnitMaximum, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tier && bps == other.bps && minimumAmount == other.minimumAmount && maximumAmount == other.maximumAmount && perUnitMaximum == other.perUnitMaximum && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bps, minimumAmount, maximumAmount, perUnitMaximum, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{bps=$bps, minimumAmount=$minimumAmount, maximumAmount=$maximumAmount, perUnitMaximum=$perUnitMaximum, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredBpsConfig && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredBpsConfig{tiers=$tiers, additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionTieredBpsPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredBpsConfig == other.tieredBpsConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredBpsConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionTieredBpsPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredBpsConfig=$tieredBpsConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionBpsPrice - @JsonCreator - private constructor( - @JsonProperty("bps_config") - @ExcludeMissing - private val bpsConfig: JsonField = JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun bpsConfig(): BpsConfig = bpsConfig.getRequired("bps_config") - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - @JsonProperty("bps_config") - @ExcludeMissing - fun _bpsConfig(): JsonField = bpsConfig - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionBpsPrice = apply { - if (validated) { - return@apply - } - - bpsConfig().validate() - cadence() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionBpsPrice]. */ - class Builder internal constructor() { - - private var bpsConfig: JsonField? = null - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newSubscriptionBpsPrice: NewSubscriptionBpsPrice) = apply { - bpsConfig = newSubscriptionBpsPrice.bpsConfig - cadence = newSubscriptionBpsPrice.cadence - itemId = newSubscriptionBpsPrice.itemId - modelType = newSubscriptionBpsPrice.modelType - name = newSubscriptionBpsPrice.name - billableMetricId = newSubscriptionBpsPrice.billableMetricId - billedInAdvance = newSubscriptionBpsPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionBpsPrice.billingCycleConfiguration - conversionRate = newSubscriptionBpsPrice.conversionRate - currency = newSubscriptionBpsPrice.currency - externalPriceId = newSubscriptionBpsPrice.externalPriceId - fixedPriceQuantity = newSubscriptionBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionBpsPrice.invoicingCycleConfiguration - metadata = newSubscriptionBpsPrice.metadata - referenceId = newSubscriptionBpsPrice.referenceId - additionalProperties = - newSubscriptionBpsPrice.additionalProperties.toMutableMap() - } - - fun bpsConfig(bpsConfig: BpsConfig) = bpsConfig(JsonField.of(bpsConfig)) - - fun bpsConfig(bpsConfig: JsonField) = apply { - this.bpsConfig = bpsConfig - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionBpsPrice = - NewSubscriptionBpsPrice( - checkRequired("bpsConfig", bpsConfig), - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BpsConfig - @JsonCreator - private constructor( - @JsonProperty("bps") - @ExcludeMissing - private val bps: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_maximum") - @ExcludeMissing - private val perUnitMaximum: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Basis point take rate per event */ - fun bps(): Double = bps.getRequired("bps") - - /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(): Optional = - Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) - - /** Basis point take rate per event */ - @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps - - /** Optional currency amount maximum to cap spend per event */ - @JsonProperty("per_unit_maximum") - @ExcludeMissing - fun _perUnitMaximum(): JsonField = perUnitMaximum - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BpsConfig = apply { - if (validated) { - return@apply - } - - bps() - perUnitMaximum() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BpsConfig]. */ - class Builder internal constructor() { - - private var bps: JsonField? = null - private var perUnitMaximum: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(bpsConfig: BpsConfig) = apply { - bps = bpsConfig.bps - perUnitMaximum = bpsConfig.perUnitMaximum - additionalProperties = bpsConfig.additionalProperties.toMutableMap() - } - - /** Basis point take rate per event */ - fun bps(bps: Double) = bps(JsonField.of(bps)) - - /** Basis point take rate per event */ - fun bps(bps: JsonField) = apply { this.bps = bps } - - /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(perUnitMaximum: String?) = - perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) - - /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(perUnitMaximum: Optional) = - perUnitMaximum(perUnitMaximum.orElse(null)) - - /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(perUnitMaximum: JsonField) = apply { - this.perUnitMaximum = perUnitMaximum - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): BpsConfig = - BpsConfig( - checkRequired("bps", bps), - perUnitMaximum, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BpsConfig && bps == other.bps && perUnitMaximum == other.perUnitMaximum && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bps, perUnitMaximum, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BpsConfig{bps=$bps, perUnitMaximum=$perUnitMaximum, additionalProperties=$additionalProperties}" - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val BPS = of("bps") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BPS -> Value.BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - BPS -> Known.BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionBpsPrice && bpsConfig == other.bpsConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bpsConfig, cadence, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionBpsPrice{bpsConfig=$bpsConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionBulkBpsPrice - @JsonCreator - private constructor( - @JsonProperty("bulk_bps_config") - @ExcludeMissing - private val bulkBpsConfig: JsonField = JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun bulkBpsConfig(): BulkBpsConfig = bulkBpsConfig.getRequired("bulk_bps_config") - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - @JsonProperty("bulk_bps_config") - @ExcludeMissing - fun _bulkBpsConfig(): JsonField = bulkBpsConfig - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionBulkBpsPrice = apply { - if (validated) { - return@apply - } - - bulkBpsConfig().validate() - cadence() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionBulkBpsPrice]. */ - class Builder internal constructor() { - - private var bulkBpsConfig: JsonField? = null - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newSubscriptionBulkBpsPrice: NewSubscriptionBulkBpsPrice) = - apply { - bulkBpsConfig = newSubscriptionBulkBpsPrice.bulkBpsConfig - cadence = newSubscriptionBulkBpsPrice.cadence - itemId = newSubscriptionBulkBpsPrice.itemId - modelType = newSubscriptionBulkBpsPrice.modelType - name = newSubscriptionBulkBpsPrice.name - billableMetricId = newSubscriptionBulkBpsPrice.billableMetricId - billedInAdvance = newSubscriptionBulkBpsPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionBulkBpsPrice.billingCycleConfiguration - conversionRate = newSubscriptionBulkBpsPrice.conversionRate - currency = newSubscriptionBulkBpsPrice.currency - externalPriceId = newSubscriptionBulkBpsPrice.externalPriceId - fixedPriceQuantity = newSubscriptionBulkBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionBulkBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionBulkBpsPrice.invoicingCycleConfiguration - metadata = newSubscriptionBulkBpsPrice.metadata - referenceId = newSubscriptionBulkBpsPrice.referenceId - additionalProperties = - newSubscriptionBulkBpsPrice.additionalProperties.toMutableMap() - } - - fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfig) = - bulkBpsConfig(JsonField.of(bulkBpsConfig)) - - fun bulkBpsConfig(bulkBpsConfig: JsonField) = apply { - this.bulkBpsConfig = bulkBpsConfig - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionBulkBpsPrice = - NewSubscriptionBulkBpsPrice( - checkRequired("bulkBpsConfig", bulkBpsConfig), - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BulkBpsConfig - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - private val tiers: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a single - * tier based on total volume - */ - fun tiers(): List = tiers.getRequired("tiers") - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a single - * tier based on total volume - */ - @JsonProperty("tiers") - @ExcludeMissing - fun _tiers(): JsonField> = tiers - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BulkBpsConfig = apply { - if (validated) { - return@apply - } - - tiers().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkBpsConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(bulkBpsConfig: BulkBpsConfig) = apply { - tiers = bulkBpsConfig.tiers.map { it.toMutableList() } - additionalProperties = bulkBpsConfig.additionalProperties.toMutableMap() - } - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a - * single tier based on total volume - */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a - * single tier based on total volume - */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** - * Tiers for a bulk BPS pricing model where all usage is aggregated to a - * single tier based on total volume - */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): BulkBpsConfig = - BulkBpsConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Tier - @JsonCreator - private constructor( - @JsonProperty("bps") - @ExcludeMissing - private val bps: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("per_unit_maximum") - @ExcludeMissing - private val perUnitMaximum: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), - ) { - - /** Basis points to rate on */ - fun bps(): Double = bps.getRequired("bps") - - /** Upper bound for tier */ - fun maximumAmount(): Optional = - Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) - - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(): Optional = - Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) - - /** Basis points to rate on */ - @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps - - /** Upper bound for tier */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** The maximum amount to charge for any one event */ - @JsonProperty("per_unit_maximum") - @ExcludeMissing - fun _perUnitMaximum(): JsonField = perUnitMaximum - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - bps() - maximumAmount() - perUnitMaximum() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var bps: JsonField? = null - private var maximumAmount: JsonField = JsonMissing.of() - private var perUnitMaximum: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - bps = tier.bps - maximumAmount = tier.maximumAmount - perUnitMaximum = tier.perUnitMaximum - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Basis points to rate on */ - fun bps(bps: Double) = bps(JsonField.of(bps)) - - /** Basis points to rate on */ - fun bps(bps: JsonField) = apply { this.bps = bps } - - /** Upper bound for tier */ - fun maximumAmount(maximumAmount: String?) = - maximumAmount(JsonField.ofNullable(maximumAmount)) - - /** Upper bound for tier */ - fun maximumAmount(maximumAmount: Optional) = - maximumAmount(maximumAmount.orElse(null)) - - /** Upper bound for tier */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(perUnitMaximum: String?) = - perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) - - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(perUnitMaximum: Optional) = - perUnitMaximum(perUnitMaximum.orElse(null)) - - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(perUnitMaximum: JsonField) = apply { - this.perUnitMaximum = perUnitMaximum - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): Tier = - Tier( - checkRequired("bps", bps), - maximumAmount, - perUnitMaximum, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tier && bps == other.bps && maximumAmount == other.maximumAmount && perUnitMaximum == other.perUnitMaximum && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bps, maximumAmount, perUnitMaximum, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{bps=$bps, maximumAmount=$maximumAmount, perUnitMaximum=$perUnitMaximum, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BulkBpsConfig && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkBpsConfig{tiers=$tiers, additionalProperties=$additionalProperties}" - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val BULK_BPS = of("bulk_bps") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK_BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK_BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK_BPS -> Value.BULK_BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - BULK_BPS -> Known.BULK_BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionBulkBpsPrice && bulkBpsConfig == other.bulkBpsConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bulkBpsConfig, cadence, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionBulkBpsPrice{bulkBpsConfig=$bulkBpsConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionBulkPrice - @JsonCreator - private constructor( - @JsonProperty("bulk_config") - @ExcludeMissing - private val bulkConfig: JsonField = JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun bulkConfig(): BulkConfig = bulkConfig.getRequired("bulk_config") - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - @JsonProperty("bulk_config") - @ExcludeMissing - fun _bulkConfig(): JsonField = bulkConfig - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionBulkPrice = apply { - if (validated) { - return@apply - } - - bulkConfig().validate() - cadence() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionBulkPrice]. */ - class Builder internal constructor() { - - private var bulkConfig: JsonField? = null - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var 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 currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(newSubscriptionBulkPrice: NewSubscriptionBulkPrice) = apply { - bulkConfig = newSubscriptionBulkPrice.bulkConfig - cadence = newSubscriptionBulkPrice.cadence - itemId = newSubscriptionBulkPrice.itemId - modelType = newSubscriptionBulkPrice.modelType - name = newSubscriptionBulkPrice.name - billableMetricId = newSubscriptionBulkPrice.billableMetricId - billedInAdvance = newSubscriptionBulkPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionBulkPrice.billingCycleConfiguration - conversionRate = newSubscriptionBulkPrice.conversionRate - currency = newSubscriptionBulkPrice.currency - externalPriceId = newSubscriptionBulkPrice.externalPriceId - fixedPriceQuantity = newSubscriptionBulkPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionBulkPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionBulkPrice.invoicingCycleConfiguration - metadata = newSubscriptionBulkPrice.metadata - referenceId = newSubscriptionBulkPrice.referenceId - additionalProperties = - newSubscriptionBulkPrice.additionalProperties.toMutableMap() - } - - fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) - - fun bulkConfig(bulkConfig: JsonField) = apply { - this.bulkConfig = bulkConfig - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionBulkPrice = - NewSubscriptionBulkPrice( - checkRequired("bulkConfig", bulkConfig), - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BulkConfig - @JsonCreator - private constructor( - @JsonProperty("tiers") - @ExcludeMissing - private val tiers: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Bulk tiers for rating based on total usage volume */ - fun tiers(): List = tiers.getRequired("tiers") - - /** Bulk tiers for rating based on total usage volume */ - @JsonProperty("tiers") - @ExcludeMissing - fun _tiers(): JsonField> = tiers - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BulkConfig = apply { - if (validated) { - return@apply - } - - tiers().forEach { it.validate() } - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkConfig]. */ - class Builder internal constructor() { - - private var tiers: JsonField>? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(bulkConfig: BulkConfig) = apply { - tiers = bulkConfig.tiers.map { it.toMutableList() } - additionalProperties = bulkConfig.additionalProperties.toMutableMap() - } - - /** Bulk tiers for rating based on total usage volume */ - fun tiers(tiers: List) = tiers(JsonField.of(tiers)) - - /** Bulk tiers for rating based on total usage volume */ - fun tiers(tiers: JsonField>) = apply { - this.tiers = tiers.map { it.toMutableList() } - } - - /** Bulk tiers for rating based on total usage volume */ - fun addTier(tier: Tier) = apply { - tiers = - (tiers ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .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) - } - - fun build(): BulkConfig = - BulkConfig( - checkRequired("tiers", tiers).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class Tier - @JsonCreator - private constructor( - @JsonProperty("unit_amount") - @ExcludeMissing - private val unitAmount: JsonField = JsonMissing.of(), - @JsonProperty("maximum_units") - @ExcludeMissing - private val maximumUnits: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = - immutableEmptyMap(), - ) { - - /** Amount per unit */ - fun unitAmount(): String = unitAmount.getRequired("unit_amount") - - /** Upper bound for this tier */ - fun maximumUnits(): Optional = - Optional.ofNullable(maximumUnits.getNullable("maximum_units")) - - /** Amount per unit */ - @JsonProperty("unit_amount") - @ExcludeMissing - fun _unitAmount(): JsonField = unitAmount - - /** Upper bound for this tier */ - @JsonProperty("maximum_units") - @ExcludeMissing - fun _maximumUnits(): JsonField = maximumUnits - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Tier = apply { - if (validated) { - return@apply - } - - unitAmount() - maximumUnits() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tier]. */ - class Builder internal constructor() { - - private var unitAmount: JsonField? = null - private var maximumUnits: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tier: Tier) = apply { - unitAmount = tier.unitAmount - maximumUnits = tier.maximumUnits - additionalProperties = tier.additionalProperties.toMutableMap() - } - - /** Amount per unit */ - fun unitAmount(unitAmount: String) = - unitAmount(JsonField.of(unitAmount)) - - /** Amount per unit */ - fun unitAmount(unitAmount: JsonField) = apply { - this.unitAmount = unitAmount - } - - /** Upper bound for this tier */ - fun maximumUnits(maximumUnits: Double?) = - maximumUnits(JsonField.ofNullable(maximumUnits)) - - /** Upper bound for this tier */ - fun maximumUnits(maximumUnits: Double) = - maximumUnits(maximumUnits as Double?) - - /** Upper bound for this tier */ - @Suppress( - "USELESS_CAST" - ) // See https://youtrack.jetbrains.com/issue/KT-74228 - fun maximumUnits(maximumUnits: Optional) = - maximumUnits(maximumUnits.orElse(null) as Double?) - - /** Upper bound for this tier */ - fun maximumUnits(maximumUnits: JsonField) = apply { - this.maximumUnits = maximumUnits - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Tier = - Tier( - checkRequired("unitAmount", unitAmount), - maximumUnits, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tier && unitAmount == other.unitAmount && maximumUnits == other.maximumUnits && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(unitAmount, maximumUnits, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tier{unitAmount=$unitAmount, maximumUnits=$maximumUnits, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BulkConfig && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkConfig{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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val BULK = of("bulk") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK -> Value.BULK - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - BULK -> Known.BULK - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionBulkPrice && bulkConfig == other.bulkConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bulkConfig, cadence, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionBulkPrice{bulkConfig=$bulkConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionThresholdTotalAmountPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("threshold_total_amount_config") - @ExcludeMissing - private val thresholdTotalAmountConfig: JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun thresholdTotalAmountConfig(): ThresholdTotalAmountConfig = - thresholdTotalAmountConfig.getRequired("threshold_total_amount_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("threshold_total_amount_config") - @ExcludeMissing - fun _thresholdTotalAmountConfig(): JsonField = - thresholdTotalAmountConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionThresholdTotalAmountPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - thresholdTotalAmountConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionThresholdTotalAmountPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var thresholdTotalAmountConfig: JsonField? = - null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionThresholdTotalAmountPrice: - NewSubscriptionThresholdTotalAmountPrice - ) = apply { - cadence = newSubscriptionThresholdTotalAmountPrice.cadence - itemId = newSubscriptionThresholdTotalAmountPrice.itemId - modelType = newSubscriptionThresholdTotalAmountPrice.modelType - name = newSubscriptionThresholdTotalAmountPrice.name - thresholdTotalAmountConfig = - newSubscriptionThresholdTotalAmountPrice.thresholdTotalAmountConfig - billableMetricId = newSubscriptionThresholdTotalAmountPrice.billableMetricId - billedInAdvance = newSubscriptionThresholdTotalAmountPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionThresholdTotalAmountPrice.billingCycleConfiguration - conversionRate = newSubscriptionThresholdTotalAmountPrice.conversionRate - currency = newSubscriptionThresholdTotalAmountPrice.currency - externalPriceId = newSubscriptionThresholdTotalAmountPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionThresholdTotalAmountPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionThresholdTotalAmountPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionThresholdTotalAmountPrice.invoicingCycleConfiguration - metadata = newSubscriptionThresholdTotalAmountPrice.metadata - referenceId = newSubscriptionThresholdTotalAmountPrice.referenceId - additionalProperties = - newSubscriptionThresholdTotalAmountPrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun thresholdTotalAmountConfig( - thresholdTotalAmountConfig: ThresholdTotalAmountConfig - ) = thresholdTotalAmountConfig(JsonField.of(thresholdTotalAmountConfig)) - - fun thresholdTotalAmountConfig( - thresholdTotalAmountConfig: JsonField - ) = apply { this.thresholdTotalAmountConfig = thresholdTotalAmountConfig } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionThresholdTotalAmountPrice = - NewSubscriptionThresholdTotalAmountPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("thresholdTotalAmountConfig", thresholdTotalAmountConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val THRESHOLD_TOTAL_AMOUNT = of("threshold_total_amount") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - THRESHOLD_TOTAL_AMOUNT - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - THRESHOLD_TOTAL_AMOUNT, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - THRESHOLD_TOTAL_AMOUNT -> Value.THRESHOLD_TOTAL_AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - THRESHOLD_TOTAL_AMOUNT -> Known.THRESHOLD_TOTAL_AMOUNT - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class ThresholdTotalAmountConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): ThresholdTotalAmountConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ThresholdTotalAmountConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(thresholdTotalAmountConfig: ThresholdTotalAmountConfig) = - apply { - additionalProperties = - thresholdTotalAmountConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): ThresholdTotalAmountConfig = - ThresholdTotalAmountConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ThresholdTotalAmountConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ThresholdTotalAmountConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionThresholdTotalAmountPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, thresholdTotalAmountConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionThresholdTotalAmountPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionTieredPackagePrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_package_config") - @ExcludeMissing - private val tieredPackageConfig: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun tieredPackageConfig(): TieredPackageConfig = - tieredPackageConfig.getRequired("tiered_package_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("tiered_package_config") - @ExcludeMissing - fun _tieredPackageConfig(): JsonField = tieredPackageConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionTieredPackagePrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - tieredPackageConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionTieredPackagePrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var tieredPackageConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionTieredPackagePrice: NewSubscriptionTieredPackagePrice - ) = apply { - cadence = newSubscriptionTieredPackagePrice.cadence - itemId = newSubscriptionTieredPackagePrice.itemId - modelType = newSubscriptionTieredPackagePrice.modelType - name = newSubscriptionTieredPackagePrice.name - tieredPackageConfig = newSubscriptionTieredPackagePrice.tieredPackageConfig - billableMetricId = newSubscriptionTieredPackagePrice.billableMetricId - billedInAdvance = newSubscriptionTieredPackagePrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionTieredPackagePrice.billingCycleConfiguration - conversionRate = newSubscriptionTieredPackagePrice.conversionRate - currency = newSubscriptionTieredPackagePrice.currency - externalPriceId = newSubscriptionTieredPackagePrice.externalPriceId - fixedPriceQuantity = newSubscriptionTieredPackagePrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionTieredPackagePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionTieredPackagePrice.invoicingCycleConfiguration - metadata = newSubscriptionTieredPackagePrice.metadata - referenceId = newSubscriptionTieredPackagePrice.referenceId - additionalProperties = - newSubscriptionTieredPackagePrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = - tieredPackageConfig(JsonField.of(tieredPackageConfig)) - - fun tieredPackageConfig(tieredPackageConfig: JsonField) = - apply { - this.tieredPackageConfig = tieredPackageConfig - } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionTieredPackagePrice = - NewSubscriptionTieredPackagePrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("tieredPackageConfig", tieredPackageConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED_PACKAGE = of("tiered_package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_PACKAGE - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_PACKAGE, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_PACKAGE -> Value.TIERED_PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TIERED_PACKAGE -> Known.TIERED_PACKAGE - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TieredPackageConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredPackageConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredPackageConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tieredPackageConfig: TieredPackageConfig) = apply { - additionalProperties = - tieredPackageConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): TieredPackageConfig = - TieredPackageConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredPackageConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionTieredPackagePrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredPackageConfig == other.tieredPackageConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredPackageConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionTieredPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionTieredWithMinimumPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_minimum_config") - @ExcludeMissing - private val tieredWithMinimumConfig: JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun tieredWithMinimumConfig(): TieredWithMinimumConfig = - tieredWithMinimumConfig.getRequired("tiered_with_minimum_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("tiered_with_minimum_config") - @ExcludeMissing - fun _tieredWithMinimumConfig(): JsonField = - tieredWithMinimumConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionTieredWithMinimumPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - tieredWithMinimumConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionTieredWithMinimumPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var tieredWithMinimumConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionTieredWithMinimumPrice: NewSubscriptionTieredWithMinimumPrice - ) = apply { - cadence = newSubscriptionTieredWithMinimumPrice.cadence - itemId = newSubscriptionTieredWithMinimumPrice.itemId - modelType = newSubscriptionTieredWithMinimumPrice.modelType - name = newSubscriptionTieredWithMinimumPrice.name - tieredWithMinimumConfig = - newSubscriptionTieredWithMinimumPrice.tieredWithMinimumConfig - billableMetricId = newSubscriptionTieredWithMinimumPrice.billableMetricId - billedInAdvance = newSubscriptionTieredWithMinimumPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionTieredWithMinimumPrice.billingCycleConfiguration - conversionRate = newSubscriptionTieredWithMinimumPrice.conversionRate - currency = newSubscriptionTieredWithMinimumPrice.currency - externalPriceId = newSubscriptionTieredWithMinimumPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionTieredWithMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionTieredWithMinimumPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionTieredWithMinimumPrice.invoicingCycleConfiguration - metadata = newSubscriptionTieredWithMinimumPrice.metadata - referenceId = newSubscriptionTieredWithMinimumPrice.referenceId - additionalProperties = - newSubscriptionTieredWithMinimumPrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredWithMinimumConfig(tieredWithMinimumConfig: TieredWithMinimumConfig) = - tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) - - fun tieredWithMinimumConfig( - tieredWithMinimumConfig: JsonField - ) = apply { this.tieredWithMinimumConfig = tieredWithMinimumConfig } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionTieredWithMinimumPrice = - NewSubscriptionTieredWithMinimumPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("tieredWithMinimumConfig", tieredWithMinimumConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED_WITH_MINIMUM = of("tiered_with_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_WITH_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_WITH_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_WITH_MINIMUM -> Value.TIERED_WITH_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TIERED_WITH_MINIMUM -> Known.TIERED_WITH_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TieredWithMinimumConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredWithMinimumConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredWithMinimumConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tieredWithMinimumConfig: TieredWithMinimumConfig) = - apply { - additionalProperties = - tieredWithMinimumConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): TieredWithMinimumConfig = - TieredWithMinimumConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredWithMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredWithMinimumConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionTieredWithMinimumPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredWithMinimumConfig == other.tieredWithMinimumConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredWithMinimumConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionTieredWithMinimumPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionUnitWithPercentPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("unit_with_percent_config") - @ExcludeMissing - private val unitWithPercentConfig: JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun unitWithPercentConfig(): UnitWithPercentConfig = - unitWithPercentConfig.getRequired("unit_with_percent_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("unit_with_percent_config") - @ExcludeMissing - fun _unitWithPercentConfig(): JsonField = - unitWithPercentConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionUnitWithPercentPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - unitWithPercentConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionUnitWithPercentPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var unitWithPercentConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionUnitWithPercentPrice: NewSubscriptionUnitWithPercentPrice - ) = apply { - cadence = newSubscriptionUnitWithPercentPrice.cadence - itemId = newSubscriptionUnitWithPercentPrice.itemId - modelType = newSubscriptionUnitWithPercentPrice.modelType - name = newSubscriptionUnitWithPercentPrice.name - unitWithPercentConfig = - newSubscriptionUnitWithPercentPrice.unitWithPercentConfig - billableMetricId = newSubscriptionUnitWithPercentPrice.billableMetricId - billedInAdvance = newSubscriptionUnitWithPercentPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionUnitWithPercentPrice.billingCycleConfiguration - conversionRate = newSubscriptionUnitWithPercentPrice.conversionRate - currency = newSubscriptionUnitWithPercentPrice.currency - externalPriceId = newSubscriptionUnitWithPercentPrice.externalPriceId - fixedPriceQuantity = newSubscriptionUnitWithPercentPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionUnitWithPercentPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionUnitWithPercentPrice.invoicingCycleConfiguration - metadata = newSubscriptionUnitWithPercentPrice.metadata - referenceId = newSubscriptionUnitWithPercentPrice.referenceId - additionalProperties = - newSubscriptionUnitWithPercentPrice.additionalProperties.toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun unitWithPercentConfig(unitWithPercentConfig: UnitWithPercentConfig) = - unitWithPercentConfig(JsonField.of(unitWithPercentConfig)) - - fun unitWithPercentConfig( - unitWithPercentConfig: JsonField - ) = apply { this.unitWithPercentConfig = unitWithPercentConfig } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionUnitWithPercentPrice = - NewSubscriptionUnitWithPercentPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("unitWithPercentConfig", unitWithPercentConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val UNIT_WITH_PERCENT = of("unit_with_percent") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - UNIT_WITH_PERCENT - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - UNIT_WITH_PERCENT, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - UNIT_WITH_PERCENT -> Value.UNIT_WITH_PERCENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - UNIT_WITH_PERCENT -> Known.UNIT_WITH_PERCENT - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class UnitWithPercentConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): UnitWithPercentConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnitWithPercentConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unitWithPercentConfig: UnitWithPercentConfig) = apply { - additionalProperties = - unitWithPercentConfig.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) - } - - fun build(): UnitWithPercentConfig = - UnitWithPercentConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UnitWithPercentConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnitWithPercentConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionUnitWithPercentPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && unitWithPercentConfig == other.unitWithPercentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, unitWithPercentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionUnitWithPercentPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionPackageWithAllocationPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("package_with_allocation_config") - @ExcludeMissing - private val packageWithAllocationConfig: JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun packageWithAllocationConfig(): PackageWithAllocationConfig = - packageWithAllocationConfig.getRequired("package_with_allocation_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("package_with_allocation_config") - @ExcludeMissing - fun _packageWithAllocationConfig(): JsonField = - packageWithAllocationConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionPackageWithAllocationPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - packageWithAllocationConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionPackageWithAllocationPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var packageWithAllocationConfig: - JsonField? = - null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionPackageWithAllocationPrice: - NewSubscriptionPackageWithAllocationPrice - ) = apply { - cadence = newSubscriptionPackageWithAllocationPrice.cadence - itemId = newSubscriptionPackageWithAllocationPrice.itemId - modelType = newSubscriptionPackageWithAllocationPrice.modelType - name = newSubscriptionPackageWithAllocationPrice.name - packageWithAllocationConfig = - newSubscriptionPackageWithAllocationPrice.packageWithAllocationConfig - billableMetricId = - newSubscriptionPackageWithAllocationPrice.billableMetricId - billedInAdvance = newSubscriptionPackageWithAllocationPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionPackageWithAllocationPrice.billingCycleConfiguration - conversionRate = newSubscriptionPackageWithAllocationPrice.conversionRate - currency = newSubscriptionPackageWithAllocationPrice.currency - externalPriceId = newSubscriptionPackageWithAllocationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionPackageWithAllocationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionPackageWithAllocationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionPackageWithAllocationPrice.invoicingCycleConfiguration - metadata = newSubscriptionPackageWithAllocationPrice.metadata - referenceId = newSubscriptionPackageWithAllocationPrice.referenceId - additionalProperties = - newSubscriptionPackageWithAllocationPrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun packageWithAllocationConfig( - packageWithAllocationConfig: PackageWithAllocationConfig - ) = packageWithAllocationConfig(JsonField.of(packageWithAllocationConfig)) - - fun packageWithAllocationConfig( - packageWithAllocationConfig: JsonField - ) = apply { this.packageWithAllocationConfig = packageWithAllocationConfig } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionPackageWithAllocationPrice = - NewSubscriptionPackageWithAllocationPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired( - "packageWithAllocationConfig", - packageWithAllocationConfig, - ), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val PACKAGE_WITH_ALLOCATION = of("package_with_allocation") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - PACKAGE_WITH_ALLOCATION - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PACKAGE_WITH_ALLOCATION, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PACKAGE_WITH_ALLOCATION -> Value.PACKAGE_WITH_ALLOCATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PACKAGE_WITH_ALLOCATION -> Known.PACKAGE_WITH_ALLOCATION - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class PackageWithAllocationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PackageWithAllocationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PackageWithAllocationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - packageWithAllocationConfig: PackageWithAllocationConfig - ) = apply { - additionalProperties = - packageWithAllocationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): PackageWithAllocationConfig = - PackageWithAllocationConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PackageWithAllocationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PackageWithAllocationConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionPackageWithAllocationPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && packageWithAllocationConfig == other.packageWithAllocationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, packageWithAllocationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionPackageWithAllocationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionTierWithProrationPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - private val tieredWithProrationConfig: JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - 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. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("tiered_with_proration_config") - @ExcludeMissing - fun _tieredWithProrationConfig(): JsonField = - tieredWithProrationConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionTierWithProrationPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - tieredWithProrationConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionTierWithProrationPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var tieredWithProrationConfig: JsonField? = - null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionTierWithProrationPrice: NewSubscriptionTierWithProrationPrice - ) = apply { - cadence = newSubscriptionTierWithProrationPrice.cadence - itemId = newSubscriptionTierWithProrationPrice.itemId - modelType = newSubscriptionTierWithProrationPrice.modelType - name = newSubscriptionTierWithProrationPrice.name - tieredWithProrationConfig = - newSubscriptionTierWithProrationPrice.tieredWithProrationConfig - billableMetricId = newSubscriptionTierWithProrationPrice.billableMetricId - billedInAdvance = newSubscriptionTierWithProrationPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionTierWithProrationPrice.billingCycleConfiguration - conversionRate = newSubscriptionTierWithProrationPrice.conversionRate - currency = newSubscriptionTierWithProrationPrice.currency - externalPriceId = newSubscriptionTierWithProrationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionTierWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionTierWithProrationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionTierWithProrationPrice.invoicingCycleConfiguration - metadata = newSubscriptionTierWithProrationPrice.metadata - referenceId = newSubscriptionTierWithProrationPrice.referenceId - additionalProperties = - newSubscriptionTierWithProrationPrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun tieredWithProrationConfig( - tieredWithProrationConfig: TieredWithProrationConfig - ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) - - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionTierWithProrationPrice = - NewSubscriptionTierWithProrationPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED_WITH_PRORATION = of("tiered_with_proration") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_WITH_PRORATION - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_WITH_PRORATION, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_WITH_PRORATION -> Value.TIERED_WITH_PRORATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TIERED_WITH_PRORATION -> Known.TIERED_WITH_PRORATION - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TieredWithProrationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TieredWithProrationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TieredWithProrationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(tieredWithProrationConfig: TieredWithProrationConfig) = - apply { - additionalProperties = - tieredWithProrationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): TieredWithProrationConfig = - TieredWithProrationConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TieredWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TieredWithProrationConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionTierWithProrationPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionTierWithProrationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionUnitWithProrationPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("unit_with_proration_config") - @ExcludeMissing - private val unitWithProrationConfig: JsonField = - JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - fun unitWithProrationConfig(): UnitWithProrationConfig = - unitWithProrationConfig.getRequired("unit_with_proration_config") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonProperty("unit_with_proration_config") - @ExcludeMissing - fun _unitWithProrationConfig(): JsonField = - unitWithProrationConfig - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionUnitWithProrationPrice = apply { - if (validated) { - return@apply - } - - cadence() - itemId() - modelType() - name() - unitWithProrationConfig().validate() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionUnitWithProrationPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var unitWithProrationConfig: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionUnitWithProrationPrice: NewSubscriptionUnitWithProrationPrice - ) = apply { - cadence = newSubscriptionUnitWithProrationPrice.cadence - itemId = newSubscriptionUnitWithProrationPrice.itemId - modelType = newSubscriptionUnitWithProrationPrice.modelType - name = newSubscriptionUnitWithProrationPrice.name - unitWithProrationConfig = - newSubscriptionUnitWithProrationPrice.unitWithProrationConfig - billableMetricId = newSubscriptionUnitWithProrationPrice.billableMetricId - billedInAdvance = newSubscriptionUnitWithProrationPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionUnitWithProrationPrice.billingCycleConfiguration - conversionRate = newSubscriptionUnitWithProrationPrice.conversionRate - currency = newSubscriptionUnitWithProrationPrice.currency - externalPriceId = newSubscriptionUnitWithProrationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionUnitWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionUnitWithProrationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionUnitWithProrationPrice.invoicingCycleConfiguration - metadata = newSubscriptionUnitWithProrationPrice.metadata - referenceId = newSubscriptionUnitWithProrationPrice.referenceId - additionalProperties = - newSubscriptionUnitWithProrationPrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - fun name(name: JsonField) = apply { this.name = name } - - fun unitWithProrationConfig(unitWithProrationConfig: UnitWithProrationConfig) = - unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) - - fun unitWithProrationConfig( - unitWithProrationConfig: JsonField - ) = apply { this.unitWithProrationConfig = unitWithProrationConfig } - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: String?) = - billableMetricId(JsonField.ofNullable(billableMetricId)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionUnitWithProrationPrice = - NewSubscriptionUnitWithProrationPrice( - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - checkRequired("unitWithProrationConfig", unitWithProrationConfig), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val UNIT_WITH_PRORATION = of("unit_with_proration") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - UNIT_WITH_PRORATION - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - UNIT_WITH_PRORATION, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - UNIT_WITH_PRORATION -> Value.UNIT_WITH_PRORATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - UNIT_WITH_PRORATION -> Known.UNIT_WITH_PRORATION - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class UnitWithProrationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): UnitWithProrationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnitWithProrationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(unitWithProrationConfig: UnitWithProrationConfig) = - apply { - additionalProperties = - unitWithProrationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): UnitWithProrationConfig = - UnitWithProrationConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UnitWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnitWithProrationConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionUnitWithProrationPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && unitWithProrationConfig == other.unitWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, unitWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionUnitWithProrationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionGroupedAllocationPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_allocation_config") - @ExcludeMissing - private val groupedAllocationConfig: JsonField = - JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - fun groupedAllocationConfig(): GroupedAllocationConfig = - groupedAllocationConfig.getRequired("grouped_allocation_config") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - @JsonProperty("grouped_allocation_config") - @ExcludeMissing - fun _groupedAllocationConfig(): JsonField = - groupedAllocationConfig - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionGroupedAllocationPrice = apply { - if (validated) { - return@apply - } - - cadence() - groupedAllocationConfig().validate() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionGroupedAllocationPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var groupedAllocationConfig: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var 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 currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionGroupedAllocationPrice: NewSubscriptionGroupedAllocationPrice - ) = apply { - cadence = newSubscriptionGroupedAllocationPrice.cadence - groupedAllocationConfig = - newSubscriptionGroupedAllocationPrice.groupedAllocationConfig - itemId = newSubscriptionGroupedAllocationPrice.itemId - modelType = newSubscriptionGroupedAllocationPrice.modelType - name = newSubscriptionGroupedAllocationPrice.name - billableMetricId = newSubscriptionGroupedAllocationPrice.billableMetricId - billedInAdvance = newSubscriptionGroupedAllocationPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionGroupedAllocationPrice.billingCycleConfiguration - conversionRate = newSubscriptionGroupedAllocationPrice.conversionRate - currency = newSubscriptionGroupedAllocationPrice.currency - externalPriceId = newSubscriptionGroupedAllocationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionGroupedAllocationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionGroupedAllocationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionGroupedAllocationPrice.invoicingCycleConfiguration - metadata = newSubscriptionGroupedAllocationPrice.metadata - referenceId = newSubscriptionGroupedAllocationPrice.referenceId - additionalProperties = - newSubscriptionGroupedAllocationPrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = - groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) - - fun groupedAllocationConfig( - groupedAllocationConfig: JsonField - ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionGroupedAllocationPrice = - NewSubscriptionGroupedAllocationPrice( - checkRequired("cadence", cadence), - checkRequired("groupedAllocationConfig", groupedAllocationConfig), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class GroupedAllocationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): GroupedAllocationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [GroupedAllocationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(groupedAllocationConfig: GroupedAllocationConfig) = - apply { - additionalProperties = - groupedAllocationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): GroupedAllocationConfig = - GroupedAllocationConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GroupedAllocationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedAllocationConfig{additionalProperties=$additionalProperties}" - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val GROUPED_ALLOCATION = of("grouped_allocation") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_ALLOCATION - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GROUPED_ALLOCATION, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GROUPED_ALLOCATION -> Value.GROUPED_ALLOCATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - GROUPED_ALLOCATION -> Known.GROUPED_ALLOCATION - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionGroupedAllocationPrice && cadence == other.cadence && groupedAllocationConfig == other.groupedAllocationConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, groupedAllocationConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionGroupedAllocationPrice{cadence=$cadence, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionGroupedWithProratedMinimumPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("grouped_with_prorated_minimum_config") - @ExcludeMissing - private val groupedWithProratedMinimumConfig: - JsonField = - JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - fun groupedWithProratedMinimumConfig(): GroupedWithProratedMinimumConfig = - groupedWithProratedMinimumConfig.getRequired( - "grouped_with_prorated_minimum_config" - ) - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - @JsonProperty("grouped_with_prorated_minimum_config") - @ExcludeMissing - fun _groupedWithProratedMinimumConfig(): - JsonField = groupedWithProratedMinimumConfig - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionGroupedWithProratedMinimumPrice = apply { - if (validated) { - return@apply - } - - cadence() - groupedWithProratedMinimumConfig().validate() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionGroupedWithProratedMinimumPrice]. */ - class Builder internal constructor() { - - private var cadence: JsonField? = null - private var groupedWithProratedMinimumConfig: - JsonField? = - null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var name: JsonField? = null - private var billableMetricId: JsonField = JsonMissing.of() - private var billedInAdvance: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionGroupedWithProratedMinimumPrice: - NewSubscriptionGroupedWithProratedMinimumPrice - ) = apply { - cadence = newSubscriptionGroupedWithProratedMinimumPrice.cadence - groupedWithProratedMinimumConfig = - newSubscriptionGroupedWithProratedMinimumPrice - .groupedWithProratedMinimumConfig - itemId = newSubscriptionGroupedWithProratedMinimumPrice.itemId - modelType = newSubscriptionGroupedWithProratedMinimumPrice.modelType - name = newSubscriptionGroupedWithProratedMinimumPrice.name - billableMetricId = - newSubscriptionGroupedWithProratedMinimumPrice.billableMetricId - billedInAdvance = - newSubscriptionGroupedWithProratedMinimumPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionGroupedWithProratedMinimumPrice.billingCycleConfiguration - conversionRate = - newSubscriptionGroupedWithProratedMinimumPrice.conversionRate - currency = newSubscriptionGroupedWithProratedMinimumPrice.currency - externalPriceId = - newSubscriptionGroupedWithProratedMinimumPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionGroupedWithProratedMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionGroupedWithProratedMinimumPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionGroupedWithProratedMinimumPrice - .invoicingCycleConfiguration - metadata = newSubscriptionGroupedWithProratedMinimumPrice.metadata - referenceId = newSubscriptionGroupedWithProratedMinimumPrice.referenceId - additionalProperties = - newSubscriptionGroupedWithProratedMinimumPrice.additionalProperties - .toMutableMap() - } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - - fun groupedWithProratedMinimumConfig( - groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig - ) = - groupedWithProratedMinimumConfig( - JsonField.of(groupedWithProratedMinimumConfig) - ) - - fun groupedWithProratedMinimumConfig( - groupedWithProratedMinimumConfig: - JsonField - ) = apply { - this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig - } - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** The id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionGroupedWithProratedMinimumPrice = - NewSubscriptionGroupedWithProratedMinimumPrice( - checkRequired("cadence", cadence), - checkRequired( - "groupedWithProratedMinimumConfig", - groupedWithProratedMinimumConfig, - ), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - /** 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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class GroupedWithProratedMinimumConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): GroupedWithProratedMinimumConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [GroupedWithProratedMinimumConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig - ) = apply { - additionalProperties = - groupedWithProratedMinimumConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): GroupedWithProratedMinimumConfig = - GroupedWithProratedMinimumConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GroupedWithProratedMinimumConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GroupedWithProratedMinimumConfig{additionalProperties=$additionalProperties}" - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField - val GROUPED_WITH_PRORATED_MINIMUM = of("grouped_with_prorated_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_WITH_PRORATED_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GROUPED_WITH_PRORATED_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GROUPED_WITH_PRORATED_MINIMUM -> Value.GROUPED_WITH_PRORATED_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - GROUPED_WITH_PRORATED_MINIMUM -> Known.GROUPED_WITH_PRORATED_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionGroupedWithProratedMinimumPrice && cadence == other.cadence && groupedWithProratedMinimumConfig == other.groupedWithProratedMinimumConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, groupedWithProratedMinimumConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionGroupedWithProratedMinimumPrice{cadence=$cadence, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class NewSubscriptionBulkWithProrationPrice - @JsonCreator - private constructor( - @JsonProperty("bulk_with_proration_config") - @ExcludeMissing - private val bulkWithProrationConfig: JsonField = - JsonMissing.of(), - @JsonProperty("cadence") - @ExcludeMissing - private val cadence: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - private val modelType: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonProperty("billable_metric_id") - @ExcludeMissing - private val billableMetricId: JsonField = JsonMissing.of(), - @JsonProperty("billed_in_advance") - @ExcludeMissing - private val billedInAdvance: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - private val billingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("conversion_rate") - @ExcludeMissing - private val conversionRate: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - private val currency: JsonField = JsonMissing.of(), - @JsonProperty("external_price_id") - @ExcludeMissing - private val externalPriceId: JsonField = JsonMissing.of(), - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - private val fixedPriceQuantity: JsonField = JsonMissing.of(), - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - private val invoiceGroupingKey: JsonField = JsonMissing.of(), - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - private val invoicingCycleConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("reference_id") - @ExcludeMissing - private val referenceId: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun bulkWithProrationConfig(): BulkWithProrationConfig = - bulkWithProrationConfig.getRequired("bulk_with_proration_config") - - /** The cadence to bill for this price on. */ - fun cadence(): Cadence = cadence.getRequired("cadence") - - /** The id of the item the price will be associated with. */ - fun itemId(): String = itemId.getRequired("item_id") - - fun modelType(): ModelType = modelType.getRequired("model_type") - - /** The name of the price. */ - fun name(): String = name.getRequired("name") - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(): Optional = - Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if this - * is true, and in-arrears if this is false. - */ - fun billedInAdvance(): Optional = - Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration(): Optional = - Optional.ofNullable( - billingCycleConfiguration.getNullable("billing_cycle_configuration") - ) - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(): Optional = - Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(): Optional = - Optional.ofNullable(currency.getNullable("currency")) - - /** An alias for the price. */ - fun externalPriceId(): Optional = - Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(): Optional = - Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(): Optional = - Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable( - invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") - ) - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - fun metadata(): Optional = - Optional.ofNullable(metadata.getNullable("metadata")) - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - fun referenceId(): Optional = - Optional.ofNullable(referenceId.getNullable("reference_id")) - - @JsonProperty("bulk_with_proration_config") - @ExcludeMissing - fun _bulkWithProrationConfig(): JsonField = - bulkWithProrationConfig - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") - @ExcludeMissing - fun _cadence(): JsonField = cadence - - /** The id of the item the price will be associated with. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - @JsonProperty("model_type") - @ExcludeMissing - fun _modelType(): JsonField = modelType - - /** The name of the price. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - @JsonProperty("billable_metric_id") - @ExcludeMissing - fun _billableMetricId(): JsonField = 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. - */ - @JsonProperty("billed_in_advance") - @ExcludeMissing - fun _billedInAdvance(): JsonField = billedInAdvance - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @JsonProperty("billing_cycle_configuration") - @ExcludeMissing - fun _billingCycleConfiguration(): JsonField = - billingCycleConfiguration - - /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - @ExcludeMissing - fun _conversionRate(): JsonField = conversionRate - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** An alias for the price. */ - @JsonProperty("external_price_id") - @ExcludeMissing - fun _externalPriceId(): JsonField = externalPriceId - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @JsonProperty("fixed_price_quantity") - @ExcludeMissing - fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity - - /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - @ExcludeMissing - fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @JsonProperty("invoicing_cycle_configuration") - @ExcludeMissing - fun _invoicingCycleConfiguration(): JsonField = - invoicingCycleConfiguration - - /** - * User-specified key/value pairs for the resource. Individual keys can be removed - * by setting the value to `null`, and the entire metadata mapping can be cleared by - * setting `metadata` to `null`. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * A transient ID that can be used to reference this price when adding adjustments - * in the same API call. - */ - @JsonProperty("reference_id") - @ExcludeMissing - fun _referenceId(): JsonField = referenceId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): NewSubscriptionBulkWithProrationPrice = apply { - if (validated) { - return@apply - } - - bulkWithProrationConfig().validate() - cadence() - itemId() - modelType() - name() - billableMetricId() - billedInAdvance() - billingCycleConfiguration().ifPresent { it.validate() } - conversionRate() - currency() - externalPriceId() - fixedPriceQuantity() - invoiceGroupingKey() - invoicingCycleConfiguration().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - referenceId() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NewSubscriptionBulkWithProrationPrice]. */ - class Builder internal constructor() { - - private var bulkWithProrationConfig: JsonField? = null - private var cadence: JsonField? = null - private var itemId: JsonField? = null - private var modelType: JsonField? = null - private var 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 currency: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoiceGroupingKey: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: - JsonField = - JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var referenceId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - newSubscriptionBulkWithProrationPrice: NewSubscriptionBulkWithProrationPrice - ) = apply { - bulkWithProrationConfig = - newSubscriptionBulkWithProrationPrice.bulkWithProrationConfig - cadence = newSubscriptionBulkWithProrationPrice.cadence - itemId = newSubscriptionBulkWithProrationPrice.itemId - modelType = newSubscriptionBulkWithProrationPrice.modelType - name = newSubscriptionBulkWithProrationPrice.name - billableMetricId = newSubscriptionBulkWithProrationPrice.billableMetricId - billedInAdvance = newSubscriptionBulkWithProrationPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionBulkWithProrationPrice.billingCycleConfiguration - conversionRate = newSubscriptionBulkWithProrationPrice.conversionRate - currency = newSubscriptionBulkWithProrationPrice.currency - externalPriceId = newSubscriptionBulkWithProrationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionBulkWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionBulkWithProrationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionBulkWithProrationPrice.invoicingCycleConfiguration - metadata = newSubscriptionBulkWithProrationPrice.metadata - referenceId = newSubscriptionBulkWithProrationPrice.referenceId - additionalProperties = - newSubscriptionBulkWithProrationPrice.additionalProperties - .toMutableMap() - } - - fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = - bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) - - fun bulkWithProrationConfig( - bulkWithProrationConfig: JsonField - ) = apply { this.bulkWithProrationConfig = bulkWithProrationConfig } - - /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) - - /** The cadence to bill for this price on. */ - 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 id of the item the price will be associated with. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } - - /** The name of the price. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price. */ - 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)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - fun billableMetricId(billableMetricId: Optional) = - billableMetricId(billableMetricId.orElse(null)) - - /** - * The id of the billable metric for the price. Only needed if the price is - * usage-based. - */ - 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)) - - /** - * If 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(billedInAdvance as Boolean?) - - /** - * If the Price represents a fixed cost, the price will be billed in-advance if - * this is true, and in-arrears if this is false. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) - - /** - * If 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: JsonField) = apply { - this.billedInAdvance = billedInAdvance - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: BillingCycleConfiguration? - ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - fun billingCycleConfiguration( - billingCycleConfiguration: Optional - ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - 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)) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: Double) = - conversionRate(conversionRate as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) - - /** - * The per unit conversion rate of the price currency to the invoicing currency. - */ - fun conversionRate(conversionRate: JsonField) = apply { - this.conversionRate = conversionRate - } - - /** - * 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. - */ - fun currency(currency: Optional) = currency(currency.orElse(null)) - - /** - * An ISO 4217 currency string, or custom pricing unit identifier, in which this - * price is billed. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = - externalPriceId(JsonField.ofNullable(externalPriceId)) - - /** An alias for the price. */ - fun externalPriceId(externalPriceId: Optional) = - externalPriceId(externalPriceId.orElse(null)) - - /** An alias for the price. */ - 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)) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(fixedPriceQuantity as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun fixedPriceQuantity(fixedPriceQuantity: Optional) = - fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - - /** - * If the Price represents a fixed cost, this represents the quantity of units - * applied. - */ - 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)) - - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: Optional) = - invoiceGroupingKey(invoiceGroupingKey.orElse(null)) - - /** The property used to group this price on an invoice */ - 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: InvoicingCycleConfiguration? - ) = - invoicingCycleConfiguration( - JsonField.ofNullable(invoicingCycleConfiguration) - ) - - /** - * Within each billing cycle, specifies the cadence at which invoices are - * produced. If unspecified, a single invoice is produced per billing cycle. - */ - fun invoicingCycleConfiguration( - invoicingCycleConfiguration: Optional - ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(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: JsonField - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** - * User-specified key/value pairs for the resource. Individual keys can be - * removed by setting the value to `null`, and the entire metadata mapping can - * be cleared by setting `metadata` to `null`. - */ - fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - fun referenceId(referenceId: Optional) = - referenceId(referenceId.orElse(null)) - - /** - * A transient ID that can be used to reference this price when adding - * adjustments in the same API call. - */ - 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) - } - - fun build(): NewSubscriptionBulkWithProrationPrice = - NewSubscriptionBulkWithProrationPrice( - checkRequired("bulkWithProrationConfig", bulkWithProrationConfig), - checkRequired("cadence", cadence), - checkRequired("itemId", itemId), - checkRequired("modelType", modelType), - checkRequired("name", name), - billableMetricId, - billedInAdvance, - billingCycleConfiguration, - conversionRate, - currency, - externalPriceId, - fixedPriceQuantity, - invoiceGroupingKey, - invoicingCycleConfiguration, - metadata, - referenceId, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class BulkWithProrationConfig - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BulkWithProrationConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkWithProrationConfig]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(bulkWithProrationConfig: BulkWithProrationConfig) = - apply { - additionalProperties = - bulkWithProrationConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): BulkWithProrationConfig = - BulkWithProrationConfig(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BulkWithProrationConfig && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkWithProrationConfig{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") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cadence && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val BULK_WITH_PRORATION = of("bulk_with_proration") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK_WITH_PRORATION - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK_WITH_PRORATION, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK_WITH_PRORATION -> Value.BULK_WITH_PRORATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - BULK_WITH_PRORATION -> Known.BULK_WITH_PRORATION - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - @NoAutoDetect - class BillingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleConfiguration = - BillingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, additionalProperties=$additionalProperties}" - } - - /** - * Within each billing cycle, specifies the cadence at which invoices are produced. - * If unspecified, a single invoice is produced per billing cycle. - */ - @NoAutoDetect - class InvoicingCycleConfiguration - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - private val duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - private val durationUnit: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The duration of the billing period. */ - fun duration(): Long = duration.getRequired("duration") - - /** The unit of billing period duration. */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** The duration of the billing period. */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** The unit of billing period duration. */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): InvoicingCycleConfiguration = apply { - if (validated) { - return@apply - } - - duration() - durationUnit() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvoicingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = apply { - duration = invoicingCycleConfiguration.duration - durationUnit = invoicingCycleConfiguration.durationUnit - additionalProperties = - invoicingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** The duration of the billing period. */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): InvoicingCycleConfiguration = - InvoicingCycleConfiguration( - checkRequired("duration", duration), - checkRequired("durationUnit", durationUnit), - additionalProperties.toImmutable(), - ) - } - - /** The unit of billing period duration. */ - class DurationUnit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DAY = of("day") - - @JvmField val MONTH = of("month") - - @JvmStatic fun of(value: String) = DurationUnit(JsonField.of(value)) - } - - /** An enum containing [DurationUnit]'s known values. */ - enum class Known { - DAY, - MONTH, - } - - /** - * An enum containing [DurationUnit]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [DurationUnit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - MONTH, - /** - * An enum member indicating that [DurationUnit] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - MONTH -> Value.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) { - DAY -> Known.DAY - MONTH -> Known.MONTH - else -> - throw OrbInvalidDataException("Unknown DurationUnit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if 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 - } - - return /* spotless:off */ other is DurationUnit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InvoicingCycleConfiguration && duration == other.duration && durationUnit == other.durationUnit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(duration, durationUnit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InvoicingCycleConfiguration{duration=$duration, durationUnit=$durationUnit, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is NewSubscriptionBulkWithProrationPrice && bulkWithProrationConfig == other.bulkWithProrationConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bulkWithProrationConfig, cadence, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, referenceId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NewSubscriptionBulkWithProrationPrice{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ReplacePrice && replacesPriceId == other.replacesPriceId && allocationPrice == other.allocationPrice && discounts == other.discounts && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && maximumAmount == other.maximumAmount && minimumAmount == other.minimumAmount && price == other.price && priceId == other.priceId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(replacesPriceId, allocationPrice, discounts, externalPriceId, fixedPriceQuantity, maximumAmount, minimumAmount, price, priceId, additionalProperties) } - /* spotless:on */ - - 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}" + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeResponse.kt deleted file mode 100644 index 39c24e8df..000000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeResponse.kt +++ /dev/null @@ -1,7173 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer -import com.withorb.api.core.Enum -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow -import com.withorb.api.core.immutableEmptyMap -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -@NoAutoDetect -class SubscriptionSchedulePlanChangeResponse -@JsonCreator -private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("active_plan_phase_order") - @ExcludeMissing - private val activePlanPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_intervals") - @ExcludeMissing - private val adjustmentIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("auto_collection") - @ExcludeMissing - private val autoCollection: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_anchor_configuration") - @ExcludeMissing - private val billingCycleAnchorConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("billing_cycle_day") - @ExcludeMissing - private val billingCycleDay: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - private val currentBillingPeriodEndDate: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - private val currentBillingPeriodStartDate: JsonField = JsonMissing.of(), - @JsonProperty("customer") - @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), - @JsonProperty("default_invoice_memo") - @ExcludeMissing - private val defaultInvoiceMemo: JsonField = JsonMissing.of(), - @JsonProperty("discount_intervals") - @ExcludeMissing - private val discountIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("fixed_fee_quantity_schedule") - @ExcludeMissing - private val fixedFeeQuantitySchedule: JsonField> = - JsonMissing.of(), - @JsonProperty("invoicing_threshold") - @ExcludeMissing - private val invoicingThreshold: JsonField = JsonMissing.of(), - @JsonProperty("maximum_intervals") - @ExcludeMissing - private val maximumIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("minimum_intervals") - @ExcludeMissing - private val minimumIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("net_terms") - @ExcludeMissing - private val netTerms: JsonField = JsonMissing.of(), - @JsonProperty("plan") @ExcludeMissing private val plan: JsonField = JsonMissing.of(), - @JsonProperty("price_intervals") - @ExcludeMissing - private val priceIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("redeemed_coupon") - @ExcludeMissing - private val redeemedCoupon: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonProperty("status") - @ExcludeMissing - private val status: JsonField = JsonMissing.of(), - @JsonProperty("trial_info") - @ExcludeMissing - private val trialInfo: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun id(): String = id.getRequired("id") - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(): Optional = - Optional.ofNullable(activePlanPhaseOrder.getNullable("active_plan_phase_order")) - - /** The adjustment intervals for this subscription. */ - fun adjustmentIntervals(): List = - adjustmentIntervals.getRequired("adjustment_intervals") - - /** - * Determines whether issued invoices for this subscription will automatically be charged with - * the saved payment method on the due date. This property defaults to the plan's behavior. If - * null, defaults to the customer's setting. - */ - fun autoCollection(): Optional = - Optional.ofNullable(autoCollection.getNullable("auto_collection")) - - fun billingCycleAnchorConfiguration(): BillingCycleAnchorConfiguration = - billingCycleAnchorConfiguration.getRequired("billing_cycle_anchor_configuration") - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of days in - * a month is greater than this value, the last day of the month is the billing cycle day (e.g. - * billing_cycle_day=31 for April means the billing period begins on the 30th. - */ - fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the instant - * returned is not part of the billing period. Set to null for subscriptions that are not - * currently active. - */ - fun currentBillingPeriodEndDate(): Optional = - Optional.ofNullable( - currentBillingPeriodEndDate.getNullable("current_billing_period_end_date") - ) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription is - * not currently active. - */ - fun currentBillingPeriodStartDate(): Optional = - Optional.ofNullable( - currentBillingPeriodStartDate.getNullable("current_billing_period_start_date") - ) - - /** - * 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 customer(): Customer = customer.getRequired("customer") - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(): Optional = - Optional.ofNullable(defaultInvoiceMemo.getNullable("default_invoice_memo")) - - /** The discount intervals for this subscription. */ - fun discountIntervals(): List = - discountIntervals.getRequired("discount_intervals") - - /** The date Orb stops billing for this subscription. */ - fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) - - fun fixedFeeQuantitySchedule(): List = - fixedFeeQuantitySchedule.getRequired("fixed_fee_quantity_schedule") - - fun invoicingThreshold(): Optional = - Optional.ofNullable(invoicingThreshold.getNullable("invoicing_threshold")) - - /** The maximum intervals for this subscription. */ - fun maximumIntervals(): List = - maximumIntervals.getRequired("maximum_intervals") - - /** - * 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.getRequired("metadata") - - /** The minimum intervals for this subscription. */ - fun minimumIntervals(): List = - minimumIntervals.getRequired("minimum_intervals") - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - fun netTerms(): Long = netTerms.getRequired("net_terms") - - /** - * 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 plan(): Plan = plan.getRequired("plan") - - /** The price intervals for this subscription. */ - fun priceIntervals(): List = priceIntervals.getRequired("price_intervals") - - fun redeemedCoupon(): Optional = - Optional.ofNullable(redeemedCoupon.getNullable("redeemed_coupon")) - - /** The date Orb starts billing for this subscription. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - fun status(): Status = status.getRequired("status") - - fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - @JsonProperty("active_plan_phase_order") - @ExcludeMissing - fun _activePlanPhaseOrder(): JsonField = activePlanPhaseOrder - - /** The adjustment intervals for this subscription. */ - @JsonProperty("adjustment_intervals") - @ExcludeMissing - fun _adjustmentIntervals(): JsonField> = adjustmentIntervals - - /** - * Determines whether issued invoices for this subscription will automatically be charged with - * the saved payment method on the due date. This property defaults to the plan's behavior. If - * null, defaults to the customer's setting. - */ - @JsonProperty("auto_collection") - @ExcludeMissing - fun _autoCollection(): JsonField = autoCollection - - @JsonProperty("billing_cycle_anchor_configuration") - @ExcludeMissing - fun _billingCycleAnchorConfiguration(): JsonField = - billingCycleAnchorConfiguration - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of days in - * a month is greater than this value, the last day of the month is the billing cycle day (e.g. - * billing_cycle_day=31 for April means the billing period begins on the 30th. - */ - @JsonProperty("billing_cycle_day") - @ExcludeMissing - fun _billingCycleDay(): JsonField = billingCycleDay - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the instant - * returned is not part of the billing period. Set to null for subscriptions that are not - * currently active. - */ - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription is - * not currently active. - */ - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - fun _currentBillingPeriodStartDate(): JsonField = currentBillingPeriodStartDate - - /** - * 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. - */ - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - @JsonProperty("default_invoice_memo") - @ExcludeMissing - fun _defaultInvoiceMemo(): JsonField = defaultInvoiceMemo - - /** The discount intervals for this subscription. */ - @JsonProperty("discount_intervals") - @ExcludeMissing - fun _discountIntervals(): JsonField> = discountIntervals - - /** The date Orb stops billing for this subscription. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate - - @JsonProperty("fixed_fee_quantity_schedule") - @ExcludeMissing - fun _fixedFeeQuantitySchedule(): JsonField> = - fixedFeeQuantitySchedule - - @JsonProperty("invoicing_threshold") - @ExcludeMissing - fun _invoicingThreshold(): JsonField = invoicingThreshold - - /** The maximum intervals for this subscription. */ - @JsonProperty("maximum_intervals") - @ExcludeMissing - fun _maximumIntervals(): JsonField> = maximumIntervals - - /** - * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - /** The minimum intervals for this subscription. */ - @JsonProperty("minimum_intervals") - @ExcludeMissing - fun _minimumIntervals(): JsonField> = minimumIntervals - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms - - /** - * 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). - */ - @JsonProperty("plan") @ExcludeMissing fun _plan(): JsonField = plan - - /** The price intervals for this subscription. */ - @JsonProperty("price_intervals") - @ExcludeMissing - fun _priceIntervals(): JsonField> = priceIntervals - - @JsonProperty("redeemed_coupon") - @ExcludeMissing - fun _redeemedCoupon(): JsonField = redeemedCoupon - - /** The date Orb starts billing for this subscription. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo(): JsonField = trialInfo - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): SubscriptionSchedulePlanChangeResponse = apply { - if (validated) { - return@apply - } - - id() - activePlanPhaseOrder() - adjustmentIntervals().forEach { it.validate() } - autoCollection() - billingCycleAnchorConfiguration().validate() - billingCycleDay() - createdAt() - currentBillingPeriodEndDate() - currentBillingPeriodStartDate() - customer().validate() - defaultInvoiceMemo() - discountIntervals().forEach { it.validate() } - endDate() - fixedFeeQuantitySchedule().forEach { it.validate() } - invoicingThreshold() - maximumIntervals().forEach { it.validate() } - metadata().validate() - minimumIntervals().forEach { it.validate() } - netTerms() - plan().validate() - priceIntervals().forEach { it.validate() } - redeemedCoupon().ifPresent { it.validate() } - startDate() - status() - trialInfo().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SubscriptionSchedulePlanChangeResponse]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var activePlanPhaseOrder: JsonField? = null - private var adjustmentIntervals: JsonField>? = null - private var autoCollection: JsonField? = null - private var billingCycleAnchorConfiguration: JsonField? = - null - private var billingCycleDay: JsonField? = null - private var createdAt: JsonField? = null - private var currentBillingPeriodEndDate: JsonField? = null - private var currentBillingPeriodStartDate: JsonField? = null - private var customer: JsonField? = null - private var defaultInvoiceMemo: JsonField? = null - private var discountIntervals: JsonField>? = null - private var endDate: JsonField? = null - private var fixedFeeQuantitySchedule: JsonField>? = - null - private var invoicingThreshold: JsonField? = null - private var maximumIntervals: JsonField>? = null - private var metadata: JsonField? = null - private var minimumIntervals: JsonField>? = null - private var netTerms: JsonField? = null - private var plan: JsonField? = null - private var priceIntervals: JsonField>? = null - private var redeemedCoupon: JsonField? = null - private var startDate: JsonField? = null - private var status: JsonField? = null - private var trialInfo: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - subscriptionSchedulePlanChangeResponse: SubscriptionSchedulePlanChangeResponse - ) = apply { - id = subscriptionSchedulePlanChangeResponse.id - activePlanPhaseOrder = subscriptionSchedulePlanChangeResponse.activePlanPhaseOrder - adjustmentIntervals = - subscriptionSchedulePlanChangeResponse.adjustmentIntervals.map { - it.toMutableList() - } - autoCollection = subscriptionSchedulePlanChangeResponse.autoCollection - billingCycleAnchorConfiguration = - subscriptionSchedulePlanChangeResponse.billingCycleAnchorConfiguration - billingCycleDay = subscriptionSchedulePlanChangeResponse.billingCycleDay - createdAt = subscriptionSchedulePlanChangeResponse.createdAt - currentBillingPeriodEndDate = - subscriptionSchedulePlanChangeResponse.currentBillingPeriodEndDate - currentBillingPeriodStartDate = - subscriptionSchedulePlanChangeResponse.currentBillingPeriodStartDate - customer = subscriptionSchedulePlanChangeResponse.customer - defaultInvoiceMemo = subscriptionSchedulePlanChangeResponse.defaultInvoiceMemo - discountIntervals = - subscriptionSchedulePlanChangeResponse.discountIntervals.map { it.toMutableList() } - endDate = subscriptionSchedulePlanChangeResponse.endDate - fixedFeeQuantitySchedule = - subscriptionSchedulePlanChangeResponse.fixedFeeQuantitySchedule.map { - it.toMutableList() - } - invoicingThreshold = subscriptionSchedulePlanChangeResponse.invoicingThreshold - maximumIntervals = - subscriptionSchedulePlanChangeResponse.maximumIntervals.map { it.toMutableList() } - metadata = subscriptionSchedulePlanChangeResponse.metadata - minimumIntervals = - subscriptionSchedulePlanChangeResponse.minimumIntervals.map { it.toMutableList() } - netTerms = subscriptionSchedulePlanChangeResponse.netTerms - plan = subscriptionSchedulePlanChangeResponse.plan - priceIntervals = - subscriptionSchedulePlanChangeResponse.priceIntervals.map { it.toMutableList() } - redeemedCoupon = subscriptionSchedulePlanChangeResponse.redeemedCoupon - startDate = subscriptionSchedulePlanChangeResponse.startDate - status = subscriptionSchedulePlanChangeResponse.status - trialInfo = subscriptionSchedulePlanChangeResponse.trialInfo - additionalProperties = - subscriptionSchedulePlanChangeResponse.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(activePlanPhaseOrder: Long?) = - activePlanPhaseOrder(JsonField.ofNullable(activePlanPhaseOrder)) - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(activePlanPhaseOrder: Long) = - activePlanPhaseOrder(activePlanPhaseOrder as Long?) - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun activePlanPhaseOrder(activePlanPhaseOrder: Optional) = - activePlanPhaseOrder(activePlanPhaseOrder.orElse(null) as Long?) - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(activePlanPhaseOrder: JsonField) = apply { - this.activePlanPhaseOrder = activePlanPhaseOrder - } - - /** The adjustment intervals for this subscription. */ - fun adjustmentIntervals(adjustmentIntervals: List) = - adjustmentIntervals(JsonField.of(adjustmentIntervals)) - - /** The adjustment intervals for this subscription. */ - fun adjustmentIntervals(adjustmentIntervals: JsonField>) = apply { - this.adjustmentIntervals = adjustmentIntervals.map { it.toMutableList() } - } - - /** The adjustment intervals for this subscription. */ - fun addAdjustmentInterval(adjustmentInterval: AdjustmentInterval) = apply { - adjustmentIntervals = - (adjustmentIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(adjustmentInterval) - } - } - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - fun autoCollection(autoCollection: Boolean?) = - autoCollection(JsonField.ofNullable(autoCollection)) - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun autoCollection(autoCollection: Optional) = - autoCollection(autoCollection.orElse(null) as Boolean?) - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - fun autoCollection(autoCollection: JsonField) = apply { - this.autoCollection = autoCollection - } - - fun billingCycleAnchorConfiguration( - billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration - ) = billingCycleAnchorConfiguration(JsonField.of(billingCycleAnchorConfiguration)) - - fun billingCycleAnchorConfiguration( - billingCycleAnchorConfiguration: JsonField - ) = apply { this.billingCycleAnchorConfiguration = billingCycleAnchorConfiguration } - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun billingCycleDay(billingCycleDay: Long) = billingCycleDay(JsonField.of(billingCycleDay)) - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun billingCycleDay(billingCycleDay: JsonField) = apply { - this.billingCycleDay = billingCycleDay - } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is not part of the billing period. Set to null for subscriptions that - * are not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = - currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is not part of the billing period. Set to null for subscriptions that - * are not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = - currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is not part of the billing period. Set to null for subscriptions that - * are not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: JsonField) = - apply { - this.currentBillingPeriodEndDate = currentBillingPeriodEndDate - } - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription - * is not currently active. - */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = - currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription - * is not currently active. - */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: Optional) = - currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription - * is not currently active. - */ - fun currentBillingPeriodStartDate( - currentBillingPeriodStartDate: JsonField - ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } - - /** - * 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 customer(customer: Customer) = customer(JsonField.of(customer)) - - /** - * 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 customer(customer: JsonField) = apply { this.customer = customer } - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(defaultInvoiceMemo: String?) = - defaultInvoiceMemo(JsonField.ofNullable(defaultInvoiceMemo)) - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(defaultInvoiceMemo: Optional) = - defaultInvoiceMemo(defaultInvoiceMemo.orElse(null)) - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(defaultInvoiceMemo: JsonField) = apply { - this.defaultInvoiceMemo = defaultInvoiceMemo - } - - /** The discount intervals for this subscription. */ - fun discountIntervals(discountIntervals: List) = - discountIntervals(JsonField.of(discountIntervals)) - - /** The discount intervals for this subscription. */ - fun discountIntervals(discountIntervals: JsonField>) = apply { - this.discountIntervals = discountIntervals.map { it.toMutableList() } - } - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(discountInterval: DiscountInterval) = apply { - discountIntervals = - (discountIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(discountInterval) - } - } - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(amount: DiscountInterval.AmountDiscountInterval) = - addDiscountInterval(DiscountInterval.ofAmount(amount)) - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(percentage: DiscountInterval.PercentageDiscountInterval) = - addDiscountInterval(DiscountInterval.ofPercentage(percentage)) - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(usage: DiscountInterval.UsageDiscountInterval) = - addDiscountInterval(DiscountInterval.ofUsage(usage)) - - /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - fun fixedFeeQuantitySchedule(fixedFeeQuantitySchedule: List) = - fixedFeeQuantitySchedule(JsonField.of(fixedFeeQuantitySchedule)) - - fun fixedFeeQuantitySchedule( - fixedFeeQuantitySchedule: JsonField> - ) = apply { - this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule.map { it.toMutableList() } - } - - fun addFixedFeeQuantitySchedule(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = - apply { - this.fixedFeeQuantitySchedule = - (this.fixedFeeQuantitySchedule ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(fixedFeeQuantitySchedule) - } - } - - fun invoicingThreshold(invoicingThreshold: String?) = - invoicingThreshold(JsonField.ofNullable(invoicingThreshold)) - - fun invoicingThreshold(invoicingThreshold: Optional) = - invoicingThreshold(invoicingThreshold.orElse(null)) - - fun invoicingThreshold(invoicingThreshold: JsonField) = apply { - this.invoicingThreshold = invoicingThreshold - } - - /** The maximum intervals for this subscription. */ - fun maximumIntervals(maximumIntervals: List) = - maximumIntervals(JsonField.of(maximumIntervals)) - - /** The maximum intervals for this subscription. */ - fun maximumIntervals(maximumIntervals: JsonField>) = apply { - this.maximumIntervals = maximumIntervals.map { it.toMutableList() } - } - - /** The maximum intervals for this subscription. */ - fun addMaximumInterval(maximumInterval: MaximumInterval) = apply { - maximumIntervals = - (maximumIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(maximumInterval) - } - } - - /** - * 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - /** The minimum intervals for this subscription. */ - fun minimumIntervals(minimumIntervals: List) = - minimumIntervals(JsonField.of(minimumIntervals)) - - /** The minimum intervals for this subscription. */ - fun minimumIntervals(minimumIntervals: JsonField>) = apply { - this.minimumIntervals = minimumIntervals.map { it.toMutableList() } - } - - /** The minimum intervals for this subscription. */ - fun addMinimumInterval(minimumInterval: MinimumInterval) = apply { - minimumIntervals = - (minimumIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(minimumInterval) - } - } - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - fun netTerms(netTerms: Long) = netTerms(JsonField.of(netTerms)) - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } - - /** - * 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 plan(plan: Plan) = plan(JsonField.of(plan)) - - /** - * 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 plan(plan: JsonField) = apply { this.plan = plan } - - /** The price intervals for this subscription. */ - fun priceIntervals(priceIntervals: List) = - priceIntervals(JsonField.of(priceIntervals)) - - /** The price intervals for this subscription. */ - fun priceIntervals(priceIntervals: JsonField>) = apply { - this.priceIntervals = priceIntervals.map { it.toMutableList() } - } - - /** The price intervals for this subscription. */ - fun addPriceInterval(priceInterval: PriceInterval) = apply { - priceIntervals = - (priceIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(priceInterval) - } - } - - fun redeemedCoupon(redeemedCoupon: RedeemedCoupon?) = - redeemedCoupon(JsonField.ofNullable(redeemedCoupon)) - - fun redeemedCoupon(redeemedCoupon: Optional) = - redeemedCoupon(redeemedCoupon.orElse(null)) - - fun redeemedCoupon(redeemedCoupon: JsonField) = apply { - this.redeemedCoupon = redeemedCoupon - } - - /** The date Orb starts billing for this subscription. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The date Orb starts billing for this subscription. */ - fun startDate(startDate: JsonField) = apply { this.startDate = startDate } - - fun status(status: Status) = status(JsonField.of(status)) - - fun status(status: JsonField) = apply { this.status = status } - - fun trialInfo(trialInfo: TrialInfo) = trialInfo(JsonField.of(trialInfo)) - - fun trialInfo(trialInfo: JsonField) = apply { this.trialInfo = trialInfo } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): SubscriptionSchedulePlanChangeResponse = - SubscriptionSchedulePlanChangeResponse( - checkRequired("id", id), - checkRequired("activePlanPhaseOrder", activePlanPhaseOrder), - checkRequired("adjustmentIntervals", adjustmentIntervals).map { it.toImmutable() }, - checkRequired("autoCollection", autoCollection), - checkRequired("billingCycleAnchorConfiguration", billingCycleAnchorConfiguration), - checkRequired("billingCycleDay", billingCycleDay), - checkRequired("createdAt", createdAt), - checkRequired("currentBillingPeriodEndDate", currentBillingPeriodEndDate), - checkRequired("currentBillingPeriodStartDate", currentBillingPeriodStartDate), - checkRequired("customer", customer), - checkRequired("defaultInvoiceMemo", defaultInvoiceMemo), - checkRequired("discountIntervals", discountIntervals).map { it.toImmutable() }, - checkRequired("endDate", endDate), - checkRequired("fixedFeeQuantitySchedule", fixedFeeQuantitySchedule).map { - it.toImmutable() - }, - checkRequired("invoicingThreshold", invoicingThreshold), - checkRequired("maximumIntervals", maximumIntervals).map { it.toImmutable() }, - checkRequired("metadata", metadata), - checkRequired("minimumIntervals", minimumIntervals).map { it.toImmutable() }, - checkRequired("netTerms", netTerms), - checkRequired("plan", plan), - checkRequired("priceIntervals", priceIntervals).map { it.toImmutable() }, - checkRequired("redeemedCoupon", redeemedCoupon), - checkRequired("startDate", startDate), - checkRequired("status", status), - checkRequired("trialInfo", trialInfo), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class AdjustmentInterval - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment") - @ExcludeMissing - private val adjustment: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") - - /** The price interval IDs that this adjustment applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - /** The end date of the adjustment interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** The start date of the adjustment interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment - - /** The price interval IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - /** The end date of the adjustment interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** The start date of the adjustment interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AdjustmentInterval = apply { - if (validated) { - return@apply - } - - id() - adjustment().validate() - appliesToPriceIntervalIds() - endDate() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AdjustmentInterval]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustment: JsonField? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(adjustmentInterval: AdjustmentInterval) = apply { - id = adjustmentInterval.id - adjustment = adjustmentInterval.adjustment - appliesToPriceIntervalIds = - adjustmentInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - endDate = adjustmentInterval.endDate - startDate = adjustmentInterval.startDate - additionalProperties = adjustmentInterval.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) - - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } - - fun adjustment(planPhaseUsageDiscount: Adjustment.PlanPhaseUsageDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)) - - fun adjustment(planPhaseAmountDiscount: Adjustment.PlanPhaseAmountDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)) - - fun adjustment( - planPhasePercentageDiscount: Adjustment.PlanPhasePercentageDiscountAdjustment - ) = adjustment(Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)) - - fun adjustment(planPhaseMinimum: Adjustment.PlanPhaseMinimumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)) - - fun adjustment(planPhaseMaximum: Adjustment.PlanPhaseMaximumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)) - - /** The price interval IDs that this adjustment applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval IDs that this adjustment applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval IDs that this adjustment applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - /** The end date of the adjustment interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the adjustment interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the adjustment interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** The start date of the adjustment interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the adjustment interval. */ - 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) - } - - fun build(): AdjustmentInterval = - AdjustmentInterval( - checkRequired("id", id), - checkRequired("adjustment", adjustment), - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment? = null, - private val planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment? = null, - private val planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment? = null, - private val planPhaseMinimum: PlanPhaseMinimumAdjustment? = null, - private val planPhaseMaximum: PlanPhaseMaximumAdjustment? = null, - private val _json: JsonValue? = null, - ) { - - fun planPhaseUsageDiscount(): Optional = - Optional.ofNullable(planPhaseUsageDiscount) - - fun planPhaseAmountDiscount(): Optional = - Optional.ofNullable(planPhaseAmountDiscount) - - fun planPhasePercentageDiscount(): Optional = - Optional.ofNullable(planPhasePercentageDiscount) - - fun planPhaseMinimum(): Optional = - Optional.ofNullable(planPhaseMinimum) - - fun planPhaseMaximum(): Optional = - Optional.ofNullable(planPhaseMaximum) - - fun isPlanPhaseUsageDiscount(): Boolean = planPhaseUsageDiscount != null - - fun isPlanPhaseAmountDiscount(): Boolean = planPhaseAmountDiscount != null - - fun isPlanPhasePercentageDiscount(): Boolean = planPhasePercentageDiscount != null - - fun isPlanPhaseMinimum(): Boolean = planPhaseMinimum != null - - fun isPlanPhaseMaximum(): Boolean = planPhaseMaximum != null - - fun asPlanPhaseUsageDiscount(): PlanPhaseUsageDiscountAdjustment = - planPhaseUsageDiscount.getOrThrow("planPhaseUsageDiscount") - - fun asPlanPhaseAmountDiscount(): PlanPhaseAmountDiscountAdjustment = - planPhaseAmountDiscount.getOrThrow("planPhaseAmountDiscount") - - fun asPlanPhasePercentageDiscount(): PlanPhasePercentageDiscountAdjustment = - planPhasePercentageDiscount.getOrThrow("planPhasePercentageDiscount") - - fun asPlanPhaseMinimum(): PlanPhaseMinimumAdjustment = - planPhaseMinimum.getOrThrow("planPhaseMinimum") - - fun asPlanPhaseMaximum(): PlanPhaseMaximumAdjustment = - planPhaseMaximum.getOrThrow("planPhaseMaximum") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - planPhaseUsageDiscount != null -> - visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) - planPhaseAmountDiscount != null -> - visitor.visitPlanPhaseAmountDiscount(planPhaseAmountDiscount) - planPhasePercentageDiscount != null -> - visitor.visitPlanPhasePercentageDiscount(planPhasePercentageDiscount) - planPhaseMinimum != null -> visitor.visitPlanPhaseMinimum(planPhaseMinimum) - planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) { - planPhaseUsageDiscount.validate() - } - - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) { - planPhaseAmountDiscount.validate() - } - - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) { - planPhasePercentageDiscount.validate() - } - - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) { - planPhaseMinimum.validate() - } - - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) { - planPhaseMaximum.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Adjustment && planPhaseUsageDiscount == other.planPhaseUsageDiscount && planPhaseAmountDiscount == other.planPhaseAmountDiscount && planPhasePercentageDiscount == other.planPhasePercentageDiscount && planPhaseMinimum == other.planPhaseMinimum && planPhaseMaximum == other.planPhaseMaximum /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(planPhaseUsageDiscount, planPhaseAmountDiscount, planPhasePercentageDiscount, planPhaseMinimum, planPhaseMaximum) /* spotless:on */ - - override fun toString(): String = - when { - planPhaseUsageDiscount != null -> - "Adjustment{planPhaseUsageDiscount=$planPhaseUsageDiscount}" - planPhaseAmountDiscount != null -> - "Adjustment{planPhaseAmountDiscount=$planPhaseAmountDiscount}" - planPhasePercentageDiscount != null -> - "Adjustment{planPhasePercentageDiscount=$planPhasePercentageDiscount}" - planPhaseMinimum != null -> "Adjustment{planPhaseMinimum=$planPhaseMinimum}" - planPhaseMaximum != null -> "Adjustment{planPhaseMaximum=$planPhaseMaximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } - - companion object { - - @JvmStatic - fun ofPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = Adjustment(planPhaseUsageDiscount = planPhaseUsageDiscount) - - @JvmStatic - fun ofPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = Adjustment(planPhaseAmountDiscount = planPhaseAmountDiscount) - - @JvmStatic - fun ofPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = Adjustment(planPhasePercentageDiscount = planPhasePercentageDiscount) - - @JvmStatic - fun ofPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment) = - Adjustment(planPhaseMinimum = planPhaseMinimum) - - @JvmStatic - fun ofPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment) = - Adjustment(planPhaseMaximum = planPhaseMaximum) - } - - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { - - fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ): T - - fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ): T - - fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ): T - - fun visitPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment): T - - fun visitPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment): T - - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } - - internal class Deserializer : BaseDeserializer(Adjustment::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = - json.asObject().getOrNull()?.get("adjustment_type")?.asString()?.getOrNull() - - when (adjustmentType) { - "usage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseUsageDiscount = it, _json = json) - } - } - "amount_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseAmountDiscount = it, _json = json) - } - } - "percentage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment( - planPhasePercentageDiscount = it, - _json = json, - ) - } - } - "minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMinimum = it, _json = json) - } - } - "maximum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMaximum = it, _json = json) - } - } - } - - return Adjustment(_json = json) - } - } - - internal class Serializer : BaseSerializer(Adjustment::class) { - - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.planPhaseUsageDiscount != null -> - generator.writeObject(value.planPhaseUsageDiscount) - value.planPhaseAmountDiscount != null -> - generator.writeObject(value.planPhaseAmountDiscount) - value.planPhasePercentageDiscount != null -> - generator.writeObject(value.planPhasePercentageDiscount) - value.planPhaseMinimum != null -> - generator.writeObject(value.planPhaseMinimum) - value.planPhaseMaximum != null -> - generator.writeObject(value.planPhaseMaximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") - } - } - } - - @NoAutoDetect - class PlanPhaseUsageDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonProperty("usage_discount") - @ExcludeMissing - private val usageDiscount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - /** - * The number of usage units by which to discount the price this adjustment applies - * to in a given billing period. - */ - fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - /** - * The number of usage units by which to discount the price this adjustment applies - * to in a given billing period. - */ - @JsonProperty("usage_discount") - @ExcludeMissing - fun _usageDiscount(): JsonField = usageDiscount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseUsageDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - planPhaseOrder() - reason() - usageDiscount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseUsageDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var usageDiscount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - planPhaseUsageDiscountAdjustment: PlanPhaseUsageDiscountAdjustment - ) = apply { - id = planPhaseUsageDiscountAdjustment.id - adjustmentType = planPhaseUsageDiscountAdjustment.adjustmentType - appliesToPriceIds = - planPhaseUsageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseUsageDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseUsageDiscountAdjustment.planPhaseOrder - reason = planPhaseUsageDiscountAdjustment.reason - usageDiscount = planPhaseUsageDiscountAdjustment.usageDiscount - additionalProperties = - planPhaseUsageDiscountAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - /** - * The number of usage units by which to discount the price this adjustment - * applies to in a given billing period. - */ - fun usageDiscount(usageDiscount: Double) = - usageDiscount(JsonField.of(usageDiscount)) - - /** - * The number of usage units by which to discount the price this adjustment - * applies to in a given billing period. - */ - fun usageDiscount(usageDiscount: JsonField) = apply { - this.usageDiscount = usageDiscount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseUsageDiscountAdjustment = - PlanPhaseUsageDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - checkRequired("usageDiscount", usageDiscount), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - USAGE_DISCOUNT -> Known.USAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseUsageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, planPhaseOrder, reason, usageDiscount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseUsageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhaseAmountDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("amount_discount") - @ExcludeMissing - private val amountDiscount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** - * The amount by which to discount the prices this adjustment applies to in a given - * billing period. - */ - fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** - * The amount by which to discount the prices this adjustment applies to in a given - * billing period. - */ - @JsonProperty("amount_discount") - @ExcludeMissing - fun _amountDiscount(): JsonField = amountDiscount - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseAmountDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - amountDiscount() - appliesToPriceIds() - isInvoiceLevel() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseAmountDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var amountDiscount: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - planPhaseAmountDiscountAdjustment: PlanPhaseAmountDiscountAdjustment - ) = apply { - id = planPhaseAmountDiscountAdjustment.id - adjustmentType = planPhaseAmountDiscountAdjustment.adjustmentType - amountDiscount = planPhaseAmountDiscountAdjustment.amountDiscount - appliesToPriceIds = - planPhaseAmountDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseAmountDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseAmountDiscountAdjustment.planPhaseOrder - reason = planPhaseAmountDiscountAdjustment.reason - additionalProperties = - planPhaseAmountDiscountAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** - * The amount by which to discount the prices this adjustment applies to in a - * given billing period. - */ - fun amountDiscount(amountDiscount: String) = - amountDiscount(JsonField.of(amountDiscount)) - - /** - * The amount by which to discount the prices this adjustment applies to in a - * given billing period. - */ - fun amountDiscount(amountDiscount: JsonField) = apply { - this.amountDiscount = amountDiscount - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseAmountDiscountAdjustment = - PlanPhaseAmountDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("amountDiscount", amountDiscount), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseAmountDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, amountDiscount, appliesToPriceIds, isInvoiceLevel, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseAmountDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhasePercentageDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("percentage_discount") - @ExcludeMissing - private val percentageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(): Double = - percentageDiscount.getRequired("percentage_discount") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - @JsonProperty("percentage_discount") - @ExcludeMissing - fun _percentageDiscount(): JsonField = percentageDiscount - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhasePercentageDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - percentageDiscount() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhasePercentageDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var percentageDiscount: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - planPhasePercentageDiscountAdjustment: PlanPhasePercentageDiscountAdjustment - ) = apply { - id = planPhasePercentageDiscountAdjustment.id - adjustmentType = planPhasePercentageDiscountAdjustment.adjustmentType - appliesToPriceIds = - planPhasePercentageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhasePercentageDiscountAdjustment.isInvoiceLevel - percentageDiscount = - planPhasePercentageDiscountAdjustment.percentageDiscount - planPhaseOrder = planPhasePercentageDiscountAdjustment.planPhaseOrder - reason = planPhasePercentageDiscountAdjustment.reason - additionalProperties = - planPhasePercentageDiscountAdjustment.additionalProperties - .toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(percentageDiscount: Double) = - percentageDiscount(JsonField.of(percentageDiscount)) - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(percentageDiscount: JsonField) = apply { - this.percentageDiscount = percentageDiscount - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhasePercentageDiscountAdjustment = - PlanPhasePercentageDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("percentageDiscount", percentageDiscount), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val PERCENTAGE_DISCOUNT = of("percentage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhasePercentageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, percentageDiscount, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhasePercentageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhaseMinimumAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(): String = itemId.getRequired("item_id") - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The item ID that revenue from this minimum will be attributed to. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseMinimumAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - itemId() - minimumAmount() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseMinimumAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var itemId: JsonField? = null - private var minimumAmount: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(planPhaseMinimumAdjustment: PlanPhaseMinimumAdjustment) = - apply { - id = planPhaseMinimumAdjustment.id - adjustmentType = planPhaseMinimumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMinimumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMinimumAdjustment.isInvoiceLevel - itemId = planPhaseMinimumAdjustment.itemId - minimumAmount = planPhaseMinimumAdjustment.minimumAmount - planPhaseOrder = planPhaseMinimumAdjustment.planPhaseOrder - reason = planPhaseMinimumAdjustment.reason - additionalProperties = - planPhaseMinimumAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseMinimumAdjustment = - PlanPhaseMinimumAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("itemId", itemId), - checkRequired("minimumAmount", minimumAmount), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseMinimumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, itemId, minimumAmount, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseMinimumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhaseMaximumAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseMaximumAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - maximumAmount() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseMaximumAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var maximumAmount: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(planPhaseMaximumAdjustment: PlanPhaseMaximumAdjustment) = - apply { - id = planPhaseMaximumAdjustment.id - adjustmentType = planPhaseMaximumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMaximumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMaximumAdjustment.isInvoiceLevel - maximumAmount = planPhaseMaximumAdjustment.maximumAmount - planPhaseOrder = planPhaseMaximumAdjustment.planPhaseOrder - reason = planPhaseMaximumAdjustment.reason - additionalProperties = - planPhaseMaximumAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseMaximumAdjustment = - PlanPhaseMaximumAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("maximumAmount", maximumAmount), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseMaximumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, maximumAmount, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseMaximumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentInterval && id == other.id && adjustment == other.adjustment && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustment, appliesToPriceIntervalIds, endDate, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AdjustmentInterval{id=$id, adjustment=$adjustment, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BillingCycleAnchorConfiguration - @JsonCreator - private constructor( - @JsonProperty("day") @ExcludeMissing private val day: JsonField = JsonMissing.of(), - @JsonProperty("month") - @ExcludeMissing - private val month: JsonField = JsonMissing.of(), - @JsonProperty("year") @ExcludeMissing private val year: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun day(): Long = day.getRequired("day") - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(): Optional = Optional.ofNullable(month.getNullable("month")) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on - * 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(): Optional = Optional.ofNullable(year.getNullable("year")) - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - @JsonProperty("day") @ExcludeMissing fun _day(): JsonField = day - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - @JsonProperty("month") @ExcludeMissing fun _month(): JsonField = month - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on - * 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - @JsonProperty("year") @ExcludeMissing fun _year(): JsonField = year - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleAnchorConfiguration = apply { - if (validated) { - return@apply - } - - day() - month() - year() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleAnchorConfiguration]. */ - class Builder internal constructor() { - - private var day: JsonField? = null - private var month: JsonField = JsonMissing.of() - private var year: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration) = - apply { - day = billingCycleAnchorConfiguration.day - month = billingCycleAnchorConfiguration.month - year = billingCycleAnchorConfiguration.year - additionalProperties = - billingCycleAnchorConfiguration.additionalProperties.toMutableMap() - } - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun day(day: Long) = day(JsonField.of(day)) - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun day(day: JsonField) = apply { this.day = day } - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(month: Long?) = month(JsonField.ofNullable(month)) - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(month: Long) = month(month as Long?) - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun month(month: Optional) = month(month.orElse(null) as Long?) - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(month: JsonField) = apply { this.month = month } - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(year: Long?) = year(JsonField.ofNullable(year)) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(year: Long) = year(year as Long?) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun year(year: Optional) = year(year.orElse(null) as Long?) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(year: JsonField) = apply { this.year = year } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleAnchorConfiguration = - BillingCycleAnchorConfiguration( - checkRequired("day", day), - month, - year, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleAnchorConfiguration && day == other.day && month == other.month && year == other.year && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(day, month, year, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleAnchorConfiguration{day=$day, month=$month, year=$year, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(using = DiscountInterval.Deserializer::class) - @JsonSerialize(using = DiscountInterval.Serializer::class) - class DiscountInterval - private constructor( - private val amount: AmountDiscountInterval? = null, - private val percentage: PercentageDiscountInterval? = null, - private val usage: UsageDiscountInterval? = null, - private val _json: JsonValue? = null, - ) { - - fun amount(): Optional = Optional.ofNullable(amount) - - fun percentage(): Optional = Optional.ofNullable(percentage) - - fun usage(): Optional = Optional.ofNullable(usage) - - fun isAmount(): Boolean = amount != null - - fun isPercentage(): Boolean = percentage != null - - fun isUsage(): Boolean = usage != null - - fun asAmount(): AmountDiscountInterval = amount.getOrThrow("amount") - - fun asPercentage(): PercentageDiscountInterval = percentage.getOrThrow("percentage") - - fun asUsage(): UsageDiscountInterval = usage.getOrThrow("usage") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - amount != null -> visitor.visitAmount(amount) - percentage != null -> visitor.visitPercentage(percentage) - usage != null -> visitor.visitUsage(usage) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): DiscountInterval = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitAmount(amount: AmountDiscountInterval) { - amount.validate() - } - - override fun visitPercentage(percentage: PercentageDiscountInterval) { - percentage.validate() - } - - override fun visitUsage(usage: UsageDiscountInterval) { - usage.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountInterval && amount == other.amount && percentage == other.percentage && usage == other.usage /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(amount, percentage, usage) /* spotless:on */ - - override fun toString(): String = - when { - amount != null -> "DiscountInterval{amount=$amount}" - percentage != null -> "DiscountInterval{percentage=$percentage}" - usage != null -> "DiscountInterval{usage=$usage}" - _json != null -> "DiscountInterval{_unknown=$_json}" - else -> throw IllegalStateException("Invalid DiscountInterval") - } - - companion object { - - @JvmStatic - fun ofAmount(amount: AmountDiscountInterval) = DiscountInterval(amount = amount) - - @JvmStatic - fun ofPercentage(percentage: PercentageDiscountInterval) = - DiscountInterval(percentage = percentage) - - @JvmStatic fun ofUsage(usage: UsageDiscountInterval) = DiscountInterval(usage = usage) - } - - /** - * An interface that defines how to map each variant of [DiscountInterval] to a value of - * type [T]. - */ - interface Visitor { - - fun visitAmount(amount: AmountDiscountInterval): T - - fun visitPercentage(percentage: PercentageDiscountInterval): T - - fun visitUsage(usage: UsageDiscountInterval): T - - /** - * Maps an unknown variant of [DiscountInterval] to a value of type [T]. - * - * An instance of [DiscountInterval] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown DiscountInterval: $json") - } - } - - internal class Deserializer : BaseDeserializer(DiscountInterval::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): DiscountInterval { - val json = JsonValue.fromJsonNode(node) - val discountType = - json.asObject().getOrNull()?.get("discount_type")?.asString()?.getOrNull() - - when (discountType) { - "amount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(amount = it, _json = json) - } - } - "percentage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(percentage = it, _json = json) - } - } - "usage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(usage = it, _json = json) - } - } - } - - return DiscountInterval(_json = json) - } - } - - internal class Serializer : BaseSerializer(DiscountInterval::class) { - - override fun serialize( - value: DiscountInterval, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.amount != null -> generator.writeObject(value.amount) - value.percentage != null -> generator.writeObject(value.percentage) - value.usage != null -> generator.writeObject(value.usage) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid DiscountInterval") - } - } - } - - @NoAutoDetect - class AmountDiscountInterval - @JsonCreator - private constructor( - @JsonProperty("amount_discount") - @ExcludeMissing - private val amountDiscount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("discount_type") - @ExcludeMissing - private val discountType: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - fun discountType(): DiscountType = discountType.getRequired("discount_type") - - /** The end date of the discount interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** The start date of the discount interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** Only available if discount_type is `amount`. */ - @JsonProperty("amount_discount") - @ExcludeMissing - fun _amountDiscount(): JsonField = amountDiscount - - /** The price ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - - /** The end date of the discount interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** The start date of the discount interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AmountDiscountInterval = apply { - if (validated) { - return@apply - } - - amountDiscount() - appliesToPriceIds() - appliesToPriceIntervalIds() - discountType() - endDate() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AmountDiscountInterval]. */ - class Builder internal constructor() { - - private var amountDiscount: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { - amountDiscount = amountDiscountInterval.amountDiscount - appliesToPriceIds = - amountDiscountInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - amountDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = amountDiscountInterval.discountType - endDate = amountDiscountInterval.endDate - startDate = amountDiscountInterval.startDate - additionalProperties = - amountDiscountInterval.additionalProperties.toMutableMap() - } - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(amountDiscount: String) = - amountDiscount(JsonField.of(amountDiscount)) - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(amountDiscount: JsonField) = apply { - this.amountDiscount = amountDiscount - } - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this discount interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this discount interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the discount interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the discount interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** The start date of the discount interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the discount interval. */ - 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) - } - - fun build(): AmountDiscountInterval = - AmountDiscountInterval( - checkRequired("amountDiscount", amountDiscount), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("discountType", discountType), - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val AMOUNT = of("amount") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - AMOUNT - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT -> Value.AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AMOUNT -> Known.AMOUNT - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AmountDiscountInterval && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amountDiscount, appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AmountDiscountInterval{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PercentageDiscountInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("discount_type") - @ExcludeMissing - private val discountType: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("percentage_discount") - @ExcludeMissing - private val percentageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - fun discountType(): DiscountType = discountType.getRequired("discount_type") - - /** The end date of the discount interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ - fun percentageDiscount(): Double = percentageDiscount.getRequired("percentage_discount") - - /** The start date of the discount interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** The price ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - - /** The end date of the discount interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ - @JsonProperty("percentage_discount") - @ExcludeMissing - fun _percentageDiscount(): JsonField = percentageDiscount - - /** The start date of the discount interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PercentageDiscountInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - discountType() - endDate() - percentageDiscount() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PercentageDiscountInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null - private var endDate: JsonField? = null - private var percentageDiscount: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { - appliesToPriceIds = - percentageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - percentageDiscountInterval.appliesToPriceIntervalIds.map { - it.toMutableList() - } - discountType = percentageDiscountInterval.discountType - endDate = percentageDiscountInterval.endDate - percentageDiscount = percentageDiscountInterval.percentageDiscount - startDate = percentageDiscountInterval.startDate - additionalProperties = - percentageDiscountInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this discount interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this discount interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the discount interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the discount interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** - * Only available if discount_type is `percentage`.This is a number between 0 and 1. - */ - fun percentageDiscount(percentageDiscount: Double) = - percentageDiscount(JsonField.of(percentageDiscount)) - - /** - * Only available if discount_type is `percentage`.This is a number between 0 and 1. - */ - fun percentageDiscount(percentageDiscount: JsonField) = apply { - this.percentageDiscount = percentageDiscount - } - - /** The start date of the discount interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the discount interval. */ - 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) - } - - fun build(): PercentageDiscountInterval = - PercentageDiscountInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("discountType", discountType), - checkRequired("endDate", endDate), - checkRequired("percentageDiscount", percentageDiscount), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val PERCENTAGE = of("percentage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - PERCENTAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE -> Value.PERCENTAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PERCENTAGE -> Known.PERCENTAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PercentageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, percentageDiscount, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PercentageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class UsageDiscountInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("discount_type") - @ExcludeMissing - private val discountType: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonProperty("usage_discount") - @ExcludeMissing - private val usageDiscount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - fun discountType(): DiscountType = discountType.getRequired("discount_type") - - /** The end date of the discount interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** The start date of the discount interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** - * Only available if discount_type is `usage`. Number of usage units that this discount - * is for - */ - fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - - /** The price ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - - /** The end date of the discount interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** The start date of the discount interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - /** - * Only available if discount_type is `usage`. Number of usage units that this discount - * is for - */ - @JsonProperty("usage_discount") - @ExcludeMissing - fun _usageDiscount(): JsonField = usageDiscount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): UsageDiscountInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - discountType() - endDate() - startDate() - usageDiscount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UsageDiscountInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var usageDiscount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { - appliesToPriceIds = - usageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - usageDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = usageDiscountInterval.discountType - endDate = usageDiscountInterval.endDate - startDate = usageDiscountInterval.startDate - usageDiscount = usageDiscountInterval.usageDiscount - additionalProperties = usageDiscountInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this discount interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this discount interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the discount interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the discount interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** The start date of the discount interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the discount interval. */ - fun startDate(startDate: JsonField) = apply { - this.startDate = startDate - } - - /** - * Only available if discount_type is `usage`. Number of usage units that this - * discount is for - */ - fun usageDiscount(usageDiscount: Double) = - usageDiscount(JsonField.of(usageDiscount)) - - /** - * Only available if discount_type is `usage`. Number of usage units that this - * discount is for - */ - fun usageDiscount(usageDiscount: JsonField) = apply { - this.usageDiscount = usageDiscount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): UsageDiscountInterval = - UsageDiscountInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("discountType", discountType), - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - checkRequired("usageDiscount", usageDiscount), - additionalProperties.toImmutable(), - ) - } - - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE = of("usage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - USAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE -> Value.USAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE -> Known.USAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UsageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, startDate, usageDiscount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UsageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" - } - } - - @NoAutoDetect - class FixedFeeQuantitySchedule - @JsonCreator - private constructor( - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("price_id") - @ExcludeMissing - private val priceId: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - private val quantity: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - fun priceId(): String = priceId.getRequired("price_id") - - fun quantity(): Double = quantity.getRequired("quantity") - - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - - @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): FixedFeeQuantitySchedule = apply { - if (validated) { - return@apply - } - - endDate() - priceId() - quantity() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FixedFeeQuantitySchedule]. */ - class Builder internal constructor() { - - private var endDate: JsonField? = null - private var priceId: JsonField? = null - private var quantity: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = apply { - endDate = fixedFeeQuantitySchedule.endDate - priceId = fixedFeeQuantitySchedule.priceId - quantity = fixedFeeQuantitySchedule.quantity - startDate = fixedFeeQuantitySchedule.startDate - additionalProperties = fixedFeeQuantitySchedule.additionalProperties.toMutableMap() - } - - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) - - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - 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) - } - - fun build(): FixedFeeQuantitySchedule = - FixedFeeQuantitySchedule( - checkRequired("endDate", endDate), - checkRequired("priceId", priceId), - checkRequired("quantity", quantity), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FixedFeeQuantitySchedule && endDate == other.endDate && priceId == other.priceId && quantity == other.quantity && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(endDate, priceId, quantity, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "FixedFeeQuantitySchedule{endDate=$endDate, priceId=$priceId, quantity=$quantity, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class MaximumInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this maximum interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this maximum interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - /** The end date of the maximum interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** The start date of the maximum interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** The price ids that this maximum interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this maximum interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - /** The end date of the maximum interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** The start date of the maximum interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MaximumInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - endDate() - maximumAmount() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MaximumInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var endDate: JsonField? = null - private var maximumAmount: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximumInterval: MaximumInterval) = apply { - appliesToPriceIds = maximumInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - maximumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - endDate = maximumInterval.endDate - maximumAmount = maximumInterval.maximumAmount - startDate = maximumInterval.startDate - additionalProperties = maximumInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this maximum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this maximum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this maximum interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this maximum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this maximum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this maximum interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - /** The end date of the maximum interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the maximum interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the maximum interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** The start date of the maximum interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the maximum interval. */ - 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) - } - - fun build(): MaximumInterval = - MaximumInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("endDate", endDate), - checkRequired("maximumAmount", maximumAmount), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MaximumInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && maximumAmount == other.maximumAmount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, endDate, maximumAmount, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MaximumInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, maximumAmount=$maximumAmount, startDate=$startDate, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class MinimumInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this minimum interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this minimum interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - /** The end date of the minimum interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** The start date of the minimum interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** The price ids that this minimum interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this minimum interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - /** The end date of the minimum interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** The start date of the minimum interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MinimumInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - endDate() - minimumAmount() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MinimumInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var endDate: JsonField? = null - private var minimumAmount: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(minimumInterval: MinimumInterval) = apply { - appliesToPriceIds = minimumInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - minimumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - endDate = minimumInterval.endDate - minimumAmount = minimumInterval.minimumAmount - startDate = minimumInterval.startDate - additionalProperties = minimumInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this minimum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this minimum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this minimum interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this minimum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this minimum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this minimum interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - /** The end date of the minimum interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the minimum interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the minimum interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** The start date of the minimum interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the minimum interval. */ - 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) - } - - fun build(): MinimumInterval = - MinimumInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("endDate", endDate), - checkRequired("minimumAmount", minimumAmount), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MinimumInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && minimumAmount == other.minimumAmount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, endDate, minimumAmount, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MinimumInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, minimumAmount=$minimumAmount, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - /** - * The Price Interval resource represents a period of time for which a price will bill on a - * subscription. A subscription’s price intervals define its billing behavior. - */ - @NoAutoDetect - class PriceInterval - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_day") - @ExcludeMissing - private val billingCycleDay: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - private val currentBillingPeriodEndDate: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - private val currentBillingPeriodStartDate: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("filter") - @ExcludeMissing - private val filter: JsonField = JsonMissing.of(), - @JsonProperty("fixed_fee_quantity_transitions") - @ExcludeMissing - private val fixedFeeQuantityTransitions: JsonField> = - JsonMissing.of(), - @JsonProperty("price") - @ExcludeMissing - private val price: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonProperty("usage_customer_ids") - @ExcludeMissing - private val usageCustomerIds: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - /** The day of the month that Orb bills for this price */ - fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate(): Optional = - Optional.ofNullable( - currentBillingPeriodEndDate.getNullable("current_billing_period_end_date") - ) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodStartDate(): Optional = - Optional.ofNullable( - currentBillingPeriodStartDate.getNullable("current_billing_period_start_date") - ) - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** An additional filter to apply to usage queries. */ - fun filter(): Optional = Optional.ofNullable(filter.getNullable("filter")) - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions(): Optional> = - Optional.ofNullable( - fixedFeeQuantityTransitions.getNullable("fixed_fee_quantity_transitions") - ) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting in - * a charge on an invoice in the form of an invoice line item. Prices take a quantity and - * determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the key - * for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(): Price = price.getRequired("price") - - /** - * The start date of the price interval. This is the date that Orb starts billing for this - * price. - */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this price - * interval. - */ - fun usageCustomerIds(): Optional> = - Optional.ofNullable(usageCustomerIds.getNullable("usage_customer_ids")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** The day of the month that Orb bills for this price */ - @JsonProperty("billing_cycle_day") - @ExcludeMissing - fun _billingCycleDay(): JsonField = billingCycleDay - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if this price - * interval is not currently active. - */ - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - fun _currentBillingPeriodStartDate(): JsonField = - currentBillingPeriodStartDate - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** An additional filter to apply to usage queries. */ - @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField = filter - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - @JsonProperty("fixed_fee_quantity_transitions") - @ExcludeMissing - fun _fixedFeeQuantityTransitions(): JsonField> = - fixedFeeQuantityTransitions - - /** - * 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) - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - - /** - * The start date of the price interval. This is the date that Orb starts billing for this - * price. - */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this price - * interval. - */ - @JsonProperty("usage_customer_ids") - @ExcludeMissing - fun _usageCustomerIds(): JsonField> = usageCustomerIds - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PriceInterval = apply { - if (validated) { - return@apply - } - - id() - billingCycleDay() - currentBillingPeriodEndDate() - currentBillingPeriodStartDate() - endDate() - filter() - fixedFeeQuantityTransitions().ifPresent { it.forEach { it.validate() } } - price().validate() - startDate() - usageCustomerIds() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PriceInterval]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var billingCycleDay: JsonField? = null - private var currentBillingPeriodEndDate: JsonField? = null - private var currentBillingPeriodStartDate: JsonField? = null - private var endDate: JsonField? = null - private var filter: JsonField? = null - private var fixedFeeQuantityTransitions: - JsonField>? = - null - private var price: JsonField? = null - private var startDate: JsonField? = null - private var usageCustomerIds: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(priceInterval: PriceInterval) = apply { - id = priceInterval.id - billingCycleDay = priceInterval.billingCycleDay - currentBillingPeriodEndDate = priceInterval.currentBillingPeriodEndDate - currentBillingPeriodStartDate = priceInterval.currentBillingPeriodStartDate - endDate = priceInterval.endDate - filter = priceInterval.filter - fixedFeeQuantityTransitions = - priceInterval.fixedFeeQuantityTransitions.map { it.toMutableList() } - price = priceInterval.price - startDate = priceInterval.startDate - usageCustomerIds = priceInterval.usageCustomerIds.map { it.toMutableList() } - additionalProperties = priceInterval.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - /** The day of the month that Orb bills for this price */ - fun billingCycleDay(billingCycleDay: Long) = - billingCycleDay(JsonField.of(billingCycleDay)) - - /** The day of the month that Orb bills for this price */ - fun billingCycleDay(billingCycleDay: JsonField) = apply { - this.billingCycleDay = billingCycleDay - } - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = - currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = - currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate( - currentBillingPeriodEndDate: JsonField - ) = apply { this.currentBillingPeriodEndDate = currentBillingPeriodEndDate } - - /** - * The start date of the current billing period. This is an inclusive timestamp; the - * instant returned is exactly the beginning of the billing period. Set to null if this - * price interval is not currently active. - */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = - currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the - * instant returned is exactly the beginning of the billing period. Set to null if this - * price interval is not currently active. - */ - fun currentBillingPeriodStartDate( - currentBillingPeriodStartDate: Optional - ) = currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the - * instant returned is exactly the beginning of the billing period. Set to null if this - * price interval is not currently active. - */ - fun currentBillingPeriodStartDate( - currentBillingPeriodStartDate: JsonField - ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** An additional filter to apply to usage queries. */ - fun filter(filter: String?) = filter(JsonField.ofNullable(filter)) - - /** An additional filter to apply to usage queries. */ - fun filter(filter: Optional) = filter(filter.orElse(null)) - - /** An additional filter to apply to usage queries. */ - fun filter(filter: JsonField) = apply { this.filter = filter } - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: List? - ) = fixedFeeQuantityTransitions(JsonField.ofNullable(fixedFeeQuantityTransitions)) - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: Optional> - ) = fixedFeeQuantityTransitions(fixedFeeQuantityTransitions.orElse(null)) - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: JsonField> - ) = apply { - this.fixedFeeQuantityTransitions = - fixedFeeQuantityTransitions.map { it.toMutableList() } - } - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun addFixedFeeQuantityTransition( - fixedFeeQuantityTransition: FixedFeeQuantityTransition - ) = apply { - fixedFeeQuantityTransitions = - (fixedFeeQuantityTransitions ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(fixedFeeQuantityTransition) - } - } - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(price: Price) = price(JsonField.of(price)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(price: JsonField) = apply { this.price = price } - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(matrix: Price.MatrixPrice) = price(Price.ofMatrix(matrix)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredPackage: Price.TieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedTiered: Price.GroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(unitWithPercent: Price.UnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredWithProration: Price.TieredWithProrationPrice) = - price(Price.ofTieredWithProration(tieredWithProration)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(unitWithProration: Price.UnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedAllocation: Price.GroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bulkWithProration: Price.BulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = - price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice) = - price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - - /** - * The start date of the price interval. This is the date that Orb starts billing for - * this price. - */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** - * The start date of the price interval. This is the date that Orb starts billing for - * this price. - */ - fun startDate(startDate: JsonField) = apply { - this.startDate = startDate - } - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun usageCustomerIds(usageCustomerIds: List?) = - usageCustomerIds(JsonField.ofNullable(usageCustomerIds)) - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun usageCustomerIds(usageCustomerIds: Optional>) = - usageCustomerIds(usageCustomerIds.orElse(null)) - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun usageCustomerIds(usageCustomerIds: JsonField>) = apply { - this.usageCustomerIds = usageCustomerIds.map { it.toMutableList() } - } - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun addUsageCustomerId(usageCustomerId: String) = apply { - usageCustomerIds = - (usageCustomerIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(usageCustomerId) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): PriceInterval = - PriceInterval( - checkRequired("id", id), - checkRequired("billingCycleDay", billingCycleDay), - checkRequired("currentBillingPeriodEndDate", currentBillingPeriodEndDate), - checkRequired("currentBillingPeriodStartDate", currentBillingPeriodStartDate), - checkRequired("endDate", endDate), - checkRequired("filter", filter), - checkRequired("fixedFeeQuantityTransitions", fixedFeeQuantityTransitions).map { - it.toImmutable() - }, - checkRequired("price", price), - checkRequired("startDate", startDate), - checkRequired("usageCustomerIds", usageCustomerIds).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class FixedFeeQuantityTransition - @JsonCreator - private constructor( - @JsonProperty("effective_date") - @ExcludeMissing - private val effectiveDate: JsonField = JsonMissing.of(), - @JsonProperty("price_id") - @ExcludeMissing - private val priceId: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - private val quantity: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun effectiveDate(): OffsetDateTime = effectiveDate.getRequired("effective_date") - - fun priceId(): String = priceId.getRequired("price_id") - - fun quantity(): Long = quantity.getRequired("quantity") - - @JsonProperty("effective_date") - @ExcludeMissing - fun _effectiveDate(): JsonField = effectiveDate - - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - - @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): FixedFeeQuantityTransition = apply { - if (validated) { - return@apply - } - - effectiveDate() - priceId() - quantity() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FixedFeeQuantityTransition]. */ - class Builder internal constructor() { - - private var effectiveDate: JsonField? = null - private var priceId: JsonField? = null - private var quantity: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(fixedFeeQuantityTransition: FixedFeeQuantityTransition) = apply { - effectiveDate = fixedFeeQuantityTransition.effectiveDate - priceId = fixedFeeQuantityTransition.priceId - quantity = fixedFeeQuantityTransition.quantity - additionalProperties = - fixedFeeQuantityTransition.additionalProperties.toMutableMap() - } - - fun effectiveDate(effectiveDate: OffsetDateTime) = - effectiveDate(JsonField.of(effectiveDate)) - - fun effectiveDate(effectiveDate: JsonField) = apply { - this.effectiveDate = effectiveDate - } - - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) - - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - - fun quantity(quantity: Long) = quantity(JsonField.of(quantity)) - - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): FixedFeeQuantityTransition = - FixedFeeQuantityTransition( - checkRequired("effectiveDate", effectiveDate), - checkRequired("priceId", priceId), - checkRequired("quantity", quantity), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FixedFeeQuantityTransition && effectiveDate == other.effectiveDate && priceId == other.priceId && quantity == other.quantity && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(effectiveDate, priceId, quantity, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "FixedFeeQuantityTransition{effectiveDate=$effectiveDate, priceId=$priceId, quantity=$quantity, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PriceInterval && id == other.id && billingCycleDay == other.billingCycleDay && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && endDate == other.endDate && filter == other.filter && fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && price == other.price && startDate == other.startDate && usageCustomerIds == other.usageCustomerIds && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billingCycleDay, currentBillingPeriodEndDate, currentBillingPeriodStartDate, endDate, filter, fixedFeeQuantityTransitions, price, startDate, usageCustomerIds, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PriceInterval{id=$id, billingCycleDay=$billingCycleDay, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, endDate=$endDate, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, price=$price, startDate=$startDate, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class RedeemedCoupon - @JsonCreator - private constructor( - @JsonProperty("coupon_id") - @ExcludeMissing - private val couponId: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun couponId(): String = couponId.getRequired("coupon_id") - - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - @JsonProperty("coupon_id") @ExcludeMissing fun _couponId(): JsonField = couponId - - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): RedeemedCoupon = apply { - if (validated) { - return@apply - } - - couponId() - endDate() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RedeemedCoupon]. */ - class Builder internal constructor() { - - private var couponId: JsonField? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(redeemedCoupon: RedeemedCoupon) = apply { - couponId = redeemedCoupon.couponId - endDate = redeemedCoupon.endDate - startDate = redeemedCoupon.startDate - additionalProperties = redeemedCoupon.additionalProperties.toMutableMap() - } - - fun couponId(couponId: String) = couponId(JsonField.of(couponId)) - - fun couponId(couponId: JsonField) = apply { this.couponId = couponId } - - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - 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) - } - - fun build(): RedeemedCoupon = - RedeemedCoupon( - checkRequired("couponId", couponId), - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RedeemedCoupon && couponId == other.couponId && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(couponId, endDate, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RedeemedCoupon{couponId=$couponId, endDate=$endDate, startDate=$startDate, 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 ENDED = of("ended") - - @JvmField val UPCOMING = of("upcoming") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - ACTIVE, - ENDED, - UPCOMING, - } - - /** - * 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, - ENDED, - UPCOMING, - /** 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 - ENDED -> Value.ENDED - UPCOMING -> Value.UPCOMING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to 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 - ENDED -> Known.ENDED - UPCOMING -> Known.UPCOMING - 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TrialInfo - @JsonCreator - private constructor( - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TrialInfo = apply { - if (validated) { - return@apply - } - - endDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TrialInfo]. */ - class Builder internal constructor() { - - private var endDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(trialInfo: TrialInfo) = apply { - endDate = trialInfo.endDate - additionalProperties = trialInfo.additionalProperties.toMutableMap() - } - - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - 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) - } - - fun build(): TrialInfo = - TrialInfo(checkRequired("endDate", endDate), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TrialInfo && endDate == other.endDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(endDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TrialInfo{endDate=$endDate, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is SubscriptionSchedulePlanChangeResponse && id == other.id && activePlanPhaseOrder == other.activePlanPhaseOrder && adjustmentIntervals == other.adjustmentIntervals && autoCollection == other.autoCollection && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && billingCycleDay == other.billingCycleDay && createdAt == other.createdAt && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && customer == other.customer && defaultInvoiceMemo == other.defaultInvoiceMemo && discountIntervals == other.discountIntervals && endDate == other.endDate && fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && invoicingThreshold == other.invoicingThreshold && maximumIntervals == other.maximumIntervals && metadata == other.metadata && minimumIntervals == other.minimumIntervals && netTerms == other.netTerms && plan == other.plan && priceIntervals == other.priceIntervals && redeemedCoupon == other.redeemedCoupon && startDate == other.startDate && status == other.status && trialInfo == other.trialInfo && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, activePlanPhaseOrder, adjustmentIntervals, autoCollection, billingCycleAnchorConfiguration, billingCycleDay, createdAt, currentBillingPeriodEndDate, currentBillingPeriodStartDate, customer, defaultInvoiceMemo, discountIntervals, endDate, fixedFeeQuantitySchedule, invoicingThreshold, maximumIntervals, metadata, minimumIntervals, netTerms, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SubscriptionSchedulePlanChangeResponse{id=$id, activePlanPhaseOrder=$activePlanPhaseOrder, adjustmentIntervals=$adjustmentIntervals, autoCollection=$autoCollection, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, billingCycleDay=$billingCycleDay, createdAt=$createdAt, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, customer=$customer, defaultInvoiceMemo=$defaultInvoiceMemo, discountIntervals=$discountIntervals, endDate=$endDate, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, invoicingThreshold=$invoicingThreshold, maximumIntervals=$maximumIntervals, metadata=$metadata, minimumIntervals=$minimumIntervals, netTerms=$netTerms, plan=$plan, priceIntervals=$priceIntervals, redeemedCoupon=$redeemedCoupon, startDate=$startDate, status=$status, trialInfo=$trialInfo, additionalProperties=$additionalProperties}" -} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTrialInfoModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTrialInfoModel.kt new file mode 100644 index 000000000..322fed6cb --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTrialInfoModel.kt @@ -0,0 +1,125 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class SubscriptionTrialInfoModel +@JsonCreator +private constructor( + @JsonProperty("end_date") + @ExcludeMissing + private val endDate: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) + + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): SubscriptionTrialInfoModel = apply { + if (validated) { + return@apply + } + + endDate() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SubscriptionTrialInfoModel]. + * + * The following fields are required: + * ```java + * .endDate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SubscriptionTrialInfoModel]. */ + class Builder internal constructor() { + + private var endDate: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(subscriptionTrialInfoModel: SubscriptionTrialInfoModel) = apply { + endDate = subscriptionTrialInfoModel.endDate + additionalProperties = subscriptionTrialInfoModel.additionalProperties.toMutableMap() + } + + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) + + 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) + } + + fun build(): SubscriptionTrialInfoModel = + SubscriptionTrialInfoModel( + checkRequired("endDate", endDate), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SubscriptionTrialInfoModel && endDate == other.endDate && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(endDate, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SubscriptionTrialInfoModel{endDate=$endDate, additionalProperties=$additionalProperties}" +} 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 7907d22fd..476d9af4b 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 @@ -145,6 +145,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Body]. */ @JvmStatic fun builder() = Builder() } @@ -263,6 +264,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [SubscriptionTriggerPhaseParams]. + * + * The following fields are required: + * ```java + * .subscriptionId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseResponse.kt deleted file mode 100644 index 186ec4c45..000000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseResponse.kt +++ /dev/null @@ -1,7170 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer -import com.withorb.api.core.Enum -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow -import com.withorb.api.core.immutableEmptyMap -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -@NoAutoDetect -class SubscriptionTriggerPhaseResponse -@JsonCreator -private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("active_plan_phase_order") - @ExcludeMissing - private val activePlanPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_intervals") - @ExcludeMissing - private val adjustmentIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("auto_collection") - @ExcludeMissing - private val autoCollection: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_anchor_configuration") - @ExcludeMissing - private val billingCycleAnchorConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("billing_cycle_day") - @ExcludeMissing - private val billingCycleDay: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - private val currentBillingPeriodEndDate: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - private val currentBillingPeriodStartDate: JsonField = JsonMissing.of(), - @JsonProperty("customer") - @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), - @JsonProperty("default_invoice_memo") - @ExcludeMissing - private val defaultInvoiceMemo: JsonField = JsonMissing.of(), - @JsonProperty("discount_intervals") - @ExcludeMissing - private val discountIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("fixed_fee_quantity_schedule") - @ExcludeMissing - private val fixedFeeQuantitySchedule: JsonField> = - JsonMissing.of(), - @JsonProperty("invoicing_threshold") - @ExcludeMissing - private val invoicingThreshold: JsonField = JsonMissing.of(), - @JsonProperty("maximum_intervals") - @ExcludeMissing - private val maximumIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("minimum_intervals") - @ExcludeMissing - private val minimumIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("net_terms") - @ExcludeMissing - private val netTerms: JsonField = JsonMissing.of(), - @JsonProperty("plan") @ExcludeMissing private val plan: JsonField = JsonMissing.of(), - @JsonProperty("price_intervals") - @ExcludeMissing - private val priceIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("redeemed_coupon") - @ExcludeMissing - private val redeemedCoupon: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonProperty("status") - @ExcludeMissing - private val status: JsonField = JsonMissing.of(), - @JsonProperty("trial_info") - @ExcludeMissing - private val trialInfo: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun id(): String = id.getRequired("id") - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(): Optional = - Optional.ofNullable(activePlanPhaseOrder.getNullable("active_plan_phase_order")) - - /** The adjustment intervals for this subscription. */ - fun adjustmentIntervals(): List = - adjustmentIntervals.getRequired("adjustment_intervals") - - /** - * Determines whether issued invoices for this subscription will automatically be charged with - * the saved payment method on the due date. This property defaults to the plan's behavior. If - * null, defaults to the customer's setting. - */ - fun autoCollection(): Optional = - Optional.ofNullable(autoCollection.getNullable("auto_collection")) - - fun billingCycleAnchorConfiguration(): BillingCycleAnchorConfiguration = - billingCycleAnchorConfiguration.getRequired("billing_cycle_anchor_configuration") - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of days in - * a month is greater than this value, the last day of the month is the billing cycle day (e.g. - * billing_cycle_day=31 for April means the billing period begins on the 30th. - */ - fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the instant - * returned is not part of the billing period. Set to null for subscriptions that are not - * currently active. - */ - fun currentBillingPeriodEndDate(): Optional = - Optional.ofNullable( - currentBillingPeriodEndDate.getNullable("current_billing_period_end_date") - ) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription is - * not currently active. - */ - fun currentBillingPeriodStartDate(): Optional = - Optional.ofNullable( - currentBillingPeriodStartDate.getNullable("current_billing_period_start_date") - ) - - /** - * 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 customer(): Customer = customer.getRequired("customer") - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(): Optional = - Optional.ofNullable(defaultInvoiceMemo.getNullable("default_invoice_memo")) - - /** The discount intervals for this subscription. */ - fun discountIntervals(): List = - discountIntervals.getRequired("discount_intervals") - - /** The date Orb stops billing for this subscription. */ - fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) - - fun fixedFeeQuantitySchedule(): List = - fixedFeeQuantitySchedule.getRequired("fixed_fee_quantity_schedule") - - fun invoicingThreshold(): Optional = - Optional.ofNullable(invoicingThreshold.getNullable("invoicing_threshold")) - - /** The maximum intervals for this subscription. */ - fun maximumIntervals(): List = - maximumIntervals.getRequired("maximum_intervals") - - /** - * 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.getRequired("metadata") - - /** The minimum intervals for this subscription. */ - fun minimumIntervals(): List = - minimumIntervals.getRequired("minimum_intervals") - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - fun netTerms(): Long = netTerms.getRequired("net_terms") - - /** - * 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 plan(): Plan = plan.getRequired("plan") - - /** The price intervals for this subscription. */ - fun priceIntervals(): List = priceIntervals.getRequired("price_intervals") - - fun redeemedCoupon(): Optional = - Optional.ofNullable(redeemedCoupon.getNullable("redeemed_coupon")) - - /** The date Orb starts billing for this subscription. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - fun status(): Status = status.getRequired("status") - - fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - @JsonProperty("active_plan_phase_order") - @ExcludeMissing - fun _activePlanPhaseOrder(): JsonField = activePlanPhaseOrder - - /** The adjustment intervals for this subscription. */ - @JsonProperty("adjustment_intervals") - @ExcludeMissing - fun _adjustmentIntervals(): JsonField> = adjustmentIntervals - - /** - * Determines whether issued invoices for this subscription will automatically be charged with - * the saved payment method on the due date. This property defaults to the plan's behavior. If - * null, defaults to the customer's setting. - */ - @JsonProperty("auto_collection") - @ExcludeMissing - fun _autoCollection(): JsonField = autoCollection - - @JsonProperty("billing_cycle_anchor_configuration") - @ExcludeMissing - fun _billingCycleAnchorConfiguration(): JsonField = - billingCycleAnchorConfiguration - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of days in - * a month is greater than this value, the last day of the month is the billing cycle day (e.g. - * billing_cycle_day=31 for April means the billing period begins on the 30th. - */ - @JsonProperty("billing_cycle_day") - @ExcludeMissing - fun _billingCycleDay(): JsonField = billingCycleDay - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the instant - * returned is not part of the billing period. Set to null for subscriptions that are not - * currently active. - */ - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription is - * not currently active. - */ - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - fun _currentBillingPeriodStartDate(): JsonField = currentBillingPeriodStartDate - - /** - * 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. - */ - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - @JsonProperty("default_invoice_memo") - @ExcludeMissing - fun _defaultInvoiceMemo(): JsonField = defaultInvoiceMemo - - /** The discount intervals for this subscription. */ - @JsonProperty("discount_intervals") - @ExcludeMissing - fun _discountIntervals(): JsonField> = discountIntervals - - /** The date Orb stops billing for this subscription. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate - - @JsonProperty("fixed_fee_quantity_schedule") - @ExcludeMissing - fun _fixedFeeQuantitySchedule(): JsonField> = - fixedFeeQuantitySchedule - - @JsonProperty("invoicing_threshold") - @ExcludeMissing - fun _invoicingThreshold(): JsonField = invoicingThreshold - - /** The maximum intervals for this subscription. */ - @JsonProperty("maximum_intervals") - @ExcludeMissing - fun _maximumIntervals(): JsonField> = maximumIntervals - - /** - * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - /** The minimum intervals for this subscription. */ - @JsonProperty("minimum_intervals") - @ExcludeMissing - fun _minimumIntervals(): JsonField> = minimumIntervals - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms - - /** - * 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). - */ - @JsonProperty("plan") @ExcludeMissing fun _plan(): JsonField = plan - - /** The price intervals for this subscription. */ - @JsonProperty("price_intervals") - @ExcludeMissing - fun _priceIntervals(): JsonField> = priceIntervals - - @JsonProperty("redeemed_coupon") - @ExcludeMissing - fun _redeemedCoupon(): JsonField = redeemedCoupon - - /** The date Orb starts billing for this subscription. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo(): JsonField = trialInfo - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): SubscriptionTriggerPhaseResponse = apply { - if (validated) { - return@apply - } - - id() - activePlanPhaseOrder() - adjustmentIntervals().forEach { it.validate() } - autoCollection() - billingCycleAnchorConfiguration().validate() - billingCycleDay() - createdAt() - currentBillingPeriodEndDate() - currentBillingPeriodStartDate() - customer().validate() - defaultInvoiceMemo() - discountIntervals().forEach { it.validate() } - endDate() - fixedFeeQuantitySchedule().forEach { it.validate() } - invoicingThreshold() - maximumIntervals().forEach { it.validate() } - metadata().validate() - minimumIntervals().forEach { it.validate() } - netTerms() - plan().validate() - priceIntervals().forEach { it.validate() } - redeemedCoupon().ifPresent { it.validate() } - startDate() - status() - trialInfo().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SubscriptionTriggerPhaseResponse]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var activePlanPhaseOrder: JsonField? = null - private var adjustmentIntervals: JsonField>? = null - private var autoCollection: JsonField? = null - private var billingCycleAnchorConfiguration: JsonField? = - null - private var billingCycleDay: JsonField? = null - private var createdAt: JsonField? = null - private var currentBillingPeriodEndDate: JsonField? = null - private var currentBillingPeriodStartDate: JsonField? = null - private var customer: JsonField? = null - private var defaultInvoiceMemo: JsonField? = null - private var discountIntervals: JsonField>? = null - private var endDate: JsonField? = null - private var fixedFeeQuantitySchedule: JsonField>? = - null - private var invoicingThreshold: JsonField? = null - private var maximumIntervals: JsonField>? = null - private var metadata: JsonField? = null - private var minimumIntervals: JsonField>? = null - private var netTerms: JsonField? = null - private var plan: JsonField? = null - private var priceIntervals: JsonField>? = null - private var redeemedCoupon: JsonField? = null - private var startDate: JsonField? = null - private var status: JsonField? = null - private var trialInfo: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(subscriptionTriggerPhaseResponse: SubscriptionTriggerPhaseResponse) = - apply { - id = subscriptionTriggerPhaseResponse.id - activePlanPhaseOrder = subscriptionTriggerPhaseResponse.activePlanPhaseOrder - adjustmentIntervals = - subscriptionTriggerPhaseResponse.adjustmentIntervals.map { it.toMutableList() } - autoCollection = subscriptionTriggerPhaseResponse.autoCollection - billingCycleAnchorConfiguration = - subscriptionTriggerPhaseResponse.billingCycleAnchorConfiguration - billingCycleDay = subscriptionTriggerPhaseResponse.billingCycleDay - createdAt = subscriptionTriggerPhaseResponse.createdAt - currentBillingPeriodEndDate = - subscriptionTriggerPhaseResponse.currentBillingPeriodEndDate - currentBillingPeriodStartDate = - subscriptionTriggerPhaseResponse.currentBillingPeriodStartDate - customer = subscriptionTriggerPhaseResponse.customer - defaultInvoiceMemo = subscriptionTriggerPhaseResponse.defaultInvoiceMemo - discountIntervals = - subscriptionTriggerPhaseResponse.discountIntervals.map { it.toMutableList() } - endDate = subscriptionTriggerPhaseResponse.endDate - fixedFeeQuantitySchedule = - subscriptionTriggerPhaseResponse.fixedFeeQuantitySchedule.map { - it.toMutableList() - } - invoicingThreshold = subscriptionTriggerPhaseResponse.invoicingThreshold - maximumIntervals = - subscriptionTriggerPhaseResponse.maximumIntervals.map { it.toMutableList() } - metadata = subscriptionTriggerPhaseResponse.metadata - minimumIntervals = - subscriptionTriggerPhaseResponse.minimumIntervals.map { it.toMutableList() } - netTerms = subscriptionTriggerPhaseResponse.netTerms - plan = subscriptionTriggerPhaseResponse.plan - priceIntervals = - subscriptionTriggerPhaseResponse.priceIntervals.map { it.toMutableList() } - redeemedCoupon = subscriptionTriggerPhaseResponse.redeemedCoupon - startDate = subscriptionTriggerPhaseResponse.startDate - status = subscriptionTriggerPhaseResponse.status - trialInfo = subscriptionTriggerPhaseResponse.trialInfo - additionalProperties = - subscriptionTriggerPhaseResponse.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(activePlanPhaseOrder: Long?) = - activePlanPhaseOrder(JsonField.ofNullable(activePlanPhaseOrder)) - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(activePlanPhaseOrder: Long) = - activePlanPhaseOrder(activePlanPhaseOrder as Long?) - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun activePlanPhaseOrder(activePlanPhaseOrder: Optional) = - activePlanPhaseOrder(activePlanPhaseOrder.orElse(null) as Long?) - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(activePlanPhaseOrder: JsonField) = apply { - this.activePlanPhaseOrder = activePlanPhaseOrder - } - - /** The adjustment intervals for this subscription. */ - fun adjustmentIntervals(adjustmentIntervals: List) = - adjustmentIntervals(JsonField.of(adjustmentIntervals)) - - /** The adjustment intervals for this subscription. */ - fun adjustmentIntervals(adjustmentIntervals: JsonField>) = apply { - this.adjustmentIntervals = adjustmentIntervals.map { it.toMutableList() } - } - - /** The adjustment intervals for this subscription. */ - fun addAdjustmentInterval(adjustmentInterval: AdjustmentInterval) = apply { - adjustmentIntervals = - (adjustmentIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(adjustmentInterval) - } - } - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - fun autoCollection(autoCollection: Boolean?) = - autoCollection(JsonField.ofNullable(autoCollection)) - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun autoCollection(autoCollection: Optional) = - autoCollection(autoCollection.orElse(null) as Boolean?) - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - fun autoCollection(autoCollection: JsonField) = apply { - this.autoCollection = autoCollection - } - - fun billingCycleAnchorConfiguration( - billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration - ) = billingCycleAnchorConfiguration(JsonField.of(billingCycleAnchorConfiguration)) - - fun billingCycleAnchorConfiguration( - billingCycleAnchorConfiguration: JsonField - ) = apply { this.billingCycleAnchorConfiguration = billingCycleAnchorConfiguration } - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun billingCycleDay(billingCycleDay: Long) = billingCycleDay(JsonField.of(billingCycleDay)) - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun billingCycleDay(billingCycleDay: JsonField) = apply { - this.billingCycleDay = billingCycleDay - } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is not part of the billing period. Set to null for subscriptions that - * are not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = - currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is not part of the billing period. Set to null for subscriptions that - * are not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = - currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is not part of the billing period. Set to null for subscriptions that - * are not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: JsonField) = - apply { - this.currentBillingPeriodEndDate = currentBillingPeriodEndDate - } - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription - * is not currently active. - */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = - currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription - * is not currently active. - */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: Optional) = - currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription - * is not currently active. - */ - fun currentBillingPeriodStartDate( - currentBillingPeriodStartDate: JsonField - ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } - - /** - * 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 customer(customer: Customer) = customer(JsonField.of(customer)) - - /** - * 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 customer(customer: JsonField) = apply { this.customer = customer } - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(defaultInvoiceMemo: String?) = - defaultInvoiceMemo(JsonField.ofNullable(defaultInvoiceMemo)) - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(defaultInvoiceMemo: Optional) = - defaultInvoiceMemo(defaultInvoiceMemo.orElse(null)) - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(defaultInvoiceMemo: JsonField) = apply { - this.defaultInvoiceMemo = defaultInvoiceMemo - } - - /** The discount intervals for this subscription. */ - fun discountIntervals(discountIntervals: List) = - discountIntervals(JsonField.of(discountIntervals)) - - /** The discount intervals for this subscription. */ - fun discountIntervals(discountIntervals: JsonField>) = apply { - this.discountIntervals = discountIntervals.map { it.toMutableList() } - } - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(discountInterval: DiscountInterval) = apply { - discountIntervals = - (discountIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(discountInterval) - } - } - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(amount: DiscountInterval.AmountDiscountInterval) = - addDiscountInterval(DiscountInterval.ofAmount(amount)) - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(percentage: DiscountInterval.PercentageDiscountInterval) = - addDiscountInterval(DiscountInterval.ofPercentage(percentage)) - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(usage: DiscountInterval.UsageDiscountInterval) = - addDiscountInterval(DiscountInterval.ofUsage(usage)) - - /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - fun fixedFeeQuantitySchedule(fixedFeeQuantitySchedule: List) = - fixedFeeQuantitySchedule(JsonField.of(fixedFeeQuantitySchedule)) - - fun fixedFeeQuantitySchedule( - fixedFeeQuantitySchedule: JsonField> - ) = apply { - this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule.map { it.toMutableList() } - } - - fun addFixedFeeQuantitySchedule(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = - apply { - this.fixedFeeQuantitySchedule = - (this.fixedFeeQuantitySchedule ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(fixedFeeQuantitySchedule) - } - } - - fun invoicingThreshold(invoicingThreshold: String?) = - invoicingThreshold(JsonField.ofNullable(invoicingThreshold)) - - fun invoicingThreshold(invoicingThreshold: Optional) = - invoicingThreshold(invoicingThreshold.orElse(null)) - - fun invoicingThreshold(invoicingThreshold: JsonField) = apply { - this.invoicingThreshold = invoicingThreshold - } - - /** The maximum intervals for this subscription. */ - fun maximumIntervals(maximumIntervals: List) = - maximumIntervals(JsonField.of(maximumIntervals)) - - /** The maximum intervals for this subscription. */ - fun maximumIntervals(maximumIntervals: JsonField>) = apply { - this.maximumIntervals = maximumIntervals.map { it.toMutableList() } - } - - /** The maximum intervals for this subscription. */ - fun addMaximumInterval(maximumInterval: MaximumInterval) = apply { - maximumIntervals = - (maximumIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(maximumInterval) - } - } - - /** - * 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - /** The minimum intervals for this subscription. */ - fun minimumIntervals(minimumIntervals: List) = - minimumIntervals(JsonField.of(minimumIntervals)) - - /** The minimum intervals for this subscription. */ - fun minimumIntervals(minimumIntervals: JsonField>) = apply { - this.minimumIntervals = minimumIntervals.map { it.toMutableList() } - } - - /** The minimum intervals for this subscription. */ - fun addMinimumInterval(minimumInterval: MinimumInterval) = apply { - minimumIntervals = - (minimumIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(minimumInterval) - } - } - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - fun netTerms(netTerms: Long) = netTerms(JsonField.of(netTerms)) - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } - - /** - * 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 plan(plan: Plan) = plan(JsonField.of(plan)) - - /** - * 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 plan(plan: JsonField) = apply { this.plan = plan } - - /** The price intervals for this subscription. */ - fun priceIntervals(priceIntervals: List) = - priceIntervals(JsonField.of(priceIntervals)) - - /** The price intervals for this subscription. */ - fun priceIntervals(priceIntervals: JsonField>) = apply { - this.priceIntervals = priceIntervals.map { it.toMutableList() } - } - - /** The price intervals for this subscription. */ - fun addPriceInterval(priceInterval: PriceInterval) = apply { - priceIntervals = - (priceIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(priceInterval) - } - } - - fun redeemedCoupon(redeemedCoupon: RedeemedCoupon?) = - redeemedCoupon(JsonField.ofNullable(redeemedCoupon)) - - fun redeemedCoupon(redeemedCoupon: Optional) = - redeemedCoupon(redeemedCoupon.orElse(null)) - - fun redeemedCoupon(redeemedCoupon: JsonField) = apply { - this.redeemedCoupon = redeemedCoupon - } - - /** The date Orb starts billing for this subscription. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The date Orb starts billing for this subscription. */ - fun startDate(startDate: JsonField) = apply { this.startDate = startDate } - - fun status(status: Status) = status(JsonField.of(status)) - - fun status(status: JsonField) = apply { this.status = status } - - fun trialInfo(trialInfo: TrialInfo) = trialInfo(JsonField.of(trialInfo)) - - fun trialInfo(trialInfo: JsonField) = apply { this.trialInfo = trialInfo } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): SubscriptionTriggerPhaseResponse = - SubscriptionTriggerPhaseResponse( - checkRequired("id", id), - checkRequired("activePlanPhaseOrder", activePlanPhaseOrder), - checkRequired("adjustmentIntervals", adjustmentIntervals).map { it.toImmutable() }, - checkRequired("autoCollection", autoCollection), - checkRequired("billingCycleAnchorConfiguration", billingCycleAnchorConfiguration), - checkRequired("billingCycleDay", billingCycleDay), - checkRequired("createdAt", createdAt), - checkRequired("currentBillingPeriodEndDate", currentBillingPeriodEndDate), - checkRequired("currentBillingPeriodStartDate", currentBillingPeriodStartDate), - checkRequired("customer", customer), - checkRequired("defaultInvoiceMemo", defaultInvoiceMemo), - checkRequired("discountIntervals", discountIntervals).map { it.toImmutable() }, - checkRequired("endDate", endDate), - checkRequired("fixedFeeQuantitySchedule", fixedFeeQuantitySchedule).map { - it.toImmutable() - }, - checkRequired("invoicingThreshold", invoicingThreshold), - checkRequired("maximumIntervals", maximumIntervals).map { it.toImmutable() }, - checkRequired("metadata", metadata), - checkRequired("minimumIntervals", minimumIntervals).map { it.toImmutable() }, - checkRequired("netTerms", netTerms), - checkRequired("plan", plan), - checkRequired("priceIntervals", priceIntervals).map { it.toImmutable() }, - checkRequired("redeemedCoupon", redeemedCoupon), - checkRequired("startDate", startDate), - checkRequired("status", status), - checkRequired("trialInfo", trialInfo), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class AdjustmentInterval - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment") - @ExcludeMissing - private val adjustment: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") - - /** The price interval IDs that this adjustment applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - /** The end date of the adjustment interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** The start date of the adjustment interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment - - /** The price interval IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - /** The end date of the adjustment interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** The start date of the adjustment interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AdjustmentInterval = apply { - if (validated) { - return@apply - } - - id() - adjustment().validate() - appliesToPriceIntervalIds() - endDate() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AdjustmentInterval]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustment: JsonField? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(adjustmentInterval: AdjustmentInterval) = apply { - id = adjustmentInterval.id - adjustment = adjustmentInterval.adjustment - appliesToPriceIntervalIds = - adjustmentInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - endDate = adjustmentInterval.endDate - startDate = adjustmentInterval.startDate - additionalProperties = adjustmentInterval.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) - - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } - - fun adjustment(planPhaseUsageDiscount: Adjustment.PlanPhaseUsageDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)) - - fun adjustment(planPhaseAmountDiscount: Adjustment.PlanPhaseAmountDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)) - - fun adjustment( - planPhasePercentageDiscount: Adjustment.PlanPhasePercentageDiscountAdjustment - ) = adjustment(Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)) - - fun adjustment(planPhaseMinimum: Adjustment.PlanPhaseMinimumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)) - - fun adjustment(planPhaseMaximum: Adjustment.PlanPhaseMaximumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)) - - /** The price interval IDs that this adjustment applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval IDs that this adjustment applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval IDs that this adjustment applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - /** The end date of the adjustment interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the adjustment interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the adjustment interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** The start date of the adjustment interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the adjustment interval. */ - 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) - } - - fun build(): AdjustmentInterval = - AdjustmentInterval( - checkRequired("id", id), - checkRequired("adjustment", adjustment), - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment? = null, - private val planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment? = null, - private val planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment? = null, - private val planPhaseMinimum: PlanPhaseMinimumAdjustment? = null, - private val planPhaseMaximum: PlanPhaseMaximumAdjustment? = null, - private val _json: JsonValue? = null, - ) { - - fun planPhaseUsageDiscount(): Optional = - Optional.ofNullable(planPhaseUsageDiscount) - - fun planPhaseAmountDiscount(): Optional = - Optional.ofNullable(planPhaseAmountDiscount) - - fun planPhasePercentageDiscount(): Optional = - Optional.ofNullable(planPhasePercentageDiscount) - - fun planPhaseMinimum(): Optional = - Optional.ofNullable(planPhaseMinimum) - - fun planPhaseMaximum(): Optional = - Optional.ofNullable(planPhaseMaximum) - - fun isPlanPhaseUsageDiscount(): Boolean = planPhaseUsageDiscount != null - - fun isPlanPhaseAmountDiscount(): Boolean = planPhaseAmountDiscount != null - - fun isPlanPhasePercentageDiscount(): Boolean = planPhasePercentageDiscount != null - - fun isPlanPhaseMinimum(): Boolean = planPhaseMinimum != null - - fun isPlanPhaseMaximum(): Boolean = planPhaseMaximum != null - - fun asPlanPhaseUsageDiscount(): PlanPhaseUsageDiscountAdjustment = - planPhaseUsageDiscount.getOrThrow("planPhaseUsageDiscount") - - fun asPlanPhaseAmountDiscount(): PlanPhaseAmountDiscountAdjustment = - planPhaseAmountDiscount.getOrThrow("planPhaseAmountDiscount") - - fun asPlanPhasePercentageDiscount(): PlanPhasePercentageDiscountAdjustment = - planPhasePercentageDiscount.getOrThrow("planPhasePercentageDiscount") - - fun asPlanPhaseMinimum(): PlanPhaseMinimumAdjustment = - planPhaseMinimum.getOrThrow("planPhaseMinimum") - - fun asPlanPhaseMaximum(): PlanPhaseMaximumAdjustment = - planPhaseMaximum.getOrThrow("planPhaseMaximum") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - planPhaseUsageDiscount != null -> - visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) - planPhaseAmountDiscount != null -> - visitor.visitPlanPhaseAmountDiscount(planPhaseAmountDiscount) - planPhasePercentageDiscount != null -> - visitor.visitPlanPhasePercentageDiscount(planPhasePercentageDiscount) - planPhaseMinimum != null -> visitor.visitPlanPhaseMinimum(planPhaseMinimum) - planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) { - planPhaseUsageDiscount.validate() - } - - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) { - planPhaseAmountDiscount.validate() - } - - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) { - planPhasePercentageDiscount.validate() - } - - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) { - planPhaseMinimum.validate() - } - - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) { - planPhaseMaximum.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Adjustment && planPhaseUsageDiscount == other.planPhaseUsageDiscount && planPhaseAmountDiscount == other.planPhaseAmountDiscount && planPhasePercentageDiscount == other.planPhasePercentageDiscount && planPhaseMinimum == other.planPhaseMinimum && planPhaseMaximum == other.planPhaseMaximum /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(planPhaseUsageDiscount, planPhaseAmountDiscount, planPhasePercentageDiscount, planPhaseMinimum, planPhaseMaximum) /* spotless:on */ - - override fun toString(): String = - when { - planPhaseUsageDiscount != null -> - "Adjustment{planPhaseUsageDiscount=$planPhaseUsageDiscount}" - planPhaseAmountDiscount != null -> - "Adjustment{planPhaseAmountDiscount=$planPhaseAmountDiscount}" - planPhasePercentageDiscount != null -> - "Adjustment{planPhasePercentageDiscount=$planPhasePercentageDiscount}" - planPhaseMinimum != null -> "Adjustment{planPhaseMinimum=$planPhaseMinimum}" - planPhaseMaximum != null -> "Adjustment{planPhaseMaximum=$planPhaseMaximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } - - companion object { - - @JvmStatic - fun ofPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = Adjustment(planPhaseUsageDiscount = planPhaseUsageDiscount) - - @JvmStatic - fun ofPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = Adjustment(planPhaseAmountDiscount = planPhaseAmountDiscount) - - @JvmStatic - fun ofPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = Adjustment(planPhasePercentageDiscount = planPhasePercentageDiscount) - - @JvmStatic - fun ofPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment) = - Adjustment(planPhaseMinimum = planPhaseMinimum) - - @JvmStatic - fun ofPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment) = - Adjustment(planPhaseMaximum = planPhaseMaximum) - } - - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { - - fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ): T - - fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ): T - - fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ): T - - fun visitPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment): T - - fun visitPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment): T - - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } - - internal class Deserializer : BaseDeserializer(Adjustment::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = - json.asObject().getOrNull()?.get("adjustment_type")?.asString()?.getOrNull() - - when (adjustmentType) { - "usage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseUsageDiscount = it, _json = json) - } - } - "amount_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseAmountDiscount = it, _json = json) - } - } - "percentage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment( - planPhasePercentageDiscount = it, - _json = json, - ) - } - } - "minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMinimum = it, _json = json) - } - } - "maximum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMaximum = it, _json = json) - } - } - } - - return Adjustment(_json = json) - } - } - - internal class Serializer : BaseSerializer(Adjustment::class) { - - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.planPhaseUsageDiscount != null -> - generator.writeObject(value.planPhaseUsageDiscount) - value.planPhaseAmountDiscount != null -> - generator.writeObject(value.planPhaseAmountDiscount) - value.planPhasePercentageDiscount != null -> - generator.writeObject(value.planPhasePercentageDiscount) - value.planPhaseMinimum != null -> - generator.writeObject(value.planPhaseMinimum) - value.planPhaseMaximum != null -> - generator.writeObject(value.planPhaseMaximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") - } - } - } - - @NoAutoDetect - class PlanPhaseUsageDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonProperty("usage_discount") - @ExcludeMissing - private val usageDiscount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - /** - * The number of usage units by which to discount the price this adjustment applies - * to in a given billing period. - */ - fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - /** - * The number of usage units by which to discount the price this adjustment applies - * to in a given billing period. - */ - @JsonProperty("usage_discount") - @ExcludeMissing - fun _usageDiscount(): JsonField = usageDiscount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseUsageDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - planPhaseOrder() - reason() - usageDiscount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseUsageDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var usageDiscount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - planPhaseUsageDiscountAdjustment: PlanPhaseUsageDiscountAdjustment - ) = apply { - id = planPhaseUsageDiscountAdjustment.id - adjustmentType = planPhaseUsageDiscountAdjustment.adjustmentType - appliesToPriceIds = - planPhaseUsageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseUsageDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseUsageDiscountAdjustment.planPhaseOrder - reason = planPhaseUsageDiscountAdjustment.reason - usageDiscount = planPhaseUsageDiscountAdjustment.usageDiscount - additionalProperties = - planPhaseUsageDiscountAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - /** - * The number of usage units by which to discount the price this adjustment - * applies to in a given billing period. - */ - fun usageDiscount(usageDiscount: Double) = - usageDiscount(JsonField.of(usageDiscount)) - - /** - * The number of usage units by which to discount the price this adjustment - * applies to in a given billing period. - */ - fun usageDiscount(usageDiscount: JsonField) = apply { - this.usageDiscount = usageDiscount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseUsageDiscountAdjustment = - PlanPhaseUsageDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - checkRequired("usageDiscount", usageDiscount), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - USAGE_DISCOUNT -> Known.USAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseUsageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, planPhaseOrder, reason, usageDiscount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseUsageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhaseAmountDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("amount_discount") - @ExcludeMissing - private val amountDiscount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** - * The amount by which to discount the prices this adjustment applies to in a given - * billing period. - */ - fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** - * The amount by which to discount the prices this adjustment applies to in a given - * billing period. - */ - @JsonProperty("amount_discount") - @ExcludeMissing - fun _amountDiscount(): JsonField = amountDiscount - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseAmountDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - amountDiscount() - appliesToPriceIds() - isInvoiceLevel() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseAmountDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var amountDiscount: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - planPhaseAmountDiscountAdjustment: PlanPhaseAmountDiscountAdjustment - ) = apply { - id = planPhaseAmountDiscountAdjustment.id - adjustmentType = planPhaseAmountDiscountAdjustment.adjustmentType - amountDiscount = planPhaseAmountDiscountAdjustment.amountDiscount - appliesToPriceIds = - planPhaseAmountDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseAmountDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseAmountDiscountAdjustment.planPhaseOrder - reason = planPhaseAmountDiscountAdjustment.reason - additionalProperties = - planPhaseAmountDiscountAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** - * The amount by which to discount the prices this adjustment applies to in a - * given billing period. - */ - fun amountDiscount(amountDiscount: String) = - amountDiscount(JsonField.of(amountDiscount)) - - /** - * The amount by which to discount the prices this adjustment applies to in a - * given billing period. - */ - fun amountDiscount(amountDiscount: JsonField) = apply { - this.amountDiscount = amountDiscount - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseAmountDiscountAdjustment = - PlanPhaseAmountDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("amountDiscount", amountDiscount), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseAmountDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, amountDiscount, appliesToPriceIds, isInvoiceLevel, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseAmountDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhasePercentageDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("percentage_discount") - @ExcludeMissing - private val percentageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(): Double = - percentageDiscount.getRequired("percentage_discount") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - @JsonProperty("percentage_discount") - @ExcludeMissing - fun _percentageDiscount(): JsonField = percentageDiscount - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhasePercentageDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - percentageDiscount() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhasePercentageDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var percentageDiscount: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - planPhasePercentageDiscountAdjustment: PlanPhasePercentageDiscountAdjustment - ) = apply { - id = planPhasePercentageDiscountAdjustment.id - adjustmentType = planPhasePercentageDiscountAdjustment.adjustmentType - appliesToPriceIds = - planPhasePercentageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhasePercentageDiscountAdjustment.isInvoiceLevel - percentageDiscount = - planPhasePercentageDiscountAdjustment.percentageDiscount - planPhaseOrder = planPhasePercentageDiscountAdjustment.planPhaseOrder - reason = planPhasePercentageDiscountAdjustment.reason - additionalProperties = - planPhasePercentageDiscountAdjustment.additionalProperties - .toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(percentageDiscount: Double) = - percentageDiscount(JsonField.of(percentageDiscount)) - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(percentageDiscount: JsonField) = apply { - this.percentageDiscount = percentageDiscount - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhasePercentageDiscountAdjustment = - PlanPhasePercentageDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("percentageDiscount", percentageDiscount), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val PERCENTAGE_DISCOUNT = of("percentage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhasePercentageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, percentageDiscount, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhasePercentageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhaseMinimumAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(): String = itemId.getRequired("item_id") - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The item ID that revenue from this minimum will be attributed to. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseMinimumAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - itemId() - minimumAmount() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseMinimumAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var itemId: JsonField? = null - private var minimumAmount: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(planPhaseMinimumAdjustment: PlanPhaseMinimumAdjustment) = - apply { - id = planPhaseMinimumAdjustment.id - adjustmentType = planPhaseMinimumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMinimumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMinimumAdjustment.isInvoiceLevel - itemId = planPhaseMinimumAdjustment.itemId - minimumAmount = planPhaseMinimumAdjustment.minimumAmount - planPhaseOrder = planPhaseMinimumAdjustment.planPhaseOrder - reason = planPhaseMinimumAdjustment.reason - additionalProperties = - planPhaseMinimumAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseMinimumAdjustment = - PlanPhaseMinimumAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("itemId", itemId), - checkRequired("minimumAmount", minimumAmount), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseMinimumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, itemId, minimumAmount, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseMinimumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhaseMaximumAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseMaximumAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - maximumAmount() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseMaximumAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var maximumAmount: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(planPhaseMaximumAdjustment: PlanPhaseMaximumAdjustment) = - apply { - id = planPhaseMaximumAdjustment.id - adjustmentType = planPhaseMaximumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMaximumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMaximumAdjustment.isInvoiceLevel - maximumAmount = planPhaseMaximumAdjustment.maximumAmount - planPhaseOrder = planPhaseMaximumAdjustment.planPhaseOrder - reason = planPhaseMaximumAdjustment.reason - additionalProperties = - planPhaseMaximumAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseMaximumAdjustment = - PlanPhaseMaximumAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("maximumAmount", maximumAmount), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseMaximumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, maximumAmount, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseMaximumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentInterval && id == other.id && adjustment == other.adjustment && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustment, appliesToPriceIntervalIds, endDate, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AdjustmentInterval{id=$id, adjustment=$adjustment, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BillingCycleAnchorConfiguration - @JsonCreator - private constructor( - @JsonProperty("day") @ExcludeMissing private val day: JsonField = JsonMissing.of(), - @JsonProperty("month") - @ExcludeMissing - private val month: JsonField = JsonMissing.of(), - @JsonProperty("year") @ExcludeMissing private val year: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun day(): Long = day.getRequired("day") - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(): Optional = Optional.ofNullable(month.getNullable("month")) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on - * 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(): Optional = Optional.ofNullable(year.getNullable("year")) - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - @JsonProperty("day") @ExcludeMissing fun _day(): JsonField = day - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - @JsonProperty("month") @ExcludeMissing fun _month(): JsonField = month - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on - * 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - @JsonProperty("year") @ExcludeMissing fun _year(): JsonField = year - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleAnchorConfiguration = apply { - if (validated) { - return@apply - } - - day() - month() - year() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleAnchorConfiguration]. */ - class Builder internal constructor() { - - private var day: JsonField? = null - private var month: JsonField = JsonMissing.of() - private var year: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration) = - apply { - day = billingCycleAnchorConfiguration.day - month = billingCycleAnchorConfiguration.month - year = billingCycleAnchorConfiguration.year - additionalProperties = - billingCycleAnchorConfiguration.additionalProperties.toMutableMap() - } - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun day(day: Long) = day(JsonField.of(day)) - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun day(day: JsonField) = apply { this.day = day } - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(month: Long?) = month(JsonField.ofNullable(month)) - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(month: Long) = month(month as Long?) - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun month(month: Optional) = month(month.orElse(null) as Long?) - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(month: JsonField) = apply { this.month = month } - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(year: Long?) = year(JsonField.ofNullable(year)) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(year: Long) = year(year as Long?) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun year(year: Optional) = year(year.orElse(null) as Long?) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(year: JsonField) = apply { this.year = year } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleAnchorConfiguration = - BillingCycleAnchorConfiguration( - checkRequired("day", day), - month, - year, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleAnchorConfiguration && day == other.day && month == other.month && year == other.year && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(day, month, year, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleAnchorConfiguration{day=$day, month=$month, year=$year, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(using = DiscountInterval.Deserializer::class) - @JsonSerialize(using = DiscountInterval.Serializer::class) - class DiscountInterval - private constructor( - private val amount: AmountDiscountInterval? = null, - private val percentage: PercentageDiscountInterval? = null, - private val usage: UsageDiscountInterval? = null, - private val _json: JsonValue? = null, - ) { - - fun amount(): Optional = Optional.ofNullable(amount) - - fun percentage(): Optional = Optional.ofNullable(percentage) - - fun usage(): Optional = Optional.ofNullable(usage) - - fun isAmount(): Boolean = amount != null - - fun isPercentage(): Boolean = percentage != null - - fun isUsage(): Boolean = usage != null - - fun asAmount(): AmountDiscountInterval = amount.getOrThrow("amount") - - fun asPercentage(): PercentageDiscountInterval = percentage.getOrThrow("percentage") - - fun asUsage(): UsageDiscountInterval = usage.getOrThrow("usage") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - amount != null -> visitor.visitAmount(amount) - percentage != null -> visitor.visitPercentage(percentage) - usage != null -> visitor.visitUsage(usage) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): DiscountInterval = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitAmount(amount: AmountDiscountInterval) { - amount.validate() - } - - override fun visitPercentage(percentage: PercentageDiscountInterval) { - percentage.validate() - } - - override fun visitUsage(usage: UsageDiscountInterval) { - usage.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountInterval && amount == other.amount && percentage == other.percentage && usage == other.usage /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(amount, percentage, usage) /* spotless:on */ - - override fun toString(): String = - when { - amount != null -> "DiscountInterval{amount=$amount}" - percentage != null -> "DiscountInterval{percentage=$percentage}" - usage != null -> "DiscountInterval{usage=$usage}" - _json != null -> "DiscountInterval{_unknown=$_json}" - else -> throw IllegalStateException("Invalid DiscountInterval") - } - - companion object { - - @JvmStatic - fun ofAmount(amount: AmountDiscountInterval) = DiscountInterval(amount = amount) - - @JvmStatic - fun ofPercentage(percentage: PercentageDiscountInterval) = - DiscountInterval(percentage = percentage) - - @JvmStatic fun ofUsage(usage: UsageDiscountInterval) = DiscountInterval(usage = usage) - } - - /** - * An interface that defines how to map each variant of [DiscountInterval] to a value of - * type [T]. - */ - interface Visitor { - - fun visitAmount(amount: AmountDiscountInterval): T - - fun visitPercentage(percentage: PercentageDiscountInterval): T - - fun visitUsage(usage: UsageDiscountInterval): T - - /** - * Maps an unknown variant of [DiscountInterval] to a value of type [T]. - * - * An instance of [DiscountInterval] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown DiscountInterval: $json") - } - } - - internal class Deserializer : BaseDeserializer(DiscountInterval::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): DiscountInterval { - val json = JsonValue.fromJsonNode(node) - val discountType = - json.asObject().getOrNull()?.get("discount_type")?.asString()?.getOrNull() - - when (discountType) { - "amount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(amount = it, _json = json) - } - } - "percentage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(percentage = it, _json = json) - } - } - "usage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(usage = it, _json = json) - } - } - } - - return DiscountInterval(_json = json) - } - } - - internal class Serializer : BaseSerializer(DiscountInterval::class) { - - override fun serialize( - value: DiscountInterval, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.amount != null -> generator.writeObject(value.amount) - value.percentage != null -> generator.writeObject(value.percentage) - value.usage != null -> generator.writeObject(value.usage) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid DiscountInterval") - } - } - } - - @NoAutoDetect - class AmountDiscountInterval - @JsonCreator - private constructor( - @JsonProperty("amount_discount") - @ExcludeMissing - private val amountDiscount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("discount_type") - @ExcludeMissing - private val discountType: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - fun discountType(): DiscountType = discountType.getRequired("discount_type") - - /** The end date of the discount interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** The start date of the discount interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** Only available if discount_type is `amount`. */ - @JsonProperty("amount_discount") - @ExcludeMissing - fun _amountDiscount(): JsonField = amountDiscount - - /** The price ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - - /** The end date of the discount interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** The start date of the discount interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AmountDiscountInterval = apply { - if (validated) { - return@apply - } - - amountDiscount() - appliesToPriceIds() - appliesToPriceIntervalIds() - discountType() - endDate() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AmountDiscountInterval]. */ - class Builder internal constructor() { - - private var amountDiscount: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { - amountDiscount = amountDiscountInterval.amountDiscount - appliesToPriceIds = - amountDiscountInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - amountDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = amountDiscountInterval.discountType - endDate = amountDiscountInterval.endDate - startDate = amountDiscountInterval.startDate - additionalProperties = - amountDiscountInterval.additionalProperties.toMutableMap() - } - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(amountDiscount: String) = - amountDiscount(JsonField.of(amountDiscount)) - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(amountDiscount: JsonField) = apply { - this.amountDiscount = amountDiscount - } - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this discount interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this discount interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the discount interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the discount interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** The start date of the discount interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the discount interval. */ - 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) - } - - fun build(): AmountDiscountInterval = - AmountDiscountInterval( - checkRequired("amountDiscount", amountDiscount), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("discountType", discountType), - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val AMOUNT = of("amount") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - AMOUNT - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT -> Value.AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AMOUNT -> Known.AMOUNT - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AmountDiscountInterval && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amountDiscount, appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AmountDiscountInterval{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PercentageDiscountInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("discount_type") - @ExcludeMissing - private val discountType: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("percentage_discount") - @ExcludeMissing - private val percentageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - fun discountType(): DiscountType = discountType.getRequired("discount_type") - - /** The end date of the discount interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ - fun percentageDiscount(): Double = percentageDiscount.getRequired("percentage_discount") - - /** The start date of the discount interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** The price ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - - /** The end date of the discount interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ - @JsonProperty("percentage_discount") - @ExcludeMissing - fun _percentageDiscount(): JsonField = percentageDiscount - - /** The start date of the discount interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PercentageDiscountInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - discountType() - endDate() - percentageDiscount() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PercentageDiscountInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null - private var endDate: JsonField? = null - private var percentageDiscount: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { - appliesToPriceIds = - percentageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - percentageDiscountInterval.appliesToPriceIntervalIds.map { - it.toMutableList() - } - discountType = percentageDiscountInterval.discountType - endDate = percentageDiscountInterval.endDate - percentageDiscount = percentageDiscountInterval.percentageDiscount - startDate = percentageDiscountInterval.startDate - additionalProperties = - percentageDiscountInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this discount interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this discount interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the discount interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the discount interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** - * Only available if discount_type is `percentage`.This is a number between 0 and 1. - */ - fun percentageDiscount(percentageDiscount: Double) = - percentageDiscount(JsonField.of(percentageDiscount)) - - /** - * Only available if discount_type is `percentage`.This is a number between 0 and 1. - */ - fun percentageDiscount(percentageDiscount: JsonField) = apply { - this.percentageDiscount = percentageDiscount - } - - /** The start date of the discount interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the discount interval. */ - 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) - } - - fun build(): PercentageDiscountInterval = - PercentageDiscountInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("discountType", discountType), - checkRequired("endDate", endDate), - checkRequired("percentageDiscount", percentageDiscount), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val PERCENTAGE = of("percentage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - PERCENTAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE -> Value.PERCENTAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PERCENTAGE -> Known.PERCENTAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PercentageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, percentageDiscount, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PercentageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class UsageDiscountInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("discount_type") - @ExcludeMissing - private val discountType: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonProperty("usage_discount") - @ExcludeMissing - private val usageDiscount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - fun discountType(): DiscountType = discountType.getRequired("discount_type") - - /** The end date of the discount interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** The start date of the discount interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** - * Only available if discount_type is `usage`. Number of usage units that this discount - * is for - */ - fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - - /** The price ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - - /** The end date of the discount interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** The start date of the discount interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - /** - * Only available if discount_type is `usage`. Number of usage units that this discount - * is for - */ - @JsonProperty("usage_discount") - @ExcludeMissing - fun _usageDiscount(): JsonField = usageDiscount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): UsageDiscountInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - discountType() - endDate() - startDate() - usageDiscount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UsageDiscountInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var usageDiscount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { - appliesToPriceIds = - usageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - usageDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = usageDiscountInterval.discountType - endDate = usageDiscountInterval.endDate - startDate = usageDiscountInterval.startDate - usageDiscount = usageDiscountInterval.usageDiscount - additionalProperties = usageDiscountInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this discount interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this discount interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the discount interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the discount interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** The start date of the discount interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the discount interval. */ - fun startDate(startDate: JsonField) = apply { - this.startDate = startDate - } - - /** - * Only available if discount_type is `usage`. Number of usage units that this - * discount is for - */ - fun usageDiscount(usageDiscount: Double) = - usageDiscount(JsonField.of(usageDiscount)) - - /** - * Only available if discount_type is `usage`. Number of usage units that this - * discount is for - */ - fun usageDiscount(usageDiscount: JsonField) = apply { - this.usageDiscount = usageDiscount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): UsageDiscountInterval = - UsageDiscountInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("discountType", discountType), - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - checkRequired("usageDiscount", usageDiscount), - additionalProperties.toImmutable(), - ) - } - - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE = of("usage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - USAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE -> Value.USAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE -> Known.USAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UsageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, startDate, usageDiscount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UsageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" - } - } - - @NoAutoDetect - class FixedFeeQuantitySchedule - @JsonCreator - private constructor( - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("price_id") - @ExcludeMissing - private val priceId: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - private val quantity: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - fun priceId(): String = priceId.getRequired("price_id") - - fun quantity(): Double = quantity.getRequired("quantity") - - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - - @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): FixedFeeQuantitySchedule = apply { - if (validated) { - return@apply - } - - endDate() - priceId() - quantity() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FixedFeeQuantitySchedule]. */ - class Builder internal constructor() { - - private var endDate: JsonField? = null - private var priceId: JsonField? = null - private var quantity: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = apply { - endDate = fixedFeeQuantitySchedule.endDate - priceId = fixedFeeQuantitySchedule.priceId - quantity = fixedFeeQuantitySchedule.quantity - startDate = fixedFeeQuantitySchedule.startDate - additionalProperties = fixedFeeQuantitySchedule.additionalProperties.toMutableMap() - } - - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) - - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - 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) - } - - fun build(): FixedFeeQuantitySchedule = - FixedFeeQuantitySchedule( - checkRequired("endDate", endDate), - checkRequired("priceId", priceId), - checkRequired("quantity", quantity), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FixedFeeQuantitySchedule && endDate == other.endDate && priceId == other.priceId && quantity == other.quantity && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(endDate, priceId, quantity, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "FixedFeeQuantitySchedule{endDate=$endDate, priceId=$priceId, quantity=$quantity, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class MaximumInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this maximum interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this maximum interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - /** The end date of the maximum interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** The start date of the maximum interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** The price ids that this maximum interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this maximum interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - /** The end date of the maximum interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** The start date of the maximum interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MaximumInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - endDate() - maximumAmount() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MaximumInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var endDate: JsonField? = null - private var maximumAmount: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximumInterval: MaximumInterval) = apply { - appliesToPriceIds = maximumInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - maximumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - endDate = maximumInterval.endDate - maximumAmount = maximumInterval.maximumAmount - startDate = maximumInterval.startDate - additionalProperties = maximumInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this maximum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this maximum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this maximum interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this maximum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this maximum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this maximum interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - /** The end date of the maximum interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the maximum interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the maximum interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** The start date of the maximum interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the maximum interval. */ - 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) - } - - fun build(): MaximumInterval = - MaximumInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("endDate", endDate), - checkRequired("maximumAmount", maximumAmount), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MaximumInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && maximumAmount == other.maximumAmount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, endDate, maximumAmount, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MaximumInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, maximumAmount=$maximumAmount, startDate=$startDate, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class MinimumInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this minimum interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this minimum interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - /** The end date of the minimum interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** The start date of the minimum interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** The price ids that this minimum interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this minimum interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - /** The end date of the minimum interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** The start date of the minimum interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MinimumInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - endDate() - minimumAmount() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MinimumInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var endDate: JsonField? = null - private var minimumAmount: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(minimumInterval: MinimumInterval) = apply { - appliesToPriceIds = minimumInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - minimumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - endDate = minimumInterval.endDate - minimumAmount = minimumInterval.minimumAmount - startDate = minimumInterval.startDate - additionalProperties = minimumInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this minimum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this minimum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this minimum interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this minimum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this minimum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this minimum interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - /** The end date of the minimum interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the minimum interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the minimum interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** The start date of the minimum interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the minimum interval. */ - 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) - } - - fun build(): MinimumInterval = - MinimumInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("endDate", endDate), - checkRequired("minimumAmount", minimumAmount), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MinimumInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && minimumAmount == other.minimumAmount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, endDate, minimumAmount, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MinimumInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, minimumAmount=$minimumAmount, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - /** - * The Price Interval resource represents a period of time for which a price will bill on a - * subscription. A subscription’s price intervals define its billing behavior. - */ - @NoAutoDetect - class PriceInterval - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_day") - @ExcludeMissing - private val billingCycleDay: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - private val currentBillingPeriodEndDate: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - private val currentBillingPeriodStartDate: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("filter") - @ExcludeMissing - private val filter: JsonField = JsonMissing.of(), - @JsonProperty("fixed_fee_quantity_transitions") - @ExcludeMissing - private val fixedFeeQuantityTransitions: JsonField> = - JsonMissing.of(), - @JsonProperty("price") - @ExcludeMissing - private val price: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonProperty("usage_customer_ids") - @ExcludeMissing - private val usageCustomerIds: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - /** The day of the month that Orb bills for this price */ - fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate(): Optional = - Optional.ofNullable( - currentBillingPeriodEndDate.getNullable("current_billing_period_end_date") - ) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodStartDate(): Optional = - Optional.ofNullable( - currentBillingPeriodStartDate.getNullable("current_billing_period_start_date") - ) - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** An additional filter to apply to usage queries. */ - fun filter(): Optional = Optional.ofNullable(filter.getNullable("filter")) - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions(): Optional> = - Optional.ofNullable( - fixedFeeQuantityTransitions.getNullable("fixed_fee_quantity_transitions") - ) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting in - * a charge on an invoice in the form of an invoice line item. Prices take a quantity and - * determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the key - * for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(): Price = price.getRequired("price") - - /** - * The start date of the price interval. This is the date that Orb starts billing for this - * price. - */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this price - * interval. - */ - fun usageCustomerIds(): Optional> = - Optional.ofNullable(usageCustomerIds.getNullable("usage_customer_ids")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** The day of the month that Orb bills for this price */ - @JsonProperty("billing_cycle_day") - @ExcludeMissing - fun _billingCycleDay(): JsonField = billingCycleDay - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if this price - * interval is not currently active. - */ - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - fun _currentBillingPeriodStartDate(): JsonField = - currentBillingPeriodStartDate - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** An additional filter to apply to usage queries. */ - @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField = filter - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - @JsonProperty("fixed_fee_quantity_transitions") - @ExcludeMissing - fun _fixedFeeQuantityTransitions(): JsonField> = - fixedFeeQuantityTransitions - - /** - * 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) - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - - /** - * The start date of the price interval. This is the date that Orb starts billing for this - * price. - */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this price - * interval. - */ - @JsonProperty("usage_customer_ids") - @ExcludeMissing - fun _usageCustomerIds(): JsonField> = usageCustomerIds - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PriceInterval = apply { - if (validated) { - return@apply - } - - id() - billingCycleDay() - currentBillingPeriodEndDate() - currentBillingPeriodStartDate() - endDate() - filter() - fixedFeeQuantityTransitions().ifPresent { it.forEach { it.validate() } } - price().validate() - startDate() - usageCustomerIds() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PriceInterval]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var billingCycleDay: JsonField? = null - private var currentBillingPeriodEndDate: JsonField? = null - private var currentBillingPeriodStartDate: JsonField? = null - private var endDate: JsonField? = null - private var filter: JsonField? = null - private var fixedFeeQuantityTransitions: - JsonField>? = - null - private var price: JsonField? = null - private var startDate: JsonField? = null - private var usageCustomerIds: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(priceInterval: PriceInterval) = apply { - id = priceInterval.id - billingCycleDay = priceInterval.billingCycleDay - currentBillingPeriodEndDate = priceInterval.currentBillingPeriodEndDate - currentBillingPeriodStartDate = priceInterval.currentBillingPeriodStartDate - endDate = priceInterval.endDate - filter = priceInterval.filter - fixedFeeQuantityTransitions = - priceInterval.fixedFeeQuantityTransitions.map { it.toMutableList() } - price = priceInterval.price - startDate = priceInterval.startDate - usageCustomerIds = priceInterval.usageCustomerIds.map { it.toMutableList() } - additionalProperties = priceInterval.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - /** The day of the month that Orb bills for this price */ - fun billingCycleDay(billingCycleDay: Long) = - billingCycleDay(JsonField.of(billingCycleDay)) - - /** The day of the month that Orb bills for this price */ - fun billingCycleDay(billingCycleDay: JsonField) = apply { - this.billingCycleDay = billingCycleDay - } - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = - currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = - currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate( - currentBillingPeriodEndDate: JsonField - ) = apply { this.currentBillingPeriodEndDate = currentBillingPeriodEndDate } - - /** - * The start date of the current billing period. This is an inclusive timestamp; the - * instant returned is exactly the beginning of the billing period. Set to null if this - * price interval is not currently active. - */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = - currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the - * instant returned is exactly the beginning of the billing period. Set to null if this - * price interval is not currently active. - */ - fun currentBillingPeriodStartDate( - currentBillingPeriodStartDate: Optional - ) = currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the - * instant returned is exactly the beginning of the billing period. Set to null if this - * price interval is not currently active. - */ - fun currentBillingPeriodStartDate( - currentBillingPeriodStartDate: JsonField - ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** An additional filter to apply to usage queries. */ - fun filter(filter: String?) = filter(JsonField.ofNullable(filter)) - - /** An additional filter to apply to usage queries. */ - fun filter(filter: Optional) = filter(filter.orElse(null)) - - /** An additional filter to apply to usage queries. */ - fun filter(filter: JsonField) = apply { this.filter = filter } - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: List? - ) = fixedFeeQuantityTransitions(JsonField.ofNullable(fixedFeeQuantityTransitions)) - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: Optional> - ) = fixedFeeQuantityTransitions(fixedFeeQuantityTransitions.orElse(null)) - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: JsonField> - ) = apply { - this.fixedFeeQuantityTransitions = - fixedFeeQuantityTransitions.map { it.toMutableList() } - } - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun addFixedFeeQuantityTransition( - fixedFeeQuantityTransition: FixedFeeQuantityTransition - ) = apply { - fixedFeeQuantityTransitions = - (fixedFeeQuantityTransitions ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(fixedFeeQuantityTransition) - } - } - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(price: Price) = price(JsonField.of(price)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(price: JsonField) = apply { this.price = price } - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(matrix: Price.MatrixPrice) = price(Price.ofMatrix(matrix)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredPackage: Price.TieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedTiered: Price.GroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(unitWithPercent: Price.UnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredWithProration: Price.TieredWithProrationPrice) = - price(Price.ofTieredWithProration(tieredWithProration)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(unitWithProration: Price.UnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedAllocation: Price.GroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bulkWithProration: Price.BulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = - price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice) = - price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - - /** - * The start date of the price interval. This is the date that Orb starts billing for - * this price. - */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** - * The start date of the price interval. This is the date that Orb starts billing for - * this price. - */ - fun startDate(startDate: JsonField) = apply { - this.startDate = startDate - } - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun usageCustomerIds(usageCustomerIds: List?) = - usageCustomerIds(JsonField.ofNullable(usageCustomerIds)) - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun usageCustomerIds(usageCustomerIds: Optional>) = - usageCustomerIds(usageCustomerIds.orElse(null)) - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun usageCustomerIds(usageCustomerIds: JsonField>) = apply { - this.usageCustomerIds = usageCustomerIds.map { it.toMutableList() } - } - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun addUsageCustomerId(usageCustomerId: String) = apply { - usageCustomerIds = - (usageCustomerIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(usageCustomerId) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): PriceInterval = - PriceInterval( - checkRequired("id", id), - checkRequired("billingCycleDay", billingCycleDay), - checkRequired("currentBillingPeriodEndDate", currentBillingPeriodEndDate), - checkRequired("currentBillingPeriodStartDate", currentBillingPeriodStartDate), - checkRequired("endDate", endDate), - checkRequired("filter", filter), - checkRequired("fixedFeeQuantityTransitions", fixedFeeQuantityTransitions).map { - it.toImmutable() - }, - checkRequired("price", price), - checkRequired("startDate", startDate), - checkRequired("usageCustomerIds", usageCustomerIds).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class FixedFeeQuantityTransition - @JsonCreator - private constructor( - @JsonProperty("effective_date") - @ExcludeMissing - private val effectiveDate: JsonField = JsonMissing.of(), - @JsonProperty("price_id") - @ExcludeMissing - private val priceId: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - private val quantity: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun effectiveDate(): OffsetDateTime = effectiveDate.getRequired("effective_date") - - fun priceId(): String = priceId.getRequired("price_id") - - fun quantity(): Long = quantity.getRequired("quantity") - - @JsonProperty("effective_date") - @ExcludeMissing - fun _effectiveDate(): JsonField = effectiveDate - - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - - @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): FixedFeeQuantityTransition = apply { - if (validated) { - return@apply - } - - effectiveDate() - priceId() - quantity() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FixedFeeQuantityTransition]. */ - class Builder internal constructor() { - - private var effectiveDate: JsonField? = null - private var priceId: JsonField? = null - private var quantity: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(fixedFeeQuantityTransition: FixedFeeQuantityTransition) = apply { - effectiveDate = fixedFeeQuantityTransition.effectiveDate - priceId = fixedFeeQuantityTransition.priceId - quantity = fixedFeeQuantityTransition.quantity - additionalProperties = - fixedFeeQuantityTransition.additionalProperties.toMutableMap() - } - - fun effectiveDate(effectiveDate: OffsetDateTime) = - effectiveDate(JsonField.of(effectiveDate)) - - fun effectiveDate(effectiveDate: JsonField) = apply { - this.effectiveDate = effectiveDate - } - - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) - - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - - fun quantity(quantity: Long) = quantity(JsonField.of(quantity)) - - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): FixedFeeQuantityTransition = - FixedFeeQuantityTransition( - checkRequired("effectiveDate", effectiveDate), - checkRequired("priceId", priceId), - checkRequired("quantity", quantity), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FixedFeeQuantityTransition && effectiveDate == other.effectiveDate && priceId == other.priceId && quantity == other.quantity && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(effectiveDate, priceId, quantity, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "FixedFeeQuantityTransition{effectiveDate=$effectiveDate, priceId=$priceId, quantity=$quantity, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PriceInterval && id == other.id && billingCycleDay == other.billingCycleDay && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && endDate == other.endDate && filter == other.filter && fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && price == other.price && startDate == other.startDate && usageCustomerIds == other.usageCustomerIds && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billingCycleDay, currentBillingPeriodEndDate, currentBillingPeriodStartDate, endDate, filter, fixedFeeQuantityTransitions, price, startDate, usageCustomerIds, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PriceInterval{id=$id, billingCycleDay=$billingCycleDay, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, endDate=$endDate, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, price=$price, startDate=$startDate, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class RedeemedCoupon - @JsonCreator - private constructor( - @JsonProperty("coupon_id") - @ExcludeMissing - private val couponId: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun couponId(): String = couponId.getRequired("coupon_id") - - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - @JsonProperty("coupon_id") @ExcludeMissing fun _couponId(): JsonField = couponId - - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): RedeemedCoupon = apply { - if (validated) { - return@apply - } - - couponId() - endDate() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RedeemedCoupon]. */ - class Builder internal constructor() { - - private var couponId: JsonField? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(redeemedCoupon: RedeemedCoupon) = apply { - couponId = redeemedCoupon.couponId - endDate = redeemedCoupon.endDate - startDate = redeemedCoupon.startDate - additionalProperties = redeemedCoupon.additionalProperties.toMutableMap() - } - - fun couponId(couponId: String) = couponId(JsonField.of(couponId)) - - fun couponId(couponId: JsonField) = apply { this.couponId = couponId } - - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - 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) - } - - fun build(): RedeemedCoupon = - RedeemedCoupon( - checkRequired("couponId", couponId), - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RedeemedCoupon && couponId == other.couponId && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(couponId, endDate, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RedeemedCoupon{couponId=$couponId, endDate=$endDate, startDate=$startDate, 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 ENDED = of("ended") - - @JvmField val UPCOMING = of("upcoming") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - ACTIVE, - ENDED, - UPCOMING, - } - - /** - * 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, - ENDED, - UPCOMING, - /** 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 - ENDED -> Value.ENDED - UPCOMING -> Value.UPCOMING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to 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 - ENDED -> Known.ENDED - UPCOMING -> Known.UPCOMING - 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TrialInfo - @JsonCreator - private constructor( - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TrialInfo = apply { - if (validated) { - return@apply - } - - endDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TrialInfo]. */ - class Builder internal constructor() { - - private var endDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(trialInfo: TrialInfo) = apply { - endDate = trialInfo.endDate - additionalProperties = trialInfo.additionalProperties.toMutableMap() - } - - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - 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) - } - - fun build(): TrialInfo = - TrialInfo(checkRequired("endDate", endDate), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TrialInfo && endDate == other.endDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(endDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TrialInfo{endDate=$endDate, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is SubscriptionTriggerPhaseResponse && id == other.id && activePlanPhaseOrder == other.activePlanPhaseOrder && adjustmentIntervals == other.adjustmentIntervals && autoCollection == other.autoCollection && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && billingCycleDay == other.billingCycleDay && createdAt == other.createdAt && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && customer == other.customer && defaultInvoiceMemo == other.defaultInvoiceMemo && discountIntervals == other.discountIntervals && endDate == other.endDate && fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && invoicingThreshold == other.invoicingThreshold && maximumIntervals == other.maximumIntervals && metadata == other.metadata && minimumIntervals == other.minimumIntervals && netTerms == other.netTerms && plan == other.plan && priceIntervals == other.priceIntervals && redeemedCoupon == other.redeemedCoupon && startDate == other.startDate && status == other.status && trialInfo == other.trialInfo && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, activePlanPhaseOrder, adjustmentIntervals, autoCollection, billingCycleAnchorConfiguration, billingCycleDay, createdAt, currentBillingPeriodEndDate, currentBillingPeriodStartDate, customer, defaultInvoiceMemo, discountIntervals, endDate, fixedFeeQuantitySchedule, invoicingThreshold, maximumIntervals, metadata, minimumIntervals, netTerms, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SubscriptionTriggerPhaseResponse{id=$id, activePlanPhaseOrder=$activePlanPhaseOrder, adjustmentIntervals=$adjustmentIntervals, autoCollection=$autoCollection, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, billingCycleDay=$billingCycleDay, createdAt=$createdAt, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, customer=$customer, defaultInvoiceMemo=$defaultInvoiceMemo, discountIntervals=$discountIntervals, endDate=$endDate, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, invoicingThreshold=$invoicingThreshold, maximumIntervals=$maximumIntervals, metadata=$metadata, minimumIntervals=$minimumIntervals, netTerms=$netTerms, plan=$plan, priceIntervals=$priceIntervals, redeemedCoupon=$redeemedCoupon, startDate=$startDate, status=$status, trialInfo=$trialInfo, additionalProperties=$additionalProperties}" -} 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 829f3a5c4..593f01f85 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 @@ -54,6 +54,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [SubscriptionUnscheduleCancellationParams]. + * + * The following fields are required: + * ```java + * .subscriptionId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationResponse.kt deleted file mode 100644 index c0a1ec5c8..000000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationResponse.kt +++ /dev/null @@ -1,7179 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer -import com.withorb.api.core.Enum -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow -import com.withorb.api.core.immutableEmptyMap -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -@NoAutoDetect -class SubscriptionUnscheduleCancellationResponse -@JsonCreator -private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("active_plan_phase_order") - @ExcludeMissing - private val activePlanPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_intervals") - @ExcludeMissing - private val adjustmentIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("auto_collection") - @ExcludeMissing - private val autoCollection: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_anchor_configuration") - @ExcludeMissing - private val billingCycleAnchorConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("billing_cycle_day") - @ExcludeMissing - private val billingCycleDay: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - private val currentBillingPeriodEndDate: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - private val currentBillingPeriodStartDate: JsonField = JsonMissing.of(), - @JsonProperty("customer") - @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), - @JsonProperty("default_invoice_memo") - @ExcludeMissing - private val defaultInvoiceMemo: JsonField = JsonMissing.of(), - @JsonProperty("discount_intervals") - @ExcludeMissing - private val discountIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("fixed_fee_quantity_schedule") - @ExcludeMissing - private val fixedFeeQuantitySchedule: JsonField> = - JsonMissing.of(), - @JsonProperty("invoicing_threshold") - @ExcludeMissing - private val invoicingThreshold: JsonField = JsonMissing.of(), - @JsonProperty("maximum_intervals") - @ExcludeMissing - private val maximumIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("minimum_intervals") - @ExcludeMissing - private val minimumIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("net_terms") - @ExcludeMissing - private val netTerms: JsonField = JsonMissing.of(), - @JsonProperty("plan") @ExcludeMissing private val plan: JsonField = JsonMissing.of(), - @JsonProperty("price_intervals") - @ExcludeMissing - private val priceIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("redeemed_coupon") - @ExcludeMissing - private val redeemedCoupon: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonProperty("status") - @ExcludeMissing - private val status: JsonField = JsonMissing.of(), - @JsonProperty("trial_info") - @ExcludeMissing - private val trialInfo: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun id(): String = id.getRequired("id") - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(): Optional = - Optional.ofNullable(activePlanPhaseOrder.getNullable("active_plan_phase_order")) - - /** The adjustment intervals for this subscription. */ - fun adjustmentIntervals(): List = - adjustmentIntervals.getRequired("adjustment_intervals") - - /** - * Determines whether issued invoices for this subscription will automatically be charged with - * the saved payment method on the due date. This property defaults to the plan's behavior. If - * null, defaults to the customer's setting. - */ - fun autoCollection(): Optional = - Optional.ofNullable(autoCollection.getNullable("auto_collection")) - - fun billingCycleAnchorConfiguration(): BillingCycleAnchorConfiguration = - billingCycleAnchorConfiguration.getRequired("billing_cycle_anchor_configuration") - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of days in - * a month is greater than this value, the last day of the month is the billing cycle day (e.g. - * billing_cycle_day=31 for April means the billing period begins on the 30th. - */ - fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the instant - * returned is not part of the billing period. Set to null for subscriptions that are not - * currently active. - */ - fun currentBillingPeriodEndDate(): Optional = - Optional.ofNullable( - currentBillingPeriodEndDate.getNullable("current_billing_period_end_date") - ) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription is - * not currently active. - */ - fun currentBillingPeriodStartDate(): Optional = - Optional.ofNullable( - currentBillingPeriodStartDate.getNullable("current_billing_period_start_date") - ) - - /** - * 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 customer(): Customer = customer.getRequired("customer") - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(): Optional = - Optional.ofNullable(defaultInvoiceMemo.getNullable("default_invoice_memo")) - - /** The discount intervals for this subscription. */ - fun discountIntervals(): List = - discountIntervals.getRequired("discount_intervals") - - /** The date Orb stops billing for this subscription. */ - fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) - - fun fixedFeeQuantitySchedule(): List = - fixedFeeQuantitySchedule.getRequired("fixed_fee_quantity_schedule") - - fun invoicingThreshold(): Optional = - Optional.ofNullable(invoicingThreshold.getNullable("invoicing_threshold")) - - /** The maximum intervals for this subscription. */ - fun maximumIntervals(): List = - maximumIntervals.getRequired("maximum_intervals") - - /** - * 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.getRequired("metadata") - - /** The minimum intervals for this subscription. */ - fun minimumIntervals(): List = - minimumIntervals.getRequired("minimum_intervals") - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - fun netTerms(): Long = netTerms.getRequired("net_terms") - - /** - * 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 plan(): Plan = plan.getRequired("plan") - - /** The price intervals for this subscription. */ - fun priceIntervals(): List = priceIntervals.getRequired("price_intervals") - - fun redeemedCoupon(): Optional = - Optional.ofNullable(redeemedCoupon.getNullable("redeemed_coupon")) - - /** The date Orb starts billing for this subscription. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - fun status(): Status = status.getRequired("status") - - fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - @JsonProperty("active_plan_phase_order") - @ExcludeMissing - fun _activePlanPhaseOrder(): JsonField = activePlanPhaseOrder - - /** The adjustment intervals for this subscription. */ - @JsonProperty("adjustment_intervals") - @ExcludeMissing - fun _adjustmentIntervals(): JsonField> = adjustmentIntervals - - /** - * Determines whether issued invoices for this subscription will automatically be charged with - * the saved payment method on the due date. This property defaults to the plan's behavior. If - * null, defaults to the customer's setting. - */ - @JsonProperty("auto_collection") - @ExcludeMissing - fun _autoCollection(): JsonField = autoCollection - - @JsonProperty("billing_cycle_anchor_configuration") - @ExcludeMissing - fun _billingCycleAnchorConfiguration(): JsonField = - billingCycleAnchorConfiguration - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of days in - * a month is greater than this value, the last day of the month is the billing cycle day (e.g. - * billing_cycle_day=31 for April means the billing period begins on the 30th. - */ - @JsonProperty("billing_cycle_day") - @ExcludeMissing - fun _billingCycleDay(): JsonField = billingCycleDay - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the instant - * returned is not part of the billing period. Set to null for subscriptions that are not - * currently active. - */ - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription is - * not currently active. - */ - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - fun _currentBillingPeriodStartDate(): JsonField = currentBillingPeriodStartDate - - /** - * 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. - */ - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - @JsonProperty("default_invoice_memo") - @ExcludeMissing - fun _defaultInvoiceMemo(): JsonField = defaultInvoiceMemo - - /** The discount intervals for this subscription. */ - @JsonProperty("discount_intervals") - @ExcludeMissing - fun _discountIntervals(): JsonField> = discountIntervals - - /** The date Orb stops billing for this subscription. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate - - @JsonProperty("fixed_fee_quantity_schedule") - @ExcludeMissing - fun _fixedFeeQuantitySchedule(): JsonField> = - fixedFeeQuantitySchedule - - @JsonProperty("invoicing_threshold") - @ExcludeMissing - fun _invoicingThreshold(): JsonField = invoicingThreshold - - /** The maximum intervals for this subscription. */ - @JsonProperty("maximum_intervals") - @ExcludeMissing - fun _maximumIntervals(): JsonField> = maximumIntervals - - /** - * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - /** The minimum intervals for this subscription. */ - @JsonProperty("minimum_intervals") - @ExcludeMissing - fun _minimumIntervals(): JsonField> = minimumIntervals - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms - - /** - * 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). - */ - @JsonProperty("plan") @ExcludeMissing fun _plan(): JsonField = plan - - /** The price intervals for this subscription. */ - @JsonProperty("price_intervals") - @ExcludeMissing - fun _priceIntervals(): JsonField> = priceIntervals - - @JsonProperty("redeemed_coupon") - @ExcludeMissing - fun _redeemedCoupon(): JsonField = redeemedCoupon - - /** The date Orb starts billing for this subscription. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo(): JsonField = trialInfo - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): SubscriptionUnscheduleCancellationResponse = apply { - if (validated) { - return@apply - } - - id() - activePlanPhaseOrder() - adjustmentIntervals().forEach { it.validate() } - autoCollection() - billingCycleAnchorConfiguration().validate() - billingCycleDay() - createdAt() - currentBillingPeriodEndDate() - currentBillingPeriodStartDate() - customer().validate() - defaultInvoiceMemo() - discountIntervals().forEach { it.validate() } - endDate() - fixedFeeQuantitySchedule().forEach { it.validate() } - invoicingThreshold() - maximumIntervals().forEach { it.validate() } - metadata().validate() - minimumIntervals().forEach { it.validate() } - netTerms() - plan().validate() - priceIntervals().forEach { it.validate() } - redeemedCoupon().ifPresent { it.validate() } - startDate() - status() - trialInfo().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SubscriptionUnscheduleCancellationResponse]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var activePlanPhaseOrder: JsonField? = null - private var adjustmentIntervals: JsonField>? = null - private var autoCollection: JsonField? = null - private var billingCycleAnchorConfiguration: JsonField? = - null - private var billingCycleDay: JsonField? = null - private var createdAt: JsonField? = null - private var currentBillingPeriodEndDate: JsonField? = null - private var currentBillingPeriodStartDate: JsonField? = null - private var customer: JsonField? = null - private var defaultInvoiceMemo: JsonField? = null - private var discountIntervals: JsonField>? = null - private var endDate: JsonField? = null - private var fixedFeeQuantitySchedule: JsonField>? = - null - private var invoicingThreshold: JsonField? = null - private var maximumIntervals: JsonField>? = null - private var metadata: JsonField? = null - private var minimumIntervals: JsonField>? = null - private var netTerms: JsonField? = null - private var plan: JsonField? = null - private var priceIntervals: JsonField>? = null - private var redeemedCoupon: JsonField? = null - private var startDate: JsonField? = null - private var status: JsonField? = null - private var trialInfo: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - subscriptionUnscheduleCancellationResponse: SubscriptionUnscheduleCancellationResponse - ) = apply { - id = subscriptionUnscheduleCancellationResponse.id - activePlanPhaseOrder = subscriptionUnscheduleCancellationResponse.activePlanPhaseOrder - adjustmentIntervals = - subscriptionUnscheduleCancellationResponse.adjustmentIntervals.map { - it.toMutableList() - } - autoCollection = subscriptionUnscheduleCancellationResponse.autoCollection - billingCycleAnchorConfiguration = - subscriptionUnscheduleCancellationResponse.billingCycleAnchorConfiguration - billingCycleDay = subscriptionUnscheduleCancellationResponse.billingCycleDay - createdAt = subscriptionUnscheduleCancellationResponse.createdAt - currentBillingPeriodEndDate = - subscriptionUnscheduleCancellationResponse.currentBillingPeriodEndDate - currentBillingPeriodStartDate = - subscriptionUnscheduleCancellationResponse.currentBillingPeriodStartDate - customer = subscriptionUnscheduleCancellationResponse.customer - defaultInvoiceMemo = subscriptionUnscheduleCancellationResponse.defaultInvoiceMemo - discountIntervals = - subscriptionUnscheduleCancellationResponse.discountIntervals.map { - it.toMutableList() - } - endDate = subscriptionUnscheduleCancellationResponse.endDate - fixedFeeQuantitySchedule = - subscriptionUnscheduleCancellationResponse.fixedFeeQuantitySchedule.map { - it.toMutableList() - } - invoicingThreshold = subscriptionUnscheduleCancellationResponse.invoicingThreshold - maximumIntervals = - subscriptionUnscheduleCancellationResponse.maximumIntervals.map { - it.toMutableList() - } - metadata = subscriptionUnscheduleCancellationResponse.metadata - minimumIntervals = - subscriptionUnscheduleCancellationResponse.minimumIntervals.map { - it.toMutableList() - } - netTerms = subscriptionUnscheduleCancellationResponse.netTerms - plan = subscriptionUnscheduleCancellationResponse.plan - priceIntervals = - subscriptionUnscheduleCancellationResponse.priceIntervals.map { it.toMutableList() } - redeemedCoupon = subscriptionUnscheduleCancellationResponse.redeemedCoupon - startDate = subscriptionUnscheduleCancellationResponse.startDate - status = subscriptionUnscheduleCancellationResponse.status - trialInfo = subscriptionUnscheduleCancellationResponse.trialInfo - additionalProperties = - subscriptionUnscheduleCancellationResponse.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(activePlanPhaseOrder: Long?) = - activePlanPhaseOrder(JsonField.ofNullable(activePlanPhaseOrder)) - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(activePlanPhaseOrder: Long) = - activePlanPhaseOrder(activePlanPhaseOrder as Long?) - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun activePlanPhaseOrder(activePlanPhaseOrder: Optional) = - activePlanPhaseOrder(activePlanPhaseOrder.orElse(null) as Long?) - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(activePlanPhaseOrder: JsonField) = apply { - this.activePlanPhaseOrder = activePlanPhaseOrder - } - - /** The adjustment intervals for this subscription. */ - fun adjustmentIntervals(adjustmentIntervals: List) = - adjustmentIntervals(JsonField.of(adjustmentIntervals)) - - /** The adjustment intervals for this subscription. */ - fun adjustmentIntervals(adjustmentIntervals: JsonField>) = apply { - this.adjustmentIntervals = adjustmentIntervals.map { it.toMutableList() } - } - - /** The adjustment intervals for this subscription. */ - fun addAdjustmentInterval(adjustmentInterval: AdjustmentInterval) = apply { - adjustmentIntervals = - (adjustmentIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(adjustmentInterval) - } - } - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - fun autoCollection(autoCollection: Boolean?) = - autoCollection(JsonField.ofNullable(autoCollection)) - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun autoCollection(autoCollection: Optional) = - autoCollection(autoCollection.orElse(null) as Boolean?) - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - fun autoCollection(autoCollection: JsonField) = apply { - this.autoCollection = autoCollection - } - - fun billingCycleAnchorConfiguration( - billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration - ) = billingCycleAnchorConfiguration(JsonField.of(billingCycleAnchorConfiguration)) - - fun billingCycleAnchorConfiguration( - billingCycleAnchorConfiguration: JsonField - ) = apply { this.billingCycleAnchorConfiguration = billingCycleAnchorConfiguration } - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun billingCycleDay(billingCycleDay: Long) = billingCycleDay(JsonField.of(billingCycleDay)) - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun billingCycleDay(billingCycleDay: JsonField) = apply { - this.billingCycleDay = billingCycleDay - } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is not part of the billing period. Set to null for subscriptions that - * are not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = - currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is not part of the billing period. Set to null for subscriptions that - * are not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = - currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is not part of the billing period. Set to null for subscriptions that - * are not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: JsonField) = - apply { - this.currentBillingPeriodEndDate = currentBillingPeriodEndDate - } - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription - * is not currently active. - */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = - currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription - * is not currently active. - */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: Optional) = - currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription - * is not currently active. - */ - fun currentBillingPeriodStartDate( - currentBillingPeriodStartDate: JsonField - ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } - - /** - * 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 customer(customer: Customer) = customer(JsonField.of(customer)) - - /** - * 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 customer(customer: JsonField) = apply { this.customer = customer } - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(defaultInvoiceMemo: String?) = - defaultInvoiceMemo(JsonField.ofNullable(defaultInvoiceMemo)) - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(defaultInvoiceMemo: Optional) = - defaultInvoiceMemo(defaultInvoiceMemo.orElse(null)) - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(defaultInvoiceMemo: JsonField) = apply { - this.defaultInvoiceMemo = defaultInvoiceMemo - } - - /** The discount intervals for this subscription. */ - fun discountIntervals(discountIntervals: List) = - discountIntervals(JsonField.of(discountIntervals)) - - /** The discount intervals for this subscription. */ - fun discountIntervals(discountIntervals: JsonField>) = apply { - this.discountIntervals = discountIntervals.map { it.toMutableList() } - } - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(discountInterval: DiscountInterval) = apply { - discountIntervals = - (discountIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(discountInterval) - } - } - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(amount: DiscountInterval.AmountDiscountInterval) = - addDiscountInterval(DiscountInterval.ofAmount(amount)) - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(percentage: DiscountInterval.PercentageDiscountInterval) = - addDiscountInterval(DiscountInterval.ofPercentage(percentage)) - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(usage: DiscountInterval.UsageDiscountInterval) = - addDiscountInterval(DiscountInterval.ofUsage(usage)) - - /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - fun fixedFeeQuantitySchedule(fixedFeeQuantitySchedule: List) = - fixedFeeQuantitySchedule(JsonField.of(fixedFeeQuantitySchedule)) - - fun fixedFeeQuantitySchedule( - fixedFeeQuantitySchedule: JsonField> - ) = apply { - this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule.map { it.toMutableList() } - } - - fun addFixedFeeQuantitySchedule(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = - apply { - this.fixedFeeQuantitySchedule = - (this.fixedFeeQuantitySchedule ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(fixedFeeQuantitySchedule) - } - } - - fun invoicingThreshold(invoicingThreshold: String?) = - invoicingThreshold(JsonField.ofNullable(invoicingThreshold)) - - fun invoicingThreshold(invoicingThreshold: Optional) = - invoicingThreshold(invoicingThreshold.orElse(null)) - - fun invoicingThreshold(invoicingThreshold: JsonField) = apply { - this.invoicingThreshold = invoicingThreshold - } - - /** The maximum intervals for this subscription. */ - fun maximumIntervals(maximumIntervals: List) = - maximumIntervals(JsonField.of(maximumIntervals)) - - /** The maximum intervals for this subscription. */ - fun maximumIntervals(maximumIntervals: JsonField>) = apply { - this.maximumIntervals = maximumIntervals.map { it.toMutableList() } - } - - /** The maximum intervals for this subscription. */ - fun addMaximumInterval(maximumInterval: MaximumInterval) = apply { - maximumIntervals = - (maximumIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(maximumInterval) - } - } - - /** - * 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - /** The minimum intervals for this subscription. */ - fun minimumIntervals(minimumIntervals: List) = - minimumIntervals(JsonField.of(minimumIntervals)) - - /** The minimum intervals for this subscription. */ - fun minimumIntervals(minimumIntervals: JsonField>) = apply { - this.minimumIntervals = minimumIntervals.map { it.toMutableList() } - } - - /** The minimum intervals for this subscription. */ - fun addMinimumInterval(minimumInterval: MinimumInterval) = apply { - minimumIntervals = - (minimumIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(minimumInterval) - } - } - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - fun netTerms(netTerms: Long) = netTerms(JsonField.of(netTerms)) - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } - - /** - * 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 plan(plan: Plan) = plan(JsonField.of(plan)) - - /** - * 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 plan(plan: JsonField) = apply { this.plan = plan } - - /** The price intervals for this subscription. */ - fun priceIntervals(priceIntervals: List) = - priceIntervals(JsonField.of(priceIntervals)) - - /** The price intervals for this subscription. */ - fun priceIntervals(priceIntervals: JsonField>) = apply { - this.priceIntervals = priceIntervals.map { it.toMutableList() } - } - - /** The price intervals for this subscription. */ - fun addPriceInterval(priceInterval: PriceInterval) = apply { - priceIntervals = - (priceIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(priceInterval) - } - } - - fun redeemedCoupon(redeemedCoupon: RedeemedCoupon?) = - redeemedCoupon(JsonField.ofNullable(redeemedCoupon)) - - fun redeemedCoupon(redeemedCoupon: Optional) = - redeemedCoupon(redeemedCoupon.orElse(null)) - - fun redeemedCoupon(redeemedCoupon: JsonField) = apply { - this.redeemedCoupon = redeemedCoupon - } - - /** The date Orb starts billing for this subscription. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The date Orb starts billing for this subscription. */ - fun startDate(startDate: JsonField) = apply { this.startDate = startDate } - - fun status(status: Status) = status(JsonField.of(status)) - - fun status(status: JsonField) = apply { this.status = status } - - fun trialInfo(trialInfo: TrialInfo) = trialInfo(JsonField.of(trialInfo)) - - fun trialInfo(trialInfo: JsonField) = apply { this.trialInfo = trialInfo } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): SubscriptionUnscheduleCancellationResponse = - SubscriptionUnscheduleCancellationResponse( - checkRequired("id", id), - checkRequired("activePlanPhaseOrder", activePlanPhaseOrder), - checkRequired("adjustmentIntervals", adjustmentIntervals).map { it.toImmutable() }, - checkRequired("autoCollection", autoCollection), - checkRequired("billingCycleAnchorConfiguration", billingCycleAnchorConfiguration), - checkRequired("billingCycleDay", billingCycleDay), - checkRequired("createdAt", createdAt), - checkRequired("currentBillingPeriodEndDate", currentBillingPeriodEndDate), - checkRequired("currentBillingPeriodStartDate", currentBillingPeriodStartDate), - checkRequired("customer", customer), - checkRequired("defaultInvoiceMemo", defaultInvoiceMemo), - checkRequired("discountIntervals", discountIntervals).map { it.toImmutable() }, - checkRequired("endDate", endDate), - checkRequired("fixedFeeQuantitySchedule", fixedFeeQuantitySchedule).map { - it.toImmutable() - }, - checkRequired("invoicingThreshold", invoicingThreshold), - checkRequired("maximumIntervals", maximumIntervals).map { it.toImmutable() }, - checkRequired("metadata", metadata), - checkRequired("minimumIntervals", minimumIntervals).map { it.toImmutable() }, - checkRequired("netTerms", netTerms), - checkRequired("plan", plan), - checkRequired("priceIntervals", priceIntervals).map { it.toImmutable() }, - checkRequired("redeemedCoupon", redeemedCoupon), - checkRequired("startDate", startDate), - checkRequired("status", status), - checkRequired("trialInfo", trialInfo), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class AdjustmentInterval - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment") - @ExcludeMissing - private val adjustment: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") - - /** The price interval IDs that this adjustment applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - /** The end date of the adjustment interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** The start date of the adjustment interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment - - /** The price interval IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - /** The end date of the adjustment interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** The start date of the adjustment interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AdjustmentInterval = apply { - if (validated) { - return@apply - } - - id() - adjustment().validate() - appliesToPriceIntervalIds() - endDate() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AdjustmentInterval]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustment: JsonField? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(adjustmentInterval: AdjustmentInterval) = apply { - id = adjustmentInterval.id - adjustment = adjustmentInterval.adjustment - appliesToPriceIntervalIds = - adjustmentInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - endDate = adjustmentInterval.endDate - startDate = adjustmentInterval.startDate - additionalProperties = adjustmentInterval.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) - - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } - - fun adjustment(planPhaseUsageDiscount: Adjustment.PlanPhaseUsageDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)) - - fun adjustment(planPhaseAmountDiscount: Adjustment.PlanPhaseAmountDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)) - - fun adjustment( - planPhasePercentageDiscount: Adjustment.PlanPhasePercentageDiscountAdjustment - ) = adjustment(Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)) - - fun adjustment(planPhaseMinimum: Adjustment.PlanPhaseMinimumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)) - - fun adjustment(planPhaseMaximum: Adjustment.PlanPhaseMaximumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)) - - /** The price interval IDs that this adjustment applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval IDs that this adjustment applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval IDs that this adjustment applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - /** The end date of the adjustment interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the adjustment interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the adjustment interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** The start date of the adjustment interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the adjustment interval. */ - 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) - } - - fun build(): AdjustmentInterval = - AdjustmentInterval( - checkRequired("id", id), - checkRequired("adjustment", adjustment), - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment? = null, - private val planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment? = null, - private val planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment? = null, - private val planPhaseMinimum: PlanPhaseMinimumAdjustment? = null, - private val planPhaseMaximum: PlanPhaseMaximumAdjustment? = null, - private val _json: JsonValue? = null, - ) { - - fun planPhaseUsageDiscount(): Optional = - Optional.ofNullable(planPhaseUsageDiscount) - - fun planPhaseAmountDiscount(): Optional = - Optional.ofNullable(planPhaseAmountDiscount) - - fun planPhasePercentageDiscount(): Optional = - Optional.ofNullable(planPhasePercentageDiscount) - - fun planPhaseMinimum(): Optional = - Optional.ofNullable(planPhaseMinimum) - - fun planPhaseMaximum(): Optional = - Optional.ofNullable(planPhaseMaximum) - - fun isPlanPhaseUsageDiscount(): Boolean = planPhaseUsageDiscount != null - - fun isPlanPhaseAmountDiscount(): Boolean = planPhaseAmountDiscount != null - - fun isPlanPhasePercentageDiscount(): Boolean = planPhasePercentageDiscount != null - - fun isPlanPhaseMinimum(): Boolean = planPhaseMinimum != null - - fun isPlanPhaseMaximum(): Boolean = planPhaseMaximum != null - - fun asPlanPhaseUsageDiscount(): PlanPhaseUsageDiscountAdjustment = - planPhaseUsageDiscount.getOrThrow("planPhaseUsageDiscount") - - fun asPlanPhaseAmountDiscount(): PlanPhaseAmountDiscountAdjustment = - planPhaseAmountDiscount.getOrThrow("planPhaseAmountDiscount") - - fun asPlanPhasePercentageDiscount(): PlanPhasePercentageDiscountAdjustment = - planPhasePercentageDiscount.getOrThrow("planPhasePercentageDiscount") - - fun asPlanPhaseMinimum(): PlanPhaseMinimumAdjustment = - planPhaseMinimum.getOrThrow("planPhaseMinimum") - - fun asPlanPhaseMaximum(): PlanPhaseMaximumAdjustment = - planPhaseMaximum.getOrThrow("planPhaseMaximum") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - planPhaseUsageDiscount != null -> - visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) - planPhaseAmountDiscount != null -> - visitor.visitPlanPhaseAmountDiscount(planPhaseAmountDiscount) - planPhasePercentageDiscount != null -> - visitor.visitPlanPhasePercentageDiscount(planPhasePercentageDiscount) - planPhaseMinimum != null -> visitor.visitPlanPhaseMinimum(planPhaseMinimum) - planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) { - planPhaseUsageDiscount.validate() - } - - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) { - planPhaseAmountDiscount.validate() - } - - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) { - planPhasePercentageDiscount.validate() - } - - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) { - planPhaseMinimum.validate() - } - - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) { - planPhaseMaximum.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Adjustment && planPhaseUsageDiscount == other.planPhaseUsageDiscount && planPhaseAmountDiscount == other.planPhaseAmountDiscount && planPhasePercentageDiscount == other.planPhasePercentageDiscount && planPhaseMinimum == other.planPhaseMinimum && planPhaseMaximum == other.planPhaseMaximum /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(planPhaseUsageDiscount, planPhaseAmountDiscount, planPhasePercentageDiscount, planPhaseMinimum, planPhaseMaximum) /* spotless:on */ - - override fun toString(): String = - when { - planPhaseUsageDiscount != null -> - "Adjustment{planPhaseUsageDiscount=$planPhaseUsageDiscount}" - planPhaseAmountDiscount != null -> - "Adjustment{planPhaseAmountDiscount=$planPhaseAmountDiscount}" - planPhasePercentageDiscount != null -> - "Adjustment{planPhasePercentageDiscount=$planPhasePercentageDiscount}" - planPhaseMinimum != null -> "Adjustment{planPhaseMinimum=$planPhaseMinimum}" - planPhaseMaximum != null -> "Adjustment{planPhaseMaximum=$planPhaseMaximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } - - companion object { - - @JvmStatic - fun ofPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = Adjustment(planPhaseUsageDiscount = planPhaseUsageDiscount) - - @JvmStatic - fun ofPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = Adjustment(planPhaseAmountDiscount = planPhaseAmountDiscount) - - @JvmStatic - fun ofPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = Adjustment(planPhasePercentageDiscount = planPhasePercentageDiscount) - - @JvmStatic - fun ofPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment) = - Adjustment(planPhaseMinimum = planPhaseMinimum) - - @JvmStatic - fun ofPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment) = - Adjustment(planPhaseMaximum = planPhaseMaximum) - } - - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { - - fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ): T - - fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ): T - - fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ): T - - fun visitPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment): T - - fun visitPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment): T - - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } - - internal class Deserializer : BaseDeserializer(Adjustment::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = - json.asObject().getOrNull()?.get("adjustment_type")?.asString()?.getOrNull() - - when (adjustmentType) { - "usage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseUsageDiscount = it, _json = json) - } - } - "amount_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseAmountDiscount = it, _json = json) - } - } - "percentage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment( - planPhasePercentageDiscount = it, - _json = json, - ) - } - } - "minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMinimum = it, _json = json) - } - } - "maximum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMaximum = it, _json = json) - } - } - } - - return Adjustment(_json = json) - } - } - - internal class Serializer : BaseSerializer(Adjustment::class) { - - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.planPhaseUsageDiscount != null -> - generator.writeObject(value.planPhaseUsageDiscount) - value.planPhaseAmountDiscount != null -> - generator.writeObject(value.planPhaseAmountDiscount) - value.planPhasePercentageDiscount != null -> - generator.writeObject(value.planPhasePercentageDiscount) - value.planPhaseMinimum != null -> - generator.writeObject(value.planPhaseMinimum) - value.planPhaseMaximum != null -> - generator.writeObject(value.planPhaseMaximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") - } - } - } - - @NoAutoDetect - class PlanPhaseUsageDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonProperty("usage_discount") - @ExcludeMissing - private val usageDiscount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - /** - * The number of usage units by which to discount the price this adjustment applies - * to in a given billing period. - */ - fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - /** - * The number of usage units by which to discount the price this adjustment applies - * to in a given billing period. - */ - @JsonProperty("usage_discount") - @ExcludeMissing - fun _usageDiscount(): JsonField = usageDiscount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseUsageDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - planPhaseOrder() - reason() - usageDiscount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseUsageDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var usageDiscount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - planPhaseUsageDiscountAdjustment: PlanPhaseUsageDiscountAdjustment - ) = apply { - id = planPhaseUsageDiscountAdjustment.id - adjustmentType = planPhaseUsageDiscountAdjustment.adjustmentType - appliesToPriceIds = - planPhaseUsageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseUsageDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseUsageDiscountAdjustment.planPhaseOrder - reason = planPhaseUsageDiscountAdjustment.reason - usageDiscount = planPhaseUsageDiscountAdjustment.usageDiscount - additionalProperties = - planPhaseUsageDiscountAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - /** - * The number of usage units by which to discount the price this adjustment - * applies to in a given billing period. - */ - fun usageDiscount(usageDiscount: Double) = - usageDiscount(JsonField.of(usageDiscount)) - - /** - * The number of usage units by which to discount the price this adjustment - * applies to in a given billing period. - */ - fun usageDiscount(usageDiscount: JsonField) = apply { - this.usageDiscount = usageDiscount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseUsageDiscountAdjustment = - PlanPhaseUsageDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - checkRequired("usageDiscount", usageDiscount), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - USAGE_DISCOUNT -> Known.USAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseUsageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, planPhaseOrder, reason, usageDiscount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseUsageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhaseAmountDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("amount_discount") - @ExcludeMissing - private val amountDiscount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** - * The amount by which to discount the prices this adjustment applies to in a given - * billing period. - */ - fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** - * The amount by which to discount the prices this adjustment applies to in a given - * billing period. - */ - @JsonProperty("amount_discount") - @ExcludeMissing - fun _amountDiscount(): JsonField = amountDiscount - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseAmountDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - amountDiscount() - appliesToPriceIds() - isInvoiceLevel() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseAmountDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var amountDiscount: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - planPhaseAmountDiscountAdjustment: PlanPhaseAmountDiscountAdjustment - ) = apply { - id = planPhaseAmountDiscountAdjustment.id - adjustmentType = planPhaseAmountDiscountAdjustment.adjustmentType - amountDiscount = planPhaseAmountDiscountAdjustment.amountDiscount - appliesToPriceIds = - planPhaseAmountDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseAmountDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseAmountDiscountAdjustment.planPhaseOrder - reason = planPhaseAmountDiscountAdjustment.reason - additionalProperties = - planPhaseAmountDiscountAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** - * The amount by which to discount the prices this adjustment applies to in a - * given billing period. - */ - fun amountDiscount(amountDiscount: String) = - amountDiscount(JsonField.of(amountDiscount)) - - /** - * The amount by which to discount the prices this adjustment applies to in a - * given billing period. - */ - fun amountDiscount(amountDiscount: JsonField) = apply { - this.amountDiscount = amountDiscount - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseAmountDiscountAdjustment = - PlanPhaseAmountDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("amountDiscount", amountDiscount), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseAmountDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, amountDiscount, appliesToPriceIds, isInvoiceLevel, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseAmountDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhasePercentageDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("percentage_discount") - @ExcludeMissing - private val percentageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(): Double = - percentageDiscount.getRequired("percentage_discount") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - @JsonProperty("percentage_discount") - @ExcludeMissing - fun _percentageDiscount(): JsonField = percentageDiscount - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhasePercentageDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - percentageDiscount() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhasePercentageDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var percentageDiscount: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - planPhasePercentageDiscountAdjustment: PlanPhasePercentageDiscountAdjustment - ) = apply { - id = planPhasePercentageDiscountAdjustment.id - adjustmentType = planPhasePercentageDiscountAdjustment.adjustmentType - appliesToPriceIds = - planPhasePercentageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhasePercentageDiscountAdjustment.isInvoiceLevel - percentageDiscount = - planPhasePercentageDiscountAdjustment.percentageDiscount - planPhaseOrder = planPhasePercentageDiscountAdjustment.planPhaseOrder - reason = planPhasePercentageDiscountAdjustment.reason - additionalProperties = - planPhasePercentageDiscountAdjustment.additionalProperties - .toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(percentageDiscount: Double) = - percentageDiscount(JsonField.of(percentageDiscount)) - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(percentageDiscount: JsonField) = apply { - this.percentageDiscount = percentageDiscount - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhasePercentageDiscountAdjustment = - PlanPhasePercentageDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("percentageDiscount", percentageDiscount), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val PERCENTAGE_DISCOUNT = of("percentage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhasePercentageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, percentageDiscount, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhasePercentageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhaseMinimumAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(): String = itemId.getRequired("item_id") - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The item ID that revenue from this minimum will be attributed to. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseMinimumAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - itemId() - minimumAmount() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseMinimumAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var itemId: JsonField? = null - private var minimumAmount: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(planPhaseMinimumAdjustment: PlanPhaseMinimumAdjustment) = - apply { - id = planPhaseMinimumAdjustment.id - adjustmentType = planPhaseMinimumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMinimumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMinimumAdjustment.isInvoiceLevel - itemId = planPhaseMinimumAdjustment.itemId - minimumAmount = planPhaseMinimumAdjustment.minimumAmount - planPhaseOrder = planPhaseMinimumAdjustment.planPhaseOrder - reason = planPhaseMinimumAdjustment.reason - additionalProperties = - planPhaseMinimumAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseMinimumAdjustment = - PlanPhaseMinimumAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("itemId", itemId), - checkRequired("minimumAmount", minimumAmount), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseMinimumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, itemId, minimumAmount, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseMinimumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhaseMaximumAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseMaximumAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - maximumAmount() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseMaximumAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var maximumAmount: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(planPhaseMaximumAdjustment: PlanPhaseMaximumAdjustment) = - apply { - id = planPhaseMaximumAdjustment.id - adjustmentType = planPhaseMaximumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMaximumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMaximumAdjustment.isInvoiceLevel - maximumAmount = planPhaseMaximumAdjustment.maximumAmount - planPhaseOrder = planPhaseMaximumAdjustment.planPhaseOrder - reason = planPhaseMaximumAdjustment.reason - additionalProperties = - planPhaseMaximumAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseMaximumAdjustment = - PlanPhaseMaximumAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("maximumAmount", maximumAmount), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseMaximumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, maximumAmount, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseMaximumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentInterval && id == other.id && adjustment == other.adjustment && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustment, appliesToPriceIntervalIds, endDate, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AdjustmentInterval{id=$id, adjustment=$adjustment, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BillingCycleAnchorConfiguration - @JsonCreator - private constructor( - @JsonProperty("day") @ExcludeMissing private val day: JsonField = JsonMissing.of(), - @JsonProperty("month") - @ExcludeMissing - private val month: JsonField = JsonMissing.of(), - @JsonProperty("year") @ExcludeMissing private val year: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun day(): Long = day.getRequired("day") - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(): Optional = Optional.ofNullable(month.getNullable("month")) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on - * 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(): Optional = Optional.ofNullable(year.getNullable("year")) - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - @JsonProperty("day") @ExcludeMissing fun _day(): JsonField = day - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - @JsonProperty("month") @ExcludeMissing fun _month(): JsonField = month - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on - * 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - @JsonProperty("year") @ExcludeMissing fun _year(): JsonField = year - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleAnchorConfiguration = apply { - if (validated) { - return@apply - } - - day() - month() - year() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleAnchorConfiguration]. */ - class Builder internal constructor() { - - private var day: JsonField? = null - private var month: JsonField = JsonMissing.of() - private var year: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration) = - apply { - day = billingCycleAnchorConfiguration.day - month = billingCycleAnchorConfiguration.month - year = billingCycleAnchorConfiguration.year - additionalProperties = - billingCycleAnchorConfiguration.additionalProperties.toMutableMap() - } - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun day(day: Long) = day(JsonField.of(day)) - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun day(day: JsonField) = apply { this.day = day } - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(month: Long?) = month(JsonField.ofNullable(month)) - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(month: Long) = month(month as Long?) - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun month(month: Optional) = month(month.orElse(null) as Long?) - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(month: JsonField) = apply { this.month = month } - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(year: Long?) = year(JsonField.ofNullable(year)) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(year: Long) = year(year as Long?) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun year(year: Optional) = year(year.orElse(null) as Long?) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(year: JsonField) = apply { this.year = year } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleAnchorConfiguration = - BillingCycleAnchorConfiguration( - checkRequired("day", day), - month, - year, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleAnchorConfiguration && day == other.day && month == other.month && year == other.year && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(day, month, year, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleAnchorConfiguration{day=$day, month=$month, year=$year, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(using = DiscountInterval.Deserializer::class) - @JsonSerialize(using = DiscountInterval.Serializer::class) - class DiscountInterval - private constructor( - private val amount: AmountDiscountInterval? = null, - private val percentage: PercentageDiscountInterval? = null, - private val usage: UsageDiscountInterval? = null, - private val _json: JsonValue? = null, - ) { - - fun amount(): Optional = Optional.ofNullable(amount) - - fun percentage(): Optional = Optional.ofNullable(percentage) - - fun usage(): Optional = Optional.ofNullable(usage) - - fun isAmount(): Boolean = amount != null - - fun isPercentage(): Boolean = percentage != null - - fun isUsage(): Boolean = usage != null - - fun asAmount(): AmountDiscountInterval = amount.getOrThrow("amount") - - fun asPercentage(): PercentageDiscountInterval = percentage.getOrThrow("percentage") - - fun asUsage(): UsageDiscountInterval = usage.getOrThrow("usage") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - amount != null -> visitor.visitAmount(amount) - percentage != null -> visitor.visitPercentage(percentage) - usage != null -> visitor.visitUsage(usage) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): DiscountInterval = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitAmount(amount: AmountDiscountInterval) { - amount.validate() - } - - override fun visitPercentage(percentage: PercentageDiscountInterval) { - percentage.validate() - } - - override fun visitUsage(usage: UsageDiscountInterval) { - usage.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountInterval && amount == other.amount && percentage == other.percentage && usage == other.usage /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(amount, percentage, usage) /* spotless:on */ - - override fun toString(): String = - when { - amount != null -> "DiscountInterval{amount=$amount}" - percentage != null -> "DiscountInterval{percentage=$percentage}" - usage != null -> "DiscountInterval{usage=$usage}" - _json != null -> "DiscountInterval{_unknown=$_json}" - else -> throw IllegalStateException("Invalid DiscountInterval") - } - - companion object { - - @JvmStatic - fun ofAmount(amount: AmountDiscountInterval) = DiscountInterval(amount = amount) - - @JvmStatic - fun ofPercentage(percentage: PercentageDiscountInterval) = - DiscountInterval(percentage = percentage) - - @JvmStatic fun ofUsage(usage: UsageDiscountInterval) = DiscountInterval(usage = usage) - } - - /** - * An interface that defines how to map each variant of [DiscountInterval] to a value of - * type [T]. - */ - interface Visitor { - - fun visitAmount(amount: AmountDiscountInterval): T - - fun visitPercentage(percentage: PercentageDiscountInterval): T - - fun visitUsage(usage: UsageDiscountInterval): T - - /** - * Maps an unknown variant of [DiscountInterval] to a value of type [T]. - * - * An instance of [DiscountInterval] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown DiscountInterval: $json") - } - } - - internal class Deserializer : BaseDeserializer(DiscountInterval::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): DiscountInterval { - val json = JsonValue.fromJsonNode(node) - val discountType = - json.asObject().getOrNull()?.get("discount_type")?.asString()?.getOrNull() - - when (discountType) { - "amount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(amount = it, _json = json) - } - } - "percentage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(percentage = it, _json = json) - } - } - "usage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(usage = it, _json = json) - } - } - } - - return DiscountInterval(_json = json) - } - } - - internal class Serializer : BaseSerializer(DiscountInterval::class) { - - override fun serialize( - value: DiscountInterval, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.amount != null -> generator.writeObject(value.amount) - value.percentage != null -> generator.writeObject(value.percentage) - value.usage != null -> generator.writeObject(value.usage) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid DiscountInterval") - } - } - } - - @NoAutoDetect - class AmountDiscountInterval - @JsonCreator - private constructor( - @JsonProperty("amount_discount") - @ExcludeMissing - private val amountDiscount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("discount_type") - @ExcludeMissing - private val discountType: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - fun discountType(): DiscountType = discountType.getRequired("discount_type") - - /** The end date of the discount interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** The start date of the discount interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** Only available if discount_type is `amount`. */ - @JsonProperty("amount_discount") - @ExcludeMissing - fun _amountDiscount(): JsonField = amountDiscount - - /** The price ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - - /** The end date of the discount interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** The start date of the discount interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AmountDiscountInterval = apply { - if (validated) { - return@apply - } - - amountDiscount() - appliesToPriceIds() - appliesToPriceIntervalIds() - discountType() - endDate() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AmountDiscountInterval]. */ - class Builder internal constructor() { - - private var amountDiscount: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { - amountDiscount = amountDiscountInterval.amountDiscount - appliesToPriceIds = - amountDiscountInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - amountDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = amountDiscountInterval.discountType - endDate = amountDiscountInterval.endDate - startDate = amountDiscountInterval.startDate - additionalProperties = - amountDiscountInterval.additionalProperties.toMutableMap() - } - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(amountDiscount: String) = - amountDiscount(JsonField.of(amountDiscount)) - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(amountDiscount: JsonField) = apply { - this.amountDiscount = amountDiscount - } - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this discount interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this discount interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the discount interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the discount interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** The start date of the discount interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the discount interval. */ - 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) - } - - fun build(): AmountDiscountInterval = - AmountDiscountInterval( - checkRequired("amountDiscount", amountDiscount), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("discountType", discountType), - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val AMOUNT = of("amount") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - AMOUNT - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT -> Value.AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AMOUNT -> Known.AMOUNT - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AmountDiscountInterval && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amountDiscount, appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AmountDiscountInterval{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PercentageDiscountInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("discount_type") - @ExcludeMissing - private val discountType: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("percentage_discount") - @ExcludeMissing - private val percentageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - fun discountType(): DiscountType = discountType.getRequired("discount_type") - - /** The end date of the discount interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ - fun percentageDiscount(): Double = percentageDiscount.getRequired("percentage_discount") - - /** The start date of the discount interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** The price ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - - /** The end date of the discount interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ - @JsonProperty("percentage_discount") - @ExcludeMissing - fun _percentageDiscount(): JsonField = percentageDiscount - - /** The start date of the discount interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PercentageDiscountInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - discountType() - endDate() - percentageDiscount() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PercentageDiscountInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null - private var endDate: JsonField? = null - private var percentageDiscount: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { - appliesToPriceIds = - percentageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - percentageDiscountInterval.appliesToPriceIntervalIds.map { - it.toMutableList() - } - discountType = percentageDiscountInterval.discountType - endDate = percentageDiscountInterval.endDate - percentageDiscount = percentageDiscountInterval.percentageDiscount - startDate = percentageDiscountInterval.startDate - additionalProperties = - percentageDiscountInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this discount interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this discount interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the discount interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the discount interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** - * Only available if discount_type is `percentage`.This is a number between 0 and 1. - */ - fun percentageDiscount(percentageDiscount: Double) = - percentageDiscount(JsonField.of(percentageDiscount)) - - /** - * Only available if discount_type is `percentage`.This is a number between 0 and 1. - */ - fun percentageDiscount(percentageDiscount: JsonField) = apply { - this.percentageDiscount = percentageDiscount - } - - /** The start date of the discount interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the discount interval. */ - 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) - } - - fun build(): PercentageDiscountInterval = - PercentageDiscountInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("discountType", discountType), - checkRequired("endDate", endDate), - checkRequired("percentageDiscount", percentageDiscount), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val PERCENTAGE = of("percentage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - PERCENTAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE -> Value.PERCENTAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PERCENTAGE -> Known.PERCENTAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PercentageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, percentageDiscount, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PercentageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class UsageDiscountInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("discount_type") - @ExcludeMissing - private val discountType: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonProperty("usage_discount") - @ExcludeMissing - private val usageDiscount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - fun discountType(): DiscountType = discountType.getRequired("discount_type") - - /** The end date of the discount interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** The start date of the discount interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** - * Only available if discount_type is `usage`. Number of usage units that this discount - * is for - */ - fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - - /** The price ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - - /** The end date of the discount interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** The start date of the discount interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - /** - * Only available if discount_type is `usage`. Number of usage units that this discount - * is for - */ - @JsonProperty("usage_discount") - @ExcludeMissing - fun _usageDiscount(): JsonField = usageDiscount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): UsageDiscountInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - discountType() - endDate() - startDate() - usageDiscount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UsageDiscountInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var usageDiscount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { - appliesToPriceIds = - usageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - usageDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = usageDiscountInterval.discountType - endDate = usageDiscountInterval.endDate - startDate = usageDiscountInterval.startDate - usageDiscount = usageDiscountInterval.usageDiscount - additionalProperties = usageDiscountInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this discount interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this discount interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the discount interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the discount interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** The start date of the discount interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the discount interval. */ - fun startDate(startDate: JsonField) = apply { - this.startDate = startDate - } - - /** - * Only available if discount_type is `usage`. Number of usage units that this - * discount is for - */ - fun usageDiscount(usageDiscount: Double) = - usageDiscount(JsonField.of(usageDiscount)) - - /** - * Only available if discount_type is `usage`. Number of usage units that this - * discount is for - */ - fun usageDiscount(usageDiscount: JsonField) = apply { - this.usageDiscount = usageDiscount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): UsageDiscountInterval = - UsageDiscountInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("discountType", discountType), - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - checkRequired("usageDiscount", usageDiscount), - additionalProperties.toImmutable(), - ) - } - - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE = of("usage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - USAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE -> Value.USAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE -> Known.USAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UsageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, startDate, usageDiscount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UsageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" - } - } - - @NoAutoDetect - class FixedFeeQuantitySchedule - @JsonCreator - private constructor( - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("price_id") - @ExcludeMissing - private val priceId: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - private val quantity: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - fun priceId(): String = priceId.getRequired("price_id") - - fun quantity(): Double = quantity.getRequired("quantity") - - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - - @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): FixedFeeQuantitySchedule = apply { - if (validated) { - return@apply - } - - endDate() - priceId() - quantity() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FixedFeeQuantitySchedule]. */ - class Builder internal constructor() { - - private var endDate: JsonField? = null - private var priceId: JsonField? = null - private var quantity: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = apply { - endDate = fixedFeeQuantitySchedule.endDate - priceId = fixedFeeQuantitySchedule.priceId - quantity = fixedFeeQuantitySchedule.quantity - startDate = fixedFeeQuantitySchedule.startDate - additionalProperties = fixedFeeQuantitySchedule.additionalProperties.toMutableMap() - } - - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) - - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - 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) - } - - fun build(): FixedFeeQuantitySchedule = - FixedFeeQuantitySchedule( - checkRequired("endDate", endDate), - checkRequired("priceId", priceId), - checkRequired("quantity", quantity), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FixedFeeQuantitySchedule && endDate == other.endDate && priceId == other.priceId && quantity == other.quantity && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(endDate, priceId, quantity, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "FixedFeeQuantitySchedule{endDate=$endDate, priceId=$priceId, quantity=$quantity, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class MaximumInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this maximum interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this maximum interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - /** The end date of the maximum interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** The start date of the maximum interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** The price ids that this maximum interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this maximum interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - /** The end date of the maximum interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** The start date of the maximum interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MaximumInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - endDate() - maximumAmount() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MaximumInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var endDate: JsonField? = null - private var maximumAmount: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximumInterval: MaximumInterval) = apply { - appliesToPriceIds = maximumInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - maximumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - endDate = maximumInterval.endDate - maximumAmount = maximumInterval.maximumAmount - startDate = maximumInterval.startDate - additionalProperties = maximumInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this maximum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this maximum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this maximum interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this maximum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this maximum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this maximum interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - /** The end date of the maximum interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the maximum interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the maximum interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** The start date of the maximum interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the maximum interval. */ - 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) - } - - fun build(): MaximumInterval = - MaximumInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("endDate", endDate), - checkRequired("maximumAmount", maximumAmount), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MaximumInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && maximumAmount == other.maximumAmount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, endDate, maximumAmount, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MaximumInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, maximumAmount=$maximumAmount, startDate=$startDate, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class MinimumInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this minimum interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this minimum interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - /** The end date of the minimum interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** The start date of the minimum interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** The price ids that this minimum interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this minimum interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - /** The end date of the minimum interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** The start date of the minimum interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MinimumInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - endDate() - minimumAmount() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MinimumInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var endDate: JsonField? = null - private var minimumAmount: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(minimumInterval: MinimumInterval) = apply { - appliesToPriceIds = minimumInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - minimumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - endDate = minimumInterval.endDate - minimumAmount = minimumInterval.minimumAmount - startDate = minimumInterval.startDate - additionalProperties = minimumInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this minimum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this minimum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this minimum interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this minimum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this minimum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this minimum interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - /** The end date of the minimum interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the minimum interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the minimum interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** The start date of the minimum interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the minimum interval. */ - 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) - } - - fun build(): MinimumInterval = - MinimumInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("endDate", endDate), - checkRequired("minimumAmount", minimumAmount), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MinimumInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && minimumAmount == other.minimumAmount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, endDate, minimumAmount, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MinimumInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, minimumAmount=$minimumAmount, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - /** - * The Price Interval resource represents a period of time for which a price will bill on a - * subscription. A subscription’s price intervals define its billing behavior. - */ - @NoAutoDetect - class PriceInterval - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_day") - @ExcludeMissing - private val billingCycleDay: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - private val currentBillingPeriodEndDate: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - private val currentBillingPeriodStartDate: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("filter") - @ExcludeMissing - private val filter: JsonField = JsonMissing.of(), - @JsonProperty("fixed_fee_quantity_transitions") - @ExcludeMissing - private val fixedFeeQuantityTransitions: JsonField> = - JsonMissing.of(), - @JsonProperty("price") - @ExcludeMissing - private val price: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonProperty("usage_customer_ids") - @ExcludeMissing - private val usageCustomerIds: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - /** The day of the month that Orb bills for this price */ - fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate(): Optional = - Optional.ofNullable( - currentBillingPeriodEndDate.getNullable("current_billing_period_end_date") - ) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodStartDate(): Optional = - Optional.ofNullable( - currentBillingPeriodStartDate.getNullable("current_billing_period_start_date") - ) - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** An additional filter to apply to usage queries. */ - fun filter(): Optional = Optional.ofNullable(filter.getNullable("filter")) - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions(): Optional> = - Optional.ofNullable( - fixedFeeQuantityTransitions.getNullable("fixed_fee_quantity_transitions") - ) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting in - * a charge on an invoice in the form of an invoice line item. Prices take a quantity and - * determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the key - * for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(): Price = price.getRequired("price") - - /** - * The start date of the price interval. This is the date that Orb starts billing for this - * price. - */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this price - * interval. - */ - fun usageCustomerIds(): Optional> = - Optional.ofNullable(usageCustomerIds.getNullable("usage_customer_ids")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** The day of the month that Orb bills for this price */ - @JsonProperty("billing_cycle_day") - @ExcludeMissing - fun _billingCycleDay(): JsonField = billingCycleDay - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if this price - * interval is not currently active. - */ - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - fun _currentBillingPeriodStartDate(): JsonField = - currentBillingPeriodStartDate - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** An additional filter to apply to usage queries. */ - @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField = filter - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - @JsonProperty("fixed_fee_quantity_transitions") - @ExcludeMissing - fun _fixedFeeQuantityTransitions(): JsonField> = - fixedFeeQuantityTransitions - - /** - * 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) - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - - /** - * The start date of the price interval. This is the date that Orb starts billing for this - * price. - */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this price - * interval. - */ - @JsonProperty("usage_customer_ids") - @ExcludeMissing - fun _usageCustomerIds(): JsonField> = usageCustomerIds - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PriceInterval = apply { - if (validated) { - return@apply - } - - id() - billingCycleDay() - currentBillingPeriodEndDate() - currentBillingPeriodStartDate() - endDate() - filter() - fixedFeeQuantityTransitions().ifPresent { it.forEach { it.validate() } } - price().validate() - startDate() - usageCustomerIds() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PriceInterval]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var billingCycleDay: JsonField? = null - private var currentBillingPeriodEndDate: JsonField? = null - private var currentBillingPeriodStartDate: JsonField? = null - private var endDate: JsonField? = null - private var filter: JsonField? = null - private var fixedFeeQuantityTransitions: - JsonField>? = - null - private var price: JsonField? = null - private var startDate: JsonField? = null - private var usageCustomerIds: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(priceInterval: PriceInterval) = apply { - id = priceInterval.id - billingCycleDay = priceInterval.billingCycleDay - currentBillingPeriodEndDate = priceInterval.currentBillingPeriodEndDate - currentBillingPeriodStartDate = priceInterval.currentBillingPeriodStartDate - endDate = priceInterval.endDate - filter = priceInterval.filter - fixedFeeQuantityTransitions = - priceInterval.fixedFeeQuantityTransitions.map { it.toMutableList() } - price = priceInterval.price - startDate = priceInterval.startDate - usageCustomerIds = priceInterval.usageCustomerIds.map { it.toMutableList() } - additionalProperties = priceInterval.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - /** The day of the month that Orb bills for this price */ - fun billingCycleDay(billingCycleDay: Long) = - billingCycleDay(JsonField.of(billingCycleDay)) - - /** The day of the month that Orb bills for this price */ - fun billingCycleDay(billingCycleDay: JsonField) = apply { - this.billingCycleDay = billingCycleDay - } - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = - currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = - currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate( - currentBillingPeriodEndDate: JsonField - ) = apply { this.currentBillingPeriodEndDate = currentBillingPeriodEndDate } - - /** - * The start date of the current billing period. This is an inclusive timestamp; the - * instant returned is exactly the beginning of the billing period. Set to null if this - * price interval is not currently active. - */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = - currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the - * instant returned is exactly the beginning of the billing period. Set to null if this - * price interval is not currently active. - */ - fun currentBillingPeriodStartDate( - currentBillingPeriodStartDate: Optional - ) = currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the - * instant returned is exactly the beginning of the billing period. Set to null if this - * price interval is not currently active. - */ - fun currentBillingPeriodStartDate( - currentBillingPeriodStartDate: JsonField - ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** An additional filter to apply to usage queries. */ - fun filter(filter: String?) = filter(JsonField.ofNullable(filter)) - - /** An additional filter to apply to usage queries. */ - fun filter(filter: Optional) = filter(filter.orElse(null)) - - /** An additional filter to apply to usage queries. */ - fun filter(filter: JsonField) = apply { this.filter = filter } - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: List? - ) = fixedFeeQuantityTransitions(JsonField.ofNullable(fixedFeeQuantityTransitions)) - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: Optional> - ) = fixedFeeQuantityTransitions(fixedFeeQuantityTransitions.orElse(null)) - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: JsonField> - ) = apply { - this.fixedFeeQuantityTransitions = - fixedFeeQuantityTransitions.map { it.toMutableList() } - } - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun addFixedFeeQuantityTransition( - fixedFeeQuantityTransition: FixedFeeQuantityTransition - ) = apply { - fixedFeeQuantityTransitions = - (fixedFeeQuantityTransitions ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(fixedFeeQuantityTransition) - } - } - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(price: Price) = price(JsonField.of(price)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(price: JsonField) = apply { this.price = price } - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(matrix: Price.MatrixPrice) = price(Price.ofMatrix(matrix)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredPackage: Price.TieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedTiered: Price.GroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(unitWithPercent: Price.UnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredWithProration: Price.TieredWithProrationPrice) = - price(Price.ofTieredWithProration(tieredWithProration)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(unitWithProration: Price.UnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedAllocation: Price.GroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bulkWithProration: Price.BulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = - price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice) = - price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - - /** - * The start date of the price interval. This is the date that Orb starts billing for - * this price. - */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** - * The start date of the price interval. This is the date that Orb starts billing for - * this price. - */ - fun startDate(startDate: JsonField) = apply { - this.startDate = startDate - } - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun usageCustomerIds(usageCustomerIds: List?) = - usageCustomerIds(JsonField.ofNullable(usageCustomerIds)) - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun usageCustomerIds(usageCustomerIds: Optional>) = - usageCustomerIds(usageCustomerIds.orElse(null)) - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun usageCustomerIds(usageCustomerIds: JsonField>) = apply { - this.usageCustomerIds = usageCustomerIds.map { it.toMutableList() } - } - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun addUsageCustomerId(usageCustomerId: String) = apply { - usageCustomerIds = - (usageCustomerIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(usageCustomerId) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): PriceInterval = - PriceInterval( - checkRequired("id", id), - checkRequired("billingCycleDay", billingCycleDay), - checkRequired("currentBillingPeriodEndDate", currentBillingPeriodEndDate), - checkRequired("currentBillingPeriodStartDate", currentBillingPeriodStartDate), - checkRequired("endDate", endDate), - checkRequired("filter", filter), - checkRequired("fixedFeeQuantityTransitions", fixedFeeQuantityTransitions).map { - it.toImmutable() - }, - checkRequired("price", price), - checkRequired("startDate", startDate), - checkRequired("usageCustomerIds", usageCustomerIds).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class FixedFeeQuantityTransition - @JsonCreator - private constructor( - @JsonProperty("effective_date") - @ExcludeMissing - private val effectiveDate: JsonField = JsonMissing.of(), - @JsonProperty("price_id") - @ExcludeMissing - private val priceId: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - private val quantity: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun effectiveDate(): OffsetDateTime = effectiveDate.getRequired("effective_date") - - fun priceId(): String = priceId.getRequired("price_id") - - fun quantity(): Long = quantity.getRequired("quantity") - - @JsonProperty("effective_date") - @ExcludeMissing - fun _effectiveDate(): JsonField = effectiveDate - - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - - @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): FixedFeeQuantityTransition = apply { - if (validated) { - return@apply - } - - effectiveDate() - priceId() - quantity() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FixedFeeQuantityTransition]. */ - class Builder internal constructor() { - - private var effectiveDate: JsonField? = null - private var priceId: JsonField? = null - private var quantity: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(fixedFeeQuantityTransition: FixedFeeQuantityTransition) = apply { - effectiveDate = fixedFeeQuantityTransition.effectiveDate - priceId = fixedFeeQuantityTransition.priceId - quantity = fixedFeeQuantityTransition.quantity - additionalProperties = - fixedFeeQuantityTransition.additionalProperties.toMutableMap() - } - - fun effectiveDate(effectiveDate: OffsetDateTime) = - effectiveDate(JsonField.of(effectiveDate)) - - fun effectiveDate(effectiveDate: JsonField) = apply { - this.effectiveDate = effectiveDate - } - - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) - - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - - fun quantity(quantity: Long) = quantity(JsonField.of(quantity)) - - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): FixedFeeQuantityTransition = - FixedFeeQuantityTransition( - checkRequired("effectiveDate", effectiveDate), - checkRequired("priceId", priceId), - checkRequired("quantity", quantity), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FixedFeeQuantityTransition && effectiveDate == other.effectiveDate && priceId == other.priceId && quantity == other.quantity && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(effectiveDate, priceId, quantity, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "FixedFeeQuantityTransition{effectiveDate=$effectiveDate, priceId=$priceId, quantity=$quantity, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PriceInterval && id == other.id && billingCycleDay == other.billingCycleDay && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && endDate == other.endDate && filter == other.filter && fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && price == other.price && startDate == other.startDate && usageCustomerIds == other.usageCustomerIds && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billingCycleDay, currentBillingPeriodEndDate, currentBillingPeriodStartDate, endDate, filter, fixedFeeQuantityTransitions, price, startDate, usageCustomerIds, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PriceInterval{id=$id, billingCycleDay=$billingCycleDay, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, endDate=$endDate, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, price=$price, startDate=$startDate, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class RedeemedCoupon - @JsonCreator - private constructor( - @JsonProperty("coupon_id") - @ExcludeMissing - private val couponId: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun couponId(): String = couponId.getRequired("coupon_id") - - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - @JsonProperty("coupon_id") @ExcludeMissing fun _couponId(): JsonField = couponId - - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): RedeemedCoupon = apply { - if (validated) { - return@apply - } - - couponId() - endDate() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RedeemedCoupon]. */ - class Builder internal constructor() { - - private var couponId: JsonField? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(redeemedCoupon: RedeemedCoupon) = apply { - couponId = redeemedCoupon.couponId - endDate = redeemedCoupon.endDate - startDate = redeemedCoupon.startDate - additionalProperties = redeemedCoupon.additionalProperties.toMutableMap() - } - - fun couponId(couponId: String) = couponId(JsonField.of(couponId)) - - fun couponId(couponId: JsonField) = apply { this.couponId = couponId } - - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - 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) - } - - fun build(): RedeemedCoupon = - RedeemedCoupon( - checkRequired("couponId", couponId), - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RedeemedCoupon && couponId == other.couponId && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(couponId, endDate, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RedeemedCoupon{couponId=$couponId, endDate=$endDate, startDate=$startDate, 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 ENDED = of("ended") - - @JvmField val UPCOMING = of("upcoming") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - ACTIVE, - ENDED, - UPCOMING, - } - - /** - * 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, - ENDED, - UPCOMING, - /** 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 - ENDED -> Value.ENDED - UPCOMING -> Value.UPCOMING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to 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 - ENDED -> Known.ENDED - UPCOMING -> Known.UPCOMING - 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TrialInfo - @JsonCreator - private constructor( - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TrialInfo = apply { - if (validated) { - return@apply - } - - endDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TrialInfo]. */ - class Builder internal constructor() { - - private var endDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(trialInfo: TrialInfo) = apply { - endDate = trialInfo.endDate - additionalProperties = trialInfo.additionalProperties.toMutableMap() - } - - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - 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) - } - - fun build(): TrialInfo = - TrialInfo(checkRequired("endDate", endDate), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TrialInfo && endDate == other.endDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(endDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TrialInfo{endDate=$endDate, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is SubscriptionUnscheduleCancellationResponse && id == other.id && activePlanPhaseOrder == other.activePlanPhaseOrder && adjustmentIntervals == other.adjustmentIntervals && autoCollection == other.autoCollection && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && billingCycleDay == other.billingCycleDay && createdAt == other.createdAt && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && customer == other.customer && defaultInvoiceMemo == other.defaultInvoiceMemo && discountIntervals == other.discountIntervals && endDate == other.endDate && fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && invoicingThreshold == other.invoicingThreshold && maximumIntervals == other.maximumIntervals && metadata == other.metadata && minimumIntervals == other.minimumIntervals && netTerms == other.netTerms && plan == other.plan && priceIntervals == other.priceIntervals && redeemedCoupon == other.redeemedCoupon && startDate == other.startDate && status == other.status && trialInfo == other.trialInfo && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, activePlanPhaseOrder, adjustmentIntervals, autoCollection, billingCycleAnchorConfiguration, billingCycleDay, createdAt, currentBillingPeriodEndDate, currentBillingPeriodStartDate, customer, defaultInvoiceMemo, discountIntervals, endDate, fixedFeeQuantitySchedule, invoicingThreshold, maximumIntervals, metadata, minimumIntervals, netTerms, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SubscriptionUnscheduleCancellationResponse{id=$id, activePlanPhaseOrder=$activePlanPhaseOrder, adjustmentIntervals=$adjustmentIntervals, autoCollection=$autoCollection, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, billingCycleDay=$billingCycleDay, createdAt=$createdAt, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, customer=$customer, defaultInvoiceMemo=$defaultInvoiceMemo, discountIntervals=$discountIntervals, endDate=$endDate, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, invoicingThreshold=$invoicingThreshold, maximumIntervals=$maximumIntervals, metadata=$metadata, minimumIntervals=$minimumIntervals, netTerms=$netTerms, plan=$plan, priceIntervals=$priceIntervals, redeemedCoupon=$redeemedCoupon, startDate=$startDate, status=$status, trialInfo=$trialInfo, additionalProperties=$additionalProperties}" -} 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 9fa302383..6bc228ac5 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 @@ -96,6 +96,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .priceId() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -162,6 +170,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [SubscriptionUnscheduleFixedFeeQuantityUpdatesParams]. + * + * The following fields are required: + * ```java + * .subscriptionId() + * .priceId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.kt deleted file mode 100644 index 8bf84b4cf..000000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.kt +++ /dev/null @@ -1,7187 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer -import com.withorb.api.core.Enum -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow -import com.withorb.api.core.immutableEmptyMap -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -@NoAutoDetect -class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse -@JsonCreator -private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("active_plan_phase_order") - @ExcludeMissing - private val activePlanPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_intervals") - @ExcludeMissing - private val adjustmentIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("auto_collection") - @ExcludeMissing - private val autoCollection: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_anchor_configuration") - @ExcludeMissing - private val billingCycleAnchorConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("billing_cycle_day") - @ExcludeMissing - private val billingCycleDay: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - private val currentBillingPeriodEndDate: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - private val currentBillingPeriodStartDate: JsonField = JsonMissing.of(), - @JsonProperty("customer") - @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), - @JsonProperty("default_invoice_memo") - @ExcludeMissing - private val defaultInvoiceMemo: JsonField = JsonMissing.of(), - @JsonProperty("discount_intervals") - @ExcludeMissing - private val discountIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("fixed_fee_quantity_schedule") - @ExcludeMissing - private val fixedFeeQuantitySchedule: JsonField> = - JsonMissing.of(), - @JsonProperty("invoicing_threshold") - @ExcludeMissing - private val invoicingThreshold: JsonField = JsonMissing.of(), - @JsonProperty("maximum_intervals") - @ExcludeMissing - private val maximumIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("minimum_intervals") - @ExcludeMissing - private val minimumIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("net_terms") - @ExcludeMissing - private val netTerms: JsonField = JsonMissing.of(), - @JsonProperty("plan") @ExcludeMissing private val plan: JsonField = JsonMissing.of(), - @JsonProperty("price_intervals") - @ExcludeMissing - private val priceIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("redeemed_coupon") - @ExcludeMissing - private val redeemedCoupon: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonProperty("status") - @ExcludeMissing - private val status: JsonField = JsonMissing.of(), - @JsonProperty("trial_info") - @ExcludeMissing - private val trialInfo: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun id(): String = id.getRequired("id") - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(): Optional = - Optional.ofNullable(activePlanPhaseOrder.getNullable("active_plan_phase_order")) - - /** The adjustment intervals for this subscription. */ - fun adjustmentIntervals(): List = - adjustmentIntervals.getRequired("adjustment_intervals") - - /** - * Determines whether issued invoices for this subscription will automatically be charged with - * the saved payment method on the due date. This property defaults to the plan's behavior. If - * null, defaults to the customer's setting. - */ - fun autoCollection(): Optional = - Optional.ofNullable(autoCollection.getNullable("auto_collection")) - - fun billingCycleAnchorConfiguration(): BillingCycleAnchorConfiguration = - billingCycleAnchorConfiguration.getRequired("billing_cycle_anchor_configuration") - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of days in - * a month is greater than this value, the last day of the month is the billing cycle day (e.g. - * billing_cycle_day=31 for April means the billing period begins on the 30th. - */ - fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the instant - * returned is not part of the billing period. Set to null for subscriptions that are not - * currently active. - */ - fun currentBillingPeriodEndDate(): Optional = - Optional.ofNullable( - currentBillingPeriodEndDate.getNullable("current_billing_period_end_date") - ) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription is - * not currently active. - */ - fun currentBillingPeriodStartDate(): Optional = - Optional.ofNullable( - currentBillingPeriodStartDate.getNullable("current_billing_period_start_date") - ) - - /** - * 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 customer(): Customer = customer.getRequired("customer") - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(): Optional = - Optional.ofNullable(defaultInvoiceMemo.getNullable("default_invoice_memo")) - - /** The discount intervals for this subscription. */ - fun discountIntervals(): List = - discountIntervals.getRequired("discount_intervals") - - /** The date Orb stops billing for this subscription. */ - fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) - - fun fixedFeeQuantitySchedule(): List = - fixedFeeQuantitySchedule.getRequired("fixed_fee_quantity_schedule") - - fun invoicingThreshold(): Optional = - Optional.ofNullable(invoicingThreshold.getNullable("invoicing_threshold")) - - /** The maximum intervals for this subscription. */ - fun maximumIntervals(): List = - maximumIntervals.getRequired("maximum_intervals") - - /** - * 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.getRequired("metadata") - - /** The minimum intervals for this subscription. */ - fun minimumIntervals(): List = - minimumIntervals.getRequired("minimum_intervals") - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - fun netTerms(): Long = netTerms.getRequired("net_terms") - - /** - * 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 plan(): Plan = plan.getRequired("plan") - - /** The price intervals for this subscription. */ - fun priceIntervals(): List = priceIntervals.getRequired("price_intervals") - - fun redeemedCoupon(): Optional = - Optional.ofNullable(redeemedCoupon.getNullable("redeemed_coupon")) - - /** The date Orb starts billing for this subscription. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - fun status(): Status = status.getRequired("status") - - fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - @JsonProperty("active_plan_phase_order") - @ExcludeMissing - fun _activePlanPhaseOrder(): JsonField = activePlanPhaseOrder - - /** The adjustment intervals for this subscription. */ - @JsonProperty("adjustment_intervals") - @ExcludeMissing - fun _adjustmentIntervals(): JsonField> = adjustmentIntervals - - /** - * Determines whether issued invoices for this subscription will automatically be charged with - * the saved payment method on the due date. This property defaults to the plan's behavior. If - * null, defaults to the customer's setting. - */ - @JsonProperty("auto_collection") - @ExcludeMissing - fun _autoCollection(): JsonField = autoCollection - - @JsonProperty("billing_cycle_anchor_configuration") - @ExcludeMissing - fun _billingCycleAnchorConfiguration(): JsonField = - billingCycleAnchorConfiguration - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of days in - * a month is greater than this value, the last day of the month is the billing cycle day (e.g. - * billing_cycle_day=31 for April means the billing period begins on the 30th. - */ - @JsonProperty("billing_cycle_day") - @ExcludeMissing - fun _billingCycleDay(): JsonField = billingCycleDay - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the instant - * returned is not part of the billing period. Set to null for subscriptions that are not - * currently active. - */ - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription is - * not currently active. - */ - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - fun _currentBillingPeriodStartDate(): JsonField = currentBillingPeriodStartDate - - /** - * 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. - */ - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - @JsonProperty("default_invoice_memo") - @ExcludeMissing - fun _defaultInvoiceMemo(): JsonField = defaultInvoiceMemo - - /** The discount intervals for this subscription. */ - @JsonProperty("discount_intervals") - @ExcludeMissing - fun _discountIntervals(): JsonField> = discountIntervals - - /** The date Orb stops billing for this subscription. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate - - @JsonProperty("fixed_fee_quantity_schedule") - @ExcludeMissing - fun _fixedFeeQuantitySchedule(): JsonField> = - fixedFeeQuantitySchedule - - @JsonProperty("invoicing_threshold") - @ExcludeMissing - fun _invoicingThreshold(): JsonField = invoicingThreshold - - /** The maximum intervals for this subscription. */ - @JsonProperty("maximum_intervals") - @ExcludeMissing - fun _maximumIntervals(): JsonField> = maximumIntervals - - /** - * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - /** The minimum intervals for this subscription. */ - @JsonProperty("minimum_intervals") - @ExcludeMissing - fun _minimumIntervals(): JsonField> = minimumIntervals - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms - - /** - * 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). - */ - @JsonProperty("plan") @ExcludeMissing fun _plan(): JsonField = plan - - /** The price intervals for this subscription. */ - @JsonProperty("price_intervals") - @ExcludeMissing - fun _priceIntervals(): JsonField> = priceIntervals - - @JsonProperty("redeemed_coupon") - @ExcludeMissing - fun _redeemedCoupon(): JsonField = redeemedCoupon - - /** The date Orb starts billing for this subscription. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo(): JsonField = trialInfo - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse = apply { - if (validated) { - return@apply - } - - id() - activePlanPhaseOrder() - adjustmentIntervals().forEach { it.validate() } - autoCollection() - billingCycleAnchorConfiguration().validate() - billingCycleDay() - createdAt() - currentBillingPeriodEndDate() - currentBillingPeriodStartDate() - customer().validate() - defaultInvoiceMemo() - discountIntervals().forEach { it.validate() } - endDate() - fixedFeeQuantitySchedule().forEach { it.validate() } - invoicingThreshold() - maximumIntervals().forEach { it.validate() } - metadata().validate() - minimumIntervals().forEach { it.validate() } - netTerms() - plan().validate() - priceIntervals().forEach { it.validate() } - redeemedCoupon().ifPresent { it.validate() } - startDate() - status() - trialInfo().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var activePlanPhaseOrder: JsonField? = null - private var adjustmentIntervals: JsonField>? = null - private var autoCollection: JsonField? = null - private var billingCycleAnchorConfiguration: JsonField? = - null - private var billingCycleDay: JsonField? = null - private var createdAt: JsonField? = null - private var currentBillingPeriodEndDate: JsonField? = null - private var currentBillingPeriodStartDate: JsonField? = null - private var customer: JsonField? = null - private var defaultInvoiceMemo: JsonField? = null - private var discountIntervals: JsonField>? = null - private var endDate: JsonField? = null - private var fixedFeeQuantitySchedule: JsonField>? = - null - private var invoicingThreshold: JsonField? = null - private var maximumIntervals: JsonField>? = null - private var metadata: JsonField? = null - private var minimumIntervals: JsonField>? = null - private var netTerms: JsonField? = null - private var plan: JsonField? = null - private var priceIntervals: JsonField>? = null - private var redeemedCoupon: JsonField? = null - private var startDate: JsonField? = null - private var status: JsonField? = null - private var trialInfo: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - subscriptionUnscheduleFixedFeeQuantityUpdatesResponse: - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse - ) = apply { - id = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.id - activePlanPhaseOrder = - subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.activePlanPhaseOrder - adjustmentIntervals = - subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.adjustmentIntervals.map { - it.toMutableList() - } - autoCollection = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.autoCollection - billingCycleAnchorConfiguration = - subscriptionUnscheduleFixedFeeQuantityUpdatesResponse - .billingCycleAnchorConfiguration - billingCycleDay = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.billingCycleDay - createdAt = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.createdAt - currentBillingPeriodEndDate = - subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.currentBillingPeriodEndDate - currentBillingPeriodStartDate = - subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.currentBillingPeriodStartDate - customer = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.customer - defaultInvoiceMemo = - subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.defaultInvoiceMemo - discountIntervals = - subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.discountIntervals.map { - it.toMutableList() - } - endDate = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.endDate - fixedFeeQuantitySchedule = - subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.fixedFeeQuantitySchedule.map { - it.toMutableList() - } - invoicingThreshold = - subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.invoicingThreshold - maximumIntervals = - subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.maximumIntervals.map { - it.toMutableList() - } - metadata = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.metadata - minimumIntervals = - subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.minimumIntervals.map { - it.toMutableList() - } - netTerms = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.netTerms - plan = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.plan - priceIntervals = - subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.priceIntervals.map { - it.toMutableList() - } - redeemedCoupon = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.redeemedCoupon - startDate = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.startDate - status = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.status - trialInfo = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.trialInfo - additionalProperties = - subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.additionalProperties - .toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(activePlanPhaseOrder: Long?) = - activePlanPhaseOrder(JsonField.ofNullable(activePlanPhaseOrder)) - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(activePlanPhaseOrder: Long) = - activePlanPhaseOrder(activePlanPhaseOrder as Long?) - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun activePlanPhaseOrder(activePlanPhaseOrder: Optional) = - activePlanPhaseOrder(activePlanPhaseOrder.orElse(null) as Long?) - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(activePlanPhaseOrder: JsonField) = apply { - this.activePlanPhaseOrder = activePlanPhaseOrder - } - - /** The adjustment intervals for this subscription. */ - fun adjustmentIntervals(adjustmentIntervals: List) = - adjustmentIntervals(JsonField.of(adjustmentIntervals)) - - /** The adjustment intervals for this subscription. */ - fun adjustmentIntervals(adjustmentIntervals: JsonField>) = apply { - this.adjustmentIntervals = adjustmentIntervals.map { it.toMutableList() } - } - - /** The adjustment intervals for this subscription. */ - fun addAdjustmentInterval(adjustmentInterval: AdjustmentInterval) = apply { - adjustmentIntervals = - (adjustmentIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(adjustmentInterval) - } - } - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - fun autoCollection(autoCollection: Boolean?) = - autoCollection(JsonField.ofNullable(autoCollection)) - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun autoCollection(autoCollection: Optional) = - autoCollection(autoCollection.orElse(null) as Boolean?) - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - fun autoCollection(autoCollection: JsonField) = apply { - this.autoCollection = autoCollection - } - - fun billingCycleAnchorConfiguration( - billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration - ) = billingCycleAnchorConfiguration(JsonField.of(billingCycleAnchorConfiguration)) - - fun billingCycleAnchorConfiguration( - billingCycleAnchorConfiguration: JsonField - ) = apply { this.billingCycleAnchorConfiguration = billingCycleAnchorConfiguration } - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun billingCycleDay(billingCycleDay: Long) = billingCycleDay(JsonField.of(billingCycleDay)) - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun billingCycleDay(billingCycleDay: JsonField) = apply { - this.billingCycleDay = billingCycleDay - } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is not part of the billing period. Set to null for subscriptions that - * are not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = - currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is not part of the billing period. Set to null for subscriptions that - * are not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = - currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is not part of the billing period. Set to null for subscriptions that - * are not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: JsonField) = - apply { - this.currentBillingPeriodEndDate = currentBillingPeriodEndDate - } - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription - * is not currently active. - */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = - currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription - * is not currently active. - */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: Optional) = - currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription - * is not currently active. - */ - fun currentBillingPeriodStartDate( - currentBillingPeriodStartDate: JsonField - ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } - - /** - * 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 customer(customer: Customer) = customer(JsonField.of(customer)) - - /** - * 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 customer(customer: JsonField) = apply { this.customer = customer } - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(defaultInvoiceMemo: String?) = - defaultInvoiceMemo(JsonField.ofNullable(defaultInvoiceMemo)) - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(defaultInvoiceMemo: Optional) = - defaultInvoiceMemo(defaultInvoiceMemo.orElse(null)) - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(defaultInvoiceMemo: JsonField) = apply { - this.defaultInvoiceMemo = defaultInvoiceMemo - } - - /** The discount intervals for this subscription. */ - fun discountIntervals(discountIntervals: List) = - discountIntervals(JsonField.of(discountIntervals)) - - /** The discount intervals for this subscription. */ - fun discountIntervals(discountIntervals: JsonField>) = apply { - this.discountIntervals = discountIntervals.map { it.toMutableList() } - } - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(discountInterval: DiscountInterval) = apply { - discountIntervals = - (discountIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(discountInterval) - } - } - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(amount: DiscountInterval.AmountDiscountInterval) = - addDiscountInterval(DiscountInterval.ofAmount(amount)) - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(percentage: DiscountInterval.PercentageDiscountInterval) = - addDiscountInterval(DiscountInterval.ofPercentage(percentage)) - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(usage: DiscountInterval.UsageDiscountInterval) = - addDiscountInterval(DiscountInterval.ofUsage(usage)) - - /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - fun fixedFeeQuantitySchedule(fixedFeeQuantitySchedule: List) = - fixedFeeQuantitySchedule(JsonField.of(fixedFeeQuantitySchedule)) - - fun fixedFeeQuantitySchedule( - fixedFeeQuantitySchedule: JsonField> - ) = apply { - this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule.map { it.toMutableList() } - } - - fun addFixedFeeQuantitySchedule(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = - apply { - this.fixedFeeQuantitySchedule = - (this.fixedFeeQuantitySchedule ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(fixedFeeQuantitySchedule) - } - } - - fun invoicingThreshold(invoicingThreshold: String?) = - invoicingThreshold(JsonField.ofNullable(invoicingThreshold)) - - fun invoicingThreshold(invoicingThreshold: Optional) = - invoicingThreshold(invoicingThreshold.orElse(null)) - - fun invoicingThreshold(invoicingThreshold: JsonField) = apply { - this.invoicingThreshold = invoicingThreshold - } - - /** The maximum intervals for this subscription. */ - fun maximumIntervals(maximumIntervals: List) = - maximumIntervals(JsonField.of(maximumIntervals)) - - /** The maximum intervals for this subscription. */ - fun maximumIntervals(maximumIntervals: JsonField>) = apply { - this.maximumIntervals = maximumIntervals.map { it.toMutableList() } - } - - /** The maximum intervals for this subscription. */ - fun addMaximumInterval(maximumInterval: MaximumInterval) = apply { - maximumIntervals = - (maximumIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(maximumInterval) - } - } - - /** - * 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - /** The minimum intervals for this subscription. */ - fun minimumIntervals(minimumIntervals: List) = - minimumIntervals(JsonField.of(minimumIntervals)) - - /** The minimum intervals for this subscription. */ - fun minimumIntervals(minimumIntervals: JsonField>) = apply { - this.minimumIntervals = minimumIntervals.map { it.toMutableList() } - } - - /** The minimum intervals for this subscription. */ - fun addMinimumInterval(minimumInterval: MinimumInterval) = apply { - minimumIntervals = - (minimumIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(minimumInterval) - } - } - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - fun netTerms(netTerms: Long) = netTerms(JsonField.of(netTerms)) - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } - - /** - * 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 plan(plan: Plan) = plan(JsonField.of(plan)) - - /** - * 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 plan(plan: JsonField) = apply { this.plan = plan } - - /** The price intervals for this subscription. */ - fun priceIntervals(priceIntervals: List) = - priceIntervals(JsonField.of(priceIntervals)) - - /** The price intervals for this subscription. */ - fun priceIntervals(priceIntervals: JsonField>) = apply { - this.priceIntervals = priceIntervals.map { it.toMutableList() } - } - - /** The price intervals for this subscription. */ - fun addPriceInterval(priceInterval: PriceInterval) = apply { - priceIntervals = - (priceIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(priceInterval) - } - } - - fun redeemedCoupon(redeemedCoupon: RedeemedCoupon?) = - redeemedCoupon(JsonField.ofNullable(redeemedCoupon)) - - fun redeemedCoupon(redeemedCoupon: Optional) = - redeemedCoupon(redeemedCoupon.orElse(null)) - - fun redeemedCoupon(redeemedCoupon: JsonField) = apply { - this.redeemedCoupon = redeemedCoupon - } - - /** The date Orb starts billing for this subscription. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The date Orb starts billing for this subscription. */ - fun startDate(startDate: JsonField) = apply { this.startDate = startDate } - - fun status(status: Status) = status(JsonField.of(status)) - - fun status(status: JsonField) = apply { this.status = status } - - fun trialInfo(trialInfo: TrialInfo) = trialInfo(JsonField.of(trialInfo)) - - fun trialInfo(trialInfo: JsonField) = apply { this.trialInfo = trialInfo } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse = - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse( - checkRequired("id", id), - checkRequired("activePlanPhaseOrder", activePlanPhaseOrder), - checkRequired("adjustmentIntervals", adjustmentIntervals).map { it.toImmutable() }, - checkRequired("autoCollection", autoCollection), - checkRequired("billingCycleAnchorConfiguration", billingCycleAnchorConfiguration), - checkRequired("billingCycleDay", billingCycleDay), - checkRequired("createdAt", createdAt), - checkRequired("currentBillingPeriodEndDate", currentBillingPeriodEndDate), - checkRequired("currentBillingPeriodStartDate", currentBillingPeriodStartDate), - checkRequired("customer", customer), - checkRequired("defaultInvoiceMemo", defaultInvoiceMemo), - checkRequired("discountIntervals", discountIntervals).map { it.toImmutable() }, - checkRequired("endDate", endDate), - checkRequired("fixedFeeQuantitySchedule", fixedFeeQuantitySchedule).map { - it.toImmutable() - }, - checkRequired("invoicingThreshold", invoicingThreshold), - checkRequired("maximumIntervals", maximumIntervals).map { it.toImmutable() }, - checkRequired("metadata", metadata), - checkRequired("minimumIntervals", minimumIntervals).map { it.toImmutable() }, - checkRequired("netTerms", netTerms), - checkRequired("plan", plan), - checkRequired("priceIntervals", priceIntervals).map { it.toImmutable() }, - checkRequired("redeemedCoupon", redeemedCoupon), - checkRequired("startDate", startDate), - checkRequired("status", status), - checkRequired("trialInfo", trialInfo), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class AdjustmentInterval - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment") - @ExcludeMissing - private val adjustment: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") - - /** The price interval IDs that this adjustment applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - /** The end date of the adjustment interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** The start date of the adjustment interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment - - /** The price interval IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - /** The end date of the adjustment interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** The start date of the adjustment interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AdjustmentInterval = apply { - if (validated) { - return@apply - } - - id() - adjustment().validate() - appliesToPriceIntervalIds() - endDate() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AdjustmentInterval]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustment: JsonField? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(adjustmentInterval: AdjustmentInterval) = apply { - id = adjustmentInterval.id - adjustment = adjustmentInterval.adjustment - appliesToPriceIntervalIds = - adjustmentInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - endDate = adjustmentInterval.endDate - startDate = adjustmentInterval.startDate - additionalProperties = adjustmentInterval.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) - - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } - - fun adjustment(planPhaseUsageDiscount: Adjustment.PlanPhaseUsageDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)) - - fun adjustment(planPhaseAmountDiscount: Adjustment.PlanPhaseAmountDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)) - - fun adjustment( - planPhasePercentageDiscount: Adjustment.PlanPhasePercentageDiscountAdjustment - ) = adjustment(Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)) - - fun adjustment(planPhaseMinimum: Adjustment.PlanPhaseMinimumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)) - - fun adjustment(planPhaseMaximum: Adjustment.PlanPhaseMaximumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)) - - /** The price interval IDs that this adjustment applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval IDs that this adjustment applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval IDs that this adjustment applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - /** The end date of the adjustment interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the adjustment interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the adjustment interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** The start date of the adjustment interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the adjustment interval. */ - 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) - } - - fun build(): AdjustmentInterval = - AdjustmentInterval( - checkRequired("id", id), - checkRequired("adjustment", adjustment), - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment? = null, - private val planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment? = null, - private val planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment? = null, - private val planPhaseMinimum: PlanPhaseMinimumAdjustment? = null, - private val planPhaseMaximum: PlanPhaseMaximumAdjustment? = null, - private val _json: JsonValue? = null, - ) { - - fun planPhaseUsageDiscount(): Optional = - Optional.ofNullable(planPhaseUsageDiscount) - - fun planPhaseAmountDiscount(): Optional = - Optional.ofNullable(planPhaseAmountDiscount) - - fun planPhasePercentageDiscount(): Optional = - Optional.ofNullable(planPhasePercentageDiscount) - - fun planPhaseMinimum(): Optional = - Optional.ofNullable(planPhaseMinimum) - - fun planPhaseMaximum(): Optional = - Optional.ofNullable(planPhaseMaximum) - - fun isPlanPhaseUsageDiscount(): Boolean = planPhaseUsageDiscount != null - - fun isPlanPhaseAmountDiscount(): Boolean = planPhaseAmountDiscount != null - - fun isPlanPhasePercentageDiscount(): Boolean = planPhasePercentageDiscount != null - - fun isPlanPhaseMinimum(): Boolean = planPhaseMinimum != null - - fun isPlanPhaseMaximum(): Boolean = planPhaseMaximum != null - - fun asPlanPhaseUsageDiscount(): PlanPhaseUsageDiscountAdjustment = - planPhaseUsageDiscount.getOrThrow("planPhaseUsageDiscount") - - fun asPlanPhaseAmountDiscount(): PlanPhaseAmountDiscountAdjustment = - planPhaseAmountDiscount.getOrThrow("planPhaseAmountDiscount") - - fun asPlanPhasePercentageDiscount(): PlanPhasePercentageDiscountAdjustment = - planPhasePercentageDiscount.getOrThrow("planPhasePercentageDiscount") - - fun asPlanPhaseMinimum(): PlanPhaseMinimumAdjustment = - planPhaseMinimum.getOrThrow("planPhaseMinimum") - - fun asPlanPhaseMaximum(): PlanPhaseMaximumAdjustment = - planPhaseMaximum.getOrThrow("planPhaseMaximum") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - planPhaseUsageDiscount != null -> - visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) - planPhaseAmountDiscount != null -> - visitor.visitPlanPhaseAmountDiscount(planPhaseAmountDiscount) - planPhasePercentageDiscount != null -> - visitor.visitPlanPhasePercentageDiscount(planPhasePercentageDiscount) - planPhaseMinimum != null -> visitor.visitPlanPhaseMinimum(planPhaseMinimum) - planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) { - planPhaseUsageDiscount.validate() - } - - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) { - planPhaseAmountDiscount.validate() - } - - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) { - planPhasePercentageDiscount.validate() - } - - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) { - planPhaseMinimum.validate() - } - - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) { - planPhaseMaximum.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Adjustment && planPhaseUsageDiscount == other.planPhaseUsageDiscount && planPhaseAmountDiscount == other.planPhaseAmountDiscount && planPhasePercentageDiscount == other.planPhasePercentageDiscount && planPhaseMinimum == other.planPhaseMinimum && planPhaseMaximum == other.planPhaseMaximum /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(planPhaseUsageDiscount, planPhaseAmountDiscount, planPhasePercentageDiscount, planPhaseMinimum, planPhaseMaximum) /* spotless:on */ - - override fun toString(): String = - when { - planPhaseUsageDiscount != null -> - "Adjustment{planPhaseUsageDiscount=$planPhaseUsageDiscount}" - planPhaseAmountDiscount != null -> - "Adjustment{planPhaseAmountDiscount=$planPhaseAmountDiscount}" - planPhasePercentageDiscount != null -> - "Adjustment{planPhasePercentageDiscount=$planPhasePercentageDiscount}" - planPhaseMinimum != null -> "Adjustment{planPhaseMinimum=$planPhaseMinimum}" - planPhaseMaximum != null -> "Adjustment{planPhaseMaximum=$planPhaseMaximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } - - companion object { - - @JvmStatic - fun ofPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = Adjustment(planPhaseUsageDiscount = planPhaseUsageDiscount) - - @JvmStatic - fun ofPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = Adjustment(planPhaseAmountDiscount = planPhaseAmountDiscount) - - @JvmStatic - fun ofPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = Adjustment(planPhasePercentageDiscount = planPhasePercentageDiscount) - - @JvmStatic - fun ofPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment) = - Adjustment(planPhaseMinimum = planPhaseMinimum) - - @JvmStatic - fun ofPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment) = - Adjustment(planPhaseMaximum = planPhaseMaximum) - } - - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { - - fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ): T - - fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ): T - - fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ): T - - fun visitPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment): T - - fun visitPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment): T - - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } - - internal class Deserializer : BaseDeserializer(Adjustment::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = - json.asObject().getOrNull()?.get("adjustment_type")?.asString()?.getOrNull() - - when (adjustmentType) { - "usage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseUsageDiscount = it, _json = json) - } - } - "amount_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseAmountDiscount = it, _json = json) - } - } - "percentage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment( - planPhasePercentageDiscount = it, - _json = json, - ) - } - } - "minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMinimum = it, _json = json) - } - } - "maximum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMaximum = it, _json = json) - } - } - } - - return Adjustment(_json = json) - } - } - - internal class Serializer : BaseSerializer(Adjustment::class) { - - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.planPhaseUsageDiscount != null -> - generator.writeObject(value.planPhaseUsageDiscount) - value.planPhaseAmountDiscount != null -> - generator.writeObject(value.planPhaseAmountDiscount) - value.planPhasePercentageDiscount != null -> - generator.writeObject(value.planPhasePercentageDiscount) - value.planPhaseMinimum != null -> - generator.writeObject(value.planPhaseMinimum) - value.planPhaseMaximum != null -> - generator.writeObject(value.planPhaseMaximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") - } - } - } - - @NoAutoDetect - class PlanPhaseUsageDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonProperty("usage_discount") - @ExcludeMissing - private val usageDiscount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - /** - * The number of usage units by which to discount the price this adjustment applies - * to in a given billing period. - */ - fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - /** - * The number of usage units by which to discount the price this adjustment applies - * to in a given billing period. - */ - @JsonProperty("usage_discount") - @ExcludeMissing - fun _usageDiscount(): JsonField = usageDiscount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseUsageDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - planPhaseOrder() - reason() - usageDiscount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseUsageDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var usageDiscount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - planPhaseUsageDiscountAdjustment: PlanPhaseUsageDiscountAdjustment - ) = apply { - id = planPhaseUsageDiscountAdjustment.id - adjustmentType = planPhaseUsageDiscountAdjustment.adjustmentType - appliesToPriceIds = - planPhaseUsageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseUsageDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseUsageDiscountAdjustment.planPhaseOrder - reason = planPhaseUsageDiscountAdjustment.reason - usageDiscount = planPhaseUsageDiscountAdjustment.usageDiscount - additionalProperties = - planPhaseUsageDiscountAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - /** - * The number of usage units by which to discount the price this adjustment - * applies to in a given billing period. - */ - fun usageDiscount(usageDiscount: Double) = - usageDiscount(JsonField.of(usageDiscount)) - - /** - * The number of usage units by which to discount the price this adjustment - * applies to in a given billing period. - */ - fun usageDiscount(usageDiscount: JsonField) = apply { - this.usageDiscount = usageDiscount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseUsageDiscountAdjustment = - PlanPhaseUsageDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - checkRequired("usageDiscount", usageDiscount), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - USAGE_DISCOUNT -> Known.USAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseUsageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, planPhaseOrder, reason, usageDiscount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseUsageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhaseAmountDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("amount_discount") - @ExcludeMissing - private val amountDiscount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** - * The amount by which to discount the prices this adjustment applies to in a given - * billing period. - */ - fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** - * The amount by which to discount the prices this adjustment applies to in a given - * billing period. - */ - @JsonProperty("amount_discount") - @ExcludeMissing - fun _amountDiscount(): JsonField = amountDiscount - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseAmountDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - amountDiscount() - appliesToPriceIds() - isInvoiceLevel() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseAmountDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var amountDiscount: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - planPhaseAmountDiscountAdjustment: PlanPhaseAmountDiscountAdjustment - ) = apply { - id = planPhaseAmountDiscountAdjustment.id - adjustmentType = planPhaseAmountDiscountAdjustment.adjustmentType - amountDiscount = planPhaseAmountDiscountAdjustment.amountDiscount - appliesToPriceIds = - planPhaseAmountDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseAmountDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseAmountDiscountAdjustment.planPhaseOrder - reason = planPhaseAmountDiscountAdjustment.reason - additionalProperties = - planPhaseAmountDiscountAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** - * The amount by which to discount the prices this adjustment applies to in a - * given billing period. - */ - fun amountDiscount(amountDiscount: String) = - amountDiscount(JsonField.of(amountDiscount)) - - /** - * The amount by which to discount the prices this adjustment applies to in a - * given billing period. - */ - fun amountDiscount(amountDiscount: JsonField) = apply { - this.amountDiscount = amountDiscount - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseAmountDiscountAdjustment = - PlanPhaseAmountDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("amountDiscount", amountDiscount), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseAmountDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, amountDiscount, appliesToPriceIds, isInvoiceLevel, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseAmountDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhasePercentageDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("percentage_discount") - @ExcludeMissing - private val percentageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(): Double = - percentageDiscount.getRequired("percentage_discount") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - @JsonProperty("percentage_discount") - @ExcludeMissing - fun _percentageDiscount(): JsonField = percentageDiscount - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhasePercentageDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - percentageDiscount() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhasePercentageDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var percentageDiscount: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - planPhasePercentageDiscountAdjustment: PlanPhasePercentageDiscountAdjustment - ) = apply { - id = planPhasePercentageDiscountAdjustment.id - adjustmentType = planPhasePercentageDiscountAdjustment.adjustmentType - appliesToPriceIds = - planPhasePercentageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhasePercentageDiscountAdjustment.isInvoiceLevel - percentageDiscount = - planPhasePercentageDiscountAdjustment.percentageDiscount - planPhaseOrder = planPhasePercentageDiscountAdjustment.planPhaseOrder - reason = planPhasePercentageDiscountAdjustment.reason - additionalProperties = - planPhasePercentageDiscountAdjustment.additionalProperties - .toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(percentageDiscount: Double) = - percentageDiscount(JsonField.of(percentageDiscount)) - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(percentageDiscount: JsonField) = apply { - this.percentageDiscount = percentageDiscount - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhasePercentageDiscountAdjustment = - PlanPhasePercentageDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("percentageDiscount", percentageDiscount), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val PERCENTAGE_DISCOUNT = of("percentage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhasePercentageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, percentageDiscount, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhasePercentageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhaseMinimumAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(): String = itemId.getRequired("item_id") - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The item ID that revenue from this minimum will be attributed to. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseMinimumAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - itemId() - minimumAmount() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseMinimumAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var itemId: JsonField? = null - private var minimumAmount: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(planPhaseMinimumAdjustment: PlanPhaseMinimumAdjustment) = - apply { - id = planPhaseMinimumAdjustment.id - adjustmentType = planPhaseMinimumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMinimumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMinimumAdjustment.isInvoiceLevel - itemId = planPhaseMinimumAdjustment.itemId - minimumAmount = planPhaseMinimumAdjustment.minimumAmount - planPhaseOrder = planPhaseMinimumAdjustment.planPhaseOrder - reason = planPhaseMinimumAdjustment.reason - additionalProperties = - planPhaseMinimumAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseMinimumAdjustment = - PlanPhaseMinimumAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("itemId", itemId), - checkRequired("minimumAmount", minimumAmount), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseMinimumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, itemId, minimumAmount, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseMinimumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhaseMaximumAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseMaximumAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - maximumAmount() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseMaximumAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var maximumAmount: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(planPhaseMaximumAdjustment: PlanPhaseMaximumAdjustment) = - apply { - id = planPhaseMaximumAdjustment.id - adjustmentType = planPhaseMaximumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMaximumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMaximumAdjustment.isInvoiceLevel - maximumAmount = planPhaseMaximumAdjustment.maximumAmount - planPhaseOrder = planPhaseMaximumAdjustment.planPhaseOrder - reason = planPhaseMaximumAdjustment.reason - additionalProperties = - planPhaseMaximumAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseMaximumAdjustment = - PlanPhaseMaximumAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("maximumAmount", maximumAmount), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseMaximumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, maximumAmount, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseMaximumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentInterval && id == other.id && adjustment == other.adjustment && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustment, appliesToPriceIntervalIds, endDate, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AdjustmentInterval{id=$id, adjustment=$adjustment, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BillingCycleAnchorConfiguration - @JsonCreator - private constructor( - @JsonProperty("day") @ExcludeMissing private val day: JsonField = JsonMissing.of(), - @JsonProperty("month") - @ExcludeMissing - private val month: JsonField = JsonMissing.of(), - @JsonProperty("year") @ExcludeMissing private val year: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun day(): Long = day.getRequired("day") - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(): Optional = Optional.ofNullable(month.getNullable("month")) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on - * 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(): Optional = Optional.ofNullable(year.getNullable("year")) - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - @JsonProperty("day") @ExcludeMissing fun _day(): JsonField = day - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - @JsonProperty("month") @ExcludeMissing fun _month(): JsonField = month - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on - * 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - @JsonProperty("year") @ExcludeMissing fun _year(): JsonField = year - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleAnchorConfiguration = apply { - if (validated) { - return@apply - } - - day() - month() - year() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleAnchorConfiguration]. */ - class Builder internal constructor() { - - private var day: JsonField? = null - private var month: JsonField = JsonMissing.of() - private var year: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration) = - apply { - day = billingCycleAnchorConfiguration.day - month = billingCycleAnchorConfiguration.month - year = billingCycleAnchorConfiguration.year - additionalProperties = - billingCycleAnchorConfiguration.additionalProperties.toMutableMap() - } - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun day(day: Long) = day(JsonField.of(day)) - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun day(day: JsonField) = apply { this.day = day } - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(month: Long?) = month(JsonField.ofNullable(month)) - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(month: Long) = month(month as Long?) - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun month(month: Optional) = month(month.orElse(null) as Long?) - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(month: JsonField) = apply { this.month = month } - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(year: Long?) = year(JsonField.ofNullable(year)) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(year: Long) = year(year as Long?) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun year(year: Optional) = year(year.orElse(null) as Long?) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(year: JsonField) = apply { this.year = year } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleAnchorConfiguration = - BillingCycleAnchorConfiguration( - checkRequired("day", day), - month, - year, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleAnchorConfiguration && day == other.day && month == other.month && year == other.year && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(day, month, year, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleAnchorConfiguration{day=$day, month=$month, year=$year, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(using = DiscountInterval.Deserializer::class) - @JsonSerialize(using = DiscountInterval.Serializer::class) - class DiscountInterval - private constructor( - private val amount: AmountDiscountInterval? = null, - private val percentage: PercentageDiscountInterval? = null, - private val usage: UsageDiscountInterval? = null, - private val _json: JsonValue? = null, - ) { - - fun amount(): Optional = Optional.ofNullable(amount) - - fun percentage(): Optional = Optional.ofNullable(percentage) - - fun usage(): Optional = Optional.ofNullable(usage) - - fun isAmount(): Boolean = amount != null - - fun isPercentage(): Boolean = percentage != null - - fun isUsage(): Boolean = usage != null - - fun asAmount(): AmountDiscountInterval = amount.getOrThrow("amount") - - fun asPercentage(): PercentageDiscountInterval = percentage.getOrThrow("percentage") - - fun asUsage(): UsageDiscountInterval = usage.getOrThrow("usage") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - amount != null -> visitor.visitAmount(amount) - percentage != null -> visitor.visitPercentage(percentage) - usage != null -> visitor.visitUsage(usage) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): DiscountInterval = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitAmount(amount: AmountDiscountInterval) { - amount.validate() - } - - override fun visitPercentage(percentage: PercentageDiscountInterval) { - percentage.validate() - } - - override fun visitUsage(usage: UsageDiscountInterval) { - usage.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountInterval && amount == other.amount && percentage == other.percentage && usage == other.usage /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(amount, percentage, usage) /* spotless:on */ - - override fun toString(): String = - when { - amount != null -> "DiscountInterval{amount=$amount}" - percentage != null -> "DiscountInterval{percentage=$percentage}" - usage != null -> "DiscountInterval{usage=$usage}" - _json != null -> "DiscountInterval{_unknown=$_json}" - else -> throw IllegalStateException("Invalid DiscountInterval") - } - - companion object { - - @JvmStatic - fun ofAmount(amount: AmountDiscountInterval) = DiscountInterval(amount = amount) - - @JvmStatic - fun ofPercentage(percentage: PercentageDiscountInterval) = - DiscountInterval(percentage = percentage) - - @JvmStatic fun ofUsage(usage: UsageDiscountInterval) = DiscountInterval(usage = usage) - } - - /** - * An interface that defines how to map each variant of [DiscountInterval] to a value of - * type [T]. - */ - interface Visitor { - - fun visitAmount(amount: AmountDiscountInterval): T - - fun visitPercentage(percentage: PercentageDiscountInterval): T - - fun visitUsage(usage: UsageDiscountInterval): T - - /** - * Maps an unknown variant of [DiscountInterval] to a value of type [T]. - * - * An instance of [DiscountInterval] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown DiscountInterval: $json") - } - } - - internal class Deserializer : BaseDeserializer(DiscountInterval::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): DiscountInterval { - val json = JsonValue.fromJsonNode(node) - val discountType = - json.asObject().getOrNull()?.get("discount_type")?.asString()?.getOrNull() - - when (discountType) { - "amount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(amount = it, _json = json) - } - } - "percentage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(percentage = it, _json = json) - } - } - "usage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(usage = it, _json = json) - } - } - } - - return DiscountInterval(_json = json) - } - } - - internal class Serializer : BaseSerializer(DiscountInterval::class) { - - override fun serialize( - value: DiscountInterval, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.amount != null -> generator.writeObject(value.amount) - value.percentage != null -> generator.writeObject(value.percentage) - value.usage != null -> generator.writeObject(value.usage) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid DiscountInterval") - } - } - } - - @NoAutoDetect - class AmountDiscountInterval - @JsonCreator - private constructor( - @JsonProperty("amount_discount") - @ExcludeMissing - private val amountDiscount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("discount_type") - @ExcludeMissing - private val discountType: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - fun discountType(): DiscountType = discountType.getRequired("discount_type") - - /** The end date of the discount interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** The start date of the discount interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** Only available if discount_type is `amount`. */ - @JsonProperty("amount_discount") - @ExcludeMissing - fun _amountDiscount(): JsonField = amountDiscount - - /** The price ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - - /** The end date of the discount interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** The start date of the discount interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AmountDiscountInterval = apply { - if (validated) { - return@apply - } - - amountDiscount() - appliesToPriceIds() - appliesToPriceIntervalIds() - discountType() - endDate() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AmountDiscountInterval]. */ - class Builder internal constructor() { - - private var amountDiscount: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { - amountDiscount = amountDiscountInterval.amountDiscount - appliesToPriceIds = - amountDiscountInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - amountDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = amountDiscountInterval.discountType - endDate = amountDiscountInterval.endDate - startDate = amountDiscountInterval.startDate - additionalProperties = - amountDiscountInterval.additionalProperties.toMutableMap() - } - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(amountDiscount: String) = - amountDiscount(JsonField.of(amountDiscount)) - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(amountDiscount: JsonField) = apply { - this.amountDiscount = amountDiscount - } - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this discount interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this discount interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the discount interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the discount interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** The start date of the discount interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the discount interval. */ - 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) - } - - fun build(): AmountDiscountInterval = - AmountDiscountInterval( - checkRequired("amountDiscount", amountDiscount), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("discountType", discountType), - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val AMOUNT = of("amount") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - AMOUNT - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT -> Value.AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AMOUNT -> Known.AMOUNT - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AmountDiscountInterval && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amountDiscount, appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AmountDiscountInterval{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PercentageDiscountInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("discount_type") - @ExcludeMissing - private val discountType: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("percentage_discount") - @ExcludeMissing - private val percentageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - fun discountType(): DiscountType = discountType.getRequired("discount_type") - - /** The end date of the discount interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ - fun percentageDiscount(): Double = percentageDiscount.getRequired("percentage_discount") - - /** The start date of the discount interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** The price ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - - /** The end date of the discount interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ - @JsonProperty("percentage_discount") - @ExcludeMissing - fun _percentageDiscount(): JsonField = percentageDiscount - - /** The start date of the discount interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PercentageDiscountInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - discountType() - endDate() - percentageDiscount() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PercentageDiscountInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null - private var endDate: JsonField? = null - private var percentageDiscount: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { - appliesToPriceIds = - percentageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - percentageDiscountInterval.appliesToPriceIntervalIds.map { - it.toMutableList() - } - discountType = percentageDiscountInterval.discountType - endDate = percentageDiscountInterval.endDate - percentageDiscount = percentageDiscountInterval.percentageDiscount - startDate = percentageDiscountInterval.startDate - additionalProperties = - percentageDiscountInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this discount interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this discount interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the discount interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the discount interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** - * Only available if discount_type is `percentage`.This is a number between 0 and 1. - */ - fun percentageDiscount(percentageDiscount: Double) = - percentageDiscount(JsonField.of(percentageDiscount)) - - /** - * Only available if discount_type is `percentage`.This is a number between 0 and 1. - */ - fun percentageDiscount(percentageDiscount: JsonField) = apply { - this.percentageDiscount = percentageDiscount - } - - /** The start date of the discount interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the discount interval. */ - 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) - } - - fun build(): PercentageDiscountInterval = - PercentageDiscountInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("discountType", discountType), - checkRequired("endDate", endDate), - checkRequired("percentageDiscount", percentageDiscount), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val PERCENTAGE = of("percentage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - PERCENTAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE -> Value.PERCENTAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PERCENTAGE -> Known.PERCENTAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PercentageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, percentageDiscount, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PercentageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class UsageDiscountInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("discount_type") - @ExcludeMissing - private val discountType: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonProperty("usage_discount") - @ExcludeMissing - private val usageDiscount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - fun discountType(): DiscountType = discountType.getRequired("discount_type") - - /** The end date of the discount interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** The start date of the discount interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** - * Only available if discount_type is `usage`. Number of usage units that this discount - * is for - */ - fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - - /** The price ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - - /** The end date of the discount interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** The start date of the discount interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - /** - * Only available if discount_type is `usage`. Number of usage units that this discount - * is for - */ - @JsonProperty("usage_discount") - @ExcludeMissing - fun _usageDiscount(): JsonField = usageDiscount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): UsageDiscountInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - discountType() - endDate() - startDate() - usageDiscount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UsageDiscountInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var usageDiscount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { - appliesToPriceIds = - usageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - usageDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = usageDiscountInterval.discountType - endDate = usageDiscountInterval.endDate - startDate = usageDiscountInterval.startDate - usageDiscount = usageDiscountInterval.usageDiscount - additionalProperties = usageDiscountInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this discount interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this discount interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the discount interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the discount interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** The start date of the discount interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the discount interval. */ - fun startDate(startDate: JsonField) = apply { - this.startDate = startDate - } - - /** - * Only available if discount_type is `usage`. Number of usage units that this - * discount is for - */ - fun usageDiscount(usageDiscount: Double) = - usageDiscount(JsonField.of(usageDiscount)) - - /** - * Only available if discount_type is `usage`. Number of usage units that this - * discount is for - */ - fun usageDiscount(usageDiscount: JsonField) = apply { - this.usageDiscount = usageDiscount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): UsageDiscountInterval = - UsageDiscountInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("discountType", discountType), - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - checkRequired("usageDiscount", usageDiscount), - additionalProperties.toImmutable(), - ) - } - - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE = of("usage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - USAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE -> Value.USAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE -> Known.USAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UsageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, startDate, usageDiscount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UsageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" - } - } - - @NoAutoDetect - class FixedFeeQuantitySchedule - @JsonCreator - private constructor( - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("price_id") - @ExcludeMissing - private val priceId: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - private val quantity: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - fun priceId(): String = priceId.getRequired("price_id") - - fun quantity(): Double = quantity.getRequired("quantity") - - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - - @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): FixedFeeQuantitySchedule = apply { - if (validated) { - return@apply - } - - endDate() - priceId() - quantity() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FixedFeeQuantitySchedule]. */ - class Builder internal constructor() { - - private var endDate: JsonField? = null - private var priceId: JsonField? = null - private var quantity: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = apply { - endDate = fixedFeeQuantitySchedule.endDate - priceId = fixedFeeQuantitySchedule.priceId - quantity = fixedFeeQuantitySchedule.quantity - startDate = fixedFeeQuantitySchedule.startDate - additionalProperties = fixedFeeQuantitySchedule.additionalProperties.toMutableMap() - } - - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) - - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - 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) - } - - fun build(): FixedFeeQuantitySchedule = - FixedFeeQuantitySchedule( - checkRequired("endDate", endDate), - checkRequired("priceId", priceId), - checkRequired("quantity", quantity), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FixedFeeQuantitySchedule && endDate == other.endDate && priceId == other.priceId && quantity == other.quantity && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(endDate, priceId, quantity, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "FixedFeeQuantitySchedule{endDate=$endDate, priceId=$priceId, quantity=$quantity, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class MaximumInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this maximum interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this maximum interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - /** The end date of the maximum interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** The start date of the maximum interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** The price ids that this maximum interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this maximum interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - /** The end date of the maximum interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** The start date of the maximum interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MaximumInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - endDate() - maximumAmount() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MaximumInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var endDate: JsonField? = null - private var maximumAmount: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximumInterval: MaximumInterval) = apply { - appliesToPriceIds = maximumInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - maximumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - endDate = maximumInterval.endDate - maximumAmount = maximumInterval.maximumAmount - startDate = maximumInterval.startDate - additionalProperties = maximumInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this maximum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this maximum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this maximum interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this maximum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this maximum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this maximum interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - /** The end date of the maximum interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the maximum interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the maximum interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** The start date of the maximum interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the maximum interval. */ - 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) - } - - fun build(): MaximumInterval = - MaximumInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("endDate", endDate), - checkRequired("maximumAmount", maximumAmount), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MaximumInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && maximumAmount == other.maximumAmount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, endDate, maximumAmount, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MaximumInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, maximumAmount=$maximumAmount, startDate=$startDate, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class MinimumInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this minimum interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this minimum interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - /** The end date of the minimum interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** The start date of the minimum interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** The price ids that this minimum interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this minimum interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - /** The end date of the minimum interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** The start date of the minimum interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MinimumInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - endDate() - minimumAmount() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MinimumInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var endDate: JsonField? = null - private var minimumAmount: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(minimumInterval: MinimumInterval) = apply { - appliesToPriceIds = minimumInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - minimumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - endDate = minimumInterval.endDate - minimumAmount = minimumInterval.minimumAmount - startDate = minimumInterval.startDate - additionalProperties = minimumInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this minimum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this minimum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this minimum interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this minimum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this minimum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this minimum interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - /** The end date of the minimum interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the minimum interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the minimum interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** The start date of the minimum interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the minimum interval. */ - 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) - } - - fun build(): MinimumInterval = - MinimumInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("endDate", endDate), - checkRequired("minimumAmount", minimumAmount), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MinimumInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && minimumAmount == other.minimumAmount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, endDate, minimumAmount, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MinimumInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, minimumAmount=$minimumAmount, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - /** - * The Price Interval resource represents a period of time for which a price will bill on a - * subscription. A subscription’s price intervals define its billing behavior. - */ - @NoAutoDetect - class PriceInterval - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_day") - @ExcludeMissing - private val billingCycleDay: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - private val currentBillingPeriodEndDate: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - private val currentBillingPeriodStartDate: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("filter") - @ExcludeMissing - private val filter: JsonField = JsonMissing.of(), - @JsonProperty("fixed_fee_quantity_transitions") - @ExcludeMissing - private val fixedFeeQuantityTransitions: JsonField> = - JsonMissing.of(), - @JsonProperty("price") - @ExcludeMissing - private val price: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonProperty("usage_customer_ids") - @ExcludeMissing - private val usageCustomerIds: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - /** The day of the month that Orb bills for this price */ - fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate(): Optional = - Optional.ofNullable( - currentBillingPeriodEndDate.getNullable("current_billing_period_end_date") - ) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodStartDate(): Optional = - Optional.ofNullable( - currentBillingPeriodStartDate.getNullable("current_billing_period_start_date") - ) - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** An additional filter to apply to usage queries. */ - fun filter(): Optional = Optional.ofNullable(filter.getNullable("filter")) - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions(): Optional> = - Optional.ofNullable( - fixedFeeQuantityTransitions.getNullable("fixed_fee_quantity_transitions") - ) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting in - * a charge on an invoice in the form of an invoice line item. Prices take a quantity and - * determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the key - * for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(): Price = price.getRequired("price") - - /** - * The start date of the price interval. This is the date that Orb starts billing for this - * price. - */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this price - * interval. - */ - fun usageCustomerIds(): Optional> = - Optional.ofNullable(usageCustomerIds.getNullable("usage_customer_ids")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** The day of the month that Orb bills for this price */ - @JsonProperty("billing_cycle_day") - @ExcludeMissing - fun _billingCycleDay(): JsonField = billingCycleDay - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if this price - * interval is not currently active. - */ - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - fun _currentBillingPeriodStartDate(): JsonField = - currentBillingPeriodStartDate - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** An additional filter to apply to usage queries. */ - @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField = filter - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - @JsonProperty("fixed_fee_quantity_transitions") - @ExcludeMissing - fun _fixedFeeQuantityTransitions(): JsonField> = - fixedFeeQuantityTransitions - - /** - * 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) - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - - /** - * The start date of the price interval. This is the date that Orb starts billing for this - * price. - */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this price - * interval. - */ - @JsonProperty("usage_customer_ids") - @ExcludeMissing - fun _usageCustomerIds(): JsonField> = usageCustomerIds - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PriceInterval = apply { - if (validated) { - return@apply - } - - id() - billingCycleDay() - currentBillingPeriodEndDate() - currentBillingPeriodStartDate() - endDate() - filter() - fixedFeeQuantityTransitions().ifPresent { it.forEach { it.validate() } } - price().validate() - startDate() - usageCustomerIds() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PriceInterval]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var billingCycleDay: JsonField? = null - private var currentBillingPeriodEndDate: JsonField? = null - private var currentBillingPeriodStartDate: JsonField? = null - private var endDate: JsonField? = null - private var filter: JsonField? = null - private var fixedFeeQuantityTransitions: - JsonField>? = - null - private var price: JsonField? = null - private var startDate: JsonField? = null - private var usageCustomerIds: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(priceInterval: PriceInterval) = apply { - id = priceInterval.id - billingCycleDay = priceInterval.billingCycleDay - currentBillingPeriodEndDate = priceInterval.currentBillingPeriodEndDate - currentBillingPeriodStartDate = priceInterval.currentBillingPeriodStartDate - endDate = priceInterval.endDate - filter = priceInterval.filter - fixedFeeQuantityTransitions = - priceInterval.fixedFeeQuantityTransitions.map { it.toMutableList() } - price = priceInterval.price - startDate = priceInterval.startDate - usageCustomerIds = priceInterval.usageCustomerIds.map { it.toMutableList() } - additionalProperties = priceInterval.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - /** The day of the month that Orb bills for this price */ - fun billingCycleDay(billingCycleDay: Long) = - billingCycleDay(JsonField.of(billingCycleDay)) - - /** The day of the month that Orb bills for this price */ - fun billingCycleDay(billingCycleDay: JsonField) = apply { - this.billingCycleDay = billingCycleDay - } - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = - currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = - currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate( - currentBillingPeriodEndDate: JsonField - ) = apply { this.currentBillingPeriodEndDate = currentBillingPeriodEndDate } - - /** - * The start date of the current billing period. This is an inclusive timestamp; the - * instant returned is exactly the beginning of the billing period. Set to null if this - * price interval is not currently active. - */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = - currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the - * instant returned is exactly the beginning of the billing period. Set to null if this - * price interval is not currently active. - */ - fun currentBillingPeriodStartDate( - currentBillingPeriodStartDate: Optional - ) = currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the - * instant returned is exactly the beginning of the billing period. Set to null if this - * price interval is not currently active. - */ - fun currentBillingPeriodStartDate( - currentBillingPeriodStartDate: JsonField - ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** An additional filter to apply to usage queries. */ - fun filter(filter: String?) = filter(JsonField.ofNullable(filter)) - - /** An additional filter to apply to usage queries. */ - fun filter(filter: Optional) = filter(filter.orElse(null)) - - /** An additional filter to apply to usage queries. */ - fun filter(filter: JsonField) = apply { this.filter = filter } - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: List? - ) = fixedFeeQuantityTransitions(JsonField.ofNullable(fixedFeeQuantityTransitions)) - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: Optional> - ) = fixedFeeQuantityTransitions(fixedFeeQuantityTransitions.orElse(null)) - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: JsonField> - ) = apply { - this.fixedFeeQuantityTransitions = - fixedFeeQuantityTransitions.map { it.toMutableList() } - } - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun addFixedFeeQuantityTransition( - fixedFeeQuantityTransition: FixedFeeQuantityTransition - ) = apply { - fixedFeeQuantityTransitions = - (fixedFeeQuantityTransitions ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(fixedFeeQuantityTransition) - } - } - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(price: Price) = price(JsonField.of(price)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(price: JsonField) = apply { this.price = price } - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(matrix: Price.MatrixPrice) = price(Price.ofMatrix(matrix)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredPackage: Price.TieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedTiered: Price.GroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(unitWithPercent: Price.UnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredWithProration: Price.TieredWithProrationPrice) = - price(Price.ofTieredWithProration(tieredWithProration)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(unitWithProration: Price.UnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedAllocation: Price.GroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bulkWithProration: Price.BulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = - price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice) = - price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - - /** - * The start date of the price interval. This is the date that Orb starts billing for - * this price. - */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** - * The start date of the price interval. This is the date that Orb starts billing for - * this price. - */ - fun startDate(startDate: JsonField) = apply { - this.startDate = startDate - } - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun usageCustomerIds(usageCustomerIds: List?) = - usageCustomerIds(JsonField.ofNullable(usageCustomerIds)) - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun usageCustomerIds(usageCustomerIds: Optional>) = - usageCustomerIds(usageCustomerIds.orElse(null)) - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun usageCustomerIds(usageCustomerIds: JsonField>) = apply { - this.usageCustomerIds = usageCustomerIds.map { it.toMutableList() } - } - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun addUsageCustomerId(usageCustomerId: String) = apply { - usageCustomerIds = - (usageCustomerIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(usageCustomerId) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): PriceInterval = - PriceInterval( - checkRequired("id", id), - checkRequired("billingCycleDay", billingCycleDay), - checkRequired("currentBillingPeriodEndDate", currentBillingPeriodEndDate), - checkRequired("currentBillingPeriodStartDate", currentBillingPeriodStartDate), - checkRequired("endDate", endDate), - checkRequired("filter", filter), - checkRequired("fixedFeeQuantityTransitions", fixedFeeQuantityTransitions).map { - it.toImmutable() - }, - checkRequired("price", price), - checkRequired("startDate", startDate), - checkRequired("usageCustomerIds", usageCustomerIds).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class FixedFeeQuantityTransition - @JsonCreator - private constructor( - @JsonProperty("effective_date") - @ExcludeMissing - private val effectiveDate: JsonField = JsonMissing.of(), - @JsonProperty("price_id") - @ExcludeMissing - private val priceId: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - private val quantity: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun effectiveDate(): OffsetDateTime = effectiveDate.getRequired("effective_date") - - fun priceId(): String = priceId.getRequired("price_id") - - fun quantity(): Long = quantity.getRequired("quantity") - - @JsonProperty("effective_date") - @ExcludeMissing - fun _effectiveDate(): JsonField = effectiveDate - - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - - @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): FixedFeeQuantityTransition = apply { - if (validated) { - return@apply - } - - effectiveDate() - priceId() - quantity() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FixedFeeQuantityTransition]. */ - class Builder internal constructor() { - - private var effectiveDate: JsonField? = null - private var priceId: JsonField? = null - private var quantity: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(fixedFeeQuantityTransition: FixedFeeQuantityTransition) = apply { - effectiveDate = fixedFeeQuantityTransition.effectiveDate - priceId = fixedFeeQuantityTransition.priceId - quantity = fixedFeeQuantityTransition.quantity - additionalProperties = - fixedFeeQuantityTransition.additionalProperties.toMutableMap() - } - - fun effectiveDate(effectiveDate: OffsetDateTime) = - effectiveDate(JsonField.of(effectiveDate)) - - fun effectiveDate(effectiveDate: JsonField) = apply { - this.effectiveDate = effectiveDate - } - - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) - - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - - fun quantity(quantity: Long) = quantity(JsonField.of(quantity)) - - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): FixedFeeQuantityTransition = - FixedFeeQuantityTransition( - checkRequired("effectiveDate", effectiveDate), - checkRequired("priceId", priceId), - checkRequired("quantity", quantity), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FixedFeeQuantityTransition && effectiveDate == other.effectiveDate && priceId == other.priceId && quantity == other.quantity && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(effectiveDate, priceId, quantity, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "FixedFeeQuantityTransition{effectiveDate=$effectiveDate, priceId=$priceId, quantity=$quantity, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PriceInterval && id == other.id && billingCycleDay == other.billingCycleDay && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && endDate == other.endDate && filter == other.filter && fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && price == other.price && startDate == other.startDate && usageCustomerIds == other.usageCustomerIds && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billingCycleDay, currentBillingPeriodEndDate, currentBillingPeriodStartDate, endDate, filter, fixedFeeQuantityTransitions, price, startDate, usageCustomerIds, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PriceInterval{id=$id, billingCycleDay=$billingCycleDay, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, endDate=$endDate, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, price=$price, startDate=$startDate, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class RedeemedCoupon - @JsonCreator - private constructor( - @JsonProperty("coupon_id") - @ExcludeMissing - private val couponId: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun couponId(): String = couponId.getRequired("coupon_id") - - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - @JsonProperty("coupon_id") @ExcludeMissing fun _couponId(): JsonField = couponId - - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): RedeemedCoupon = apply { - if (validated) { - return@apply - } - - couponId() - endDate() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RedeemedCoupon]. */ - class Builder internal constructor() { - - private var couponId: JsonField? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(redeemedCoupon: RedeemedCoupon) = apply { - couponId = redeemedCoupon.couponId - endDate = redeemedCoupon.endDate - startDate = redeemedCoupon.startDate - additionalProperties = redeemedCoupon.additionalProperties.toMutableMap() - } - - fun couponId(couponId: String) = couponId(JsonField.of(couponId)) - - fun couponId(couponId: JsonField) = apply { this.couponId = couponId } - - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - 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) - } - - fun build(): RedeemedCoupon = - RedeemedCoupon( - checkRequired("couponId", couponId), - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RedeemedCoupon && couponId == other.couponId && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(couponId, endDate, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RedeemedCoupon{couponId=$couponId, endDate=$endDate, startDate=$startDate, 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 ENDED = of("ended") - - @JvmField val UPCOMING = of("upcoming") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - ACTIVE, - ENDED, - UPCOMING, - } - - /** - * 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, - ENDED, - UPCOMING, - /** 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 - ENDED -> Value.ENDED - UPCOMING -> Value.UPCOMING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to 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 - ENDED -> Known.ENDED - UPCOMING -> Known.UPCOMING - 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TrialInfo - @JsonCreator - private constructor( - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TrialInfo = apply { - if (validated) { - return@apply - } - - endDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TrialInfo]. */ - class Builder internal constructor() { - - private var endDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(trialInfo: TrialInfo) = apply { - endDate = trialInfo.endDate - additionalProperties = trialInfo.additionalProperties.toMutableMap() - } - - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - 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) - } - - fun build(): TrialInfo = - TrialInfo(checkRequired("endDate", endDate), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TrialInfo && endDate == other.endDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(endDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TrialInfo{endDate=$endDate, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse && id == other.id && activePlanPhaseOrder == other.activePlanPhaseOrder && adjustmentIntervals == other.adjustmentIntervals && autoCollection == other.autoCollection && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && billingCycleDay == other.billingCycleDay && createdAt == other.createdAt && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && customer == other.customer && defaultInvoiceMemo == other.defaultInvoiceMemo && discountIntervals == other.discountIntervals && endDate == other.endDate && fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && invoicingThreshold == other.invoicingThreshold && maximumIntervals == other.maximumIntervals && metadata == other.metadata && minimumIntervals == other.minimumIntervals && netTerms == other.netTerms && plan == other.plan && priceIntervals == other.priceIntervals && redeemedCoupon == other.redeemedCoupon && startDate == other.startDate && status == other.status && trialInfo == other.trialInfo && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, activePlanPhaseOrder, adjustmentIntervals, autoCollection, billingCycleAnchorConfiguration, billingCycleDay, createdAt, currentBillingPeriodEndDate, currentBillingPeriodStartDate, customer, defaultInvoiceMemo, discountIntervals, endDate, fixedFeeQuantitySchedule, invoicingThreshold, maximumIntervals, metadata, minimumIntervals, netTerms, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse{id=$id, activePlanPhaseOrder=$activePlanPhaseOrder, adjustmentIntervals=$adjustmentIntervals, autoCollection=$autoCollection, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, billingCycleDay=$billingCycleDay, createdAt=$createdAt, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, customer=$customer, defaultInvoiceMemo=$defaultInvoiceMemo, discountIntervals=$discountIntervals, endDate=$endDate, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, invoicingThreshold=$invoicingThreshold, maximumIntervals=$maximumIntervals, metadata=$metadata, minimumIntervals=$minimumIntervals, netTerms=$netTerms, plan=$plan, priceIntervals=$priceIntervals, redeemedCoupon=$redeemedCoupon, startDate=$startDate, status=$status, trialInfo=$trialInfo, additionalProperties=$additionalProperties}" -} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesParams.kt index 6abdc39c6..692f76de4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesParams.kt @@ -48,6 +48,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [SubscriptionUnschedulePendingPlanChangesParams]. + * + * The following fields are required: + * ```java + * .subscriptionId() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesResponse.kt deleted file mode 100644 index 19852f269..000000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesResponse.kt +++ /dev/null @@ -1,7183 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer -import com.withorb.api.core.Enum -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow -import com.withorb.api.core.immutableEmptyMap -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -@NoAutoDetect -class SubscriptionUnschedulePendingPlanChangesResponse -@JsonCreator -private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("active_plan_phase_order") - @ExcludeMissing - private val activePlanPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_intervals") - @ExcludeMissing - private val adjustmentIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("auto_collection") - @ExcludeMissing - private val autoCollection: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_anchor_configuration") - @ExcludeMissing - private val billingCycleAnchorConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("billing_cycle_day") - @ExcludeMissing - private val billingCycleDay: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - private val currentBillingPeriodEndDate: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - private val currentBillingPeriodStartDate: JsonField = JsonMissing.of(), - @JsonProperty("customer") - @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), - @JsonProperty("default_invoice_memo") - @ExcludeMissing - private val defaultInvoiceMemo: JsonField = JsonMissing.of(), - @JsonProperty("discount_intervals") - @ExcludeMissing - private val discountIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("fixed_fee_quantity_schedule") - @ExcludeMissing - private val fixedFeeQuantitySchedule: JsonField> = - JsonMissing.of(), - @JsonProperty("invoicing_threshold") - @ExcludeMissing - private val invoicingThreshold: JsonField = JsonMissing.of(), - @JsonProperty("maximum_intervals") - @ExcludeMissing - private val maximumIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("minimum_intervals") - @ExcludeMissing - private val minimumIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("net_terms") - @ExcludeMissing - private val netTerms: JsonField = JsonMissing.of(), - @JsonProperty("plan") @ExcludeMissing private val plan: JsonField = JsonMissing.of(), - @JsonProperty("price_intervals") - @ExcludeMissing - private val priceIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("redeemed_coupon") - @ExcludeMissing - private val redeemedCoupon: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonProperty("status") - @ExcludeMissing - private val status: JsonField = JsonMissing.of(), - @JsonProperty("trial_info") - @ExcludeMissing - private val trialInfo: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun id(): String = id.getRequired("id") - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(): Optional = - Optional.ofNullable(activePlanPhaseOrder.getNullable("active_plan_phase_order")) - - /** The adjustment intervals for this subscription. */ - fun adjustmentIntervals(): List = - adjustmentIntervals.getRequired("adjustment_intervals") - - /** - * Determines whether issued invoices for this subscription will automatically be charged with - * the saved payment method on the due date. This property defaults to the plan's behavior. If - * null, defaults to the customer's setting. - */ - fun autoCollection(): Optional = - Optional.ofNullable(autoCollection.getNullable("auto_collection")) - - fun billingCycleAnchorConfiguration(): BillingCycleAnchorConfiguration = - billingCycleAnchorConfiguration.getRequired("billing_cycle_anchor_configuration") - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of days in - * a month is greater than this value, the last day of the month is the billing cycle day (e.g. - * billing_cycle_day=31 for April means the billing period begins on the 30th. - */ - fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the instant - * returned is not part of the billing period. Set to null for subscriptions that are not - * currently active. - */ - fun currentBillingPeriodEndDate(): Optional = - Optional.ofNullable( - currentBillingPeriodEndDate.getNullable("current_billing_period_end_date") - ) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription is - * not currently active. - */ - fun currentBillingPeriodStartDate(): Optional = - Optional.ofNullable( - currentBillingPeriodStartDate.getNullable("current_billing_period_start_date") - ) - - /** - * 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 customer(): Customer = customer.getRequired("customer") - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(): Optional = - Optional.ofNullable(defaultInvoiceMemo.getNullable("default_invoice_memo")) - - /** The discount intervals for this subscription. */ - fun discountIntervals(): List = - discountIntervals.getRequired("discount_intervals") - - /** The date Orb stops billing for this subscription. */ - fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) - - fun fixedFeeQuantitySchedule(): List = - fixedFeeQuantitySchedule.getRequired("fixed_fee_quantity_schedule") - - fun invoicingThreshold(): Optional = - Optional.ofNullable(invoicingThreshold.getNullable("invoicing_threshold")) - - /** The maximum intervals for this subscription. */ - fun maximumIntervals(): List = - maximumIntervals.getRequired("maximum_intervals") - - /** - * 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.getRequired("metadata") - - /** The minimum intervals for this subscription. */ - fun minimumIntervals(): List = - minimumIntervals.getRequired("minimum_intervals") - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - fun netTerms(): Long = netTerms.getRequired("net_terms") - - /** - * 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 plan(): Plan = plan.getRequired("plan") - - /** The price intervals for this subscription. */ - fun priceIntervals(): List = priceIntervals.getRequired("price_intervals") - - fun redeemedCoupon(): Optional = - Optional.ofNullable(redeemedCoupon.getNullable("redeemed_coupon")) - - /** The date Orb starts billing for this subscription. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - fun status(): Status = status.getRequired("status") - - fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - @JsonProperty("active_plan_phase_order") - @ExcludeMissing - fun _activePlanPhaseOrder(): JsonField = activePlanPhaseOrder - - /** The adjustment intervals for this subscription. */ - @JsonProperty("adjustment_intervals") - @ExcludeMissing - fun _adjustmentIntervals(): JsonField> = adjustmentIntervals - - /** - * Determines whether issued invoices for this subscription will automatically be charged with - * the saved payment method on the due date. This property defaults to the plan's behavior. If - * null, defaults to the customer's setting. - */ - @JsonProperty("auto_collection") - @ExcludeMissing - fun _autoCollection(): JsonField = autoCollection - - @JsonProperty("billing_cycle_anchor_configuration") - @ExcludeMissing - fun _billingCycleAnchorConfiguration(): JsonField = - billingCycleAnchorConfiguration - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of days in - * a month is greater than this value, the last day of the month is the billing cycle day (e.g. - * billing_cycle_day=31 for April means the billing period begins on the 30th. - */ - @JsonProperty("billing_cycle_day") - @ExcludeMissing - fun _billingCycleDay(): JsonField = billingCycleDay - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the instant - * returned is not part of the billing period. Set to null for subscriptions that are not - * currently active. - */ - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription is - * not currently active. - */ - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - fun _currentBillingPeriodStartDate(): JsonField = currentBillingPeriodStartDate - - /** - * 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. - */ - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - @JsonProperty("default_invoice_memo") - @ExcludeMissing - fun _defaultInvoiceMemo(): JsonField = defaultInvoiceMemo - - /** The discount intervals for this subscription. */ - @JsonProperty("discount_intervals") - @ExcludeMissing - fun _discountIntervals(): JsonField> = discountIntervals - - /** The date Orb stops billing for this subscription. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate - - @JsonProperty("fixed_fee_quantity_schedule") - @ExcludeMissing - fun _fixedFeeQuantitySchedule(): JsonField> = - fixedFeeQuantitySchedule - - @JsonProperty("invoicing_threshold") - @ExcludeMissing - fun _invoicingThreshold(): JsonField = invoicingThreshold - - /** The maximum intervals for this subscription. */ - @JsonProperty("maximum_intervals") - @ExcludeMissing - fun _maximumIntervals(): JsonField> = maximumIntervals - - /** - * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - /** The minimum intervals for this subscription. */ - @JsonProperty("minimum_intervals") - @ExcludeMissing - fun _minimumIntervals(): JsonField> = minimumIntervals - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms - - /** - * 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). - */ - @JsonProperty("plan") @ExcludeMissing fun _plan(): JsonField = plan - - /** The price intervals for this subscription. */ - @JsonProperty("price_intervals") - @ExcludeMissing - fun _priceIntervals(): JsonField> = priceIntervals - - @JsonProperty("redeemed_coupon") - @ExcludeMissing - fun _redeemedCoupon(): JsonField = redeemedCoupon - - /** The date Orb starts billing for this subscription. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo(): JsonField = trialInfo - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): SubscriptionUnschedulePendingPlanChangesResponse = apply { - if (validated) { - return@apply - } - - id() - activePlanPhaseOrder() - adjustmentIntervals().forEach { it.validate() } - autoCollection() - billingCycleAnchorConfiguration().validate() - billingCycleDay() - createdAt() - currentBillingPeriodEndDate() - currentBillingPeriodStartDate() - customer().validate() - defaultInvoiceMemo() - discountIntervals().forEach { it.validate() } - endDate() - fixedFeeQuantitySchedule().forEach { it.validate() } - invoicingThreshold() - maximumIntervals().forEach { it.validate() } - metadata().validate() - minimumIntervals().forEach { it.validate() } - netTerms() - plan().validate() - priceIntervals().forEach { it.validate() } - redeemedCoupon().ifPresent { it.validate() } - startDate() - status() - trialInfo().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SubscriptionUnschedulePendingPlanChangesResponse]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var activePlanPhaseOrder: JsonField? = null - private var adjustmentIntervals: JsonField>? = null - private var autoCollection: JsonField? = null - private var billingCycleAnchorConfiguration: JsonField? = - null - private var billingCycleDay: JsonField? = null - private var createdAt: JsonField? = null - private var currentBillingPeriodEndDate: JsonField? = null - private var currentBillingPeriodStartDate: JsonField? = null - private var customer: JsonField? = null - private var defaultInvoiceMemo: JsonField? = null - private var discountIntervals: JsonField>? = null - private var endDate: JsonField? = null - private var fixedFeeQuantitySchedule: JsonField>? = - null - private var invoicingThreshold: JsonField? = null - private var maximumIntervals: JsonField>? = null - private var metadata: JsonField? = null - private var minimumIntervals: JsonField>? = null - private var netTerms: JsonField? = null - private var plan: JsonField? = null - private var priceIntervals: JsonField>? = null - private var redeemedCoupon: JsonField? = null - private var startDate: JsonField? = null - private var status: JsonField? = null - private var trialInfo: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - subscriptionUnschedulePendingPlanChangesResponse: - SubscriptionUnschedulePendingPlanChangesResponse - ) = apply { - id = subscriptionUnschedulePendingPlanChangesResponse.id - activePlanPhaseOrder = - subscriptionUnschedulePendingPlanChangesResponse.activePlanPhaseOrder - adjustmentIntervals = - subscriptionUnschedulePendingPlanChangesResponse.adjustmentIntervals.map { - it.toMutableList() - } - autoCollection = subscriptionUnschedulePendingPlanChangesResponse.autoCollection - billingCycleAnchorConfiguration = - subscriptionUnschedulePendingPlanChangesResponse.billingCycleAnchorConfiguration - billingCycleDay = subscriptionUnschedulePendingPlanChangesResponse.billingCycleDay - createdAt = subscriptionUnschedulePendingPlanChangesResponse.createdAt - currentBillingPeriodEndDate = - subscriptionUnschedulePendingPlanChangesResponse.currentBillingPeriodEndDate - currentBillingPeriodStartDate = - subscriptionUnschedulePendingPlanChangesResponse.currentBillingPeriodStartDate - customer = subscriptionUnschedulePendingPlanChangesResponse.customer - defaultInvoiceMemo = subscriptionUnschedulePendingPlanChangesResponse.defaultInvoiceMemo - discountIntervals = - subscriptionUnschedulePendingPlanChangesResponse.discountIntervals.map { - it.toMutableList() - } - endDate = subscriptionUnschedulePendingPlanChangesResponse.endDate - fixedFeeQuantitySchedule = - subscriptionUnschedulePendingPlanChangesResponse.fixedFeeQuantitySchedule.map { - it.toMutableList() - } - invoicingThreshold = subscriptionUnschedulePendingPlanChangesResponse.invoicingThreshold - maximumIntervals = - subscriptionUnschedulePendingPlanChangesResponse.maximumIntervals.map { - it.toMutableList() - } - metadata = subscriptionUnschedulePendingPlanChangesResponse.metadata - minimumIntervals = - subscriptionUnschedulePendingPlanChangesResponse.minimumIntervals.map { - it.toMutableList() - } - netTerms = subscriptionUnschedulePendingPlanChangesResponse.netTerms - plan = subscriptionUnschedulePendingPlanChangesResponse.plan - priceIntervals = - subscriptionUnschedulePendingPlanChangesResponse.priceIntervals.map { - it.toMutableList() - } - redeemedCoupon = subscriptionUnschedulePendingPlanChangesResponse.redeemedCoupon - startDate = subscriptionUnschedulePendingPlanChangesResponse.startDate - status = subscriptionUnschedulePendingPlanChangesResponse.status - trialInfo = subscriptionUnschedulePendingPlanChangesResponse.trialInfo - additionalProperties = - subscriptionUnschedulePendingPlanChangesResponse.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(activePlanPhaseOrder: Long?) = - activePlanPhaseOrder(JsonField.ofNullable(activePlanPhaseOrder)) - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(activePlanPhaseOrder: Long) = - activePlanPhaseOrder(activePlanPhaseOrder as Long?) - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun activePlanPhaseOrder(activePlanPhaseOrder: Optional) = - activePlanPhaseOrder(activePlanPhaseOrder.orElse(null) as Long?) - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(activePlanPhaseOrder: JsonField) = apply { - this.activePlanPhaseOrder = activePlanPhaseOrder - } - - /** The adjustment intervals for this subscription. */ - fun adjustmentIntervals(adjustmentIntervals: List) = - adjustmentIntervals(JsonField.of(adjustmentIntervals)) - - /** The adjustment intervals for this subscription. */ - fun adjustmentIntervals(adjustmentIntervals: JsonField>) = apply { - this.adjustmentIntervals = adjustmentIntervals.map { it.toMutableList() } - } - - /** The adjustment intervals for this subscription. */ - fun addAdjustmentInterval(adjustmentInterval: AdjustmentInterval) = apply { - adjustmentIntervals = - (adjustmentIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(adjustmentInterval) - } - } - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - fun autoCollection(autoCollection: Boolean?) = - autoCollection(JsonField.ofNullable(autoCollection)) - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun autoCollection(autoCollection: Optional) = - autoCollection(autoCollection.orElse(null) as Boolean?) - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - fun autoCollection(autoCollection: JsonField) = apply { - this.autoCollection = autoCollection - } - - fun billingCycleAnchorConfiguration( - billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration - ) = billingCycleAnchorConfiguration(JsonField.of(billingCycleAnchorConfiguration)) - - fun billingCycleAnchorConfiguration( - billingCycleAnchorConfiguration: JsonField - ) = apply { this.billingCycleAnchorConfiguration = billingCycleAnchorConfiguration } - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun billingCycleDay(billingCycleDay: Long) = billingCycleDay(JsonField.of(billingCycleDay)) - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun billingCycleDay(billingCycleDay: JsonField) = apply { - this.billingCycleDay = billingCycleDay - } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is not part of the billing period. Set to null for subscriptions that - * are not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = - currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is not part of the billing period. Set to null for subscriptions that - * are not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = - currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is not part of the billing period. Set to null for subscriptions that - * are not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: JsonField) = - apply { - this.currentBillingPeriodEndDate = currentBillingPeriodEndDate - } - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription - * is not currently active. - */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = - currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription - * is not currently active. - */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: Optional) = - currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription - * is not currently active. - */ - fun currentBillingPeriodStartDate( - currentBillingPeriodStartDate: JsonField - ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } - - /** - * 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 customer(customer: Customer) = customer(JsonField.of(customer)) - - /** - * 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 customer(customer: JsonField) = apply { this.customer = customer } - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(defaultInvoiceMemo: String?) = - defaultInvoiceMemo(JsonField.ofNullable(defaultInvoiceMemo)) - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(defaultInvoiceMemo: Optional) = - defaultInvoiceMemo(defaultInvoiceMemo.orElse(null)) - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(defaultInvoiceMemo: JsonField) = apply { - this.defaultInvoiceMemo = defaultInvoiceMemo - } - - /** The discount intervals for this subscription. */ - fun discountIntervals(discountIntervals: List) = - discountIntervals(JsonField.of(discountIntervals)) - - /** The discount intervals for this subscription. */ - fun discountIntervals(discountIntervals: JsonField>) = apply { - this.discountIntervals = discountIntervals.map { it.toMutableList() } - } - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(discountInterval: DiscountInterval) = apply { - discountIntervals = - (discountIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(discountInterval) - } - } - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(amount: DiscountInterval.AmountDiscountInterval) = - addDiscountInterval(DiscountInterval.ofAmount(amount)) - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(percentage: DiscountInterval.PercentageDiscountInterval) = - addDiscountInterval(DiscountInterval.ofPercentage(percentage)) - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(usage: DiscountInterval.UsageDiscountInterval) = - addDiscountInterval(DiscountInterval.ofUsage(usage)) - - /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - fun fixedFeeQuantitySchedule(fixedFeeQuantitySchedule: List) = - fixedFeeQuantitySchedule(JsonField.of(fixedFeeQuantitySchedule)) - - fun fixedFeeQuantitySchedule( - fixedFeeQuantitySchedule: JsonField> - ) = apply { - this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule.map { it.toMutableList() } - } - - fun addFixedFeeQuantitySchedule(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = - apply { - this.fixedFeeQuantitySchedule = - (this.fixedFeeQuantitySchedule ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(fixedFeeQuantitySchedule) - } - } - - fun invoicingThreshold(invoicingThreshold: String?) = - invoicingThreshold(JsonField.ofNullable(invoicingThreshold)) - - fun invoicingThreshold(invoicingThreshold: Optional) = - invoicingThreshold(invoicingThreshold.orElse(null)) - - fun invoicingThreshold(invoicingThreshold: JsonField) = apply { - this.invoicingThreshold = invoicingThreshold - } - - /** The maximum intervals for this subscription. */ - fun maximumIntervals(maximumIntervals: List) = - maximumIntervals(JsonField.of(maximumIntervals)) - - /** The maximum intervals for this subscription. */ - fun maximumIntervals(maximumIntervals: JsonField>) = apply { - this.maximumIntervals = maximumIntervals.map { it.toMutableList() } - } - - /** The maximum intervals for this subscription. */ - fun addMaximumInterval(maximumInterval: MaximumInterval) = apply { - maximumIntervals = - (maximumIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(maximumInterval) - } - } - - /** - * 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - /** The minimum intervals for this subscription. */ - fun minimumIntervals(minimumIntervals: List) = - minimumIntervals(JsonField.of(minimumIntervals)) - - /** The minimum intervals for this subscription. */ - fun minimumIntervals(minimumIntervals: JsonField>) = apply { - this.minimumIntervals = minimumIntervals.map { it.toMutableList() } - } - - /** The minimum intervals for this subscription. */ - fun addMinimumInterval(minimumInterval: MinimumInterval) = apply { - minimumIntervals = - (minimumIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(minimumInterval) - } - } - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - fun netTerms(netTerms: Long) = netTerms(JsonField.of(netTerms)) - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } - - /** - * 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 plan(plan: Plan) = plan(JsonField.of(plan)) - - /** - * 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 plan(plan: JsonField) = apply { this.plan = plan } - - /** The price intervals for this subscription. */ - fun priceIntervals(priceIntervals: List) = - priceIntervals(JsonField.of(priceIntervals)) - - /** The price intervals for this subscription. */ - fun priceIntervals(priceIntervals: JsonField>) = apply { - this.priceIntervals = priceIntervals.map { it.toMutableList() } - } - - /** The price intervals for this subscription. */ - fun addPriceInterval(priceInterval: PriceInterval) = apply { - priceIntervals = - (priceIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(priceInterval) - } - } - - fun redeemedCoupon(redeemedCoupon: RedeemedCoupon?) = - redeemedCoupon(JsonField.ofNullable(redeemedCoupon)) - - fun redeemedCoupon(redeemedCoupon: Optional) = - redeemedCoupon(redeemedCoupon.orElse(null)) - - fun redeemedCoupon(redeemedCoupon: JsonField) = apply { - this.redeemedCoupon = redeemedCoupon - } - - /** The date Orb starts billing for this subscription. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The date Orb starts billing for this subscription. */ - fun startDate(startDate: JsonField) = apply { this.startDate = startDate } - - fun status(status: Status) = status(JsonField.of(status)) - - fun status(status: JsonField) = apply { this.status = status } - - fun trialInfo(trialInfo: TrialInfo) = trialInfo(JsonField.of(trialInfo)) - - fun trialInfo(trialInfo: JsonField) = apply { this.trialInfo = trialInfo } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): SubscriptionUnschedulePendingPlanChangesResponse = - SubscriptionUnschedulePendingPlanChangesResponse( - checkRequired("id", id), - checkRequired("activePlanPhaseOrder", activePlanPhaseOrder), - checkRequired("adjustmentIntervals", adjustmentIntervals).map { it.toImmutable() }, - checkRequired("autoCollection", autoCollection), - checkRequired("billingCycleAnchorConfiguration", billingCycleAnchorConfiguration), - checkRequired("billingCycleDay", billingCycleDay), - checkRequired("createdAt", createdAt), - checkRequired("currentBillingPeriodEndDate", currentBillingPeriodEndDate), - checkRequired("currentBillingPeriodStartDate", currentBillingPeriodStartDate), - checkRequired("customer", customer), - checkRequired("defaultInvoiceMemo", defaultInvoiceMemo), - checkRequired("discountIntervals", discountIntervals).map { it.toImmutable() }, - checkRequired("endDate", endDate), - checkRequired("fixedFeeQuantitySchedule", fixedFeeQuantitySchedule).map { - it.toImmutable() - }, - checkRequired("invoicingThreshold", invoicingThreshold), - checkRequired("maximumIntervals", maximumIntervals).map { it.toImmutable() }, - checkRequired("metadata", metadata), - checkRequired("minimumIntervals", minimumIntervals).map { it.toImmutable() }, - checkRequired("netTerms", netTerms), - checkRequired("plan", plan), - checkRequired("priceIntervals", priceIntervals).map { it.toImmutable() }, - checkRequired("redeemedCoupon", redeemedCoupon), - checkRequired("startDate", startDate), - checkRequired("status", status), - checkRequired("trialInfo", trialInfo), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class AdjustmentInterval - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment") - @ExcludeMissing - private val adjustment: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") - - /** The price interval IDs that this adjustment applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - /** The end date of the adjustment interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** The start date of the adjustment interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment - - /** The price interval IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - /** The end date of the adjustment interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** The start date of the adjustment interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AdjustmentInterval = apply { - if (validated) { - return@apply - } - - id() - adjustment().validate() - appliesToPriceIntervalIds() - endDate() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AdjustmentInterval]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustment: JsonField? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(adjustmentInterval: AdjustmentInterval) = apply { - id = adjustmentInterval.id - adjustment = adjustmentInterval.adjustment - appliesToPriceIntervalIds = - adjustmentInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - endDate = adjustmentInterval.endDate - startDate = adjustmentInterval.startDate - additionalProperties = adjustmentInterval.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) - - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } - - fun adjustment(planPhaseUsageDiscount: Adjustment.PlanPhaseUsageDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)) - - fun adjustment(planPhaseAmountDiscount: Adjustment.PlanPhaseAmountDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)) - - fun adjustment( - planPhasePercentageDiscount: Adjustment.PlanPhasePercentageDiscountAdjustment - ) = adjustment(Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)) - - fun adjustment(planPhaseMinimum: Adjustment.PlanPhaseMinimumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)) - - fun adjustment(planPhaseMaximum: Adjustment.PlanPhaseMaximumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)) - - /** The price interval IDs that this adjustment applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval IDs that this adjustment applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval IDs that this adjustment applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - /** The end date of the adjustment interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the adjustment interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the adjustment interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** The start date of the adjustment interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the adjustment interval. */ - 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) - } - - fun build(): AdjustmentInterval = - AdjustmentInterval( - checkRequired("id", id), - checkRequired("adjustment", adjustment), - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment? = null, - private val planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment? = null, - private val planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment? = null, - private val planPhaseMinimum: PlanPhaseMinimumAdjustment? = null, - private val planPhaseMaximum: PlanPhaseMaximumAdjustment? = null, - private val _json: JsonValue? = null, - ) { - - fun planPhaseUsageDiscount(): Optional = - Optional.ofNullable(planPhaseUsageDiscount) - - fun planPhaseAmountDiscount(): Optional = - Optional.ofNullable(planPhaseAmountDiscount) - - fun planPhasePercentageDiscount(): Optional = - Optional.ofNullable(planPhasePercentageDiscount) - - fun planPhaseMinimum(): Optional = - Optional.ofNullable(planPhaseMinimum) - - fun planPhaseMaximum(): Optional = - Optional.ofNullable(planPhaseMaximum) - - fun isPlanPhaseUsageDiscount(): Boolean = planPhaseUsageDiscount != null - - fun isPlanPhaseAmountDiscount(): Boolean = planPhaseAmountDiscount != null - - fun isPlanPhasePercentageDiscount(): Boolean = planPhasePercentageDiscount != null - - fun isPlanPhaseMinimum(): Boolean = planPhaseMinimum != null - - fun isPlanPhaseMaximum(): Boolean = planPhaseMaximum != null - - fun asPlanPhaseUsageDiscount(): PlanPhaseUsageDiscountAdjustment = - planPhaseUsageDiscount.getOrThrow("planPhaseUsageDiscount") - - fun asPlanPhaseAmountDiscount(): PlanPhaseAmountDiscountAdjustment = - planPhaseAmountDiscount.getOrThrow("planPhaseAmountDiscount") - - fun asPlanPhasePercentageDiscount(): PlanPhasePercentageDiscountAdjustment = - planPhasePercentageDiscount.getOrThrow("planPhasePercentageDiscount") - - fun asPlanPhaseMinimum(): PlanPhaseMinimumAdjustment = - planPhaseMinimum.getOrThrow("planPhaseMinimum") - - fun asPlanPhaseMaximum(): PlanPhaseMaximumAdjustment = - planPhaseMaximum.getOrThrow("planPhaseMaximum") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - planPhaseUsageDiscount != null -> - visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) - planPhaseAmountDiscount != null -> - visitor.visitPlanPhaseAmountDiscount(planPhaseAmountDiscount) - planPhasePercentageDiscount != null -> - visitor.visitPlanPhasePercentageDiscount(planPhasePercentageDiscount) - planPhaseMinimum != null -> visitor.visitPlanPhaseMinimum(planPhaseMinimum) - planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) { - planPhaseUsageDiscount.validate() - } - - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) { - planPhaseAmountDiscount.validate() - } - - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) { - planPhasePercentageDiscount.validate() - } - - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) { - planPhaseMinimum.validate() - } - - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) { - planPhaseMaximum.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Adjustment && planPhaseUsageDiscount == other.planPhaseUsageDiscount && planPhaseAmountDiscount == other.planPhaseAmountDiscount && planPhasePercentageDiscount == other.planPhasePercentageDiscount && planPhaseMinimum == other.planPhaseMinimum && planPhaseMaximum == other.planPhaseMaximum /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(planPhaseUsageDiscount, planPhaseAmountDiscount, planPhasePercentageDiscount, planPhaseMinimum, planPhaseMaximum) /* spotless:on */ - - override fun toString(): String = - when { - planPhaseUsageDiscount != null -> - "Adjustment{planPhaseUsageDiscount=$planPhaseUsageDiscount}" - planPhaseAmountDiscount != null -> - "Adjustment{planPhaseAmountDiscount=$planPhaseAmountDiscount}" - planPhasePercentageDiscount != null -> - "Adjustment{planPhasePercentageDiscount=$planPhasePercentageDiscount}" - planPhaseMinimum != null -> "Adjustment{planPhaseMinimum=$planPhaseMinimum}" - planPhaseMaximum != null -> "Adjustment{planPhaseMaximum=$planPhaseMaximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } - - companion object { - - @JvmStatic - fun ofPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = Adjustment(planPhaseUsageDiscount = planPhaseUsageDiscount) - - @JvmStatic - fun ofPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = Adjustment(planPhaseAmountDiscount = planPhaseAmountDiscount) - - @JvmStatic - fun ofPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = Adjustment(planPhasePercentageDiscount = planPhasePercentageDiscount) - - @JvmStatic - fun ofPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment) = - Adjustment(planPhaseMinimum = planPhaseMinimum) - - @JvmStatic - fun ofPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment) = - Adjustment(planPhaseMaximum = planPhaseMaximum) - } - - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { - - fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ): T - - fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ): T - - fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ): T - - fun visitPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment): T - - fun visitPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment): T - - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } - - internal class Deserializer : BaseDeserializer(Adjustment::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = - json.asObject().getOrNull()?.get("adjustment_type")?.asString()?.getOrNull() - - when (adjustmentType) { - "usage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseUsageDiscount = it, _json = json) - } - } - "amount_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseAmountDiscount = it, _json = json) - } - } - "percentage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment( - planPhasePercentageDiscount = it, - _json = json, - ) - } - } - "minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMinimum = it, _json = json) - } - } - "maximum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMaximum = it, _json = json) - } - } - } - - return Adjustment(_json = json) - } - } - - internal class Serializer : BaseSerializer(Adjustment::class) { - - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.planPhaseUsageDiscount != null -> - generator.writeObject(value.planPhaseUsageDiscount) - value.planPhaseAmountDiscount != null -> - generator.writeObject(value.planPhaseAmountDiscount) - value.planPhasePercentageDiscount != null -> - generator.writeObject(value.planPhasePercentageDiscount) - value.planPhaseMinimum != null -> - generator.writeObject(value.planPhaseMinimum) - value.planPhaseMaximum != null -> - generator.writeObject(value.planPhaseMaximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") - } - } - } - - @NoAutoDetect - class PlanPhaseUsageDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonProperty("usage_discount") - @ExcludeMissing - private val usageDiscount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - /** - * The number of usage units by which to discount the price this adjustment applies - * to in a given billing period. - */ - fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - /** - * The number of usage units by which to discount the price this adjustment applies - * to in a given billing period. - */ - @JsonProperty("usage_discount") - @ExcludeMissing - fun _usageDiscount(): JsonField = usageDiscount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseUsageDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - planPhaseOrder() - reason() - usageDiscount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseUsageDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var usageDiscount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - planPhaseUsageDiscountAdjustment: PlanPhaseUsageDiscountAdjustment - ) = apply { - id = planPhaseUsageDiscountAdjustment.id - adjustmentType = planPhaseUsageDiscountAdjustment.adjustmentType - appliesToPriceIds = - planPhaseUsageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseUsageDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseUsageDiscountAdjustment.planPhaseOrder - reason = planPhaseUsageDiscountAdjustment.reason - usageDiscount = planPhaseUsageDiscountAdjustment.usageDiscount - additionalProperties = - planPhaseUsageDiscountAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - /** - * The number of usage units by which to discount the price this adjustment - * applies to in a given billing period. - */ - fun usageDiscount(usageDiscount: Double) = - usageDiscount(JsonField.of(usageDiscount)) - - /** - * The number of usage units by which to discount the price this adjustment - * applies to in a given billing period. - */ - fun usageDiscount(usageDiscount: JsonField) = apply { - this.usageDiscount = usageDiscount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseUsageDiscountAdjustment = - PlanPhaseUsageDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - checkRequired("usageDiscount", usageDiscount), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - USAGE_DISCOUNT -> Known.USAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseUsageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, planPhaseOrder, reason, usageDiscount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseUsageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhaseAmountDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("amount_discount") - @ExcludeMissing - private val amountDiscount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** - * The amount by which to discount the prices this adjustment applies to in a given - * billing period. - */ - fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** - * The amount by which to discount the prices this adjustment applies to in a given - * billing period. - */ - @JsonProperty("amount_discount") - @ExcludeMissing - fun _amountDiscount(): JsonField = amountDiscount - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseAmountDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - amountDiscount() - appliesToPriceIds() - isInvoiceLevel() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseAmountDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var amountDiscount: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - planPhaseAmountDiscountAdjustment: PlanPhaseAmountDiscountAdjustment - ) = apply { - id = planPhaseAmountDiscountAdjustment.id - adjustmentType = planPhaseAmountDiscountAdjustment.adjustmentType - amountDiscount = planPhaseAmountDiscountAdjustment.amountDiscount - appliesToPriceIds = - planPhaseAmountDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseAmountDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseAmountDiscountAdjustment.planPhaseOrder - reason = planPhaseAmountDiscountAdjustment.reason - additionalProperties = - planPhaseAmountDiscountAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** - * The amount by which to discount the prices this adjustment applies to in a - * given billing period. - */ - fun amountDiscount(amountDiscount: String) = - amountDiscount(JsonField.of(amountDiscount)) - - /** - * The amount by which to discount the prices this adjustment applies to in a - * given billing period. - */ - fun amountDiscount(amountDiscount: JsonField) = apply { - this.amountDiscount = amountDiscount - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseAmountDiscountAdjustment = - PlanPhaseAmountDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("amountDiscount", amountDiscount), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseAmountDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, amountDiscount, appliesToPriceIds, isInvoiceLevel, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseAmountDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhasePercentageDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("percentage_discount") - @ExcludeMissing - private val percentageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(): Double = - percentageDiscount.getRequired("percentage_discount") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - @JsonProperty("percentage_discount") - @ExcludeMissing - fun _percentageDiscount(): JsonField = percentageDiscount - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhasePercentageDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - percentageDiscount() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhasePercentageDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var percentageDiscount: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - planPhasePercentageDiscountAdjustment: PlanPhasePercentageDiscountAdjustment - ) = apply { - id = planPhasePercentageDiscountAdjustment.id - adjustmentType = planPhasePercentageDiscountAdjustment.adjustmentType - appliesToPriceIds = - planPhasePercentageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhasePercentageDiscountAdjustment.isInvoiceLevel - percentageDiscount = - planPhasePercentageDiscountAdjustment.percentageDiscount - planPhaseOrder = planPhasePercentageDiscountAdjustment.planPhaseOrder - reason = planPhasePercentageDiscountAdjustment.reason - additionalProperties = - planPhasePercentageDiscountAdjustment.additionalProperties - .toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(percentageDiscount: Double) = - percentageDiscount(JsonField.of(percentageDiscount)) - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(percentageDiscount: JsonField) = apply { - this.percentageDiscount = percentageDiscount - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhasePercentageDiscountAdjustment = - PlanPhasePercentageDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("percentageDiscount", percentageDiscount), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val PERCENTAGE_DISCOUNT = of("percentage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhasePercentageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, percentageDiscount, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhasePercentageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhaseMinimumAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(): String = itemId.getRequired("item_id") - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The item ID that revenue from this minimum will be attributed to. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseMinimumAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - itemId() - minimumAmount() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseMinimumAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var itemId: JsonField? = null - private var minimumAmount: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(planPhaseMinimumAdjustment: PlanPhaseMinimumAdjustment) = - apply { - id = planPhaseMinimumAdjustment.id - adjustmentType = planPhaseMinimumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMinimumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMinimumAdjustment.isInvoiceLevel - itemId = planPhaseMinimumAdjustment.itemId - minimumAmount = planPhaseMinimumAdjustment.minimumAmount - planPhaseOrder = planPhaseMinimumAdjustment.planPhaseOrder - reason = planPhaseMinimumAdjustment.reason - additionalProperties = - planPhaseMinimumAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseMinimumAdjustment = - PlanPhaseMinimumAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("itemId", itemId), - checkRequired("minimumAmount", minimumAmount), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseMinimumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, itemId, minimumAmount, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseMinimumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhaseMaximumAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseMaximumAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - maximumAmount() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseMaximumAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var maximumAmount: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(planPhaseMaximumAdjustment: PlanPhaseMaximumAdjustment) = - apply { - id = planPhaseMaximumAdjustment.id - adjustmentType = planPhaseMaximumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMaximumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMaximumAdjustment.isInvoiceLevel - maximumAmount = planPhaseMaximumAdjustment.maximumAmount - planPhaseOrder = planPhaseMaximumAdjustment.planPhaseOrder - reason = planPhaseMaximumAdjustment.reason - additionalProperties = - planPhaseMaximumAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseMaximumAdjustment = - PlanPhaseMaximumAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("maximumAmount", maximumAmount), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseMaximumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, maximumAmount, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseMaximumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentInterval && id == other.id && adjustment == other.adjustment && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustment, appliesToPriceIntervalIds, endDate, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AdjustmentInterval{id=$id, adjustment=$adjustment, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BillingCycleAnchorConfiguration - @JsonCreator - private constructor( - @JsonProperty("day") @ExcludeMissing private val day: JsonField = JsonMissing.of(), - @JsonProperty("month") - @ExcludeMissing - private val month: JsonField = JsonMissing.of(), - @JsonProperty("year") @ExcludeMissing private val year: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun day(): Long = day.getRequired("day") - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(): Optional = Optional.ofNullable(month.getNullable("month")) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on - * 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(): Optional = Optional.ofNullable(year.getNullable("year")) - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - @JsonProperty("day") @ExcludeMissing fun _day(): JsonField = day - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - @JsonProperty("month") @ExcludeMissing fun _month(): JsonField = month - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on - * 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - @JsonProperty("year") @ExcludeMissing fun _year(): JsonField = year - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleAnchorConfiguration = apply { - if (validated) { - return@apply - } - - day() - month() - year() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleAnchorConfiguration]. */ - class Builder internal constructor() { - - private var day: JsonField? = null - private var month: JsonField = JsonMissing.of() - private var year: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration) = - apply { - day = billingCycleAnchorConfiguration.day - month = billingCycleAnchorConfiguration.month - year = billingCycleAnchorConfiguration.year - additionalProperties = - billingCycleAnchorConfiguration.additionalProperties.toMutableMap() - } - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun day(day: Long) = day(JsonField.of(day)) - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun day(day: JsonField) = apply { this.day = day } - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(month: Long?) = month(JsonField.ofNullable(month)) - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(month: Long) = month(month as Long?) - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun month(month: Optional) = month(month.orElse(null) as Long?) - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(month: JsonField) = apply { this.month = month } - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(year: Long?) = year(JsonField.ofNullable(year)) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(year: Long) = year(year as Long?) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun year(year: Optional) = year(year.orElse(null) as Long?) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(year: JsonField) = apply { this.year = year } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleAnchorConfiguration = - BillingCycleAnchorConfiguration( - checkRequired("day", day), - month, - year, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleAnchorConfiguration && day == other.day && month == other.month && year == other.year && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(day, month, year, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleAnchorConfiguration{day=$day, month=$month, year=$year, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(using = DiscountInterval.Deserializer::class) - @JsonSerialize(using = DiscountInterval.Serializer::class) - class DiscountInterval - private constructor( - private val amount: AmountDiscountInterval? = null, - private val percentage: PercentageDiscountInterval? = null, - private val usage: UsageDiscountInterval? = null, - private val _json: JsonValue? = null, - ) { - - fun amount(): Optional = Optional.ofNullable(amount) - - fun percentage(): Optional = Optional.ofNullable(percentage) - - fun usage(): Optional = Optional.ofNullable(usage) - - fun isAmount(): Boolean = amount != null - - fun isPercentage(): Boolean = percentage != null - - fun isUsage(): Boolean = usage != null - - fun asAmount(): AmountDiscountInterval = amount.getOrThrow("amount") - - fun asPercentage(): PercentageDiscountInterval = percentage.getOrThrow("percentage") - - fun asUsage(): UsageDiscountInterval = usage.getOrThrow("usage") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - amount != null -> visitor.visitAmount(amount) - percentage != null -> visitor.visitPercentage(percentage) - usage != null -> visitor.visitUsage(usage) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): DiscountInterval = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitAmount(amount: AmountDiscountInterval) { - amount.validate() - } - - override fun visitPercentage(percentage: PercentageDiscountInterval) { - percentage.validate() - } - - override fun visitUsage(usage: UsageDiscountInterval) { - usage.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountInterval && amount == other.amount && percentage == other.percentage && usage == other.usage /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(amount, percentage, usage) /* spotless:on */ - - override fun toString(): String = - when { - amount != null -> "DiscountInterval{amount=$amount}" - percentage != null -> "DiscountInterval{percentage=$percentage}" - usage != null -> "DiscountInterval{usage=$usage}" - _json != null -> "DiscountInterval{_unknown=$_json}" - else -> throw IllegalStateException("Invalid DiscountInterval") - } - - companion object { - - @JvmStatic - fun ofAmount(amount: AmountDiscountInterval) = DiscountInterval(amount = amount) - - @JvmStatic - fun ofPercentage(percentage: PercentageDiscountInterval) = - DiscountInterval(percentage = percentage) - - @JvmStatic fun ofUsage(usage: UsageDiscountInterval) = DiscountInterval(usage = usage) - } - - /** - * An interface that defines how to map each variant of [DiscountInterval] to a value of - * type [T]. - */ - interface Visitor { - - fun visitAmount(amount: AmountDiscountInterval): T - - fun visitPercentage(percentage: PercentageDiscountInterval): T - - fun visitUsage(usage: UsageDiscountInterval): T - - /** - * Maps an unknown variant of [DiscountInterval] to a value of type [T]. - * - * An instance of [DiscountInterval] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown DiscountInterval: $json") - } - } - - internal class Deserializer : BaseDeserializer(DiscountInterval::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): DiscountInterval { - val json = JsonValue.fromJsonNode(node) - val discountType = - json.asObject().getOrNull()?.get("discount_type")?.asString()?.getOrNull() - - when (discountType) { - "amount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(amount = it, _json = json) - } - } - "percentage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(percentage = it, _json = json) - } - } - "usage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(usage = it, _json = json) - } - } - } - - return DiscountInterval(_json = json) - } - } - - internal class Serializer : BaseSerializer(DiscountInterval::class) { - - override fun serialize( - value: DiscountInterval, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.amount != null -> generator.writeObject(value.amount) - value.percentage != null -> generator.writeObject(value.percentage) - value.usage != null -> generator.writeObject(value.usage) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid DiscountInterval") - } - } - } - - @NoAutoDetect - class AmountDiscountInterval - @JsonCreator - private constructor( - @JsonProperty("amount_discount") - @ExcludeMissing - private val amountDiscount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("discount_type") - @ExcludeMissing - private val discountType: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - fun discountType(): DiscountType = discountType.getRequired("discount_type") - - /** The end date of the discount interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** The start date of the discount interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** Only available if discount_type is `amount`. */ - @JsonProperty("amount_discount") - @ExcludeMissing - fun _amountDiscount(): JsonField = amountDiscount - - /** The price ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - - /** The end date of the discount interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** The start date of the discount interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AmountDiscountInterval = apply { - if (validated) { - return@apply - } - - amountDiscount() - appliesToPriceIds() - appliesToPriceIntervalIds() - discountType() - endDate() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AmountDiscountInterval]. */ - class Builder internal constructor() { - - private var amountDiscount: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { - amountDiscount = amountDiscountInterval.amountDiscount - appliesToPriceIds = - amountDiscountInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - amountDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = amountDiscountInterval.discountType - endDate = amountDiscountInterval.endDate - startDate = amountDiscountInterval.startDate - additionalProperties = - amountDiscountInterval.additionalProperties.toMutableMap() - } - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(amountDiscount: String) = - amountDiscount(JsonField.of(amountDiscount)) - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(amountDiscount: JsonField) = apply { - this.amountDiscount = amountDiscount - } - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this discount interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this discount interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the discount interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the discount interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** The start date of the discount interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the discount interval. */ - 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) - } - - fun build(): AmountDiscountInterval = - AmountDiscountInterval( - checkRequired("amountDiscount", amountDiscount), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("discountType", discountType), - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val AMOUNT = of("amount") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - AMOUNT - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT -> Value.AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AMOUNT -> Known.AMOUNT - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AmountDiscountInterval && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amountDiscount, appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AmountDiscountInterval{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PercentageDiscountInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("discount_type") - @ExcludeMissing - private val discountType: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("percentage_discount") - @ExcludeMissing - private val percentageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - fun discountType(): DiscountType = discountType.getRequired("discount_type") - - /** The end date of the discount interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ - fun percentageDiscount(): Double = percentageDiscount.getRequired("percentage_discount") - - /** The start date of the discount interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** The price ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - - /** The end date of the discount interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ - @JsonProperty("percentage_discount") - @ExcludeMissing - fun _percentageDiscount(): JsonField = percentageDiscount - - /** The start date of the discount interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PercentageDiscountInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - discountType() - endDate() - percentageDiscount() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PercentageDiscountInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null - private var endDate: JsonField? = null - private var percentageDiscount: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { - appliesToPriceIds = - percentageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - percentageDiscountInterval.appliesToPriceIntervalIds.map { - it.toMutableList() - } - discountType = percentageDiscountInterval.discountType - endDate = percentageDiscountInterval.endDate - percentageDiscount = percentageDiscountInterval.percentageDiscount - startDate = percentageDiscountInterval.startDate - additionalProperties = - percentageDiscountInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this discount interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this discount interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the discount interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the discount interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** - * Only available if discount_type is `percentage`.This is a number between 0 and 1. - */ - fun percentageDiscount(percentageDiscount: Double) = - percentageDiscount(JsonField.of(percentageDiscount)) - - /** - * Only available if discount_type is `percentage`.This is a number between 0 and 1. - */ - fun percentageDiscount(percentageDiscount: JsonField) = apply { - this.percentageDiscount = percentageDiscount - } - - /** The start date of the discount interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the discount interval. */ - 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) - } - - fun build(): PercentageDiscountInterval = - PercentageDiscountInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("discountType", discountType), - checkRequired("endDate", endDate), - checkRequired("percentageDiscount", percentageDiscount), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val PERCENTAGE = of("percentage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - PERCENTAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE -> Value.PERCENTAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PERCENTAGE -> Known.PERCENTAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PercentageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, percentageDiscount, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PercentageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class UsageDiscountInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("discount_type") - @ExcludeMissing - private val discountType: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonProperty("usage_discount") - @ExcludeMissing - private val usageDiscount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - fun discountType(): DiscountType = discountType.getRequired("discount_type") - - /** The end date of the discount interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** The start date of the discount interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** - * Only available if discount_type is `usage`. Number of usage units that this discount - * is for - */ - fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - - /** The price ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - - /** The end date of the discount interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** The start date of the discount interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - /** - * Only available if discount_type is `usage`. Number of usage units that this discount - * is for - */ - @JsonProperty("usage_discount") - @ExcludeMissing - fun _usageDiscount(): JsonField = usageDiscount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): UsageDiscountInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - discountType() - endDate() - startDate() - usageDiscount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UsageDiscountInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var usageDiscount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { - appliesToPriceIds = - usageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - usageDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = usageDiscountInterval.discountType - endDate = usageDiscountInterval.endDate - startDate = usageDiscountInterval.startDate - usageDiscount = usageDiscountInterval.usageDiscount - additionalProperties = usageDiscountInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this discount interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this discount interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the discount interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the discount interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** The start date of the discount interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the discount interval. */ - fun startDate(startDate: JsonField) = apply { - this.startDate = startDate - } - - /** - * Only available if discount_type is `usage`. Number of usage units that this - * discount is for - */ - fun usageDiscount(usageDiscount: Double) = - usageDiscount(JsonField.of(usageDiscount)) - - /** - * Only available if discount_type is `usage`. Number of usage units that this - * discount is for - */ - fun usageDiscount(usageDiscount: JsonField) = apply { - this.usageDiscount = usageDiscount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): UsageDiscountInterval = - UsageDiscountInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("discountType", discountType), - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - checkRequired("usageDiscount", usageDiscount), - additionalProperties.toImmutable(), - ) - } - - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE = of("usage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - USAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE -> Value.USAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE -> Known.USAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UsageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, startDate, usageDiscount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UsageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" - } - } - - @NoAutoDetect - class FixedFeeQuantitySchedule - @JsonCreator - private constructor( - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("price_id") - @ExcludeMissing - private val priceId: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - private val quantity: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - fun priceId(): String = priceId.getRequired("price_id") - - fun quantity(): Double = quantity.getRequired("quantity") - - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - - @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): FixedFeeQuantitySchedule = apply { - if (validated) { - return@apply - } - - endDate() - priceId() - quantity() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FixedFeeQuantitySchedule]. */ - class Builder internal constructor() { - - private var endDate: JsonField? = null - private var priceId: JsonField? = null - private var quantity: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = apply { - endDate = fixedFeeQuantitySchedule.endDate - priceId = fixedFeeQuantitySchedule.priceId - quantity = fixedFeeQuantitySchedule.quantity - startDate = fixedFeeQuantitySchedule.startDate - additionalProperties = fixedFeeQuantitySchedule.additionalProperties.toMutableMap() - } - - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) - - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - 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) - } - - fun build(): FixedFeeQuantitySchedule = - FixedFeeQuantitySchedule( - checkRequired("endDate", endDate), - checkRequired("priceId", priceId), - checkRequired("quantity", quantity), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FixedFeeQuantitySchedule && endDate == other.endDate && priceId == other.priceId && quantity == other.quantity && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(endDate, priceId, quantity, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "FixedFeeQuantitySchedule{endDate=$endDate, priceId=$priceId, quantity=$quantity, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class MaximumInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this maximum interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this maximum interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - /** The end date of the maximum interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** The start date of the maximum interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** The price ids that this maximum interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this maximum interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - /** The end date of the maximum interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** The start date of the maximum interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MaximumInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - endDate() - maximumAmount() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MaximumInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var endDate: JsonField? = null - private var maximumAmount: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximumInterval: MaximumInterval) = apply { - appliesToPriceIds = maximumInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - maximumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - endDate = maximumInterval.endDate - maximumAmount = maximumInterval.maximumAmount - startDate = maximumInterval.startDate - additionalProperties = maximumInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this maximum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this maximum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this maximum interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this maximum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this maximum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this maximum interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - /** The end date of the maximum interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the maximum interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the maximum interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** The start date of the maximum interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the maximum interval. */ - 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) - } - - fun build(): MaximumInterval = - MaximumInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("endDate", endDate), - checkRequired("maximumAmount", maximumAmount), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MaximumInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && maximumAmount == other.maximumAmount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, endDate, maximumAmount, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MaximumInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, maximumAmount=$maximumAmount, startDate=$startDate, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class MinimumInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this minimum interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this minimum interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - /** The end date of the minimum interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** The start date of the minimum interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** The price ids that this minimum interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this minimum interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - /** The end date of the minimum interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** The start date of the minimum interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MinimumInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - endDate() - minimumAmount() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MinimumInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var endDate: JsonField? = null - private var minimumAmount: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(minimumInterval: MinimumInterval) = apply { - appliesToPriceIds = minimumInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - minimumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - endDate = minimumInterval.endDate - minimumAmount = minimumInterval.minimumAmount - startDate = minimumInterval.startDate - additionalProperties = minimumInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this minimum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this minimum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this minimum interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this minimum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this minimum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this minimum interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - /** The end date of the minimum interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the minimum interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the minimum interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** The start date of the minimum interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the minimum interval. */ - 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) - } - - fun build(): MinimumInterval = - MinimumInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("endDate", endDate), - checkRequired("minimumAmount", minimumAmount), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MinimumInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && minimumAmount == other.minimumAmount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, endDate, minimumAmount, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MinimumInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, minimumAmount=$minimumAmount, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - /** - * The Price Interval resource represents a period of time for which a price will bill on a - * subscription. A subscription’s price intervals define its billing behavior. - */ - @NoAutoDetect - class PriceInterval - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_day") - @ExcludeMissing - private val billingCycleDay: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - private val currentBillingPeriodEndDate: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - private val currentBillingPeriodStartDate: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("filter") - @ExcludeMissing - private val filter: JsonField = JsonMissing.of(), - @JsonProperty("fixed_fee_quantity_transitions") - @ExcludeMissing - private val fixedFeeQuantityTransitions: JsonField> = - JsonMissing.of(), - @JsonProperty("price") - @ExcludeMissing - private val price: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonProperty("usage_customer_ids") - @ExcludeMissing - private val usageCustomerIds: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - /** The day of the month that Orb bills for this price */ - fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate(): Optional = - Optional.ofNullable( - currentBillingPeriodEndDate.getNullable("current_billing_period_end_date") - ) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodStartDate(): Optional = - Optional.ofNullable( - currentBillingPeriodStartDate.getNullable("current_billing_period_start_date") - ) - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** An additional filter to apply to usage queries. */ - fun filter(): Optional = Optional.ofNullable(filter.getNullable("filter")) - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions(): Optional> = - Optional.ofNullable( - fixedFeeQuantityTransitions.getNullable("fixed_fee_quantity_transitions") - ) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting in - * a charge on an invoice in the form of an invoice line item. Prices take a quantity and - * determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the key - * for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(): Price = price.getRequired("price") - - /** - * The start date of the price interval. This is the date that Orb starts billing for this - * price. - */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this price - * interval. - */ - fun usageCustomerIds(): Optional> = - Optional.ofNullable(usageCustomerIds.getNullable("usage_customer_ids")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** The day of the month that Orb bills for this price */ - @JsonProperty("billing_cycle_day") - @ExcludeMissing - fun _billingCycleDay(): JsonField = billingCycleDay - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if this price - * interval is not currently active. - */ - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - fun _currentBillingPeriodStartDate(): JsonField = - currentBillingPeriodStartDate - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** An additional filter to apply to usage queries. */ - @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField = filter - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - @JsonProperty("fixed_fee_quantity_transitions") - @ExcludeMissing - fun _fixedFeeQuantityTransitions(): JsonField> = - fixedFeeQuantityTransitions - - /** - * 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) - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - - /** - * The start date of the price interval. This is the date that Orb starts billing for this - * price. - */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this price - * interval. - */ - @JsonProperty("usage_customer_ids") - @ExcludeMissing - fun _usageCustomerIds(): JsonField> = usageCustomerIds - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PriceInterval = apply { - if (validated) { - return@apply - } - - id() - billingCycleDay() - currentBillingPeriodEndDate() - currentBillingPeriodStartDate() - endDate() - filter() - fixedFeeQuantityTransitions().ifPresent { it.forEach { it.validate() } } - price().validate() - startDate() - usageCustomerIds() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PriceInterval]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var billingCycleDay: JsonField? = null - private var currentBillingPeriodEndDate: JsonField? = null - private var currentBillingPeriodStartDate: JsonField? = null - private var endDate: JsonField? = null - private var filter: JsonField? = null - private var fixedFeeQuantityTransitions: - JsonField>? = - null - private var price: JsonField? = null - private var startDate: JsonField? = null - private var usageCustomerIds: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(priceInterval: PriceInterval) = apply { - id = priceInterval.id - billingCycleDay = priceInterval.billingCycleDay - currentBillingPeriodEndDate = priceInterval.currentBillingPeriodEndDate - currentBillingPeriodStartDate = priceInterval.currentBillingPeriodStartDate - endDate = priceInterval.endDate - filter = priceInterval.filter - fixedFeeQuantityTransitions = - priceInterval.fixedFeeQuantityTransitions.map { it.toMutableList() } - price = priceInterval.price - startDate = priceInterval.startDate - usageCustomerIds = priceInterval.usageCustomerIds.map { it.toMutableList() } - additionalProperties = priceInterval.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - /** The day of the month that Orb bills for this price */ - fun billingCycleDay(billingCycleDay: Long) = - billingCycleDay(JsonField.of(billingCycleDay)) - - /** The day of the month that Orb bills for this price */ - fun billingCycleDay(billingCycleDay: JsonField) = apply { - this.billingCycleDay = billingCycleDay - } - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = - currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = - currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate( - currentBillingPeriodEndDate: JsonField - ) = apply { this.currentBillingPeriodEndDate = currentBillingPeriodEndDate } - - /** - * The start date of the current billing period. This is an inclusive timestamp; the - * instant returned is exactly the beginning of the billing period. Set to null if this - * price interval is not currently active. - */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = - currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the - * instant returned is exactly the beginning of the billing period. Set to null if this - * price interval is not currently active. - */ - fun currentBillingPeriodStartDate( - currentBillingPeriodStartDate: Optional - ) = currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the - * instant returned is exactly the beginning of the billing period. Set to null if this - * price interval is not currently active. - */ - fun currentBillingPeriodStartDate( - currentBillingPeriodStartDate: JsonField - ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** An additional filter to apply to usage queries. */ - fun filter(filter: String?) = filter(JsonField.ofNullable(filter)) - - /** An additional filter to apply to usage queries. */ - fun filter(filter: Optional) = filter(filter.orElse(null)) - - /** An additional filter to apply to usage queries. */ - fun filter(filter: JsonField) = apply { this.filter = filter } - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: List? - ) = fixedFeeQuantityTransitions(JsonField.ofNullable(fixedFeeQuantityTransitions)) - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: Optional> - ) = fixedFeeQuantityTransitions(fixedFeeQuantityTransitions.orElse(null)) - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: JsonField> - ) = apply { - this.fixedFeeQuantityTransitions = - fixedFeeQuantityTransitions.map { it.toMutableList() } - } - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun addFixedFeeQuantityTransition( - fixedFeeQuantityTransition: FixedFeeQuantityTransition - ) = apply { - fixedFeeQuantityTransitions = - (fixedFeeQuantityTransitions ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(fixedFeeQuantityTransition) - } - } - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(price: Price) = price(JsonField.of(price)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(price: JsonField) = apply { this.price = price } - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(matrix: Price.MatrixPrice) = price(Price.ofMatrix(matrix)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredPackage: Price.TieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedTiered: Price.GroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(unitWithPercent: Price.UnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredWithProration: Price.TieredWithProrationPrice) = - price(Price.ofTieredWithProration(tieredWithProration)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(unitWithProration: Price.UnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedAllocation: Price.GroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bulkWithProration: Price.BulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = - price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice) = - price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - - /** - * The start date of the price interval. This is the date that Orb starts billing for - * this price. - */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** - * The start date of the price interval. This is the date that Orb starts billing for - * this price. - */ - fun startDate(startDate: JsonField) = apply { - this.startDate = startDate - } - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun usageCustomerIds(usageCustomerIds: List?) = - usageCustomerIds(JsonField.ofNullable(usageCustomerIds)) - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun usageCustomerIds(usageCustomerIds: Optional>) = - usageCustomerIds(usageCustomerIds.orElse(null)) - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun usageCustomerIds(usageCustomerIds: JsonField>) = apply { - this.usageCustomerIds = usageCustomerIds.map { it.toMutableList() } - } - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun addUsageCustomerId(usageCustomerId: String) = apply { - usageCustomerIds = - (usageCustomerIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(usageCustomerId) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): PriceInterval = - PriceInterval( - checkRequired("id", id), - checkRequired("billingCycleDay", billingCycleDay), - checkRequired("currentBillingPeriodEndDate", currentBillingPeriodEndDate), - checkRequired("currentBillingPeriodStartDate", currentBillingPeriodStartDate), - checkRequired("endDate", endDate), - checkRequired("filter", filter), - checkRequired("fixedFeeQuantityTransitions", fixedFeeQuantityTransitions).map { - it.toImmutable() - }, - checkRequired("price", price), - checkRequired("startDate", startDate), - checkRequired("usageCustomerIds", usageCustomerIds).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class FixedFeeQuantityTransition - @JsonCreator - private constructor( - @JsonProperty("effective_date") - @ExcludeMissing - private val effectiveDate: JsonField = JsonMissing.of(), - @JsonProperty("price_id") - @ExcludeMissing - private val priceId: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - private val quantity: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun effectiveDate(): OffsetDateTime = effectiveDate.getRequired("effective_date") - - fun priceId(): String = priceId.getRequired("price_id") - - fun quantity(): Long = quantity.getRequired("quantity") - - @JsonProperty("effective_date") - @ExcludeMissing - fun _effectiveDate(): JsonField = effectiveDate - - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - - @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): FixedFeeQuantityTransition = apply { - if (validated) { - return@apply - } - - effectiveDate() - priceId() - quantity() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FixedFeeQuantityTransition]. */ - class Builder internal constructor() { - - private var effectiveDate: JsonField? = null - private var priceId: JsonField? = null - private var quantity: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(fixedFeeQuantityTransition: FixedFeeQuantityTransition) = apply { - effectiveDate = fixedFeeQuantityTransition.effectiveDate - priceId = fixedFeeQuantityTransition.priceId - quantity = fixedFeeQuantityTransition.quantity - additionalProperties = - fixedFeeQuantityTransition.additionalProperties.toMutableMap() - } - - fun effectiveDate(effectiveDate: OffsetDateTime) = - effectiveDate(JsonField.of(effectiveDate)) - - fun effectiveDate(effectiveDate: JsonField) = apply { - this.effectiveDate = effectiveDate - } - - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) - - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - - fun quantity(quantity: Long) = quantity(JsonField.of(quantity)) - - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): FixedFeeQuantityTransition = - FixedFeeQuantityTransition( - checkRequired("effectiveDate", effectiveDate), - checkRequired("priceId", priceId), - checkRequired("quantity", quantity), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FixedFeeQuantityTransition && effectiveDate == other.effectiveDate && priceId == other.priceId && quantity == other.quantity && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(effectiveDate, priceId, quantity, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "FixedFeeQuantityTransition{effectiveDate=$effectiveDate, priceId=$priceId, quantity=$quantity, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PriceInterval && id == other.id && billingCycleDay == other.billingCycleDay && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && endDate == other.endDate && filter == other.filter && fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && price == other.price && startDate == other.startDate && usageCustomerIds == other.usageCustomerIds && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billingCycleDay, currentBillingPeriodEndDate, currentBillingPeriodStartDate, endDate, filter, fixedFeeQuantityTransitions, price, startDate, usageCustomerIds, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PriceInterval{id=$id, billingCycleDay=$billingCycleDay, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, endDate=$endDate, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, price=$price, startDate=$startDate, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class RedeemedCoupon - @JsonCreator - private constructor( - @JsonProperty("coupon_id") - @ExcludeMissing - private val couponId: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun couponId(): String = couponId.getRequired("coupon_id") - - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - @JsonProperty("coupon_id") @ExcludeMissing fun _couponId(): JsonField = couponId - - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): RedeemedCoupon = apply { - if (validated) { - return@apply - } - - couponId() - endDate() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RedeemedCoupon]. */ - class Builder internal constructor() { - - private var couponId: JsonField? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(redeemedCoupon: RedeemedCoupon) = apply { - couponId = redeemedCoupon.couponId - endDate = redeemedCoupon.endDate - startDate = redeemedCoupon.startDate - additionalProperties = redeemedCoupon.additionalProperties.toMutableMap() - } - - fun couponId(couponId: String) = couponId(JsonField.of(couponId)) - - fun couponId(couponId: JsonField) = apply { this.couponId = couponId } - - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - 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) - } - - fun build(): RedeemedCoupon = - RedeemedCoupon( - checkRequired("couponId", couponId), - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RedeemedCoupon && couponId == other.couponId && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(couponId, endDate, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RedeemedCoupon{couponId=$couponId, endDate=$endDate, startDate=$startDate, 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 ENDED = of("ended") - - @JvmField val UPCOMING = of("upcoming") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - ACTIVE, - ENDED, - UPCOMING, - } - - /** - * 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, - ENDED, - UPCOMING, - /** 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 - ENDED -> Value.ENDED - UPCOMING -> Value.UPCOMING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to 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 - ENDED -> Known.ENDED - UPCOMING -> Known.UPCOMING - 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TrialInfo - @JsonCreator - private constructor( - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TrialInfo = apply { - if (validated) { - return@apply - } - - endDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TrialInfo]. */ - class Builder internal constructor() { - - private var endDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(trialInfo: TrialInfo) = apply { - endDate = trialInfo.endDate - additionalProperties = trialInfo.additionalProperties.toMutableMap() - } - - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - 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) - } - - fun build(): TrialInfo = - TrialInfo(checkRequired("endDate", endDate), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TrialInfo && endDate == other.endDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(endDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TrialInfo{endDate=$endDate, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is SubscriptionUnschedulePendingPlanChangesResponse && id == other.id && activePlanPhaseOrder == other.activePlanPhaseOrder && adjustmentIntervals == other.adjustmentIntervals && autoCollection == other.autoCollection && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && billingCycleDay == other.billingCycleDay && createdAt == other.createdAt && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && customer == other.customer && defaultInvoiceMemo == other.defaultInvoiceMemo && discountIntervals == other.discountIntervals && endDate == other.endDate && fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && invoicingThreshold == other.invoicingThreshold && maximumIntervals == other.maximumIntervals && metadata == other.metadata && minimumIntervals == other.minimumIntervals && netTerms == other.netTerms && plan == other.plan && priceIntervals == other.priceIntervals && redeemedCoupon == other.redeemedCoupon && startDate == other.startDate && status == other.status && trialInfo == other.trialInfo && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, activePlanPhaseOrder, adjustmentIntervals, autoCollection, billingCycleAnchorConfiguration, billingCycleDay, createdAt, currentBillingPeriodEndDate, currentBillingPeriodStartDate, customer, defaultInvoiceMemo, discountIntervals, endDate, fixedFeeQuantitySchedule, invoicingThreshold, maximumIntervals, metadata, minimumIntervals, netTerms, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SubscriptionUnschedulePendingPlanChangesResponse{id=$id, activePlanPhaseOrder=$activePlanPhaseOrder, adjustmentIntervals=$adjustmentIntervals, autoCollection=$autoCollection, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, billingCycleDay=$billingCycleDay, createdAt=$createdAt, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, customer=$customer, defaultInvoiceMemo=$defaultInvoiceMemo, discountIntervals=$discountIntervals, endDate=$endDate, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, invoicingThreshold=$invoicingThreshold, maximumIntervals=$maximumIntervals, metadata=$metadata, minimumIntervals=$minimumIntervals, netTerms=$netTerms, plan=$plan, priceIntervals=$priceIntervals, redeemedCoupon=$redeemedCoupon, startDate=$startDate, status=$status, trialInfo=$trialInfo, additionalProperties=$additionalProperties}" -} 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 e685452d1..7b1d08517 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 @@ -227,6 +227,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .priceId() + * .quantity() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -387,6 +396,17 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [SubscriptionUpdateFixedFeeQuantityParams]. + * + * The following fields are required: + * ```java + * .subscriptionId() + * .priceId() + * .quantity() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityResponse.kt deleted file mode 100644 index c94cbe3fc..000000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityResponse.kt +++ /dev/null @@ -1,7179 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer -import com.withorb.api.core.Enum -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow -import com.withorb.api.core.immutableEmptyMap -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -@NoAutoDetect -class SubscriptionUpdateFixedFeeQuantityResponse -@JsonCreator -private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("active_plan_phase_order") - @ExcludeMissing - private val activePlanPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_intervals") - @ExcludeMissing - private val adjustmentIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("auto_collection") - @ExcludeMissing - private val autoCollection: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_anchor_configuration") - @ExcludeMissing - private val billingCycleAnchorConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("billing_cycle_day") - @ExcludeMissing - private val billingCycleDay: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - private val currentBillingPeriodEndDate: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - private val currentBillingPeriodStartDate: JsonField = JsonMissing.of(), - @JsonProperty("customer") - @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), - @JsonProperty("default_invoice_memo") - @ExcludeMissing - private val defaultInvoiceMemo: JsonField = JsonMissing.of(), - @JsonProperty("discount_intervals") - @ExcludeMissing - private val discountIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("fixed_fee_quantity_schedule") - @ExcludeMissing - private val fixedFeeQuantitySchedule: JsonField> = - JsonMissing.of(), - @JsonProperty("invoicing_threshold") - @ExcludeMissing - private val invoicingThreshold: JsonField = JsonMissing.of(), - @JsonProperty("maximum_intervals") - @ExcludeMissing - private val maximumIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("minimum_intervals") - @ExcludeMissing - private val minimumIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("net_terms") - @ExcludeMissing - private val netTerms: JsonField = JsonMissing.of(), - @JsonProperty("plan") @ExcludeMissing private val plan: JsonField = JsonMissing.of(), - @JsonProperty("price_intervals") - @ExcludeMissing - private val priceIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("redeemed_coupon") - @ExcludeMissing - private val redeemedCoupon: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonProperty("status") - @ExcludeMissing - private val status: JsonField = JsonMissing.of(), - @JsonProperty("trial_info") - @ExcludeMissing - private val trialInfo: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun id(): String = id.getRequired("id") - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(): Optional = - Optional.ofNullable(activePlanPhaseOrder.getNullable("active_plan_phase_order")) - - /** The adjustment intervals for this subscription. */ - fun adjustmentIntervals(): List = - adjustmentIntervals.getRequired("adjustment_intervals") - - /** - * Determines whether issued invoices for this subscription will automatically be charged with - * the saved payment method on the due date. This property defaults to the plan's behavior. If - * null, defaults to the customer's setting. - */ - fun autoCollection(): Optional = - Optional.ofNullable(autoCollection.getNullable("auto_collection")) - - fun billingCycleAnchorConfiguration(): BillingCycleAnchorConfiguration = - billingCycleAnchorConfiguration.getRequired("billing_cycle_anchor_configuration") - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of days in - * a month is greater than this value, the last day of the month is the billing cycle day (e.g. - * billing_cycle_day=31 for April means the billing period begins on the 30th. - */ - fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the instant - * returned is not part of the billing period. Set to null for subscriptions that are not - * currently active. - */ - fun currentBillingPeriodEndDate(): Optional = - Optional.ofNullable( - currentBillingPeriodEndDate.getNullable("current_billing_period_end_date") - ) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription is - * not currently active. - */ - fun currentBillingPeriodStartDate(): Optional = - Optional.ofNullable( - currentBillingPeriodStartDate.getNullable("current_billing_period_start_date") - ) - - /** - * 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 customer(): Customer = customer.getRequired("customer") - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(): Optional = - Optional.ofNullable(defaultInvoiceMemo.getNullable("default_invoice_memo")) - - /** The discount intervals for this subscription. */ - fun discountIntervals(): List = - discountIntervals.getRequired("discount_intervals") - - /** The date Orb stops billing for this subscription. */ - fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) - - fun fixedFeeQuantitySchedule(): List = - fixedFeeQuantitySchedule.getRequired("fixed_fee_quantity_schedule") - - fun invoicingThreshold(): Optional = - Optional.ofNullable(invoicingThreshold.getNullable("invoicing_threshold")) - - /** The maximum intervals for this subscription. */ - fun maximumIntervals(): List = - maximumIntervals.getRequired("maximum_intervals") - - /** - * 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.getRequired("metadata") - - /** The minimum intervals for this subscription. */ - fun minimumIntervals(): List = - minimumIntervals.getRequired("minimum_intervals") - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - fun netTerms(): Long = netTerms.getRequired("net_terms") - - /** - * 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 plan(): Plan = plan.getRequired("plan") - - /** The price intervals for this subscription. */ - fun priceIntervals(): List = priceIntervals.getRequired("price_intervals") - - fun redeemedCoupon(): Optional = - Optional.ofNullable(redeemedCoupon.getNullable("redeemed_coupon")) - - /** The date Orb starts billing for this subscription. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - fun status(): Status = status.getRequired("status") - - fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - @JsonProperty("active_plan_phase_order") - @ExcludeMissing - fun _activePlanPhaseOrder(): JsonField = activePlanPhaseOrder - - /** The adjustment intervals for this subscription. */ - @JsonProperty("adjustment_intervals") - @ExcludeMissing - fun _adjustmentIntervals(): JsonField> = adjustmentIntervals - - /** - * Determines whether issued invoices for this subscription will automatically be charged with - * the saved payment method on the due date. This property defaults to the plan's behavior. If - * null, defaults to the customer's setting. - */ - @JsonProperty("auto_collection") - @ExcludeMissing - fun _autoCollection(): JsonField = autoCollection - - @JsonProperty("billing_cycle_anchor_configuration") - @ExcludeMissing - fun _billingCycleAnchorConfiguration(): JsonField = - billingCycleAnchorConfiguration - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of days in - * a month is greater than this value, the last day of the month is the billing cycle day (e.g. - * billing_cycle_day=31 for April means the billing period begins on the 30th. - */ - @JsonProperty("billing_cycle_day") - @ExcludeMissing - fun _billingCycleDay(): JsonField = billingCycleDay - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the instant - * returned is not part of the billing period. Set to null for subscriptions that are not - * currently active. - */ - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription is - * not currently active. - */ - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - fun _currentBillingPeriodStartDate(): JsonField = currentBillingPeriodStartDate - - /** - * 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. - */ - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - @JsonProperty("default_invoice_memo") - @ExcludeMissing - fun _defaultInvoiceMemo(): JsonField = defaultInvoiceMemo - - /** The discount intervals for this subscription. */ - @JsonProperty("discount_intervals") - @ExcludeMissing - fun _discountIntervals(): JsonField> = discountIntervals - - /** The date Orb stops billing for this subscription. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate - - @JsonProperty("fixed_fee_quantity_schedule") - @ExcludeMissing - fun _fixedFeeQuantitySchedule(): JsonField> = - fixedFeeQuantitySchedule - - @JsonProperty("invoicing_threshold") - @ExcludeMissing - fun _invoicingThreshold(): JsonField = invoicingThreshold - - /** The maximum intervals for this subscription. */ - @JsonProperty("maximum_intervals") - @ExcludeMissing - fun _maximumIntervals(): JsonField> = maximumIntervals - - /** - * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - /** The minimum intervals for this subscription. */ - @JsonProperty("minimum_intervals") - @ExcludeMissing - fun _minimumIntervals(): JsonField> = minimumIntervals - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms - - /** - * 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). - */ - @JsonProperty("plan") @ExcludeMissing fun _plan(): JsonField = plan - - /** The price intervals for this subscription. */ - @JsonProperty("price_intervals") - @ExcludeMissing - fun _priceIntervals(): JsonField> = priceIntervals - - @JsonProperty("redeemed_coupon") - @ExcludeMissing - fun _redeemedCoupon(): JsonField = redeemedCoupon - - /** The date Orb starts billing for this subscription. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo(): JsonField = trialInfo - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): SubscriptionUpdateFixedFeeQuantityResponse = apply { - if (validated) { - return@apply - } - - id() - activePlanPhaseOrder() - adjustmentIntervals().forEach { it.validate() } - autoCollection() - billingCycleAnchorConfiguration().validate() - billingCycleDay() - createdAt() - currentBillingPeriodEndDate() - currentBillingPeriodStartDate() - customer().validate() - defaultInvoiceMemo() - discountIntervals().forEach { it.validate() } - endDate() - fixedFeeQuantitySchedule().forEach { it.validate() } - invoicingThreshold() - maximumIntervals().forEach { it.validate() } - metadata().validate() - minimumIntervals().forEach { it.validate() } - netTerms() - plan().validate() - priceIntervals().forEach { it.validate() } - redeemedCoupon().ifPresent { it.validate() } - startDate() - status() - trialInfo().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SubscriptionUpdateFixedFeeQuantityResponse]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var activePlanPhaseOrder: JsonField? = null - private var adjustmentIntervals: JsonField>? = null - private var autoCollection: JsonField? = null - private var billingCycleAnchorConfiguration: JsonField? = - null - private var billingCycleDay: JsonField? = null - private var createdAt: JsonField? = null - private var currentBillingPeriodEndDate: JsonField? = null - private var currentBillingPeriodStartDate: JsonField? = null - private var customer: JsonField? = null - private var defaultInvoiceMemo: JsonField? = null - private var discountIntervals: JsonField>? = null - private var endDate: JsonField? = null - private var fixedFeeQuantitySchedule: JsonField>? = - null - private var invoicingThreshold: JsonField? = null - private var maximumIntervals: JsonField>? = null - private var metadata: JsonField? = null - private var minimumIntervals: JsonField>? = null - private var netTerms: JsonField? = null - private var plan: JsonField? = null - private var priceIntervals: JsonField>? = null - private var redeemedCoupon: JsonField? = null - private var startDate: JsonField? = null - private var status: JsonField? = null - private var trialInfo: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - subscriptionUpdateFixedFeeQuantityResponse: SubscriptionUpdateFixedFeeQuantityResponse - ) = apply { - id = subscriptionUpdateFixedFeeQuantityResponse.id - activePlanPhaseOrder = subscriptionUpdateFixedFeeQuantityResponse.activePlanPhaseOrder - adjustmentIntervals = - subscriptionUpdateFixedFeeQuantityResponse.adjustmentIntervals.map { - it.toMutableList() - } - autoCollection = subscriptionUpdateFixedFeeQuantityResponse.autoCollection - billingCycleAnchorConfiguration = - subscriptionUpdateFixedFeeQuantityResponse.billingCycleAnchorConfiguration - billingCycleDay = subscriptionUpdateFixedFeeQuantityResponse.billingCycleDay - createdAt = subscriptionUpdateFixedFeeQuantityResponse.createdAt - currentBillingPeriodEndDate = - subscriptionUpdateFixedFeeQuantityResponse.currentBillingPeriodEndDate - currentBillingPeriodStartDate = - subscriptionUpdateFixedFeeQuantityResponse.currentBillingPeriodStartDate - customer = subscriptionUpdateFixedFeeQuantityResponse.customer - defaultInvoiceMemo = subscriptionUpdateFixedFeeQuantityResponse.defaultInvoiceMemo - discountIntervals = - subscriptionUpdateFixedFeeQuantityResponse.discountIntervals.map { - it.toMutableList() - } - endDate = subscriptionUpdateFixedFeeQuantityResponse.endDate - fixedFeeQuantitySchedule = - subscriptionUpdateFixedFeeQuantityResponse.fixedFeeQuantitySchedule.map { - it.toMutableList() - } - invoicingThreshold = subscriptionUpdateFixedFeeQuantityResponse.invoicingThreshold - maximumIntervals = - subscriptionUpdateFixedFeeQuantityResponse.maximumIntervals.map { - it.toMutableList() - } - metadata = subscriptionUpdateFixedFeeQuantityResponse.metadata - minimumIntervals = - subscriptionUpdateFixedFeeQuantityResponse.minimumIntervals.map { - it.toMutableList() - } - netTerms = subscriptionUpdateFixedFeeQuantityResponse.netTerms - plan = subscriptionUpdateFixedFeeQuantityResponse.plan - priceIntervals = - subscriptionUpdateFixedFeeQuantityResponse.priceIntervals.map { it.toMutableList() } - redeemedCoupon = subscriptionUpdateFixedFeeQuantityResponse.redeemedCoupon - startDate = subscriptionUpdateFixedFeeQuantityResponse.startDate - status = subscriptionUpdateFixedFeeQuantityResponse.status - trialInfo = subscriptionUpdateFixedFeeQuantityResponse.trialInfo - additionalProperties = - subscriptionUpdateFixedFeeQuantityResponse.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(activePlanPhaseOrder: Long?) = - activePlanPhaseOrder(JsonField.ofNullable(activePlanPhaseOrder)) - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(activePlanPhaseOrder: Long) = - activePlanPhaseOrder(activePlanPhaseOrder as Long?) - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun activePlanPhaseOrder(activePlanPhaseOrder: Optional) = - activePlanPhaseOrder(activePlanPhaseOrder.orElse(null) as Long?) - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(activePlanPhaseOrder: JsonField) = apply { - this.activePlanPhaseOrder = activePlanPhaseOrder - } - - /** The adjustment intervals for this subscription. */ - fun adjustmentIntervals(adjustmentIntervals: List) = - adjustmentIntervals(JsonField.of(adjustmentIntervals)) - - /** The adjustment intervals for this subscription. */ - fun adjustmentIntervals(adjustmentIntervals: JsonField>) = apply { - this.adjustmentIntervals = adjustmentIntervals.map { it.toMutableList() } - } - - /** The adjustment intervals for this subscription. */ - fun addAdjustmentInterval(adjustmentInterval: AdjustmentInterval) = apply { - adjustmentIntervals = - (adjustmentIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(adjustmentInterval) - } - } - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - fun autoCollection(autoCollection: Boolean?) = - autoCollection(JsonField.ofNullable(autoCollection)) - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun autoCollection(autoCollection: Optional) = - autoCollection(autoCollection.orElse(null) as Boolean?) - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - fun autoCollection(autoCollection: JsonField) = apply { - this.autoCollection = autoCollection - } - - fun billingCycleAnchorConfiguration( - billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration - ) = billingCycleAnchorConfiguration(JsonField.of(billingCycleAnchorConfiguration)) - - fun billingCycleAnchorConfiguration( - billingCycleAnchorConfiguration: JsonField - ) = apply { this.billingCycleAnchorConfiguration = billingCycleAnchorConfiguration } - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun billingCycleDay(billingCycleDay: Long) = billingCycleDay(JsonField.of(billingCycleDay)) - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun billingCycleDay(billingCycleDay: JsonField) = apply { - this.billingCycleDay = billingCycleDay - } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is not part of the billing period. Set to null for subscriptions that - * are not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = - currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is not part of the billing period. Set to null for subscriptions that - * are not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = - currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is not part of the billing period. Set to null for subscriptions that - * are not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: JsonField) = - apply { - this.currentBillingPeriodEndDate = currentBillingPeriodEndDate - } - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription - * is not currently active. - */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = - currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription - * is not currently active. - */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: Optional) = - currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription - * is not currently active. - */ - fun currentBillingPeriodStartDate( - currentBillingPeriodStartDate: JsonField - ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } - - /** - * 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 customer(customer: Customer) = customer(JsonField.of(customer)) - - /** - * 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 customer(customer: JsonField) = apply { this.customer = customer } - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(defaultInvoiceMemo: String?) = - defaultInvoiceMemo(JsonField.ofNullable(defaultInvoiceMemo)) - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(defaultInvoiceMemo: Optional) = - defaultInvoiceMemo(defaultInvoiceMemo.orElse(null)) - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(defaultInvoiceMemo: JsonField) = apply { - this.defaultInvoiceMemo = defaultInvoiceMemo - } - - /** The discount intervals for this subscription. */ - fun discountIntervals(discountIntervals: List) = - discountIntervals(JsonField.of(discountIntervals)) - - /** The discount intervals for this subscription. */ - fun discountIntervals(discountIntervals: JsonField>) = apply { - this.discountIntervals = discountIntervals.map { it.toMutableList() } - } - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(discountInterval: DiscountInterval) = apply { - discountIntervals = - (discountIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(discountInterval) - } - } - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(amount: DiscountInterval.AmountDiscountInterval) = - addDiscountInterval(DiscountInterval.ofAmount(amount)) - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(percentage: DiscountInterval.PercentageDiscountInterval) = - addDiscountInterval(DiscountInterval.ofPercentage(percentage)) - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(usage: DiscountInterval.UsageDiscountInterval) = - addDiscountInterval(DiscountInterval.ofUsage(usage)) - - /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - fun fixedFeeQuantitySchedule(fixedFeeQuantitySchedule: List) = - fixedFeeQuantitySchedule(JsonField.of(fixedFeeQuantitySchedule)) - - fun fixedFeeQuantitySchedule( - fixedFeeQuantitySchedule: JsonField> - ) = apply { - this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule.map { it.toMutableList() } - } - - fun addFixedFeeQuantitySchedule(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = - apply { - this.fixedFeeQuantitySchedule = - (this.fixedFeeQuantitySchedule ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(fixedFeeQuantitySchedule) - } - } - - fun invoicingThreshold(invoicingThreshold: String?) = - invoicingThreshold(JsonField.ofNullable(invoicingThreshold)) - - fun invoicingThreshold(invoicingThreshold: Optional) = - invoicingThreshold(invoicingThreshold.orElse(null)) - - fun invoicingThreshold(invoicingThreshold: JsonField) = apply { - this.invoicingThreshold = invoicingThreshold - } - - /** The maximum intervals for this subscription. */ - fun maximumIntervals(maximumIntervals: List) = - maximumIntervals(JsonField.of(maximumIntervals)) - - /** The maximum intervals for this subscription. */ - fun maximumIntervals(maximumIntervals: JsonField>) = apply { - this.maximumIntervals = maximumIntervals.map { it.toMutableList() } - } - - /** The maximum intervals for this subscription. */ - fun addMaximumInterval(maximumInterval: MaximumInterval) = apply { - maximumIntervals = - (maximumIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(maximumInterval) - } - } - - /** - * 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - /** The minimum intervals for this subscription. */ - fun minimumIntervals(minimumIntervals: List) = - minimumIntervals(JsonField.of(minimumIntervals)) - - /** The minimum intervals for this subscription. */ - fun minimumIntervals(minimumIntervals: JsonField>) = apply { - this.minimumIntervals = minimumIntervals.map { it.toMutableList() } - } - - /** The minimum intervals for this subscription. */ - fun addMinimumInterval(minimumInterval: MinimumInterval) = apply { - minimumIntervals = - (minimumIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(minimumInterval) - } - } - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - fun netTerms(netTerms: Long) = netTerms(JsonField.of(netTerms)) - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } - - /** - * 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 plan(plan: Plan) = plan(JsonField.of(plan)) - - /** - * 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 plan(plan: JsonField) = apply { this.plan = plan } - - /** The price intervals for this subscription. */ - fun priceIntervals(priceIntervals: List) = - priceIntervals(JsonField.of(priceIntervals)) - - /** The price intervals for this subscription. */ - fun priceIntervals(priceIntervals: JsonField>) = apply { - this.priceIntervals = priceIntervals.map { it.toMutableList() } - } - - /** The price intervals for this subscription. */ - fun addPriceInterval(priceInterval: PriceInterval) = apply { - priceIntervals = - (priceIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(priceInterval) - } - } - - fun redeemedCoupon(redeemedCoupon: RedeemedCoupon?) = - redeemedCoupon(JsonField.ofNullable(redeemedCoupon)) - - fun redeemedCoupon(redeemedCoupon: Optional) = - redeemedCoupon(redeemedCoupon.orElse(null)) - - fun redeemedCoupon(redeemedCoupon: JsonField) = apply { - this.redeemedCoupon = redeemedCoupon - } - - /** The date Orb starts billing for this subscription. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The date Orb starts billing for this subscription. */ - fun startDate(startDate: JsonField) = apply { this.startDate = startDate } - - fun status(status: Status) = status(JsonField.of(status)) - - fun status(status: JsonField) = apply { this.status = status } - - fun trialInfo(trialInfo: TrialInfo) = trialInfo(JsonField.of(trialInfo)) - - fun trialInfo(trialInfo: JsonField) = apply { this.trialInfo = trialInfo } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): SubscriptionUpdateFixedFeeQuantityResponse = - SubscriptionUpdateFixedFeeQuantityResponse( - checkRequired("id", id), - checkRequired("activePlanPhaseOrder", activePlanPhaseOrder), - checkRequired("adjustmentIntervals", adjustmentIntervals).map { it.toImmutable() }, - checkRequired("autoCollection", autoCollection), - checkRequired("billingCycleAnchorConfiguration", billingCycleAnchorConfiguration), - checkRequired("billingCycleDay", billingCycleDay), - checkRequired("createdAt", createdAt), - checkRequired("currentBillingPeriodEndDate", currentBillingPeriodEndDate), - checkRequired("currentBillingPeriodStartDate", currentBillingPeriodStartDate), - checkRequired("customer", customer), - checkRequired("defaultInvoiceMemo", defaultInvoiceMemo), - checkRequired("discountIntervals", discountIntervals).map { it.toImmutable() }, - checkRequired("endDate", endDate), - checkRequired("fixedFeeQuantitySchedule", fixedFeeQuantitySchedule).map { - it.toImmutable() - }, - checkRequired("invoicingThreshold", invoicingThreshold), - checkRequired("maximumIntervals", maximumIntervals).map { it.toImmutable() }, - checkRequired("metadata", metadata), - checkRequired("minimumIntervals", minimumIntervals).map { it.toImmutable() }, - checkRequired("netTerms", netTerms), - checkRequired("plan", plan), - checkRequired("priceIntervals", priceIntervals).map { it.toImmutable() }, - checkRequired("redeemedCoupon", redeemedCoupon), - checkRequired("startDate", startDate), - checkRequired("status", status), - checkRequired("trialInfo", trialInfo), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class AdjustmentInterval - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment") - @ExcludeMissing - private val adjustment: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") - - /** The price interval IDs that this adjustment applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - /** The end date of the adjustment interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** The start date of the adjustment interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment - - /** The price interval IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - /** The end date of the adjustment interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** The start date of the adjustment interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AdjustmentInterval = apply { - if (validated) { - return@apply - } - - id() - adjustment().validate() - appliesToPriceIntervalIds() - endDate() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AdjustmentInterval]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustment: JsonField? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(adjustmentInterval: AdjustmentInterval) = apply { - id = adjustmentInterval.id - adjustment = adjustmentInterval.adjustment - appliesToPriceIntervalIds = - adjustmentInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - endDate = adjustmentInterval.endDate - startDate = adjustmentInterval.startDate - additionalProperties = adjustmentInterval.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) - - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } - - fun adjustment(planPhaseUsageDiscount: Adjustment.PlanPhaseUsageDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)) - - fun adjustment(planPhaseAmountDiscount: Adjustment.PlanPhaseAmountDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)) - - fun adjustment( - planPhasePercentageDiscount: Adjustment.PlanPhasePercentageDiscountAdjustment - ) = adjustment(Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)) - - fun adjustment(planPhaseMinimum: Adjustment.PlanPhaseMinimumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)) - - fun adjustment(planPhaseMaximum: Adjustment.PlanPhaseMaximumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)) - - /** The price interval IDs that this adjustment applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval IDs that this adjustment applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval IDs that this adjustment applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - /** The end date of the adjustment interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the adjustment interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the adjustment interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** The start date of the adjustment interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the adjustment interval. */ - 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) - } - - fun build(): AdjustmentInterval = - AdjustmentInterval( - checkRequired("id", id), - checkRequired("adjustment", adjustment), - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment? = null, - private val planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment? = null, - private val planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment? = null, - private val planPhaseMinimum: PlanPhaseMinimumAdjustment? = null, - private val planPhaseMaximum: PlanPhaseMaximumAdjustment? = null, - private val _json: JsonValue? = null, - ) { - - fun planPhaseUsageDiscount(): Optional = - Optional.ofNullable(planPhaseUsageDiscount) - - fun planPhaseAmountDiscount(): Optional = - Optional.ofNullable(planPhaseAmountDiscount) - - fun planPhasePercentageDiscount(): Optional = - Optional.ofNullable(planPhasePercentageDiscount) - - fun planPhaseMinimum(): Optional = - Optional.ofNullable(planPhaseMinimum) - - fun planPhaseMaximum(): Optional = - Optional.ofNullable(planPhaseMaximum) - - fun isPlanPhaseUsageDiscount(): Boolean = planPhaseUsageDiscount != null - - fun isPlanPhaseAmountDiscount(): Boolean = planPhaseAmountDiscount != null - - fun isPlanPhasePercentageDiscount(): Boolean = planPhasePercentageDiscount != null - - fun isPlanPhaseMinimum(): Boolean = planPhaseMinimum != null - - fun isPlanPhaseMaximum(): Boolean = planPhaseMaximum != null - - fun asPlanPhaseUsageDiscount(): PlanPhaseUsageDiscountAdjustment = - planPhaseUsageDiscount.getOrThrow("planPhaseUsageDiscount") - - fun asPlanPhaseAmountDiscount(): PlanPhaseAmountDiscountAdjustment = - planPhaseAmountDiscount.getOrThrow("planPhaseAmountDiscount") - - fun asPlanPhasePercentageDiscount(): PlanPhasePercentageDiscountAdjustment = - planPhasePercentageDiscount.getOrThrow("planPhasePercentageDiscount") - - fun asPlanPhaseMinimum(): PlanPhaseMinimumAdjustment = - planPhaseMinimum.getOrThrow("planPhaseMinimum") - - fun asPlanPhaseMaximum(): PlanPhaseMaximumAdjustment = - planPhaseMaximum.getOrThrow("planPhaseMaximum") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - planPhaseUsageDiscount != null -> - visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) - planPhaseAmountDiscount != null -> - visitor.visitPlanPhaseAmountDiscount(planPhaseAmountDiscount) - planPhasePercentageDiscount != null -> - visitor.visitPlanPhasePercentageDiscount(planPhasePercentageDiscount) - planPhaseMinimum != null -> visitor.visitPlanPhaseMinimum(planPhaseMinimum) - planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) { - planPhaseUsageDiscount.validate() - } - - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) { - planPhaseAmountDiscount.validate() - } - - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) { - planPhasePercentageDiscount.validate() - } - - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) { - planPhaseMinimum.validate() - } - - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) { - planPhaseMaximum.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Adjustment && planPhaseUsageDiscount == other.planPhaseUsageDiscount && planPhaseAmountDiscount == other.planPhaseAmountDiscount && planPhasePercentageDiscount == other.planPhasePercentageDiscount && planPhaseMinimum == other.planPhaseMinimum && planPhaseMaximum == other.planPhaseMaximum /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(planPhaseUsageDiscount, planPhaseAmountDiscount, planPhasePercentageDiscount, planPhaseMinimum, planPhaseMaximum) /* spotless:on */ - - override fun toString(): String = - when { - planPhaseUsageDiscount != null -> - "Adjustment{planPhaseUsageDiscount=$planPhaseUsageDiscount}" - planPhaseAmountDiscount != null -> - "Adjustment{planPhaseAmountDiscount=$planPhaseAmountDiscount}" - planPhasePercentageDiscount != null -> - "Adjustment{planPhasePercentageDiscount=$planPhasePercentageDiscount}" - planPhaseMinimum != null -> "Adjustment{planPhaseMinimum=$planPhaseMinimum}" - planPhaseMaximum != null -> "Adjustment{planPhaseMaximum=$planPhaseMaximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } - - companion object { - - @JvmStatic - fun ofPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = Adjustment(planPhaseUsageDiscount = planPhaseUsageDiscount) - - @JvmStatic - fun ofPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = Adjustment(planPhaseAmountDiscount = planPhaseAmountDiscount) - - @JvmStatic - fun ofPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = Adjustment(planPhasePercentageDiscount = planPhasePercentageDiscount) - - @JvmStatic - fun ofPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment) = - Adjustment(planPhaseMinimum = planPhaseMinimum) - - @JvmStatic - fun ofPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment) = - Adjustment(planPhaseMaximum = planPhaseMaximum) - } - - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { - - fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ): T - - fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ): T - - fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ): T - - fun visitPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment): T - - fun visitPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment): T - - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } - - internal class Deserializer : BaseDeserializer(Adjustment::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = - json.asObject().getOrNull()?.get("adjustment_type")?.asString()?.getOrNull() - - when (adjustmentType) { - "usage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseUsageDiscount = it, _json = json) - } - } - "amount_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseAmountDiscount = it, _json = json) - } - } - "percentage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment( - planPhasePercentageDiscount = it, - _json = json, - ) - } - } - "minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMinimum = it, _json = json) - } - } - "maximum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMaximum = it, _json = json) - } - } - } - - return Adjustment(_json = json) - } - } - - internal class Serializer : BaseSerializer(Adjustment::class) { - - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.planPhaseUsageDiscount != null -> - generator.writeObject(value.planPhaseUsageDiscount) - value.planPhaseAmountDiscount != null -> - generator.writeObject(value.planPhaseAmountDiscount) - value.planPhasePercentageDiscount != null -> - generator.writeObject(value.planPhasePercentageDiscount) - value.planPhaseMinimum != null -> - generator.writeObject(value.planPhaseMinimum) - value.planPhaseMaximum != null -> - generator.writeObject(value.planPhaseMaximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") - } - } - } - - @NoAutoDetect - class PlanPhaseUsageDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonProperty("usage_discount") - @ExcludeMissing - private val usageDiscount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - /** - * The number of usage units by which to discount the price this adjustment applies - * to in a given billing period. - */ - fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - /** - * The number of usage units by which to discount the price this adjustment applies - * to in a given billing period. - */ - @JsonProperty("usage_discount") - @ExcludeMissing - fun _usageDiscount(): JsonField = usageDiscount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseUsageDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - planPhaseOrder() - reason() - usageDiscount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseUsageDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var usageDiscount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - planPhaseUsageDiscountAdjustment: PlanPhaseUsageDiscountAdjustment - ) = apply { - id = planPhaseUsageDiscountAdjustment.id - adjustmentType = planPhaseUsageDiscountAdjustment.adjustmentType - appliesToPriceIds = - planPhaseUsageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseUsageDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseUsageDiscountAdjustment.planPhaseOrder - reason = planPhaseUsageDiscountAdjustment.reason - usageDiscount = planPhaseUsageDiscountAdjustment.usageDiscount - additionalProperties = - planPhaseUsageDiscountAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - /** - * The number of usage units by which to discount the price this adjustment - * applies to in a given billing period. - */ - fun usageDiscount(usageDiscount: Double) = - usageDiscount(JsonField.of(usageDiscount)) - - /** - * The number of usage units by which to discount the price this adjustment - * applies to in a given billing period. - */ - fun usageDiscount(usageDiscount: JsonField) = apply { - this.usageDiscount = usageDiscount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseUsageDiscountAdjustment = - PlanPhaseUsageDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - checkRequired("usageDiscount", usageDiscount), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - USAGE_DISCOUNT -> Known.USAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseUsageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, planPhaseOrder, reason, usageDiscount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseUsageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhaseAmountDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("amount_discount") - @ExcludeMissing - private val amountDiscount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** - * The amount by which to discount the prices this adjustment applies to in a given - * billing period. - */ - fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** - * The amount by which to discount the prices this adjustment applies to in a given - * billing period. - */ - @JsonProperty("amount_discount") - @ExcludeMissing - fun _amountDiscount(): JsonField = amountDiscount - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseAmountDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - amountDiscount() - appliesToPriceIds() - isInvoiceLevel() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseAmountDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var amountDiscount: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - planPhaseAmountDiscountAdjustment: PlanPhaseAmountDiscountAdjustment - ) = apply { - id = planPhaseAmountDiscountAdjustment.id - adjustmentType = planPhaseAmountDiscountAdjustment.adjustmentType - amountDiscount = planPhaseAmountDiscountAdjustment.amountDiscount - appliesToPriceIds = - planPhaseAmountDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseAmountDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseAmountDiscountAdjustment.planPhaseOrder - reason = planPhaseAmountDiscountAdjustment.reason - additionalProperties = - planPhaseAmountDiscountAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** - * The amount by which to discount the prices this adjustment applies to in a - * given billing period. - */ - fun amountDiscount(amountDiscount: String) = - amountDiscount(JsonField.of(amountDiscount)) - - /** - * The amount by which to discount the prices this adjustment applies to in a - * given billing period. - */ - fun amountDiscount(amountDiscount: JsonField) = apply { - this.amountDiscount = amountDiscount - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseAmountDiscountAdjustment = - PlanPhaseAmountDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("amountDiscount", amountDiscount), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseAmountDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, amountDiscount, appliesToPriceIds, isInvoiceLevel, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseAmountDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhasePercentageDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("percentage_discount") - @ExcludeMissing - private val percentageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(): Double = - percentageDiscount.getRequired("percentage_discount") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - @JsonProperty("percentage_discount") - @ExcludeMissing - fun _percentageDiscount(): JsonField = percentageDiscount - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhasePercentageDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - percentageDiscount() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhasePercentageDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var percentageDiscount: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - planPhasePercentageDiscountAdjustment: PlanPhasePercentageDiscountAdjustment - ) = apply { - id = planPhasePercentageDiscountAdjustment.id - adjustmentType = planPhasePercentageDiscountAdjustment.adjustmentType - appliesToPriceIds = - planPhasePercentageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhasePercentageDiscountAdjustment.isInvoiceLevel - percentageDiscount = - planPhasePercentageDiscountAdjustment.percentageDiscount - planPhaseOrder = planPhasePercentageDiscountAdjustment.planPhaseOrder - reason = planPhasePercentageDiscountAdjustment.reason - additionalProperties = - planPhasePercentageDiscountAdjustment.additionalProperties - .toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(percentageDiscount: Double) = - percentageDiscount(JsonField.of(percentageDiscount)) - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(percentageDiscount: JsonField) = apply { - this.percentageDiscount = percentageDiscount - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhasePercentageDiscountAdjustment = - PlanPhasePercentageDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("percentageDiscount", percentageDiscount), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val PERCENTAGE_DISCOUNT = of("percentage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhasePercentageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, percentageDiscount, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhasePercentageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhaseMinimumAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(): String = itemId.getRequired("item_id") - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The item ID that revenue from this minimum will be attributed to. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseMinimumAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - itemId() - minimumAmount() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseMinimumAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var itemId: JsonField? = null - private var minimumAmount: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(planPhaseMinimumAdjustment: PlanPhaseMinimumAdjustment) = - apply { - id = planPhaseMinimumAdjustment.id - adjustmentType = planPhaseMinimumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMinimumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMinimumAdjustment.isInvoiceLevel - itemId = planPhaseMinimumAdjustment.itemId - minimumAmount = planPhaseMinimumAdjustment.minimumAmount - planPhaseOrder = planPhaseMinimumAdjustment.planPhaseOrder - reason = planPhaseMinimumAdjustment.reason - additionalProperties = - planPhaseMinimumAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseMinimumAdjustment = - PlanPhaseMinimumAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("itemId", itemId), - checkRequired("minimumAmount", minimumAmount), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseMinimumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, itemId, minimumAmount, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseMinimumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhaseMaximumAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseMaximumAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - maximumAmount() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseMaximumAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var maximumAmount: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(planPhaseMaximumAdjustment: PlanPhaseMaximumAdjustment) = - apply { - id = planPhaseMaximumAdjustment.id - adjustmentType = planPhaseMaximumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMaximumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMaximumAdjustment.isInvoiceLevel - maximumAmount = planPhaseMaximumAdjustment.maximumAmount - planPhaseOrder = planPhaseMaximumAdjustment.planPhaseOrder - reason = planPhaseMaximumAdjustment.reason - additionalProperties = - planPhaseMaximumAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseMaximumAdjustment = - PlanPhaseMaximumAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("maximumAmount", maximumAmount), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseMaximumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, maximumAmount, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseMaximumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentInterval && id == other.id && adjustment == other.adjustment && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustment, appliesToPriceIntervalIds, endDate, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AdjustmentInterval{id=$id, adjustment=$adjustment, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BillingCycleAnchorConfiguration - @JsonCreator - private constructor( - @JsonProperty("day") @ExcludeMissing private val day: JsonField = JsonMissing.of(), - @JsonProperty("month") - @ExcludeMissing - private val month: JsonField = JsonMissing.of(), - @JsonProperty("year") @ExcludeMissing private val year: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun day(): Long = day.getRequired("day") - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(): Optional = Optional.ofNullable(month.getNullable("month")) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on - * 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(): Optional = Optional.ofNullable(year.getNullable("year")) - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - @JsonProperty("day") @ExcludeMissing fun _day(): JsonField = day - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - @JsonProperty("month") @ExcludeMissing fun _month(): JsonField = month - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on - * 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - @JsonProperty("year") @ExcludeMissing fun _year(): JsonField = year - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleAnchorConfiguration = apply { - if (validated) { - return@apply - } - - day() - month() - year() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleAnchorConfiguration]. */ - class Builder internal constructor() { - - private var day: JsonField? = null - private var month: JsonField = JsonMissing.of() - private var year: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration) = - apply { - day = billingCycleAnchorConfiguration.day - month = billingCycleAnchorConfiguration.month - year = billingCycleAnchorConfiguration.year - additionalProperties = - billingCycleAnchorConfiguration.additionalProperties.toMutableMap() - } - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun day(day: Long) = day(JsonField.of(day)) - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun day(day: JsonField) = apply { this.day = day } - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(month: Long?) = month(JsonField.ofNullable(month)) - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(month: Long) = month(month as Long?) - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun month(month: Optional) = month(month.orElse(null) as Long?) - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(month: JsonField) = apply { this.month = month } - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(year: Long?) = year(JsonField.ofNullable(year)) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(year: Long) = year(year as Long?) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun year(year: Optional) = year(year.orElse(null) as Long?) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(year: JsonField) = apply { this.year = year } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleAnchorConfiguration = - BillingCycleAnchorConfiguration( - checkRequired("day", day), - month, - year, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleAnchorConfiguration && day == other.day && month == other.month && year == other.year && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(day, month, year, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleAnchorConfiguration{day=$day, month=$month, year=$year, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(using = DiscountInterval.Deserializer::class) - @JsonSerialize(using = DiscountInterval.Serializer::class) - class DiscountInterval - private constructor( - private val amount: AmountDiscountInterval? = null, - private val percentage: PercentageDiscountInterval? = null, - private val usage: UsageDiscountInterval? = null, - private val _json: JsonValue? = null, - ) { - - fun amount(): Optional = Optional.ofNullable(amount) - - fun percentage(): Optional = Optional.ofNullable(percentage) - - fun usage(): Optional = Optional.ofNullable(usage) - - fun isAmount(): Boolean = amount != null - - fun isPercentage(): Boolean = percentage != null - - fun isUsage(): Boolean = usage != null - - fun asAmount(): AmountDiscountInterval = amount.getOrThrow("amount") - - fun asPercentage(): PercentageDiscountInterval = percentage.getOrThrow("percentage") - - fun asUsage(): UsageDiscountInterval = usage.getOrThrow("usage") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - amount != null -> visitor.visitAmount(amount) - percentage != null -> visitor.visitPercentage(percentage) - usage != null -> visitor.visitUsage(usage) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): DiscountInterval = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitAmount(amount: AmountDiscountInterval) { - amount.validate() - } - - override fun visitPercentage(percentage: PercentageDiscountInterval) { - percentage.validate() - } - - override fun visitUsage(usage: UsageDiscountInterval) { - usage.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountInterval && amount == other.amount && percentage == other.percentage && usage == other.usage /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(amount, percentage, usage) /* spotless:on */ - - override fun toString(): String = - when { - amount != null -> "DiscountInterval{amount=$amount}" - percentage != null -> "DiscountInterval{percentage=$percentage}" - usage != null -> "DiscountInterval{usage=$usage}" - _json != null -> "DiscountInterval{_unknown=$_json}" - else -> throw IllegalStateException("Invalid DiscountInterval") - } - - companion object { - - @JvmStatic - fun ofAmount(amount: AmountDiscountInterval) = DiscountInterval(amount = amount) - - @JvmStatic - fun ofPercentage(percentage: PercentageDiscountInterval) = - DiscountInterval(percentage = percentage) - - @JvmStatic fun ofUsage(usage: UsageDiscountInterval) = DiscountInterval(usage = usage) - } - - /** - * An interface that defines how to map each variant of [DiscountInterval] to a value of - * type [T]. - */ - interface Visitor { - - fun visitAmount(amount: AmountDiscountInterval): T - - fun visitPercentage(percentage: PercentageDiscountInterval): T - - fun visitUsage(usage: UsageDiscountInterval): T - - /** - * Maps an unknown variant of [DiscountInterval] to a value of type [T]. - * - * An instance of [DiscountInterval] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown DiscountInterval: $json") - } - } - - internal class Deserializer : BaseDeserializer(DiscountInterval::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): DiscountInterval { - val json = JsonValue.fromJsonNode(node) - val discountType = - json.asObject().getOrNull()?.get("discount_type")?.asString()?.getOrNull() - - when (discountType) { - "amount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(amount = it, _json = json) - } - } - "percentage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(percentage = it, _json = json) - } - } - "usage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(usage = it, _json = json) - } - } - } - - return DiscountInterval(_json = json) - } - } - - internal class Serializer : BaseSerializer(DiscountInterval::class) { - - override fun serialize( - value: DiscountInterval, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.amount != null -> generator.writeObject(value.amount) - value.percentage != null -> generator.writeObject(value.percentage) - value.usage != null -> generator.writeObject(value.usage) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid DiscountInterval") - } - } - } - - @NoAutoDetect - class AmountDiscountInterval - @JsonCreator - private constructor( - @JsonProperty("amount_discount") - @ExcludeMissing - private val amountDiscount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("discount_type") - @ExcludeMissing - private val discountType: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - fun discountType(): DiscountType = discountType.getRequired("discount_type") - - /** The end date of the discount interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** The start date of the discount interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** Only available if discount_type is `amount`. */ - @JsonProperty("amount_discount") - @ExcludeMissing - fun _amountDiscount(): JsonField = amountDiscount - - /** The price ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - - /** The end date of the discount interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** The start date of the discount interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AmountDiscountInterval = apply { - if (validated) { - return@apply - } - - amountDiscount() - appliesToPriceIds() - appliesToPriceIntervalIds() - discountType() - endDate() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AmountDiscountInterval]. */ - class Builder internal constructor() { - - private var amountDiscount: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { - amountDiscount = amountDiscountInterval.amountDiscount - appliesToPriceIds = - amountDiscountInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - amountDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = amountDiscountInterval.discountType - endDate = amountDiscountInterval.endDate - startDate = amountDiscountInterval.startDate - additionalProperties = - amountDiscountInterval.additionalProperties.toMutableMap() - } - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(amountDiscount: String) = - amountDiscount(JsonField.of(amountDiscount)) - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(amountDiscount: JsonField) = apply { - this.amountDiscount = amountDiscount - } - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this discount interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this discount interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the discount interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the discount interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** The start date of the discount interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the discount interval. */ - 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) - } - - fun build(): AmountDiscountInterval = - AmountDiscountInterval( - checkRequired("amountDiscount", amountDiscount), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("discountType", discountType), - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val AMOUNT = of("amount") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - AMOUNT - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT -> Value.AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AMOUNT -> Known.AMOUNT - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AmountDiscountInterval && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amountDiscount, appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AmountDiscountInterval{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PercentageDiscountInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("discount_type") - @ExcludeMissing - private val discountType: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("percentage_discount") - @ExcludeMissing - private val percentageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - fun discountType(): DiscountType = discountType.getRequired("discount_type") - - /** The end date of the discount interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ - fun percentageDiscount(): Double = percentageDiscount.getRequired("percentage_discount") - - /** The start date of the discount interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** The price ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - - /** The end date of the discount interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ - @JsonProperty("percentage_discount") - @ExcludeMissing - fun _percentageDiscount(): JsonField = percentageDiscount - - /** The start date of the discount interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PercentageDiscountInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - discountType() - endDate() - percentageDiscount() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PercentageDiscountInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null - private var endDate: JsonField? = null - private var percentageDiscount: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { - appliesToPriceIds = - percentageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - percentageDiscountInterval.appliesToPriceIntervalIds.map { - it.toMutableList() - } - discountType = percentageDiscountInterval.discountType - endDate = percentageDiscountInterval.endDate - percentageDiscount = percentageDiscountInterval.percentageDiscount - startDate = percentageDiscountInterval.startDate - additionalProperties = - percentageDiscountInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this discount interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this discount interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the discount interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the discount interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** - * Only available if discount_type is `percentage`.This is a number between 0 and 1. - */ - fun percentageDiscount(percentageDiscount: Double) = - percentageDiscount(JsonField.of(percentageDiscount)) - - /** - * Only available if discount_type is `percentage`.This is a number between 0 and 1. - */ - fun percentageDiscount(percentageDiscount: JsonField) = apply { - this.percentageDiscount = percentageDiscount - } - - /** The start date of the discount interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the discount interval. */ - 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) - } - - fun build(): PercentageDiscountInterval = - PercentageDiscountInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("discountType", discountType), - checkRequired("endDate", endDate), - checkRequired("percentageDiscount", percentageDiscount), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val PERCENTAGE = of("percentage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - PERCENTAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE -> Value.PERCENTAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PERCENTAGE -> Known.PERCENTAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PercentageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, percentageDiscount, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PercentageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class UsageDiscountInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("discount_type") - @ExcludeMissing - private val discountType: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonProperty("usage_discount") - @ExcludeMissing - private val usageDiscount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - fun discountType(): DiscountType = discountType.getRequired("discount_type") - - /** The end date of the discount interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** The start date of the discount interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** - * Only available if discount_type is `usage`. Number of usage units that this discount - * is for - */ - fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - - /** The price ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - - /** The end date of the discount interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** The start date of the discount interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - /** - * Only available if discount_type is `usage`. Number of usage units that this discount - * is for - */ - @JsonProperty("usage_discount") - @ExcludeMissing - fun _usageDiscount(): JsonField = usageDiscount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): UsageDiscountInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - discountType() - endDate() - startDate() - usageDiscount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UsageDiscountInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var usageDiscount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { - appliesToPriceIds = - usageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - usageDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = usageDiscountInterval.discountType - endDate = usageDiscountInterval.endDate - startDate = usageDiscountInterval.startDate - usageDiscount = usageDiscountInterval.usageDiscount - additionalProperties = usageDiscountInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this discount interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this discount interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the discount interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the discount interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** The start date of the discount interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the discount interval. */ - fun startDate(startDate: JsonField) = apply { - this.startDate = startDate - } - - /** - * Only available if discount_type is `usage`. Number of usage units that this - * discount is for - */ - fun usageDiscount(usageDiscount: Double) = - usageDiscount(JsonField.of(usageDiscount)) - - /** - * Only available if discount_type is `usage`. Number of usage units that this - * discount is for - */ - fun usageDiscount(usageDiscount: JsonField) = apply { - this.usageDiscount = usageDiscount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): UsageDiscountInterval = - UsageDiscountInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("discountType", discountType), - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - checkRequired("usageDiscount", usageDiscount), - additionalProperties.toImmutable(), - ) - } - - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE = of("usage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - USAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE -> Value.USAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE -> Known.USAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UsageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, startDate, usageDiscount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UsageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" - } - } - - @NoAutoDetect - class FixedFeeQuantitySchedule - @JsonCreator - private constructor( - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("price_id") - @ExcludeMissing - private val priceId: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - private val quantity: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - fun priceId(): String = priceId.getRequired("price_id") - - fun quantity(): Double = quantity.getRequired("quantity") - - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - - @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): FixedFeeQuantitySchedule = apply { - if (validated) { - return@apply - } - - endDate() - priceId() - quantity() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FixedFeeQuantitySchedule]. */ - class Builder internal constructor() { - - private var endDate: JsonField? = null - private var priceId: JsonField? = null - private var quantity: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = apply { - endDate = fixedFeeQuantitySchedule.endDate - priceId = fixedFeeQuantitySchedule.priceId - quantity = fixedFeeQuantitySchedule.quantity - startDate = fixedFeeQuantitySchedule.startDate - additionalProperties = fixedFeeQuantitySchedule.additionalProperties.toMutableMap() - } - - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) - - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - 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) - } - - fun build(): FixedFeeQuantitySchedule = - FixedFeeQuantitySchedule( - checkRequired("endDate", endDate), - checkRequired("priceId", priceId), - checkRequired("quantity", quantity), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FixedFeeQuantitySchedule && endDate == other.endDate && priceId == other.priceId && quantity == other.quantity && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(endDate, priceId, quantity, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "FixedFeeQuantitySchedule{endDate=$endDate, priceId=$priceId, quantity=$quantity, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class MaximumInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this maximum interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this maximum interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - /** The end date of the maximum interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** The start date of the maximum interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** The price ids that this maximum interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this maximum interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - /** The end date of the maximum interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** The start date of the maximum interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MaximumInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - endDate() - maximumAmount() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MaximumInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var endDate: JsonField? = null - private var maximumAmount: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximumInterval: MaximumInterval) = apply { - appliesToPriceIds = maximumInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - maximumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - endDate = maximumInterval.endDate - maximumAmount = maximumInterval.maximumAmount - startDate = maximumInterval.startDate - additionalProperties = maximumInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this maximum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this maximum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this maximum interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this maximum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this maximum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this maximum interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - /** The end date of the maximum interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the maximum interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the maximum interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** The start date of the maximum interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the maximum interval. */ - 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) - } - - fun build(): MaximumInterval = - MaximumInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("endDate", endDate), - checkRequired("maximumAmount", maximumAmount), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MaximumInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && maximumAmount == other.maximumAmount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, endDate, maximumAmount, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MaximumInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, maximumAmount=$maximumAmount, startDate=$startDate, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class MinimumInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this minimum interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this minimum interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - /** The end date of the minimum interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** The start date of the minimum interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** The price ids that this minimum interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this minimum interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - /** The end date of the minimum interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** The start date of the minimum interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MinimumInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - endDate() - minimumAmount() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MinimumInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var endDate: JsonField? = null - private var minimumAmount: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(minimumInterval: MinimumInterval) = apply { - appliesToPriceIds = minimumInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - minimumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - endDate = minimumInterval.endDate - minimumAmount = minimumInterval.minimumAmount - startDate = minimumInterval.startDate - additionalProperties = minimumInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this minimum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this minimum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this minimum interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this minimum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this minimum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this minimum interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - /** The end date of the minimum interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the minimum interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the minimum interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** The start date of the minimum interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the minimum interval. */ - 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) - } - - fun build(): MinimumInterval = - MinimumInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("endDate", endDate), - checkRequired("minimumAmount", minimumAmount), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MinimumInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && minimumAmount == other.minimumAmount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, endDate, minimumAmount, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MinimumInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, minimumAmount=$minimumAmount, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - /** - * The Price Interval resource represents a period of time for which a price will bill on a - * subscription. A subscription’s price intervals define its billing behavior. - */ - @NoAutoDetect - class PriceInterval - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_day") - @ExcludeMissing - private val billingCycleDay: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - private val currentBillingPeriodEndDate: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - private val currentBillingPeriodStartDate: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("filter") - @ExcludeMissing - private val filter: JsonField = JsonMissing.of(), - @JsonProperty("fixed_fee_quantity_transitions") - @ExcludeMissing - private val fixedFeeQuantityTransitions: JsonField> = - JsonMissing.of(), - @JsonProperty("price") - @ExcludeMissing - private val price: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonProperty("usage_customer_ids") - @ExcludeMissing - private val usageCustomerIds: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - /** The day of the month that Orb bills for this price */ - fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate(): Optional = - Optional.ofNullable( - currentBillingPeriodEndDate.getNullable("current_billing_period_end_date") - ) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodStartDate(): Optional = - Optional.ofNullable( - currentBillingPeriodStartDate.getNullable("current_billing_period_start_date") - ) - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** An additional filter to apply to usage queries. */ - fun filter(): Optional = Optional.ofNullable(filter.getNullable("filter")) - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions(): Optional> = - Optional.ofNullable( - fixedFeeQuantityTransitions.getNullable("fixed_fee_quantity_transitions") - ) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting in - * a charge on an invoice in the form of an invoice line item. Prices take a quantity and - * determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the key - * for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(): Price = price.getRequired("price") - - /** - * The start date of the price interval. This is the date that Orb starts billing for this - * price. - */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this price - * interval. - */ - fun usageCustomerIds(): Optional> = - Optional.ofNullable(usageCustomerIds.getNullable("usage_customer_ids")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** The day of the month that Orb bills for this price */ - @JsonProperty("billing_cycle_day") - @ExcludeMissing - fun _billingCycleDay(): JsonField = billingCycleDay - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if this price - * interval is not currently active. - */ - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - fun _currentBillingPeriodStartDate(): JsonField = - currentBillingPeriodStartDate - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** An additional filter to apply to usage queries. */ - @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField = filter - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - @JsonProperty("fixed_fee_quantity_transitions") - @ExcludeMissing - fun _fixedFeeQuantityTransitions(): JsonField> = - fixedFeeQuantityTransitions - - /** - * 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) - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - - /** - * The start date of the price interval. This is the date that Orb starts billing for this - * price. - */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this price - * interval. - */ - @JsonProperty("usage_customer_ids") - @ExcludeMissing - fun _usageCustomerIds(): JsonField> = usageCustomerIds - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PriceInterval = apply { - if (validated) { - return@apply - } - - id() - billingCycleDay() - currentBillingPeriodEndDate() - currentBillingPeriodStartDate() - endDate() - filter() - fixedFeeQuantityTransitions().ifPresent { it.forEach { it.validate() } } - price().validate() - startDate() - usageCustomerIds() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PriceInterval]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var billingCycleDay: JsonField? = null - private var currentBillingPeriodEndDate: JsonField? = null - private var currentBillingPeriodStartDate: JsonField? = null - private var endDate: JsonField? = null - private var filter: JsonField? = null - private var fixedFeeQuantityTransitions: - JsonField>? = - null - private var price: JsonField? = null - private var startDate: JsonField? = null - private var usageCustomerIds: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(priceInterval: PriceInterval) = apply { - id = priceInterval.id - billingCycleDay = priceInterval.billingCycleDay - currentBillingPeriodEndDate = priceInterval.currentBillingPeriodEndDate - currentBillingPeriodStartDate = priceInterval.currentBillingPeriodStartDate - endDate = priceInterval.endDate - filter = priceInterval.filter - fixedFeeQuantityTransitions = - priceInterval.fixedFeeQuantityTransitions.map { it.toMutableList() } - price = priceInterval.price - startDate = priceInterval.startDate - usageCustomerIds = priceInterval.usageCustomerIds.map { it.toMutableList() } - additionalProperties = priceInterval.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - /** The day of the month that Orb bills for this price */ - fun billingCycleDay(billingCycleDay: Long) = - billingCycleDay(JsonField.of(billingCycleDay)) - - /** The day of the month that Orb bills for this price */ - fun billingCycleDay(billingCycleDay: JsonField) = apply { - this.billingCycleDay = billingCycleDay - } - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = - currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = - currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate( - currentBillingPeriodEndDate: JsonField - ) = apply { this.currentBillingPeriodEndDate = currentBillingPeriodEndDate } - - /** - * The start date of the current billing period. This is an inclusive timestamp; the - * instant returned is exactly the beginning of the billing period. Set to null if this - * price interval is not currently active. - */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = - currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the - * instant returned is exactly the beginning of the billing period. Set to null if this - * price interval is not currently active. - */ - fun currentBillingPeriodStartDate( - currentBillingPeriodStartDate: Optional - ) = currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the - * instant returned is exactly the beginning of the billing period. Set to null if this - * price interval is not currently active. - */ - fun currentBillingPeriodStartDate( - currentBillingPeriodStartDate: JsonField - ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** An additional filter to apply to usage queries. */ - fun filter(filter: String?) = filter(JsonField.ofNullable(filter)) - - /** An additional filter to apply to usage queries. */ - fun filter(filter: Optional) = filter(filter.orElse(null)) - - /** An additional filter to apply to usage queries. */ - fun filter(filter: JsonField) = apply { this.filter = filter } - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: List? - ) = fixedFeeQuantityTransitions(JsonField.ofNullable(fixedFeeQuantityTransitions)) - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: Optional> - ) = fixedFeeQuantityTransitions(fixedFeeQuantityTransitions.orElse(null)) - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: JsonField> - ) = apply { - this.fixedFeeQuantityTransitions = - fixedFeeQuantityTransitions.map { it.toMutableList() } - } - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun addFixedFeeQuantityTransition( - fixedFeeQuantityTransition: FixedFeeQuantityTransition - ) = apply { - fixedFeeQuantityTransitions = - (fixedFeeQuantityTransitions ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(fixedFeeQuantityTransition) - } - } - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(price: Price) = price(JsonField.of(price)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(price: JsonField) = apply { this.price = price } - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(matrix: Price.MatrixPrice) = price(Price.ofMatrix(matrix)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredPackage: Price.TieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedTiered: Price.GroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(unitWithPercent: Price.UnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredWithProration: Price.TieredWithProrationPrice) = - price(Price.ofTieredWithProration(tieredWithProration)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(unitWithProration: Price.UnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedAllocation: Price.GroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bulkWithProration: Price.BulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = - price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice) = - price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - - /** - * The start date of the price interval. This is the date that Orb starts billing for - * this price. - */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** - * The start date of the price interval. This is the date that Orb starts billing for - * this price. - */ - fun startDate(startDate: JsonField) = apply { - this.startDate = startDate - } - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun usageCustomerIds(usageCustomerIds: List?) = - usageCustomerIds(JsonField.ofNullable(usageCustomerIds)) - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun usageCustomerIds(usageCustomerIds: Optional>) = - usageCustomerIds(usageCustomerIds.orElse(null)) - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun usageCustomerIds(usageCustomerIds: JsonField>) = apply { - this.usageCustomerIds = usageCustomerIds.map { it.toMutableList() } - } - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun addUsageCustomerId(usageCustomerId: String) = apply { - usageCustomerIds = - (usageCustomerIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(usageCustomerId) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): PriceInterval = - PriceInterval( - checkRequired("id", id), - checkRequired("billingCycleDay", billingCycleDay), - checkRequired("currentBillingPeriodEndDate", currentBillingPeriodEndDate), - checkRequired("currentBillingPeriodStartDate", currentBillingPeriodStartDate), - checkRequired("endDate", endDate), - checkRequired("filter", filter), - checkRequired("fixedFeeQuantityTransitions", fixedFeeQuantityTransitions).map { - it.toImmutable() - }, - checkRequired("price", price), - checkRequired("startDate", startDate), - checkRequired("usageCustomerIds", usageCustomerIds).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class FixedFeeQuantityTransition - @JsonCreator - private constructor( - @JsonProperty("effective_date") - @ExcludeMissing - private val effectiveDate: JsonField = JsonMissing.of(), - @JsonProperty("price_id") - @ExcludeMissing - private val priceId: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - private val quantity: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun effectiveDate(): OffsetDateTime = effectiveDate.getRequired("effective_date") - - fun priceId(): String = priceId.getRequired("price_id") - - fun quantity(): Long = quantity.getRequired("quantity") - - @JsonProperty("effective_date") - @ExcludeMissing - fun _effectiveDate(): JsonField = effectiveDate - - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - - @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): FixedFeeQuantityTransition = apply { - if (validated) { - return@apply - } - - effectiveDate() - priceId() - quantity() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FixedFeeQuantityTransition]. */ - class Builder internal constructor() { - - private var effectiveDate: JsonField? = null - private var priceId: JsonField? = null - private var quantity: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(fixedFeeQuantityTransition: FixedFeeQuantityTransition) = apply { - effectiveDate = fixedFeeQuantityTransition.effectiveDate - priceId = fixedFeeQuantityTransition.priceId - quantity = fixedFeeQuantityTransition.quantity - additionalProperties = - fixedFeeQuantityTransition.additionalProperties.toMutableMap() - } - - fun effectiveDate(effectiveDate: OffsetDateTime) = - effectiveDate(JsonField.of(effectiveDate)) - - fun effectiveDate(effectiveDate: JsonField) = apply { - this.effectiveDate = effectiveDate - } - - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) - - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - - fun quantity(quantity: Long) = quantity(JsonField.of(quantity)) - - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): FixedFeeQuantityTransition = - FixedFeeQuantityTransition( - checkRequired("effectiveDate", effectiveDate), - checkRequired("priceId", priceId), - checkRequired("quantity", quantity), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FixedFeeQuantityTransition && effectiveDate == other.effectiveDate && priceId == other.priceId && quantity == other.quantity && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(effectiveDate, priceId, quantity, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "FixedFeeQuantityTransition{effectiveDate=$effectiveDate, priceId=$priceId, quantity=$quantity, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PriceInterval && id == other.id && billingCycleDay == other.billingCycleDay && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && endDate == other.endDate && filter == other.filter && fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && price == other.price && startDate == other.startDate && usageCustomerIds == other.usageCustomerIds && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billingCycleDay, currentBillingPeriodEndDate, currentBillingPeriodStartDate, endDate, filter, fixedFeeQuantityTransitions, price, startDate, usageCustomerIds, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PriceInterval{id=$id, billingCycleDay=$billingCycleDay, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, endDate=$endDate, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, price=$price, startDate=$startDate, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class RedeemedCoupon - @JsonCreator - private constructor( - @JsonProperty("coupon_id") - @ExcludeMissing - private val couponId: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun couponId(): String = couponId.getRequired("coupon_id") - - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - @JsonProperty("coupon_id") @ExcludeMissing fun _couponId(): JsonField = couponId - - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): RedeemedCoupon = apply { - if (validated) { - return@apply - } - - couponId() - endDate() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RedeemedCoupon]. */ - class Builder internal constructor() { - - private var couponId: JsonField? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(redeemedCoupon: RedeemedCoupon) = apply { - couponId = redeemedCoupon.couponId - endDate = redeemedCoupon.endDate - startDate = redeemedCoupon.startDate - additionalProperties = redeemedCoupon.additionalProperties.toMutableMap() - } - - fun couponId(couponId: String) = couponId(JsonField.of(couponId)) - - fun couponId(couponId: JsonField) = apply { this.couponId = couponId } - - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - 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) - } - - fun build(): RedeemedCoupon = - RedeemedCoupon( - checkRequired("couponId", couponId), - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RedeemedCoupon && couponId == other.couponId && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(couponId, endDate, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RedeemedCoupon{couponId=$couponId, endDate=$endDate, startDate=$startDate, 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 ENDED = of("ended") - - @JvmField val UPCOMING = of("upcoming") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - ACTIVE, - ENDED, - UPCOMING, - } - - /** - * 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, - ENDED, - UPCOMING, - /** 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 - ENDED -> Value.ENDED - UPCOMING -> Value.UPCOMING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to 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 - ENDED -> Known.ENDED - UPCOMING -> Known.UPCOMING - 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TrialInfo - @JsonCreator - private constructor( - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TrialInfo = apply { - if (validated) { - return@apply - } - - endDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TrialInfo]. */ - class Builder internal constructor() { - - private var endDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(trialInfo: TrialInfo) = apply { - endDate = trialInfo.endDate - additionalProperties = trialInfo.additionalProperties.toMutableMap() - } - - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - 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) - } - - fun build(): TrialInfo = - TrialInfo(checkRequired("endDate", endDate), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TrialInfo && endDate == other.endDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(endDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TrialInfo{endDate=$endDate, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is SubscriptionUpdateFixedFeeQuantityResponse && id == other.id && activePlanPhaseOrder == other.activePlanPhaseOrder && adjustmentIntervals == other.adjustmentIntervals && autoCollection == other.autoCollection && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && billingCycleDay == other.billingCycleDay && createdAt == other.createdAt && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && customer == other.customer && defaultInvoiceMemo == other.defaultInvoiceMemo && discountIntervals == other.discountIntervals && endDate == other.endDate && fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && invoicingThreshold == other.invoicingThreshold && maximumIntervals == other.maximumIntervals && metadata == other.metadata && minimumIntervals == other.minimumIntervals && netTerms == other.netTerms && plan == other.plan && priceIntervals == other.priceIntervals && redeemedCoupon == other.redeemedCoupon && startDate == other.startDate && status == other.status && trialInfo == other.trialInfo && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, activePlanPhaseOrder, adjustmentIntervals, autoCollection, billingCycleAnchorConfiguration, billingCycleDay, createdAt, currentBillingPeriodEndDate, currentBillingPeriodStartDate, customer, defaultInvoiceMemo, discountIntervals, endDate, fixedFeeQuantitySchedule, invoicingThreshold, maximumIntervals, metadata, minimumIntervals, netTerms, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SubscriptionUpdateFixedFeeQuantityResponse{id=$id, activePlanPhaseOrder=$activePlanPhaseOrder, adjustmentIntervals=$adjustmentIntervals, autoCollection=$autoCollection, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, billingCycleDay=$billingCycleDay, createdAt=$createdAt, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, customer=$customer, defaultInvoiceMemo=$defaultInvoiceMemo, discountIntervals=$discountIntervals, endDate=$endDate, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, invoicingThreshold=$invoicingThreshold, maximumIntervals=$maximumIntervals, metadata=$metadata, minimumIntervals=$minimumIntervals, netTerms=$netTerms, plan=$plan, priceIntervals=$priceIntervals, redeemedCoupon=$redeemedCoupon, startDate=$startDate, status=$status, trialInfo=$trialInfo, additionalProperties=$additionalProperties}" -} 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 9c9902d46..b9f8dd696 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 @@ -242,6 +242,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Body]. */ @JvmStatic fun builder() = Builder() } @@ -451,6 +452,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [SubscriptionUpdateParams]. + * + * The following fields are required: + * ```java + * .subscriptionId() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -761,6 +770,7 @@ private constructor( companion object { + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } 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 a87d3882c..db8da9208 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 @@ -164,6 +164,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .trialEndDate() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -270,6 +278,16 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [SubscriptionUpdateTrialParams]. + * + * The following fields are required: + * ```java + * .subscriptionId() + * .trialEndDate() + * ``` + */ @JvmStatic fun builder() = Builder() } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialResponse.kt deleted file mode 100644 index 63cff8c7e..000000000 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialResponse.kt +++ /dev/null @@ -1,7170 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.withorb.api.core.BaseDeserializer -import com.withorb.api.core.BaseSerializer -import com.withorb.api.core.Enum -import com.withorb.api.core.ExcludeMissing -import com.withorb.api.core.JsonField -import com.withorb.api.core.JsonMissing -import com.withorb.api.core.JsonValue -import com.withorb.api.core.NoAutoDetect -import com.withorb.api.core.checkRequired -import com.withorb.api.core.getOrThrow -import com.withorb.api.core.immutableEmptyMap -import com.withorb.api.core.toImmutable -import com.withorb.api.errors.OrbInvalidDataException -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -@NoAutoDetect -class SubscriptionUpdateTrialResponse -@JsonCreator -private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("active_plan_phase_order") - @ExcludeMissing - private val activePlanPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_intervals") - @ExcludeMissing - private val adjustmentIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("auto_collection") - @ExcludeMissing - private val autoCollection: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_anchor_configuration") - @ExcludeMissing - private val billingCycleAnchorConfiguration: JsonField = - JsonMissing.of(), - @JsonProperty("billing_cycle_day") - @ExcludeMissing - private val billingCycleDay: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - private val createdAt: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - private val currentBillingPeriodEndDate: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - private val currentBillingPeriodStartDate: JsonField = JsonMissing.of(), - @JsonProperty("customer") - @ExcludeMissing - private val customer: JsonField = JsonMissing.of(), - @JsonProperty("default_invoice_memo") - @ExcludeMissing - private val defaultInvoiceMemo: JsonField = JsonMissing.of(), - @JsonProperty("discount_intervals") - @ExcludeMissing - private val discountIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("fixed_fee_quantity_schedule") - @ExcludeMissing - private val fixedFeeQuantitySchedule: JsonField> = - JsonMissing.of(), - @JsonProperty("invoicing_threshold") - @ExcludeMissing - private val invoicingThreshold: JsonField = JsonMissing.of(), - @JsonProperty("maximum_intervals") - @ExcludeMissing - private val maximumIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - private val metadata: JsonField = JsonMissing.of(), - @JsonProperty("minimum_intervals") - @ExcludeMissing - private val minimumIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("net_terms") - @ExcludeMissing - private val netTerms: JsonField = JsonMissing.of(), - @JsonProperty("plan") @ExcludeMissing private val plan: JsonField = JsonMissing.of(), - @JsonProperty("price_intervals") - @ExcludeMissing - private val priceIntervals: JsonField> = JsonMissing.of(), - @JsonProperty("redeemed_coupon") - @ExcludeMissing - private val redeemedCoupon: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonProperty("status") - @ExcludeMissing - private val status: JsonField = JsonMissing.of(), - @JsonProperty("trial_info") - @ExcludeMissing - private val trialInfo: JsonField = JsonMissing.of(), - @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), -) { - - fun id(): String = id.getRequired("id") - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(): Optional = - Optional.ofNullable(activePlanPhaseOrder.getNullable("active_plan_phase_order")) - - /** The adjustment intervals for this subscription. */ - fun adjustmentIntervals(): List = - adjustmentIntervals.getRequired("adjustment_intervals") - - /** - * Determines whether issued invoices for this subscription will automatically be charged with - * the saved payment method on the due date. This property defaults to the plan's behavior. If - * null, defaults to the customer's setting. - */ - fun autoCollection(): Optional = - Optional.ofNullable(autoCollection.getNullable("auto_collection")) - - fun billingCycleAnchorConfiguration(): BillingCycleAnchorConfiguration = - billingCycleAnchorConfiguration.getRequired("billing_cycle_anchor_configuration") - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of days in - * a month is greater than this value, the last day of the month is the billing cycle day (e.g. - * billing_cycle_day=31 for April means the billing period begins on the 30th. - */ - fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") - - fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the instant - * returned is not part of the billing period. Set to null for subscriptions that are not - * currently active. - */ - fun currentBillingPeriodEndDate(): Optional = - Optional.ofNullable( - currentBillingPeriodEndDate.getNullable("current_billing_period_end_date") - ) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription is - * not currently active. - */ - fun currentBillingPeriodStartDate(): Optional = - Optional.ofNullable( - currentBillingPeriodStartDate.getNullable("current_billing_period_start_date") - ) - - /** - * 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 customer(): Customer = customer.getRequired("customer") - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(): Optional = - Optional.ofNullable(defaultInvoiceMemo.getNullable("default_invoice_memo")) - - /** The discount intervals for this subscription. */ - fun discountIntervals(): List = - discountIntervals.getRequired("discount_intervals") - - /** The date Orb stops billing for this subscription. */ - fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) - - fun fixedFeeQuantitySchedule(): List = - fixedFeeQuantitySchedule.getRequired("fixed_fee_quantity_schedule") - - fun invoicingThreshold(): Optional = - Optional.ofNullable(invoicingThreshold.getNullable("invoicing_threshold")) - - /** The maximum intervals for this subscription. */ - fun maximumIntervals(): List = - maximumIntervals.getRequired("maximum_intervals") - - /** - * 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.getRequired("metadata") - - /** The minimum intervals for this subscription. */ - fun minimumIntervals(): List = - minimumIntervals.getRequired("minimum_intervals") - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - fun netTerms(): Long = netTerms.getRequired("net_terms") - - /** - * 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 plan(): Plan = plan.getRequired("plan") - - /** The price intervals for this subscription. */ - fun priceIntervals(): List = priceIntervals.getRequired("price_intervals") - - fun redeemedCoupon(): Optional = - Optional.ofNullable(redeemedCoupon.getNullable("redeemed_coupon")) - - /** The date Orb starts billing for this subscription. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - fun status(): Status = status.getRequired("status") - - fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - @JsonProperty("active_plan_phase_order") - @ExcludeMissing - fun _activePlanPhaseOrder(): JsonField = activePlanPhaseOrder - - /** The adjustment intervals for this subscription. */ - @JsonProperty("adjustment_intervals") - @ExcludeMissing - fun _adjustmentIntervals(): JsonField> = adjustmentIntervals - - /** - * Determines whether issued invoices for this subscription will automatically be charged with - * the saved payment method on the due date. This property defaults to the plan's behavior. If - * null, defaults to the customer's setting. - */ - @JsonProperty("auto_collection") - @ExcludeMissing - fun _autoCollection(): JsonField = autoCollection - - @JsonProperty("billing_cycle_anchor_configuration") - @ExcludeMissing - fun _billingCycleAnchorConfiguration(): JsonField = - billingCycleAnchorConfiguration - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of days in - * a month is greater than this value, the last day of the month is the billing cycle day (e.g. - * billing_cycle_day=31 for April means the billing period begins on the 30th. - */ - @JsonProperty("billing_cycle_day") - @ExcludeMissing - fun _billingCycleDay(): JsonField = billingCycleDay - - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the instant - * returned is not part of the billing period. Set to null for subscriptions that are not - * currently active. - */ - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription is - * not currently active. - */ - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - fun _currentBillingPeriodStartDate(): JsonField = currentBillingPeriodStartDate - - /** - * 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. - */ - @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - @JsonProperty("default_invoice_memo") - @ExcludeMissing - fun _defaultInvoiceMemo(): JsonField = defaultInvoiceMemo - - /** The discount intervals for this subscription. */ - @JsonProperty("discount_intervals") - @ExcludeMissing - fun _discountIntervals(): JsonField> = discountIntervals - - /** The date Orb stops billing for this subscription. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate - - @JsonProperty("fixed_fee_quantity_schedule") - @ExcludeMissing - fun _fixedFeeQuantitySchedule(): JsonField> = - fixedFeeQuantitySchedule - - @JsonProperty("invoicing_threshold") - @ExcludeMissing - fun _invoicingThreshold(): JsonField = invoicingThreshold - - /** The maximum intervals for this subscription. */ - @JsonProperty("maximum_intervals") - @ExcludeMissing - fun _maximumIntervals(): JsonField> = maximumIntervals - - /** - * 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - /** The minimum intervals for this subscription. */ - @JsonProperty("minimum_intervals") - @ExcludeMissing - fun _minimumIntervals(): JsonField> = minimumIntervals - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms - - /** - * 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). - */ - @JsonProperty("plan") @ExcludeMissing fun _plan(): JsonField = plan - - /** The price intervals for this subscription. */ - @JsonProperty("price_intervals") - @ExcludeMissing - fun _priceIntervals(): JsonField> = priceIntervals - - @JsonProperty("redeemed_coupon") - @ExcludeMissing - fun _redeemedCoupon(): JsonField = redeemedCoupon - - /** The date Orb starts billing for this subscription. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo(): JsonField = trialInfo - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): SubscriptionUpdateTrialResponse = apply { - if (validated) { - return@apply - } - - id() - activePlanPhaseOrder() - adjustmentIntervals().forEach { it.validate() } - autoCollection() - billingCycleAnchorConfiguration().validate() - billingCycleDay() - createdAt() - currentBillingPeriodEndDate() - currentBillingPeriodStartDate() - customer().validate() - defaultInvoiceMemo() - discountIntervals().forEach { it.validate() } - endDate() - fixedFeeQuantitySchedule().forEach { it.validate() } - invoicingThreshold() - maximumIntervals().forEach { it.validate() } - metadata().validate() - minimumIntervals().forEach { it.validate() } - netTerms() - plan().validate() - priceIntervals().forEach { it.validate() } - redeemedCoupon().ifPresent { it.validate() } - startDate() - status() - trialInfo().validate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SubscriptionUpdateTrialResponse]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var activePlanPhaseOrder: JsonField? = null - private var adjustmentIntervals: JsonField>? = null - private var autoCollection: JsonField? = null - private var billingCycleAnchorConfiguration: JsonField? = - null - private var billingCycleDay: JsonField? = null - private var createdAt: JsonField? = null - private var currentBillingPeriodEndDate: JsonField? = null - private var currentBillingPeriodStartDate: JsonField? = null - private var customer: JsonField? = null - private var defaultInvoiceMemo: JsonField? = null - private var discountIntervals: JsonField>? = null - private var endDate: JsonField? = null - private var fixedFeeQuantitySchedule: JsonField>? = - null - private var invoicingThreshold: JsonField? = null - private var maximumIntervals: JsonField>? = null - private var metadata: JsonField? = null - private var minimumIntervals: JsonField>? = null - private var netTerms: JsonField? = null - private var plan: JsonField? = null - private var priceIntervals: JsonField>? = null - private var redeemedCoupon: JsonField? = null - private var startDate: JsonField? = null - private var status: JsonField? = null - private var trialInfo: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(subscriptionUpdateTrialResponse: SubscriptionUpdateTrialResponse) = - apply { - id = subscriptionUpdateTrialResponse.id - activePlanPhaseOrder = subscriptionUpdateTrialResponse.activePlanPhaseOrder - adjustmentIntervals = - subscriptionUpdateTrialResponse.adjustmentIntervals.map { it.toMutableList() } - autoCollection = subscriptionUpdateTrialResponse.autoCollection - billingCycleAnchorConfiguration = - subscriptionUpdateTrialResponse.billingCycleAnchorConfiguration - billingCycleDay = subscriptionUpdateTrialResponse.billingCycleDay - createdAt = subscriptionUpdateTrialResponse.createdAt - currentBillingPeriodEndDate = - subscriptionUpdateTrialResponse.currentBillingPeriodEndDate - currentBillingPeriodStartDate = - subscriptionUpdateTrialResponse.currentBillingPeriodStartDate - customer = subscriptionUpdateTrialResponse.customer - defaultInvoiceMemo = subscriptionUpdateTrialResponse.defaultInvoiceMemo - discountIntervals = - subscriptionUpdateTrialResponse.discountIntervals.map { it.toMutableList() } - endDate = subscriptionUpdateTrialResponse.endDate - fixedFeeQuantitySchedule = - subscriptionUpdateTrialResponse.fixedFeeQuantitySchedule.map { - it.toMutableList() - } - invoicingThreshold = subscriptionUpdateTrialResponse.invoicingThreshold - maximumIntervals = - subscriptionUpdateTrialResponse.maximumIntervals.map { it.toMutableList() } - metadata = subscriptionUpdateTrialResponse.metadata - minimumIntervals = - subscriptionUpdateTrialResponse.minimumIntervals.map { it.toMutableList() } - netTerms = subscriptionUpdateTrialResponse.netTerms - plan = subscriptionUpdateTrialResponse.plan - priceIntervals = - subscriptionUpdateTrialResponse.priceIntervals.map { it.toMutableList() } - redeemedCoupon = subscriptionUpdateTrialResponse.redeemedCoupon - startDate = subscriptionUpdateTrialResponse.startDate - status = subscriptionUpdateTrialResponse.status - trialInfo = subscriptionUpdateTrialResponse.trialInfo - additionalProperties = - subscriptionUpdateTrialResponse.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(activePlanPhaseOrder: Long?) = - activePlanPhaseOrder(JsonField.ofNullable(activePlanPhaseOrder)) - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(activePlanPhaseOrder: Long) = - activePlanPhaseOrder(activePlanPhaseOrder as Long?) - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun activePlanPhaseOrder(activePlanPhaseOrder: Optional) = - activePlanPhaseOrder(activePlanPhaseOrder.orElse(null) as Long?) - - /** The current plan phase that is active, only if the subscription's plan has phases. */ - fun activePlanPhaseOrder(activePlanPhaseOrder: JsonField) = apply { - this.activePlanPhaseOrder = activePlanPhaseOrder - } - - /** The adjustment intervals for this subscription. */ - fun adjustmentIntervals(adjustmentIntervals: List) = - adjustmentIntervals(JsonField.of(adjustmentIntervals)) - - /** The adjustment intervals for this subscription. */ - fun adjustmentIntervals(adjustmentIntervals: JsonField>) = apply { - this.adjustmentIntervals = adjustmentIntervals.map { it.toMutableList() } - } - - /** The adjustment intervals for this subscription. */ - fun addAdjustmentInterval(adjustmentInterval: AdjustmentInterval) = apply { - adjustmentIntervals = - (adjustmentIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(adjustmentInterval) - } - } - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - fun autoCollection(autoCollection: Boolean?) = - autoCollection(JsonField.ofNullable(autoCollection)) - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun autoCollection(autoCollection: Optional) = - autoCollection(autoCollection.orElse(null) as Boolean?) - - /** - * Determines whether issued invoices for this subscription will automatically be charged - * with the saved payment method on the due date. This property defaults to the plan's - * behavior. If null, defaults to the customer's setting. - */ - fun autoCollection(autoCollection: JsonField) = apply { - this.autoCollection = autoCollection - } - - fun billingCycleAnchorConfiguration( - billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration - ) = billingCycleAnchorConfiguration(JsonField.of(billingCycleAnchorConfiguration)) - - fun billingCycleAnchorConfiguration( - billingCycleAnchorConfiguration: JsonField - ) = apply { this.billingCycleAnchorConfiguration = billingCycleAnchorConfiguration } - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun billingCycleDay(billingCycleDay: Long) = billingCycleDay(JsonField.of(billingCycleDay)) - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun billingCycleDay(billingCycleDay: JsonField) = apply { - this.billingCycleDay = billingCycleDay - } - - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is not part of the billing period. Set to null for subscriptions that - * are not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = - currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is not part of the billing period. Set to null for subscriptions that - * are not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = - currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is not part of the billing period. Set to null for subscriptions that - * are not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: JsonField) = - apply { - this.currentBillingPeriodEndDate = currentBillingPeriodEndDate - } - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription - * is not currently active. - */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = - currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription - * is not currently active. - */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: Optional) = - currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if the subscription - * is not currently active. - */ - fun currentBillingPeriodStartDate( - currentBillingPeriodStartDate: JsonField - ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } - - /** - * 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 customer(customer: Customer) = customer(JsonField.of(customer)) - - /** - * 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 customer(customer: JsonField) = apply { this.customer = customer } - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(defaultInvoiceMemo: String?) = - defaultInvoiceMemo(JsonField.ofNullable(defaultInvoiceMemo)) - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(defaultInvoiceMemo: Optional) = - defaultInvoiceMemo(defaultInvoiceMemo.orElse(null)) - - /** - * Determines the default memo on this subscriptions' invoices. Note that if this is not - * provided, it is determined by the plan configuration. - */ - fun defaultInvoiceMemo(defaultInvoiceMemo: JsonField) = apply { - this.defaultInvoiceMemo = defaultInvoiceMemo - } - - /** The discount intervals for this subscription. */ - fun discountIntervals(discountIntervals: List) = - discountIntervals(JsonField.of(discountIntervals)) - - /** The discount intervals for this subscription. */ - fun discountIntervals(discountIntervals: JsonField>) = apply { - this.discountIntervals = discountIntervals.map { it.toMutableList() } - } - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(discountInterval: DiscountInterval) = apply { - discountIntervals = - (discountIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(discountInterval) - } - } - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(amount: DiscountInterval.AmountDiscountInterval) = - addDiscountInterval(DiscountInterval.ofAmount(amount)) - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(percentage: DiscountInterval.PercentageDiscountInterval) = - addDiscountInterval(DiscountInterval.ofPercentage(percentage)) - - /** The discount intervals for this subscription. */ - fun addDiscountInterval(usage: DiscountInterval.UsageDiscountInterval) = - addDiscountInterval(DiscountInterval.ofUsage(usage)) - - /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - fun fixedFeeQuantitySchedule(fixedFeeQuantitySchedule: List) = - fixedFeeQuantitySchedule(JsonField.of(fixedFeeQuantitySchedule)) - - fun fixedFeeQuantitySchedule( - fixedFeeQuantitySchedule: JsonField> - ) = apply { - this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule.map { it.toMutableList() } - } - - fun addFixedFeeQuantitySchedule(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = - apply { - this.fixedFeeQuantitySchedule = - (this.fixedFeeQuantitySchedule ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(fixedFeeQuantitySchedule) - } - } - - fun invoicingThreshold(invoicingThreshold: String?) = - invoicingThreshold(JsonField.ofNullable(invoicingThreshold)) - - fun invoicingThreshold(invoicingThreshold: Optional) = - invoicingThreshold(invoicingThreshold.orElse(null)) - - fun invoicingThreshold(invoicingThreshold: JsonField) = apply { - this.invoicingThreshold = invoicingThreshold - } - - /** The maximum intervals for this subscription. */ - fun maximumIntervals(maximumIntervals: List) = - maximumIntervals(JsonField.of(maximumIntervals)) - - /** The maximum intervals for this subscription. */ - fun maximumIntervals(maximumIntervals: JsonField>) = apply { - this.maximumIntervals = maximumIntervals.map { it.toMutableList() } - } - - /** The maximum intervals for this subscription. */ - fun addMaximumInterval(maximumInterval: MaximumInterval) = apply { - maximumIntervals = - (maximumIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(maximumInterval) - } - } - - /** - * 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)) - - /** - * 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: JsonField) = apply { this.metadata = metadata } - - /** The minimum intervals for this subscription. */ - fun minimumIntervals(minimumIntervals: List) = - minimumIntervals(JsonField.of(minimumIntervals)) - - /** The minimum intervals for this subscription. */ - fun minimumIntervals(minimumIntervals: JsonField>) = apply { - this.minimumIntervals = minimumIntervals.map { it.toMutableList() } - } - - /** The minimum intervals for this subscription. */ - fun addMinimumInterval(minimumInterval: MinimumInterval) = apply { - minimumIntervals = - (minimumIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(minimumInterval) - } - } - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - fun netTerms(netTerms: Long) = netTerms(JsonField.of(netTerms)) - - /** - * Determines the difference between the invoice issue date for subscription invoices as the - * date that they are due. A value of `0` here represents that the invoice is due on issue, - * whereas a value of `30` represents that the customer has a month to pay the invoice. - */ - fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } - - /** - * 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 plan(plan: Plan) = plan(JsonField.of(plan)) - - /** - * 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 plan(plan: JsonField) = apply { this.plan = plan } - - /** The price intervals for this subscription. */ - fun priceIntervals(priceIntervals: List) = - priceIntervals(JsonField.of(priceIntervals)) - - /** The price intervals for this subscription. */ - fun priceIntervals(priceIntervals: JsonField>) = apply { - this.priceIntervals = priceIntervals.map { it.toMutableList() } - } - - /** The price intervals for this subscription. */ - fun addPriceInterval(priceInterval: PriceInterval) = apply { - priceIntervals = - (priceIntervals ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(priceInterval) - } - } - - fun redeemedCoupon(redeemedCoupon: RedeemedCoupon?) = - redeemedCoupon(JsonField.ofNullable(redeemedCoupon)) - - fun redeemedCoupon(redeemedCoupon: Optional) = - redeemedCoupon(redeemedCoupon.orElse(null)) - - fun redeemedCoupon(redeemedCoupon: JsonField) = apply { - this.redeemedCoupon = redeemedCoupon - } - - /** The date Orb starts billing for this subscription. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The date Orb starts billing for this subscription. */ - fun startDate(startDate: JsonField) = apply { this.startDate = startDate } - - fun status(status: Status) = status(JsonField.of(status)) - - fun status(status: JsonField) = apply { this.status = status } - - fun trialInfo(trialInfo: TrialInfo) = trialInfo(JsonField.of(trialInfo)) - - fun trialInfo(trialInfo: JsonField) = apply { this.trialInfo = trialInfo } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): SubscriptionUpdateTrialResponse = - SubscriptionUpdateTrialResponse( - checkRequired("id", id), - checkRequired("activePlanPhaseOrder", activePlanPhaseOrder), - checkRequired("adjustmentIntervals", adjustmentIntervals).map { it.toImmutable() }, - checkRequired("autoCollection", autoCollection), - checkRequired("billingCycleAnchorConfiguration", billingCycleAnchorConfiguration), - checkRequired("billingCycleDay", billingCycleDay), - checkRequired("createdAt", createdAt), - checkRequired("currentBillingPeriodEndDate", currentBillingPeriodEndDate), - checkRequired("currentBillingPeriodStartDate", currentBillingPeriodStartDate), - checkRequired("customer", customer), - checkRequired("defaultInvoiceMemo", defaultInvoiceMemo), - checkRequired("discountIntervals", discountIntervals).map { it.toImmutable() }, - checkRequired("endDate", endDate), - checkRequired("fixedFeeQuantitySchedule", fixedFeeQuantitySchedule).map { - it.toImmutable() - }, - checkRequired("invoicingThreshold", invoicingThreshold), - checkRequired("maximumIntervals", maximumIntervals).map { it.toImmutable() }, - checkRequired("metadata", metadata), - checkRequired("minimumIntervals", minimumIntervals).map { it.toImmutable() }, - checkRequired("netTerms", netTerms), - checkRequired("plan", plan), - checkRequired("priceIntervals", priceIntervals).map { it.toImmutable() }, - checkRequired("redeemedCoupon", redeemedCoupon), - checkRequired("startDate", startDate), - checkRequired("status", status), - checkRequired("trialInfo", trialInfo), - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class AdjustmentInterval - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment") - @ExcludeMissing - private val adjustment: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustment(): Adjustment = adjustment.getRequired("adjustment") - - /** The price interval IDs that this adjustment applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - /** The end date of the adjustment interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** The start date of the adjustment interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment") - @ExcludeMissing - fun _adjustment(): JsonField = adjustment - - /** The price interval IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - /** The end date of the adjustment interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** The start date of the adjustment interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AdjustmentInterval = apply { - if (validated) { - return@apply - } - - id() - adjustment().validate() - appliesToPriceIntervalIds() - endDate() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AdjustmentInterval]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustment: JsonField? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(adjustmentInterval: AdjustmentInterval) = apply { - id = adjustmentInterval.id - adjustment = adjustmentInterval.adjustment - appliesToPriceIntervalIds = - adjustmentInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - endDate = adjustmentInterval.endDate - startDate = adjustmentInterval.startDate - additionalProperties = adjustmentInterval.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) - - fun adjustment(adjustment: JsonField) = apply { - this.adjustment = adjustment - } - - fun adjustment(planPhaseUsageDiscount: Adjustment.PlanPhaseUsageDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)) - - fun adjustment(planPhaseAmountDiscount: Adjustment.PlanPhaseAmountDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)) - - fun adjustment( - planPhasePercentageDiscount: Adjustment.PlanPhasePercentageDiscountAdjustment - ) = adjustment(Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)) - - fun adjustment(planPhaseMinimum: Adjustment.PlanPhaseMinimumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)) - - fun adjustment(planPhaseMaximum: Adjustment.PlanPhaseMaximumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)) - - /** The price interval IDs that this adjustment applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval IDs that this adjustment applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval IDs that this adjustment applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - /** The end date of the adjustment interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the adjustment interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the adjustment interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** The start date of the adjustment interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the adjustment interval. */ - 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) - } - - fun build(): AdjustmentInterval = - AdjustmentInterval( - checkRequired("id", id), - checkRequired("adjustment", adjustment), - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(using = Adjustment.Deserializer::class) - @JsonSerialize(using = Adjustment.Serializer::class) - class Adjustment - private constructor( - private val planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment? = null, - private val planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment? = null, - private val planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment? = null, - private val planPhaseMinimum: PlanPhaseMinimumAdjustment? = null, - private val planPhaseMaximum: PlanPhaseMaximumAdjustment? = null, - private val _json: JsonValue? = null, - ) { - - fun planPhaseUsageDiscount(): Optional = - Optional.ofNullable(planPhaseUsageDiscount) - - fun planPhaseAmountDiscount(): Optional = - Optional.ofNullable(planPhaseAmountDiscount) - - fun planPhasePercentageDiscount(): Optional = - Optional.ofNullable(planPhasePercentageDiscount) - - fun planPhaseMinimum(): Optional = - Optional.ofNullable(planPhaseMinimum) - - fun planPhaseMaximum(): Optional = - Optional.ofNullable(planPhaseMaximum) - - fun isPlanPhaseUsageDiscount(): Boolean = planPhaseUsageDiscount != null - - fun isPlanPhaseAmountDiscount(): Boolean = planPhaseAmountDiscount != null - - fun isPlanPhasePercentageDiscount(): Boolean = planPhasePercentageDiscount != null - - fun isPlanPhaseMinimum(): Boolean = planPhaseMinimum != null - - fun isPlanPhaseMaximum(): Boolean = planPhaseMaximum != null - - fun asPlanPhaseUsageDiscount(): PlanPhaseUsageDiscountAdjustment = - planPhaseUsageDiscount.getOrThrow("planPhaseUsageDiscount") - - fun asPlanPhaseAmountDiscount(): PlanPhaseAmountDiscountAdjustment = - planPhaseAmountDiscount.getOrThrow("planPhaseAmountDiscount") - - fun asPlanPhasePercentageDiscount(): PlanPhasePercentageDiscountAdjustment = - planPhasePercentageDiscount.getOrThrow("planPhasePercentageDiscount") - - fun asPlanPhaseMinimum(): PlanPhaseMinimumAdjustment = - planPhaseMinimum.getOrThrow("planPhaseMinimum") - - fun asPlanPhaseMaximum(): PlanPhaseMaximumAdjustment = - planPhaseMaximum.getOrThrow("planPhaseMaximum") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - planPhaseUsageDiscount != null -> - visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) - planPhaseAmountDiscount != null -> - visitor.visitPlanPhaseAmountDiscount(planPhaseAmountDiscount) - planPhasePercentageDiscount != null -> - visitor.visitPlanPhasePercentageDiscount(planPhasePercentageDiscount) - planPhaseMinimum != null -> visitor.visitPlanPhaseMinimum(planPhaseMinimum) - planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): Adjustment = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) { - planPhaseUsageDiscount.validate() - } - - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) { - planPhaseAmountDiscount.validate() - } - - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) { - planPhasePercentageDiscount.validate() - } - - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) { - planPhaseMinimum.validate() - } - - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) { - planPhaseMaximum.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Adjustment && planPhaseUsageDiscount == other.planPhaseUsageDiscount && planPhaseAmountDiscount == other.planPhaseAmountDiscount && planPhasePercentageDiscount == other.planPhasePercentageDiscount && planPhaseMinimum == other.planPhaseMinimum && planPhaseMaximum == other.planPhaseMaximum /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(planPhaseUsageDiscount, planPhaseAmountDiscount, planPhasePercentageDiscount, planPhaseMinimum, planPhaseMaximum) /* spotless:on */ - - override fun toString(): String = - when { - planPhaseUsageDiscount != null -> - "Adjustment{planPhaseUsageDiscount=$planPhaseUsageDiscount}" - planPhaseAmountDiscount != null -> - "Adjustment{planPhaseAmountDiscount=$planPhaseAmountDiscount}" - planPhasePercentageDiscount != null -> - "Adjustment{planPhasePercentageDiscount=$planPhasePercentageDiscount}" - planPhaseMinimum != null -> "Adjustment{planPhaseMinimum=$planPhaseMinimum}" - planPhaseMaximum != null -> "Adjustment{planPhaseMaximum=$planPhaseMaximum}" - _json != null -> "Adjustment{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Adjustment") - } - - companion object { - - @JvmStatic - fun ofPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = Adjustment(planPhaseUsageDiscount = planPhaseUsageDiscount) - - @JvmStatic - fun ofPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = Adjustment(planPhaseAmountDiscount = planPhaseAmountDiscount) - - @JvmStatic - fun ofPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = Adjustment(planPhasePercentageDiscount = planPhasePercentageDiscount) - - @JvmStatic - fun ofPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment) = - Adjustment(planPhaseMinimum = planPhaseMinimum) - - @JvmStatic - fun ofPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment) = - Adjustment(planPhaseMaximum = planPhaseMaximum) - } - - /** - * An interface that defines how to map each variant of [Adjustment] to a value of type - * [T]. - */ - interface Visitor { - - fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ): T - - fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ): T - - fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ): T - - fun visitPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment): T - - fun visitPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment): T - - /** - * Maps an unknown variant of [Adjustment] to a value of type [T]. - * - * An instance of [Adjustment] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown Adjustment: $json") - } - } - - internal class Deserializer : BaseDeserializer(Adjustment::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Adjustment { - val json = JsonValue.fromJsonNode(node) - val adjustmentType = - json.asObject().getOrNull()?.get("adjustment_type")?.asString()?.getOrNull() - - when (adjustmentType) { - "usage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseUsageDiscount = it, _json = json) - } - } - "amount_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment(planPhaseAmountDiscount = it, _json = json) - } - } - "percentage_discount" -> { - tryDeserialize( - node, - jacksonTypeRef(), - ) { - it.validate() - } - ?.let { - return Adjustment( - planPhasePercentageDiscount = it, - _json = json, - ) - } - } - "minimum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMinimum = it, _json = json) - } - } - "maximum" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return Adjustment(planPhaseMaximum = it, _json = json) - } - } - } - - return Adjustment(_json = json) - } - } - - internal class Serializer : BaseSerializer(Adjustment::class) { - - override fun serialize( - value: Adjustment, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.planPhaseUsageDiscount != null -> - generator.writeObject(value.planPhaseUsageDiscount) - value.planPhaseAmountDiscount != null -> - generator.writeObject(value.planPhaseAmountDiscount) - value.planPhasePercentageDiscount != null -> - generator.writeObject(value.planPhasePercentageDiscount) - value.planPhaseMinimum != null -> - generator.writeObject(value.planPhaseMinimum) - value.planPhaseMaximum != null -> - generator.writeObject(value.planPhaseMaximum) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Adjustment") - } - } - } - - @NoAutoDetect - class PlanPhaseUsageDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonProperty("usage_discount") - @ExcludeMissing - private val usageDiscount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - /** - * The number of usage units by which to discount the price this adjustment applies - * to in a given billing period. - */ - fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - /** - * The number of usage units by which to discount the price this adjustment applies - * to in a given billing period. - */ - @JsonProperty("usage_discount") - @ExcludeMissing - fun _usageDiscount(): JsonField = usageDiscount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseUsageDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - planPhaseOrder() - reason() - usageDiscount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseUsageDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var usageDiscount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - planPhaseUsageDiscountAdjustment: PlanPhaseUsageDiscountAdjustment - ) = apply { - id = planPhaseUsageDiscountAdjustment.id - adjustmentType = planPhaseUsageDiscountAdjustment.adjustmentType - appliesToPriceIds = - planPhaseUsageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseUsageDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseUsageDiscountAdjustment.planPhaseOrder - reason = planPhaseUsageDiscountAdjustment.reason - usageDiscount = planPhaseUsageDiscountAdjustment.usageDiscount - additionalProperties = - planPhaseUsageDiscountAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - /** - * The number of usage units by which to discount the price this adjustment - * applies to in a given billing period. - */ - fun usageDiscount(usageDiscount: Double) = - usageDiscount(JsonField.of(usageDiscount)) - - /** - * The number of usage units by which to discount the price this adjustment - * applies to in a given billing period. - */ - fun usageDiscount(usageDiscount: JsonField) = apply { - this.usageDiscount = usageDiscount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseUsageDiscountAdjustment = - PlanPhaseUsageDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - checkRequired("usageDiscount", usageDiscount), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - USAGE_DISCOUNT -> Known.USAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseUsageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, planPhaseOrder, reason, usageDiscount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseUsageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhaseAmountDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("amount_discount") - @ExcludeMissing - private val amountDiscount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** - * The amount by which to discount the prices this adjustment applies to in a given - * billing period. - */ - fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** - * The amount by which to discount the prices this adjustment applies to in a given - * billing period. - */ - @JsonProperty("amount_discount") - @ExcludeMissing - fun _amountDiscount(): JsonField = amountDiscount - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseAmountDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - amountDiscount() - appliesToPriceIds() - isInvoiceLevel() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseAmountDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var amountDiscount: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - planPhaseAmountDiscountAdjustment: PlanPhaseAmountDiscountAdjustment - ) = apply { - id = planPhaseAmountDiscountAdjustment.id - adjustmentType = planPhaseAmountDiscountAdjustment.adjustmentType - amountDiscount = planPhaseAmountDiscountAdjustment.amountDiscount - appliesToPriceIds = - planPhaseAmountDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseAmountDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseAmountDiscountAdjustment.planPhaseOrder - reason = planPhaseAmountDiscountAdjustment.reason - additionalProperties = - planPhaseAmountDiscountAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** - * The amount by which to discount the prices this adjustment applies to in a - * given billing period. - */ - fun amountDiscount(amountDiscount: String) = - amountDiscount(JsonField.of(amountDiscount)) - - /** - * The amount by which to discount the prices this adjustment applies to in a - * given billing period. - */ - fun amountDiscount(amountDiscount: JsonField) = apply { - this.amountDiscount = amountDiscount - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseAmountDiscountAdjustment = - PlanPhaseAmountDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("amountDiscount", amountDiscount), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseAmountDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, amountDiscount, appliesToPriceIds, isInvoiceLevel, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseAmountDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhasePercentageDiscountAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("percentage_discount") - @ExcludeMissing - private val percentageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(): Double = - percentageDiscount.getRequired("percentage_discount") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - @JsonProperty("percentage_discount") - @ExcludeMissing - fun _percentageDiscount(): JsonField = percentageDiscount - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhasePercentageDiscountAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - percentageDiscount() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhasePercentageDiscountAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var percentageDiscount: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - planPhasePercentageDiscountAdjustment: PlanPhasePercentageDiscountAdjustment - ) = apply { - id = planPhasePercentageDiscountAdjustment.id - adjustmentType = planPhasePercentageDiscountAdjustment.adjustmentType - appliesToPriceIds = - planPhasePercentageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhasePercentageDiscountAdjustment.isInvoiceLevel - percentageDiscount = - planPhasePercentageDiscountAdjustment.percentageDiscount - planPhaseOrder = planPhasePercentageDiscountAdjustment.planPhaseOrder - reason = planPhasePercentageDiscountAdjustment.reason - additionalProperties = - planPhasePercentageDiscountAdjustment.additionalProperties - .toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(percentageDiscount: Double) = - percentageDiscount(JsonField.of(percentageDiscount)) - - /** - * The percentage (as a value between 0 and 1) by which to discount the price - * intervals this adjustment applies to in a given billing period. - */ - fun percentageDiscount(percentageDiscount: JsonField) = apply { - this.percentageDiscount = percentageDiscount - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhasePercentageDiscountAdjustment = - PlanPhasePercentageDiscountAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("percentageDiscount", percentageDiscount), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val PERCENTAGE_DISCOUNT = of("percentage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhasePercentageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, percentageDiscount, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhasePercentageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhaseMinimumAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("item_id") - @ExcludeMissing - private val itemId: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(): String = itemId.getRequired("item_id") - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** The item ID that revenue from this minimum will be attributed to. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseMinimumAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - itemId() - minimumAmount() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseMinimumAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var itemId: JsonField? = null - private var minimumAmount: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(planPhaseMinimumAdjustment: PlanPhaseMinimumAdjustment) = - apply { - id = planPhaseMinimumAdjustment.id - adjustmentType = planPhaseMinimumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMinimumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMinimumAdjustment.isInvoiceLevel - itemId = planPhaseMinimumAdjustment.itemId - minimumAmount = planPhaseMinimumAdjustment.minimumAmount - planPhaseOrder = planPhaseMinimumAdjustment.planPhaseOrder - reason = planPhaseMinimumAdjustment.reason - additionalProperties = - planPhaseMinimumAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(minimumAmount: String) = - minimumAmount(JsonField.of(minimumAmount)) - - /** - * The minimum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseMinimumAdjustment = - PlanPhaseMinimumAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("itemId", itemId), - checkRequired("minimumAmount", minimumAmount), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseMinimumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, itemId, minimumAmount, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseMinimumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PlanPhaseMaximumAdjustment - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("adjustment_type") - @ExcludeMissing - private val adjustmentType: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("is_invoice_level") - @ExcludeMissing - private val isInvoiceLevel: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("plan_phase_order") - @ExcludeMissing - private val planPhaseOrder: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - private val reason: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - fun isInvoiceLevel(): Boolean = isInvoiceLevel.getRequired("is_invoice_level") - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(): Optional = - Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) - - /** The reason for the adjustment. */ - fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** The price IDs that this adjustment applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** - * True for adjustments that apply to an entire invocice, false for adjustments that - * apply to only one price. - */ - @JsonProperty("is_invoice_level") - @ExcludeMissing - fun _isInvoiceLevel(): JsonField = isInvoiceLevel - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") - @ExcludeMissing - fun _planPhaseOrder(): JsonField = planPhaseOrder - - /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PlanPhaseMaximumAdjustment = apply { - if (validated) { - return@apply - } - - id() - adjustmentType() - appliesToPriceIds() - isInvoiceLevel() - maximumAmount() - planPhaseOrder() - reason() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PlanPhaseMaximumAdjustment]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var adjustmentType: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var isInvoiceLevel: JsonField? = null - private var maximumAmount: JsonField? = null - private var planPhaseOrder: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(planPhaseMaximumAdjustment: PlanPhaseMaximumAdjustment) = - apply { - id = planPhaseMaximumAdjustment.id - adjustmentType = planPhaseMaximumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMaximumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMaximumAdjustment.isInvoiceLevel - maximumAmount = planPhaseMaximumAdjustment.maximumAmount - planPhaseOrder = planPhaseMaximumAdjustment.planPhaseOrder - reason = planPhaseMaximumAdjustment.reason - additionalProperties = - planPhaseMaximumAdjustment.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - - fun adjustmentType(adjustmentType: JsonField) = apply { - this.adjustmentType = adjustmentType - } - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price IDs that this adjustment applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price IDs that this adjustment applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(JsonField.of(isInvoiceLevel)) - - /** - * True for adjustments that apply to an entire invocice, false for adjustments - * that apply to only one price. - */ - fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { - this.isInvoiceLevel = isInvoiceLevel - } - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) - - /** - * The maximum amount to charge in a given billing period for the prices this - * adjustment applies to. - */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long?) = - planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(planPhaseOrder as Long?) - - /** The plan phase in which this adjustment is active. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun planPhaseOrder(planPhaseOrder: Optional) = - planPhaseOrder(planPhaseOrder.orElse(null) as Long?) - - /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: JsonField) = apply { - this.planPhaseOrder = planPhaseOrder - } - - /** The reason for the adjustment. */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** The reason for the adjustment. */ - fun reason(reason: Optional) = reason(reason.orElse(null)) - - /** The reason for the adjustment. */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): PlanPhaseMaximumAdjustment = - PlanPhaseMaximumAdjustment( - checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("isInvoiceLevel", isInvoiceLevel), - checkRequired("maximumAmount", maximumAmount), - checkRequired("planPhaseOrder", planPhaseOrder), - checkRequired("reason", reason), - additionalProperties.toImmutable(), - ) - } - - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PlanPhaseMaximumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, appliesToPriceIds, isInvoiceLevel, maximumAmount, planPhaseOrder, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PlanPhaseMaximumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentInterval && id == other.id && adjustment == other.adjustment && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustment, appliesToPriceIntervalIds, endDate, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AdjustmentInterval{id=$id, adjustment=$adjustment, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class BillingCycleAnchorConfiguration - @JsonCreator - private constructor( - @JsonProperty("day") @ExcludeMissing private val day: JsonField = JsonMissing.of(), - @JsonProperty("month") - @ExcludeMissing - private val month: JsonField = JsonMissing.of(), - @JsonProperty("year") @ExcludeMissing private val year: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun day(): Long = day.getRequired("day") - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(): Optional = Optional.ofNullable(month.getNullable("month")) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on - * 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(): Optional = Optional.ofNullable(year.getNullable("year")) - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - @JsonProperty("day") @ExcludeMissing fun _day(): JsonField = day - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - @JsonProperty("month") @ExcludeMissing fun _month(): JsonField = month - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on - * 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - @JsonProperty("year") @ExcludeMissing fun _year(): JsonField = year - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillingCycleAnchorConfiguration = apply { - if (validated) { - return@apply - } - - day() - month() - year() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleAnchorConfiguration]. */ - class Builder internal constructor() { - - private var day: JsonField? = null - private var month: JsonField = JsonMissing.of() - private var year: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration) = - apply { - day = billingCycleAnchorConfiguration.day - month = billingCycleAnchorConfiguration.month - year = billingCycleAnchorConfiguration.year - additionalProperties = - billingCycleAnchorConfiguration.additionalProperties.toMutableMap() - } - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun day(day: Long) = day(JsonField.of(day)) - - /** - * The day of the month on which the billing cycle is anchored. If the maximum number of - * days in a month is greater than this value, the last day of the month is the billing - * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the - * 30th. - */ - fun day(day: JsonField) = apply { this.day = day } - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(month: Long?) = month(JsonField.ofNullable(month)) - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(month: Long) = month(month as Long?) - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun month(month: Optional) = month(month.orElse(null) as Long?) - - /** - * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in - * February would have cycles starting February, May, August, and November). - */ - fun month(month: JsonField) = apply { this.month = month } - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(year: Long?) = year(JsonField.ofNullable(year)) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(year: Long) = year(year as Long?) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun year(year: Optional) = year(year.orElse(null) as Long?) - - /** - * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored - * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). - */ - fun year(year: JsonField) = apply { this.year = year } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): BillingCycleAnchorConfiguration = - BillingCycleAnchorConfiguration( - checkRequired("day", day), - month, - year, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillingCycleAnchorConfiguration && day == other.day && month == other.month && year == other.year && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(day, month, year, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillingCycleAnchorConfiguration{day=$day, month=$month, year=$year, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(using = DiscountInterval.Deserializer::class) - @JsonSerialize(using = DiscountInterval.Serializer::class) - class DiscountInterval - private constructor( - private val amount: AmountDiscountInterval? = null, - private val percentage: PercentageDiscountInterval? = null, - private val usage: UsageDiscountInterval? = null, - private val _json: JsonValue? = null, - ) { - - fun amount(): Optional = Optional.ofNullable(amount) - - fun percentage(): Optional = Optional.ofNullable(percentage) - - fun usage(): Optional = Optional.ofNullable(usage) - - fun isAmount(): Boolean = amount != null - - fun isPercentage(): Boolean = percentage != null - - fun isUsage(): Boolean = usage != null - - fun asAmount(): AmountDiscountInterval = amount.getOrThrow("amount") - - fun asPercentage(): PercentageDiscountInterval = percentage.getOrThrow("percentage") - - fun asUsage(): UsageDiscountInterval = usage.getOrThrow("usage") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - amount != null -> visitor.visitAmount(amount) - percentage != null -> visitor.visitPercentage(percentage) - usage != null -> visitor.visitUsage(usage) - else -> visitor.unknown(_json) - } - } - - private var validated: Boolean = false - - fun validate(): DiscountInterval = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitAmount(amount: AmountDiscountInterval) { - amount.validate() - } - - override fun visitPercentage(percentage: PercentageDiscountInterval) { - percentage.validate() - } - - override fun visitUsage(usage: UsageDiscountInterval) { - usage.validate() - } - } - ) - validated = true - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountInterval && amount == other.amount && percentage == other.percentage && usage == other.usage /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(amount, percentage, usage) /* spotless:on */ - - override fun toString(): String = - when { - amount != null -> "DiscountInterval{amount=$amount}" - percentage != null -> "DiscountInterval{percentage=$percentage}" - usage != null -> "DiscountInterval{usage=$usage}" - _json != null -> "DiscountInterval{_unknown=$_json}" - else -> throw IllegalStateException("Invalid DiscountInterval") - } - - companion object { - - @JvmStatic - fun ofAmount(amount: AmountDiscountInterval) = DiscountInterval(amount = amount) - - @JvmStatic - fun ofPercentage(percentage: PercentageDiscountInterval) = - DiscountInterval(percentage = percentage) - - @JvmStatic fun ofUsage(usage: UsageDiscountInterval) = DiscountInterval(usage = usage) - } - - /** - * An interface that defines how to map each variant of [DiscountInterval] to a value of - * type [T]. - */ - interface Visitor { - - fun visitAmount(amount: AmountDiscountInterval): T - - fun visitPercentage(percentage: PercentageDiscountInterval): T - - fun visitUsage(usage: UsageDiscountInterval): T - - /** - * Maps an unknown variant of [DiscountInterval] to a value of type [T]. - * - * An instance of [DiscountInterval] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK - * is on an older version than the API, then the API may respond with new variants that - * the SDK is unaware of. - * - * @throws OrbInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw OrbInvalidDataException("Unknown DiscountInterval: $json") - } - } - - internal class Deserializer : BaseDeserializer(DiscountInterval::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): DiscountInterval { - val json = JsonValue.fromJsonNode(node) - val discountType = - json.asObject().getOrNull()?.get("discount_type")?.asString()?.getOrNull() - - when (discountType) { - "amount" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(amount = it, _json = json) - } - } - "percentage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(percentage = it, _json = json) - } - } - "usage" -> { - tryDeserialize(node, jacksonTypeRef()) { - it.validate() - } - ?.let { - return DiscountInterval(usage = it, _json = json) - } - } - } - - return DiscountInterval(_json = json) - } - } - - internal class Serializer : BaseSerializer(DiscountInterval::class) { - - override fun serialize( - value: DiscountInterval, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.amount != null -> generator.writeObject(value.amount) - value.percentage != null -> generator.writeObject(value.percentage) - value.usage != null -> generator.writeObject(value.usage) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid DiscountInterval") - } - } - } - - @NoAutoDetect - class AmountDiscountInterval - @JsonCreator - private constructor( - @JsonProperty("amount_discount") - @ExcludeMissing - private val amountDiscount: JsonField = JsonMissing.of(), - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("discount_type") - @ExcludeMissing - private val discountType: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - fun discountType(): DiscountType = discountType.getRequired("discount_type") - - /** The end date of the discount interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** The start date of the discount interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** Only available if discount_type is `amount`. */ - @JsonProperty("amount_discount") - @ExcludeMissing - fun _amountDiscount(): JsonField = amountDiscount - - /** The price ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - - /** The end date of the discount interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** The start date of the discount interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): AmountDiscountInterval = apply { - if (validated) { - return@apply - } - - amountDiscount() - appliesToPriceIds() - appliesToPriceIntervalIds() - discountType() - endDate() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AmountDiscountInterval]. */ - class Builder internal constructor() { - - private var amountDiscount: JsonField? = null - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { - amountDiscount = amountDiscountInterval.amountDiscount - appliesToPriceIds = - amountDiscountInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - amountDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = amountDiscountInterval.discountType - endDate = amountDiscountInterval.endDate - startDate = amountDiscountInterval.startDate - additionalProperties = - amountDiscountInterval.additionalProperties.toMutableMap() - } - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(amountDiscount: String) = - amountDiscount(JsonField.of(amountDiscount)) - - /** Only available if discount_type is `amount`. */ - fun amountDiscount(amountDiscount: JsonField) = apply { - this.amountDiscount = amountDiscount - } - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this discount interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this discount interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the discount interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the discount interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** The start date of the discount interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the discount interval. */ - 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) - } - - fun build(): AmountDiscountInterval = - AmountDiscountInterval( - checkRequired("amountDiscount", amountDiscount), - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("discountType", discountType), - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val AMOUNT = of("amount") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - AMOUNT - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT -> Value.AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AMOUNT -> Known.AMOUNT - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AmountDiscountInterval && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amountDiscount, appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AmountDiscountInterval{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class PercentageDiscountInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("discount_type") - @ExcludeMissing - private val discountType: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("percentage_discount") - @ExcludeMissing - private val percentageDiscount: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - fun discountType(): DiscountType = discountType.getRequired("discount_type") - - /** The end date of the discount interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ - fun percentageDiscount(): Double = percentageDiscount.getRequired("percentage_discount") - - /** The start date of the discount interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** The price ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - - /** The end date of the discount interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ - @JsonProperty("percentage_discount") - @ExcludeMissing - fun _percentageDiscount(): JsonField = percentageDiscount - - /** The start date of the discount interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PercentageDiscountInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - discountType() - endDate() - percentageDiscount() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PercentageDiscountInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null - private var endDate: JsonField? = null - private var percentageDiscount: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { - appliesToPriceIds = - percentageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - percentageDiscountInterval.appliesToPriceIntervalIds.map { - it.toMutableList() - } - discountType = percentageDiscountInterval.discountType - endDate = percentageDiscountInterval.endDate - percentageDiscount = percentageDiscountInterval.percentageDiscount - startDate = percentageDiscountInterval.startDate - additionalProperties = - percentageDiscountInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this discount interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this discount interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the discount interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the discount interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** - * Only available if discount_type is `percentage`.This is a number between 0 and 1. - */ - fun percentageDiscount(percentageDiscount: Double) = - percentageDiscount(JsonField.of(percentageDiscount)) - - /** - * Only available if discount_type is `percentage`.This is a number between 0 and 1. - */ - fun percentageDiscount(percentageDiscount: JsonField) = apply { - this.percentageDiscount = percentageDiscount - } - - /** The start date of the discount interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the discount interval. */ - 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) - } - - fun build(): PercentageDiscountInterval = - PercentageDiscountInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("discountType", discountType), - checkRequired("endDate", endDate), - checkRequired("percentageDiscount", percentageDiscount), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val PERCENTAGE = of("percentage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - PERCENTAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE -> Value.PERCENTAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PERCENTAGE -> Known.PERCENTAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PercentageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, percentageDiscount, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PercentageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class UsageDiscountInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("discount_type") - @ExcludeMissing - private val discountType: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonProperty("usage_discount") - @ExcludeMissing - private val usageDiscount: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - fun discountType(): DiscountType = discountType.getRequired("discount_type") - - /** The end date of the discount interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** The start date of the discount interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** - * Only available if discount_type is `usage`. Number of usage units that this discount - * is for - */ - fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - - /** The price ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this discount interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - - /** The end date of the discount interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** The start date of the discount interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - /** - * Only available if discount_type is `usage`. Number of usage units that this discount - * is for - */ - @JsonProperty("usage_discount") - @ExcludeMissing - fun _usageDiscount(): JsonField = usageDiscount - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): UsageDiscountInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - discountType() - endDate() - startDate() - usageDiscount() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UsageDiscountInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var usageDiscount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { - appliesToPriceIds = - usageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - usageDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = usageDiscountInterval.discountType - endDate = usageDiscountInterval.endDate - startDate = usageDiscountInterval.startDate - usageDiscount = usageDiscountInterval.usageDiscount - additionalProperties = usageDiscountInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this discount interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this discount interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this discount interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this discount interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the discount interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the discount interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** The start date of the discount interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the discount interval. */ - fun startDate(startDate: JsonField) = apply { - this.startDate = startDate - } - - /** - * Only available if discount_type is `usage`. Number of usage units that this - * discount is for - */ - fun usageDiscount(usageDiscount: Double) = - usageDiscount(JsonField.of(usageDiscount)) - - /** - * Only available if discount_type is `usage`. Number of usage units that this - * discount is for - */ - fun usageDiscount(usageDiscount: JsonField) = apply { - this.usageDiscount = usageDiscount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): UsageDiscountInterval = - UsageDiscountInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { - it.toImmutable() - }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("discountType", discountType), - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - checkRequired("usageDiscount", usageDiscount), - additionalProperties.toImmutable(), - ) - } - - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val USAGE = of("usage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - USAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE -> Value.USAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE -> Known.USAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UsageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, startDate, usageDiscount, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UsageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" - } - } - - @NoAutoDetect - class FixedFeeQuantitySchedule - @JsonCreator - private constructor( - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("price_id") - @ExcludeMissing - private val priceId: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - private val quantity: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - fun priceId(): String = priceId.getRequired("price_id") - - fun quantity(): Double = quantity.getRequired("quantity") - - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - - @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): FixedFeeQuantitySchedule = apply { - if (validated) { - return@apply - } - - endDate() - priceId() - quantity() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FixedFeeQuantitySchedule]. */ - class Builder internal constructor() { - - private var endDate: JsonField? = null - private var priceId: JsonField? = null - private var quantity: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = apply { - endDate = fixedFeeQuantitySchedule.endDate - priceId = fixedFeeQuantitySchedule.priceId - quantity = fixedFeeQuantitySchedule.quantity - startDate = fixedFeeQuantitySchedule.startDate - additionalProperties = fixedFeeQuantitySchedule.additionalProperties.toMutableMap() - } - - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) - - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - 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) - } - - fun build(): FixedFeeQuantitySchedule = - FixedFeeQuantitySchedule( - checkRequired("endDate", endDate), - checkRequired("priceId", priceId), - checkRequired("quantity", quantity), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FixedFeeQuantitySchedule && endDate == other.endDate && priceId == other.priceId && quantity == other.quantity && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(endDate, priceId, quantity, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "FixedFeeQuantitySchedule{endDate=$endDate, priceId=$priceId, quantity=$quantity, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class MaximumInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("maximum_amount") - @ExcludeMissing - private val maximumAmount: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this maximum interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this maximum interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - /** The end date of the maximum interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") - - /** The start date of the maximum interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** The price ids that this maximum interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this maximum interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - /** The end date of the maximum interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - @JsonProperty("maximum_amount") - @ExcludeMissing - fun _maximumAmount(): JsonField = maximumAmount - - /** The start date of the maximum interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MaximumInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - endDate() - maximumAmount() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MaximumInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var endDate: JsonField? = null - private var maximumAmount: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(maximumInterval: MaximumInterval) = apply { - appliesToPriceIds = maximumInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - maximumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - endDate = maximumInterval.endDate - maximumAmount = maximumInterval.maximumAmount - startDate = maximumInterval.startDate - additionalProperties = maximumInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this maximum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this maximum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this maximum interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this maximum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this maximum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this maximum interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - /** The end date of the maximum interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the maximum interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the maximum interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) - - /** - * The maximum amount to charge in a given billing period for the price intervals this - * transform applies to. - */ - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - /** The start date of the maximum interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the maximum interval. */ - 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) - } - - fun build(): MaximumInterval = - MaximumInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("endDate", endDate), - checkRequired("maximumAmount", maximumAmount), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MaximumInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && maximumAmount == other.maximumAmount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, endDate, maximumAmount, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MaximumInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, maximumAmount=$maximumAmount, startDate=$startDate, 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`. - */ - @NoAutoDetect - class Metadata - @JsonCreator - private constructor( - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap() - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @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) - } - - fun build(): Metadata = Metadata(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class MinimumInterval - @JsonCreator - private constructor( - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - private val appliesToPriceIds: JsonField> = JsonMissing.of(), - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("minimum_amount") - @ExcludeMissing - private val minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - /** The price ids that this minimum interval applies to. */ - fun appliesToPriceIds(): List = - appliesToPriceIds.getRequired("applies_to_price_ids") - - /** The price interval ids that this minimum interval applies to. */ - fun appliesToPriceIntervalIds(): List = - appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") - - /** The end date of the minimum interval. */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") - - /** The start date of the minimum interval. */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** The price ids that this minimum interval applies to. */ - @JsonProperty("applies_to_price_ids") - @ExcludeMissing - fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - - /** The price interval ids that this minimum interval applies to. */ - @JsonProperty("applies_to_price_interval_ids") - @ExcludeMissing - fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - - /** The end date of the minimum interval. */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - @JsonProperty("minimum_amount") - @ExcludeMissing - fun _minimumAmount(): JsonField = minimumAmount - - /** The start date of the minimum interval. */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): MinimumInterval = apply { - if (validated) { - return@apply - } - - appliesToPriceIds() - appliesToPriceIntervalIds() - endDate() - minimumAmount() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MinimumInterval]. */ - class Builder internal constructor() { - - private var appliesToPriceIds: JsonField>? = null - private var appliesToPriceIntervalIds: JsonField>? = null - private var endDate: JsonField? = null - private var minimumAmount: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(minimumInterval: MinimumInterval) = apply { - appliesToPriceIds = minimumInterval.appliesToPriceIds.map { it.toMutableList() } - appliesToPriceIntervalIds = - minimumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - endDate = minimumInterval.endDate - minimumAmount = minimumInterval.minimumAmount - startDate = minimumInterval.startDate - additionalProperties = minimumInterval.additionalProperties.toMutableMap() - } - - /** The price ids that this minimum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: List) = - appliesToPriceIds(JsonField.of(appliesToPriceIds)) - - /** The price ids that this minimum interval applies to. */ - fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } - } - - /** The price ids that this minimum interval applies to. */ - fun addAppliesToPriceId(appliesToPriceId: String) = apply { - appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) - } - } - - /** The price interval ids that this minimum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = - appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) - - /** The price interval ids that this minimum interval applies to. */ - fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = - apply { - this.appliesToPriceIntervalIds = - appliesToPriceIntervalIds.map { it.toMutableList() } - } - - /** The price interval ids that this minimum interval applies to. */ - fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { - appliesToPriceIntervalIds = - (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceIntervalId) - } - } - - /** The end date of the minimum interval. */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** The end date of the minimum interval. */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** The end date of the minimum interval. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) - - /** - * The minimum amount to charge in a given billing period for the price intervals this - * minimum applies to. - */ - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** The start date of the minimum interval. */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** The start date of the minimum interval. */ - 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) - } - - fun build(): MinimumInterval = - MinimumInterval( - checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, - checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { - it.toImmutable() - }, - checkRequired("endDate", endDate), - checkRequired("minimumAmount", minimumAmount), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MinimumInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && endDate == other.endDate && minimumAmount == other.minimumAmount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, endDate, minimumAmount, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MinimumInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, endDate=$endDate, minimumAmount=$minimumAmount, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - /** - * The Price Interval resource represents a period of time for which a price will bill on a - * subscription. A subscription’s price intervals define its billing behavior. - */ - @NoAutoDetect - class PriceInterval - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), - @JsonProperty("billing_cycle_day") - @ExcludeMissing - private val billingCycleDay: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - private val currentBillingPeriodEndDate: JsonField = JsonMissing.of(), - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - private val currentBillingPeriodStartDate: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("filter") - @ExcludeMissing - private val filter: JsonField = JsonMissing.of(), - @JsonProperty("fixed_fee_quantity_transitions") - @ExcludeMissing - private val fixedFeeQuantityTransitions: JsonField> = - JsonMissing.of(), - @JsonProperty("price") - @ExcludeMissing - private val price: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonProperty("usage_customer_ids") - @ExcludeMissing - private val usageCustomerIds: JsonField> = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - /** The day of the month that Orb bills for this price */ - fun billingCycleDay(): Long = billingCycleDay.getRequired("billing_cycle_day") - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate(): Optional = - Optional.ofNullable( - currentBillingPeriodEndDate.getNullable("current_billing_period_end_date") - ) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodStartDate(): Optional = - Optional.ofNullable( - currentBillingPeriodStartDate.getNullable("current_billing_period_start_date") - ) - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - /** An additional filter to apply to usage queries. */ - fun filter(): Optional = Optional.ofNullable(filter.getNullable("filter")) - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions(): Optional> = - Optional.ofNullable( - fixedFeeQuantityTransitions.getNullable("fixed_fee_quantity_transitions") - ) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting in - * a charge on an invoice in the form of an invoice line item. Prices take a quantity and - * determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the key - * for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(): Price = price.getRequired("price") - - /** - * The start date of the price interval. This is the date that Orb starts billing for this - * price. - */ - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this price - * interval. - */ - fun usageCustomerIds(): Optional> = - Optional.ofNullable(usageCustomerIds.getNullable("usage_customer_ids")) - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** The day of the month that Orb bills for this price */ - @JsonProperty("billing_cycle_day") - @ExcludeMissing - fun _billingCycleDay(): JsonField = billingCycleDay - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - @JsonProperty("current_billing_period_end_date") - @ExcludeMissing - fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate - - /** - * The start date of the current billing period. This is an inclusive timestamp; the instant - * returned is exactly the beginning of the billing period. Set to null if this price - * interval is not currently active. - */ - @JsonProperty("current_billing_period_start_date") - @ExcludeMissing - fun _currentBillingPeriodStartDate(): JsonField = - currentBillingPeriodStartDate - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - /** An additional filter to apply to usage queries. */ - @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField = filter - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - @JsonProperty("fixed_fee_quantity_transitions") - @ExcludeMissing - fun _fixedFeeQuantityTransitions(): JsonField> = - fixedFeeQuantityTransitions - - /** - * 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) - */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - - /** - * The start date of the price interval. This is the date that Orb starts billing for this - * price. - */ - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this price - * interval. - */ - @JsonProperty("usage_customer_ids") - @ExcludeMissing - fun _usageCustomerIds(): JsonField> = usageCustomerIds - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): PriceInterval = apply { - if (validated) { - return@apply - } - - id() - billingCycleDay() - currentBillingPeriodEndDate() - currentBillingPeriodStartDate() - endDate() - filter() - fixedFeeQuantityTransitions().ifPresent { it.forEach { it.validate() } } - price().validate() - startDate() - usageCustomerIds() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PriceInterval]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var billingCycleDay: JsonField? = null - private var currentBillingPeriodEndDate: JsonField? = null - private var currentBillingPeriodStartDate: JsonField? = null - private var endDate: JsonField? = null - private var filter: JsonField? = null - private var fixedFeeQuantityTransitions: - JsonField>? = - null - private var price: JsonField? = null - private var startDate: JsonField? = null - private var usageCustomerIds: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(priceInterval: PriceInterval) = apply { - id = priceInterval.id - billingCycleDay = priceInterval.billingCycleDay - currentBillingPeriodEndDate = priceInterval.currentBillingPeriodEndDate - currentBillingPeriodStartDate = priceInterval.currentBillingPeriodStartDate - endDate = priceInterval.endDate - filter = priceInterval.filter - fixedFeeQuantityTransitions = - priceInterval.fixedFeeQuantityTransitions.map { it.toMutableList() } - price = priceInterval.price - startDate = priceInterval.startDate - usageCustomerIds = priceInterval.usageCustomerIds.map { it.toMutableList() } - additionalProperties = priceInterval.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - /** The day of the month that Orb bills for this price */ - fun billingCycleDay(billingCycleDay: Long) = - billingCycleDay(JsonField.of(billingCycleDay)) - - /** The day of the month that Orb bills for this price */ - fun billingCycleDay(billingCycleDay: JsonField) = apply { - this.billingCycleDay = billingCycleDay - } - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = - currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = - currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) - - /** - * The end of the current billing period. This is an exclusive timestamp, such that the - * instant returned is exactly the end of the billing period. Set to null if this price - * interval is not currently active. - */ - fun currentBillingPeriodEndDate( - currentBillingPeriodEndDate: JsonField - ) = apply { this.currentBillingPeriodEndDate = currentBillingPeriodEndDate } - - /** - * The start date of the current billing period. This is an inclusive timestamp; the - * instant returned is exactly the beginning of the billing period. Set to null if this - * price interval is not currently active. - */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = - currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the - * instant returned is exactly the beginning of the billing period. Set to null if this - * price interval is not currently active. - */ - fun currentBillingPeriodStartDate( - currentBillingPeriodStartDate: Optional - ) = currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) - - /** - * The start date of the current billing period. This is an inclusive timestamp; the - * instant returned is exactly the beginning of the billing period. Set to null if this - * price interval is not currently active. - */ - fun currentBillingPeriodStartDate( - currentBillingPeriodStartDate: JsonField - ) = apply { this.currentBillingPeriodStartDate = currentBillingPeriodStartDate } - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - /** - * The end date of the price interval. This is the date that Orb stops billing for this - * price. - */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** An additional filter to apply to usage queries. */ - fun filter(filter: String?) = filter(JsonField.ofNullable(filter)) - - /** An additional filter to apply to usage queries. */ - fun filter(filter: Optional) = filter(filter.orElse(null)) - - /** An additional filter to apply to usage queries. */ - fun filter(filter: JsonField) = apply { this.filter = filter } - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: List? - ) = fixedFeeQuantityTransitions(JsonField.ofNullable(fixedFeeQuantityTransitions)) - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: Optional> - ) = fixedFeeQuantityTransitions(fixedFeeQuantityTransitions.orElse(null)) - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: JsonField> - ) = apply { - this.fixedFeeQuantityTransitions = - fixedFeeQuantityTransitions.map { it.toMutableList() } - } - - /** - * The fixed fee quantity transitions for this price interval. This is only relevant for - * fixed fees. - */ - fun addFixedFeeQuantityTransition( - fixedFeeQuantityTransition: FixedFeeQuantityTransition - ) = apply { - fixedFeeQuantityTransitions = - (fixedFeeQuantityTransitions ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(fixedFeeQuantityTransition) - } - } - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(price: Price) = price(JsonField.of(price)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(price: JsonField) = apply { this.price = price } - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(matrix: Price.MatrixPrice) = price(Price.ofMatrix(matrix)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = - price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredPackage: Price.TieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedTiered: Price.GroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = - price(Price.ofTieredWithMinimum(tieredWithMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = - price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = - price(Price.ofPackageWithAllocation(packageWithAllocation)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(unitWithPercent: Price.UnitWithPercentPrice) = - price(Price.ofUnitWithPercent(unitWithPercent)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = - price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(tieredWithProration: Price.TieredWithProrationPrice) = - price(Price.ofTieredWithProration(tieredWithProration)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(unitWithProration: Price.UnitWithProrationPrice) = - price(Price.ofUnitWithProration(unitWithProration)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedAllocation: Price.GroupedAllocationPrice) = - price(Price.ofGroupedAllocation(groupedAllocation)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = - price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = - price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = - price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(bulkWithProration: Price.BulkWithProrationPrice) = - price(Price.ofBulkWithProration(bulkWithProration)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = - price(Price.ofGroupedTieredPackage(groupedTieredPackage)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = - price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = - price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice) = - price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - - /** - * The Price resource represents a price that can be billed on a subscription, resulting - * in a charge on an invoice in the form of an invoice line item. Prices take a quantity - * and determine an amount to bill. - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given Price object. The model_type field determines the - * key for the configuration object that is present. - * - * For more on the types of prices, see - * [the core concepts documentation](/core-concepts#plan-and-price) - */ - fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = - price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) - - /** - * The start date of the price interval. This is the date that Orb starts billing for - * this price. - */ - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - /** - * The start date of the price interval. This is the date that Orb starts billing for - * this price. - */ - fun startDate(startDate: JsonField) = apply { - this.startDate = startDate - } - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun usageCustomerIds(usageCustomerIds: List?) = - usageCustomerIds(JsonField.ofNullable(usageCustomerIds)) - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun usageCustomerIds(usageCustomerIds: Optional>) = - usageCustomerIds(usageCustomerIds.orElse(null)) - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun usageCustomerIds(usageCustomerIds: JsonField>) = apply { - this.usageCustomerIds = usageCustomerIds.map { it.toMutableList() } - } - - /** - * A list of customer IDs whose usage events will be aggregated and billed under this - * price interval. - */ - fun addUsageCustomerId(usageCustomerId: String) = apply { - usageCustomerIds = - (usageCustomerIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(usageCustomerId) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): PriceInterval = - PriceInterval( - checkRequired("id", id), - checkRequired("billingCycleDay", billingCycleDay), - checkRequired("currentBillingPeriodEndDate", currentBillingPeriodEndDate), - checkRequired("currentBillingPeriodStartDate", currentBillingPeriodStartDate), - checkRequired("endDate", endDate), - checkRequired("filter", filter), - checkRequired("fixedFeeQuantityTransitions", fixedFeeQuantityTransitions).map { - it.toImmutable() - }, - checkRequired("price", price), - checkRequired("startDate", startDate), - checkRequired("usageCustomerIds", usageCustomerIds).map { it.toImmutable() }, - additionalProperties.toImmutable(), - ) - } - - @NoAutoDetect - class FixedFeeQuantityTransition - @JsonCreator - private constructor( - @JsonProperty("effective_date") - @ExcludeMissing - private val effectiveDate: JsonField = JsonMissing.of(), - @JsonProperty("price_id") - @ExcludeMissing - private val priceId: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - private val quantity: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun effectiveDate(): OffsetDateTime = effectiveDate.getRequired("effective_date") - - fun priceId(): String = priceId.getRequired("price_id") - - fun quantity(): Long = quantity.getRequired("quantity") - - @JsonProperty("effective_date") - @ExcludeMissing - fun _effectiveDate(): JsonField = effectiveDate - - @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - - @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): FixedFeeQuantityTransition = apply { - if (validated) { - return@apply - } - - effectiveDate() - priceId() - quantity() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FixedFeeQuantityTransition]. */ - class Builder internal constructor() { - - private var effectiveDate: JsonField? = null - private var priceId: JsonField? = null - private var quantity: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(fixedFeeQuantityTransition: FixedFeeQuantityTransition) = apply { - effectiveDate = fixedFeeQuantityTransition.effectiveDate - priceId = fixedFeeQuantityTransition.priceId - quantity = fixedFeeQuantityTransition.quantity - additionalProperties = - fixedFeeQuantityTransition.additionalProperties.toMutableMap() - } - - fun effectiveDate(effectiveDate: OffsetDateTime) = - effectiveDate(JsonField.of(effectiveDate)) - - fun effectiveDate(effectiveDate: JsonField) = apply { - this.effectiveDate = effectiveDate - } - - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) - - fun priceId(priceId: JsonField) = apply { this.priceId = priceId } - - fun quantity(quantity: Long) = quantity(JsonField.of(quantity)) - - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): FixedFeeQuantityTransition = - FixedFeeQuantityTransition( - checkRequired("effectiveDate", effectiveDate), - checkRequired("priceId", priceId), - checkRequired("quantity", quantity), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FixedFeeQuantityTransition && effectiveDate == other.effectiveDate && priceId == other.priceId && quantity == other.quantity && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(effectiveDate, priceId, quantity, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "FixedFeeQuantityTransition{effectiveDate=$effectiveDate, priceId=$priceId, quantity=$quantity, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PriceInterval && id == other.id && billingCycleDay == other.billingCycleDay && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && endDate == other.endDate && filter == other.filter && fixedFeeQuantityTransitions == other.fixedFeeQuantityTransitions && price == other.price && startDate == other.startDate && usageCustomerIds == other.usageCustomerIds && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, billingCycleDay, currentBillingPeriodEndDate, currentBillingPeriodStartDate, endDate, filter, fixedFeeQuantityTransitions, price, startDate, usageCustomerIds, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PriceInterval{id=$id, billingCycleDay=$billingCycleDay, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, endDate=$endDate, filter=$filter, fixedFeeQuantityTransitions=$fixedFeeQuantityTransitions, price=$price, startDate=$startDate, usageCustomerIds=$usageCustomerIds, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class RedeemedCoupon - @JsonCreator - private constructor( - @JsonProperty("coupon_id") - @ExcludeMissing - private val couponId: JsonField = JsonMissing.of(), - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - private val startDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun couponId(): String = couponId.getRequired("coupon_id") - - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - - @JsonProperty("coupon_id") @ExcludeMissing fun _couponId(): JsonField = couponId - - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - @JsonProperty("start_date") - @ExcludeMissing - fun _startDate(): JsonField = startDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): RedeemedCoupon = apply { - if (validated) { - return@apply - } - - couponId() - endDate() - startDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RedeemedCoupon]. */ - class Builder internal constructor() { - - private var couponId: JsonField? = null - private var endDate: JsonField? = null - private var startDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(redeemedCoupon: RedeemedCoupon) = apply { - couponId = redeemedCoupon.couponId - endDate = redeemedCoupon.endDate - startDate = redeemedCoupon.startDate - additionalProperties = redeemedCoupon.additionalProperties.toMutableMap() - } - - fun couponId(couponId: String) = couponId(JsonField.of(couponId)) - - fun couponId(couponId: JsonField) = apply { this.couponId = couponId } - - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) - - 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) - } - - fun build(): RedeemedCoupon = - RedeemedCoupon( - checkRequired("couponId", couponId), - checkRequired("endDate", endDate), - checkRequired("startDate", startDate), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is RedeemedCoupon && couponId == other.couponId && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(couponId, endDate, startDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RedeemedCoupon{couponId=$couponId, endDate=$endDate, startDate=$startDate, 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 ENDED = of("ended") - - @JvmField val UPCOMING = of("upcoming") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - ACTIVE, - ENDED, - UPCOMING, - } - - /** - * 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, - ENDED, - UPCOMING, - /** 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 - ENDED -> Value.ENDED - UPCOMING -> Value.UPCOMING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to 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 - ENDED -> Known.ENDED - UPCOMING -> Known.UPCOMING - 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") } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @NoAutoDetect - class TrialInfo - @JsonCreator - private constructor( - @JsonProperty("end_date") - @ExcludeMissing - private val endDate: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun endDate(): Optional = - Optional.ofNullable(endDate.getNullable("end_date")) - - @JsonProperty("end_date") - @ExcludeMissing - fun _endDate(): JsonField = endDate - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): TrialInfo = apply { - if (validated) { - return@apply - } - - endDate() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TrialInfo]. */ - class Builder internal constructor() { - - private var endDate: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(trialInfo: TrialInfo) = apply { - endDate = trialInfo.endDate - additionalProperties = trialInfo.additionalProperties.toMutableMap() - } - - fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) - - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - - 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) - } - - fun build(): TrialInfo = - TrialInfo(checkRequired("endDate", endDate), additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TrialInfo && endDate == other.endDate && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(endDate, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TrialInfo{endDate=$endDate, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is SubscriptionUpdateTrialResponse && id == other.id && activePlanPhaseOrder == other.activePlanPhaseOrder && adjustmentIntervals == other.adjustmentIntervals && autoCollection == other.autoCollection && billingCycleAnchorConfiguration == other.billingCycleAnchorConfiguration && billingCycleDay == other.billingCycleDay && createdAt == other.createdAt && currentBillingPeriodEndDate == other.currentBillingPeriodEndDate && currentBillingPeriodStartDate == other.currentBillingPeriodStartDate && customer == other.customer && defaultInvoiceMemo == other.defaultInvoiceMemo && discountIntervals == other.discountIntervals && endDate == other.endDate && fixedFeeQuantitySchedule == other.fixedFeeQuantitySchedule && invoicingThreshold == other.invoicingThreshold && maximumIntervals == other.maximumIntervals && metadata == other.metadata && minimumIntervals == other.minimumIntervals && netTerms == other.netTerms && plan == other.plan && priceIntervals == other.priceIntervals && redeemedCoupon == other.redeemedCoupon && startDate == other.startDate && status == other.status && trialInfo == other.trialInfo && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, activePlanPhaseOrder, adjustmentIntervals, autoCollection, billingCycleAnchorConfiguration, billingCycleDay, createdAt, currentBillingPeriodEndDate, currentBillingPeriodStartDate, customer, defaultInvoiceMemo, discountIntervals, endDate, fixedFeeQuantitySchedule, invoicingThreshold, maximumIntervals, metadata, minimumIntervals, netTerms, plan, priceIntervals, redeemedCoupon, startDate, status, trialInfo, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SubscriptionUpdateTrialResponse{id=$id, activePlanPhaseOrder=$activePlanPhaseOrder, adjustmentIntervals=$adjustmentIntervals, autoCollection=$autoCollection, billingCycleAnchorConfiguration=$billingCycleAnchorConfiguration, billingCycleDay=$billingCycleDay, createdAt=$createdAt, currentBillingPeriodEndDate=$currentBillingPeriodEndDate, currentBillingPeriodStartDate=$currentBillingPeriodStartDate, customer=$customer, defaultInvoiceMemo=$defaultInvoiceMemo, discountIntervals=$discountIntervals, endDate=$endDate, fixedFeeQuantitySchedule=$fixedFeeQuantitySchedule, invoicingThreshold=$invoicingThreshold, maximumIntervals=$maximumIntervals, metadata=$metadata, minimumIntervals=$minimumIntervals, netTerms=$netTerms, plan=$plan, priceIntervals=$priceIntervals, redeemedCoupon=$redeemedCoupon, startDate=$startDate, status=$status, trialInfo=$trialInfo, additionalProperties=$additionalProperties}" -} 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 c6e608499..04db57a43 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 @@ -21,12 +21,12 @@ import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.getOrThrow import com.withorb.api.core.immutableEmptyMap import com.withorb.api.core.toImmutable import com.withorb.api.errors.OrbInvalidDataException -import java.time.OffsetDateTime import java.util.Objects import java.util.Optional @@ -203,6 +203,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of + * [UngroupedSubscriptionUsage]. + * + * The following fields are required: + * ```java + * .data() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -227,14 +236,8 @@ private constructor( fun addData(data: Data) = apply { this.data = - (this.data ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(data) + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) } } @@ -270,10 +273,10 @@ private constructor( private constructor( @JsonProperty("billable_metric") @ExcludeMissing - private val billableMetric: JsonField = JsonMissing.of(), + private val billableMetric: JsonField = JsonMissing.of(), @JsonProperty("usage") @ExcludeMissing - private val usage: JsonField> = JsonMissing.of(), + private val usage: JsonField> = JsonMissing.of(), @JsonProperty("view_mode") @ExcludeMissing private val viewMode: JsonField = JsonMissing.of(), @@ -281,17 +284,18 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - fun billableMetric(): BillableMetric = billableMetric.getRequired("billable_metric") + fun billableMetric(): BillableMetricSimpleModel = + billableMetric.getRequired("billable_metric") - fun usage(): List = usage.getRequired("usage") + fun usage(): List = usage.getRequired("usage") fun viewMode(): ViewMode = viewMode.getRequired("view_mode") @JsonProperty("billable_metric") @ExcludeMissing - fun _billableMetric(): JsonField = billableMetric + fun _billableMetric(): JsonField = billableMetric - @JsonProperty("usage") @ExcludeMissing fun _usage(): JsonField> = usage + @JsonProperty("usage") @ExcludeMissing fun _usage(): JsonField> = usage @JsonProperty("view_mode") @ExcludeMissing @@ -318,14 +322,24 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .billableMetric() + * .usage() + * .viewMode() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Data]. */ class Builder internal constructor() { - private var billableMetric: JsonField? = null - private var usage: JsonField>? = null + private var billableMetric: JsonField? = null + private var usage: JsonField>? = null private var viewMode: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -337,29 +351,23 @@ private constructor( additionalProperties = data.additionalProperties.toMutableMap() } - fun billableMetric(billableMetric: BillableMetric) = + fun billableMetric(billableMetric: BillableMetricSimpleModel) = billableMetric(JsonField.of(billableMetric)) - fun billableMetric(billableMetric: JsonField) = apply { + fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric } - fun usage(usage: List) = usage(JsonField.of(usage)) + fun usage(usage: List) = usage(JsonField.of(usage)) - fun usage(usage: JsonField>) = apply { + fun usage(usage: JsonField>) = apply { this.usage = usage.map { it.toMutableList() } } - fun addUsage(usage: Usage) = apply { + fun addUsage(usage: UsageModel) = apply { this.usage = - (this.usage ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(usage) + (this.usage ?: JsonField.of(mutableListOf())).also { + checkKnown("usage", it).add(usage) } } @@ -398,263 +406,6 @@ private constructor( ) } - @NoAutoDetect - class BillableMetric - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun name(): String = name.getRequired("name") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillableMetric = apply { - if (validated) { - return@apply - } - - id() - name() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillableMetric]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billableMetric: BillableMetric) = apply { - id = billableMetric.id - name = billableMetric.name - additionalProperties = billableMetric.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun name(name: String) = name(JsonField.of(name)) - - 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) - } - - fun build(): BillableMetric = - BillableMetric( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillableMetric && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillableMetric{id=$id, name=$name, additionalProperties=$additionalProperties}" - } - - @NoAutoDetect - class Usage - @JsonCreator - private constructor( - @JsonProperty("quantity") - @ExcludeMissing - private val quantity: JsonField = JsonMissing.of(), - @JsonProperty("timeframe_end") - @ExcludeMissing - private val timeframeEnd: JsonField = JsonMissing.of(), - @JsonProperty("timeframe_start") - @ExcludeMissing - private val timeframeStart: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun quantity(): Double = quantity.getRequired("quantity") - - fun timeframeEnd(): OffsetDateTime = timeframeEnd.getRequired("timeframe_end") - - fun timeframeStart(): OffsetDateTime = timeframeStart.getRequired("timeframe_start") - - @JsonProperty("quantity") - @ExcludeMissing - fun _quantity(): JsonField = quantity - - @JsonProperty("timeframe_end") - @ExcludeMissing - fun _timeframeEnd(): JsonField = timeframeEnd - - @JsonProperty("timeframe_start") - @ExcludeMissing - fun _timeframeStart(): JsonField = timeframeStart - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Usage = apply { - if (validated) { - return@apply - } - - quantity() - timeframeEnd() - timeframeStart() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Usage]. */ - class Builder internal constructor() { - - private var quantity: JsonField? = null - private var timeframeEnd: JsonField? = null - private var timeframeStart: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(usage: Usage) = apply { - quantity = usage.quantity - timeframeEnd = usage.timeframeEnd - timeframeStart = usage.timeframeStart - additionalProperties = usage.additionalProperties.toMutableMap() - } - - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun timeframeEnd(timeframeEnd: OffsetDateTime) = - timeframeEnd(JsonField.of(timeframeEnd)) - - fun timeframeEnd(timeframeEnd: JsonField) = apply { - this.timeframeEnd = timeframeEnd - } - - fun timeframeStart(timeframeStart: OffsetDateTime) = - timeframeStart(JsonField.of(timeframeStart)) - - fun timeframeStart(timeframeStart: JsonField) = apply { - this.timeframeStart = timeframeStart - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Usage = - Usage( - checkRequired("quantity", quantity), - checkRequired("timeframeEnd", timeframeEnd), - checkRequired("timeframeStart", timeframeStart), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Usage && quantity == other.quantity && timeframeEnd == other.timeframeEnd && timeframeStart == other.timeframeStart && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(quantity, timeframeEnd, timeframeStart, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Usage{quantity=$quantity, timeframeEnd=$timeframeEnd, timeframeStart=$timeframeStart, additionalProperties=$additionalProperties}" - } - class ViewMode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -840,6 +591,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [GroupedSubscriptionUsage]. + * + * The following fields are required: + * ```java + * .data() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -865,14 +624,8 @@ private constructor( fun addData(data: Data) = apply { this.data = - (this.data ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(data) + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) } } @@ -919,13 +672,13 @@ private constructor( private constructor( @JsonProperty("billable_metric") @ExcludeMissing - private val billableMetric: JsonField = JsonMissing.of(), + private val billableMetric: JsonField = JsonMissing.of(), @JsonProperty("metric_group") @ExcludeMissing private val metricGroup: JsonField = JsonMissing.of(), @JsonProperty("usage") @ExcludeMissing - private val usage: JsonField> = JsonMissing.of(), + private val usage: JsonField> = JsonMissing.of(), @JsonProperty("view_mode") @ExcludeMissing private val viewMode: JsonField = JsonMissing.of(), @@ -933,23 +686,24 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - fun billableMetric(): BillableMetric = billableMetric.getRequired("billable_metric") + fun billableMetric(): BillableMetricSimpleModel = + billableMetric.getRequired("billable_metric") fun metricGroup(): MetricGroup = metricGroup.getRequired("metric_group") - fun usage(): List = usage.getRequired("usage") + fun usage(): List = usage.getRequired("usage") fun viewMode(): ViewMode = viewMode.getRequired("view_mode") @JsonProperty("billable_metric") @ExcludeMissing - fun _billableMetric(): JsonField = billableMetric + fun _billableMetric(): JsonField = billableMetric @JsonProperty("metric_group") @ExcludeMissing fun _metricGroup(): JsonField = metricGroup - @JsonProperty("usage") @ExcludeMissing fun _usage(): JsonField> = usage + @JsonProperty("usage") @ExcludeMissing fun _usage(): JsonField> = usage @JsonProperty("view_mode") @ExcludeMissing @@ -977,15 +731,26 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .billableMetric() + * .metricGroup() + * .usage() + * .viewMode() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Data]. */ class Builder internal constructor() { - private var billableMetric: JsonField? = null + private var billableMetric: JsonField? = null private var metricGroup: JsonField? = null - private var usage: JsonField>? = null + private var usage: JsonField>? = null private var viewMode: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -998,10 +763,10 @@ private constructor( additionalProperties = data.additionalProperties.toMutableMap() } - fun billableMetric(billableMetric: BillableMetric) = + fun billableMetric(billableMetric: BillableMetricSimpleModel) = billableMetric(JsonField.of(billableMetric)) - fun billableMetric(billableMetric: JsonField) = apply { + fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric } @@ -1011,22 +776,16 @@ private constructor( this.metricGroup = metricGroup } - fun usage(usage: List) = usage(JsonField.of(usage)) + fun usage(usage: List) = usage(JsonField.of(usage)) - fun usage(usage: JsonField>) = apply { + fun usage(usage: JsonField>) = apply { this.usage = usage.map { it.toMutableList() } } - fun addUsage(usage: Usage) = apply { + fun addUsage(usage: UsageModel) = apply { this.usage = - (this.usage ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(usage) + (this.usage ?: JsonField.of(mutableListOf())).also { + checkKnown("usage", it).add(usage) } } @@ -1066,121 +825,6 @@ private constructor( ) } - @NoAutoDetect - class BillableMetric - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - private val id: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - private val name: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun id(): String = id.getRequired("id") - - fun name(): String = name.getRequired("name") - - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): BillableMetric = apply { - if (validated) { - return@apply - } - - id() - name() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillableMetric]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billableMetric: BillableMetric) = apply { - id = billableMetric.id - name = billableMetric.name - additionalProperties = billableMetric.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - fun id(id: JsonField) = apply { this.id = id } - - fun name(name: String) = name(JsonField.of(name)) - - 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) - } - - fun build(): BillableMetric = - BillableMetric( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BillableMetric && id == other.id && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BillableMetric{id=$id, name=$name, additionalProperties=$additionalProperties}" - } - @NoAutoDetect class MetricGroup @JsonCreator @@ -1227,6 +871,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [MetricGroup]. + * + * The following fields are required: + * ```java + * .propertyKey() + * .propertyValue() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -1305,148 +958,6 @@ private constructor( "MetricGroup{propertyKey=$propertyKey, propertyValue=$propertyValue, additionalProperties=$additionalProperties}" } - @NoAutoDetect - class Usage - @JsonCreator - private constructor( - @JsonProperty("quantity") - @ExcludeMissing - private val quantity: JsonField = JsonMissing.of(), - @JsonProperty("timeframe_end") - @ExcludeMissing - private val timeframeEnd: JsonField = JsonMissing.of(), - @JsonProperty("timeframe_start") - @ExcludeMissing - private val timeframeStart: JsonField = JsonMissing.of(), - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - fun quantity(): Double = quantity.getRequired("quantity") - - fun timeframeEnd(): OffsetDateTime = timeframeEnd.getRequired("timeframe_end") - - fun timeframeStart(): OffsetDateTime = timeframeStart.getRequired("timeframe_start") - - @JsonProperty("quantity") - @ExcludeMissing - fun _quantity(): JsonField = quantity - - @JsonProperty("timeframe_end") - @ExcludeMissing - fun _timeframeEnd(): JsonField = timeframeEnd - - @JsonProperty("timeframe_start") - @ExcludeMissing - fun _timeframeStart(): JsonField = timeframeStart - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - private var validated: Boolean = false - - fun validate(): Usage = apply { - if (validated) { - return@apply - } - - quantity() - timeframeEnd() - timeframeStart() - validated = true - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Usage]. */ - class Builder internal constructor() { - - private var quantity: JsonField? = null - private var timeframeEnd: JsonField? = null - private var timeframeStart: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(usage: Usage) = apply { - quantity = usage.quantity - timeframeEnd = usage.timeframeEnd - timeframeStart = usage.timeframeStart - additionalProperties = usage.additionalProperties.toMutableMap() - } - - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - fun timeframeEnd(timeframeEnd: OffsetDateTime) = - timeframeEnd(JsonField.of(timeframeEnd)) - - fun timeframeEnd(timeframeEnd: JsonField) = apply { - this.timeframeEnd = timeframeEnd - } - - fun timeframeStart(timeframeStart: OffsetDateTime) = - timeframeStart(JsonField.of(timeframeStart)) - - fun timeframeStart(timeframeStart: JsonField) = apply { - this.timeframeStart = timeframeStart - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun 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 build(): Usage = - Usage( - checkRequired("quantity", quantity), - checkRequired("timeframeEnd", timeframeEnd), - checkRequired("timeframeStart", timeframeStart), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Usage && quantity == other.quantity && timeframeEnd == other.timeframeEnd && timeframeStart == other.timeframeStart && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(quantity, timeframeEnd, timeframeStart, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Usage{quantity=$quantity, timeframeEnd=$timeframeEnd, timeframeStart=$timeframeStart, additionalProperties=$additionalProperties}" - } - class ViewMode @JsonCreator private constructor(private val value: JsonField) : Enum { 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 6e735207e..c19a3d3dc 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 @@ -11,6 +11,7 @@ import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.immutableEmptyMap import com.withorb.api.core.toImmutable @@ -22,19 +23,19 @@ class Subscriptions private constructor( @JsonProperty("data") @ExcludeMissing - private val data: JsonField> = JsonMissing.of(), + private val data: JsonField> = JsonMissing.of(), @JsonProperty("pagination_metadata") @ExcludeMissing private val paginationMetadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - fun data(): List = data.getRequired("data") + fun data(): List = data.getRequired("data") fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data @JsonProperty("pagination_metadata") @ExcludeMissing @@ -60,13 +61,22 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [Subscriptions]. + * + * The following fields are required: + * ```java + * .data() + * .paginationMetadata() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Subscriptions]. */ class Builder internal constructor() { - private var data: JsonField>? = null + private var data: JsonField>? = null private var paginationMetadata: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -77,22 +87,16 @@ private constructor( additionalProperties = subscriptions.additionalProperties.toMutableMap() } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { + fun data(data: JsonField>) = apply { this.data = data.map { it.toMutableList() } } - fun addData(data: Subscription) = apply { + fun addData(data: SubscriptionModel) = apply { this.data = - (this.data ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(data) + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionsModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionsModel.kt new file mode 100644 index 000000000..1ad6cea7e --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionsModel.kt @@ -0,0 +1,153 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects + +@NoAutoDetect +class SubscriptionsModel +@JsonCreator +private constructor( + @JsonProperty("data") + @ExcludeMissing + private val data: JsonField> = JsonMissing.of(), + @JsonProperty("pagination_metadata") + @ExcludeMissing + private val paginationMetadata: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun data(): List = data.getRequired("data") + + fun paginationMetadata(): PaginationMetadata = + paginationMetadata.getRequired("pagination_metadata") + + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data + + @JsonProperty("pagination_metadata") + @ExcludeMissing + fun _paginationMetadata(): JsonField = paginationMetadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): SubscriptionsModel = apply { + if (validated) { + return@apply + } + + data().forEach { it.validate() } + paginationMetadata().validate() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SubscriptionsModel]. + * + * The following fields are required: + * ```java + * .data() + * .paginationMetadata() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SubscriptionsModel]. */ + class Builder internal constructor() { + + private var data: JsonField>? = null + private var paginationMetadata: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(subscriptionsModel: SubscriptionsModel) = apply { + data = subscriptionsModel.data.map { it.toMutableList() } + paginationMetadata = subscriptionsModel.paginationMetadata + additionalProperties = subscriptionsModel.additionalProperties.toMutableMap() + } + + fun data(data: List) = data(JsonField.of(data)) + + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + fun addData(data: SubscriptionModel) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) + } + } + + fun paginationMetadata(paginationMetadata: PaginationMetadata) = + paginationMetadata(JsonField.of(paginationMetadata)) + + 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) + } + + fun build(): SubscriptionsModel = + SubscriptionsModel( + checkRequired("data", data).map { it.toImmutable() }, + checkRequired("paginationMetadata", paginationMetadata), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SubscriptionsModel && data == other.data && paginationMetadata == other.paginationMetadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(data, paginationMetadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SubscriptionsModel{data=$data, paginationMetadata=$paginationMetadata, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/TaxAmountModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/TaxAmountModel.kt new file mode 100644 index 000000000..f1fd9ff5a --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/TaxAmountModel.kt @@ -0,0 +1,181 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class TaxAmountModel +@JsonCreator +private constructor( + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("tax_rate_description") + @ExcludeMissing + private val taxRateDescription: JsonField = JsonMissing.of(), + @JsonProperty("tax_rate_percentage") + @ExcludeMissing + private val taxRatePercentage: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** The amount of additional tax incurred by this tax rate. */ + fun amount(): String = amount.getRequired("amount") + + /** The human-readable description of the applied tax rate. */ + fun taxRateDescription(): String = taxRateDescription.getRequired("tax_rate_description") + + /** The tax rate percentage, out of 100. */ + fun taxRatePercentage(): Optional = + Optional.ofNullable(taxRatePercentage.getNullable("tax_rate_percentage")) + + /** The amount of additional tax incurred by this tax rate. */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** The human-readable description of the applied tax rate. */ + @JsonProperty("tax_rate_description") + @ExcludeMissing + fun _taxRateDescription(): JsonField = taxRateDescription + + /** The tax rate percentage, out of 100. */ + @JsonProperty("tax_rate_percentage") + @ExcludeMissing + fun _taxRatePercentage(): JsonField = taxRatePercentage + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): TaxAmountModel = apply { + if (validated) { + return@apply + } + + amount() + taxRateDescription() + taxRatePercentage() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TaxAmountModel]. + * + * The following fields are required: + * ```java + * .amount() + * .taxRateDescription() + * .taxRatePercentage() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TaxAmountModel]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var taxRateDescription: JsonField? = null + private var taxRatePercentage: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(taxAmountModel: TaxAmountModel) = apply { + amount = taxAmountModel.amount + taxRateDescription = taxAmountModel.taxRateDescription + taxRatePercentage = taxAmountModel.taxRatePercentage + additionalProperties = taxAmountModel.additionalProperties.toMutableMap() + } + + /** The amount of additional tax incurred by this tax rate. */ + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** The amount of additional tax incurred by this tax rate. */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The human-readable description of the applied tax rate. */ + fun taxRateDescription(taxRateDescription: String) = + taxRateDescription(JsonField.of(taxRateDescription)) + + /** The human-readable description of the applied tax rate. */ + fun taxRateDescription(taxRateDescription: JsonField) = apply { + this.taxRateDescription = taxRateDescription + } + + /** The tax rate percentage, out of 100. */ + fun taxRatePercentage(taxRatePercentage: String?) = + taxRatePercentage(JsonField.ofNullable(taxRatePercentage)) + + /** The tax rate percentage, out of 100. */ + fun taxRatePercentage(taxRatePercentage: Optional) = + taxRatePercentage(taxRatePercentage.orElse(null)) + + /** The tax rate percentage, out of 100. */ + fun taxRatePercentage(taxRatePercentage: JsonField) = apply { + this.taxRatePercentage = taxRatePercentage + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): TaxAmountModel = + TaxAmountModel( + checkRequired("amount", amount), + checkRequired("taxRateDescription", taxRateDescription), + checkRequired("taxRatePercentage", taxRatePercentage), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TaxAmountModel && amount == other.amount && taxRateDescription == other.taxRateDescription && taxRatePercentage == other.taxRatePercentage && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(amount, taxRateDescription, taxRatePercentage, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TaxAmountModel{amount=$amount, taxRateDescription=$taxRateDescription, taxRatePercentage=$taxRatePercentage, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/ThresholdModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ThresholdModel.kt new file mode 100644 index 000000000..1c9e3d215 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ThresholdModel.kt @@ -0,0 +1,135 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects + +/** Thresholds are used to define the conditions under which an alert will be triggered. */ +@NoAutoDetect +class ThresholdModel +@JsonCreator +private constructor( + @JsonProperty("value") @ExcludeMissing private val value: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** + * The value at which an alert will fire. For credit balance alerts, the alert will fire at or + * below this value. For usage and cost alerts, the alert will fire at or above this value. + */ + fun value(): Double = value.getRequired("value") + + /** + * The value at which an alert will fire. For credit balance alerts, the alert will fire at or + * below this value. For usage and cost alerts, the alert will fire at or above this value. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): ThresholdModel = apply { + if (validated) { + return@apply + } + + value() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ThresholdModel]. + * + * The following fields are required: + * ```java + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ThresholdModel]. */ + class Builder internal constructor() { + + private var value: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(thresholdModel: ThresholdModel) = apply { + value = thresholdModel.value + additionalProperties = thresholdModel.additionalProperties.toMutableMap() + } + + /** + * The value at which an alert will fire. For credit balance alerts, the alert will fire at + * or below this value. For usage and cost alerts, the alert will fire at or above this + * value. + */ + fun value(value: Double) = value(JsonField.of(value)) + + /** + * The value at which an alert will fire. For credit balance alerts, the alert will fire at + * or below this value. For usage and cost alerts, the alert will fire at or above this + * value. + */ + fun value(value: JsonField) = apply { this.value = 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) + } + + fun build(): ThresholdModel = + ThresholdModel(checkRequired("value", value), additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ThresholdModel && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(value, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThresholdModel{value=$value, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/TieredBpsConfigModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/TieredBpsConfigModel.kt new file mode 100644 index 000000000..06ee21220 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/TieredBpsConfigModel.kt @@ -0,0 +1,324 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class TieredBpsConfigModel +@JsonCreator +private constructor( + @JsonProperty("tiers") + @ExcludeMissing + private val tiers: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** Tiers for a Graduated BPS pricing model, where usage is bucketed into specified tiers */ + fun tiers(): List = tiers.getRequired("tiers") + + /** Tiers for a Graduated BPS pricing model, where usage is bucketed into specified tiers */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): TieredBpsConfigModel = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TieredBpsConfigModel]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredBpsConfigModel]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredBpsConfigModel: TieredBpsConfigModel) = apply { + tiers = tieredBpsConfigModel.tiers.map { it.toMutableList() } + additionalProperties = tieredBpsConfigModel.additionalProperties.toMutableMap() + } + + /** Tiers for a Graduated BPS pricing model, where usage is bucketed into specified tiers */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** Tiers for a Graduated BPS pricing model, where usage is bucketed into specified tiers */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** Tiers for a Graduated BPS pricing model, where usage is bucketed into specified tiers */ + 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) + } + + fun build(): TieredBpsConfigModel = + TieredBpsConfigModel( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + @NoAutoDetect + class Tier + @JsonCreator + private constructor( + @JsonProperty("bps") @ExcludeMissing private val bps: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_maximum") + @ExcludeMissing + private val perUnitMaximum: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** Per-event basis point rate */ + fun bps(): Double = bps.getRequired("bps") + + /** Inclusive tier starting value */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** Exclusive tier ending value */ + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** Per unit maximum to charge */ + fun perUnitMaximum(): Optional = + Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) + + /** Per-event basis point rate */ + @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps + + /** Inclusive tier starting value */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount + + /** Exclusive tier ending value */ + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount + + /** Per unit maximum to charge */ + @JsonProperty("per_unit_maximum") + @ExcludeMissing + fun _perUnitMaximum(): JsonField = perUnitMaximum + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + bps() + minimumAmount() + maximumAmount() + perUnitMaximum() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```java + * .bps() + * .minimumAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var bps: JsonField? = null + private var minimumAmount: JsonField? = null + private var maximumAmount: JsonField = JsonMissing.of() + private var perUnitMaximum: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + bps = tier.bps + minimumAmount = tier.minimumAmount + maximumAmount = tier.maximumAmount + perUnitMaximum = tier.perUnitMaximum + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Per-event basis point rate */ + fun bps(bps: Double) = bps(JsonField.of(bps)) + + /** Per-event basis point rate */ + fun bps(bps: JsonField) = apply { this.bps = bps } + + /** Inclusive tier starting value */ + fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) + + /** Inclusive tier starting value */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** Exclusive tier ending value */ + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + /** Exclusive tier ending value */ + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) + + /** Exclusive tier ending value */ + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + /** Per unit maximum to charge */ + fun perUnitMaximum(perUnitMaximum: String?) = + perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) + + /** Per unit maximum to charge */ + fun perUnitMaximum(perUnitMaximum: Optional) = + perUnitMaximum(perUnitMaximum.orElse(null)) + + /** Per unit maximum to charge */ + fun perUnitMaximum(perUnitMaximum: JsonField) = apply { + this.perUnitMaximum = perUnitMaximum + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): Tier = + Tier( + checkRequired("bps", bps), + checkRequired("minimumAmount", minimumAmount), + maximumAmount, + perUnitMaximum, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Tier && bps == other.bps && minimumAmount == other.minimumAmount && maximumAmount == other.maximumAmount && perUnitMaximum == other.perUnitMaximum && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(bps, minimumAmount, maximumAmount, perUnitMaximum, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{bps=$bps, minimumAmount=$minimumAmount, maximumAmount=$maximumAmount, perUnitMaximum=$perUnitMaximum, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TieredBpsConfigModel && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredBpsConfigModel{tiers=$tiers, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/TieredConfigModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/TieredConfigModel.kt new file mode 100644 index 000000000..307db740d --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/TieredConfigModel.kt @@ -0,0 +1,292 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class TieredConfigModel +@JsonCreator +private constructor( + @JsonProperty("tiers") + @ExcludeMissing + private val tiers: JsonField> = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** Tiers for rating based on total usage quantities into the specified tier */ + fun tiers(): List = tiers.getRequired("tiers") + + /** Tiers for rating based on total usage quantities into the specified tier */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): TieredConfigModel = apply { + if (validated) { + return@apply + } + + tiers().forEach { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TieredConfigModel]. + * + * The following fields are required: + * ```java + * .tiers() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TieredConfigModel]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredConfigModel: TieredConfigModel) = apply { + tiers = tieredConfigModel.tiers.map { it.toMutableList() } + additionalProperties = tieredConfigModel.additionalProperties.toMutableMap() + } + + /** Tiers for rating based on total usage quantities into the specified tier */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** Tiers for rating based on total usage quantities into the specified tier */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** Tiers for rating based on total usage quantities into the specified tier */ + 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) + } + + fun build(): TieredConfigModel = + TieredConfigModel( + checkRequired("tiers", tiers).map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + @NoAutoDetect + class Tier + @JsonCreator + private constructor( + @JsonProperty("first_unit") + @ExcludeMissing + private val firstUnit: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + private val unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("last_unit") + @ExcludeMissing + private val lastUnit: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** Inclusive tier starting value */ + fun firstUnit(): Double = firstUnit.getRequired("first_unit") + + /** Amount per unit */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** Exclusive tier ending value. If null, this is treated as the last tier */ + fun lastUnit(): Optional = Optional.ofNullable(lastUnit.getNullable("last_unit")) + + /** Inclusive tier starting value */ + @JsonProperty("first_unit") @ExcludeMissing fun _firstUnit(): JsonField = firstUnit + + /** Amount per unit */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount + + /** Exclusive tier ending value. If null, this is treated as the last tier */ + @JsonProperty("last_unit") @ExcludeMissing fun _lastUnit(): JsonField = lastUnit + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + firstUnit() + unitAmount() + lastUnit() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tier]. + * + * The following fields are required: + * ```java + * .firstUnit() + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var firstUnit: JsonField? = null + private var unitAmount: JsonField? = null + private var lastUnit: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + firstUnit = tier.firstUnit + unitAmount = tier.unitAmount + lastUnit = tier.lastUnit + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** Inclusive tier starting value */ + fun firstUnit(firstUnit: Double) = firstUnit(JsonField.of(firstUnit)) + + /** Inclusive tier starting value */ + fun firstUnit(firstUnit: JsonField) = apply { this.firstUnit = firstUnit } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** Amount per unit */ + fun unitAmount(unitAmount: JsonField) = apply { this.unitAmount = unitAmount } + + /** Exclusive tier ending value. If null, this is treated as the last tier */ + fun lastUnit(lastUnit: Double?) = lastUnit(JsonField.ofNullable(lastUnit)) + + /** Exclusive tier ending value. If null, this is treated as the last tier */ + fun lastUnit(lastUnit: Double) = lastUnit(lastUnit as Double?) + + /** Exclusive tier ending value. If null, this is treated as the last tier */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun lastUnit(lastUnit: Optional) = lastUnit(lastUnit.orElse(null) as Double?) + + /** Exclusive tier ending value. If null, this is treated as the last tier */ + fun lastUnit(lastUnit: JsonField) = apply { this.lastUnit = lastUnit } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): Tier = + Tier( + checkRequired("firstUnit", firstUnit), + checkRequired("unitAmount", unitAmount), + lastUnit, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Tier && firstUnit == other.firstUnit && unitAmount == other.unitAmount && lastUnit == other.lastUnit && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(firstUnit, unitAmount, lastUnit, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{firstUnit=$firstUnit, unitAmount=$unitAmount, lastUnit=$lastUnit, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TieredConfigModel && tiers == other.tiers && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(tiers, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredConfigModel{tiers=$tiers, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/TopLevelPingParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/TopLevelPingParams.kt index 0127c0e8a..55a571312 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/TopLevelPingParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/TopLevelPingParams.kt @@ -35,6 +35,7 @@ private constructor( @JvmStatic fun none(): TopLevelPingParams = builder().build() + /** Returns a mutable builder for constructing an instance of [TopLevelPingParams]. */ @JvmStatic fun builder() = Builder() } 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 f1c0896ae..41013e071 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 @@ -49,6 +49,14 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [TopLevelPingResponse]. + * + * The following fields are required: + * ```java + * .response() + * ``` + */ @JvmStatic fun builder() = Builder() } 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/TopUpModel.kt similarity index 92% rename from orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdResponse.kt rename to orb-java-core/src/main/kotlin/com/withorb/api/models/TopUpModel.kt index f33c11a00..c78d13c4e 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/TopUpModel.kt @@ -20,7 +20,7 @@ import java.util.Objects import java.util.Optional @NoAutoDetect -class CustomerCreditTopUpListByExternalIdResponse +class TopUpModel @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @@ -128,7 +128,7 @@ private constructor( private var validated: Boolean = false - fun validate(): CustomerCreditTopUpListByExternalIdResponse = apply { + fun validate(): TopUpModel = apply { if (validated) { return@apply } @@ -148,10 +148,23 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [TopUpModel]. + * + * The following fields are required: + * ```java + * .id() + * .amount() + * .currency() + * .invoiceSettings() + * .perUnitCostBasis() + * .threshold() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [CustomerCreditTopUpListByExternalIdResponse]. */ + /** A builder for [TopUpModel]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -165,19 +178,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - customerCreditTopUpListByExternalIdResponse: CustomerCreditTopUpListByExternalIdResponse - ) = apply { - id = customerCreditTopUpListByExternalIdResponse.id - amount = customerCreditTopUpListByExternalIdResponse.amount - currency = customerCreditTopUpListByExternalIdResponse.currency - invoiceSettings = customerCreditTopUpListByExternalIdResponse.invoiceSettings - perUnitCostBasis = customerCreditTopUpListByExternalIdResponse.perUnitCostBasis - threshold = customerCreditTopUpListByExternalIdResponse.threshold - expiresAfter = customerCreditTopUpListByExternalIdResponse.expiresAfter - expiresAfterUnit = customerCreditTopUpListByExternalIdResponse.expiresAfterUnit - additionalProperties = - customerCreditTopUpListByExternalIdResponse.additionalProperties.toMutableMap() + internal fun from(topUpModel: TopUpModel) = apply { + id = topUpModel.id + amount = topUpModel.amount + currency = topUpModel.currency + invoiceSettings = topUpModel.invoiceSettings + perUnitCostBasis = topUpModel.perUnitCostBasis + threshold = topUpModel.threshold + expiresAfter = topUpModel.expiresAfter + expiresAfterUnit = topUpModel.expiresAfterUnit + additionalProperties = topUpModel.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -290,8 +300,8 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): CustomerCreditTopUpListByExternalIdResponse = - CustomerCreditTopUpListByExternalIdResponse( + fun build(): TopUpModel = + TopUpModel( checkRequired("id", id), checkRequired("amount", amount), checkRequired("currency", currency), @@ -394,6 +404,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [InvoiceSettings]. + * + * The following fields are required: + * ```java + * .autoCollection() + * .netTerms() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -620,7 +639,7 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditTopUpListByExternalIdResponse && id == other.id && amount == other.amount && currency == other.currency && invoiceSettings == other.invoiceSettings && perUnitCostBasis == other.perUnitCostBasis && threshold == other.threshold && expiresAfter == other.expiresAfter && expiresAfterUnit == other.expiresAfterUnit && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TopUpModel && id == other.id && amount == other.amount && currency == other.currency && invoiceSettings == other.invoiceSettings && perUnitCostBasis == other.perUnitCostBasis && threshold == other.threshold && expiresAfter == other.expiresAfter && expiresAfterUnit == other.expiresAfterUnit && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -630,5 +649,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CustomerCreditTopUpListByExternalIdResponse{id=$id, amount=$amount, currency=$currency, invoiceSettings=$invoiceSettings, perUnitCostBasis=$perUnitCostBasis, threshold=$threshold, expiresAfter=$expiresAfter, expiresAfterUnit=$expiresAfterUnit, additionalProperties=$additionalProperties}" + "TopUpModel{id=$id, amount=$amount, currency=$currency, invoiceSettings=$invoiceSettings, perUnitCostBasis=$perUnitCostBasis, threshold=$threshold, expiresAfter=$expiresAfter, expiresAfterUnit=$expiresAfterUnit, additionalProperties=$additionalProperties}" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/TopUpsModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/TopUpsModel.kt new file mode 100644 index 000000000..77a16a4f6 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/TopUpsModel.kt @@ -0,0 +1,153 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects + +@NoAutoDetect +class TopUpsModel +@JsonCreator +private constructor( + @JsonProperty("data") + @ExcludeMissing + private val data: JsonField> = JsonMissing.of(), + @JsonProperty("pagination_metadata") + @ExcludeMissing + private val paginationMetadata: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun data(): List = data.getRequired("data") + + fun paginationMetadata(): PaginationMetadata = + paginationMetadata.getRequired("pagination_metadata") + + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data + + @JsonProperty("pagination_metadata") + @ExcludeMissing + fun _paginationMetadata(): JsonField = paginationMetadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): TopUpsModel = apply { + if (validated) { + return@apply + } + + data().forEach { it.validate() } + paginationMetadata().validate() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TopUpsModel]. + * + * The following fields are required: + * ```java + * .data() + * .paginationMetadata() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TopUpsModel]. */ + class Builder internal constructor() { + + private var data: JsonField>? = null + private var paginationMetadata: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(topUpsModel: TopUpsModel) = apply { + data = topUpsModel.data.map { it.toMutableList() } + paginationMetadata = topUpsModel.paginationMetadata + additionalProperties = topUpsModel.additionalProperties.toMutableMap() + } + + fun data(data: List) = data(JsonField.of(data)) + + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + fun addData(data: TopUpModel) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) + } + } + + fun paginationMetadata(paginationMetadata: PaginationMetadata) = + paginationMetadata(JsonField.of(paginationMetadata)) + + 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) + } + + fun build(): TopUpsModel = + TopUpsModel( + checkRequired("data", data).map { it.toImmutable() }, + checkRequired("paginationMetadata", paginationMetadata), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TopUpsModel && data == other.data && paginationMetadata == other.paginationMetadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(data, paginationMetadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TopUpsModel{data=$data, paginationMetadata=$paginationMetadata, additionalProperties=$additionalProperties}" +} 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 d4f652b19..2742d2b55 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 @@ -12,6 +12,7 @@ import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect +import com.withorb.api.core.checkKnown import com.withorb.api.core.checkRequired import com.withorb.api.core.immutableEmptyMap import com.withorb.api.core.toImmutable @@ -106,6 +107,15 @@ private constructor( companion object { + /** + * Returns a mutable builder for constructing an instance of [TrialDiscount]. + * + * The following fields are required: + * ```java + * .appliesToPriceIds() + * .discountType() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -150,14 +160,8 @@ private constructor( */ fun addAppliesToPriceId(appliesToPriceId: String) = apply { appliesToPriceIds = - (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { - asKnown() - .orElseThrow { - IllegalStateException( - "Field was set to non-list type: ${javaClass.simpleName}" - ) - } - .add(appliesToPriceId) + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/TrialDiscountModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/TrialDiscountModel.kt new file mode 100644 index 000000000..7b310d7d8 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/TrialDiscountModel.kt @@ -0,0 +1,351 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class TrialDiscountModel +@JsonCreator +private constructor( + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("discount_type") + @ExcludeMissing + private val discountType: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + private val reason: JsonField = JsonMissing.of(), + @JsonProperty("trial_amount_discount") + @ExcludeMissing + private val trialAmountDiscount: JsonField = JsonMissing.of(), + @JsonProperty("trial_percentage_discount") + @ExcludeMissing + private val trialPercentageDiscount: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** + * List of price_ids that this discount applies to. For plan/plan phase discounts, this can be a + * subset of prices. + */ + fun appliesToPriceIds(): List = appliesToPriceIds.getRequired("applies_to_price_ids") + + fun discountType(): DiscountType = discountType.getRequired("discount_type") + + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + /** Only available if discount_type is `trial` */ + fun trialAmountDiscount(): Optional = + Optional.ofNullable(trialAmountDiscount.getNullable("trial_amount_discount")) + + /** Only available if discount_type is `trial` */ + fun trialPercentageDiscount(): Optional = + Optional.ofNullable(trialPercentageDiscount.getNullable("trial_percentage_discount")) + + /** + * List of price_ids that this discount applies to. For plan/plan phase discounts, this can be a + * subset of prices. + */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType + + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + + /** Only available if discount_type is `trial` */ + @JsonProperty("trial_amount_discount") + @ExcludeMissing + fun _trialAmountDiscount(): JsonField = trialAmountDiscount + + /** Only available if discount_type is `trial` */ + @JsonProperty("trial_percentage_discount") + @ExcludeMissing + fun _trialPercentageDiscount(): JsonField = trialPercentageDiscount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): TrialDiscountModel = apply { + if (validated) { + return@apply + } + + appliesToPriceIds() + discountType() + reason() + trialAmountDiscount() + trialPercentageDiscount() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TrialDiscountModel]. + * + * The following fields are required: + * ```java + * .appliesToPriceIds() + * .discountType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TrialDiscountModel]. */ + class Builder internal constructor() { + + private var appliesToPriceIds: JsonField>? = null + private var discountType: JsonField? = null + private var reason: JsonField = JsonMissing.of() + private var trialAmountDiscount: JsonField = JsonMissing.of() + private var trialPercentageDiscount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(trialDiscountModel: TrialDiscountModel) = apply { + appliesToPriceIds = trialDiscountModel.appliesToPriceIds.map { it.toMutableList() } + discountType = trialDiscountModel.discountType + reason = trialDiscountModel.reason + trialAmountDiscount = trialDiscountModel.trialAmountDiscount + trialPercentageDiscount = trialDiscountModel.trialPercentageDiscount + additionalProperties = trialDiscountModel.additionalProperties.toMutableMap() + } + + /** + * List of price_ids that this discount applies to. For plan/plan phase discounts, this can + * be a subset of prices. + */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** + * List of price_ids that this discount applies to. For plan/plan phase discounts, this can + * be a subset of prices. + */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this discount applies to. For plan/plan phase discounts, this can + * be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) + + fun discountType(discountType: JsonField) = apply { + this.discountType = discountType + } + + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + fun reason(reason: Optional) = reason(reason.orElse(null)) + + fun reason(reason: JsonField) = apply { this.reason = reason } + + /** Only available if discount_type is `trial` */ + fun trialAmountDiscount(trialAmountDiscount: String?) = + trialAmountDiscount(JsonField.ofNullable(trialAmountDiscount)) + + /** Only available if discount_type is `trial` */ + fun trialAmountDiscount(trialAmountDiscount: Optional) = + trialAmountDiscount(trialAmountDiscount.orElse(null)) + + /** Only available if discount_type is `trial` */ + fun trialAmountDiscount(trialAmountDiscount: JsonField) = apply { + this.trialAmountDiscount = trialAmountDiscount + } + + /** Only available if discount_type is `trial` */ + fun trialPercentageDiscount(trialPercentageDiscount: Double?) = + trialPercentageDiscount(JsonField.ofNullable(trialPercentageDiscount)) + + /** Only available if discount_type is `trial` */ + fun trialPercentageDiscount(trialPercentageDiscount: Double) = + trialPercentageDiscount(trialPercentageDiscount as Double?) + + /** Only available if discount_type is `trial` */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun trialPercentageDiscount(trialPercentageDiscount: Optional) = + trialPercentageDiscount(trialPercentageDiscount.orElse(null) as Double?) + + /** Only available if discount_type is `trial` */ + fun trialPercentageDiscount(trialPercentageDiscount: JsonField) = apply { + this.trialPercentageDiscount = trialPercentageDiscount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): TrialDiscountModel = + TrialDiscountModel( + checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, + checkRequired("discountType", discountType), + reason, + trialAmountDiscount, + trialPercentageDiscount, + additionalProperties.toImmutable(), + ) + } + + class DiscountType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TRIAL = of("trial") + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + /** An enum containing [DiscountType]'s known values. */ + enum class Known { + TRIAL + } + + /** + * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [DiscountType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TRIAL, + /** + * An enum member indicating that [DiscountType] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TRIAL -> Value.TRIAL + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + TRIAL -> Known.TRIAL + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TrialDiscountModel && appliesToPriceIds == other.appliesToPriceIds && discountType == other.discountType && reason == other.reason && trialAmountDiscount == other.trialAmountDiscount && trialPercentageDiscount == other.trialPercentageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, discountType, reason, trialAmountDiscount, trialPercentageDiscount, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TrialDiscountModel{appliesToPriceIds=$appliesToPriceIds, discountType=$discountType, reason=$reason, trialAmountDiscount=$trialAmountDiscount, trialPercentageDiscount=$trialPercentageDiscount, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/UnitConfigModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/UnitConfigModel.kt new file mode 100644 index 000000000..cedefd85c --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/UnitConfigModel.kt @@ -0,0 +1,125 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects + +@NoAutoDetect +class UnitConfigModel +@JsonCreator +private constructor( + @JsonProperty("unit_amount") + @ExcludeMissing + private val unitAmount: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** Rate per unit of usage */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** Rate per unit of usage */ + @JsonProperty("unit_amount") @ExcludeMissing fun _unitAmount(): JsonField = unitAmount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): UnitConfigModel = apply { + if (validated) { + return@apply + } + + unitAmount() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnitConfigModel]. + * + * The following fields are required: + * ```java + * .unitAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnitConfigModel]. */ + class Builder internal constructor() { + + private var unitAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unitConfigModel: UnitConfigModel) = apply { + unitAmount = unitConfigModel.unitAmount + additionalProperties = unitConfigModel.additionalProperties.toMutableMap() + } + + /** Rate per unit of usage */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** Rate per unit of usage */ + 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 build(): UnitConfigModel = + UnitConfigModel( + checkRequired("unitAmount", unitAmount), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is UnitConfigModel && unitAmount == other.unitAmount && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(unitAmount, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnitConfigModel{unitAmount=$unitAmount, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/UpdatePriceRequestParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/UpdatePriceRequestParams.kt new file mode 100644 index 000000000..4c637bd03 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/UpdatePriceRequestParams.kt @@ -0,0 +1,222 @@ +// 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.NoAutoDetect +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class UpdatePriceRequestParams +@JsonCreator +private constructor( + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by setting + * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to + * `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * User-specified key/value pairs for the resource. 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("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): UpdatePriceRequestParams = apply { + if (validated) { + return@apply + } + + metadata().ifPresent { it.validate() } + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UpdatePriceRequestParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UpdatePriceRequestParams]. */ + class Builder internal constructor() { + + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(updatePriceRequestParams: UpdatePriceRequestParams) = apply { + metadata = updatePriceRequestParams.metadata + additionalProperties = updatePriceRequestParams.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`. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(metadata: Optional) = metadata(metadata.orElse(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: 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) + } + + fun build(): UpdatePriceRequestParams = + UpdatePriceRequestParams(metadata, additionalProperties.toImmutable()) + } + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by setting + * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to + * `null`. + */ + @NoAutoDetect + class Metadata + @JsonCreator + private constructor( + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap() + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + 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) + } + + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is UpdatePriceRequestParams && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UpdatePriceRequestParams{metadata=$metadata, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/UsageDiscountIntervalModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/UsageDiscountIntervalModel.kt new file mode 100644 index 000000000..81922ee4f --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/UsageDiscountIntervalModel.kt @@ -0,0 +1,374 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkKnown +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import com.withorb.api.errors.OrbInvalidDataException +import java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +@NoAutoDetect +class UsageDiscountIntervalModel +@JsonCreator +private constructor( + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + private val appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), + @JsonProperty("discount_type") + @ExcludeMissing + private val discountType: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + private val endDate: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + private val startDate: JsonField = JsonMissing.of(), + @JsonProperty("usage_discount") + @ExcludeMissing + private val usageDiscount: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + /** The price ids that this discount interval applies to. */ + fun appliesToPriceIds(): List = appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The price interval ids that this discount interval applies to. */ + fun appliesToPriceIntervalIds(): List = + appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") + + fun discountType(): DiscountType = discountType.getRequired("discount_type") + + /** The end date of the discount interval. */ + fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) + + /** The start date of the discount interval. */ + fun startDate(): OffsetDateTime = startDate.getRequired("start_date") + + /** + * Only available if discount_type is `usage`. Number of usage units that this discount is for + */ + fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") + + /** The price ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds + + /** The price interval ids that this discount interval applies to. */ + @JsonProperty("applies_to_price_interval_ids") + @ExcludeMissing + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds + + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType + + /** The end date of the discount interval. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + /** The start date of the discount interval. */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + /** + * Only available if discount_type is `usage`. Number of usage units that this discount is for + */ + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): UsageDiscountIntervalModel = apply { + if (validated) { + return@apply + } + + appliesToPriceIds() + appliesToPriceIntervalIds() + discountType() + endDate() + startDate() + usageDiscount() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UsageDiscountIntervalModel]. + * + * The following fields are required: + * ```java + * .appliesToPriceIds() + * .appliesToPriceIntervalIds() + * .discountType() + * .endDate() + * .startDate() + * .usageDiscount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UsageDiscountIntervalModel]. */ + class Builder internal constructor() { + + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null + private var usageDiscount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(usageDiscountIntervalModel: UsageDiscountIntervalModel) = apply { + appliesToPriceIds = + usageDiscountIntervalModel.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + usageDiscountIntervalModel.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = usageDiscountIntervalModel.discountType + endDate = usageDiscountIntervalModel.endDate + startDate = usageDiscountIntervalModel.startDate + usageDiscount = usageDiscountIntervalModel.usageDiscount + additionalProperties = usageDiscountIntervalModel.additionalProperties.toMutableMap() + } + + /** The price ids that this discount interval applies to. */ + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The price ids that this discount interval applies to. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this discount interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIds", it).add(appliesToPriceId) + } + } + + /** The price interval ids that this discount interval applies to. */ + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = + appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) + + /** The price interval ids that this discount interval applies to. */ + fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { + this.appliesToPriceIntervalIds = appliesToPriceIntervalIds.map { it.toMutableList() } + } + + /** The price interval ids that this discount interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).also { + checkKnown("appliesToPriceIntervalIds", it).add(appliesToPriceIntervalId) + } + } + + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) + + fun discountType(discountType: JsonField) = apply { + this.discountType = discountType + } + + /** The end date of the discount interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the discount interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) + + /** The end date of the discount interval. */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** The start date of the discount interval. */ + fun startDate(startDate: OffsetDateTime) = startDate(JsonField.of(startDate)) + + /** The start date of the discount interval. */ + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + /** + * Only available if discount_type is `usage`. Number of usage units that this discount is + * for + */ + fun usageDiscount(usageDiscount: Double) = usageDiscount(JsonField.of(usageDiscount)) + + /** + * Only available if discount_type is `usage`. Number of usage units that this discount is + * for + */ + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): UsageDiscountIntervalModel = + UsageDiscountIntervalModel( + checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, + checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { + it.toImmutable() + }, + checkRequired("discountType", discountType), + checkRequired("endDate", endDate), + checkRequired("startDate", startDate), + checkRequired("usageDiscount", usageDiscount), + additionalProperties.toImmutable(), + ) + } + + class DiscountType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USAGE = of("usage") + + @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) + } + + /** An enum containing [DiscountType]'s known values. */ + enum class Known { + USAGE + } + + /** + * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [DiscountType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USAGE, + /** + * An enum member indicating that [DiscountType] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USAGE -> Value.USAGE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OrbInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + USAGE -> Known.USAGE + else -> throw OrbInvalidDataException("Unknown DiscountType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OrbInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is UsageDiscountIntervalModel && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(appliesToPriceIds, appliesToPriceIntervalIds, discountType, endDate, startDate, usageDiscount, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UsageDiscountIntervalModel{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/UsageModel.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/UsageModel.kt new file mode 100644 index 000000000..b401b5eea --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/UsageModel.kt @@ -0,0 +1,163 @@ +// 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.NoAutoDetect +import com.withorb.api.core.checkRequired +import com.withorb.api.core.immutableEmptyMap +import com.withorb.api.core.toImmutable +import java.time.OffsetDateTime +import java.util.Objects + +@NoAutoDetect +class UsageModel +@JsonCreator +private constructor( + @JsonProperty("quantity") + @ExcludeMissing + private val quantity: JsonField = JsonMissing.of(), + @JsonProperty("timeframe_end") + @ExcludeMissing + private val timeframeEnd: JsonField = JsonMissing.of(), + @JsonProperty("timeframe_start") + @ExcludeMissing + private val timeframeStart: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), +) { + + fun quantity(): Double = quantity.getRequired("quantity") + + fun timeframeEnd(): OffsetDateTime = timeframeEnd.getRequired("timeframe_end") + + fun timeframeStart(): OffsetDateTime = timeframeStart.getRequired("timeframe_start") + + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity + + @JsonProperty("timeframe_end") + @ExcludeMissing + fun _timeframeEnd(): JsonField = timeframeEnd + + @JsonProperty("timeframe_start") + @ExcludeMissing + fun _timeframeStart(): JsonField = timeframeStart + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): UsageModel = apply { + if (validated) { + return@apply + } + + quantity() + timeframeEnd() + timeframeStart() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UsageModel]. + * + * The following fields are required: + * ```java + * .quantity() + * .timeframeEnd() + * .timeframeStart() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UsageModel]. */ + class Builder internal constructor() { + + private var quantity: JsonField? = null + private var timeframeEnd: JsonField? = null + private var timeframeStart: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(usageModel: UsageModel) = apply { + quantity = usageModel.quantity + timeframeEnd = usageModel.timeframeEnd + timeframeStart = usageModel.timeframeStart + additionalProperties = usageModel.additionalProperties.toMutableMap() + } + + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + fun timeframeEnd(timeframeEnd: OffsetDateTime) = timeframeEnd(JsonField.of(timeframeEnd)) + + fun timeframeEnd(timeframeEnd: JsonField) = apply { + this.timeframeEnd = timeframeEnd + } + + fun timeframeStart(timeframeStart: OffsetDateTime) = + timeframeStart(JsonField.of(timeframeStart)) + + fun timeframeStart(timeframeStart: JsonField) = apply { + this.timeframeStart = timeframeStart + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun 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 build(): UsageModel = + UsageModel( + checkRequired("quantity", quantity), + checkRequired("timeframeEnd", timeframeEnd), + checkRequired("timeframeStart", timeframeStart), + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is UsageModel && quantity == other.quantity && timeframeEnd == other.timeframeEnd && timeframeStart == other.timeframeStart && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(quantity, timeframeEnd, timeframeStart, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UsageModel{quantity=$quantity, timeframeEnd=$timeframeEnd, timeframeStart=$timeframeStart, additionalProperties=$additionalProperties}" +} 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 e4a5fc0cc..b1ab00b4e 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 @@ -4,8 +4,9 @@ package com.withorb.api.services.async +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions -import com.withorb.api.models.Alert +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.AlertCreateForCustomerParams import com.withorb.api.models.AlertCreateForExternalCustomerParams import com.withorb.api.models.AlertCreateForSubscriptionParams @@ -13,25 +14,31 @@ import com.withorb.api.models.AlertDisableParams import com.withorb.api.models.AlertEnableParams import com.withorb.api.models.AlertListPageAsync import com.withorb.api.models.AlertListParams +import com.withorb.api.models.AlertModel import com.withorb.api.models.AlertRetrieveParams import com.withorb.api.models.AlertUpdateParams import java.util.concurrent.CompletableFuture interface AlertServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** This endpoint retrieves an alert by its ID. */ @JvmOverloads fun retrieve( params: AlertRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** This endpoint updates the thresholds of an alert. */ @JvmOverloads fun update( params: AlertUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This endpoint returns a list of alerts within Orb. @@ -76,7 +83,7 @@ interface AlertServiceAsync { fun createForCustomer( params: AlertCreateForCustomerParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This endpoint creates a new alert to monitor a customer's credit balance. There are three @@ -90,7 +97,7 @@ interface AlertServiceAsync { fun createForExternalCustomer( params: AlertCreateForExternalCustomerParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This endpoint is used to create alerts at the subscription level. @@ -108,7 +115,7 @@ interface AlertServiceAsync { fun createForSubscription( params: AlertCreateForSubscriptionParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This endpoint allows you to disable an alert. To disable a plan-level alert for a specific @@ -119,7 +126,7 @@ interface AlertServiceAsync { fun disable( params: AlertDisableParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This endpoint allows you to enable an alert. To enable a plan-level alert for a specific @@ -130,5 +137,108 @@ interface AlertServiceAsync { fun enable( params: AlertEnableParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture + + /** A view of [AlertServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /alerts/{alert_id}`, but is otherwise the same as + * [AlertServiceAsync.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: AlertRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `put /alerts/{alert_configuration_id}`, but is otherwise + * the same as [AlertServiceAsync.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: AlertUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /alerts`, but is otherwise the same as + * [AlertServiceAsync.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: AlertListParams = AlertListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /alerts`, but is otherwise the same as + * [AlertServiceAsync.list]. + */ + @MustBeClosed + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(AlertListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /alerts/customer_id/{customer_id}`, but is + * otherwise the same as [AlertServiceAsync.createForCustomer]. + */ + @JvmOverloads + @MustBeClosed + fun createForCustomer( + params: AlertCreateForCustomerParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post + * /alerts/external_customer_id/{external_customer_id}`, but is otherwise the same as + * [AlertServiceAsync.createForExternalCustomer]. + */ + @JvmOverloads + @MustBeClosed + fun createForExternalCustomer( + params: AlertCreateForExternalCustomerParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /alerts/subscription_id/{subscription_id}`, but is + * otherwise the same as [AlertServiceAsync.createForSubscription]. + */ + @JvmOverloads + @MustBeClosed + fun createForSubscription( + params: AlertCreateForSubscriptionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /alerts/{alert_configuration_id}/disable`, but is + * otherwise the same as [AlertServiceAsync.disable]. + */ + @JvmOverloads + @MustBeClosed + fun disable( + params: AlertDisableParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /alerts/{alert_configuration_id}/enable`, but is + * otherwise the same as [AlertServiceAsync.enable]. + */ + @JvmOverloads + @MustBeClosed + fun enable( + params: AlertEnableParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } 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 f4841a10c..98f839222 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 @@ -10,10 +10,11 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest import com.withorb.api.core.http.HttpResponse.Handler -import com.withorb.api.core.json +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.errors.OrbError -import com.withorb.api.models.Alert import com.withorb.api.models.AlertCreateForCustomerParams import com.withorb.api.models.AlertCreateForExternalCustomerParams import com.withorb.api.models.AlertCreateForSubscriptionParams @@ -21,6 +22,7 @@ import com.withorb.api.models.AlertDisableParams import com.withorb.api.models.AlertEnableParams import com.withorb.api.models.AlertListPageAsync import com.withorb.api.models.AlertListParams +import com.withorb.api.models.AlertModel import com.withorb.api.models.AlertRetrieveParams import com.withorb.api.models.AlertUpdateParams import java.util.concurrent.CompletableFuture @@ -28,272 +30,317 @@ import java.util.concurrent.CompletableFuture class AlertServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : AlertServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: AlertServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): AlertServiceAsync.WithRawResponse = withRawResponse - /** This endpoint retrieves an alert by its ID. */ override fun retrieve( params: AlertRetrieveParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("alerts", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } + ): CompletableFuture = + // get /alerts/{alert_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** This endpoint updates the thresholds of an alert. */ override fun update( params: AlertUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("alerts", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } + ): CompletableFuture = + // put /alerts/{alert_configuration_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * This endpoint returns a list of alerts within Orb. - * - * The request must specify one of `customer_id`, `external_customer_id`, or `subscription_id`. - * - * If querying by subscripion_id, the endpoint will return the subscription level alerts as well - * as the plan level alerts associated with the subscription. - * - * The list of alerts is ordered starting from the most recently created alert. This endpoint - * follows Orb's [standardized pagination format](/api-reference/pagination). - */ override fun list( params: AlertListParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("alerts") - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - .let { AlertListPageAsync.of(this, params, it) } - } - } + ): CompletableFuture = + // get /alerts + withRawResponse().list(params, requestOptions).thenApply { it.parse() } - private val createForCustomerHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint creates a new alert to monitor a customer's credit balance. There are three - * types of alerts that can be scoped to customers: `credit_balance_depleted`, - * `credit_balance_dropped`, and `credit_balance_recovered`. Customers can have a maximum of one - * of each type of alert per [credit balance currency](/product-catalog/prepurchase). - * `credit_balance_dropped` alerts require a list of thresholds to be provided while - * `credit_balance_depleted` and `credit_balance_recovered` alerts do not require thresholds. - */ override fun createForCustomer( params: AlertCreateForCustomerParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("alerts", "customer_id", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { createForCustomerHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } + ): CompletableFuture = + // post /alerts/customer_id/{customer_id} + withRawResponse().createForCustomer(params, requestOptions).thenApply { it.parse() } - private val createForExternalCustomerHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint creates a new alert to monitor a customer's credit balance. There are three - * types of alerts that can be scoped to customers: `credit_balance_depleted`, - * `credit_balance_dropped`, and `credit_balance_recovered`. Customers can have a maximum of one - * of each type of alert per [credit balance currency](/product-catalog/prepurchase). - * `credit_balance_dropped` alerts require a list of thresholds to be provided while - * `credit_balance_depleted` and `credit_balance_recovered` alerts do not require thresholds. - */ override fun createForExternalCustomer( params: AlertCreateForExternalCustomerParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("alerts", "external_customer_id", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { createForExternalCustomerHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } + ): CompletableFuture = + // post /alerts/external_customer_id/{external_customer_id} + withRawResponse().createForExternalCustomer(params, requestOptions).thenApply { it.parse() } - private val createForSubscriptionHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint is used to create alerts at the subscription level. - * - * Subscription level alerts can be one of two types: `usage_exceeded` or `cost_exceeded`. A - * `usage_exceeded` alert is scoped to a particular metric and is triggered when the usage of - * that metric exceeds predefined thresholds during the current billing cycle. A `cost_exceeded` - * alert is triggered when the total amount due during the current billing cycle surpasses - * predefined thresholds. `cost_exceeded` alerts do not include burndown of pre-purchase - * credits. Each subscription can have one `cost_exceeded` alert and one `usage_exceeded` alert - * per metric that is a part of the subscription. Alerts are triggered based on usage or cost - * conditions met during the current billing cycle. - */ override fun createForSubscription( params: AlertCreateForSubscriptionParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("alerts", "subscription_id", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { createForSubscriptionHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } + ): CompletableFuture = + // post /alerts/subscription_id/{subscription_id} + withRawResponse().createForSubscription(params, requestOptions).thenApply { it.parse() } - private val disableHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint allows you to disable an alert. To disable a plan-level alert for a specific - * subscription, you must include the `subscription_id`. The `subscription_id` is not required - * for customer or subscription level alerts. - */ override fun disable( params: AlertDisableParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("alerts", params.getPathParam(0), "disable") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { disableHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } + ): CompletableFuture = + // post /alerts/{alert_configuration_id}/disable + withRawResponse().disable(params, requestOptions).thenApply { it.parse() } - private val enableHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint allows you to enable an alert. To enable a plan-level alert for a specific - * subscription, you must include the `subscription_id`. The `subscription_id` is not required - * for customer or subscription level alerts. - */ override fun enable( params: AlertEnableParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("alerts", params.getPathParam(0), "enable") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { enableHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): CompletableFuture = + // post /alerts/{alert_configuration_id}/enable + withRawResponse().enable(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AlertServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: AlertRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("alerts", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: AlertUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("alerts", params.getPathParam(0)) + .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 -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: AlertListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("alerts") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + AlertListPageAsync.of( + AlertServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } + } + + private val createForCustomerHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun createForCustomer( + params: AlertCreateForCustomerParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("alerts", "customer_id", params.getPathParam(0)) + .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 -> + response.parseable { + response + .use { createForCustomerHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val createForExternalCustomerHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun createForExternalCustomer( + params: AlertCreateForExternalCustomerParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("alerts", "external_customer_id", params.getPathParam(0)) + .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 -> + response.parseable { + response + .use { createForExternalCustomerHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val createForSubscriptionHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun createForSubscription( + params: AlertCreateForSubscriptionParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("alerts", "subscription_id", params.getPathParam(0)) + .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 -> + response.parseable { + response + .use { createForSubscriptionHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val disableHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun disable( + params: AlertDisableParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("alerts", params.getPathParam(0), "disable") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { disableHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val enableHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun enable( + params: AlertEnableParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("alerts", params.getPathParam(0), "enable") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { enableHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } 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 891e9b0a2..53d3bff1c 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 @@ -4,18 +4,25 @@ package com.withorb.api.services.async +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions -import com.withorb.api.models.Coupon +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.CouponArchiveParams import com.withorb.api.models.CouponCreateParams import com.withorb.api.models.CouponFetchParams import com.withorb.api.models.CouponListPageAsync import com.withorb.api.models.CouponListParams +import com.withorb.api.models.CouponModel import com.withorb.api.services.async.coupons.SubscriptionServiceAsync import java.util.concurrent.CompletableFuture interface CouponServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + fun subscriptions(): SubscriptionServiceAsync /** @@ -26,7 +33,7 @@ interface CouponServiceAsync { fun create( params: CouponCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This endpoint returns a list of all coupons for an account in a list format. @@ -62,7 +69,7 @@ interface CouponServiceAsync { fun archive( params: CouponArchiveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This endpoint retrieves a coupon by its ID. To fetch coupons by their redemption code, use @@ -72,5 +79,67 @@ interface CouponServiceAsync { fun fetch( params: CouponFetchParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture + + /** + * A view of [CouponServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + fun subscriptions(): SubscriptionServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /coupons`, but is otherwise the same as + * [CouponServiceAsync.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: CouponCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /coupons`, but is otherwise the same as + * [CouponServiceAsync.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: CouponListParams = CouponListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /coupons`, but is otherwise the same as + * [CouponServiceAsync.list]. + */ + @MustBeClosed + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(CouponListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /coupons/{coupon_id}/archive`, but is otherwise the + * same as [CouponServiceAsync.archive]. + */ + @JvmOverloads + @MustBeClosed + fun archive( + params: CouponArchiveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /coupons/{coupon_id}`, but is otherwise the same as + * [CouponServiceAsync.fetch]. + */ + @JvmOverloads + @MustBeClosed + fun fetch( + params: CouponFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } 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 6703534b8..293795625 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 @@ -10,15 +10,17 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest import com.withorb.api.core.http.HttpResponse.Handler -import com.withorb.api.core.json +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.errors.OrbError -import com.withorb.api.models.Coupon import com.withorb.api.models.CouponArchiveParams import com.withorb.api.models.CouponCreateParams import com.withorb.api.models.CouponFetchParams import com.withorb.api.models.CouponListPageAsync import com.withorb.api.models.CouponListParams +import com.withorb.api.models.CouponModel import com.withorb.api.services.async.coupons.SubscriptionServiceAsync import com.withorb.api.services.async.coupons.SubscriptionServiceAsyncImpl import java.util.concurrent.CompletableFuture @@ -26,140 +28,181 @@ import java.util.concurrent.CompletableFuture class CouponServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CouponServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: CouponServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } private val subscriptions: SubscriptionServiceAsync by lazy { SubscriptionServiceAsyncImpl(clientOptions) } - override fun subscriptions(): SubscriptionServiceAsync = subscriptions + override fun withRawResponse(): CouponServiceAsync.WithRawResponse = withRawResponse - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun subscriptions(): SubscriptionServiceAsync = subscriptions - /** - * This endpoint allows the creation of coupons, which can then be redeemed at subscription - * creation or plan change. - */ override fun create( params: CouponCreateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("coupons") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } + ): CompletableFuture = + // post /coupons + withRawResponse().create(params, requestOptions).thenApply { it.parse() } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * This endpoint returns a list of all coupons for an account in a list format. - * - * 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. - */ override fun list( params: CouponListParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("coupons") - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - .let { CouponListPageAsync.of(this, params, it) } - } - } + ): CompletableFuture = + // get /coupons + withRawResponse().list(params, requestOptions).thenApply { it.parse() } - private val archiveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint allows a coupon to be archived. Archived coupons can no longer be redeemed, and - * will be hidden from lists of active coupons. Additionally, once a coupon is archived, its - * redemption code can be reused for a different coupon. - */ override fun archive( params: CouponArchiveParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("coupons", params.getPathParam(0), "archive") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { archiveHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } + ): CompletableFuture = + // post /coupons/{coupon_id}/archive + withRawResponse().archive(params, requestOptions).thenApply { it.parse() } - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint retrieves a coupon by its ID. To fetch coupons by their redemption code, use - * the [List coupons](list-coupons) endpoint with the redemption_code parameter. - */ override fun fetch( params: CouponFetchParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("coupons", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): CompletableFuture = + // get /coupons/{coupon_id} + withRawResponse().fetch(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CouponServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val subscriptions: SubscriptionServiceAsync.WithRawResponse by lazy { + SubscriptionServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun subscriptions(): SubscriptionServiceAsync.WithRawResponse = subscriptions + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: CouponCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("coupons") + .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 -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: CouponListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("coupons") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + CouponListPageAsync.of( + CouponServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } + } + + private val archiveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun archive( + params: CouponArchiveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("coupons", params.getPathParam(0), "archive") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { archiveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetch( + params: CouponFetchParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("coupons", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { fetchHandler.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 994261843..cda45d3d6 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 @@ -4,22 +4,29 @@ package com.withorb.api.services.async +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions -import com.withorb.api.models.CreditNote +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.CreditNoteCreateParams import com.withorb.api.models.CreditNoteFetchParams import com.withorb.api.models.CreditNoteListPageAsync import com.withorb.api.models.CreditNoteListParams +import com.withorb.api.models.CreditNoteModel import java.util.concurrent.CompletableFuture interface CreditNoteServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** This endpoint is used to create a single [`Credit Note`](/invoicing/credit-notes). */ @JvmOverloads fun create( params: CreditNoteCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * Get a paginated list of CreditNotes. Users can also filter by customer_id, subscription_id, @@ -48,5 +55,55 @@ interface CreditNoteServiceAsync { fun fetch( params: CreditNoteFetchParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture + + /** + * A view of [CreditNoteServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /credit_notes`, but is otherwise the same as + * [CreditNoteServiceAsync.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: CreditNoteCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /credit_notes`, but is otherwise the same as + * [CreditNoteServiceAsync.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: CreditNoteListParams = CreditNoteListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /credit_notes`, but is otherwise the same as + * [CreditNoteServiceAsync.list]. + */ + @MustBeClosed + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(CreditNoteListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /credit_notes/{credit_note_id}`, but is otherwise + * the same as [CreditNoteServiceAsync.fetch]. + */ + @JvmOverloads + @MustBeClosed + fun fetch( + params: CreditNoteFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } 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 352382223..caaac4e7c 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 @@ -10,109 +10,147 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest import com.withorb.api.core.http.HttpResponse.Handler -import com.withorb.api.core.json +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.errors.OrbError -import com.withorb.api.models.CreditNote import com.withorb.api.models.CreditNoteCreateParams import com.withorb.api.models.CreditNoteFetchParams import com.withorb.api.models.CreditNoteListPageAsync import com.withorb.api.models.CreditNoteListParams +import com.withorb.api.models.CreditNoteModel import java.util.concurrent.CompletableFuture class CreditNoteServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CreditNoteServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: CreditNoteServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): CreditNoteServiceAsync.WithRawResponse = withRawResponse - /** This endpoint is used to create a single [`Credit Note`](/invoicing/credit-notes). */ override fun create( params: CreditNoteCreateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("credit_notes") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } + ): CompletableFuture = + // post /credit_notes + withRawResponse().create(params, requestOptions).thenApply { it.parse() } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * Get a paginated list of CreditNotes. Users can also filter by customer_id, subscription_id, - * or external_customer_id. The credit notes will be returned in reverse chronological order by - * `creation_time`. - */ override fun list( params: CreditNoteListParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("credit_notes") - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - .let { CreditNoteListPageAsync.of(this, params, it) } - } - } - - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // get /credit_notes + withRawResponse().list(params, requestOptions).thenApply { it.parse() } - /** - * This endpoint is used to fetch a single [`Credit Note`](/invoicing/credit-notes) given an - * identifier. - */ override fun fetch( params: CreditNoteFetchParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("credit_notes", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): CompletableFuture = + // get /credit_notes/{credit_note_id} + withRawResponse().fetch(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CreditNoteServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: CreditNoteCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("credit_notes") + .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 -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: CreditNoteListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("credit_notes") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + CreditNoteListPageAsync.of( + CreditNoteServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } + } + + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetch( + params: CreditNoteFetchParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("credit_notes", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } 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 92d65506e..e4c58fa27 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 @@ -4,14 +4,17 @@ package com.withorb.api.services.async +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions -import com.withorb.api.models.Customer +import com.withorb.api.core.http.HttpResponse +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.CustomerCreateParams import com.withorb.api.models.CustomerDeleteParams import com.withorb.api.models.CustomerFetchByExternalIdParams import com.withorb.api.models.CustomerFetchParams import com.withorb.api.models.CustomerListPageAsync import com.withorb.api.models.CustomerListParams +import com.withorb.api.models.CustomerModel import com.withorb.api.models.CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams import com.withorb.api.models.CustomerSyncPaymentMethodsFromGatewayParams import com.withorb.api.models.CustomerUpdateByExternalIdParams @@ -23,6 +26,11 @@ import java.util.concurrent.CompletableFuture interface CustomerServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + fun costs(): CostServiceAsync fun credits(): CreditServiceAsync @@ -46,7 +54,7 @@ interface CustomerServiceAsync { fun create( params: CustomerCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This endpoint can be used to update the `payment_provider`, `payment_provider_id`, `name`, @@ -58,7 +66,7 @@ interface CustomerServiceAsync { fun update( params: CustomerUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This endpoint returns a list of all customers for an account. The list of customers is @@ -115,7 +123,7 @@ interface CustomerServiceAsync { fun fetch( params: CustomerFetchParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This endpoint is used to fetch customer details given an `external_customer_id` (see @@ -128,7 +136,7 @@ interface CustomerServiceAsync { fun fetchByExternalId( params: CustomerFetchByExternalIdParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * Sync Orb's payment methods for the customer with their gateway. @@ -167,5 +175,130 @@ interface CustomerServiceAsync { fun updateByExternalId( params: CustomerUpdateByExternalIdParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture + + /** + * A view of [CustomerServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + fun costs(): CostServiceAsync.WithRawResponse + + fun credits(): CreditServiceAsync.WithRawResponse + + fun balanceTransactions(): BalanceTransactionServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /customers`, but is otherwise the same as + * [CustomerServiceAsync.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: CustomerCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `put /customers/{customer_id}`, but is otherwise the same + * as [CustomerServiceAsync.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: CustomerUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /customers`, but is otherwise the same as + * [CustomerServiceAsync.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: CustomerListParams = CustomerListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /customers`, but is otherwise the same as + * [CustomerServiceAsync.list]. + */ + @MustBeClosed + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(CustomerListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /customers/{customer_id}`, but is otherwise the + * same as [CustomerServiceAsync.delete]. + */ + @JvmOverloads + @MustBeClosed + fun delete( + params: CustomerDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * Returns a raw HTTP response for `get /customers/{customer_id}`, but is otherwise the same + * as [CustomerServiceAsync.fetch]. + */ + @JvmOverloads + @MustBeClosed + fun fetch( + params: CustomerFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get + * /customers/external_customer_id/{external_customer_id}`, but is otherwise the same as + * [CustomerServiceAsync.fetchByExternalId]. + */ + @JvmOverloads + @MustBeClosed + fun fetchByExternalId( + params: CustomerFetchByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post + * /customers/external_customer_id/{external_customer_id}/sync_payment_methods_from_gateway`, + * but is otherwise the same as [CustomerServiceAsync.syncPaymentMethodsFromGateway]. + */ + @JvmOverloads + @MustBeClosed + fun syncPaymentMethodsFromGateway( + params: CustomerSyncPaymentMethodsFromGatewayParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * Returns a raw HTTP response for `post + * /customers/{customer_id}/sync_payment_methods_from_gateway`, but is otherwise the same as + * [CustomerServiceAsync.syncPaymentMethodsFromGatewayByExternalCustomerId]. + */ + @JvmOverloads + @MustBeClosed + fun syncPaymentMethodsFromGatewayByExternalCustomerId( + params: CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * Returns a raw HTTP response for `put + * /customers/external_customer_id/{external_customer_id}`, but is otherwise the same as + * [CustomerServiceAsync.updateByExternalId]. + */ + @JvmOverloads + @MustBeClosed + fun updateByExternalId( + params: CustomerUpdateByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } 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 01a8f83aa..a3b6e76d2 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 @@ -10,17 +10,20 @@ import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler 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.json +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.errors.OrbError -import com.withorb.api.models.Customer import com.withorb.api.models.CustomerCreateParams import com.withorb.api.models.CustomerDeleteParams import com.withorb.api.models.CustomerFetchByExternalIdParams import com.withorb.api.models.CustomerFetchParams import com.withorb.api.models.CustomerListPageAsync import com.withorb.api.models.CustomerListParams +import com.withorb.api.models.CustomerModel import com.withorb.api.models.CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams import com.withorb.api.models.CustomerSyncPaymentMethodsFromGatewayParams import com.withorb.api.models.CustomerUpdateByExternalIdParams @@ -36,7 +39,9 @@ import java.util.concurrent.CompletableFuture class CustomerServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CustomerServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: CustomerServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } private val costs: CostServiceAsync by lazy { CostServiceAsyncImpl(clientOptions) } @@ -46,315 +51,367 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C BalanceTransactionServiceAsyncImpl(clientOptions) } + override fun withRawResponse(): CustomerServiceAsync.WithRawResponse = withRawResponse + override fun costs(): CostServiceAsync = costs override fun credits(): CreditServiceAsync = credits override fun balanceTransactions(): BalanceTransactionServiceAsync = balanceTransactions - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This operation is used to create an Orb customer, who is party to the core billing - * relationship. See [Customer](/core-concepts##customer) for an overview of the customer - * resource. - * - * This endpoint is critical in the following Orb functionality: - * - Automated charges can be configured by setting `payment_provider` and `payment_provider_id` - * to automatically issue invoices - * - [Customer ID Aliases](/events-and-metrics/customer-aliases) can be configured by setting - * `external_customer_id` - * - [Timezone localization](/essentials/timezones) can be configured on a per-customer basis by - * setting the `timezone` parameter - */ override fun create( params: CustomerCreateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("customers") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } - - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // post /customers + withRawResponse().create(params, requestOptions).thenApply { it.parse() } - /** - * 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. - */ override fun update( params: CustomerUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("customers", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } + ): CompletableFuture = + // put /customers/{customer_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * This endpoint returns a list of all customers for an account. The list of customers is - * ordered starting from the most recently created customer. This endpoint follows Orb's - * [standardized pagination format](/api-reference/pagination). - * - * See [Customer](/core-concepts##customer) for an overview of the customer model. - */ override fun list( params: CustomerListParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("customers") - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - .let { CustomerListPageAsync.of(this, params, it) } - } - } + ): CompletableFuture = + // get /customers + withRawResponse().list(params, requestOptions).thenApply { it.parse() } - private val deleteHandler: Handler = emptyHandler().withErrorHandler(errorHandler) - - /** - * This performs a deletion of this customer, its subscriptions, and its invoices, provided the - * customer does not have any issued invoices. Customers with issued invoices cannot be deleted. - * This operation is irreversible. Note that this is a _soft_ deletion, but the data will be - * inaccessible through the API and Orb dashboard. - * - * For a hard-deletion, please reach out to the Orb team directly. - * - * **Note**: This operation happens asynchronously and can be expected to take a few minutes to - * propagate to related resources. However, querying for the customer on subsequent GET requests - * while deletion is in process will reflect its deletion with a `deleted: true` property. Once - * the customer deletion has been fully processed, the customer will not be returned in the API. - * - * On successful processing, this returns an empty dictionary (`{}`) in the API. - */ override fun delete( params: CustomerDeleteParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("customers", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> response.use { deleteHandler.handle(it) } } - } - - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // delete /customers/{customer_id} + withRawResponse().delete(params, requestOptions).thenAccept {} - /** - * This endpoint is used to fetch customer details given an identifier. If the `Customer` is in - * the process of being deleted, only the properties `id` and `deleted: true` will be returned. - * - * See the [Customer resource](/core-concepts#customer) for a full discussion of the Customer - * model. - */ override fun fetch( params: CustomerFetchParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("customers", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } + ): CompletableFuture = + // get /customers/{customer_id} + withRawResponse().fetch(params, requestOptions).thenApply { it.parse() } - private val fetchByExternalIdHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint is used to fetch customer details given an `external_customer_id` (see - * [Customer ID Aliases](/events-and-metrics/customer-aliases)). - * - * Note that the resource and semantics of this endpoint exactly mirror - * [Get Customer](fetch-customer). - */ override fun fetchByExternalId( params: CustomerFetchByExternalIdParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("customers", "external_customer_id", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { fetchByExternalIdHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } + ): CompletableFuture = + // get /customers/external_customer_id/{external_customer_id} + withRawResponse().fetchByExternalId(params, requestOptions).thenApply { it.parse() } - private val syncPaymentMethodsFromGatewayHandler: Handler = - emptyHandler().withErrorHandler(errorHandler) - - /** - * Sync Orb's payment methods for the customer with their gateway. - * - * This method can be called before taking an action that may cause the customer to be charged, - * ensuring that the most up-to-date payment method is charged. - * - * **Note**: This functionality is currently only available for Stripe. - */ override fun syncPaymentMethodsFromGateway( params: CustomerSyncPaymentMethodsFromGatewayParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments( - "customers", - "external_customer_id", - params.getPathParam(0), - "sync_payment_methods_from_gateway", - ) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.use { syncPaymentMethodsFromGatewayHandler.handle(it) } - } - } + ): CompletableFuture = + // post + // /customers/external_customer_id/{external_customer_id}/sync_payment_methods_from_gateway + withRawResponse().syncPaymentMethodsFromGateway(params, requestOptions).thenAccept {} - private val syncPaymentMethodsFromGatewayByExternalCustomerIdHandler: Handler = - emptyHandler().withErrorHandler(errorHandler) - - /** - * Sync Orb's payment methods for the customer with their gateway. - * - * This method can be called before taking an action that may cause the customer to be charged, - * ensuring that the most up-to-date payment method is charged. - * - * **Note**: This functionality is currently only available for Stripe. - */ override fun syncPaymentMethodsFromGatewayByExternalCustomerId( params: CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments( - "customers", - params.getPathParam(0), - "sync_payment_methods_from_gateway", - ) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response.use { syncPaymentMethodsFromGatewayByExternalCustomerIdHandler.handle(it) } - } - } - - private val updateByExternalIdHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // post /customers/{customer_id}/sync_payment_methods_from_gateway + withRawResponse() + .syncPaymentMethodsFromGatewayByExternalCustomerId(params, requestOptions) + .thenAccept {} - /** - * This endpoint is used to update customer details given an `external_customer_id` (see - * [Customer ID Aliases](/events-and-metrics/customer-aliases)). Note that the resource and - * semantics of this endpoint exactly mirror [Update Customer](update-customer). - */ override fun updateByExternalId( params: CustomerUpdateByExternalIdParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("customers", "external_customer_id", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { updateByExternalIdHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() + ): CompletableFuture = + // put /customers/external_customer_id/{external_customer_id} + withRawResponse().updateByExternalId(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CustomerServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val costs: CostServiceAsync.WithRawResponse by lazy { + CostServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val credits: CreditServiceAsync.WithRawResponse by lazy { + CreditServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val balanceTransactions: BalanceTransactionServiceAsync.WithRawResponse by lazy { + BalanceTransactionServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun costs(): CostServiceAsync.WithRawResponse = costs + + override fun credits(): CreditServiceAsync.WithRawResponse = credits + + override fun balanceTransactions(): BalanceTransactionServiceAsync.WithRawResponse = + balanceTransactions + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: CustomerCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("customers") + .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 -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: CustomerUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("customers", params.getPathParam(0)) + .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 -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: CustomerListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("customers") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + CustomerListPageAsync.of( + CustomerServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } + } + + private val deleteHandler: Handler = emptyHandler().withErrorHandler(errorHandler) + + override fun delete( + params: CustomerDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("customers", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { response.use { deleteHandler.handle(it) } } + } + } + + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetch( + params: CustomerFetchParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("customers", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val fetchByExternalIdHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetchByExternalId( + params: CustomerFetchByExternalIdParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("customers", "external_customer_id", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { fetchByExternalIdHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val syncPaymentMethodsFromGatewayHandler: Handler = + emptyHandler().withErrorHandler(errorHandler) + + override fun syncPaymentMethodsFromGateway( + params: CustomerSyncPaymentMethodsFromGatewayParams, + requestOptions: RequestOptions, + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments( + "customers", + "external_customer_id", + params.getPathParam(0), + "sync_payment_methods_from_gateway", + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response.use { syncPaymentMethodsFromGatewayHandler.handle(it) } + } + } + } + + private val syncPaymentMethodsFromGatewayByExternalCustomerIdHandler: Handler = + emptyHandler().withErrorHandler(errorHandler) + + override fun syncPaymentMethodsFromGatewayByExternalCustomerId( + params: CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams, + requestOptions: RequestOptions, + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments( + "customers", + params.getPathParam(0), + "sync_payment_methods_from_gateway", + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response.use { + syncPaymentMethodsFromGatewayByExternalCustomerIdHandler.handle(it) } } - } + } + } + + private val updateByExternalIdHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun updateByExternalId( + params: CustomerUpdateByExternalIdParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("customers", "external_customer_id", params.getPathParam(0)) + .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 -> + response.parseable { + response + .use { updateByExternalIdHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/DimensionalPriceGroupServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/DimensionalPriceGroupServiceAsync.kt index 21d91bd5f..05be94009 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/DimensionalPriceGroupServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/DimensionalPriceGroupServiceAsync.kt @@ -4,17 +4,24 @@ package com.withorb.api.services.async +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions -import com.withorb.api.models.DimensionalPriceGroup +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.DimensionalPriceGroupCreateParams import com.withorb.api.models.DimensionalPriceGroupListPageAsync import com.withorb.api.models.DimensionalPriceGroupListParams +import com.withorb.api.models.DimensionalPriceGroupModel import com.withorb.api.models.DimensionalPriceGroupRetrieveParams import com.withorb.api.services.async.dimensionalPriceGroups.ExternalDimensionalPriceGroupIdServiceAsync import java.util.concurrent.CompletableFuture interface DimensionalPriceGroupServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + fun externalDimensionalPriceGroupId(): ExternalDimensionalPriceGroupIdServiceAsync /** @@ -30,14 +37,14 @@ interface DimensionalPriceGroupServiceAsync { fun create( params: DimensionalPriceGroupCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** Fetch dimensional price group */ @JvmOverloads fun retrieve( params: DimensionalPriceGroupRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** List dimensional price groups */ @JvmOverloads @@ -51,4 +58,58 @@ interface DimensionalPriceGroupServiceAsync { requestOptions: RequestOptions ): CompletableFuture = list(DimensionalPriceGroupListParams.none(), requestOptions) + + /** + * A view of [DimensionalPriceGroupServiceAsync] that provides access to raw HTTP responses for + * each method. + */ + interface WithRawResponse { + + fun externalDimensionalPriceGroupId(): + ExternalDimensionalPriceGroupIdServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /dimensional_price_groups`, but is otherwise the + * same as [DimensionalPriceGroupServiceAsync.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: DimensionalPriceGroupCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get + * /dimensional_price_groups/{dimensional_price_group_id}`, but is otherwise the same as + * [DimensionalPriceGroupServiceAsync.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: DimensionalPriceGroupRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /dimensional_price_groups`, but is otherwise the + * same as [DimensionalPriceGroupServiceAsync.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: DimensionalPriceGroupListParams = DimensionalPriceGroupListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /dimensional_price_groups`, but is otherwise the + * same as [DimensionalPriceGroupServiceAsync.list]. + */ + @MustBeClosed + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(DimensionalPriceGroupListParams.none(), requestOptions) + } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/DimensionalPriceGroupServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/DimensionalPriceGroupServiceAsyncImpl.kt index 7c5125c5e..7bc463a07 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/DimensionalPriceGroupServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/DimensionalPriceGroupServiceAsyncImpl.kt @@ -10,13 +10,15 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest import com.withorb.api.core.http.HttpResponse.Handler -import com.withorb.api.core.json +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.errors.OrbError -import com.withorb.api.models.DimensionalPriceGroup import com.withorb.api.models.DimensionalPriceGroupCreateParams import com.withorb.api.models.DimensionalPriceGroupListPageAsync import com.withorb.api.models.DimensionalPriceGroupListParams +import com.withorb.api.models.DimensionalPriceGroupModel import com.withorb.api.models.DimensionalPriceGroupRetrieveParams import com.withorb.api.services.async.dimensionalPriceGroups.ExternalDimensionalPriceGroupIdServiceAsync import com.withorb.api.services.async.dimensionalPriceGroups.ExternalDimensionalPriceGroupIdServiceAsyncImpl @@ -25,105 +27,152 @@ import java.util.concurrent.CompletableFuture class DimensionalPriceGroupServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : DimensionalPriceGroupServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: DimensionalPriceGroupServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } private val externalDimensionalPriceGroupId: ExternalDimensionalPriceGroupIdServiceAsync by lazy { ExternalDimensionalPriceGroupIdServiceAsyncImpl(clientOptions) } + override fun withRawResponse(): DimensionalPriceGroupServiceAsync.WithRawResponse = + withRawResponse + override fun externalDimensionalPriceGroupId(): ExternalDimensionalPriceGroupIdServiceAsync = externalDimensionalPriceGroupId - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * 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. - * - * For example, suppose we have a billable metric that measures the number of widgets used and - * we want to charge differently depending on the color of the widget. We can create a price - * group with a dimension "color" and two prices: one that charges $10 per red widget and one - * that charges $20 per blue widget. - */ override fun create( params: DimensionalPriceGroupCreateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("dimensional_price_groups") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } - - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // post /dimensional_price_groups + withRawResponse().create(params, requestOptions).thenApply { it.parse() } - /** Fetch dimensional price group */ override fun retrieve( params: DimensionalPriceGroupRetrieveParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("dimensional_price_groups", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + ): CompletableFuture = + // get /dimensional_price_groups/{dimensional_price_group_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - /** List dimensional price groups */ override fun list( params: DimensionalPriceGroupListParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("dimensional_price_groups") - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): CompletableFuture = + // get /dimensional_price_groups + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + DimensionalPriceGroupServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val externalDimensionalPriceGroupId: + ExternalDimensionalPriceGroupIdServiceAsync.WithRawResponse by lazy { + ExternalDimensionalPriceGroupIdServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun externalDimensionalPriceGroupId(): + ExternalDimensionalPriceGroupIdServiceAsync.WithRawResponse = + externalDimensionalPriceGroupId + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun create( + params: DimensionalPriceGroupCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("dimensional_price_groups") + .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 -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: DimensionalPriceGroupRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("dimensional_price_groups", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: DimensionalPriceGroupListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("dimensional_price_groups") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + DimensionalPriceGroupListPageAsync.of( + DimensionalPriceGroupServiceAsyncImpl(clientOptions), + params, + it, + ) + } } - .let { DimensionalPriceGroupListPageAsync.of(this, params, it) } - } + } + } } } 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 c26e1ecee..26e89877f 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 @@ -4,7 +4,9 @@ package com.withorb.api.services.async +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.EventDeprecateParams import com.withorb.api.models.EventDeprecateResponse import com.withorb.api.models.EventIngestParams @@ -19,6 +21,11 @@ import java.util.concurrent.CompletableFuture interface EventServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + fun backfills(): BackfillServiceAsync fun volume(): VolumeServiceAsync @@ -330,4 +337,56 @@ interface EventServiceAsync { params: EventSearchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** A view of [EventServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + fun backfills(): BackfillServiceAsync.WithRawResponse + + fun volume(): VolumeServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `put /events/{event_id}`, but is otherwise the same as + * [EventServiceAsync.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: EventUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `put /events/{event_id}/deprecate`, but is otherwise the + * same as [EventServiceAsync.deprecate]. + */ + @JvmOverloads + @MustBeClosed + fun deprecate( + params: EventDeprecateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /ingest`, but is otherwise the same as + * [EventServiceAsync.ingest]. + */ + @JvmOverloads + @MustBeClosed + fun ingest( + params: EventIngestParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /events/search`, but is otherwise the same as + * [EventServiceAsync.search]. + */ + @JvmOverloads + @MustBeClosed + fun search( + params: EventSearchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } 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 57d5f25fe..3715926dc 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 @@ -10,7 +10,9 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest import com.withorb.api.core.http.HttpResponse.Handler -import com.withorb.api.core.json +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.errors.OrbError import com.withorb.api.models.EventDeprecateParams @@ -30,405 +32,187 @@ import java.util.concurrent.CompletableFuture class EventServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : EventServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: EventServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } private val backfills: BackfillServiceAsync by lazy { BackfillServiceAsyncImpl(clientOptions) } private val volume: VolumeServiceAsync by lazy { VolumeServiceAsyncImpl(clientOptions) } + override fun withRawResponse(): EventServiceAsync.WithRawResponse = withRawResponse + override fun backfills(): BackfillServiceAsync = backfills override fun volume(): VolumeServiceAsync = volume - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint is used to amend a single usage event with a given `event_id`. `event_id` - * refers to the `idempotency_key` passed in during ingestion. The event will maintain its - * existing `event_id` after the amendment. - * - * This endpoint will mark the existing event as ignored, and Orb will only use the new event - * passed in the body of this request as the source of truth for that `event_id`. Note that a - * single event can be amended any number of times, so the same event can be overwritten in - * subsequent calls to this endpoint. Only a single event with a given `event_id` will be - * considered the source of truth at any given time. - * - * This is a powerful and audit-safe mechanism to retroactively update a single event in cases - * where you need to: - * - update an event with new metadata as you iterate on your pricing model - * - update an event based on the result of an external API call (e.g. call to a payment gateway - * succeeded or failed) - * - * This amendment API is always audit-safe. The process will still retain the original event, - * though it will be ignored for billing calculations. For auditing and data fidelity purposes, - * Orb never overwrites or permanently deletes ingested usage data. - * - * ## Request validation - * - The `timestamp` of the new event must match the `timestamp` of the existing event already - * ingested. As with ingestion, all timestamps must be sent in ISO8601 format with UTC - * timezone offset. - * - The `customer_id` or `external_customer_id` of the new event must match the `customer_id` - * or `external_customer_id` of the existing event already ingested. Exactly one of - * `customer_id` and `external_customer_id` should be specified, and similar to ingestion, the - * ID must identify a Customer resource within Orb. Unlike ingestion, for event amendment, we - * strictly enforce that the Customer must be in the Orb system, even during the initial - * integration period. We do not allow updating the `Customer` an event is associated with. - * - Orb does not accept an `idempotency_key` with the event in this endpoint, since this - * request is by design idempotent. On retryable errors, you should retry the request and - * assume the amendment operation has not succeeded until receipt of a 2xx. - * - The event's `timestamp` must fall within the customer's current subscription's billing - * period, or within the grace period of the customer's current subscription's previous - * billing period. - * - By default, no more than 100 events can be amended for a single customer in a 100 day - * period. For higher volume updates, consider using the [event backfill](create-backfill) - * endpoint. - */ override fun update( params: EventUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("events", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } - - private val deprecateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // put /events/{event_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } - /** - * This endpoint is used to deprecate a single usage event with a given `event_id`. `event_id` - * refers to the `idempotency_key` passed in during ingestion. - * - * This endpoint will mark the existing event as ignored. Note that if you attempt to re-ingest - * an event with the same `event_id` as a deprecated event, Orb will return an error. - * - * This is a powerful and audit-safe mechanism to retroactively deprecate a single event in - * cases where you need to: - * - no longer bill for an event that was improperly reported - * - no longer bill for an event based on the result of an external API call (e.g. call to a - * payment gateway failed and the user should not be billed) - * - * If you want to only change specific properties of an event, but keep the event as part of the - * billing calculation, use the [Amend event](amend-event) endpoint instead. - * - * This API is always audit-safe. The process will still retain the deprecated event, though it - * will be ignored for billing calculations. For auditing and data fidelity purposes, Orb never - * overwrites or permanently deletes ingested usage data. - * - * ## Request validation - * - Orb does not accept an `idempotency_key` with the event in this endpoint, since this - * request is by design idempotent. On retryable errors, you should retry the request and - * assume the deprecation operation has not succeeded until receipt of a 2xx. - * - The event's `timestamp` must fall within the customer's current subscription's billing - * period, or within the grace period of the customer's current subscription's previous - * billing period. Orb does not allow deprecating events for billing periods that have already - * invoiced customers. - * - The `customer_id` or the `external_customer_id` of the original event ingestion request - * must identify a Customer resource within Orb, even if this event was ingested during the - * initial integration period. We do not allow deprecating events for customers not in the Orb - * system. - * - By default, no more than 100 events can be deprecated for a single customer in a 100 day - * period. For higher volume updates, consider using the [event backfill](create-backfill) - * endpoint. - */ override fun deprecate( params: EventDeprecateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("events", params.getPathParam(0), "deprecate") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { deprecateHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } + ): CompletableFuture = + // put /events/{event_id}/deprecate + withRawResponse().deprecate(params, requestOptions).thenApply { it.parse() } - private val ingestHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Orb's event ingestion model and API is designed around two core principles: - * 1. **Data fidelity**: The accuracy of your billing model depends on a robust foundation of - * events. Orb's API protocol encourages usage patterns that ensure that your data is - * consistently complete and correct. - * 2. **Fast integration**: Sending events into Orb requires no tedious setup steps or explicit - * field schema for your event shape, making it instant to start streaming in usage in - * real-time. - * - * ## Event shape - * - * Events are the starting point for all usage calculations in the system, and are simple at - * their core: - * ```ts - * { - * // customer_id and external_customer_id are used to - * // attribute usage to a given Customer. Exactly one of these - * // should be specified in a given ingestion event. - * - * // `customer_id` is the Orb generated identifier for the Customer, - * // which is returned from the Create customer API call. - * customer_id: string, - * - * // external_customer_id is an alternate identifier which is associated - * // with a Customer at creation time. This is treated as an alias for - * // customer_id, and is usually set to an identifier native to your system. - * external_customer_id: string, - * - * // A string name identifying the event, usually a usage - * // action. By convention, this should not contain any whitespace. - * event_name: string, - * - * // An ISO 8601 format date with no timezone offset. - * // This should represent the time that usage occurred - * // and is important to attribute usage to a given - * // billing period. See the notes below on determining the timestamp. - * // e.g. 2020-12-09T16:09:53Z - * timestamp: string, - * - * // A unique value, generated by the client, that is - * // used to de-duplicate events. - * // Exactly one event with a given - * // idempotency key will be ingested, which allows for - * // safe request retries. - * idempotency_key: string - * - * // Optional custom metadata to attach to the event. - * // This might include a numeric value used for aggregation, - * // or a string/boolean value used for filtering. - * // The schema of this dictionary need not be pre-declared, and - * // properties can be added at any time. - * properties: { - * [key: string]?: string | number | boolean, - * }, - * } - * ``` - * - * ## Required fields - * - * Because events streamed to Orb are meant to be as flexible as possible, there are only a few - * required fields in every event. - * - We recommend that `idempotency_key` are unique strings that you generated with V4 UUIDs, - * but only require that they uniquely identify an event (i.e. don’t collide). - * - The `timestamp` field in the event body will be used to determine which billable period a - * given event falls into. For example, with a monthly billing cycle starting from the first - * of December, Orb will calculate metrics based on events that fall into the range `12-01 - * 00:00:00 <= timestamp < 01-01 00:00:00`. - * - * ## Logging metadata - * - * Orb allows tagging events with metadata using a flexible properties dictionary. Since Orb - * does not enforce a rigid schema for this field-set, key-value pairs can be added dynamically - * as your events evolve. - * - * This dictionary can be helpful for a wide variety of use cases: - * - Numeric properties on events like `compute_time_ms` can later be inputs to our flexible - * query engine to determine usage. - * - Logging a region or cluster with each event can help you provide customers more granular - * visibility into their usage. - * - If you are using matrix pricing and matching a matrix price key with a property, you should - * ensure the value for that property is sent as a string. - * - * We encourage logging this metadata with an eye towards future use cases to ensure full - * coverage for historical data. The datatype of the value in the properties dictionary is - * important for metric creation from an event source. Values that you wish to numerically - * aggregate should be of numeric type in the event. - * - * ## Determining event timestamp - * - * For cases where usage is being reported in real time as it is occurring, timestamp should - * correspond to the time that usage occurred. - * - * In cases where usage is reported in aggregate for a historical timeframe at a regular - * interval, we recommend setting the event `timestamp` to the midpoint of the interval. As an - * example, if you have an hourly reporter that sends data once an hour for the previous hour of - * usage, setting the `timestamp` to the half-hour mark will ensure that the usage is counted - * within the correct period. - * - * Note that other time-related fields (e.g. time elapsed) can be added to the properties - * dictionary as necessary. - * - * In cases where usage is reported in aggregate for a historical timeframe, the timestamp must - * be within the grace period set for your account. Events with `timestamp < current_time - - * grace_period` will not be accepted as a valid event, and will throw validation errors. - * Enforcing the grace period enables Orb to accurately map usage to the correct billing cycle - * and ensure that all usage is billed for in the corresponding billing period. - * - * In general, Orb does not expect events with future dated timestamps. In cases where the - * timestamp is at least 24 hours ahead of the current time, the event will not be accepted as a - * valid event, and will throw validation errors. - * - * ## Event validation - * - * Orb’s validation ensures that you recognize errors in your events as quickly as possible, and - * the API provides informative error messages to help you fix problems quickly. - * - * We validate the following: - * - Exactly one of `customer_id` and `external_customer_id` should be specified. - * - If the `customer_id` is specified, the customer in Orb must exist. - * - If the `external_customer_id` is specified, the customer in Orb does not need to exist. - * Events will be attributed to any future customers with the `external_customer_id` on - * subscription creation. - * - `timestamp` must conform to ISO 8601 and represent a timestamp at most 1 hour in the - * future. This timestamp should be sent in UTC timezone (no timezone offset). - * - * ## Idempotency and retry semantics - * - * Orb's idempotency guarantees allow you to implement safe retry logic in the event of network - * or machine failures, ensuring data fidelity. Each event in the request payload is associated - * with an idempotency key, and Orb guarantees that a single idempotency key will be - * successfully ingested at most once. Note that when Orb encounters events with duplicate - * idempotency keys and differing event bodies in a batch of events, the entire batch will be - * rejected. - * - Successful responses return a 200 HTTP status code. The response contains information about - * previously processed events. - * - Requests that return a `4xx` HTTP status code indicate a payload error and contain at least - * one event with a validation failure. An event with a validation failure can be re-sent to - * the ingestion endpoint (after the payload is fixed) with the original idempotency key since - * that key is not marked as processed. - * - Requests that return a `5xx` HTTP status code indicate a server-side failure. These - * requests should be retried in their entirety. - * - * ## API usage and limits - * - * The ingestion API is designed made for real-time streaming ingestion and architected for high - * throughput. Even if events are later deemed unnecessary or filtered out, we encourage you to - * log them to Orb if they may be relevant to billing calculations in the future. - * - * To take advantage of the real-time features of the Orb platform and avoid any chance of - * dropped events by producers, we recommend reporting events to Orb frequently. Optionally, - * events can also be briefly aggregated at the source, as this API accepts an array of event - * bodies. - * - * Orb does not currently enforce a hard rate-limit for API usage or a maximum request payload - * size, but please give us a heads up if you’re changing either of these factors by an order of - * magnitude from initial setup. - * - * ## Testing in debug mode - * - * The ingestion API supports a debug mode, which returns additional verbose output to indicate - * which event idempotency keys were newly ingested or duplicates from previous requests. To - * enable this mode, mark `debug=true` as a query parameter. - * - * If `debug=true` is not specified, the response will only contain `validation_failed`. Orb - * will still honor the idempotency guarantees set - * [here](/events-and-metrics/event-ingestion#event-volume-and-concurrency) in all cases. - * - * We strongly recommend that you only use debug mode as part of testing your initial Orb - * integration. Once you're ready to switch to production, disable debug mode to take advantage - * of improved performance and maximal throughput. - * - * #### Example: ingestion response with `debug=true` - * - * ```json - * { - * "debug": { - * "duplicate": [], - * "ingested": ["B7E83HDMfJPAunXW", "SJs5DQJ3TnwSqEZE", "8SivfDsNKwCeAXim"] - * }, - * "validation_failed": [] - * } - * ``` - * - * #### Example: ingestion response with `debug=false` - * - * ```json - * { - * "validation_failed": [] - * } - * ``` - */ override fun ingest( params: EventIngestParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("ingest") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { ingestHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } - - private val searchHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // post /ingest + withRawResponse().ingest(params, requestOptions).thenApply { it.parse() } - /** - * This endpoint returns a filtered set of events for an account in a - * [paginated list format](/api-reference/pagination). - * - * Note that this is a `POST` endpoint rather than a `GET` endpoint because it employs a JSON - * body for search criteria rather than query parameters, allowing for a more flexible search - * syntax. - * - * Note that a search criteria _must_ be specified. Currently, Orb supports the following - * criteria: - * - `event_ids`: This is an explicit array of IDs to filter by. Note that an event's ID is the - * `idempotency_key` that was originally used for ingestion. - * - * By default, Orb will not throw a `404` if no events matched, Orb will return an empty array - * for `data` instead. - */ override fun search( params: EventSearchParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("events", "search") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { searchHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): CompletableFuture = + // post /events/search + withRawResponse().search(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + EventServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val backfills: BackfillServiceAsync.WithRawResponse by lazy { + BackfillServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val volume: VolumeServiceAsync.WithRawResponse by lazy { + VolumeServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun backfills(): BackfillServiceAsync.WithRawResponse = backfills + + override fun volume(): VolumeServiceAsync.WithRawResponse = volume + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun update( + params: EventUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("events", params.getPathParam(0)) + .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 -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val deprecateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun deprecate( + params: EventDeprecateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("events", params.getPathParam(0), "deprecate") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { deprecateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val ingestHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun ingest( + params: EventIngestParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("ingest") + .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 -> + response.parseable { + response + .use { ingestHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val searchHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun search( + params: EventSearchParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("events", "search") + .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 -> + response.parseable { + response + .use { searchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } 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 36556e2dc..84c743b93 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 @@ -4,13 +4,20 @@ package com.withorb.api.services.async +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.InvoiceLineItemCreateParams -import com.withorb.api.models.InvoiceLineItemCreateResponse +import com.withorb.api.models.InvoiceLineItemModel import java.util.concurrent.CompletableFuture interface InvoiceLineItemServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * This creates a one-off fixed fee invoice line item on an Invoice. This can only be done for * invoices that are in a `draft` status. @@ -19,5 +26,23 @@ interface InvoiceLineItemServiceAsync { fun create( params: InvoiceLineItemCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture + + /** + * A view of [InvoiceLineItemServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /invoice_line_items`, but is otherwise the same as + * [InvoiceLineItemServiceAsync.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: InvoiceLineItemCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } 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 2640414ad..5a775143c 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 @@ -10,47 +10,65 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest import com.withorb.api.core.http.HttpResponse.Handler -import com.withorb.api.core.json +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.errors.OrbError import com.withorb.api.models.InvoiceLineItemCreateParams -import com.withorb.api.models.InvoiceLineItemCreateResponse +import com.withorb.api.models.InvoiceLineItemModel import java.util.concurrent.CompletableFuture class InvoiceLineItemServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : InvoiceLineItemServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: InvoiceLineItemServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): InvoiceLineItemServiceAsync.WithRawResponse = withRawResponse - /** - * This creates a one-off fixed fee invoice line item on an Invoice. This can only be done for - * invoices that are in a `draft` status. - */ override fun create( params: InvoiceLineItemCreateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("invoice_line_items") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): CompletableFuture = + // post /invoice_line_items + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + InvoiceLineItemServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun create( + params: InvoiceLineItemCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("invoice_line_items") + .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 -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } 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 828ef2e04..ca9e637c6 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 @@ -4,8 +4,9 @@ package com.withorb.api.services.async +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions -import com.withorb.api.models.Invoice +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.InvoiceCreateParams import com.withorb.api.models.InvoiceFetchParams import com.withorb.api.models.InvoiceFetchUpcomingParams @@ -14,6 +15,7 @@ import com.withorb.api.models.InvoiceIssueParams import com.withorb.api.models.InvoiceListPageAsync import com.withorb.api.models.InvoiceListParams import com.withorb.api.models.InvoiceMarkPaidParams +import com.withorb.api.models.InvoiceModel import com.withorb.api.models.InvoicePayParams import com.withorb.api.models.InvoiceUpdateParams import com.withorb.api.models.InvoiceVoidInvoiceParams @@ -21,12 +23,17 @@ import java.util.concurrent.CompletableFuture interface InvoiceServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** This endpoint is used to create a one-off invoice for a customer. */ @JvmOverloads fun create( params: InvoiceCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This endpoint allows you to update the `metadata` property on an invoice. If you pass null @@ -38,7 +45,7 @@ interface InvoiceServiceAsync { fun update( params: InvoiceUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This endpoint returns a list of all [`Invoice`](/core-concepts#invoice)s for an account in a @@ -84,7 +91,7 @@ interface InvoiceServiceAsync { fun fetch( params: InvoiceFetchParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This endpoint can be used to fetch the upcoming [invoice](/core-concepts#invoice) for the @@ -107,7 +114,7 @@ interface InvoiceServiceAsync { fun issue( params: InvoiceIssueParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This endpoint allows an invoice's status to be set the `paid` status. This can only be done @@ -117,7 +124,7 @@ interface InvoiceServiceAsync { fun markPaid( params: InvoiceMarkPaidParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This endpoint collects payment for an invoice using the customer's default payment method. @@ -127,7 +134,7 @@ interface InvoiceServiceAsync { fun pay( params: InvoicePayParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This endpoint allows an invoice's status to be set the `void` status. This can only be done @@ -145,5 +152,120 @@ interface InvoiceServiceAsync { fun voidInvoice( params: InvoiceVoidInvoiceParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture + + /** + * A view of [InvoiceServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /invoices`, but is otherwise the same as + * [InvoiceServiceAsync.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: InvoiceCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `put /invoices/{invoice_id}`, but is otherwise the same + * as [InvoiceServiceAsync.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: InvoiceUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /invoices`, but is otherwise the same as + * [InvoiceServiceAsync.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: InvoiceListParams = InvoiceListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /invoices`, but is otherwise the same as + * [InvoiceServiceAsync.list]. + */ + @MustBeClosed + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(InvoiceListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /invoices/{invoice_id}`, but is otherwise the same + * as [InvoiceServiceAsync.fetch]. + */ + @JvmOverloads + @MustBeClosed + fun fetch( + params: InvoiceFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /invoices/upcoming`, but is otherwise the same as + * [InvoiceServiceAsync.fetchUpcoming]. + */ + @JvmOverloads + @MustBeClosed + fun fetchUpcoming( + params: InvoiceFetchUpcomingParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /invoices/{invoice_id}/issue`, but is otherwise the + * same as [InvoiceServiceAsync.issue]. + */ + @JvmOverloads + @MustBeClosed + fun issue( + params: InvoiceIssueParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /invoices/{invoice_id}/mark_paid`, but is otherwise + * the same as [InvoiceServiceAsync.markPaid]. + */ + @JvmOverloads + @MustBeClosed + fun markPaid( + params: InvoiceMarkPaidParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /invoices/{invoice_id}/pay`, but is otherwise the + * same as [InvoiceServiceAsync.pay]. + */ + @JvmOverloads + @MustBeClosed + fun pay( + params: InvoicePayParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /invoices/{invoice_id}/void`, but is otherwise the + * same as [InvoiceServiceAsync.voidInvoice]. + */ + @JvmOverloads + @MustBeClosed + fun voidInvoice( + params: InvoiceVoidInvoiceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } 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 f1443bb55..c5fc991e1 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 @@ -10,10 +10,11 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest import com.withorb.api.core.http.HttpResponse.Handler -import com.withorb.api.core.json +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.errors.OrbError -import com.withorb.api.models.Invoice import com.withorb.api.models.InvoiceCreateParams import com.withorb.api.models.InvoiceFetchParams import com.withorb.api.models.InvoiceFetchUpcomingParams @@ -22,6 +23,7 @@ import com.withorb.api.models.InvoiceIssueParams import com.withorb.api.models.InvoiceListPageAsync import com.withorb.api.models.InvoiceListParams import com.withorb.api.models.InvoiceMarkPaidParams +import com.withorb.api.models.InvoiceModel import com.withorb.api.models.InvoicePayParams import com.withorb.api.models.InvoiceUpdateParams import com.withorb.api.models.InvoiceVoidInvoiceParams @@ -30,303 +32,354 @@ import java.util.concurrent.CompletableFuture class InvoiceServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : InvoiceServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: InvoiceServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): InvoiceServiceAsync.WithRawResponse = withRawResponse - /** This endpoint is used to create a one-off invoice for a customer. */ override fun create( params: InvoiceCreateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("invoices") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } - - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // post /invoices + withRawResponse().create(params, requestOptions).thenApply { it.parse() } - /** - * This endpoint allows you to update the `metadata` property 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. - */ override fun update( params: InvoiceUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("invoices", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } + ): CompletableFuture = + // put /invoices/{invoice_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * This endpoint returns a list of all [`Invoice`](/core-concepts#invoice)s for an account in a - * list format. - * - * The list of invoices is ordered starting from the most recently issued invoice date. The - * response also includes [`pagination_metadata`](/api-reference/pagination), which lets the - * caller retrieve the next page of results if they exist. - * - * By default, this only returns invoices that are `issued`, `paid`, or `synced`. - * - * 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. - */ override fun list( params: InvoiceListParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("invoices") - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - .let { InvoiceListPageAsync.of(this, params, it) } - } - } - - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // get /invoices + withRawResponse().list(params, requestOptions).thenApply { it.parse() } - /** - * This endpoint is used to fetch an [`Invoice`](/core-concepts#invoice) given an identifier. - */ override fun fetch( params: InvoiceFetchParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("invoices", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } - - private val fetchUpcomingHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + ): CompletableFuture = + // get /invoices/{invoice_id} + withRawResponse().fetch(params, requestOptions).thenApply { it.parse() } - /** - * This endpoint can be used to fetch the upcoming [invoice](/core-concepts#invoice) for the - * current billing period given a subscription. - */ override fun fetchUpcoming( params: InvoiceFetchUpcomingParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("invoices", "upcoming") - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { fetchUpcomingHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } - - private val issueHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // get /invoices/upcoming + withRawResponse().fetchUpcoming(params, requestOptions).thenApply { it.parse() } - /** - * 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). - */ override fun issue( params: InvoiceIssueParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("invoices", params.getPathParam(0), "issue") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { issueHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } + ): CompletableFuture = + // post /invoices/{invoice_id}/issue + withRawResponse().issue(params, requestOptions).thenApply { it.parse() } - private val markPaidHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint allows an invoice's status to be set the `paid` status. This can only be done - * to invoices that are in the `issued` status. - */ override fun markPaid( params: InvoiceMarkPaidParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("invoices", params.getPathParam(0), "mark_paid") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { markPaidHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } + ): CompletableFuture = + // post /invoices/{invoice_id}/mark_paid + withRawResponse().markPaid(params, requestOptions).thenApply { it.parse() } - private val payHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * 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". - */ override fun pay( params: InvoicePayParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("invoices", params.getPathParam(0), "pay") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { payHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } + ): CompletableFuture = + // post /invoices/{invoice_id}/pay + withRawResponse().pay(params, requestOptions).thenApply { it.parse() } - private val voidInvoiceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint allows an invoice's status to be set the `void` status. This can only be done - * to invoices that are in the `issued` status. - * - * If the associated invoice has used the customer balance to change the amount due, the - * customer balance operation will be reverted. For example, if the invoice used $10 of customer - * balance, that amount will be added back to the customer balance upon voiding. - * - * If the invoice was used to purchase a credit block, but the invoice is not yet paid, the - * credit block will be voided. If the invoice was created due to a top-up, the top-up will be - * disabled. - */ override fun voidInvoice( params: InvoiceVoidInvoiceParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("invoices", params.getPathParam(0), "void") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { voidInvoiceHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): CompletableFuture = + // post /invoices/{invoice_id}/void + withRawResponse().voidInvoice(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + InvoiceServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: InvoiceCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("invoices") + .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 -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: InvoiceUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("invoices", params.getPathParam(0)) + .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 -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: InvoiceListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("invoices") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + InvoiceListPageAsync.of( + InvoiceServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } + } + + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetch( + params: InvoiceFetchParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("invoices", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val fetchUpcomingHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun fetchUpcoming( + params: InvoiceFetchUpcomingParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("invoices", "upcoming") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { fetchUpcomingHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val issueHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun issue( + params: InvoiceIssueParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("invoices", params.getPathParam(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 -> + response.parseable { + response + .use { issueHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val markPaidHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun markPaid( + params: InvoiceMarkPaidParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("invoices", params.getPathParam(0), "mark_paid") + .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 -> + response.parseable { + response + .use { markPaidHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val payHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun pay( + params: InvoicePayParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("invoices", params.getPathParam(0), "pay") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { payHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val voidInvoiceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun voidInvoice( + params: InvoiceVoidInvoiceParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("invoices", params.getPathParam(0), "void") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { voidInvoiceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } 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 eea61b1f5..03194e9d5 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 @@ -4,30 +4,37 @@ package com.withorb.api.services.async +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions -import com.withorb.api.models.Item +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.ItemCreateParams import com.withorb.api.models.ItemFetchParams import com.withorb.api.models.ItemListPageAsync import com.withorb.api.models.ItemListParams +import com.withorb.api.models.ItemModel import com.withorb.api.models.ItemUpdateParams import java.util.concurrent.CompletableFuture interface ItemServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** This endpoint is used to create an [Item](/core-concepts#item). */ @JvmOverloads fun create( params: ItemCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** This endpoint can be used to update properties on the Item. */ @JvmOverloads fun update( params: ItemUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** This endpoint returns a list of all Items, ordered in descending order by creation time. */ @JvmOverloads @@ -45,5 +52,63 @@ interface ItemServiceAsync { fun fetch( params: ItemFetchParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture + + /** A view of [ItemServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /items`, but is otherwise the same as + * [ItemServiceAsync.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: ItemCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `put /items/{item_id}`, but is otherwise the same as + * [ItemServiceAsync.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: ItemUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /items`, but is otherwise the same as + * [ItemServiceAsync.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: ItemListParams = ItemListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /items`, but is otherwise the same as + * [ItemServiceAsync.list]. + */ + @MustBeClosed + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(ItemListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /items/{item_id}`, but is otherwise the same as + * [ItemServiceAsync.fetch]. + */ + @JvmOverloads + @MustBeClosed + fun fetch( + params: ItemFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } 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 4025ad340..fcf754dd5 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 @@ -10,131 +10,185 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest import com.withorb.api.core.http.HttpResponse.Handler -import com.withorb.api.core.json +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.errors.OrbError -import com.withorb.api.models.Item import com.withorb.api.models.ItemCreateParams import com.withorb.api.models.ItemFetchParams import com.withorb.api.models.ItemListPageAsync import com.withorb.api.models.ItemListParams +import com.withorb.api.models.ItemModel import com.withorb.api.models.ItemUpdateParams import java.util.concurrent.CompletableFuture class ItemServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ItemServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ItemServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): ItemServiceAsync.WithRawResponse = withRawResponse - /** This endpoint is used to create an [Item](/core-concepts#item). */ override fun create( params: ItemCreateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("items") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } + ): CompletableFuture = + // post /items + withRawResponse().create(params, requestOptions).thenApply { it.parse() } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** This endpoint can be used to update properties on the Item. */ override fun update( params: ItemUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("items", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } + ): CompletableFuture = + // put /items/{item_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** This endpoint returns a list of all Items, ordered in descending order by creation time. */ override fun list( params: ItemListParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("items") - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - .let { ItemListPageAsync.of(this, params, it) } - } - } + ): CompletableFuture = + // get /items + withRawResponse().list(params, requestOptions).thenApply { it.parse() } - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** This endpoint returns an item identified by its item_id. */ override fun fetch( params: ItemFetchParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("items", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): CompletableFuture = + // get /items/{item_id} + withRawResponse().fetch(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ItemServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: ItemCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("items") + .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 -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: ItemUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("items", params.getPathParam(0)) + .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 -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: ItemListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("items") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ItemListPageAsync.of( + ItemServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } + } + + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetch( + params: ItemFetchParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("items", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } 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 0aae832ac..d3cc83bd6 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 @@ -4,8 +4,10 @@ package com.withorb.api.services.async +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions -import com.withorb.api.models.BillableMetric +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.BillableMetricModel import com.withorb.api.models.MetricCreateParams import com.withorb.api.models.MetricFetchParams import com.withorb.api.models.MetricListPageAsync @@ -15,6 +17,11 @@ import java.util.concurrent.CompletableFuture interface MetricServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * This endpoint is used to create a [metric](/core-concepts###metric) using a SQL string. See * [SQL support](/extensibility/advanced-metrics#sql-support) for a description of constructing @@ -24,7 +31,7 @@ interface MetricServiceAsync { fun create( params: MetricCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This endpoint allows you to update the `metadata` property on a metric. If you pass `null` @@ -34,7 +41,7 @@ interface MetricServiceAsync { fun update( params: MetricUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This endpoint is used to fetch [metric](/core-concepts##metric) details given a metric @@ -63,5 +70,65 @@ interface MetricServiceAsync { fun fetch( params: MetricFetchParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture + + /** + * A view of [MetricServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /metrics`, but is otherwise the same as + * [MetricServiceAsync.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: MetricCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `put /metrics/{metric_id}`, but is otherwise the same as + * [MetricServiceAsync.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: MetricUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /metrics`, but is otherwise the same as + * [MetricServiceAsync.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: MetricListParams = MetricListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /metrics`, but is otherwise the same as + * [MetricServiceAsync.list]. + */ + @MustBeClosed + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(MetricListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /metrics/{metric_id}`, but is otherwise the same as + * [MetricServiceAsync.fetch]. + */ + @JvmOverloads + @MustBeClosed + fun fetch( + params: MetricFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } 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 4e713bf68..de7bcbebc 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 @@ -10,10 +10,12 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest import com.withorb.api.core.http.HttpResponse.Handler -import com.withorb.api.core.json +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.errors.OrbError -import com.withorb.api.models.BillableMetric +import com.withorb.api.models.BillableMetricModel import com.withorb.api.models.MetricCreateParams import com.withorb.api.models.MetricFetchParams import com.withorb.api.models.MetricListPageAsync @@ -24,131 +26,172 @@ import java.util.concurrent.CompletableFuture class MetricServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : MetricServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: MetricServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): MetricServiceAsync.WithRawResponse = withRawResponse - /** - * This endpoint is used to create a [metric](/core-concepts###metric) using a SQL string. See - * [SQL support](/extensibility/advanced-metrics#sql-support) for a description of constructing - * SQL queries with examples. - */ override fun create( params: MetricCreateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("metrics") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } + ): CompletableFuture = + // post /metrics + withRawResponse().create(params, requestOptions).thenApply { it.parse() } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint allows you to update the `metadata` property on a metric. If you pass `null` - * for the metadata value, it will clear any existing metadata for that invoice. - */ override fun update( params: MetricUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("metrics", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } + ): CompletableFuture = + // put /metrics/{metric_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * 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. - */ override fun list( params: MetricListParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("metrics") - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - .let { MetricListPageAsync.of(this, params, it) } - } - } + ): CompletableFuture = + // get /metrics + withRawResponse().list(params, requestOptions).thenApply { it.parse() } - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint is used to list [metrics](/core-concepts#metric). It returns information about - * the metrics including its name, description, and item. - */ override fun fetch( params: MetricFetchParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("metrics", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): CompletableFuture = + // get /metrics/{metric_id} + withRawResponse().fetch(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + MetricServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun create( + params: MetricCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("metrics") + .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 -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun update( + params: MetricUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("metrics", params.getPathParam(0)) + .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 -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: MetricListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("metrics") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + MetricListPageAsync.of( + MetricServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } + } + + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun fetch( + params: MetricFetchParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("metrics", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } 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 4f1bbf319..4318a22ba 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 @@ -4,18 +4,25 @@ package com.withorb.api.services.async +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions -import com.withorb.api.models.Plan +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.PlanCreateParams import com.withorb.api.models.PlanFetchParams import com.withorb.api.models.PlanListPageAsync import com.withorb.api.models.PlanListParams +import com.withorb.api.models.PlanModel import com.withorb.api.models.PlanUpdateParams import com.withorb.api.services.async.plans.ExternalPlanIdServiceAsync import java.util.concurrent.CompletableFuture interface PlanServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + fun externalPlanId(): ExternalPlanIdServiceAsync /** This endpoint allows creation of plans including their prices. */ @@ -23,7 +30,7 @@ interface PlanServiceAsync { fun create( params: PlanCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This endpoint can be used to update the `external_plan_id`, and `metadata` of an existing @@ -35,7 +42,7 @@ interface PlanServiceAsync { fun update( params: PlanUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This endpoint returns a list of all [plans](/core-concepts#plan-and-price) for an account in @@ -80,5 +87,65 @@ interface PlanServiceAsync { fun fetch( params: PlanFetchParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture + + /** A view of [PlanServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + fun externalPlanId(): ExternalPlanIdServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /plans`, but is otherwise the same as + * [PlanServiceAsync.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: PlanCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `put /plans/{plan_id}`, but is otherwise the same as + * [PlanServiceAsync.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: PlanUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /plans`, but is otherwise the same as + * [PlanServiceAsync.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: PlanListParams = PlanListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /plans`, but is otherwise the same as + * [PlanServiceAsync.list]. + */ + @MustBeClosed + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(PlanListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /plans/{plan_id}`, but is otherwise the same as + * [PlanServiceAsync.fetch]. + */ + @JvmOverloads + @MustBeClosed + fun fetch( + params: PlanFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } 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 71d70f3ad..5cf90f9f3 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 @@ -10,14 +10,16 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest import com.withorb.api.core.http.HttpResponse.Handler -import com.withorb.api.core.json +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.errors.OrbError -import com.withorb.api.models.Plan import com.withorb.api.models.PlanCreateParams import com.withorb.api.models.PlanFetchParams import com.withorb.api.models.PlanListPageAsync import com.withorb.api.models.PlanListParams +import com.withorb.api.models.PlanModel import com.withorb.api.models.PlanUpdateParams import com.withorb.api.services.async.plans.ExternalPlanIdServiceAsync import com.withorb.api.services.async.plans.ExternalPlanIdServiceAsyncImpl @@ -26,150 +28,181 @@ import java.util.concurrent.CompletableFuture class PlanServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : PlanServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: PlanServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } private val externalPlanId: ExternalPlanIdServiceAsync by lazy { ExternalPlanIdServiceAsyncImpl(clientOptions) } - override fun externalPlanId(): ExternalPlanIdServiceAsync = externalPlanId + override fun withRawResponse(): PlanServiceAsync.WithRawResponse = withRawResponse - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun externalPlanId(): ExternalPlanIdServiceAsync = externalPlanId - /** This endpoint allows creation of plans including their prices. */ override fun create( params: PlanCreateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("plans") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } - - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // post /plans + withRawResponse().create(params, requestOptions).thenApply { it.parse() } - /** - * This endpoint can be used to update the `external_plan_id`, and `metadata` of an existing - * plan. - * - * Other fields on a customer are currently immutable. - */ override fun update( params: PlanUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("plans", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + ): CompletableFuture = + // put /plans/{plan_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } - /** - * This endpoint returns a list of all [plans](/core-concepts#plan-and-price) for an account in - * a list format. The list of plans is ordered starting from the most recently created plan. The - * response also includes [`pagination_metadata`](/api-reference/pagination), which lets the - * caller retrieve the next page of results if they exist. - */ override fun list( params: PlanListParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("plans") - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - .let { PlanListPageAsync.of(this, params, it) } - } - } + ): CompletableFuture = + // get /plans + withRawResponse().list(params, requestOptions).thenApply { it.parse() } - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint is used to fetch [plan](/core-concepts#plan-and-price) details given a plan - * identifier. It returns information about the prices included in the plan and their - * configuration, as well as the product that the plan is attached to. - * - * ## Serialized prices - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given [Price](/core-concepts#plan-and-price) object. The - * `model_type` field determines the key for the configuration object that is present. A - * detailed explanation of price types can be found in the - * [Price schema](/core-concepts#plan-and-price). - * - * ## Phases - * - * Orb supports plan phases, also known as contract ramps. For plans with phases, the serialized - * prices refer to all prices across all phases. - */ override fun fetch( params: PlanFetchParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("plans", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): CompletableFuture = + // get /plans/{plan_id} + withRawResponse().fetch(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + PlanServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val externalPlanId: ExternalPlanIdServiceAsync.WithRawResponse by lazy { + ExternalPlanIdServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun externalPlanId(): ExternalPlanIdServiceAsync.WithRawResponse = externalPlanId + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: PlanCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("plans") + .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 -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: PlanUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("plans", params.getPathParam(0)) + .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 -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: PlanListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("plans") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + PlanListPageAsync.of( + PlanServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } + } + + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetch( + params: PlanFetchParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("plans", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } 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 64ce49d94..8632a7274 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 @@ -4,20 +4,27 @@ package com.withorb.api.services.async +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions -import com.withorb.api.models.Price +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.PriceCreateParams import com.withorb.api.models.PriceEvaluateParams import com.withorb.api.models.PriceEvaluateResponse import com.withorb.api.models.PriceFetchParams import com.withorb.api.models.PriceListPageAsync import com.withorb.api.models.PriceListParams +import com.withorb.api.models.PriceModel import com.withorb.api.models.PriceUpdateParams import com.withorb.api.services.async.prices.ExternalPriceIdServiceAsync import java.util.concurrent.CompletableFuture interface PriceServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + fun externalPriceId(): ExternalPriceIdServiceAsync /** @@ -36,7 +43,7 @@ interface PriceServiceAsync { fun create( params: PriceCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This endpoint allows you to update the `metadata` property on a price. If you pass null for @@ -46,7 +53,7 @@ interface PriceServiceAsync { fun update( params: PriceUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This endpoint is used to list all add-on prices created using the @@ -95,5 +102,76 @@ interface PriceServiceAsync { fun fetch( params: PriceFetchParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture + + /** A view of [PriceServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + fun externalPriceId(): ExternalPriceIdServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /prices`, but is otherwise the same as + * [PriceServiceAsync.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: PriceCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `put /prices/{price_id}`, but is otherwise the same as + * [PriceServiceAsync.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: PriceUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /prices`, but is otherwise the same as + * [PriceServiceAsync.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: PriceListParams = PriceListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /prices`, but is otherwise the same as + * [PriceServiceAsync.list]. + */ + @MustBeClosed + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(PriceListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /prices/{price_id}/evaluate`, but is otherwise the + * same as [PriceServiceAsync.evaluate]. + */ + @JvmOverloads + @MustBeClosed + fun evaluate( + params: PriceEvaluateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /prices/{price_id}`, but is otherwise the same as + * [PriceServiceAsync.fetch]. + */ + @JvmOverloads + @MustBeClosed + fun fetch( + params: PriceFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } 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 062cebec8..bf9733be9 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 @@ -10,16 +10,18 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest import com.withorb.api.core.http.HttpResponse.Handler -import com.withorb.api.core.json +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.errors.OrbError -import com.withorb.api.models.Price import com.withorb.api.models.PriceCreateParams import com.withorb.api.models.PriceEvaluateParams import com.withorb.api.models.PriceEvaluateResponse import com.withorb.api.models.PriceFetchParams import com.withorb.api.models.PriceListPageAsync import com.withorb.api.models.PriceListParams +import com.withorb.api.models.PriceModel import com.withorb.api.models.PriceUpdateParams import com.withorb.api.services.async.prices.ExternalPriceIdServiceAsync import com.withorb.api.services.async.prices.ExternalPriceIdServiceAsyncImpl @@ -28,186 +30,220 @@ import java.util.concurrent.CompletableFuture class PriceServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : PriceServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: PriceServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } private val externalPriceId: ExternalPriceIdServiceAsync by lazy { ExternalPriceIdServiceAsyncImpl(clientOptions) } + override fun withRawResponse(): PriceServiceAsync.WithRawResponse = withRawResponse + override fun externalPriceId(): ExternalPriceIdServiceAsync = externalPriceId - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint is used to create a [price](/product-catalog/price-configuration). A price - * created using this endpoint is always an add-on, meaning that it’s not associated with a - * specific plan and can instead be individually added to subscriptions, including subscriptions - * on different plans. - * - * An `external_price_id` can be optionally specified as an alias to allow ergonomic interaction - * with prices in the Orb API. - * - * See the [Price resource](/product-catalog/price-configuration) for the specification of - * different price model configurations possible in this endpoint. - */ override fun create( params: PriceCreateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("prices") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } - - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // post /prices + withRawResponse().create(params, requestOptions).thenApply { it.parse() } - /** - * 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. - */ override fun update( params: PriceUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("prices", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } + ): CompletableFuture = + // put /prices/{price_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * This endpoint is used to list all add-on prices created using the - * [price creation endpoint](/api-reference/price/create-price). - */ override fun list( params: PriceListParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("prices") - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - .let { PriceListPageAsync.of(this, params, it) } - } - } + ): CompletableFuture = + // get /prices + withRawResponse().list(params, requestOptions).thenApply { it.parse() } - private val evaluateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * 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. - */ override fun evaluate( params: PriceEvaluateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("prices", params.getPathParam(0), "evaluate") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { evaluateHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } - - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // post /prices/{price_id}/evaluate + withRawResponse().evaluate(params, requestOptions).thenApply { it.parse() } - /** This endpoint returns a price given an identifier. */ override fun fetch( params: PriceFetchParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("prices", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): CompletableFuture = + // get /prices/{price_id} + withRawResponse().fetch(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + PriceServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val externalPriceId: ExternalPriceIdServiceAsync.WithRawResponse by lazy { + ExternalPriceIdServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun externalPriceId(): ExternalPriceIdServiceAsync.WithRawResponse = + externalPriceId + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: PriceCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("prices") + .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 -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: PriceUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("prices", params.getPathParam(0)) + .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 -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: PriceListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("prices") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + PriceListPageAsync.of( + PriceServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } + } + + private val evaluateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun evaluate( + params: PriceEvaluateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("prices", params.getPathParam(0), "evaluate") + .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 -> + response.parseable { + response + .use { evaluateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetch( + params: PriceFetchParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("prices", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } 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 1438db3f5..53aa880f8 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 @@ -4,12 +4,12 @@ package com.withorb.api.services.async +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions -import com.withorb.api.models.Subscription +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.MutatedSubscriptionModel import com.withorb.api.models.SubscriptionCancelParams -import com.withorb.api.models.SubscriptionCancelResponse import com.withorb.api.models.SubscriptionCreateParams -import com.withorb.api.models.SubscriptionCreateResponse import com.withorb.api.models.SubscriptionFetchCostsParams import com.withorb.api.models.SubscriptionFetchCostsResponse import com.withorb.api.models.SubscriptionFetchParams @@ -18,28 +18,26 @@ import com.withorb.api.models.SubscriptionFetchScheduleParams import com.withorb.api.models.SubscriptionFetchUsageParams import com.withorb.api.models.SubscriptionListPageAsync import com.withorb.api.models.SubscriptionListParams +import com.withorb.api.models.SubscriptionModel import com.withorb.api.models.SubscriptionPriceIntervalsParams -import com.withorb.api.models.SubscriptionPriceIntervalsResponse import com.withorb.api.models.SubscriptionSchedulePlanChangeParams -import com.withorb.api.models.SubscriptionSchedulePlanChangeResponse import com.withorb.api.models.SubscriptionTriggerPhaseParams -import com.withorb.api.models.SubscriptionTriggerPhaseResponse import com.withorb.api.models.SubscriptionUnscheduleCancellationParams -import com.withorb.api.models.SubscriptionUnscheduleCancellationResponse import com.withorb.api.models.SubscriptionUnscheduleFixedFeeQuantityUpdatesParams -import com.withorb.api.models.SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse import com.withorb.api.models.SubscriptionUnschedulePendingPlanChangesParams -import com.withorb.api.models.SubscriptionUnschedulePendingPlanChangesResponse import com.withorb.api.models.SubscriptionUpdateFixedFeeQuantityParams -import com.withorb.api.models.SubscriptionUpdateFixedFeeQuantityResponse import com.withorb.api.models.SubscriptionUpdateParams import com.withorb.api.models.SubscriptionUpdateTrialParams -import com.withorb.api.models.SubscriptionUpdateTrialResponse import com.withorb.api.models.SubscriptionUsage import java.util.concurrent.CompletableFuture interface SubscriptionServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * A subscription represents the purchase of a plan by a customer. The customer is identified by * either the `customer_id` or the `external_customer_id`, and exactly one of these fields must @@ -282,7 +280,7 @@ interface SubscriptionServiceAsync { fun create( params: SubscriptionCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This endpoint can be used to update the `metadata`, `net terms`, `auto_collection`, @@ -292,7 +290,7 @@ interface SubscriptionServiceAsync { fun update( params: SubscriptionUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This endpoint returns a list of all subscriptions for an account as a @@ -380,7 +378,7 @@ interface SubscriptionServiceAsync { fun cancel( params: SubscriptionCancelParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This endpoint is used to fetch a [Subscription](/core-concepts##subscription) given an @@ -390,7 +388,7 @@ interface SubscriptionServiceAsync { fun fetch( params: SubscriptionFetchParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This endpoint is used to fetch a day-by-day snapshot of a subscription's costs in Orb, @@ -674,7 +672,7 @@ interface SubscriptionServiceAsync { fun priceIntervals( params: SubscriptionPriceIntervalsParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This endpoint can be used to change an existing subscription's plan. It returns the @@ -846,7 +844,7 @@ interface SubscriptionServiceAsync { fun schedulePlanChange( params: SubscriptionSchedulePlanChangeParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * Manually trigger a phase, effective the given date (or the current time, if not specified). @@ -855,7 +853,7 @@ interface SubscriptionServiceAsync { fun triggerPhase( params: SubscriptionTriggerPhaseParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This endpoint can be used to unschedule any pending cancellations for a subscription. @@ -868,7 +866,7 @@ interface SubscriptionServiceAsync { fun unscheduleCancellation( params: SubscriptionUnscheduleCancellationParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This endpoint can be used to clear scheduled updates to the quantity for a fixed fee. @@ -880,7 +878,7 @@ interface SubscriptionServiceAsync { fun unscheduleFixedFeeQuantityUpdates( params: SubscriptionUnscheduleFixedFeeQuantityUpdatesParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This endpoint can be used to unschedule any pending plan changes on an existing subscription. @@ -889,7 +887,7 @@ interface SubscriptionServiceAsync { fun unschedulePendingPlanChanges( params: SubscriptionUnschedulePendingPlanChangesParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This endpoint can be used to update the quantity for a fixed fee. @@ -909,7 +907,7 @@ interface SubscriptionServiceAsync { fun updateFixedFeeQuantity( params: SubscriptionUpdateFixedFeeQuantityParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This endpoint is used to update the trial end date for a subscription. The new trial end date @@ -933,5 +931,203 @@ interface SubscriptionServiceAsync { fun updateTrial( params: SubscriptionUpdateTrialParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture + + /** + * A view of [SubscriptionServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /subscriptions`, but is otherwise the same as + * [SubscriptionServiceAsync.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: SubscriptionCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `put /subscriptions/{subscription_id}`, but is otherwise + * the same as [SubscriptionServiceAsync.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: SubscriptionUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /subscriptions`, but is otherwise the same as + * [SubscriptionServiceAsync.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: SubscriptionListParams = SubscriptionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /subscriptions`, but is otherwise the same as + * [SubscriptionServiceAsync.list]. + */ + @MustBeClosed + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(SubscriptionListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /subscriptions/{subscription_id}/cancel`, but is + * otherwise the same as [SubscriptionServiceAsync.cancel]. + */ + @JvmOverloads + @MustBeClosed + fun cancel( + params: SubscriptionCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /subscriptions/{subscription_id}`, but is otherwise + * the same as [SubscriptionServiceAsync.fetch]. + */ + @JvmOverloads + @MustBeClosed + fun fetch( + params: SubscriptionFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /subscriptions/{subscription_id}/costs`, but is + * otherwise the same as [SubscriptionServiceAsync.fetchCosts]. + */ + @JvmOverloads + @MustBeClosed + fun fetchCosts( + params: SubscriptionFetchCostsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /subscriptions/{subscription_id}/schedule`, but is + * otherwise the same as [SubscriptionServiceAsync.fetchSchedule]. + */ + @JvmOverloads + @MustBeClosed + fun fetchSchedule( + params: SubscriptionFetchScheduleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /subscriptions/{subscription_id}/usage`, but is + * otherwise the same as [SubscriptionServiceAsync.fetchUsage]. + */ + @JvmOverloads + @MustBeClosed + fun fetchUsage( + params: SubscriptionFetchUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /subscriptions/{subscription_id}/price_intervals`, + * but is otherwise the same as [SubscriptionServiceAsync.priceIntervals]. + */ + @JvmOverloads + @MustBeClosed + fun priceIntervals( + params: SubscriptionPriceIntervalsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post + * /subscriptions/{subscription_id}/schedule_plan_change`, but is otherwise the same as + * [SubscriptionServiceAsync.schedulePlanChange]. + */ + @JvmOverloads + @MustBeClosed + fun schedulePlanChange( + params: SubscriptionSchedulePlanChangeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /subscriptions/{subscription_id}/trigger_phase`, + * but is otherwise the same as [SubscriptionServiceAsync.triggerPhase]. + */ + @JvmOverloads + @MustBeClosed + fun triggerPhase( + params: SubscriptionTriggerPhaseParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post + * /subscriptions/{subscription_id}/unschedule_cancellation`, but is otherwise the same as + * [SubscriptionServiceAsync.unscheduleCancellation]. + */ + @JvmOverloads + @MustBeClosed + fun unscheduleCancellation( + params: SubscriptionUnscheduleCancellationParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post + * /subscriptions/{subscription_id}/unschedule_fixed_fee_quantity_updates`, but is otherwise + * the same as [SubscriptionServiceAsync.unscheduleFixedFeeQuantityUpdates]. + */ + @JvmOverloads + @MustBeClosed + fun unscheduleFixedFeeQuantityUpdates( + params: SubscriptionUnscheduleFixedFeeQuantityUpdatesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post + * /subscriptions/{subscription_id}/unschedule_pending_plan_changes`, but is otherwise the + * same as [SubscriptionServiceAsync.unschedulePendingPlanChanges]. + */ + @JvmOverloads + @MustBeClosed + fun unschedulePendingPlanChanges( + params: SubscriptionUnschedulePendingPlanChangesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post + * /subscriptions/{subscription_id}/update_fixed_fee_quantity`, but is otherwise the same as + * [SubscriptionServiceAsync.updateFixedFeeQuantity]. + */ + @JvmOverloads + @MustBeClosed + fun updateFixedFeeQuantity( + params: SubscriptionUpdateFixedFeeQuantityParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /subscriptions/{subscription_id}/update_trial`, but + * is otherwise the same as [SubscriptionServiceAsync.updateTrial]. + */ + @JvmOverloads + @MustBeClosed + fun updateTrial( + params: SubscriptionUpdateTrialParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncImpl.kt index 0d2ba7b81..4d20df3f3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncImpl.kt @@ -10,14 +10,14 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest import com.withorb.api.core.http.HttpResponse.Handler -import com.withorb.api.core.json +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.errors.OrbError -import com.withorb.api.models.Subscription +import com.withorb.api.models.MutatedSubscriptionModel import com.withorb.api.models.SubscriptionCancelParams -import com.withorb.api.models.SubscriptionCancelResponse import com.withorb.api.models.SubscriptionCreateParams -import com.withorb.api.models.SubscriptionCreateResponse import com.withorb.api.models.SubscriptionFetchCostsParams import com.withorb.api.models.SubscriptionFetchCostsResponse import com.withorb.api.models.SubscriptionFetchParams @@ -26,1270 +26,669 @@ import com.withorb.api.models.SubscriptionFetchScheduleParams import com.withorb.api.models.SubscriptionFetchUsageParams import com.withorb.api.models.SubscriptionListPageAsync import com.withorb.api.models.SubscriptionListParams +import com.withorb.api.models.SubscriptionModel import com.withorb.api.models.SubscriptionPriceIntervalsParams -import com.withorb.api.models.SubscriptionPriceIntervalsResponse import com.withorb.api.models.SubscriptionSchedulePlanChangeParams -import com.withorb.api.models.SubscriptionSchedulePlanChangeResponse import com.withorb.api.models.SubscriptionTriggerPhaseParams -import com.withorb.api.models.SubscriptionTriggerPhaseResponse import com.withorb.api.models.SubscriptionUnscheduleCancellationParams -import com.withorb.api.models.SubscriptionUnscheduleCancellationResponse import com.withorb.api.models.SubscriptionUnscheduleFixedFeeQuantityUpdatesParams -import com.withorb.api.models.SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse import com.withorb.api.models.SubscriptionUnschedulePendingPlanChangesParams -import com.withorb.api.models.SubscriptionUnschedulePendingPlanChangesResponse import com.withorb.api.models.SubscriptionUpdateFixedFeeQuantityParams -import com.withorb.api.models.SubscriptionUpdateFixedFeeQuantityResponse import com.withorb.api.models.SubscriptionUpdateParams import com.withorb.api.models.SubscriptionUpdateTrialParams -import com.withorb.api.models.SubscriptionUpdateTrialResponse import com.withorb.api.models.SubscriptionUsage import java.util.concurrent.CompletableFuture class SubscriptionServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : SubscriptionServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: SubscriptionServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): SubscriptionServiceAsync.WithRawResponse = withRawResponse - /** - * A subscription represents the purchase of a plan by a customer. The customer is identified by - * either the `customer_id` or the `external_customer_id`, and exactly one of these fields must - * be provided. - * - * By default, subscriptions begin on the day that they're created and renew automatically for - * each billing cycle at the cadence that's configured in the plan definition. - * - * The default configuration for subscriptions in Orb is **In-advance billing** and **Beginning - * of month alignment** (see [Subscription](/core-concepts##subscription) for more details). - * - * In order to change the alignment behavior, Orb also supports billing subscriptions on the day - * of the month they are created. If `align_billing_with_subscription_start_date = true` is - * specified, subscriptions have billing cycles that are aligned with their `start_date`. For - * example, a subscription that begins on January 15th will have a billing cycle from January - * 15th to February 15th. Every subsequent billing cycle will continue to start and invoice on - * the 15th. - * - * If the "day" value is greater than the number of days in the month, the next billing cycle - * will start at the end of the month. For example, if the start_date is January 31st, the next - * billing cycle will start on February 28th. - * - * If a customer was created with a currency, Orb only allows subscribing the customer to a plan - * with a matching `invoicing_currency`. If the customer does not have a currency set, on - * subscription creation, we set the customer's currency to be the `invoicing_currency` of the - * plan. - * - * ## Customize your customer's subscriptions - * - * Prices and adjustments in a plan can be added, removed, or replaced for the subscription - * being created. This is useful when a customer has prices that differ from the default prices - * for a specific plan. - * - * This feature is only available for accounts that have migrated to Subscription - * Overrides Version 2. You can find your Subscription Overrides Version at the bottom of your - * [Plans page](https://app.withorb.com/plans) - * - * ### Adding Prices - * - * To add prices, provide a list of objects with the key `add_prices`. An object in the list - * must specify an existing add-on price with a `price_id` or `external_price_id` field, or - * create a new add-on price by including an object with the key `price`, identical to what - * would be used in the request body for the - * [create price endpoint](/api-reference/price/create-price). See the - * [Price resource](/product-catalog/price-configuration) for the specification of different - * price model configurations possible in this object. - * - * If the plan has phases, each object in the list must include a number with `plan_phase_order` - * key to indicate which phase the price should be added to. - * - * An object in the list can specify an optional `start_date` and optional `end_date`. This is - * equivalent to creating a price interval with the - * [add/edit price intervals endpoint](/api-reference/price-interval/add-or-edit-price-intervals). - * If unspecified, the start or end date of the phase or subscription will be used. - * - * An object in the list can specify an optional `minimum_amount`, `maximum_amount`, or - * `discounts`. This will create adjustments which apply only to this price. - * - * Additionally, an object in the list can specify an optional `reference_id`. This ID can be - * used to reference this price when [adding an adjustment](#adding-adjustments) in the same API - * call. However the ID is _transient_ and cannot be used to refer to the price in future API - * calls. - * - * ### Removing Prices - * - * To remove prices, provide a list of objects with the key `remove_prices`. An object in the - * list must specify a plan price with either a `price_id` or `external_price_id` field. - * - * ### Replacing Prices - * - * To replace prices, provide a list of objects with the key `replace_prices`. An object in the - * list must specify a plan price to replace with the `replaces_price_id` key, and it must - * specify a price to replace it with by either referencing an existing add-on price with a - * `price_id` or `external_price_id` field, or by creating a new add-on price by including an - * object with the key `price`, identical to what would be used in the request body for the - * [create price endpoint](/api-reference/price/create-price). See the - * [Price resource](/product-catalog/price-configuration) for the specification of different - * price model configurations possible in this object. - * - * For fixed fees, an object in the list can supply a `fixed_price_quantity` instead of a - * `price`, `price_id`, or `external_price_id` field. This will update only the quantity for the - * price, similar to the - * [Update price quantity](/api-reference/subscription/update-price-quantity) endpoint. - * - * The replacement price will have the same phase, if applicable, and the same start and end - * dates as the price it replaces. - * - * An object in the list can specify an optional `minimum_amount`, `maximum_amount`, or - * `discounts`. This will create adjustments which apply only to this price. - * - * Additionally, an object in the list can specify an optional `reference_id`. This ID can be - * used to reference the replacement price when [adding an adjustment](#adding-adjustments) in - * the same API call. However the ID is _transient_ and cannot be used to refer to the price in - * future API calls. - * - * ### Adding adjustments - * - * To add adjustments, provide a list of objects with the key `add_adjustments`. An object in - * the list must include an object with the key `adjustment`, identical to the adjustment object - * in the - * [add/edit price intervals endpoint](/api-reference/price-interval/add-or-edit-price-intervals). - * - * If the plan has phases, each object in the list must include a number with `plan_phase_order` - * key to indicate which phase the adjustment should be added to. - * - * An object in the list can specify an optional `start_date` and optional `end_date`. If - * unspecified, the start or end date of the phase or subscription will be used. - * - * ### Removing adjustments - * - * To remove adjustments, provide a list of objects with the key `remove_adjustments`. An object - * in the list must include a key, `adjustment_id`, with the ID of the adjustment to be removed. - * - * ### Replacing adjustments - * - * To replace adjustments, provide a list of objects with the key `replace_adjustments`. An - * object in the list must specify a plan adjustment to replace with the - * `replaces_adjustment_id` key, and it must specify an adjustment to replace it with by - * including an object with the key `adjustment`, identical to the adjustment object in the - * [add/edit price intervals endpoint](/api-reference/price-interval/add-or-edit-price-intervals). - * - * The replacement adjustment will have the same phase, if applicable, and the same start and - * end dates as the adjustment it replaces. - * - * ## Price overrides (DEPRECATED) - * - * Price overrides are being phased out in favor adding/removing/replacing prices. (See - * [Customize your customer's subscriptions](/api-reference/subscription/create-subscription)) - * - * - * Price overrides are used to update some or all prices in a plan for the specific subscription - * being created. This is useful when a new customer has negotiated a rate that is unique to the - * customer. - * - * To override prices, provide a list of objects with the key `price_overrides`. The price - * object in the list of overrides is expected to contain the existing price id, the - * `model_type` and configuration. (See the - * [Price resource](/product-catalog/price-configuration) for the specification of different - * price model configurations.) The numerical values can be updated, but the billable metric, - * cadence, type, and name of a price can not be overridden. - * - * ### Maximums and Minimums - * - * Minimums and maximums, much like price overrides, can be useful when a new customer has - * negotiated a new or different minimum or maximum spend cap than the default for a given - * price. If one exists for a price and null is provided for the minimum/maximum override on - * creation, then there will be no minimum/maximum on the new subscription. If no value is - * provided, then the default price maximum or minimum is used. - * - * To add a minimum for a specific price, add `minimum_amount` to the specific price in the - * `price_overrides` object. - * - * To add a maximum for a specific price, add `maximum_amount` to the specific price in the - * `price_overrides` object. - * - * ### Minimum override example - * - * Price minimum override example: - * ```json - * { - * ... - * "id": "price_id", - * "model_type": "unit", - * "unit_config": { - * "unit_amount": "0.50" - * }, - * "minimum_amount": "100.00" - * ... - * } - * ``` - * - * Removing an existing minimum example - * - * ```json - * { - * ... - * "id": "price_id", - * "model_type": "unit", - * "unit_config": { - * "unit_amount": "0.50" - * }, - * "minimum_amount": null - * ... - * } - * ``` - * - * ### Discounts - * - * Discounts, like price overrides, can be useful when a new customer has negotiated a new or - * different discount than the default for a price. If a discount exists for a price and a null - * discount is provided on creation, then there will be no discount on the new subscription. - * - * To add a discount for a specific price, add `discount` to the price in the `price_overrides` - * object. Discount should be a dictionary of the format: - * ```ts - * { - * "discount_type": "amount" | "percentage" | "usage", - * "amount_discount": string, - * "percentage_discount": string, - * "usage_discount": string - * } - * ``` - * - * where either `amount_discount`, `percentage_discount`, or `usage_discount` is provided. - * - * Price discount example - * - * ```json - * { - * ... - * "id": "price_id", - * "model_type": "unit", - * "unit_config": { - * "unit_amount": "0.50" - * }, - * "discount": {"discount_type": "amount", "amount_discount": "175"}, - * } - * ``` - * - * Removing an existing discount example - * - * ```json - * { - * "customer_id": "customer_id", - * "plan_id": "plan_id", - * "discount": null, - * "price_overrides": [ ... ] - * ... - * } - * ``` - * - * ## Threshold Billing - * - * Orb supports invoicing for a subscription when a preconfigured usage threshold is hit. To - * enable threshold billing, pass in an `invoicing_threshold`, which is specified in the - * subscription's invoicing currency, when creating a subscription. E.g. pass in `10.00` to - * issue an invoice when usage amounts hit $10.00 for a subscription that invoices in USD. - */ override fun create( params: SubscriptionCreateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("subscriptions") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } - - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // post /subscriptions + withRawResponse().create(params, requestOptions).thenApply { it.parse() } - /** - * This endpoint can be used to update the `metadata`, `net terms`, `auto_collection`, - * `invoicing_threshold`, and `default_invoice_memo` properties on a subscription. - */ override fun update( params: SubscriptionUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("subscriptions", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } + ): CompletableFuture = + // put /subscriptions/{subscription_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * This endpoint returns a list of all subscriptions for an account as a - * [paginated](/api-reference/pagination) list, ordered starting from the most recently created - * subscription. For a full discussion of the subscription resource, see - * [Subscription](/core-concepts##subscription). - * - * Subscriptions can be filtered for a specific customer by using either the customer_id or - * external_customer_id query parameters. To filter subscriptions for multiple customers, use - * the customer_id[] or external_customer_id[] query parameters. - */ override fun list( params: SubscriptionListParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("subscriptions") - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - .let { SubscriptionListPageAsync.of(this, params, it) } - } - } - - private val cancelHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + ): CompletableFuture = + // get /subscriptions + withRawResponse().list(params, requestOptions).thenApply { it.parse() } - /** - * This endpoint can be used to cancel an existing subscription. It returns the serialized - * subscription object with an `end_date` parameter that signifies when the subscription will - * transition to an ended state. - * - * The body parameter `cancel_option` determines the cancellation behavior. Orb supports three - * cancellation options: - * - `end_of_subscription_term`: stops the subscription from auto-renewing. Subscriptions that - * have been cancelled with this option can still incur charges for the remainder of their - * term: - * - Issuing this cancellation request for a monthly subscription will keep the subscription - * active until the start of the subsequent month, and potentially issue an invoice for - * any usage charges incurred in the intervening period. - * - Issuing this cancellation request for a quarterly subscription will keep the - * subscription active until the end of the quarter and potentially issue an invoice for - * any usage charges incurred in the intervening period. - * - Issuing this cancellation request for a yearly subscription will keep the subscription - * active for the full year. For example, a yearly subscription starting on 2021-11-01 and - * cancelled on 2021-12-08 will remain active until 2022-11-01 and potentially issue - * charges in the intervening months for any recurring monthly usage charges in its plan. - * - **Note**: If a subscription's plan contains prices with difference cadences, the end of - * term date will be determined by the largest cadence value. For example, cancelling end - * of term for a subscription with a quarterly fixed fee with a monthly usage fee will - * result in the subscription ending at the end of the quarter. - * - `immediate`: ends the subscription immediately, setting the `end_date` to the current time: - * - Subscriptions that have been cancelled with this option will be invoiced immediately. - * This invoice will include any usage fees incurred in the billing period up to the - * cancellation, along with any prorated recurring fees for the billing period, if - * applicable. - * - **Note**: If the subscription has a recurring fee that was paid in-advance, the - * prorated amount for the remaining time period will be added to the - * [customer's balance](list-balance-transactions) upon immediate cancellation. However, - * if the customer is ineligible to use the customer balance, the subscription cannot be - * cancelled immediately. - * - `requested_date`: ends the subscription on a specified date, which requires a - * `cancellation_date` to be passed in. If no timezone is provided, the customer's timezone is - * used. For example, a subscription starting on January 1st with a monthly price can be set - * to be cancelled on the first of any month after January 1st (e.g. March 1st, April 1st, May - * 1st). A subscription with multiple prices with different cadences defines the "term" to be - * the highest cadence of the prices. - * - * Upcoming subscriptions are only eligible for immediate cancellation, which will set the - * `end_date` equal to the `start_date` upon cancellation. - * - * ## Backdated cancellations - * - * Orb allows you to cancel a subscription in the past as long as there are no paid invoices - * between the `requested_date` and the current time. If the cancellation is after the latest - * issued invoice, Orb will generate a balance refund for the current period. If the - * cancellation is before the most recently issued invoice, Orb will void the intervening - * invoice and generate a new one based on the new dates for the subscription. See the section - * on [cancellation behaviors](/product-catalog/creating-subscriptions#cancellation-behaviors). - */ override fun cancel( params: SubscriptionCancelParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("subscriptions", params.getPathParam(0), "cancel") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { cancelHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } + ): CompletableFuture = + // post /subscriptions/{subscription_id}/cancel + withRawResponse().cancel(params, requestOptions).thenApply { it.parse() } - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint is used to fetch a [Subscription](/core-concepts##subscription) given an - * identifier. - */ override fun fetch( params: SubscriptionFetchParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("subscriptions", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } - - private val fetchCostsHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + ): CompletableFuture = + // get /subscriptions/{subscription_id} + withRawResponse().fetch(params, requestOptions).thenApply { it.parse() } - /** - * This endpoint is used to fetch a day-by-day snapshot of a subscription's costs in Orb, - * calculated by applying pricing information to the underlying usage (see the - * [subscription usage endpoint](fetch-subscription-usage) to fetch usage per metric, in usage - * 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). - */ override fun fetchCosts( params: SubscriptionFetchCostsParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("subscriptions", params.getPathParam(0), "costs") - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { fetchCostsHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } + ): CompletableFuture = + // get /subscriptions/{subscription_id}/costs + withRawResponse().fetchCosts(params, requestOptions).thenApply { it.parse() } - private val fetchScheduleHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * This endpoint returns a [paginated](/api-reference/pagination) list of all plans associated - * with a subscription along with their start and end dates. This list contains the - * subscription's initial plan along with past and future plan changes. - */ override fun fetchSchedule( params: SubscriptionFetchScheduleParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("subscriptions", params.getPathParam(0), "schedule") - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { fetchScheduleHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - .let { SubscriptionFetchSchedulePageAsync.of(this, params, it) } - } - } - - private val fetchUsageHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): CompletableFuture = + // get /subscriptions/{subscription_id}/schedule + withRawResponse().fetchSchedule(params, requestOptions).thenApply { it.parse() } - /** - * This endpoint is used to fetch a subscription's usage in Orb. Especially when combined with - * optional query parameters, this endpoint is a powerful way to build visualizations on top of - * Orb's event data and metrics. - * - * With no query parameters specified, this endpoint returns usage for the subscription's - * _current billing period_ across each billable metric that participates in the subscription. - * Usage quantities returned are the result of evaluating the metric definition for the entirety - * of the customer's billing period. - * - * ### Default response shape - * - * Orb returns a `data` array with an object corresponding to each billable metric. Nested - * within this object is a `usage` array which has a `quantity` value and a corresponding - * `timeframe_start` and `timeframe_end`. The `quantity` value represents the calculated usage - * value for the billable metric over the specified timeframe (inclusive of the - * `timeframe_start` timestamp and exclusive of the `timeframe_end` timestamp). - * - * Orb will include _every_ window in the response starting from the beginning of the billing - * period, even when there were no events (and therefore no usage) in the window. This increases - * the size of the response but prevents the caller from filling in gaps and handling cumbersome - * time-based logic. - * - * The query parameters in this endpoint serve to override this behavior and provide some key - * functionality, as listed below. Note that this functionality can also be used _in - * conjunction_ with each other, e.g. to display grouped usage on a custom timeframe. - * - * ## Custom timeframe - * - * In order to view usage for a custom timeframe rather than the current billing period, specify - * a `timeframe_start` and `timeframe_end`. This will calculate quantities for usage incurred - * between timeframe_start (inclusive) and timeframe_end (exclusive), i.e. `[timeframe_start, - * timeframe_end)`. - * - * Note: - * - These timestamps must be specified in ISO 8601 format and UTC timezone, e.g. - * `2022-02-01T05:00:00Z`. - * - Both parameters must be specified if either is specified. - * - * ## Grouping by custom attributes - * - * In order to view a single metric grouped by a specific _attribute_ that each event is tagged - * with (e.g. `cluster`), you must additionally specify a `billable_metric_id` and a `group_by` - * key. The `group_by` key denotes the event property on which to group. - * - * When returning grouped usage, only usage for `billable_metric_id` is returned, and a separate - * object in the `data` array is returned for each value of the `group_by` key present in your - * events. The `quantity` value is the result of evaluating the billable metric for events - * filtered to a single value of the `group_by` key. - * - * Orb expects that events that match the billable metric will contain values in the - * `properties` dictionary that correspond to the `group_by` key specified. By default, Orb will - * not return a `null` group (i.e. events that match the metric but do not have the key set). - * Currently, it is only possible to view usage grouped by a single attribute at a time. - * - * When viewing grouped usage, Orb uses pagination to limit the response size to 1000 groups by - * default. If there are more groups for a given subscription, pagination metadata in the - * response can be used to fetch all of the data. - * - * The following example shows usage for an "API Requests" billable metric grouped by `region`. - * Note the extra `metric_group` dictionary in the response, which provides metadata about the - * group: - * ```json - * { - * "data": [ - * { - * "usage": [ - * { - * "quantity": 0.19291, - * "timeframe_start": "2021-10-01T07:00:00Z", - * "timeframe_end": "2021-10-02T07:00:00Z", - * }, - * ... - * ], - * "metric_group": { - * "property_key": "region", - * "property_value": "asia/pacific" - * }, - * "billable_metric": { - * "id": "Fe9pbpMk86xpwdGB", - * "name": "API Requests" - * }, - * "view_mode": "periodic" - * }, - * ... - * ] - * } - * ``` - * - * ## Windowed usage - * - * The `granularity` parameter can be used to _window_ the usage `quantity` value into periods. - * When not specified, usage is returned for the entirety of the time range. - * - * When `granularity = day` is specified with a timeframe longer than a day, Orb will return a - * `quantity` value for each full day between `timeframe_start` and `timeframe_end`. Note that - * the days are demarcated by the _customer's local midnight_. - * - * For example, with `timeframe_start = 2022-02-01T05:00:00Z`, `timeframe_end = - * 2022-02-04T01:00:00Z` and `granularity=day`, the following windows will be returned for a - * customer in the `America/Los_Angeles` timezone since local midnight is `08:00` UTC: - * - `[2022-02-01T05:00:00Z, 2022-02-01T08:00:00Z)` - * - `[2022-02-01T08:00:00, 2022-02-02T08:00:00Z)` - * - `[2022-02-02T08:00:00, 2022-02-03T08:00:00Z)` - * - `[2022-02-03T08:00:00, 2022-02-04T01:00:00Z)` - * - * ```json - * { - * "data": [ - * { - * "billable_metric": { - * "id": "Q8w89wjTtBdejXKsm", - * "name": "API Requests" - * }, - * "usage": [ - * { - * "quantity": 0, - * "timeframe_end": "2022-02-01T08:00:00+00:00", - * "timeframe_start": "2022-02-01T05:00:00+00:00" - * }, - * { - * - * "quantity": 0, - * "timeframe_end": "2022-02-02T08:00:00+00:00", - * "timeframe_start": "2022-02-01T08:00:00+00:00" - * }, - * { - * "quantity": 0, - * "timeframe_end": "2022-02-03T08:00:00+00:00", - * "timeframe_start": "2022-02-02T08:00:00+00:00" - * }, - * { - * "quantity": 0, - * "timeframe_end": "2022-02-04T01:00:00+00:00", - * "timeframe_start": "2022-02-03T08:00:00+00:00" - * } - * ], - * "view_mode": "periodic" - * }, - * ... - * ] - * } - * ``` - * - * ## Decomposable vs. non-decomposable metrics - * - * Billable metrics fall into one of two categories: decomposable and non-decomposable. A - * decomposable billable metric, such as a sum or a count, can be displayed and aggregated - * across arbitrary timescales. On the other hand, a non-decomposable metric is not meaningful - * when only a slice of the billing window is considered. - * - * As an example, if we have a billable metric that's defined to count unique users, displaying - * a graph of unique users for each day is not representative of the billable metric value over - * the month (days could have an overlapping set of 'unique' users). Instead, what's useful for - * any given day is the number of unique users in the billing period so far, which are the - * _cumulative_ unique users. - * - * Accordingly, this endpoint returns treats these two types of metrics differently when - * `group_by` is specified: - * - Decomposable metrics can be grouped by any event property. - * - Non-decomposable metrics can only be grouped by the corresponding price's invoice grouping - * key. If no invoice grouping key is present, the metric does not support `group_by`. - * - * ## Matrix prices - * - * When a billable metric is attached to a price that uses matrix pricing, it's important to - * view usage grouped by those matrix dimensions. In this case, use the query parameters - * `first_dimension_key`, `first_dimension_value` and `second_dimension_key`, - * `second_dimension_value` while filtering to a specific `billable_metric_id`. - * - * For example, if your compute metric has a separate unit price (i.e. a matrix pricing model) - * per `region` and `provider`, your request might provide the following parameters: - * - `first_dimension_key`: `region` - * - `first_dimension_value`: `us-east-1` - * - `second_dimension_key`: `provider` - * - `second_dimension_value`: `aws` - */ override fun fetchUsage( params: SubscriptionFetchUsageParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("subscriptions", params.getPathParam(0), "usage") - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { fetchUsageHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } + ): CompletableFuture = + // get /subscriptions/{subscription_id}/usage + withRawResponse().fetchUsage(params, requestOptions).thenApply { it.parse() } - private val priceIntervalsHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * This endpoint is used to add and edit subscription - * [price intervals](/api-reference/price-interval/add-or-edit-price-intervals). By making - * modifications to a subscription’s price intervals, you can - * [flexibly and atomically control the billing behavior of a subscription](/product-catalog/modifying-subscriptions). - * - * ## Adding price intervals - * - * Prices can be added as price intervals to a subscription by specifying them in the `add` - * array. A `price_id` or `external_price_id` from an add-on price or previously removed plan - * price can be specified to reuse an existing price definition (however, please note that - * prices from other plans cannot be added to the subscription). Additionally, a new price can - * be specified using the `price` field — this price will be created automatically. - * - * A `start_date` must be specified for the price interval. This is the date when the price will - * start billing on the subscription, so this will notably result in an immediate charge at this - * time for any billed in advance fixed fees. The `end_date` will default to null, resulting in - * a price interval that will bill on a continually recurring basis. Both of these dates can be - * set in the past or the future and Orb will generate or modify invoices to ensure the - * subscription’s invoicing behavior is correct. - * - * Additionally, a discount, minimum, or maximum can be specified on the price interval. This - * will only apply to this price interval, not any other price intervals on the subscription. - * - * ## Adjustment intervals - * - * An adjustment interval represents the time period that a particular adjustment (a discount, - * minimum, or maximum) applies to the prices on a subscription. Adjustment intervals can be - * added to a subscription by specifying them in the `add_adjustments` array, or modified via - * the `edit_adjustments` array. When creating an adjustment interval, you'll need to provide - * the definition of the new adjustment (the type of adjustment, and which prices it applies - * to), as well as the start and end dates for the adjustment interval. The start and end dates - * of an existing adjustment interval can be edited via the `edit_adjustments` field (just like - * price intervals). (To "change" the amount of a discount, minimum, or maximum, then, you'll - * need to end the existing interval, and create a new adjustment interval with the new amount - * and a start date that matches the end date of the previous interval.) - * - * ## Editing price intervals - * - * Price intervals can be adjusted by specifying edits to make in the `edit` array. A - * `price_interval_id` to edit must be specified — this can be retrieved from the - * `price_intervals` field on the subscription. - * - * A new `start_date` or `end_date` can be specified to change the range of the price interval, - * which will modify past or future invoices to ensure correctness. If either of these dates are - * unspecified, they will default to the existing date on the price interval. To remove a price - * interval entirely from a subscription, set the `end_date` to be equivalent to the - * `start_date`. - * - * ## Fixed fee quantity transitions - * - * The fixed fee quantity transitions for a fixed fee price interval can also be specified when - * adding or editing by passing an array for `fixed_fee_quantity_transitions`. A fixed fee - * quantity transition must have a `quantity` and an `effective_date`, which is the date after - * which the new quantity will be used for billing. If a fixed fee quantity transition is - * scheduled at a billing period boundary, the full quantity will be billed on an invoice with - * the other prices on the subscription. If the fixed fee quantity transition is scheduled - * mid-billing period, the difference between the existing quantity and quantity specified in - * the transition will be prorated for the rest of the billing period and billed immediately, - * which will generate a new invoice. - * - * Notably, the list of fixed fee quantity transitions passed will overwrite the existing fixed - * fee quantity transitions on the price interval, so the entire list of transitions must be - * specified to add additional transitions. The existing list of transitions can be retrieved - * using the `fixed_fee_quantity_transitions` property on a subscription’s serialized price - * intervals. - */ override fun priceIntervals( params: SubscriptionPriceIntervalsParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("subscriptions", params.getPathParam(0), "price_intervals") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { priceIntervalsHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } - - private val schedulePlanChangeHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + ): CompletableFuture = + // post /subscriptions/{subscription_id}/price_intervals + withRawResponse().priceIntervals(params, requestOptions).thenApply { it.parse() } - /** - * This endpoint can be used to change an existing subscription's plan. It returns the - * serialized updated subscription object. - * - * The body parameter `change_option` determines when the plan change occurrs. Orb supports - * three options: - * - `end_of_subscription_term`: changes the plan at the end of the existing plan's term. - * - Issuing this plan change request for a monthly subscription will keep the existing plan - * active until the start of the subsequent month. Issuing this plan change request for a - * yearly subscription will keep the existing plan active for the full year. Charges - * incurred in the remaining period will be invoiced as normal. - * - Example: The plan is billed monthly on the 1st of the month, the request is made on - * January 15th, so the plan will be changed on February 1st, and invoice will be issued - * on February 1st for the last month of the original plan. - * - `immediate`: changes the plan immediately. - * - Subscriptions that have their plan changed with this option will move to the new plan - * immediately, and be invoiced immediately. - * - This invoice will include any usage fees incurred in the billing period up to the - * change, along with any prorated recurring fees for the billing period, if applicable. - * - Example: The plan is billed monthly on the 1st of the month, the request is made on - * January 15th, so the plan will be changed on January 15th, and an invoice will be - * issued for the partial month, from January 1 to January 15, on the original plan. - * - `requested_date`: changes the plan on the requested date (`change_date`). - * - If no timezone is provided, the customer's timezone is used. The `change_date` body - * parameter is required if this option is chosen. - * - Example: The plan is billed monthly on the 1st of the month, the request is made on - * January 15th, with a requested `change_date` of February 15th, so the plan will be - * changed on February 15th, and invoices will be issued on February 1st and February - * 15th. - * - * Note that one of `plan_id` or `external_plan_id` is required in the request body for this - * operation. - * - * ## Customize your customer's subscriptions - * - * Prices and adjustments in a plan can be added, removed, or replaced on the subscription when - * you schedule the plan change. This is useful when a customer has prices that differ from the - * default prices for a specific plan. - * - * This feature is only available for accounts that have migrated to Subscription - * Overrides Version 2. You can find your Subscription Overrides Version at the bottom of your - * [Plans page](https://app.withorb.com/plans) - * - * ### Adding Prices - * - * To add prices, provide a list of objects with the key `add_prices`. An object in the list - * must specify an existing add-on price with a `price_id` or `external_price_id` field, or - * create a new add-on price by including an object with the key `price`, identical to what - * would be used in the request body for the - * [create price endpoint](/api-reference/price/create-price). See the - * [Price resource](/product-catalog/price-configuration) for the specification of different - * price model configurations possible in this object. - * - * If the plan has phases, each object in the list must include a number with `plan_phase_order` - * key to indicate which phase the price should be added to. - * - * An object in the list can specify an optional `start_date` and optional `end_date`. If - * `start_date` is unspecified, the start of the phase / plan change time will be used. If - * `end_date` is unspecified, it will finish at the end of the phase / have no end time. - * - * An object in the list can specify an optional `minimum_amount`, `maximum_amount`, or - * `discounts`. This will create adjustments which apply only to this price. - * - * Additionally, an object in the list can specify an optional `reference_id`. This ID can be - * used to reference this price when [adding an adjustment](#adding-adjustments) in the same API - * call. However the ID is _transient_ and cannot be used to refer to the price in future API - * calls. - * - * ### Removing Prices - * - * To remove prices, provide a list of objects with the key `remove_prices`. An object in the - * list must specify a plan price with either a `price_id` or `external_price_id` field. - * - * ### Replacing Prices - * - * To replace prices, provide a list of objects with the key `replace_prices`. An object in the - * list must specify a plan price to replace with the `replaces_price_id` key, and it must - * specify a price to replace it with by either referencing an existing add-on price with a - * `price_id` or `external_price_id` field, or by creating a new add-on price by including an - * object with the key `price`, identical to what would be used in the request body for the - * [create price endpoint](/api-reference/price/create-price). See the - * [Price resource](/product-catalog/price-configuration) for the specification of different - * price model configurations possible in this object. - * - * For fixed fees, an object in the list can supply a `fixed_price_quantity` instead of a - * `price`, `price_id`, or `external_price_id` field. This will update only the quantity for the - * price, similar to the - * [Update price quantity](/api-reference/subscription/update-price-quantity) endpoint. - * - * The replacement price will have the same phase, if applicable, and the same start and end - * dates as the price it replaces. - * - * An object in the list can specify an optional `minimum_amount`, `maximum_amount`, or - * `discounts`. This will create adjustments which apply only to this price. - * - * Additionally, an object in the list can specify an optional `reference_id`. This ID can be - * used to reference the replacement price when [adding an adjustment](#adding-adjustments) in - * the same API call. However the ID is _transient_ and cannot be used to refer to the price in - * future API calls. - * - * ### Adding adjustments - * - * To add adjustments, provide a list of objects with the key `add_adjustments`. An object in - * the list must include an object with the key `adjustment`, identical to the adjustment object - * in the - * [add/edit price intervals endpoint](/api-reference/price-interval/add-or-edit-price-intervals). - * - * If the plan has phases, each object in the list must include a number with `plan_phase_order` - * key to indicate which phase the adjustment should be added to. - * - * An object in the list can specify an optional `start_date` and optional `end_date`. If - * `start_date` is unspecified, the start of the phase / plan change time will be used. If - * `end_date` is unspecified, it will finish at the end of the phase / have no end time. - * - * ### Removing adjustments - * - * To remove adjustments, provide a list of objects with the key `remove_adjustments`. An object - * in the list must include a key, `adjustment_id`, with the ID of the adjustment to be removed. - * - * ### Replacing adjustments - * - * To replace adjustments, provide a list of objects with the key `replace_adjustments`. An - * object in the list must specify a plan adjustment to replace with the - * `replaces_adjustment_id` key, and it must specify an adjustment to replace it with by - * including an object with the key `adjustment`, identical to the adjustment object in the - * [add/edit price intervals endpoint](/api-reference/price-interval/add-or-edit-price-intervals). - * - * The replacement adjustment will have the same phase, if applicable, and the same start and - * end dates as the adjustment it replaces. - * - * ## Price overrides (DEPRECATED) - * - * Price overrides are being phased out in favor adding/removing/replacing prices. (See - * [Customize your customer's subscriptions](/api-reference/subscription/schedule-plan-change)) - * - * - * Price overrides are used to update some or all prices in a plan for the specific subscription - * being created. This is useful when a new customer has negotiated a rate that is unique to the - * customer. - * - * To override prices, provide a list of objects with the key `price_overrides`. The price - * object in the list of overrides is expected to contain the existing price id, the - * `model_type` and configuration. (See the - * [Price resource](/product-catalog/price-configuration) for the specification of different - * price model configurations.) The numerical values can be updated, but the billable metric, - * cadence, type, and name of a price can not be overridden. - * - * ### Maximums, and minimums - * - * Price overrides are used to update some or all prices in the target plan. Minimums and - * maximums, much like price overrides, can be useful when a new customer has negotiated a new - * or different minimum or maximum spend cap than the default for the plan. The request format - * for maximums and minimums is the same as those in - * [subscription creation](create-subscription). - * - * ## Scheduling multiple plan changes - * - * When scheduling multiple plan changes with the same date, the latest plan change on that day - * takes effect. - * - * ## Prorations for in-advance fees - * - * By default, Orb calculates the prorated difference in any fixed fees when making a plan - * change, adjusting the customer balance as needed. For details on this behavior, see - * [Modifying subscriptions](/product-catalog/modifying-subscriptions#prorations-for-in-advance-fees). - */ override fun schedulePlanChange( params: SubscriptionSchedulePlanChangeParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("subscriptions", params.getPathParam(0), "schedule_plan_change") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { schedulePlanChangeHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } - - private val triggerPhaseHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + ): CompletableFuture = + // post /subscriptions/{subscription_id}/schedule_plan_change + withRawResponse().schedulePlanChange(params, requestOptions).thenApply { it.parse() } - /** - * Manually trigger a phase, effective the given date (or the current time, if not specified). - */ override fun triggerPhase( params: SubscriptionTriggerPhaseParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("subscriptions", params.getPathParam(0), "trigger_phase") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { triggerPhaseHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } + ): CompletableFuture = + // post /subscriptions/{subscription_id}/trigger_phase + withRawResponse().triggerPhase(params, requestOptions).thenApply { it.parse() } - private val unscheduleCancellationHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * This endpoint can be used to unschedule any pending cancellations for a subscription. - * - * 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. - */ override fun unscheduleCancellation( params: SubscriptionUnscheduleCancellationParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("subscriptions", params.getPathParam(0), "unschedule_cancellation") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { unscheduleCancellationHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } - - private val unscheduleFixedFeeQuantityUpdatesHandler: - Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + ): CompletableFuture = + // post /subscriptions/{subscription_id}/unschedule_cancellation + withRawResponse().unscheduleCancellation(params, requestOptions).thenApply { it.parse() } - /** - * This endpoint can be used to clear scheduled updates to the quantity for a fixed fee. - * - * If there are no updates scheduled, a request validation error will be returned with a 400 - * status code. - */ override fun unscheduleFixedFeeQuantityUpdates( params: SubscriptionUnscheduleFixedFeeQuantityUpdatesParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments( - "subscriptions", - params.getPathParam(0), - "unschedule_fixed_fee_quantity_updates", - ) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { unscheduleFixedFeeQuantityUpdatesHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } + ): CompletableFuture = + // post /subscriptions/{subscription_id}/unschedule_fixed_fee_quantity_updates + withRawResponse().unscheduleFixedFeeQuantityUpdates(params, requestOptions).thenApply { + it.parse() + } - private val unschedulePendingPlanChangesHandler: - Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * This endpoint can be used to unschedule any pending plan changes on an existing subscription. - */ override fun unschedulePendingPlanChanges( params: SubscriptionUnschedulePendingPlanChangesParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments( - "subscriptions", - params.getPathParam(0), - "unschedule_pending_plan_changes", - ) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { unschedulePendingPlanChangesHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } - - private val updateFixedFeeQuantityHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + ): CompletableFuture = + // post /subscriptions/{subscription_id}/unschedule_pending_plan_changes + withRawResponse().unschedulePendingPlanChanges(params, requestOptions).thenApply { + it.parse() + } - /** - * This endpoint can be used to update the quantity for a fixed fee. - * - * To be eligible, the subscription must currently be active and the price specified must be a - * fixed fee (not usage-based). This operation will immediately update the quantity for the fee, - * or if a `effective_date` is passed in, will update the quantity on the requested date at - * midnight in the customer's timezone. - * - * In order to change the fixed fee quantity as of the next draft invoice for this subscription, - * pass `change_option=upcoming_invoice` without an `effective_date` specified. - * - * If the fee is an in-advance fixed fee, it will also issue an immediate invoice for the - * difference for the remainder of the billing period. - */ override fun updateFixedFeeQuantity( params: SubscriptionUpdateFixedFeeQuantityParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments( - "subscriptions", - params.getPathParam(0), - "update_fixed_fee_quantity", - ) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { updateFixedFeeQuantityHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } - - private val updateTrialHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + ): CompletableFuture = + // post /subscriptions/{subscription_id}/update_fixed_fee_quantity + withRawResponse().updateFixedFeeQuantity(params, requestOptions).thenApply { it.parse() } - /** - * This endpoint is used to update the trial end date for a subscription. The new trial end date - * must be within the time range of the current plan (i.e. the new trial end date must be on or - * after the subscription's start date on the current plan, and on or before the subscription - * end date). - * - * In order to retroactively remove a trial completely, the end date can be set to the - * transition date of the subscription to this plan (or, if this is the first plan for this - * subscription, the subscription's start date). In order to end a trial immediately, the - * keyword `immediate` can be provided as the trial end date. - * - * By default, Orb will shift only the trial end date (and price intervals that start or end on - * the previous trial end date), and leave all other future price intervals untouched. If the - * `shift` parameter is set to `true`, Orb will shift all subsequent price and adjustment - * intervals by the same amount as the trial end date shift (so, e.g., if a plan change is - * scheduled or an add-on price was added, that change will be pushed back by the same amount of - * time the trial is extended). - */ override fun updateTrial( params: SubscriptionUpdateTrialParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("subscriptions", params.getPathParam(0), "update_trial") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { updateTrialHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): CompletableFuture = + // post /subscriptions/{subscription_id}/update_trial + withRawResponse().updateTrial(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SubscriptionServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun create( + params: SubscriptionCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("subscriptions") + .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 -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: SubscriptionUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("subscriptions", params.getPathParam(0)) + .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 -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: SubscriptionListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("subscriptions") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + SubscriptionListPageAsync.of( + SubscriptionServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } + } + + private val cancelHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun cancel( + params: SubscriptionCancelParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("subscriptions", params.getPathParam(0), "cancel") + .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 -> + response.parseable { + response + .use { cancelHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetch( + params: SubscriptionFetchParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("subscriptions", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val fetchCostsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun fetchCosts( + params: SubscriptionFetchCostsParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("subscriptions", params.getPathParam(0), "costs") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { fetchCostsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val fetchScheduleHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun fetchSchedule( + params: SubscriptionFetchScheduleParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("subscriptions", params.getPathParam(0), "schedule") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { fetchScheduleHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + SubscriptionFetchSchedulePageAsync.of( + SubscriptionServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } + } + + private val fetchUsageHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetchUsage( + params: SubscriptionFetchUsageParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("subscriptions", params.getPathParam(0), "usage") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { fetchUsageHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val priceIntervalsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun priceIntervals( + params: SubscriptionPriceIntervalsParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("subscriptions", params.getPathParam(0), "price_intervals") + .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 -> + response.parseable { + response + .use { priceIntervalsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val schedulePlanChangeHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun schedulePlanChange( + params: SubscriptionSchedulePlanChangeParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments( + "subscriptions", + params.getPathParam(0), + "schedule_plan_change", + ) + .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 -> + response.parseable { + response + .use { schedulePlanChangeHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val triggerPhaseHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun triggerPhase( + params: SubscriptionTriggerPhaseParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("subscriptions", params.getPathParam(0), "trigger_phase") + .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 -> + response.parseable { + response + .use { triggerPhaseHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val unscheduleCancellationHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun unscheduleCancellation( + params: SubscriptionUnscheduleCancellationParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments( + "subscriptions", + params.getPathParam(0), + "unschedule_cancellation", + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { unscheduleCancellationHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val unscheduleFixedFeeQuantityUpdatesHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun unscheduleFixedFeeQuantityUpdates( + params: SubscriptionUnscheduleFixedFeeQuantityUpdatesParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments( + "subscriptions", + params.getPathParam(0), + "unschedule_fixed_fee_quantity_updates", + ) + .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 -> + response.parseable { + response + .use { unscheduleFixedFeeQuantityUpdatesHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val unschedulePendingPlanChangesHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun unschedulePendingPlanChanges( + params: SubscriptionUnschedulePendingPlanChangesParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments( + "subscriptions", + params.getPathParam(0), + "unschedule_pending_plan_changes", + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { unschedulePendingPlanChangesHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateFixedFeeQuantityHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun updateFixedFeeQuantity( + params: SubscriptionUpdateFixedFeeQuantityParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments( + "subscriptions", + params.getPathParam(0), + "update_fixed_fee_quantity", + ) + .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 -> + response.parseable { + response + .use { updateFixedFeeQuantityHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateTrialHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun updateTrial( + params: SubscriptionUpdateTrialParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("subscriptions", params.getPathParam(0), "update_trial") + .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 -> + response.parseable { + response + .use { updateTrialHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/TopLevelServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/TopLevelServiceAsync.kt index d81f30311..451fdb1b4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/TopLevelServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/TopLevelServiceAsync.kt @@ -4,13 +4,20 @@ package com.withorb.api.services.async +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.TopLevelPingParams import com.withorb.api.models.TopLevelPingResponse import java.util.concurrent.CompletableFuture interface TopLevelServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * This endpoint allows you to test your connection to the Orb API and check the validity of * your API key, passed in the Authorization header. This is particularly useful for checking @@ -35,4 +42,31 @@ interface TopLevelServiceAsync { */ fun ping(requestOptions: RequestOptions): CompletableFuture = ping(TopLevelPingParams.none(), requestOptions) + + /** + * A view of [TopLevelServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /ping`, but is otherwise the same as + * [TopLevelServiceAsync.ping]. + */ + @JvmOverloads + @MustBeClosed + fun ping( + params: TopLevelPingParams = TopLevelPingParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /ping`, but is otherwise the same as + * [TopLevelServiceAsync.ping]. + */ + @MustBeClosed + fun ping( + requestOptions: RequestOptions + ): CompletableFuture> = + ping(TopLevelPingParams.none(), requestOptions) + } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/TopLevelServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/TopLevelServiceAsyncImpl.kt index 2989fe7c1..ed3088883 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/TopLevelServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/TopLevelServiceAsyncImpl.kt @@ -10,6 +10,8 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest 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.errors.OrbError import com.withorb.api.models.TopLevelPingParams @@ -19,39 +21,52 @@ import java.util.concurrent.CompletableFuture class TopLevelServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : TopLevelServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: TopLevelServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val pingHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): TopLevelServiceAsync.WithRawResponse = withRawResponse - /** - * This endpoint allows you to test your connection to the Orb API and check the validity of - * your API key, passed in the Authorization header. This is particularly useful for checking - * that your environment is set up properly, and is a great choice for connectors and - * integrations. - * - * This API does not have any side-effects or return any Orb resources. - */ override fun ping( params: TopLevelPingParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("ping") - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { pingHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): CompletableFuture = + // get /ping + withRawResponse().ping(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TopLevelServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val pingHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun ping( + params: TopLevelPingParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("ping") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { pingHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } 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 2824b8983..8a33f5951 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 @@ -4,13 +4,20 @@ package com.withorb.api.services.async.coupons +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.CouponSubscriptionListPageAsync import com.withorb.api.models.CouponSubscriptionListParams import java.util.concurrent.CompletableFuture interface SubscriptionServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * This endpoint returns a list of all subscriptions that have redeemed a given coupon as a * [paginated](/api-reference/pagination) list, ordered starting from the most recently created @@ -22,4 +29,22 @@ interface SubscriptionServiceAsync { params: CouponSubscriptionListParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** + * A view of [SubscriptionServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /coupons/{coupon_id}/subscriptions`, but is + * otherwise the same as [SubscriptionServiceAsync.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: CouponSubscriptionListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } 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 db9391784..71e4dede7 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 @@ -10,6 +10,8 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest 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.errors.OrbError import com.withorb.api.models.CouponSubscriptionListPageAsync @@ -19,39 +21,59 @@ import java.util.concurrent.CompletableFuture class SubscriptionServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : SubscriptionServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: SubscriptionServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): SubscriptionServiceAsync.WithRawResponse = withRawResponse - /** - * This endpoint returns a list of all subscriptions that have redeemed a given coupon as a - * [paginated](/api-reference/pagination) list, ordered starting from the most recently created - * subscription. For a full discussion of the subscription resource, see - * [Subscription](/core-concepts#subscription). - */ override fun list( params: CouponSubscriptionListParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("coupons", params.getPathParam(0), "subscriptions") - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): CompletableFuture = + // get /coupons/{coupon_id}/subscriptions + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SubscriptionServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: CouponSubscriptionListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("coupons", params.getPathParam(0), "subscriptions") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + CouponSubscriptionListPageAsync.of( + SubscriptionServiceAsyncImpl(clientOptions), + params, + it, + ) + } } - .let { CouponSubscriptionListPageAsync.of(this, params, it) } - } + } + } } } 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 8486da2b5..fe517086c 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 @@ -4,15 +4,22 @@ package com.withorb.api.services.async.customers +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.CustomerBalanceTransactionCreateParams -import com.withorb.api.models.CustomerBalanceTransactionCreateResponse import com.withorb.api.models.CustomerBalanceTransactionListPageAsync import com.withorb.api.models.CustomerBalanceTransactionListParams +import com.withorb.api.models.CustomerBalanceTransactionModel import java.util.concurrent.CompletableFuture interface BalanceTransactionServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * Creates an immutable balance transaction that updates the customer's balance and returns back * the newly created transaction. @@ -21,7 +28,7 @@ interface BalanceTransactionServiceAsync { fun create( params: CustomerBalanceTransactionCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * ## The customer balance @@ -55,4 +62,33 @@ interface BalanceTransactionServiceAsync { params: CustomerBalanceTransactionListParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** + * A view of [BalanceTransactionServiceAsync] that provides access to raw HTTP responses for + * each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /customers/{customer_id}/balance_transactions`, but + * is otherwise the same as [BalanceTransactionServiceAsync.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: CustomerBalanceTransactionCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /customers/{customer_id}/balance_transactions`, but + * is otherwise the same as [BalanceTransactionServiceAsync.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: CustomerBalanceTransactionListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } 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 52545b34f..87be8d884 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 @@ -10,104 +10,111 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest import com.withorb.api.core.http.HttpResponse.Handler -import com.withorb.api.core.json +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.errors.OrbError import com.withorb.api.models.CustomerBalanceTransactionCreateParams -import com.withorb.api.models.CustomerBalanceTransactionCreateResponse import com.withorb.api.models.CustomerBalanceTransactionListPageAsync import com.withorb.api.models.CustomerBalanceTransactionListParams +import com.withorb.api.models.CustomerBalanceTransactionModel import java.util.concurrent.CompletableFuture class BalanceTransactionServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : BalanceTransactionServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: BalanceTransactionServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): BalanceTransactionServiceAsync.WithRawResponse = withRawResponse - /** - * Creates an immutable balance transaction that updates the customer's balance and returns back - * the newly created transaction. - */ override fun create( params: CustomerBalanceTransactionCreateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("customers", params.getPathParam(0), "balance_transactions") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } + ): CompletableFuture = + // post /customers/{customer_id}/balance_transactions + withRawResponse().create(params, requestOptions).thenApply { it.parse() } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * ## The customer balance - * - * The customer balance is an amount in the customer's currency, which Orb automatically applies - * to subsequent invoices. This balance can be adjusted manually via Orb's webapp on the - * customer details page. You can use this balance to provide a fixed mid-period credit to the - * customer. Commonly, this is done due to system downtime/SLA violation, or an adhoc adjustment - * discussed with the customer. - * - * If the balance is a positive value at the time of invoicing, it represents that the customer - * has credit that should be used to offset the amount due on the next issued invoice. In this - * case, Orb will automatically reduce the next invoice by the balance amount, and roll over any - * remaining balance if the invoice is fully discounted. - * - * If the balance is a negative value at the time of invoicing, Orb will increase the invoice's - * amount due with a positive adjustment, and reset the balance to 0. - * - * This endpoint retrieves all customer balance transactions in reverse chronological order for - * a single customer, providing a complete audit trail of all adjustments and invoice - * applications. - * - * ## Eligibility - * - * The customer balance can only be applied to invoices or adjusted manually if invoices are not - * synced to a separate invoicing provider. If a payment gateway such as Stripe is used, the - * balance will be applied to the invoice before forwarding payment to the gateway. - */ override fun list( params: CustomerBalanceTransactionListParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("customers", params.getPathParam(0), "balance_transactions") - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): CompletableFuture = + // get /customers/{customer_id}/balance_transactions + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BalanceTransactionServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun create( + params: CustomerBalanceTransactionCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("customers", params.getPathParam(0), "balance_transactions") + .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 -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: CustomerBalanceTransactionListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("customers", params.getPathParam(0), "balance_transactions") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + CustomerBalanceTransactionListPageAsync.of( + BalanceTransactionServiceAsyncImpl(clientOptions), + params, + it, + ) + } } - .let { CustomerBalanceTransactionListPageAsync.of(this, params, it) } - } + } + } } } 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 151a5c89c..ab0b33466 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 @@ -4,15 +4,21 @@ package com.withorb.api.services.async.customers +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.CustomerCostListByExternalIdParams -import com.withorb.api.models.CustomerCostListByExternalIdResponse import com.withorb.api.models.CustomerCostListParams -import com.withorb.api.models.CustomerCostListResponse +import com.withorb.api.models.CustomerCostsModel import java.util.concurrent.CompletableFuture interface CostServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * This endpoint is used to fetch a day-by-day snapshot of a customer's costs in Orb, calculated * by applying pricing information to the underlying usage (see the @@ -127,7 +133,7 @@ interface CostServiceAsync { fun list( params: CustomerCostListParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This endpoint is used to fetch a day-by-day snapshot of a customer's costs in Orb, calculated @@ -243,5 +249,32 @@ interface CostServiceAsync { fun listByExternalId( params: CustomerCostListByExternalIdParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture + + /** A view of [CostServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /customers/{customer_id}/costs`, but is otherwise + * the same as [CostServiceAsync.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: CustomerCostListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get + * /customers/external_customer_id/{external_customer_id}/costs`, but is otherwise the same + * as [CostServiceAsync.listByExternalId]. + */ + @JvmOverloads + @MustBeClosed + fun listByExternalId( + params: CustomerCostListByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } 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 4424202f7..0da7dd3b5 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 @@ -10,295 +10,104 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest 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.errors.OrbError import com.withorb.api.models.CustomerCostListByExternalIdParams -import com.withorb.api.models.CustomerCostListByExternalIdResponse import com.withorb.api.models.CustomerCostListParams -import com.withorb.api.models.CustomerCostListResponse +import com.withorb.api.models.CustomerCostsModel import java.util.concurrent.CompletableFuture class CostServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CostServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: CostServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): CostServiceAsync.WithRawResponse = withRawResponse - /** - * This endpoint is used to fetch a day-by-day snapshot of a customer's costs in Orb, calculated - * by applying pricing information to the underlying usage (see the - * [subscription usage endpoint](/api-reference/subscription/fetch-subscription-usage) to fetch - * usage per metric, in usage units rather than a currency). - * - * This endpoint can be leveraged for internal tooling and to provide a more transparent billing - * experience for your end users: - * 1. Understand the cost breakdown per line item historically and in real-time for the current - * billing period. - * 2. Provide customer visibility into how different services are contributing to the overall - * invoice with a per-day timeseries (as compared to the - * [upcoming invoice](/api-reference/invoice/fetch-upcoming-invoice) resource, which - * represents a snapshot for the current period). - * 3. Assess how minimums and discounts affect your customers by teasing apart costs directly as - * a result of usage, as opposed to minimums and discounts at the plan and price level. - * 4. Gain insight into key customer health metrics, such as the percent utilization of the - * minimum committed spend. - * - * ## Fetching subscriptions - * - * By default, this endpoint fetches the currently active subscription for the customer, and - * returns cost information for the subscription's current billing period, broken down by each - * participating price. If there are no currently active subscriptions, this will instead - * default to the most recently active subscription or return an empty series if none are found. - * For example, if your plan charges for compute hours, job runs, and data syncs, then this - * endpoint would provide a daily breakdown of your customer's cost for each of those axes. - * - * If timeframe bounds are specified, Orb fetches all subscriptions that were active in that - * timeframe. If two subscriptions overlap on a single day, costs from each price will be - * summed, and prices for both subscriptions will be included in the breakdown. - * - * ## Prepaid plans - * - * For plans that include prices which deduct credits rather than accrue in-arrears charges in a - * billable currency, this endpoint will return the total deduction amount, in credits, for the - * specified timeframe. - * - * ## Cumulative subtotals and totals - * - * Since the subtotal and total must factor in any billing-period level discounts and minimums, - * it's most meaningful to consider costs relative to the start of the subscription's billing - * period. As a result, by default this endpoint returns cumulative totals since the beginning - * of the billing period. In particular, the `timeframe_start` of a returned timeframe window is - * _always_ the beginning of the billing period and `timeframe_end` is incremented one day at a - * time to build the result. - * - * A customer that uses a few API calls a day but has a minimum commitment might exhibit the - * following pattern for their subtotal and total in the first few days of the month. Here, we - * assume that each API call is $2.50, the customer's plan has a monthly minimum of $50 for this - * price, and that the subscription's billing period bounds are aligned to the first of the - * month: - * - * | timeframe_start | timeframe_end | Cumulative usage | Subtotal | Total (incl. commitment) | - * |-----------------|---------------|------------------|----------|--------------------------| - * | 2023-02-01 | 2023-02-02 | 9 | $22.50 | $50.00 | - * | 2023-02-01 | 2023-02-03 | 19 | $47.50 | $50.00 | - * | 2023-02-01 | 2023-02-04 | 20 | $50.00 | $50.00 | - * | 2023-02-01 | 2023-02-05 | 28 | $70.00 | $70.00 | - * | 2023-02-01 | 2023-02-06 | 36 | $90.00 | $90.00 | - * - * ### Periodic values - * - * When the query parameter `view_mode=periodic` is specified, Orb will return an incremental - * day-by-day view of costs. In this case, there will always be a one-day difference between - * `timeframe_start` and `timeframe_end` for the timeframes returned. This is a transform on top - * of the cumulative costs, calculated by taking the difference of each timeframe with the last. - * Note that in the above example, the `Total` value would be 0 for the second two data points, - * since the minimum commitment has not yet been hit and each day is not contributing anything - * to the total cost. - * - * ## Timeframe bounds - * - * For an active subscription, both timeframes should be specified in the request. If a - * subscription starts or ends within the timeframe, the response will only include windows - * where the subscription is active. If a subscription has ended, no timeframe bounds need to be - * specified and the response will default to the billing period when the subscription was last - * active. - * - * As noted above, `timeframe_start` for a given cumulative datapoint is always the beginning of - * the billing period, and `timeframe_end` is incremented one day at a time to construct the - * response. When a timeframe is passed in that is not aligned to the current subscription's - * billing period, the response will contain cumulative totals from multiple billing periods. - * - * Suppose the queried customer has a subscription aligned to the 15th of every month. If this - * endpoint is queried with the date range `2023-06-01` - `2023-07-01`, the first data point - * will represent about half a billing period's worth of costs, accounting for accruals from the - * start of the billing period and inclusive of the first day of the timeframe (`timeframe_start - * = 2023-05-15 00:00:00`, `timeframe_end = 2023-06-02 00:00:00`) - * - * | datapoint index | timeframe_start | timeframe_end | - * |-----------------|-----------------|---------------| - * | 0 | 2023-05-15 | 2023-06-02 | - * | 1 | 2023-05-15 | 2023-06-03 | - * | 2 | ... | ... | - * | 3 | 2023-05-15 | 2023-06-14 | - * | 4 | 2023-06-15 | 2023-06-16 | - * | 5 | 2023-06-15 | 2023-06-17 | - * | 6 | ... | ... | - * | 7 | 2023-06-15 | 2023-07-01 | - * - * You can see this sliced timeframe visualized [here](https://i.imgur.com/TXhYgme.png). - * - * ### Matrix prices - * - * When a price uses matrix pricing, it's important to view costs grouped by those matrix - * dimensions. Orb will return `price_groups` with the `grouping_key` and - * `secondary_grouping_key` based on the matrix price definition, for each `grouping_value` and - * `secondary_grouping_value` available. - */ override fun list( params: CustomerCostListParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("customers", params.getPathParam(0), "costs") - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } + ): CompletableFuture = + // get /customers/{customer_id}/costs + withRawResponse().list(params, requestOptions).thenApply { it.parse() } - private val listByExternalIdHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * This endpoint is used to fetch a day-by-day snapshot of a customer's costs in Orb, calculated - * by applying pricing information to the underlying usage (see the - * [subscription usage endpoint](/api-reference/subscription/fetch-subscription-usage) to fetch - * usage per metric, in usage units rather than a currency). - * - * This endpoint can be leveraged for internal tooling and to provide a more transparent billing - * experience for your end users: - * 1. Understand the cost breakdown per line item historically and in real-time for the current - * billing period. - * 2. Provide customer visibility into how different services are contributing to the overall - * invoice with a per-day timeseries (as compared to the - * [upcoming invoice](/api-reference/invoice/fetch-upcoming-invoice) resource, which - * represents a snapshot for the current period). - * 3. Assess how minimums and discounts affect your customers by teasing apart costs directly as - * a result of usage, as opposed to minimums and discounts at the plan and price level. - * 4. Gain insight into key customer health metrics, such as the percent utilization of the - * minimum committed spend. - * - * ## Fetching subscriptions - * - * By default, this endpoint fetches the currently active subscription for the customer, and - * returns cost information for the subscription's current billing period, broken down by each - * participating price. If there are no currently active subscriptions, this will instead - * default to the most recently active subscription or return an empty series if none are found. - * For example, if your plan charges for compute hours, job runs, and data syncs, then this - * endpoint would provide a daily breakdown of your customer's cost for each of those axes. - * - * If timeframe bounds are specified, Orb fetches all subscriptions that were active in that - * timeframe. If two subscriptions overlap on a single day, costs from each price will be - * summed, and prices for both subscriptions will be included in the breakdown. - * - * ## Prepaid plans - * - * For plans that include prices which deduct credits rather than accrue in-arrears charges in a - * billable currency, this endpoint will return the total deduction amount, in credits, for the - * specified timeframe. - * - * ## Cumulative subtotals and totals - * - * Since the subtotal and total must factor in any billing-period level discounts and minimums, - * it's most meaningful to consider costs relative to the start of the subscription's billing - * period. As a result, by default this endpoint returns cumulative totals since the beginning - * of the billing period. In particular, the `timeframe_start` of a returned timeframe window is - * _always_ the beginning of the billing period and `timeframe_end` is incremented one day at a - * time to build the result. - * - * A customer that uses a few API calls a day but has a minimum commitment might exhibit the - * following pattern for their subtotal and total in the first few days of the month. Here, we - * assume that each API call is $2.50, the customer's plan has a monthly minimum of $50 for this - * price, and that the subscription's billing period bounds are aligned to the first of the - * month: - * - * | timeframe_start | timeframe_end | Cumulative usage | Subtotal | Total (incl. commitment) | - * |-----------------|---------------|------------------|----------|--------------------------| - * | 2023-02-01 | 2023-02-02 | 9 | $22.50 | $50.00 | - * | 2023-02-01 | 2023-02-03 | 19 | $47.50 | $50.00 | - * | 2023-02-01 | 2023-02-04 | 20 | $50.00 | $50.00 | - * | 2023-02-01 | 2023-02-05 | 28 | $70.00 | $70.00 | - * | 2023-02-01 | 2023-02-06 | 36 | $90.00 | $90.00 | - * - * ### Periodic values - * - * When the query parameter `view_mode=periodic` is specified, Orb will return an incremental - * day-by-day view of costs. In this case, there will always be a one-day difference between - * `timeframe_start` and `timeframe_end` for the timeframes returned. This is a transform on top - * of the cumulative costs, calculated by taking the difference of each timeframe with the last. - * Note that in the above example, the `Total` value would be 0 for the second two data points, - * since the minimum commitment has not yet been hit and each day is not contributing anything - * to the total cost. - * - * ## Timeframe bounds - * - * For an active subscription, both timeframes should be specified in the request. If a - * subscription starts or ends within the timeframe, the response will only include windows - * where the subscription is active. If a subscription has ended, no timeframe bounds need to be - * specified and the response will default to the billing period when the subscription was last - * active. - * - * As noted above, `timeframe_start` for a given cumulative datapoint is always the beginning of - * the billing period, and `timeframe_end` is incremented one day at a time to construct the - * response. When a timeframe is passed in that is not aligned to the current subscription's - * billing period, the response will contain cumulative totals from multiple billing periods. - * - * Suppose the queried customer has a subscription aligned to the 15th of every month. If this - * endpoint is queried with the date range `2023-06-01` - `2023-07-01`, the first data point - * will represent about half a billing period's worth of costs, accounting for accruals from the - * start of the billing period and inclusive of the first day of the timeframe (`timeframe_start - * = 2023-05-15 00:00:00`, `timeframe_end = 2023-06-02 00:00:00`) - * - * | datapoint index | timeframe_start | timeframe_end | - * |-----------------|-----------------|---------------| - * | 0 | 2023-05-15 | 2023-06-02 | - * | 1 | 2023-05-15 | 2023-06-03 | - * | 2 | ... | ... | - * | 3 | 2023-05-15 | 2023-06-14 | - * | 4 | 2023-06-15 | 2023-06-16 | - * | 5 | 2023-06-15 | 2023-06-17 | - * | 6 | ... | ... | - * | 7 | 2023-06-15 | 2023-07-01 | - * - * You can see this sliced timeframe visualized [here](https://i.imgur.com/TXhYgme.png). - * - * ### Matrix prices - * - * When a price uses matrix pricing, it's important to view costs grouped by those matrix - * dimensions. Orb will return `price_groups` with the `grouping_key` and - * `secondary_grouping_key` based on the matrix price definition, for each `grouping_value` and - * `secondary_grouping_value` available. - */ override fun listByExternalId( params: CustomerCostListByExternalIdParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "customers", - "external_customer_id", - params.getPathParam(0), - "costs", - ) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listByExternalIdHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): CompletableFuture = + // get /customers/external_customer_id/{external_customer_id}/costs + withRawResponse().listByExternalId(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CostServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list( + params: CustomerCostListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("customers", params.getPathParam(0), "costs") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listByExternalIdHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun listByExternalId( + params: CustomerCostListByExternalIdParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "customers", + "external_customer_id", + params.getPathParam(0), + "costs", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listByExternalIdHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } 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 29ed966b3..f8602de82 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 @@ -4,7 +4,9 @@ package com.withorb.api.services.async.customers +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.CustomerCreditListByExternalIdPageAsync import com.withorb.api.models.CustomerCreditListByExternalIdParams import com.withorb.api.models.CustomerCreditListPageAsync @@ -15,6 +17,11 @@ import java.util.concurrent.CompletableFuture interface CreditServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + fun ledger(): LedgerServiceAsync fun topUps(): TopUpServiceAsync @@ -48,4 +55,37 @@ interface CreditServiceAsync { params: CustomerCreditListByExternalIdParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** + * A view of [CreditServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + fun ledger(): LedgerServiceAsync.WithRawResponse + + fun topUps(): TopUpServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /customers/{customer_id}/credits`, but is otherwise + * the same as [CreditServiceAsync.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: CustomerCreditListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get + * /customers/external_customer_id/{external_customer_id}/credits`, but is otherwise the + * same as [CreditServiceAsync.listByExternalId]. + */ + @JvmOverloads + @MustBeClosed + fun listByExternalId( + params: CustomerCreditListByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } 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 3a3adfd6c..a2e7e8439 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 @@ -10,6 +10,8 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest 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.errors.OrbError import com.withorb.api.models.CustomerCreditListByExternalIdPageAsync @@ -25,92 +27,129 @@ import java.util.concurrent.CompletableFuture class CreditServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CreditServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: CreditServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } private val ledger: LedgerServiceAsync by lazy { LedgerServiceAsyncImpl(clientOptions) } private val topUps: TopUpServiceAsync by lazy { TopUpServiceAsyncImpl(clientOptions) } + override fun withRawResponse(): CreditServiceAsync.WithRawResponse = withRawResponse + override fun ledger(): LedgerServiceAsync = ledger override fun topUps(): TopUpServiceAsync = topUps - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * Returns a paginated list of unexpired, non-zero credit blocks for a customer. - * - * If `include_all_blocks` is set to `true`, all credit blocks (including expired and depleted - * blocks) will be included in the response. - * - * Note that `currency` defaults to credits if not specified. To use a real world currency, set - * `currency` to an ISO 4217 string. - */ override fun list( params: CustomerCreditListParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("customers", params.getPathParam(0), "credits") - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - .let { CustomerCreditListPageAsync.of(this, params, it) } - } - } + ): CompletableFuture = + // get /customers/{customer_id}/credits + withRawResponse().list(params, requestOptions).thenApply { it.parse() } - private val listByExternalIdHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * Returns a paginated list of unexpired, non-zero credit blocks for a customer. - * - * If `include_all_blocks` is set to `true`, all credit blocks (including expired and depleted - * blocks) will be included in the response. - * - * Note that `currency` defaults to credits if not specified. To use a real world currency, set - * `currency` to an ISO 4217 string. - */ override fun listByExternalId( params: CustomerCreditListByExternalIdParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "customers", - "external_customer_id", - params.getPathParam(0), - "credits", - ) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listByExternalIdHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): CompletableFuture = + // get /customers/external_customer_id/{external_customer_id}/credits + withRawResponse().listByExternalId(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CreditServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val ledger: LedgerServiceAsync.WithRawResponse by lazy { + LedgerServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val topUps: TopUpServiceAsync.WithRawResponse by lazy { + TopUpServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun ledger(): LedgerServiceAsync.WithRawResponse = ledger + + override fun topUps(): TopUpServiceAsync.WithRawResponse = topUps + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: CustomerCreditListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("customers", params.getPathParam(0), "credits") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + CustomerCreditListPageAsync.of( + CreditServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } + } + + private val listByExternalIdHandler: + Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun listByExternalId( + params: CustomerCreditListByExternalIdParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "customers", + "external_customer_id", + params.getPathParam(0), + "credits", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listByExternalIdHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + CustomerCreditListByExternalIdPageAsync.of( + CreditServiceAsyncImpl(clientOptions), + params, + it, + ) + } } - .let { CustomerCreditListByExternalIdPageAsync.of(this, params, it) } - } + } + } } } 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 4eb5913a9..998a8aeab 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 @@ -4,11 +4,12 @@ package com.withorb.api.services.async.customers.credits +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.CreditLedgerEntryModel import com.withorb.api.models.CustomerCreditLedgerCreateEntryByExternalIdParams -import com.withorb.api.models.CustomerCreditLedgerCreateEntryByExternalIdResponse import com.withorb.api.models.CustomerCreditLedgerCreateEntryParams -import com.withorb.api.models.CustomerCreditLedgerCreateEntryResponse import com.withorb.api.models.CustomerCreditLedgerListByExternalIdPageAsync import com.withorb.api.models.CustomerCreditLedgerListByExternalIdParams import com.withorb.api.models.CustomerCreditLedgerListPageAsync @@ -17,6 +18,11 @@ import java.util.concurrent.CompletableFuture interface LedgerServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * The credits ledger provides _auditing_ functionality over Orb's credits system with a list of * actions that have taken place to modify a customer's credit balance. This @@ -209,7 +215,7 @@ interface LedgerServiceAsync { fun createEntry( params: CustomerCreditLedgerCreateEntryParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This endpoint allows you to create a new ledger entry for a specified customer's balance. @@ -318,7 +324,7 @@ interface LedgerServiceAsync { fun createEntryByExternalId( params: CustomerCreditLedgerCreateEntryByExternalIdParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * The credits ledger provides _auditing_ functionality over Orb's credits system with a list of @@ -404,4 +410,56 @@ interface LedgerServiceAsync { params: CustomerCreditLedgerListByExternalIdParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** + * A view of [LedgerServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /customers/{customer_id}/credits/ledger`, but is + * otherwise the same as [LedgerServiceAsync.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: CustomerCreditLedgerListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /customers/{customer_id}/credits/ledger_entry`, but + * is otherwise the same as [LedgerServiceAsync.createEntry]. + */ + @JvmOverloads + @MustBeClosed + fun createEntry( + params: CustomerCreditLedgerCreateEntryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post + * /customers/external_customer_id/{external_customer_id}/credits/ledger_entry`, but is + * otherwise the same as [LedgerServiceAsync.createEntryByExternalId]. + */ + @JvmOverloads + @MustBeClosed + fun createEntryByExternalId( + params: CustomerCreditLedgerCreateEntryByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get + * /customers/external_customer_id/{external_customer_id}/credits/ledger`, but is otherwise + * the same as [LedgerServiceAsync.listByExternalId]. + */ + @JvmOverloads + @MustBeClosed + fun listByExternalId( + params: CustomerCreditLedgerListByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } 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 9024b4783..050d0cd5b 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 @@ -10,13 +10,14 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest import com.withorb.api.core.http.HttpResponse.Handler -import com.withorb.api.core.json +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.errors.OrbError +import com.withorb.api.models.CreditLedgerEntryModel import com.withorb.api.models.CustomerCreditLedgerCreateEntryByExternalIdParams -import com.withorb.api.models.CustomerCreditLedgerCreateEntryByExternalIdResponse import com.withorb.api.models.CustomerCreditLedgerCreateEntryParams -import com.withorb.api.models.CustomerCreditLedgerCreateEntryResponse import com.withorb.api.models.CustomerCreditLedgerListByExternalIdPageAsync import com.withorb.api.models.CustomerCreditLedgerListByExternalIdParams import com.withorb.api.models.CustomerCreditLedgerListPageAsync @@ -26,497 +27,194 @@ import java.util.concurrent.CompletableFuture class LedgerServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : LedgerServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: LedgerServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): LedgerServiceAsync.WithRawResponse = withRawResponse - /** - * The credits ledger provides _auditing_ functionality over Orb's credits system with a list of - * actions that have taken place to modify a customer's credit balance. This - * [paginated endpoint](/api-reference/pagination) lists these entries, starting from the most - * recent ledger entry. - * - * More details on using Orb's real-time credit feature are - * [here](/product-catalog/prepurchase). - * - * There are four major types of modifications to credit balance, detailed below. - * - * ## Increment - * - * Credits (which optionally expire on a future date) can be added via the API ([Add Ledger - * Entry](create-ledger-entry)). The ledger entry for such an action will always contain the - * total eligible starting and ending balance for the customer at the time the entry was added - * to the ledger. - * - * ## Decrement - * - * Deductions can occur as a result of an API call to create a ledger entry (see - * [Add Ledger Entry](create-ledger-entry)), or automatically as a result of incurring usage. - * Both ledger entries present the `decrement` entry type. - * - * 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. - * - * By default, Orb uses an algorithm that automatically deducts from the _soonest expiring - * credit block_ first in order to ensure that all credits are utilized appropriately. As an - * example, if trial credits with an expiration date of 2 weeks from now are present for a - * customer, they will be used before any deductions take place from a non-expiring credit - * block. - * - * If there are multiple blocks with the same expiration date, Orb will deduct from the block - * with the _lower cost basis_ first (e.g. trial credits with a $0 cost basis before paid - * credits with a $5.00 cost basis). - * - * It's also possible for a single usage event's deduction to _span_ credit blocks. In this - * case, Orb will deduct from the next block, ending at the credit block which consists of - * unexpiring credits. Each of these deductions will lead to a _separate_ ledger entry, one per - * credit block that is deducted from. By default, the customer's total credit balance in Orb - * can be negative as a result of a decrement. - * - * ## Expiration change - * - * The expiry of credits can be changed as a result of the API (See - * [Add Ledger Entry](create-ledger-entry)). This will create a ledger entry that specifies the - * balance as well as the initial and target expiry dates. - * - * Note that for this entry type, `starting_balance` will equal `ending_balance`, and the - * `amount` represents the balance transferred. The credit block linked to the ledger entry is - * the source credit block from which there was an expiration change - * - * ## Credits expiry - * - * When a set of credits expire on pre-set expiration date, the customer's balance automatically - * reflects this change and adds an entry to the ledger indicating this event. Note that credit - * expiry should always happen close to a date boundary in the customer's timezone. - * - * ## Void initiated - * - * Credit blocks can be voided via the API. The `amount` on this entry corresponds to the number - * of credits that were remaining in the block at time of void. `void_reason` will be populated - * if the void is created with a reason. - * - * ## Void - * - * When a set of credits is voided, the customer's balance automatically reflects this change - * and adds an entry to the ledger indicating this event. - * - * ## Amendment - * - * When credits are added to a customer's balance as a result of a correction, this entry will - * be added to the ledger to indicate the adjustment of credits. - */ override fun list( params: CustomerCreditLedgerListParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("customers", params.getPathParam(0), "credits", "ledger") - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - .let { CustomerCreditLedgerListPageAsync.of(this, params, it) } - } - } + ): CompletableFuture = + // get /customers/{customer_id}/credits/ledger + withRawResponse().list(params, requestOptions).thenApply { it.parse() } - private val createEntryHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * This endpoint allows you to create a new ledger entry for a specified customer's balance. - * This can be used to increment balance, deduct credits, and change the expiry date of existing - * credits. - * - * ## Effects of adding a ledger entry - * 1. After calling this endpoint, [Fetch Credit Balance](fetch-customer-credits) will return a - * credit block that represents the changes (i.e. balance changes or transfers). - * 2. A ledger entry will be added to the credits ledger for this customer, and therefore - * returned in the [View Credits Ledger](fetch-customer-credits-ledger) response as well as - * serialized in the response to this request. In the case of deductions without a specified - * block, multiple ledger entries may be created if the deduction spans credit blocks. - * 3. If `invoice_settings` is specified, an invoice will be created that reflects the cost of - * the credits (based on `amount` and `per_unit_cost_basis`). - * - * ## Adding credits - * - * Adding credits is done by creating an entry of type `increment`. This requires the caller to - * specify a number of credits as well as an optional expiry date in `YYYY-MM-DD` format. Orb - * also recommends specifying a description to assist with auditing. When adding credits, the - * caller can also specify a cost basis per-credit, to indicate how much in USD a customer paid - * for a single credit in a block. This can later be used for revenue recognition. - * - * The following snippet illustrates a sample request body to increment credits which will - * expire in January of 2022. - * - * ```json - * { - * "entry_type": "increment", - * "amount": 100, - * "expiry_date": "2022-12-28", - * "per_unit_cost_basis": "0.20", - * "description": "Purchased 100 credits" - * } - * ``` - * - * Note that by default, Orb will always first increment any _negative_ balance in existing - * blocks before adding the remaining amount to the desired credit block. - * - * ### Invoicing for credits - * - * By default, Orb manipulates the credit ledger but does not charge for credits. However, if - * you pass `invoice_settings` in the body of this request, Orb will also generate a one-off - * invoice for the customer for the credits pre-purchase. Note that you _must_ provide the - * `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. - * - * ## 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. - * - * The following snippet illustrates a sample request body to decrement credits. - * - * ```json - * { - * "entry_type": "decrement", - * "amount": 20, - * "description": "Removing excess credits" - * } - * ``` - * - * ## Changing credits expiry - * - * If you'd like to change when existing credits expire, you should create a ledger entry of - * type `expiration_change`. For this entry, the required parameter `expiry_date` identifies the - * _originating_ block, and the required parameter `target_expiry_date` identifies when the - * transferred credits should now expire. A new credit block will be created with expiry date - * `target_expiry_date`, with the same cost basis data as the original credit block, if present. - * - * Note that the balance of the block with the given `expiry_date` must be at least equal to the - * desired transfer amount determined by the `amount` parameter. - * - * The following snippet illustrates a sample request body to extend the expiration date of - * credits by one year: - * ```json - * { - * "entry_type": "expiration_change", - * "amount": 10, - * "expiry_date": "2022-12-28", - * "block_id": "UiUhFWeLHPrBY4Ad", - * "target_expiry_date": "2023-12-28", - * "description": "Extending credit validity" - * } - * ``` - * - * ## Voiding credits - * - * If you'd like to void a credit block, create a ledger entry of type `void`. For this entry, - * `block_id` is required to identify the block, and `amount` indicates how many credits to - * void, up to the block's initial balance. Pass in a `void_reason` of `refund` if the void is - * due to a refund. - * - * ## Amendment - * - * If you'd like to undo a decrement on a credit block, create a ledger entry of type - * `amendment`. For this entry, `block_id` is required to identify the block that was originally - * decremented from, and `amount` indicates how many credits to return to the customer, up to - * the block's initial balance. - */ override fun createEntry( params: CustomerCreditLedgerCreateEntryParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("customers", params.getPathParam(0), "credits", "ledger_entry") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { createEntryHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } + ): CompletableFuture = + // post /customers/{customer_id}/credits/ledger_entry + withRawResponse().createEntry(params, requestOptions).thenApply { it.parse() } - private val createEntryByExternalIdHandler: - Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * This endpoint allows you to create a new ledger entry for a specified customer's balance. - * This can be used to increment balance, deduct credits, and change the expiry date of existing - * credits. - * - * ## Effects of adding a ledger entry - * 1. After calling this endpoint, [Fetch Credit Balance](fetch-customer-credits) will return a - * credit block that represents the changes (i.e. balance changes or transfers). - * 2. A ledger entry will be added to the credits ledger for this customer, and therefore - * returned in the [View Credits Ledger](fetch-customer-credits-ledger) response as well as - * serialized in the response to this request. In the case of deductions without a specified - * block, multiple ledger entries may be created if the deduction spans credit blocks. - * 3. If `invoice_settings` is specified, an invoice will be created that reflects the cost of - * the credits (based on `amount` and `per_unit_cost_basis`). - * - * ## Adding credits - * - * Adding credits is done by creating an entry of type `increment`. This requires the caller to - * specify a number of credits as well as an optional expiry date in `YYYY-MM-DD` format. Orb - * also recommends specifying a description to assist with auditing. When adding credits, the - * caller can also specify a cost basis per-credit, to indicate how much in USD a customer paid - * for a single credit in a block. This can later be used for revenue recognition. - * - * The following snippet illustrates a sample request body to increment credits which will - * expire in January of 2022. - * - * ```json - * { - * "entry_type": "increment", - * "amount": 100, - * "expiry_date": "2022-12-28", - * "per_unit_cost_basis": "0.20", - * "description": "Purchased 100 credits" - * } - * ``` - * - * Note that by default, Orb will always first increment any _negative_ balance in existing - * blocks before adding the remaining amount to the desired credit block. - * - * ### Invoicing for credits - * - * By default, Orb manipulates the credit ledger but does not charge for credits. However, if - * you pass `invoice_settings` in the body of this request, Orb will also generate a one-off - * invoice for the customer for the credits pre-purchase. Note that you _must_ provide the - * `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. - * - * ## 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. - * - * The following snippet illustrates a sample request body to decrement credits. - * - * ```json - * { - * "entry_type": "decrement", - * "amount": 20, - * "description": "Removing excess credits" - * } - * ``` - * - * ## Changing credits expiry - * - * If you'd like to change when existing credits expire, you should create a ledger entry of - * type `expiration_change`. For this entry, the required parameter `expiry_date` identifies the - * _originating_ block, and the required parameter `target_expiry_date` identifies when the - * transferred credits should now expire. A new credit block will be created with expiry date - * `target_expiry_date`, with the same cost basis data as the original credit block, if present. - * - * Note that the balance of the block with the given `expiry_date` must be at least equal to the - * desired transfer amount determined by the `amount` parameter. - * - * The following snippet illustrates a sample request body to extend the expiration date of - * credits by one year: - * ```json - * { - * "entry_type": "expiration_change", - * "amount": 10, - * "expiry_date": "2022-12-28", - * "block_id": "UiUhFWeLHPrBY4Ad", - * "target_expiry_date": "2023-12-28", - * "description": "Extending credit validity" - * } - * ``` - * - * ## Voiding credits - * - * If you'd like to void a credit block, create a ledger entry of type `void`. For this entry, - * `block_id` is required to identify the block, and `amount` indicates how many credits to - * void, up to the block's initial balance. Pass in a `void_reason` of `refund` if the void is - * due to a refund. - * - * ## Amendment - * - * If you'd like to undo a decrement on a credit block, create a ledger entry of type - * `amendment`. For this entry, `block_id` is required to identify the block that was originally - * decremented from, and `amount` indicates how many credits to return to the customer, up to - * the block's initial balance. - */ override fun createEntryByExternalId( params: CustomerCreditLedgerCreateEntryByExternalIdParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments( - "customers", - "external_customer_id", - params.getPathParam(0), - "credits", - "ledger_entry", - ) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { createEntryByExternalIdHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } - - private val listByExternalIdHandler: - Handler = - jsonHandler( - clientOptions.jsonMapper - ) - .withErrorHandler(errorHandler) + ): CompletableFuture = + // post /customers/external_customer_id/{external_customer_id}/credits/ledger_entry + withRawResponse().createEntryByExternalId(params, requestOptions).thenApply { it.parse() } - /** - * The credits ledger provides _auditing_ functionality over Orb's credits system with a list of - * actions that have taken place to modify a customer's credit balance. This - * [paginated endpoint](/api-reference/pagination) lists these entries, starting from the most - * recent ledger entry. - * - * More details on using Orb's real-time credit feature are - * [here](/product-catalog/prepurchase). - * - * There are four major types of modifications to credit balance, detailed below. - * - * ## Increment - * - * Credits (which optionally expire on a future date) can be added via the API ([Add Ledger - * Entry](create-ledger-entry)). The ledger entry for such an action will always contain the - * total eligible starting and ending balance for the customer at the time the entry was added - * to the ledger. - * - * ## Decrement - * - * Deductions can occur as a result of an API call to create a ledger entry (see - * [Add Ledger Entry](create-ledger-entry)), or automatically as a result of incurring usage. - * Both ledger entries present the `decrement` entry type. - * - * 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. - * - * By default, Orb uses an algorithm that automatically deducts from the _soonest expiring - * credit block_ first in order to ensure that all credits are utilized appropriately. As an - * example, if trial credits with an expiration date of 2 weeks from now are present for a - * customer, they will be used before any deductions take place from a non-expiring credit - * block. - * - * If there are multiple blocks with the same expiration date, Orb will deduct from the block - * with the _lower cost basis_ first (e.g. trial credits with a $0 cost basis before paid - * credits with a $5.00 cost basis). - * - * It's also possible for a single usage event's deduction to _span_ credit blocks. In this - * case, Orb will deduct from the next block, ending at the credit block which consists of - * unexpiring credits. Each of these deductions will lead to a _separate_ ledger entry, one per - * credit block that is deducted from. By default, the customer's total credit balance in Orb - * can be negative as a result of a decrement. - * - * ## Expiration change - * - * The expiry of credits can be changed as a result of the API (See - * [Add Ledger Entry](create-ledger-entry)). This will create a ledger entry that specifies the - * balance as well as the initial and target expiry dates. - * - * Note that for this entry type, `starting_balance` will equal `ending_balance`, and the - * `amount` represents the balance transferred. The credit block linked to the ledger entry is - * the source credit block from which there was an expiration change - * - * ## Credits expiry - * - * When a set of credits expire on pre-set expiration date, the customer's balance automatically - * reflects this change and adds an entry to the ledger indicating this event. Note that credit - * expiry should always happen close to a date boundary in the customer's timezone. - * - * ## Void initiated - * - * Credit blocks can be voided via the API. The `amount` on this entry corresponds to the number - * of credits that were remaining in the block at time of void. `void_reason` will be populated - * if the void is created with a reason. - * - * ## Void - * - * When a set of credits is voided, the customer's balance automatically reflects this change - * and adds an entry to the ledger indicating this event. - * - * ## Amendment - * - * When credits are added to a customer's balance as a result of a correction, this entry will - * be added to the ledger to indicate the adjustment of credits. - */ override fun listByExternalId( params: CustomerCreditLedgerListByExternalIdParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "customers", - "external_customer_id", - params.getPathParam(0), - "credits", - "ledger", + ): CompletableFuture = + // get /customers/external_customer_id/{external_customer_id}/credits/ledger + withRawResponse().listByExternalId(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + LedgerServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: CustomerCreditLedgerListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("customers", params.getPathParam(0), "credits", "ledger") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + CustomerCreditLedgerListPageAsync.of( + LedgerServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } + } + + private val createEntryHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun createEntry( + params: CustomerCreditLedgerCreateEntryParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("customers", params.getPathParam(0), "credits", "ledger_entry") + .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 -> + response.parseable { + response + .use { createEntryHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val createEntryByExternalIdHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun createEntryByExternalId( + params: CustomerCreditLedgerCreateEntryByExternalIdParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments( + "customers", + "external_customer_id", + params.getPathParam(0), + "credits", + "ledger_entry", + ) + .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 -> + response.parseable { + response + .use { createEntryByExternalIdHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listByExternalIdHandler: + Handler = + jsonHandler( + clientOptions.jsonMapper ) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listByExternalIdHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + .withErrorHandler(errorHandler) + + override fun listByExternalId( + params: CustomerCreditLedgerListByExternalIdParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "customers", + "external_customer_id", + params.getPathParam(0), + "credits", + "ledger", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listByExternalIdHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + CustomerCreditLedgerListByExternalIdPageAsync.of( + LedgerServiceAsyncImpl(clientOptions), + params, + it, + ) + } } - .let { CustomerCreditLedgerListByExternalIdPageAsync.of(this, params, it) } - } + } + } } } 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 0595a1de0..b340c1854 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 @@ -4,21 +4,28 @@ package com.withorb.api.services.async.customers.credits +import com.google.errorprone.annotations.MustBeClosed 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.CustomerCreditTopUpCreateByExternalIdParams -import com.withorb.api.models.CustomerCreditTopUpCreateByExternalIdResponse import com.withorb.api.models.CustomerCreditTopUpCreateParams -import com.withorb.api.models.CustomerCreditTopUpCreateResponse import com.withorb.api.models.CustomerCreditTopUpDeleteByExternalIdParams import com.withorb.api.models.CustomerCreditTopUpDeleteParams import com.withorb.api.models.CustomerCreditTopUpListByExternalIdPageAsync import com.withorb.api.models.CustomerCreditTopUpListByExternalIdParams import com.withorb.api.models.CustomerCreditTopUpListPageAsync import com.withorb.api.models.CustomerCreditTopUpListParams +import com.withorb.api.models.TopUpModel import java.util.concurrent.CompletableFuture interface TopUpServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * This endpoint allows you to create a new top-up for a specified customer's balance. While * this top-up is active, the customer's balance will added in increments of the specified @@ -31,7 +38,7 @@ interface TopUpServiceAsync { fun create( params: CustomerCreditTopUpCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** List top-ups */ @JvmOverloads @@ -62,7 +69,7 @@ interface TopUpServiceAsync { fun createByExternalId( params: CustomerCreditTopUpCreateByExternalIdParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This deactivates the top-up and voids any invoices associated with pending credit blocks @@ -80,4 +87,78 @@ interface TopUpServiceAsync { params: CustomerCreditTopUpListByExternalIdParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** A view of [TopUpServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /customers/{customer_id}/credits/top_ups`, but is + * otherwise the same as [TopUpServiceAsync.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: CustomerCreditTopUpCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /customers/{customer_id}/credits/top_ups`, but is + * otherwise the same as [TopUpServiceAsync.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: CustomerCreditTopUpListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `delete + * /customers/{customer_id}/credits/top_ups/{top_up_id}`, but is otherwise the same as + * [TopUpServiceAsync.delete]. + */ + @JvmOverloads + @MustBeClosed + fun delete( + params: CustomerCreditTopUpDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * Returns a raw HTTP response for `post + * /customers/external_customer_id/{external_customer_id}/credits/top_ups`, but is otherwise + * the same as [TopUpServiceAsync.createByExternalId]. + */ + @JvmOverloads + @MustBeClosed + fun createByExternalId( + params: CustomerCreditTopUpCreateByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `delete + * /customers/external_customer_id/{external_customer_id}/credits/top_ups/{top_up_id}`, but + * is otherwise the same as [TopUpServiceAsync.deleteByExternalId]. + */ + @JvmOverloads + @MustBeClosed + fun deleteByExternalId( + params: CustomerCreditTopUpDeleteByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * Returns a raw HTTP response for `get + * /customers/external_customer_id/{external_customer_id}/credits/top_ups`, but is otherwise + * the same as [TopUpServiceAsync.listByExternalId]. + */ + @JvmOverloads + @MustBeClosed + fun listByExternalId( + params: CustomerCreditTopUpListByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } 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 d4552def8..6bdab89ac 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 @@ -10,225 +10,283 @@ import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler 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.json +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.errors.OrbError import com.withorb.api.models.CustomerCreditTopUpCreateByExternalIdParams -import com.withorb.api.models.CustomerCreditTopUpCreateByExternalIdResponse import com.withorb.api.models.CustomerCreditTopUpCreateParams -import com.withorb.api.models.CustomerCreditTopUpCreateResponse import com.withorb.api.models.CustomerCreditTopUpDeleteByExternalIdParams import com.withorb.api.models.CustomerCreditTopUpDeleteParams import com.withorb.api.models.CustomerCreditTopUpListByExternalIdPageAsync import com.withorb.api.models.CustomerCreditTopUpListByExternalIdParams import com.withorb.api.models.CustomerCreditTopUpListPageAsync import com.withorb.api.models.CustomerCreditTopUpListParams +import com.withorb.api.models.TopUpModel import java.util.concurrent.CompletableFuture class TopUpServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : TopUpServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: TopUpServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): TopUpServiceAsync.WithRawResponse = withRawResponse - /** - * This endpoint allows you to create a new top-up for a specified customer's balance. While - * this top-up is active, the customer's balance will added in increments of the specified - * amount whenever the balance reaches the specified threshold. - * - * If a top-up already exists for this customer in the same currency, the existing top-up will - * be replaced. - */ override fun create( params: CustomerCreditTopUpCreateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("customers", params.getPathParam(0), "credits", "top_ups") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } + ): CompletableFuture = + // post /customers/{customer_id}/credits/top_ups + withRawResponse().create(params, requestOptions).thenApply { it.parse() } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** List top-ups */ override fun list( params: CustomerCreditTopUpListParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("customers", params.getPathParam(0), "credits", "top_ups") - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - .let { CustomerCreditTopUpListPageAsync.of(this, params, it) } - } - } - - private val deleteHandler: Handler = emptyHandler().withErrorHandler(errorHandler) + ): CompletableFuture = + // get /customers/{customer_id}/credits/top_ups + withRawResponse().list(params, requestOptions).thenApply { it.parse() } - /** - * This deactivates the top-up and voids any invoices associated with pending credit blocks - * purchased through the top-up. - */ override fun delete( params: CustomerCreditTopUpDeleteParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments( - "customers", - params.getPathParam(0), - "credits", - "top_ups", - params.getPathParam(1), - ) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> response.use { deleteHandler.handle(it) } } - } + ): CompletableFuture = + // delete /customers/{customer_id}/credits/top_ups/{top_up_id} + withRawResponse().delete(params, requestOptions).thenAccept {} - private val createByExternalIdHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * This endpoint allows you to create a new top-up for a specified customer's balance. While - * this top-up is active, the customer's balance will added in increments of the specified - * amount whenever the balance reaches the specified threshold. - * - * If a top-up already exists for this customer in the same currency, the existing top-up will - * be replaced. - */ override fun createByExternalId( params: CustomerCreditTopUpCreateByExternalIdParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments( - "customers", - "external_customer_id", - params.getPathParam(0), - "credits", - "top_ups", - ) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { createByExternalIdHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } - - private val deleteByExternalIdHandler: Handler = - emptyHandler().withErrorHandler(errorHandler) + ): CompletableFuture = + // post /customers/external_customer_id/{external_customer_id}/credits/top_ups + withRawResponse().createByExternalId(params, requestOptions).thenApply { it.parse() } - /** - * This deactivates the top-up and voids any invoices associated with pending credit blocks - * purchased through the top-up. - */ override fun deleteByExternalId( params: CustomerCreditTopUpDeleteByExternalIdParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments( - "customers", - "external_customer_id", - params.getPathParam(0), - "credits", - "top_ups", - params.getPathParam(1), - ) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> response.use { deleteByExternalIdHandler.handle(it) } } - } + ): CompletableFuture = + // delete /customers/external_customer_id/{external_customer_id}/credits/top_ups/{top_up_id} + withRawResponse().deleteByExternalId(params, requestOptions).thenAccept {} - private val listByExternalIdHandler: - Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** List top-ups by external ID */ override fun listByExternalId( params: CustomerCreditTopUpListByExternalIdParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "customers", - "external_customer_id", - params.getPathParam(0), - "credits", - "top_ups", + ): CompletableFuture = + // get /customers/external_customer_id/{external_customer_id}/credits/top_ups + withRawResponse().listByExternalId(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TopUpServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: CustomerCreditTopUpCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("customers", params.getPathParam(0), "credits", "top_ups") + .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 -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: CustomerCreditTopUpListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("customers", params.getPathParam(0), "credits", "top_ups") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + CustomerCreditTopUpListPageAsync.of( + TopUpServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } + } + + private val deleteHandler: Handler = emptyHandler().withErrorHandler(errorHandler) + + override fun delete( + params: CustomerCreditTopUpDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments( + "customers", + params.getPathParam(0), + "credits", + "top_ups", + params.getPathParam(1), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { response.use { deleteHandler.handle(it) } } + } + } + + private val createByExternalIdHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun createByExternalId( + params: CustomerCreditTopUpCreateByExternalIdParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments( + "customers", + "external_customer_id", + params.getPathParam(0), + "credits", + "top_ups", + ) + .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 -> + response.parseable { + response + .use { createByExternalIdHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val deleteByExternalIdHandler: Handler = + emptyHandler().withErrorHandler(errorHandler) + + override fun deleteByExternalId( + params: CustomerCreditTopUpDeleteByExternalIdParams, + requestOptions: RequestOptions, + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments( + "customers", + "external_customer_id", + params.getPathParam(0), + "credits", + "top_ups", + params.getPathParam(1), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { response.use { deleteByExternalIdHandler.handle(it) } } + } + } + + private val listByExternalIdHandler: + Handler = + jsonHandler( + clientOptions.jsonMapper ) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listByExternalIdHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + .withErrorHandler(errorHandler) + + override fun listByExternalId( + params: CustomerCreditTopUpListByExternalIdParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "customers", + "external_customer_id", + params.getPathParam(0), + "credits", + "top_ups", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listByExternalIdHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + CustomerCreditTopUpListByExternalIdPageAsync.of( + TopUpServiceAsyncImpl(clientOptions), + params, + it, + ) + } } - .let { CustomerCreditTopUpListByExternalIdPageAsync.of(this, params, it) } - } + } + } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceAsync.kt index 422536396..e283d1bd3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceAsync.kt @@ -4,17 +4,43 @@ package com.withorb.api.services.async.dimensionalPriceGroups +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions -import com.withorb.api.models.DimensionalPriceGroup +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams +import com.withorb.api.models.DimensionalPriceGroupModel import java.util.concurrent.CompletableFuture interface ExternalDimensionalPriceGroupIdServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Fetch dimensional price group by external ID */ @JvmOverloads fun retrieve( params: DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture + + /** + * A view of [ExternalDimensionalPriceGroupIdServiceAsync] that provides access to raw HTTP + * responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get + * /dimensional_price_groups/external_dimensional_price_group_id/{external_dimensional_price_group_id}`, + * but is otherwise the same as [ExternalDimensionalPriceGroupIdServiceAsync.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceAsyncImpl.kt index 74ba97499..7c1194f7a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceAsyncImpl.kt @@ -10,46 +10,71 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest 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.errors.OrbError -import com.withorb.api.models.DimensionalPriceGroup import com.withorb.api.models.DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams +import com.withorb.api.models.DimensionalPriceGroupModel import java.util.concurrent.CompletableFuture class ExternalDimensionalPriceGroupIdServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ExternalDimensionalPriceGroupIdServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: + ExternalDimensionalPriceGroupIdServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): ExternalDimensionalPriceGroupIdServiceAsync.WithRawResponse = + withRawResponse - /** Fetch dimensional price group by external ID */ override fun retrieve( params: DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "dimensional_price_groups", - "external_dimensional_price_group_id", - params.getPathParam(0), - ) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): CompletableFuture = + // get + // /dimensional_price_groups/external_dimensional_price_group_id/{external_dimensional_price_group_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ExternalDimensionalPriceGroupIdServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "dimensional_price_groups", + "external_dimensional_price_group_id", + params.getPathParam(0), + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } 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 e285d8ee5..28ceb44ec 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 @@ -4,21 +4,25 @@ package com.withorb.api.services.async.events +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.BackfillModel import com.withorb.api.models.EventBackfillCloseParams -import com.withorb.api.models.EventBackfillCloseResponse import com.withorb.api.models.EventBackfillCreateParams -import com.withorb.api.models.EventBackfillCreateResponse import com.withorb.api.models.EventBackfillFetchParams -import com.withorb.api.models.EventBackfillFetchResponse import com.withorb.api.models.EventBackfillListPageAsync import com.withorb.api.models.EventBackfillListParams import com.withorb.api.models.EventBackfillRevertParams -import com.withorb.api.models.EventBackfillRevertResponse import java.util.concurrent.CompletableFuture interface BackfillServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * 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: @@ -53,7 +57,7 @@ interface BackfillServiceAsync { fun create( params: EventBackfillCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This endpoint returns a list of all backfills in a list format. @@ -89,14 +93,14 @@ interface BackfillServiceAsync { fun close( params: EventBackfillCloseParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** This endpoint is used to fetch a backfill given an identifier. */ @JvmOverloads fun fetch( params: EventBackfillFetchParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * Reverting a backfill undoes all the effects of closing the backfill. If the backfill is @@ -110,5 +114,76 @@ interface BackfillServiceAsync { fun revert( params: EventBackfillRevertParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture + + /** + * A view of [BackfillServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /events/backfills`, but is otherwise the same as + * [BackfillServiceAsync.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: EventBackfillCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /events/backfills`, but is otherwise the same as + * [BackfillServiceAsync.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: EventBackfillListParams = EventBackfillListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /events/backfills`, but is otherwise the same as + * [BackfillServiceAsync.list]. + */ + @MustBeClosed + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(EventBackfillListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /events/backfills/{backfill_id}/close`, but is + * otherwise the same as [BackfillServiceAsync.close]. + */ + @JvmOverloads + @MustBeClosed + fun close( + params: EventBackfillCloseParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /events/backfills/{backfill_id}`, but is otherwise + * the same as [BackfillServiceAsync.fetch]. + */ + @JvmOverloads + @MustBeClosed + fun fetch( + params: EventBackfillFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /events/backfills/{backfill_id}/revert`, but is + * otherwise the same as [BackfillServiceAsync.revert]. + */ + @JvmOverloads + @MustBeClosed + fun revert( + params: EventBackfillRevertParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } 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 35bf790e9..92a546c60 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 @@ -10,214 +10,223 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest import com.withorb.api.core.http.HttpResponse.Handler -import com.withorb.api.core.json +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.errors.OrbError +import com.withorb.api.models.BackfillModel import com.withorb.api.models.EventBackfillCloseParams -import com.withorb.api.models.EventBackfillCloseResponse import com.withorb.api.models.EventBackfillCreateParams -import com.withorb.api.models.EventBackfillCreateResponse import com.withorb.api.models.EventBackfillFetchParams -import com.withorb.api.models.EventBackfillFetchResponse import com.withorb.api.models.EventBackfillListPageAsync import com.withorb.api.models.EventBackfillListParams import com.withorb.api.models.EventBackfillRevertParams -import com.withorb.api.models.EventBackfillRevertResponse import java.util.concurrent.CompletableFuture class BackfillServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : BackfillServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * 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`). - * 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 - * worry about your customers seeing partially updated usage data. Backfills are also - * reversible, so you’ll be able to revert a backfill if you’ve made a mistake. - * - * This endpoint will return a backfill object, which contains an `id`. That `id` can then be - * used as the `backfill_id` query parameter to the event ingestion endpoint to associate - * ingested events with this backfill. The effects (e.g. updated usage graphs) of this backfill - * will not take place until the backfill is closed. - * - * If the `replace_existing_events` is `true`, existing events in the backfill's timeframe will - * be replaced with the newly ingested events associated with the backfill. If `false`, newly - * ingested events will be added to the existing events. - * - * If a `customer_id` or `external_customer_id` is specified, the backfill will only affect - * events for that customer. If neither is specified, the backfill will affect all customers. - * - * When `replace_existing_events` is `true`, this indicates that existing events in the - * timeframe should no longer be counted towards invoiced usage. In this scenario, the parameter - * `filter` can be optionally added which enables filtering using - * [computed properties](/extensibility/advanced-metrics#computed-properties). The - * expressiveness of computed properties allows you to deprecate existing events based on both a - * period of time and specific property values. - */ + private val withRawResponse: BackfillServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): BackfillServiceAsync.WithRawResponse = withRawResponse + override fun create( params: EventBackfillCreateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("events", "backfills") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } + ): CompletableFuture = + // post /events/backfills + withRawResponse().create(params, requestOptions).thenApply { it.parse() } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * This endpoint returns a list of all backfills in a list format. - * - * 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). - */ override fun list( params: EventBackfillListParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("events", "backfills") - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - .let { EventBackfillListPageAsync.of(this, params, it) } - } - } - - private val closeHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + ): CompletableFuture = + // get /events/backfills + withRawResponse().list(params, requestOptions).thenApply { it.parse() } - /** - * Closing a backfill makes the updated usage visible in Orb. Upon closing a backfill, Orb will - * asynchronously reflect the updated usage in invoice amounts and usage graphs. Once all of the - * updates are complete, the backfill's status will transition to `reflected`. - */ override fun close( params: EventBackfillCloseParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("events", "backfills", params.getPathParam(0), "close") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { closeHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } + ): CompletableFuture = + // post /events/backfills/{backfill_id}/close + withRawResponse().close(params, requestOptions).thenApply { it.parse() } - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** This endpoint is used to fetch a backfill given an identifier. */ override fun fetch( params: EventBackfillFetchParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("events", "backfills", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } + ): CompletableFuture = + // get /events/backfills/{backfill_id} + withRawResponse().fetch(params, requestOptions).thenApply { it.parse() } - private val revertHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * Reverting a backfill undoes all the effects of closing the backfill. If the backfill is - * reflected, the status will transition to `pending_revert` while the effects of the backfill - * are undone. Once all effects are undone, the backfill will transition to `reverted`. - * - * If a backfill is reverted before its closed, no usage will be updated as a result of the - * backfill and it will immediately transition to `reverted`. - */ override fun revert( params: EventBackfillRevertParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("events", "backfills", params.getPathParam(0), "revert") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { revertHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): CompletableFuture = + // post /events/backfills/{backfill_id}/revert + withRawResponse().revert(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BackfillServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: EventBackfillCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("events", "backfills") + .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 -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: EventBackfillListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("events", "backfills") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + EventBackfillListPageAsync.of( + BackfillServiceAsyncImpl(clientOptions), + params, + it, + ) + } + } + } + } + + private val closeHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun close( + params: EventBackfillCloseParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("events", "backfills", params.getPathParam(0), "close") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { closeHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetch( + params: EventBackfillFetchParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("events", "backfills", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val revertHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun revert( + params: EventBackfillRevertParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("events", "backfills", params.getPathParam(0), "revert") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { revertHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } 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 bcbf29ec5..0eea889f8 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 @@ -4,13 +4,20 @@ package com.withorb.api.services.async.events +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.EventVolumeListParams import com.withorb.api.models.EventVolumes import java.util.concurrent.CompletableFuture interface VolumeServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * This endpoint returns the event volume for an account in a * [paginated list format](/api-reference/pagination). @@ -29,4 +36,21 @@ interface VolumeServiceAsync { params: EventVolumeListParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** + * A view of [VolumeServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /events/volume`, but is otherwise the same as + * [VolumeServiceAsync.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: EventVolumeListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } 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 024cbdd5f..badc78e38 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 @@ -10,6 +10,8 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest 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.errors.OrbError import com.withorb.api.models.EventVolumeListParams @@ -19,44 +21,51 @@ import java.util.concurrent.CompletableFuture class VolumeServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : VolumeServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint returns the event volume for an account in a - * [paginated list format](/api-reference/pagination). - * - * The event volume is aggregated by the hour and the - * [timestamp](/api-reference/event/ingest-events) field is used to determine which hour an - * event is associated with. Note, this means that late-arriving events increment the volume - * count for the hour window the timestamp is in, not the latest hour window. - * - * Each item in the response contains the count of events aggregated by the hour where the start - * and end time are hour-aligned and in UTC. When a specific timestamp is passed in for either - * start or end time, the response includes the hours the timestamp falls in. - */ + private val withRawResponse: VolumeServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): VolumeServiceAsync.WithRawResponse = withRawResponse + override fun list( params: EventVolumeListParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("events", "volume") - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): CompletableFuture = + // get /events/volume + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + VolumeServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list( + params: EventVolumeListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("events", "volume") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.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 ae4720f91..03b4908df 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 @@ -4,14 +4,21 @@ package com.withorb.api.services.async.plans +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions -import com.withorb.api.models.Plan +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.PlanExternalPlanIdFetchParams import com.withorb.api.models.PlanExternalPlanIdUpdateParams +import com.withorb.api.models.PlanModel import java.util.concurrent.CompletableFuture interface ExternalPlanIdServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * This endpoint can be used to update the `external_plan_id`, and `metadata` of an existing * plan. @@ -22,7 +29,7 @@ interface ExternalPlanIdServiceAsync { fun update( params: PlanExternalPlanIdUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This endpoint is used to fetch [plan](/core-concepts##plan-and-price) details given an @@ -45,5 +52,34 @@ interface ExternalPlanIdServiceAsync { fun fetch( params: PlanExternalPlanIdFetchParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture + + /** + * A view of [ExternalPlanIdServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `put /plans/external_plan_id/{external_plan_id}`, but is + * otherwise the same as [ExternalPlanIdServiceAsync.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: PlanExternalPlanIdUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /plans/external_plan_id/{external_plan_id}`, but is + * otherwise the same as [ExternalPlanIdServiceAsync.fetch]. + */ + @JvmOverloads + @MustBeClosed + fun fetch( + params: PlanExternalPlanIdFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } 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 cd485e5e2..f00b6d33d 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 @@ -10,92 +10,101 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest import com.withorb.api.core.http.HttpResponse.Handler -import com.withorb.api.core.json +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.errors.OrbError -import com.withorb.api.models.Plan import com.withorb.api.models.PlanExternalPlanIdFetchParams import com.withorb.api.models.PlanExternalPlanIdUpdateParams +import com.withorb.api.models.PlanModel import java.util.concurrent.CompletableFuture class ExternalPlanIdServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ExternalPlanIdServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ExternalPlanIdServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): ExternalPlanIdServiceAsync.WithRawResponse = withRawResponse - /** - * This endpoint can be used to update the `external_plan_id`, and `metadata` of an existing - * plan. - * - * Other fields on a customer are currently immutable. - */ override fun update( params: PlanExternalPlanIdUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("plans", "external_plan_id", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } + ): CompletableFuture = + // put /plans/external_plan_id/{external_plan_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint is used to fetch [plan](/core-concepts##plan-and-price) details given an - * external_plan_id identifier. It returns information about the prices included in the plan and - * their configuration, as well as the product that the plan is attached to. - * - * If multiple plans are found to contain the specified external_plan_id, the active plans will - * take priority over archived ones, and among those, the endpoint will return the most recently - * created plan. - * - * ## Serialized prices - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given [Price](/core-concepts#plan-and-price) object. The - * `model_type` field determines the key for the configuration object that is present. A - * detailed explanation of price types can be found in the - * [Price schema](/core-concepts#plan-and-price). " - */ override fun fetch( params: PlanExternalPlanIdFetchParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("plans", "external_plan_id", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): CompletableFuture = + // get /plans/external_plan_id/{external_plan_id} + withRawResponse().fetch(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ExternalPlanIdServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: PlanExternalPlanIdUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("plans", "external_plan_id", params.getPathParam(0)) + .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 -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetch( + params: PlanExternalPlanIdFetchParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("plans", "external_plan_id", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } 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 f26f1cfda..eced19013 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 @@ -4,14 +4,21 @@ package com.withorb.api.services.async.prices +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions -import com.withorb.api.models.Price +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.PriceExternalPriceIdFetchParams import com.withorb.api.models.PriceExternalPriceIdUpdateParams +import com.withorb.api.models.PriceModel import java.util.concurrent.CompletableFuture interface ExternalPriceIdServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * 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. @@ -20,7 +27,7 @@ interface ExternalPriceIdServiceAsync { fun update( params: PriceExternalPriceIdUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This endpoint returns a price given an external price id. See the @@ -31,5 +38,34 @@ interface ExternalPriceIdServiceAsync { fun fetch( params: PriceExternalPriceIdFetchParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture + + /** + * A view of [ExternalPriceIdServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `put /prices/external_price_id/{external_price_id}`, but + * is otherwise the same as [ExternalPriceIdServiceAsync.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: PriceExternalPriceIdUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /prices/external_price_id/{external_price_id}`, but + * is otherwise the same as [ExternalPriceIdServiceAsync.fetch]. + */ + @JvmOverloads + @MustBeClosed + fun fetch( + params: PriceExternalPriceIdFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } 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 9c4db82e4..9c501471a 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 @@ -10,78 +10,101 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest import com.withorb.api.core.http.HttpResponse.Handler -import com.withorb.api.core.json +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.errors.OrbError -import com.withorb.api.models.Price import com.withorb.api.models.PriceExternalPriceIdFetchParams import com.withorb.api.models.PriceExternalPriceIdUpdateParams +import com.withorb.api.models.PriceModel import java.util.concurrent.CompletableFuture class ExternalPriceIdServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ExternalPriceIdServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ExternalPriceIdServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): ExternalPriceIdServiceAsync.WithRawResponse = withRawResponse - /** - * 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. - */ override fun update( params: PriceExternalPriceIdUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("prices", "external_price_id", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - } + ): CompletableFuture = + // put /prices/external_price_id/{external_price_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint returns a price given an external price id. See the - * [price creation API](/api-reference/price/create-price) for more information about external - * price aliases. - */ override fun fetch( params: PriceExternalPriceIdFetchParams, requestOptions: RequestOptions, - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("prices", "external_price_id", params.getPathParam(0)) - .build() - .prepareAsync(clientOptions, params) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): CompletableFuture = + // get /prices/external_price_id/{external_price_id} + withRawResponse().fetch(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ExternalPriceIdServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: PriceExternalPriceIdUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("prices", "external_price_id", params.getPathParam(0)) + .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 -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetch( + params: PriceExternalPriceIdFetchParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("prices", "external_price_id", params.getPathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + } } } 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 1c2e3fbb8..a3448e8e0 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 @@ -4,8 +4,9 @@ package com.withorb.api.services.blocking +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions -import com.withorb.api.models.Alert +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.AlertCreateForCustomerParams import com.withorb.api.models.AlertCreateForExternalCustomerParams import com.withorb.api.models.AlertCreateForSubscriptionParams @@ -13,24 +14,30 @@ import com.withorb.api.models.AlertDisableParams import com.withorb.api.models.AlertEnableParams import com.withorb.api.models.AlertListPage import com.withorb.api.models.AlertListParams +import com.withorb.api.models.AlertModel import com.withorb.api.models.AlertRetrieveParams import com.withorb.api.models.AlertUpdateParams interface AlertService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** This endpoint retrieves an alert by its ID. */ @JvmOverloads fun retrieve( params: AlertRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Alert + ): AlertModel /** This endpoint updates the thresholds of an alert. */ @JvmOverloads fun update( params: AlertUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Alert + ): AlertModel /** * This endpoint returns a list of alerts within Orb. @@ -75,7 +82,7 @@ interface AlertService { fun createForCustomer( params: AlertCreateForCustomerParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Alert + ): AlertModel /** * This endpoint creates a new alert to monitor a customer's credit balance. There are three @@ -89,7 +96,7 @@ interface AlertService { fun createForExternalCustomer( params: AlertCreateForExternalCustomerParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Alert + ): AlertModel /** * This endpoint is used to create alerts at the subscription level. @@ -107,7 +114,7 @@ interface AlertService { fun createForSubscription( params: AlertCreateForSubscriptionParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Alert + ): AlertModel /** * This endpoint allows you to disable an alert. To disable a plan-level alert for a specific @@ -118,7 +125,7 @@ interface AlertService { fun disable( params: AlertDisableParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Alert + ): AlertModel /** * This endpoint allows you to enable an alert. To enable a plan-level alert for a specific @@ -129,5 +136,106 @@ interface AlertService { fun enable( params: AlertEnableParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Alert + ): AlertModel + + /** A view of [AlertService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /alerts/{alert_id}`, but is otherwise the same as + * [AlertService.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: AlertRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `put /alerts/{alert_configuration_id}`, but is otherwise + * the same as [AlertService.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: AlertUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /alerts`, but is otherwise the same as + * [AlertService.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: AlertListParams = AlertListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /alerts`, but is otherwise the same as + * [AlertService.list]. + */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(AlertListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /alerts/customer_id/{customer_id}`, but is + * otherwise the same as [AlertService.createForCustomer]. + */ + @JvmOverloads + @MustBeClosed + fun createForCustomer( + params: AlertCreateForCustomerParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post + * /alerts/external_customer_id/{external_customer_id}`, but is otherwise the same as + * [AlertService.createForExternalCustomer]. + */ + @JvmOverloads + @MustBeClosed + fun createForExternalCustomer( + params: AlertCreateForExternalCustomerParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /alerts/subscription_id/{subscription_id}`, but is + * otherwise the same as [AlertService.createForSubscription]. + */ + @JvmOverloads + @MustBeClosed + fun createForSubscription( + params: AlertCreateForSubscriptionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /alerts/{alert_configuration_id}/disable`, but is + * otherwise the same as [AlertService.disable]. + */ + @JvmOverloads + @MustBeClosed + fun disable( + params: AlertDisableParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /alerts/{alert_configuration_id}/enable`, but is + * otherwise the same as [AlertService.enable]. + */ + @JvmOverloads + @MustBeClosed + fun enable( + params: AlertEnableParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } 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 ff7482302..17943c9a9 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 @@ -10,10 +10,11 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest import com.withorb.api.core.http.HttpResponse.Handler -import com.withorb.api.core.json +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.errors.OrbError -import com.withorb.api.models.Alert import com.withorb.api.models.AlertCreateForCustomerParams import com.withorb.api.models.AlertCreateForExternalCustomerParams import com.withorb.api.models.AlertCreateForSubscriptionParams @@ -21,238 +22,279 @@ import com.withorb.api.models.AlertDisableParams import com.withorb.api.models.AlertEnableParams import com.withorb.api.models.AlertListPage import com.withorb.api.models.AlertListParams +import com.withorb.api.models.AlertModel import com.withorb.api.models.AlertRetrieveParams import com.withorb.api.models.AlertUpdateParams class AlertServiceImpl internal constructor(private val clientOptions: ClientOptions) : AlertService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** This endpoint retrieves an alert by its ID. */ - override fun retrieve(params: AlertRetrieveParams, requestOptions: RequestOptions): Alert { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("alerts", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } + private val withRawResponse: AlertService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** This endpoint updates the thresholds of an alert. */ - override fun update(params: AlertUpdateParams, requestOptions: RequestOptions): Alert { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("alerts", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } + override fun withRawResponse(): AlertService.WithRawResponse = withRawResponse - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun retrieve(params: AlertRetrieveParams, requestOptions: RequestOptions): AlertModel = + // get /alerts/{alert_id} + withRawResponse().retrieve(params, requestOptions).parse() - /** - * This endpoint returns a list of alerts within Orb. - * - * The request must specify one of `customer_id`, `external_customer_id`, or `subscription_id`. - * - * If querying by subscripion_id, the endpoint will return the subscription level alerts as well - * as the plan level alerts associated with the subscription. - * - * The list of alerts is ordered starting from the most recently created alert. This endpoint - * follows Orb's [standardized pagination format](/api-reference/pagination). - */ - override fun list(params: AlertListParams, requestOptions: RequestOptions): AlertListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("alerts") - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - .let { AlertListPage.of(this, params, it) } - } + override fun update(params: AlertUpdateParams, requestOptions: RequestOptions): AlertModel = + // put /alerts/{alert_configuration_id} + withRawResponse().update(params, requestOptions).parse() - private val createForCustomerHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun list(params: AlertListParams, requestOptions: RequestOptions): AlertListPage = + // get /alerts + withRawResponse().list(params, requestOptions).parse() - /** - * This endpoint creates a new alert to monitor a customer's credit balance. There are three - * types of alerts that can be scoped to customers: `credit_balance_depleted`, - * `credit_balance_dropped`, and `credit_balance_recovered`. Customers can have a maximum of one - * of each type of alert per [credit balance currency](/product-catalog/prepurchase). - * `credit_balance_dropped` alerts require a list of thresholds to be provided while - * `credit_balance_depleted` and `credit_balance_recovered` alerts do not require thresholds. - */ override fun createForCustomer( params: AlertCreateForCustomerParams, requestOptions: RequestOptions, - ): Alert { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("alerts", "customer_id", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { createForCustomerHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } + ): AlertModel = + // post /alerts/customer_id/{customer_id} + withRawResponse().createForCustomer(params, requestOptions).parse() - private val createForExternalCustomerHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint creates a new alert to monitor a customer's credit balance. There are three - * types of alerts that can be scoped to customers: `credit_balance_depleted`, - * `credit_balance_dropped`, and `credit_balance_recovered`. Customers can have a maximum of one - * of each type of alert per [credit balance currency](/product-catalog/prepurchase). - * `credit_balance_dropped` alerts require a list of thresholds to be provided while - * `credit_balance_depleted` and `credit_balance_recovered` alerts do not require thresholds. - */ override fun createForExternalCustomer( params: AlertCreateForExternalCustomerParams, requestOptions: RequestOptions, - ): Alert { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("alerts", "external_customer_id", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { createForExternalCustomerHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } + ): AlertModel = + // post /alerts/external_customer_id/{external_customer_id} + withRawResponse().createForExternalCustomer(params, requestOptions).parse() - private val createForSubscriptionHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint is used to create alerts at the subscription level. - * - * Subscription level alerts can be one of two types: `usage_exceeded` or `cost_exceeded`. A - * `usage_exceeded` alert is scoped to a particular metric and is triggered when the usage of - * that metric exceeds predefined thresholds during the current billing cycle. A `cost_exceeded` - * alert is triggered when the total amount due during the current billing cycle surpasses - * predefined thresholds. `cost_exceeded` alerts do not include burndown of pre-purchase - * credits. Each subscription can have one `cost_exceeded` alert and one `usage_exceeded` alert - * per metric that is a part of the subscription. Alerts are triggered based on usage or cost - * conditions met during the current billing cycle. - */ override fun createForSubscription( params: AlertCreateForSubscriptionParams, requestOptions: RequestOptions, - ): Alert { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("alerts", "subscription_id", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { createForSubscriptionHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): AlertModel = + // post /alerts/subscription_id/{subscription_id} + withRawResponse().createForSubscription(params, requestOptions).parse() + + override fun disable(params: AlertDisableParams, requestOptions: RequestOptions): AlertModel = + // post /alerts/{alert_configuration_id}/disable + withRawResponse().disable(params, requestOptions).parse() + + override fun enable(params: AlertEnableParams, requestOptions: RequestOptions): AlertModel = + // post /alerts/{alert_configuration_id}/enable + withRawResponse().enable(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AlertService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: AlertRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("alerts", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } - private val disableHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - /** - * This endpoint allows you to disable an alert. To disable a plan-level alert for a specific - * subscription, you must include the `subscription_id`. The `subscription_id` is not required - * for customer or subscription level alerts. - */ - override fun disable(params: AlertDisableParams, requestOptions: RequestOptions): Alert { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("alerts", params.getPathParam(0), "disable") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { disableHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + override fun update( + params: AlertUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("alerts", params.getPathParam(0)) + .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 response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: AlertListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("alerts") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { AlertListPage.of(AlertServiceImpl(clientOptions), params, it) } + } + } + + private val createForCustomerHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun createForCustomer( + params: AlertCreateForCustomerParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("alerts", "customer_id", params.getPathParam(0)) + .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 response.parseable { + response + .use { createForCustomerHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val createForExternalCustomerHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun createForExternalCustomer( + params: AlertCreateForExternalCustomerParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("alerts", "external_customer_id", params.getPathParam(0)) + .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 response.parseable { + response + .use { createForExternalCustomerHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val createForSubscriptionHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun createForSubscription( + params: AlertCreateForSubscriptionParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("alerts", "subscription_id", params.getPathParam(0)) + .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 response.parseable { + response + .use { createForSubscriptionHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val disableHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun disable( + params: AlertDisableParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("alerts", params.getPathParam(0), "disable") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { disableHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } - private val enableHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val enableHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - /** - * This endpoint allows you to enable an alert. To enable a plan-level alert for a specific - * subscription, you must include the `subscription_id`. The `subscription_id` is not required - * for customer or subscription level alerts. - */ - override fun enable(params: AlertEnableParams, requestOptions: RequestOptions): Alert { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("alerts", params.getPathParam(0), "enable") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { enableHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + override fun enable( + params: AlertEnableParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("alerts", params.getPathParam(0), "enable") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { enableHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } 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 a50c55fd0..f599117af 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 @@ -4,17 +4,24 @@ package com.withorb.api.services.blocking +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions -import com.withorb.api.models.Coupon +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.CouponArchiveParams import com.withorb.api.models.CouponCreateParams import com.withorb.api.models.CouponFetchParams import com.withorb.api.models.CouponListPage import com.withorb.api.models.CouponListParams +import com.withorb.api.models.CouponModel import com.withorb.api.services.blocking.coupons.SubscriptionService interface CouponService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + fun subscriptions(): SubscriptionService /** @@ -25,7 +32,7 @@ interface CouponService { fun create( params: CouponCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Coupon + ): CouponModel /** * This endpoint returns a list of all coupons for an account in a list format. @@ -61,7 +68,7 @@ interface CouponService { fun archive( params: CouponArchiveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Coupon + ): CouponModel /** * This endpoint retrieves a coupon by its ID. To fetch coupons by their redemption code, use @@ -71,5 +78,63 @@ interface CouponService { fun fetch( params: CouponFetchParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Coupon + ): CouponModel + + /** A view of [CouponService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + fun subscriptions(): SubscriptionService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /coupons`, but is otherwise the same as + * [CouponService.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: CouponCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /coupons`, but is otherwise the same as + * [CouponService.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: CouponListParams = CouponListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /coupons`, but is otherwise the same as + * [CouponService.list]. + */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(CouponListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /coupons/{coupon_id}/archive`, but is otherwise the + * same as [CouponService.archive]. + */ + @JvmOverloads + @MustBeClosed + fun archive( + params: CouponArchiveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /coupons/{coupon_id}`, but is otherwise the same as + * [CouponService.fetch]. + */ + @JvmOverloads + @MustBeClosed + fun fetch( + params: CouponFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } 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 e5f394b31..eae58201a 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 @@ -10,131 +10,168 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest import com.withorb.api.core.http.HttpResponse.Handler -import com.withorb.api.core.json +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.errors.OrbError -import com.withorb.api.models.Coupon import com.withorb.api.models.CouponArchiveParams import com.withorb.api.models.CouponCreateParams import com.withorb.api.models.CouponFetchParams import com.withorb.api.models.CouponListPage import com.withorb.api.models.CouponListParams +import com.withorb.api.models.CouponModel import com.withorb.api.services.blocking.coupons.SubscriptionService import com.withorb.api.services.blocking.coupons.SubscriptionServiceImpl class CouponServiceImpl internal constructor(private val clientOptions: ClientOptions) : CouponService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: CouponService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } private val subscriptions: SubscriptionService by lazy { SubscriptionServiceImpl(clientOptions) } + override fun withRawResponse(): CouponService.WithRawResponse = withRawResponse + override fun subscriptions(): SubscriptionService = subscriptions - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint allows the creation of coupons, which can then be redeemed at subscription - * creation or plan change. - */ - override fun create(params: CouponCreateParams, requestOptions: RequestOptions): Coupon { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("coupons") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + override fun create(params: CouponCreateParams, requestOptions: RequestOptions): CouponModel = + // post /coupons + withRawResponse().create(params, requestOptions).parse() + + override fun list(params: CouponListParams, requestOptions: RequestOptions): CouponListPage = + // get /coupons + withRawResponse().list(params, requestOptions).parse() + + override fun archive(params: CouponArchiveParams, requestOptions: RequestOptions): CouponModel = + // post /coupons/{coupon_id}/archive + withRawResponse().archive(params, requestOptions).parse() + + override fun fetch(params: CouponFetchParams, requestOptions: RequestOptions): CouponModel = + // get /coupons/{coupon_id} + withRawResponse().fetch(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CouponService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val subscriptions: SubscriptionService.WithRawResponse by lazy { + SubscriptionServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun subscriptions(): SubscriptionService.WithRawResponse = subscriptions + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: CouponCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("coupons") + .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 response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * This endpoint returns a list of all coupons for an account in a list format. - * - * 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. - */ - override fun list(params: CouponListParams, requestOptions: RequestOptions): CouponListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("coupons") - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + override fun list( + params: CouponListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("coupons") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { CouponListPage.of(CouponServiceImpl(clientOptions), params, it) } } - .let { CouponListPage.of(this, params, it) } - } + } + + private val archiveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - private val archiveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint allows a coupon to be archived. Archived coupons can no longer be redeemed, and - * will be hidden from lists of active coupons. Additionally, once a coupon is archived, its - * redemption code can be reused for a different coupon. - */ - override fun archive(params: CouponArchiveParams, requestOptions: RequestOptions): Coupon { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("coupons", params.getPathParam(0), "archive") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { archiveHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + override fun archive( + params: CouponArchiveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("coupons", params.getPathParam(0), "archive") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { archiveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint retrieves a coupon by its ID. To fetch coupons by their redemption code, use - * the [List coupons](list-coupons) endpoint with the redemption_code parameter. - */ - override fun fetch(params: CouponFetchParams, requestOptions: RequestOptions): Coupon { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("coupons", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + override fun fetch( + params: CouponFetchParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("coupons", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { fetchHandler.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 6b4339810..a7d736346 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 @@ -4,21 +4,28 @@ package com.withorb.api.services.blocking +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions -import com.withorb.api.models.CreditNote +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.CreditNoteCreateParams import com.withorb.api.models.CreditNoteFetchParams import com.withorb.api.models.CreditNoteListPage import com.withorb.api.models.CreditNoteListParams +import com.withorb.api.models.CreditNoteModel interface CreditNoteService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** This endpoint is used to create a single [`Credit Note`](/invoicing/credit-notes). */ @JvmOverloads fun create( params: CreditNoteCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CreditNote + ): CreditNoteModel /** * Get a paginated list of CreditNotes. Users can also filter by customer_id, subscription_id, @@ -47,5 +54,50 @@ interface CreditNoteService { fun fetch( params: CreditNoteFetchParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CreditNote + ): CreditNoteModel + + /** A view of [CreditNoteService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /credit_notes`, but is otherwise the same as + * [CreditNoteService.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: CreditNoteCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /credit_notes`, but is otherwise the same as + * [CreditNoteService.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: CreditNoteListParams = CreditNoteListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /credit_notes`, but is otherwise the same as + * [CreditNoteService.list]. + */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(CreditNoteListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /credit_notes/{credit_note_id}`, but is otherwise + * the same as [CreditNoteService.fetch]. + */ + @JvmOverloads + @MustBeClosed + fun fetch( + params: CreditNoteFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } 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 9affdd09c..b3e5d3aaf 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 @@ -10,96 +10,131 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest import com.withorb.api.core.http.HttpResponse.Handler -import com.withorb.api.core.json +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.errors.OrbError -import com.withorb.api.models.CreditNote import com.withorb.api.models.CreditNoteCreateParams import com.withorb.api.models.CreditNoteFetchParams import com.withorb.api.models.CreditNoteListPage import com.withorb.api.models.CreditNoteListParams +import com.withorb.api.models.CreditNoteModel class CreditNoteServiceImpl internal constructor(private val clientOptions: ClientOptions) : CreditNoteService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: CreditNoteService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): CreditNoteService.WithRawResponse = withRawResponse - /** This endpoint is used to create a single [`Credit Note`](/invoicing/credit-notes). */ override fun create( params: CreditNoteCreateParams, requestOptions: RequestOptions, - ): CreditNote { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("credit_notes") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + ): CreditNoteModel = + // post /credit_notes + withRawResponse().create(params, requestOptions).parse() - /** - * Get a paginated list of CreditNotes. Users can also filter by customer_id, subscription_id, - * or external_customer_id. The credit notes will be returned in reverse chronological order by - * `creation_time`. - */ override fun list( params: CreditNoteListParams, requestOptions: RequestOptions, - ): CreditNoteListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("credit_notes") - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): CreditNoteListPage = + // get /credit_notes + withRawResponse().list(params, requestOptions).parse() + + override fun fetch( + params: CreditNoteFetchParams, + requestOptions: RequestOptions, + ): CreditNoteModel = + // get /credit_notes/{credit_note_id} + withRawResponse().fetch(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CreditNoteService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: CreditNoteCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("credit_notes") + .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 response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - .let { CreditNoteListPage.of(this, params, it) } - } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: CreditNoteListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("credit_notes") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { CreditNoteListPage.of(CreditNoteServiceImpl(clientOptions), params, it) } + } + } + + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint is used to fetch a single [`Credit Note`](/invoicing/credit-notes) given an - * identifier. - */ - override fun fetch(params: CreditNoteFetchParams, requestOptions: RequestOptions): CreditNote { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("credit_notes", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + override fun fetch( + params: CreditNoteFetchParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("credit_notes", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } 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 75f3065fb..a23b81780 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 @@ -4,14 +4,17 @@ package com.withorb.api.services.blocking +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions -import com.withorb.api.models.Customer +import com.withorb.api.core.http.HttpResponse +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.CustomerCreateParams import com.withorb.api.models.CustomerDeleteParams import com.withorb.api.models.CustomerFetchByExternalIdParams import com.withorb.api.models.CustomerFetchParams import com.withorb.api.models.CustomerListPage import com.withorb.api.models.CustomerListParams +import com.withorb.api.models.CustomerModel import com.withorb.api.models.CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams import com.withorb.api.models.CustomerSyncPaymentMethodsFromGatewayParams import com.withorb.api.models.CustomerUpdateByExternalIdParams @@ -22,6 +25,11 @@ import com.withorb.api.services.blocking.customers.CreditService interface CustomerService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + fun costs(): CostService fun credits(): CreditService @@ -45,7 +53,7 @@ interface CustomerService { fun create( params: CustomerCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Customer + ): CustomerModel /** * This endpoint can be used to update the `payment_provider`, `payment_provider_id`, `name`, @@ -57,7 +65,7 @@ interface CustomerService { fun update( params: CustomerUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Customer + ): CustomerModel /** * This endpoint returns a list of all customers for an account. The list of customers is @@ -111,7 +119,7 @@ interface CustomerService { fun fetch( params: CustomerFetchParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Customer + ): CustomerModel /** * This endpoint is used to fetch customer details given an `external_customer_id` (see @@ -124,7 +132,7 @@ interface CustomerService { fun fetchByExternalId( params: CustomerFetchByExternalIdParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Customer + ): CustomerModel /** * Sync Orb's payment methods for the customer with their gateway. @@ -163,5 +171,126 @@ interface CustomerService { fun updateByExternalId( params: CustomerUpdateByExternalIdParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Customer + ): CustomerModel + + /** A view of [CustomerService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + fun costs(): CostService.WithRawResponse + + fun credits(): CreditService.WithRawResponse + + fun balanceTransactions(): BalanceTransactionService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /customers`, but is otherwise the same as + * [CustomerService.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: CustomerCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `put /customers/{customer_id}`, but is otherwise the same + * as [CustomerService.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: CustomerUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /customers`, but is otherwise the same as + * [CustomerService.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: CustomerListParams = CustomerListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /customers`, but is otherwise the same as + * [CustomerService.list]. + */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(CustomerListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /customers/{customer_id}`, but is otherwise the + * same as [CustomerService.delete]. + */ + @JvmOverloads + @MustBeClosed + fun delete( + params: CustomerDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** + * Returns a raw HTTP response for `get /customers/{customer_id}`, but is otherwise the same + * as [CustomerService.fetch]. + */ + @JvmOverloads + @MustBeClosed + fun fetch( + params: CustomerFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get + * /customers/external_customer_id/{external_customer_id}`, but is otherwise the same as + * [CustomerService.fetchByExternalId]. + */ + @JvmOverloads + @MustBeClosed + fun fetchByExternalId( + params: CustomerFetchByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post + * /customers/external_customer_id/{external_customer_id}/sync_payment_methods_from_gateway`, + * but is otherwise the same as [CustomerService.syncPaymentMethodsFromGateway]. + */ + @JvmOverloads + @MustBeClosed + fun syncPaymentMethodsFromGateway( + params: CustomerSyncPaymentMethodsFromGatewayParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** + * Returns a raw HTTP response for `post + * /customers/{customer_id}/sync_payment_methods_from_gateway`, but is otherwise the same as + * [CustomerService.syncPaymentMethodsFromGatewayByExternalCustomerId]. + */ + @JvmOverloads + @MustBeClosed + fun syncPaymentMethodsFromGatewayByExternalCustomerId( + params: CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** + * Returns a raw HTTP response for `put + * /customers/external_customer_id/{external_customer_id}`, but is otherwise the same as + * [CustomerService.updateByExternalId]. + */ + @JvmOverloads + @MustBeClosed + fun updateByExternalId( + params: CustomerUpdateByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } 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 bafad84e5..4312c83b8 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 @@ -10,17 +10,20 @@ import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler 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.json +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.errors.OrbError -import com.withorb.api.models.Customer import com.withorb.api.models.CustomerCreateParams import com.withorb.api.models.CustomerDeleteParams import com.withorb.api.models.CustomerFetchByExternalIdParams import com.withorb.api.models.CustomerFetchParams import com.withorb.api.models.CustomerListPage import com.withorb.api.models.CustomerListParams +import com.withorb.api.models.CustomerModel import com.withorb.api.models.CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams import com.withorb.api.models.CustomerSyncPaymentMethodsFromGatewayParams import com.withorb.api.models.CustomerUpdateByExternalIdParams @@ -35,7 +38,9 @@ import com.withorb.api.services.blocking.customers.CreditServiceImpl class CustomerServiceImpl internal constructor(private val clientOptions: ClientOptions) : CustomerService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: CustomerService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } private val costs: CostService by lazy { CostServiceImpl(clientOptions) } @@ -45,278 +50,327 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client BalanceTransactionServiceImpl(clientOptions) } + override fun withRawResponse(): CustomerService.WithRawResponse = withRawResponse + override fun costs(): CostService = costs override fun credits(): CreditService = credits override fun balanceTransactions(): BalanceTransactionService = balanceTransactions - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This operation is used to create an Orb customer, who is party to the core billing - * relationship. See [Customer](/core-concepts##customer) for an overview of the customer - * resource. - * - * This endpoint is critical in the following Orb functionality: - * - Automated charges can be configured by setting `payment_provider` and `payment_provider_id` - * to automatically issue invoices - * - [Customer ID Aliases](/events-and-metrics/customer-aliases) can be configured by setting - * `external_customer_id` - * - [Timezone localization](/essentials/timezones) can be configured on a per-customer basis by - * setting the `timezone` parameter - */ - override fun create(params: CustomerCreateParams, requestOptions: RequestOptions): Customer { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("customers") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } + override fun create( + params: CustomerCreateParams, + requestOptions: RequestOptions, + ): CustomerModel = + // post /customers + withRawResponse().create(params, requestOptions).parse() - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * 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. - */ - override fun update(params: CustomerUpdateParams, requestOptions: RequestOptions): Customer { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("customers", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } + override fun update( + params: CustomerUpdateParams, + requestOptions: RequestOptions, + ): CustomerModel = + // put /customers/{customer_id} + withRawResponse().update(params, requestOptions).parse() - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * This endpoint returns a list of all customers for an account. The list of customers is - * ordered starting from the most recently created customer. This endpoint follows Orb's - * [standardized pagination format](/api-reference/pagination). - * - * See [Customer](/core-concepts##customer) for an overview of the customer model. - */ override fun list( params: CustomerListParams, requestOptions: RequestOptions, - ): CustomerListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("customers") - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - .let { CustomerListPage.of(this, params, it) } - } + ): CustomerListPage = + // get /customers + withRawResponse().list(params, requestOptions).parse() - private val deleteHandler: Handler = emptyHandler().withErrorHandler(errorHandler) - - /** - * This performs a deletion of this customer, its subscriptions, and its invoices, provided the - * customer does not have any issued invoices. Customers with issued invoices cannot be deleted. - * This operation is irreversible. Note that this is a _soft_ deletion, but the data will be - * inaccessible through the API and Orb dashboard. - * - * For a hard-deletion, please reach out to the Orb team directly. - * - * **Note**: This operation happens asynchronously and can be expected to take a few minutes to - * propagate to related resources. However, querying for the customer on subsequent GET requests - * while deletion is in process will reflect its deletion with a `deleted: true` property. Once - * the customer deletion has been fully processed, the customer will not be returned in the API. - * - * On successful processing, this returns an empty dictionary (`{}`) in the API. - */ override fun delete(params: CustomerDeleteParams, requestOptions: RequestOptions) { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("customers", params.getPathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - response.use { deleteHandler.handle(it) } - } - - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint is used to fetch customer details given an identifier. If the `Customer` is in - * the process of being deleted, only the properties `id` and `deleted: true` will be returned. - * - * See the [Customer resource](/core-concepts#customer) for a full discussion of the Customer - * model. - */ - override fun fetch(params: CustomerFetchParams, requestOptions: RequestOptions): Customer { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("customers", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } + // delete /customers/{customer_id} + withRawResponse().delete(params, requestOptions) } - private val fetchByExternalIdHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun fetch(params: CustomerFetchParams, requestOptions: RequestOptions): CustomerModel = + // get /customers/{customer_id} + withRawResponse().fetch(params, requestOptions).parse() - /** - * This endpoint is used to fetch customer details given an `external_customer_id` (see - * [Customer ID Aliases](/events-and-metrics/customer-aliases)). - * - * Note that the resource and semantics of this endpoint exactly mirror - * [Get Customer](fetch-customer). - */ override fun fetchByExternalId( params: CustomerFetchByExternalIdParams, requestOptions: RequestOptions, - ): Customer { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("customers", "external_customer_id", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { fetchByExternalIdHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } + ): CustomerModel = + // get /customers/external_customer_id/{external_customer_id} + withRawResponse().fetchByExternalId(params, requestOptions).parse() - private val syncPaymentMethodsFromGatewayHandler: Handler = - emptyHandler().withErrorHandler(errorHandler) - - /** - * Sync Orb's payment methods for the customer with their gateway. - * - * This method can be called before taking an action that may cause the customer to be charged, - * ensuring that the most up-to-date payment method is charged. - * - * **Note**: This functionality is currently only available for Stripe. - */ override fun syncPaymentMethodsFromGateway( params: CustomerSyncPaymentMethodsFromGatewayParams, requestOptions: RequestOptions, ) { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments( - "customers", - "external_customer_id", - params.getPathParam(0), - "sync_payment_methods_from_gateway", - ) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - response.use { syncPaymentMethodsFromGatewayHandler.handle(it) } + // post + // /customers/external_customer_id/{external_customer_id}/sync_payment_methods_from_gateway + withRawResponse().syncPaymentMethodsFromGateway(params, requestOptions) } - private val syncPaymentMethodsFromGatewayByExternalCustomerIdHandler: Handler = - emptyHandler().withErrorHandler(errorHandler) - - /** - * Sync Orb's payment methods for the customer with their gateway. - * - * This method can be called before taking an action that may cause the customer to be charged, - * ensuring that the most up-to-date payment method is charged. - * - * **Note**: This functionality is currently only available for Stripe. - */ override fun syncPaymentMethodsFromGatewayByExternalCustomerId( params: CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams, requestOptions: RequestOptions, ) { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments( - "customers", - params.getPathParam(0), - "sync_payment_methods_from_gateway", - ) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - response.use { syncPaymentMethodsFromGatewayByExternalCustomerIdHandler.handle(it) } + // post /customers/{customer_id}/sync_payment_methods_from_gateway + withRawResponse().syncPaymentMethodsFromGatewayByExternalCustomerId(params, requestOptions) } - private val updateByExternalIdHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint is used to update customer details given an `external_customer_id` (see - * [Customer ID Aliases](/events-and-metrics/customer-aliases)). Note that the resource and - * semantics of this endpoint exactly mirror [Update Customer](update-customer). - */ override fun updateByExternalId( params: CustomerUpdateByExternalIdParams, requestOptions: RequestOptions, - ): Customer { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("customers", "external_customer_id", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { updateByExternalIdHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): CustomerModel = + // put /customers/external_customer_id/{external_customer_id} + withRawResponse().updateByExternalId(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CustomerService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val costs: CostService.WithRawResponse by lazy { + CostServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val credits: CreditService.WithRawResponse by lazy { + CreditServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val balanceTransactions: BalanceTransactionService.WithRawResponse by lazy { + BalanceTransactionServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun costs(): CostService.WithRawResponse = costs + + override fun credits(): CreditService.WithRawResponse = credits + + override fun balanceTransactions(): BalanceTransactionService.WithRawResponse = + balanceTransactions + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: CustomerCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("customers") + .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 response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: CustomerUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("customers", params.getPathParam(0)) + .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 response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: CustomerListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("customers") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { CustomerListPage.of(CustomerServiceImpl(clientOptions), params, it) } + } + } + + private val deleteHandler: Handler = emptyHandler().withErrorHandler(errorHandler) + + override fun delete( + params: CustomerDeleteParams, + requestOptions: RequestOptions, + ): HttpResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("customers", params.getPathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { response.use { deleteHandler.handle(it) } } + } + + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetch( + params: CustomerFetchParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("customers", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val fetchByExternalIdHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetchByExternalId( + params: CustomerFetchByExternalIdParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("customers", "external_customer_id", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { fetchByExternalIdHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val syncPaymentMethodsFromGatewayHandler: Handler = + emptyHandler().withErrorHandler(errorHandler) + + override fun syncPaymentMethodsFromGateway( + params: CustomerSyncPaymentMethodsFromGatewayParams, + requestOptions: RequestOptions, + ): HttpResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments( + "customers", + "external_customer_id", + params.getPathParam(0), + "sync_payment_methods_from_gateway", + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response.use { syncPaymentMethodsFromGatewayHandler.handle(it) } + } + } + + private val syncPaymentMethodsFromGatewayByExternalCustomerIdHandler: Handler = + emptyHandler().withErrorHandler(errorHandler) + + override fun syncPaymentMethodsFromGatewayByExternalCustomerId( + params: CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams, + requestOptions: RequestOptions, + ): HttpResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments( + "customers", + params.getPathParam(0), + "sync_payment_methods_from_gateway", + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response.use { syncPaymentMethodsFromGatewayByExternalCustomerIdHandler.handle(it) } + } + } + + private val updateByExternalIdHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun updateByExternalId( + params: CustomerUpdateByExternalIdParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("customers", "external_customer_id", params.getPathParam(0)) + .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 response.parseable { + response + .use { updateByExternalIdHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/DimensionalPriceGroupService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/DimensionalPriceGroupService.kt index 3f86e6132..91398e145 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/DimensionalPriceGroupService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/DimensionalPriceGroupService.kt @@ -4,16 +4,23 @@ package com.withorb.api.services.blocking +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions -import com.withorb.api.models.DimensionalPriceGroup +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.DimensionalPriceGroupCreateParams import com.withorb.api.models.DimensionalPriceGroupListPage import com.withorb.api.models.DimensionalPriceGroupListParams +import com.withorb.api.models.DimensionalPriceGroupModel import com.withorb.api.models.DimensionalPriceGroupRetrieveParams import com.withorb.api.services.blocking.dimensionalPriceGroups.ExternalDimensionalPriceGroupIdService interface DimensionalPriceGroupService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + fun externalDimensionalPriceGroupId(): ExternalDimensionalPriceGroupIdService /** @@ -29,14 +36,14 @@ interface DimensionalPriceGroupService { fun create( params: DimensionalPriceGroupCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): DimensionalPriceGroup + ): DimensionalPriceGroupModel /** Fetch dimensional price group */ @JvmOverloads fun retrieve( params: DimensionalPriceGroupRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): DimensionalPriceGroup + ): DimensionalPriceGroupModel /** List dimensional price groups */ @JvmOverloads @@ -48,4 +55,56 @@ interface DimensionalPriceGroupService { /** List dimensional price groups */ fun list(requestOptions: RequestOptions): DimensionalPriceGroupListPage = list(DimensionalPriceGroupListParams.none(), requestOptions) + + /** + * A view of [DimensionalPriceGroupService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + fun externalDimensionalPriceGroupId(): + ExternalDimensionalPriceGroupIdService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /dimensional_price_groups`, but is otherwise the + * same as [DimensionalPriceGroupService.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: DimensionalPriceGroupCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get + * /dimensional_price_groups/{dimensional_price_group_id}`, but is otherwise the same as + * [DimensionalPriceGroupService.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: DimensionalPriceGroupRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /dimensional_price_groups`, but is otherwise the + * same as [DimensionalPriceGroupService.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: DimensionalPriceGroupListParams = DimensionalPriceGroupListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /dimensional_price_groups`, but is otherwise the + * same as [DimensionalPriceGroupService.list]. + */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(DimensionalPriceGroupListParams.none(), requestOptions) + } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/DimensionalPriceGroupServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/DimensionalPriceGroupServiceImpl.kt index 9f2a74185..25d3dde93 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/DimensionalPriceGroupServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/DimensionalPriceGroupServiceImpl.kt @@ -10,13 +10,15 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest import com.withorb.api.core.http.HttpResponse.Handler -import com.withorb.api.core.json +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.errors.OrbError -import com.withorb.api.models.DimensionalPriceGroup import com.withorb.api.models.DimensionalPriceGroupCreateParams import com.withorb.api.models.DimensionalPriceGroupListPage import com.withorb.api.models.DimensionalPriceGroupListParams +import com.withorb.api.models.DimensionalPriceGroupModel import com.withorb.api.models.DimensionalPriceGroupRetrieveParams import com.withorb.api.services.blocking.dimensionalPriceGroups.ExternalDimensionalPriceGroupIdService import com.withorb.api.services.blocking.dimensionalPriceGroups.ExternalDimensionalPriceGroupIdServiceImpl @@ -24,95 +26,140 @@ import com.withorb.api.services.blocking.dimensionalPriceGroups.ExternalDimensio class DimensionalPriceGroupServiceImpl internal constructor(private val clientOptions: ClientOptions) : DimensionalPriceGroupService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: DimensionalPriceGroupService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } private val externalDimensionalPriceGroupId: ExternalDimensionalPriceGroupIdService by lazy { ExternalDimensionalPriceGroupIdServiceImpl(clientOptions) } + override fun withRawResponse(): DimensionalPriceGroupService.WithRawResponse = withRawResponse + override fun externalDimensionalPriceGroupId(): ExternalDimensionalPriceGroupIdService = externalDimensionalPriceGroupId - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * 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. - * - * For example, suppose we have a billable metric that measures the number of widgets used and - * we want to charge differently depending on the color of the widget. We can create a price - * group with a dimension "color" and two prices: one that charges $10 per red widget and one - * that charges $20 per blue widget. - */ override fun create( params: DimensionalPriceGroupCreateParams, requestOptions: RequestOptions, - ): DimensionalPriceGroup { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("dimensional_price_groups") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): DimensionalPriceGroupModel = + // post /dimensional_price_groups + withRawResponse().create(params, requestOptions).parse() - /** Fetch dimensional price group */ override fun retrieve( params: DimensionalPriceGroupRetrieveParams, requestOptions: RequestOptions, - ): DimensionalPriceGroup { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("dimensional_price_groups", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + ): DimensionalPriceGroupModel = + // get /dimensional_price_groups/{dimensional_price_group_id} + withRawResponse().retrieve(params, requestOptions).parse() - /** List dimensional price groups */ override fun list( params: DimensionalPriceGroupListParams, requestOptions: RequestOptions, - ): DimensionalPriceGroupListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("dimensional_price_groups") - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): DimensionalPriceGroupListPage = + // get /dimensional_price_groups + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + DimensionalPriceGroupService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val externalDimensionalPriceGroupId: + ExternalDimensionalPriceGroupIdService.WithRawResponse by lazy { + ExternalDimensionalPriceGroupIdServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun externalDimensionalPriceGroupId(): + ExternalDimensionalPriceGroupIdService.WithRawResponse = externalDimensionalPriceGroupId + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun create( + params: DimensionalPriceGroupCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("dimensional_price_groups") + .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 response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: DimensionalPriceGroupRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("dimensional_price_groups", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: DimensionalPriceGroupListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("dimensional_price_groups") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + DimensionalPriceGroupListPage.of( + DimensionalPriceGroupServiceImpl(clientOptions), + params, + it, + ) + } } - .let { DimensionalPriceGroupListPage.of(this, params, it) } + } } } 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 bcfca46cd..346cd12a5 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 @@ -4,7 +4,9 @@ package com.withorb.api.services.blocking +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.EventDeprecateParams import com.withorb.api.models.EventDeprecateResponse import com.withorb.api.models.EventIngestParams @@ -18,6 +20,11 @@ import com.withorb.api.services.blocking.events.VolumeService interface EventService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + fun backfills(): BackfillService fun volume(): VolumeService @@ -329,4 +336,56 @@ interface EventService { params: EventSearchParams, requestOptions: RequestOptions = RequestOptions.none(), ): EventSearchResponse + + /** A view of [EventService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + fun backfills(): BackfillService.WithRawResponse + + fun volume(): VolumeService.WithRawResponse + + /** + * Returns a raw HTTP response for `put /events/{event_id}`, but is otherwise the same as + * [EventService.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: EventUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `put /events/{event_id}/deprecate`, but is otherwise the + * same as [EventService.deprecate]. + */ + @JvmOverloads + @MustBeClosed + fun deprecate( + params: EventDeprecateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /ingest`, but is otherwise the same as + * [EventService.ingest]. + */ + @JvmOverloads + @MustBeClosed + fun ingest( + params: EventIngestParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /events/search`, but is otherwise the same as + * [EventService.search]. + */ + @JvmOverloads + @MustBeClosed + fun search( + params: EventSearchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } 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 5e34a56f8..87c9d40e7 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 @@ -10,7 +10,9 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest import com.withorb.api.core.http.HttpResponse.Handler -import com.withorb.api.core.json +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.errors.OrbError import com.withorb.api.models.EventDeprecateParams @@ -29,393 +31,175 @@ import com.withorb.api.services.blocking.events.VolumeServiceImpl class EventServiceImpl internal constructor(private val clientOptions: ClientOptions) : EventService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: EventService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } private val backfills: BackfillService by lazy { BackfillServiceImpl(clientOptions) } private val volume: VolumeService by lazy { VolumeServiceImpl(clientOptions) } + override fun withRawResponse(): EventService.WithRawResponse = withRawResponse + override fun backfills(): BackfillService = backfills override fun volume(): VolumeService = volume - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint is used to amend a single usage event with a given `event_id`. `event_id` - * refers to the `idempotency_key` passed in during ingestion. The event will maintain its - * existing `event_id` after the amendment. - * - * This endpoint will mark the existing event as ignored, and Orb will only use the new event - * passed in the body of this request as the source of truth for that `event_id`. Note that a - * single event can be amended any number of times, so the same event can be overwritten in - * subsequent calls to this endpoint. Only a single event with a given `event_id` will be - * considered the source of truth at any given time. - * - * This is a powerful and audit-safe mechanism to retroactively update a single event in cases - * where you need to: - * - update an event with new metadata as you iterate on your pricing model - * - update an event based on the result of an external API call (e.g. call to a payment gateway - * succeeded or failed) - * - * This amendment API is always audit-safe. The process will still retain the original event, - * though it will be ignored for billing calculations. For auditing and data fidelity purposes, - * Orb never overwrites or permanently deletes ingested usage data. - * - * ## Request validation - * - The `timestamp` of the new event must match the `timestamp` of the existing event already - * ingested. As with ingestion, all timestamps must be sent in ISO8601 format with UTC - * timezone offset. - * - The `customer_id` or `external_customer_id` of the new event must match the `customer_id` - * or `external_customer_id` of the existing event already ingested. Exactly one of - * `customer_id` and `external_customer_id` should be specified, and similar to ingestion, the - * ID must identify a Customer resource within Orb. Unlike ingestion, for event amendment, we - * strictly enforce that the Customer must be in the Orb system, even during the initial - * integration period. We do not allow updating the `Customer` an event is associated with. - * - Orb does not accept an `idempotency_key` with the event in this endpoint, since this - * request is by design idempotent. On retryable errors, you should retry the request and - * assume the amendment operation has not succeeded until receipt of a 2xx. - * - The event's `timestamp` must fall within the customer's current subscription's billing - * period, or within the grace period of the customer's current subscription's previous - * billing period. - * - By default, no more than 100 events can be amended for a single customer in a 100 day - * period. For higher volume updates, consider using the [event backfill](create-backfill) - * endpoint. - */ override fun update( params: EventUpdateParams, requestOptions: RequestOptions, - ): EventUpdateResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("events", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - - private val deprecateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): EventUpdateResponse = + // put /events/{event_id} + withRawResponse().update(params, requestOptions).parse() - /** - * This endpoint is used to deprecate a single usage event with a given `event_id`. `event_id` - * refers to the `idempotency_key` passed in during ingestion. - * - * This endpoint will mark the existing event as ignored. Note that if you attempt to re-ingest - * an event with the same `event_id` as a deprecated event, Orb will return an error. - * - * This is a powerful and audit-safe mechanism to retroactively deprecate a single event in - * cases where you need to: - * - no longer bill for an event that was improperly reported - * - no longer bill for an event based on the result of an external API call (e.g. call to a - * payment gateway failed and the user should not be billed) - * - * If you want to only change specific properties of an event, but keep the event as part of the - * billing calculation, use the [Amend event](amend-event) endpoint instead. - * - * This API is always audit-safe. The process will still retain the deprecated event, though it - * will be ignored for billing calculations. For auditing and data fidelity purposes, Orb never - * overwrites or permanently deletes ingested usage data. - * - * ## Request validation - * - Orb does not accept an `idempotency_key` with the event in this endpoint, since this - * request is by design idempotent. On retryable errors, you should retry the request and - * assume the deprecation operation has not succeeded until receipt of a 2xx. - * - The event's `timestamp` must fall within the customer's current subscription's billing - * period, or within the grace period of the customer's current subscription's previous - * billing period. Orb does not allow deprecating events for billing periods that have already - * invoiced customers. - * - The `customer_id` or the `external_customer_id` of the original event ingestion request - * must identify a Customer resource within Orb, even if this event was ingested during the - * initial integration period. We do not allow deprecating events for customers not in the Orb - * system. - * - By default, no more than 100 events can be deprecated for a single customer in a 100 day - * period. For higher volume updates, consider using the [event backfill](create-backfill) - * endpoint. - */ override fun deprecate( params: EventDeprecateParams, requestOptions: RequestOptions, - ): EventDeprecateResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("events", params.getPathParam(0), "deprecate") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { deprecateHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } + ): EventDeprecateResponse = + // put /events/{event_id}/deprecate + withRawResponse().deprecate(params, requestOptions).parse() - private val ingestHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * Orb's event ingestion model and API is designed around two core principles: - * 1. **Data fidelity**: The accuracy of your billing model depends on a robust foundation of - * events. Orb's API protocol encourages usage patterns that ensure that your data is - * consistently complete and correct. - * 2. **Fast integration**: Sending events into Orb requires no tedious setup steps or explicit - * field schema for your event shape, making it instant to start streaming in usage in - * real-time. - * - * ## Event shape - * - * Events are the starting point for all usage calculations in the system, and are simple at - * their core: - * ```ts - * { - * // customer_id and external_customer_id are used to - * // attribute usage to a given Customer. Exactly one of these - * // should be specified in a given ingestion event. - * - * // `customer_id` is the Orb generated identifier for the Customer, - * // which is returned from the Create customer API call. - * customer_id: string, - * - * // external_customer_id is an alternate identifier which is associated - * // with a Customer at creation time. This is treated as an alias for - * // customer_id, and is usually set to an identifier native to your system. - * external_customer_id: string, - * - * // A string name identifying the event, usually a usage - * // action. By convention, this should not contain any whitespace. - * event_name: string, - * - * // An ISO 8601 format date with no timezone offset. - * // This should represent the time that usage occurred - * // and is important to attribute usage to a given - * // billing period. See the notes below on determining the timestamp. - * // e.g. 2020-12-09T16:09:53Z - * timestamp: string, - * - * // A unique value, generated by the client, that is - * // used to de-duplicate events. - * // Exactly one event with a given - * // idempotency key will be ingested, which allows for - * // safe request retries. - * idempotency_key: string - * - * // Optional custom metadata to attach to the event. - * // This might include a numeric value used for aggregation, - * // or a string/boolean value used for filtering. - * // The schema of this dictionary need not be pre-declared, and - * // properties can be added at any time. - * properties: { - * [key: string]?: string | number | boolean, - * }, - * } - * ``` - * - * ## Required fields - * - * Because events streamed to Orb are meant to be as flexible as possible, there are only a few - * required fields in every event. - * - We recommend that `idempotency_key` are unique strings that you generated with V4 UUIDs, - * but only require that they uniquely identify an event (i.e. don’t collide). - * - The `timestamp` field in the event body will be used to determine which billable period a - * given event falls into. For example, with a monthly billing cycle starting from the first - * of December, Orb will calculate metrics based on events that fall into the range `12-01 - * 00:00:00 <= timestamp < 01-01 00:00:00`. - * - * ## Logging metadata - * - * Orb allows tagging events with metadata using a flexible properties dictionary. Since Orb - * does not enforce a rigid schema for this field-set, key-value pairs can be added dynamically - * as your events evolve. - * - * This dictionary can be helpful for a wide variety of use cases: - * - Numeric properties on events like `compute_time_ms` can later be inputs to our flexible - * query engine to determine usage. - * - Logging a region or cluster with each event can help you provide customers more granular - * visibility into their usage. - * - If you are using matrix pricing and matching a matrix price key with a property, you should - * ensure the value for that property is sent as a string. - * - * We encourage logging this metadata with an eye towards future use cases to ensure full - * coverage for historical data. The datatype of the value in the properties dictionary is - * important for metric creation from an event source. Values that you wish to numerically - * aggregate should be of numeric type in the event. - * - * ## Determining event timestamp - * - * For cases where usage is being reported in real time as it is occurring, timestamp should - * correspond to the time that usage occurred. - * - * In cases where usage is reported in aggregate for a historical timeframe at a regular - * interval, we recommend setting the event `timestamp` to the midpoint of the interval. As an - * example, if you have an hourly reporter that sends data once an hour for the previous hour of - * usage, setting the `timestamp` to the half-hour mark will ensure that the usage is counted - * within the correct period. - * - * Note that other time-related fields (e.g. time elapsed) can be added to the properties - * dictionary as necessary. - * - * In cases where usage is reported in aggregate for a historical timeframe, the timestamp must - * be within the grace period set for your account. Events with `timestamp < current_time - - * grace_period` will not be accepted as a valid event, and will throw validation errors. - * Enforcing the grace period enables Orb to accurately map usage to the correct billing cycle - * and ensure that all usage is billed for in the corresponding billing period. - * - * In general, Orb does not expect events with future dated timestamps. In cases where the - * timestamp is at least 24 hours ahead of the current time, the event will not be accepted as a - * valid event, and will throw validation errors. - * - * ## Event validation - * - * Orb’s validation ensures that you recognize errors in your events as quickly as possible, and - * the API provides informative error messages to help you fix problems quickly. - * - * We validate the following: - * - Exactly one of `customer_id` and `external_customer_id` should be specified. - * - If the `customer_id` is specified, the customer in Orb must exist. - * - If the `external_customer_id` is specified, the customer in Orb does not need to exist. - * Events will be attributed to any future customers with the `external_customer_id` on - * subscription creation. - * - `timestamp` must conform to ISO 8601 and represent a timestamp at most 1 hour in the - * future. This timestamp should be sent in UTC timezone (no timezone offset). - * - * ## Idempotency and retry semantics - * - * Orb's idempotency guarantees allow you to implement safe retry logic in the event of network - * or machine failures, ensuring data fidelity. Each event in the request payload is associated - * with an idempotency key, and Orb guarantees that a single idempotency key will be - * successfully ingested at most once. Note that when Orb encounters events with duplicate - * idempotency keys and differing event bodies in a batch of events, the entire batch will be - * rejected. - * - Successful responses return a 200 HTTP status code. The response contains information about - * previously processed events. - * - Requests that return a `4xx` HTTP status code indicate a payload error and contain at least - * one event with a validation failure. An event with a validation failure can be re-sent to - * the ingestion endpoint (after the payload is fixed) with the original idempotency key since - * that key is not marked as processed. - * - Requests that return a `5xx` HTTP status code indicate a server-side failure. These - * requests should be retried in their entirety. - * - * ## API usage and limits - * - * The ingestion API is designed made for real-time streaming ingestion and architected for high - * throughput. Even if events are later deemed unnecessary or filtered out, we encourage you to - * log them to Orb if they may be relevant to billing calculations in the future. - * - * To take advantage of the real-time features of the Orb platform and avoid any chance of - * dropped events by producers, we recommend reporting events to Orb frequently. Optionally, - * events can also be briefly aggregated at the source, as this API accepts an array of event - * bodies. - * - * Orb does not currently enforce a hard rate-limit for API usage or a maximum request payload - * size, but please give us a heads up if you’re changing either of these factors by an order of - * magnitude from initial setup. - * - * ## Testing in debug mode - * - * The ingestion API supports a debug mode, which returns additional verbose output to indicate - * which event idempotency keys were newly ingested or duplicates from previous requests. To - * enable this mode, mark `debug=true` as a query parameter. - * - * If `debug=true` is not specified, the response will only contain `validation_failed`. Orb - * will still honor the idempotency guarantees set - * [here](/events-and-metrics/event-ingestion#event-volume-and-concurrency) in all cases. - * - * We strongly recommend that you only use debug mode as part of testing your initial Orb - * integration. Once you're ready to switch to production, disable debug mode to take advantage - * of improved performance and maximal throughput. - * - * #### Example: ingestion response with `debug=true` - * - * ```json - * { - * "debug": { - * "duplicate": [], - * "ingested": ["B7E83HDMfJPAunXW", "SJs5DQJ3TnwSqEZE", "8SivfDsNKwCeAXim"] - * }, - * "validation_failed": [] - * } - * ``` - * - * #### Example: ingestion response with `debug=false` - * - * ```json - * { - * "validation_failed": [] - * } - * ``` - */ override fun ingest( params: EventIngestParams, requestOptions: RequestOptions, - ): EventIngestResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("ingest") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { ingestHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - - private val searchHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): EventIngestResponse = + // post /ingest + withRawResponse().ingest(params, requestOptions).parse() - /** - * This endpoint returns a filtered set of events for an account in a - * [paginated list format](/api-reference/pagination). - * - * Note that this is a `POST` endpoint rather than a `GET` endpoint because it employs a JSON - * body for search criteria rather than query parameters, allowing for a more flexible search - * syntax. - * - * Note that a search criteria _must_ be specified. Currently, Orb supports the following - * criteria: - * - `event_ids`: This is an explicit array of IDs to filter by. Note that an event's ID is the - * `idempotency_key` that was originally used for ingestion. - * - * By default, Orb will not throw a `404` if no events matched, Orb will return an empty array - * for `data` instead. - */ override fun search( params: EventSearchParams, requestOptions: RequestOptions, - ): EventSearchResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("events", "search") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { searchHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): EventSearchResponse = + // post /events/search + withRawResponse().search(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + EventService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val backfills: BackfillService.WithRawResponse by lazy { + BackfillServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val volume: VolumeService.WithRawResponse by lazy { + VolumeServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun backfills(): BackfillService.WithRawResponse = backfills + + override fun volume(): VolumeService.WithRawResponse = volume + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun update( + params: EventUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("events", params.getPathParam(0)) + .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 response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val deprecateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun deprecate( + params: EventDeprecateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("events", params.getPathParam(0), "deprecate") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { deprecateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val ingestHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun ingest( + params: EventIngestParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("ingest") + .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 response.parseable { + response + .use { ingestHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val searchHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun search( + params: EventSearchParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("events", "search") + .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 response.parseable { + response + .use { searchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } 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 6ad07bb10..9c18d7b61 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 @@ -4,12 +4,19 @@ package com.withorb.api.services.blocking +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.InvoiceLineItemCreateParams -import com.withorb.api.models.InvoiceLineItemCreateResponse +import com.withorb.api.models.InvoiceLineItemModel interface InvoiceLineItemService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * This creates a one-off fixed fee invoice line item on an Invoice. This can only be done for * invoices that are in a `draft` status. @@ -18,5 +25,23 @@ interface InvoiceLineItemService { fun create( params: InvoiceLineItemCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): InvoiceLineItemCreateResponse + ): InvoiceLineItemModel + + /** + * A view of [InvoiceLineItemService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /invoice_line_items`, but is otherwise the same as + * [InvoiceLineItemService.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: InvoiceLineItemCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } 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 f42976fec..1fe275702 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 @@ -10,43 +10,61 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest import com.withorb.api.core.http.HttpResponse.Handler -import com.withorb.api.core.json +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.errors.OrbError import com.withorb.api.models.InvoiceLineItemCreateParams -import com.withorb.api.models.InvoiceLineItemCreateResponse +import com.withorb.api.models.InvoiceLineItemModel class InvoiceLineItemServiceImpl internal constructor(private val clientOptions: ClientOptions) : InvoiceLineItemService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: InvoiceLineItemService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): InvoiceLineItemService.WithRawResponse = withRawResponse - /** - * This creates a one-off fixed fee invoice line item on an Invoice. This can only be done for - * invoices that are in a `draft` status. - */ override fun create( params: InvoiceLineItemCreateParams, requestOptions: RequestOptions, - ): InvoiceLineItemCreateResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("invoice_line_items") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): InvoiceLineItemModel = + // post /invoice_line_items + withRawResponse().create(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + InvoiceLineItemService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun create( + params: InvoiceLineItemCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("invoice_line_items") + .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 response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } 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 7996f1bb6..bb37a4b0e 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 @@ -4,8 +4,9 @@ package com.withorb.api.services.blocking +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions -import com.withorb.api.models.Invoice +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.InvoiceCreateParams import com.withorb.api.models.InvoiceFetchParams import com.withorb.api.models.InvoiceFetchUpcomingParams @@ -14,18 +15,24 @@ import com.withorb.api.models.InvoiceIssueParams import com.withorb.api.models.InvoiceListPage import com.withorb.api.models.InvoiceListParams import com.withorb.api.models.InvoiceMarkPaidParams +import com.withorb.api.models.InvoiceModel import com.withorb.api.models.InvoicePayParams import com.withorb.api.models.InvoiceUpdateParams import com.withorb.api.models.InvoiceVoidInvoiceParams interface InvoiceService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** This endpoint is used to create a one-off invoice for a customer. */ @JvmOverloads fun create( params: InvoiceCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Invoice + ): InvoiceModel /** * This endpoint allows you to update the `metadata` property on an invoice. If you pass null @@ -37,7 +44,7 @@ interface InvoiceService { fun update( params: InvoiceUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Invoice + ): InvoiceModel /** * This endpoint returns a list of all [`Invoice`](/core-concepts#invoice)s for an account in a @@ -83,7 +90,7 @@ interface InvoiceService { fun fetch( params: InvoiceFetchParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Invoice + ): InvoiceModel /** * This endpoint can be used to fetch the upcoming [invoice](/core-concepts#invoice) for the @@ -106,7 +113,7 @@ interface InvoiceService { fun issue( params: InvoiceIssueParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Invoice + ): InvoiceModel /** * This endpoint allows an invoice's status to be set the `paid` status. This can only be done @@ -116,7 +123,7 @@ interface InvoiceService { fun markPaid( params: InvoiceMarkPaidParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Invoice + ): InvoiceModel /** * This endpoint collects payment for an invoice using the customer's default payment method. @@ -126,7 +133,7 @@ interface InvoiceService { fun pay( params: InvoicePayParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Invoice + ): InvoiceModel /** * This endpoint allows an invoice's status to be set the `void` status. This can only be done @@ -144,5 +151,116 @@ interface InvoiceService { fun voidInvoice( params: InvoiceVoidInvoiceParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Invoice + ): InvoiceModel + + /** A view of [InvoiceService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /invoices`, but is otherwise the same as + * [InvoiceService.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: InvoiceCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `put /invoices/{invoice_id}`, but is otherwise the same + * as [InvoiceService.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: InvoiceUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /invoices`, but is otherwise the same as + * [InvoiceService.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: InvoiceListParams = InvoiceListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /invoices`, but is otherwise the same as + * [InvoiceService.list]. + */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(InvoiceListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /invoices/{invoice_id}`, but is otherwise the same + * as [InvoiceService.fetch]. + */ + @JvmOverloads + @MustBeClosed + fun fetch( + params: InvoiceFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /invoices/upcoming`, but is otherwise the same as + * [InvoiceService.fetchUpcoming]. + */ + @JvmOverloads + @MustBeClosed + fun fetchUpcoming( + params: InvoiceFetchUpcomingParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /invoices/{invoice_id}/issue`, but is otherwise the + * same as [InvoiceService.issue]. + */ + @JvmOverloads + @MustBeClosed + fun issue( + params: InvoiceIssueParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /invoices/{invoice_id}/mark_paid`, but is otherwise + * the same as [InvoiceService.markPaid]. + */ + @JvmOverloads + @MustBeClosed + fun markPaid( + params: InvoiceMarkPaidParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /invoices/{invoice_id}/pay`, but is otherwise the + * same as [InvoiceService.pay]. + */ + @JvmOverloads + @MustBeClosed + fun pay( + params: InvoicePayParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /invoices/{invoice_id}/void`, but is otherwise the + * same as [InvoiceService.voidInvoice]. + */ + @JvmOverloads + @MustBeClosed + fun voidInvoice( + params: InvoiceVoidInvoiceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } 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 926b7b18d..552000e35 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 @@ -10,10 +10,11 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest import com.withorb.api.core.http.HttpResponse.Handler -import com.withorb.api.core.json +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.errors.OrbError -import com.withorb.api.models.Invoice import com.withorb.api.models.InvoiceCreateParams import com.withorb.api.models.InvoiceFetchParams import com.withorb.api.models.InvoiceFetchUpcomingParams @@ -22,6 +23,7 @@ import com.withorb.api.models.InvoiceIssueParams import com.withorb.api.models.InvoiceListPage import com.withorb.api.models.InvoiceListParams import com.withorb.api.models.InvoiceMarkPaidParams +import com.withorb.api.models.InvoiceModel import com.withorb.api.models.InvoicePayParams import com.withorb.api.models.InvoiceUpdateParams import com.withorb.api.models.InvoiceVoidInvoiceParams @@ -29,255 +31,303 @@ import com.withorb.api.models.InvoiceVoidInvoiceParams class InvoiceServiceImpl internal constructor(private val clientOptions: ClientOptions) : InvoiceService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** This endpoint is used to create a one-off invoice for a customer. */ - override fun create(params: InvoiceCreateParams, requestOptions: RequestOptions): Invoice { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("invoices") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } + private val withRawResponse: InvoiceService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint allows you to update the `metadata` property 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. - */ - override fun update(params: InvoiceUpdateParams, requestOptions: RequestOptions): Invoice { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("invoices", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } + override fun withRawResponse(): InvoiceService.WithRawResponse = withRawResponse - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * This endpoint returns a list of all [`Invoice`](/core-concepts#invoice)s for an account in a - * list format. - * - * The list of invoices is ordered starting from the most recently issued invoice date. The - * response also includes [`pagination_metadata`](/api-reference/pagination), which lets the - * caller retrieve the next page of results if they exist. - * - * By default, this only returns invoices that are `issued`, `paid`, or `synced`. - * - * 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. - */ - override fun list(params: InvoiceListParams, requestOptions: RequestOptions): InvoiceListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("invoices") - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - .let { InvoiceListPage.of(this, params, it) } - } + override fun create(params: InvoiceCreateParams, requestOptions: RequestOptions): InvoiceModel = + // post /invoices + withRawResponse().create(params, requestOptions).parse() - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint is used to fetch an [`Invoice`](/core-concepts#invoice) given an identifier. - */ - override fun fetch(params: InvoiceFetchParams, requestOptions: RequestOptions): Invoice { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("invoices", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } + override fun update(params: InvoiceUpdateParams, requestOptions: RequestOptions): InvoiceModel = + // put /invoices/{invoice_id} + withRawResponse().update(params, requestOptions).parse() + + override fun list(params: InvoiceListParams, requestOptions: RequestOptions): InvoiceListPage = + // get /invoices + withRawResponse().list(params, requestOptions).parse() - private val fetchUpcomingHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun fetch(params: InvoiceFetchParams, requestOptions: RequestOptions): InvoiceModel = + // get /invoices/{invoice_id} + withRawResponse().fetch(params, requestOptions).parse() - /** - * This endpoint can be used to fetch the upcoming [invoice](/core-concepts#invoice) for the - * current billing period given a subscription. - */ override fun fetchUpcoming( params: InvoiceFetchUpcomingParams, requestOptions: RequestOptions, - ): InvoiceFetchUpcomingResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("invoices", "upcoming") - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { fetchUpcomingHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): InvoiceFetchUpcomingResponse = + // get /invoices/upcoming + withRawResponse().fetchUpcoming(params, requestOptions).parse() + + override fun issue(params: InvoiceIssueParams, requestOptions: RequestOptions): InvoiceModel = + // post /invoices/{invoice_id}/issue + withRawResponse().issue(params, requestOptions).parse() + + override fun markPaid( + params: InvoiceMarkPaidParams, + requestOptions: RequestOptions, + ): InvoiceModel = + // post /invoices/{invoice_id}/mark_paid + withRawResponse().markPaid(params, requestOptions).parse() + + override fun pay(params: InvoicePayParams, requestOptions: RequestOptions): InvoiceModel = + // post /invoices/{invoice_id}/pay + withRawResponse().pay(params, requestOptions).parse() + + override fun voidInvoice( + params: InvoiceVoidInvoiceParams, + requestOptions: RequestOptions, + ): InvoiceModel = + // post /invoices/{invoice_id}/void + withRawResponse().voidInvoice(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + InvoiceService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: InvoiceCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("invoices") + .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 response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - private val issueHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * 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). - */ - override fun issue(params: InvoiceIssueParams, requestOptions: RequestOptions): Invoice { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("invoices", params.getPathParam(0), "issue") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { issueHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + override fun update( + params: InvoiceUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("invoices", params.getPathParam(0)) + .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 response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) - private val markPaidHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint allows an invoice's status to be set the `paid` status. This can only be done - * to invoices that are in the `issued` status. - */ - override fun markPaid(params: InvoiceMarkPaidParams, requestOptions: RequestOptions): Invoice { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("invoices", params.getPathParam(0), "mark_paid") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { markPaidHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + override fun list( + params: InvoiceListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("invoices") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { InvoiceListPage.of(InvoiceServiceImpl(clientOptions), params, it) } } - } + } - private val payHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * 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". - */ - override fun pay(params: InvoicePayParams, requestOptions: RequestOptions): Invoice { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("invoices", params.getPathParam(0), "pay") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { payHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetch( + params: InvoiceFetchParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("invoices", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } - private val voidInvoiceHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint allows an invoice's status to be set the `void` status. This can only be done - * to invoices that are in the `issued` status. - * - * If the associated invoice has used the customer balance to change the amount due, the - * customer balance operation will be reverted. For example, if the invoice used $10 of customer - * balance, that amount will be added back to the customer balance upon voiding. - * - * If the invoice was used to purchase a credit block, but the invoice is not yet paid, the - * credit block will be voided. If the invoice was created due to a top-up, the top-up will be - * disabled. - */ - override fun voidInvoice( - params: InvoiceVoidInvoiceParams, - requestOptions: RequestOptions, - ): Invoice { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("invoices", params.getPathParam(0), "void") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { voidInvoiceHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + private val fetchUpcomingHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun fetchUpcoming( + params: InvoiceFetchUpcomingParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("invoices", "upcoming") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { fetchUpcomingHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val issueHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun issue( + params: InvoiceIssueParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("invoices", params.getPathParam(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 response.parseable { + response + .use { issueHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val markPaidHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun markPaid( + params: InvoiceMarkPaidParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("invoices", params.getPathParam(0), "mark_paid") + .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 response.parseable { + response + .use { markPaidHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val payHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun pay( + params: InvoicePayParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("invoices", params.getPathParam(0), "pay") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { payHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val voidInvoiceHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun voidInvoice( + params: InvoiceVoidInvoiceParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("invoices", params.getPathParam(0), "void") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { voidInvoiceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } 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 0be9fd5f2..b08f0cea1 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 @@ -4,29 +4,36 @@ package com.withorb.api.services.blocking +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions -import com.withorb.api.models.Item +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.ItemCreateParams import com.withorb.api.models.ItemFetchParams import com.withorb.api.models.ItemListPage import com.withorb.api.models.ItemListParams +import com.withorb.api.models.ItemModel import com.withorb.api.models.ItemUpdateParams interface ItemService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** This endpoint is used to create an [Item](/core-concepts#item). */ @JvmOverloads fun create( params: ItemCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Item + ): ItemModel /** This endpoint can be used to update properties on the Item. */ @JvmOverloads fun update( params: ItemUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Item + ): ItemModel /** This endpoint returns a list of all Items, ordered in descending order by creation time. */ @JvmOverloads @@ -41,5 +48,64 @@ interface ItemService { /** This endpoint returns an item identified by its item_id. */ @JvmOverloads - fun fetch(params: ItemFetchParams, requestOptions: RequestOptions = RequestOptions.none()): Item + fun fetch( + params: ItemFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ItemModel + + /** A view of [ItemService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /items`, but is otherwise the same as + * [ItemService.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: ItemCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `put /items/{item_id}`, but is otherwise the same as + * [ItemService.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: ItemUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /items`, but is otherwise the same as + * [ItemService.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: ItemListParams = ItemListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /items`, but is otherwise the same as + * [ItemService.list]. + */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(ItemListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /items/{item_id}`, but is otherwise the same as + * [ItemService.fetch]. + */ + @JvmOverloads + @MustBeClosed + fun fetch( + params: ItemFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } 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 0f2a98980..81b9f4668 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 @@ -10,104 +10,153 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest import com.withorb.api.core.http.HttpResponse.Handler -import com.withorb.api.core.json +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.errors.OrbError -import com.withorb.api.models.Item import com.withorb.api.models.ItemCreateParams import com.withorb.api.models.ItemFetchParams import com.withorb.api.models.ItemListPage import com.withorb.api.models.ItemListParams +import com.withorb.api.models.ItemModel import com.withorb.api.models.ItemUpdateParams class ItemServiceImpl internal constructor(private val clientOptions: ClientOptions) : ItemService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** This endpoint is used to create an [Item](/core-concepts#item). */ - override fun create(params: ItemCreateParams, requestOptions: RequestOptions): Item { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("items") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } + private val withRawResponse: ItemService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** This endpoint can be used to update properties on the Item. */ - override fun update(params: ItemUpdateParams, requestOptions: RequestOptions): Item { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("items", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + override fun withRawResponse(): ItemService.WithRawResponse = withRawResponse + + override fun create(params: ItemCreateParams, requestOptions: RequestOptions): ItemModel = + // post /items + withRawResponse().create(params, requestOptions).parse() + + override fun update(params: ItemUpdateParams, requestOptions: RequestOptions): ItemModel = + // put /items/{item_id} + withRawResponse().update(params, requestOptions).parse() + + override fun list(params: ItemListParams, requestOptions: RequestOptions): ItemListPage = + // get /items + withRawResponse().list(params, requestOptions).parse() + + override fun fetch(params: ItemFetchParams, requestOptions: RequestOptions): ItemModel = + // get /items/{item_id} + withRawResponse().fetch(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ItemService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: ItemCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("items") + .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 response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** This endpoint returns a list of all Items, ordered in descending order by creation time. */ - override fun list(params: ItemListParams, requestOptions: RequestOptions): ItemListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("items") - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: ItemUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("items", params.getPathParam(0)) + .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 response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - .let { ItemListPage.of(this, params, it) } - } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: ItemListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("items") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { ItemListPage.of(ItemServiceImpl(clientOptions), params, it) } + } + } + + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** This endpoint returns an item identified by its item_id. */ - override fun fetch(params: ItemFetchParams, requestOptions: RequestOptions): Item { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("items", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + override fun fetch( + params: ItemFetchParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("items", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } 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 4ac52d0c2..9e3ca7778 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 @@ -4,8 +4,10 @@ package com.withorb.api.services.blocking +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions -import com.withorb.api.models.BillableMetric +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.BillableMetricModel import com.withorb.api.models.MetricCreateParams import com.withorb.api.models.MetricFetchParams import com.withorb.api.models.MetricListPage @@ -14,6 +16,11 @@ import com.withorb.api.models.MetricUpdateParams interface MetricService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * This endpoint is used to create a [metric](/core-concepts###metric) using a SQL string. See * [SQL support](/extensibility/advanced-metrics#sql-support) for a description of constructing @@ -23,7 +30,7 @@ interface MetricService { fun create( params: MetricCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): BillableMetric + ): BillableMetricModel /** * This endpoint allows you to update the `metadata` property on a metric. If you pass `null` @@ -33,7 +40,7 @@ interface MetricService { fun update( params: MetricUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): BillableMetric + ): BillableMetricModel /** * This endpoint is used to fetch [metric](/core-concepts##metric) details given a metric @@ -62,5 +69,61 @@ interface MetricService { fun fetch( params: MetricFetchParams, requestOptions: RequestOptions = RequestOptions.none(), - ): BillableMetric + ): BillableMetricModel + + /** A view of [MetricService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /metrics`, but is otherwise the same as + * [MetricService.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: MetricCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `put /metrics/{metric_id}`, but is otherwise the same as + * [MetricService.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: MetricUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /metrics`, but is otherwise the same as + * [MetricService.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: MetricListParams = MetricListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /metrics`, but is otherwise the same as + * [MetricService.list]. + */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(MetricListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /metrics/{metric_id}`, but is otherwise the same as + * [MetricService.fetch]. + */ + @JvmOverloads + @MustBeClosed + fun fetch( + params: MetricFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } 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 b9fe248fb..efbc2d560 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 @@ -10,10 +10,12 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest import com.withorb.api.core.http.HttpResponse.Handler -import com.withorb.api.core.json +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.errors.OrbError -import com.withorb.api.models.BillableMetric +import com.withorb.api.models.BillableMetricModel import com.withorb.api.models.MetricCreateParams import com.withorb.api.models.MetricFetchParams import com.withorb.api.models.MetricListPage @@ -23,113 +25,151 @@ import com.withorb.api.models.MetricUpdateParams class MetricServiceImpl internal constructor(private val clientOptions: ClientOptions) : MetricService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: MetricService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): MetricService.WithRawResponse = withRawResponse - /** - * This endpoint is used to create a [metric](/core-concepts###metric) using a SQL string. See - * [SQL support](/extensibility/advanced-metrics#sql-support) for a description of constructing - * SQL queries with examples. - */ override fun create( params: MetricCreateParams, requestOptions: RequestOptions, - ): BillableMetric { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("metrics") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } + ): BillableMetricModel = + // post /metrics + withRawResponse().create(params, requestOptions).parse() - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint allows you to update the `metadata` property on a metric. If you pass `null` - * for the metadata value, it will clear any existing metadata for that invoice. - */ override fun update( params: MetricUpdateParams, requestOptions: RequestOptions, - ): BillableMetric { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("metrics", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): BillableMetricModel = + // put /metrics/{metric_id} + withRawResponse().update(params, requestOptions).parse() + + override fun list(params: MetricListParams, requestOptions: RequestOptions): MetricListPage = + // get /metrics + withRawResponse().list(params, requestOptions).parse() + + override fun fetch( + params: MetricFetchParams, + requestOptions: RequestOptions, + ): BillableMetricModel = + // get /metrics/{metric_id} + withRawResponse().fetch(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + MetricService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun create( + params: MetricCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("metrics") + .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 response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * 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. - */ - override fun list(params: MetricListParams, requestOptions: RequestOptions): MetricListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("metrics") - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun update( + params: MetricUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("metrics", params.getPathParam(0)) + .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 response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - .let { MetricListPage.of(this, params, it) } - } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: MetricListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("metrics") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { MetricListPage.of(MetricServiceImpl(clientOptions), params, it) } + } + } + + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint is used to list [metrics](/core-concepts#metric). It returns information about - * the metrics including its name, description, and item. - */ - override fun fetch(params: MetricFetchParams, requestOptions: RequestOptions): BillableMetric { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("metrics", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + override fun fetch( + params: MetricFetchParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("metrics", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } 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 2008c4558..afa4a0f6e 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 @@ -4,17 +4,24 @@ package com.withorb.api.services.blocking +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions -import com.withorb.api.models.Plan +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.PlanCreateParams import com.withorb.api.models.PlanFetchParams import com.withorb.api.models.PlanListPage import com.withorb.api.models.PlanListParams +import com.withorb.api.models.PlanModel import com.withorb.api.models.PlanUpdateParams import com.withorb.api.services.blocking.plans.ExternalPlanIdService interface PlanService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + fun externalPlanId(): ExternalPlanIdService /** This endpoint allows creation of plans including their prices. */ @@ -22,7 +29,7 @@ interface PlanService { fun create( params: PlanCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Plan + ): PlanModel /** * This endpoint can be used to update the `external_plan_id`, and `metadata` of an existing @@ -34,7 +41,7 @@ interface PlanService { fun update( params: PlanUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Plan + ): PlanModel /** * This endpoint returns a list of all [plans](/core-concepts#plan-and-price) for an account in @@ -76,5 +83,66 @@ interface PlanService { * prices refer to all prices across all phases. */ @JvmOverloads - fun fetch(params: PlanFetchParams, requestOptions: RequestOptions = RequestOptions.none()): Plan + fun fetch( + params: PlanFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): PlanModel + + /** A view of [PlanService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + fun externalPlanId(): ExternalPlanIdService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /plans`, but is otherwise the same as + * [PlanService.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: PlanCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `put /plans/{plan_id}`, but is otherwise the same as + * [PlanService.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: PlanUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /plans`, but is otherwise the same as + * [PlanService.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: PlanListParams = PlanListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /plans`, but is otherwise the same as + * [PlanService.list]. + */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(PlanListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /plans/{plan_id}`, but is otherwise the same as + * [PlanService.fetch]. + */ + @JvmOverloads + @MustBeClosed + fun fetch( + params: PlanFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } 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 f5fd96a86..11d03a963 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 @@ -10,139 +10,167 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest import com.withorb.api.core.http.HttpResponse.Handler -import com.withorb.api.core.json +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.errors.OrbError -import com.withorb.api.models.Plan import com.withorb.api.models.PlanCreateParams import com.withorb.api.models.PlanFetchParams import com.withorb.api.models.PlanListPage import com.withorb.api.models.PlanListParams +import com.withorb.api.models.PlanModel import com.withorb.api.models.PlanUpdateParams import com.withorb.api.services.blocking.plans.ExternalPlanIdService import com.withorb.api.services.blocking.plans.ExternalPlanIdServiceImpl class PlanServiceImpl internal constructor(private val clientOptions: ClientOptions) : PlanService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: PlanService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } private val externalPlanId: ExternalPlanIdService by lazy { ExternalPlanIdServiceImpl(clientOptions) } + override fun withRawResponse(): PlanService.WithRawResponse = withRawResponse + override fun externalPlanId(): ExternalPlanIdService = externalPlanId - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** This endpoint allows creation of plans including their prices. */ - override fun create(params: PlanCreateParams, requestOptions: RequestOptions): Plan { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("plans") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + override fun create(params: PlanCreateParams, requestOptions: RequestOptions): PlanModel = + // post /plans + withRawResponse().create(params, requestOptions).parse() + + override fun update(params: PlanUpdateParams, requestOptions: RequestOptions): PlanModel = + // put /plans/{plan_id} + withRawResponse().update(params, requestOptions).parse() + + override fun list(params: PlanListParams, requestOptions: RequestOptions): PlanListPage = + // get /plans + withRawResponse().list(params, requestOptions).parse() + + override fun fetch(params: PlanFetchParams, requestOptions: RequestOptions): PlanModel = + // get /plans/{plan_id} + withRawResponse().fetch(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + PlanService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val externalPlanId: ExternalPlanIdService.WithRawResponse by lazy { + ExternalPlanIdServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun externalPlanId(): ExternalPlanIdService.WithRawResponse = externalPlanId + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: PlanCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("plans") + .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 response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint can be used to update the `external_plan_id`, and `metadata` of an existing - * plan. - * - * Other fields on a customer are currently immutable. - */ - override fun update(params: PlanUpdateParams, requestOptions: RequestOptions): Plan { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("plans", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + override fun update( + params: PlanUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("plans", params.getPathParam(0)) + .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 response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint returns a list of all [plans](/core-concepts#plan-and-price) for an account in - * a list format. The list of plans is ordered starting from the most recently created plan. The - * response also includes [`pagination_metadata`](/api-reference/pagination), which lets the - * caller retrieve the next page of results if they exist. - */ - override fun list(params: PlanListParams, requestOptions: RequestOptions): PlanListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("plans") - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + override fun list( + params: PlanListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("plans") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { PlanListPage.of(PlanServiceImpl(clientOptions), params, it) } } - .let { PlanListPage.of(this, params, it) } - } + } + + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint is used to fetch [plan](/core-concepts#plan-and-price) details given a plan - * identifier. It returns information about the prices included in the plan and their - * configuration, as well as the product that the plan is attached to. - * - * ## Serialized prices - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given [Price](/core-concepts#plan-and-price) object. The - * `model_type` field determines the key for the configuration object that is present. A - * detailed explanation of price types can be found in the - * [Price schema](/core-concepts#plan-and-price). - * - * ## Phases - * - * Orb supports plan phases, also known as contract ramps. For plans with phases, the serialized - * prices refer to all prices across all phases. - */ - override fun fetch(params: PlanFetchParams, requestOptions: RequestOptions): Plan { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("plans", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + override fun fetch( + params: PlanFetchParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("plans", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } 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 45ecda49c..fb9b7ce44 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 @@ -4,19 +4,26 @@ package com.withorb.api.services.blocking +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions -import com.withorb.api.models.Price +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.PriceCreateParams import com.withorb.api.models.PriceEvaluateParams import com.withorb.api.models.PriceEvaluateResponse import com.withorb.api.models.PriceFetchParams import com.withorb.api.models.PriceListPage import com.withorb.api.models.PriceListParams +import com.withorb.api.models.PriceModel import com.withorb.api.models.PriceUpdateParams import com.withorb.api.services.blocking.prices.ExternalPriceIdService interface PriceService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + fun externalPriceId(): ExternalPriceIdService /** @@ -35,7 +42,7 @@ interface PriceService { fun create( params: PriceCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Price + ): PriceModel /** * This endpoint allows you to update the `metadata` property on a price. If you pass null for @@ -45,7 +52,7 @@ interface PriceService { fun update( params: PriceUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Price + ): PriceModel /** * This endpoint is used to list all add-on prices created using the @@ -94,5 +101,74 @@ interface PriceService { fun fetch( params: PriceFetchParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Price + ): PriceModel + + /** A view of [PriceService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + fun externalPriceId(): ExternalPriceIdService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /prices`, but is otherwise the same as + * [PriceService.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: PriceCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `put /prices/{price_id}`, but is otherwise the same as + * [PriceService.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: PriceUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /prices`, but is otherwise the same as + * [PriceService.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: PriceListParams = PriceListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /prices`, but is otherwise the same as + * [PriceService.list]. + */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(PriceListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /prices/{price_id}/evaluate`, but is otherwise the + * same as [PriceService.evaluate]. + */ + @JvmOverloads + @MustBeClosed + fun evaluate( + params: PriceEvaluateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /prices/{price_id}`, but is otherwise the same as + * [PriceService.fetch]. + */ + @JvmOverloads + @MustBeClosed + fun fetch( + params: PriceFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } 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 a7bb42699..79d584baf 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 @@ -10,16 +10,18 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest import com.withorb.api.core.http.HttpResponse.Handler -import com.withorb.api.core.json +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.errors.OrbError -import com.withorb.api.models.Price import com.withorb.api.models.PriceCreateParams import com.withorb.api.models.PriceEvaluateParams import com.withorb.api.models.PriceEvaluateResponse import com.withorb.api.models.PriceFetchParams import com.withorb.api.models.PriceListPage import com.withorb.api.models.PriceListParams +import com.withorb.api.models.PriceModel import com.withorb.api.models.PriceUpdateParams import com.withorb.api.services.blocking.prices.ExternalPriceIdService import com.withorb.api.services.blocking.prices.ExternalPriceIdServiceImpl @@ -27,158 +29,186 @@ import com.withorb.api.services.blocking.prices.ExternalPriceIdServiceImpl class PriceServiceImpl internal constructor(private val clientOptions: ClientOptions) : PriceService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: PriceService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } private val externalPriceId: ExternalPriceIdService by lazy { ExternalPriceIdServiceImpl(clientOptions) } + override fun withRawResponse(): PriceService.WithRawResponse = withRawResponse + override fun externalPriceId(): ExternalPriceIdService = externalPriceId - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint is used to create a [price](/product-catalog/price-configuration). A price - * created using this endpoint is always an add-on, meaning that it’s not associated with a - * specific plan and can instead be individually added to subscriptions, including subscriptions - * on different plans. - * - * An `external_price_id` can be optionally specified as an alias to allow ergonomic interaction - * with prices in the Orb API. - * - * See the [Price resource](/product-catalog/price-configuration) for the specification of - * different price model configurations possible in this endpoint. - */ - override fun create(params: PriceCreateParams, requestOptions: RequestOptions): Price { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("prices") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } + override fun create(params: PriceCreateParams, requestOptions: RequestOptions): PriceModel = + // post /prices + withRawResponse().create(params, requestOptions).parse() - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * 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. - */ - override fun update(params: PriceUpdateParams, requestOptions: RequestOptions): Price { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("prices", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } + override fun update(params: PriceUpdateParams, requestOptions: RequestOptions): PriceModel = + // put /prices/{price_id} + withRawResponse().update(params, requestOptions).parse() - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint is used to list all add-on prices created using the - * [price creation endpoint](/api-reference/price/create-price). - */ - override fun list(params: PriceListParams, requestOptions: RequestOptions): PriceListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("prices") - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - .let { PriceListPage.of(this, params, it) } - } + override fun list(params: PriceListParams, requestOptions: RequestOptions): PriceListPage = + // get /prices + withRawResponse().list(params, requestOptions).parse() - private val evaluateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * 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. - */ override fun evaluate( params: PriceEvaluateParams, requestOptions: RequestOptions, - ): PriceEvaluateResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("prices", params.getPathParam(0), "evaluate") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { evaluateHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): PriceEvaluateResponse = + // post /prices/{price_id}/evaluate + withRawResponse().evaluate(params, requestOptions).parse() + + override fun fetch(params: PriceFetchParams, requestOptions: RequestOptions): PriceModel = + // get /prices/{price_id} + withRawResponse().fetch(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + PriceService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val externalPriceId: ExternalPriceIdService.WithRawResponse by lazy { + ExternalPriceIdServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun externalPriceId(): ExternalPriceIdService.WithRawResponse = externalPriceId + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: PriceCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("prices") + .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 response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } - } - - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** This endpoint returns a price given an identifier. */ - override fun fetch(params: PriceFetchParams, requestOptions: RequestOptions): Price { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("prices", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: PriceUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("prices", params.getPathParam(0)) + .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 response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: PriceListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("prices") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { PriceListPage.of(PriceServiceImpl(clientOptions), params, it) } + } + } + + private val evaluateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun evaluate( + params: PriceEvaluateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("prices", params.getPathParam(0), "evaluate") + .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 response.parseable { + response + .use { evaluateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetch( + params: PriceFetchParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("prices", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } 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 624bb7f51..a7a416509 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 @@ -4,12 +4,12 @@ package com.withorb.api.services.blocking +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions -import com.withorb.api.models.Subscription +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.MutatedSubscriptionModel import com.withorb.api.models.SubscriptionCancelParams -import com.withorb.api.models.SubscriptionCancelResponse import com.withorb.api.models.SubscriptionCreateParams -import com.withorb.api.models.SubscriptionCreateResponse import com.withorb.api.models.SubscriptionFetchCostsParams import com.withorb.api.models.SubscriptionFetchCostsResponse import com.withorb.api.models.SubscriptionFetchParams @@ -18,27 +18,25 @@ import com.withorb.api.models.SubscriptionFetchScheduleParams import com.withorb.api.models.SubscriptionFetchUsageParams import com.withorb.api.models.SubscriptionListPage import com.withorb.api.models.SubscriptionListParams +import com.withorb.api.models.SubscriptionModel import com.withorb.api.models.SubscriptionPriceIntervalsParams -import com.withorb.api.models.SubscriptionPriceIntervalsResponse import com.withorb.api.models.SubscriptionSchedulePlanChangeParams -import com.withorb.api.models.SubscriptionSchedulePlanChangeResponse import com.withorb.api.models.SubscriptionTriggerPhaseParams -import com.withorb.api.models.SubscriptionTriggerPhaseResponse import com.withorb.api.models.SubscriptionUnscheduleCancellationParams -import com.withorb.api.models.SubscriptionUnscheduleCancellationResponse import com.withorb.api.models.SubscriptionUnscheduleFixedFeeQuantityUpdatesParams -import com.withorb.api.models.SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse import com.withorb.api.models.SubscriptionUnschedulePendingPlanChangesParams -import com.withorb.api.models.SubscriptionUnschedulePendingPlanChangesResponse import com.withorb.api.models.SubscriptionUpdateFixedFeeQuantityParams -import com.withorb.api.models.SubscriptionUpdateFixedFeeQuantityResponse import com.withorb.api.models.SubscriptionUpdateParams import com.withorb.api.models.SubscriptionUpdateTrialParams -import com.withorb.api.models.SubscriptionUpdateTrialResponse import com.withorb.api.models.SubscriptionUsage interface SubscriptionService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * A subscription represents the purchase of a plan by a customer. The customer is identified by * either the `customer_id` or the `external_customer_id`, and exactly one of these fields must @@ -281,7 +279,7 @@ interface SubscriptionService { fun create( params: SubscriptionCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): SubscriptionCreateResponse + ): MutatedSubscriptionModel /** * This endpoint can be used to update the `metadata`, `net terms`, `auto_collection`, @@ -291,7 +289,7 @@ interface SubscriptionService { fun update( params: SubscriptionUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Subscription + ): SubscriptionModel /** * This endpoint returns a list of all subscriptions for an account as a @@ -379,7 +377,7 @@ interface SubscriptionService { fun cancel( params: SubscriptionCancelParams, requestOptions: RequestOptions = RequestOptions.none(), - ): SubscriptionCancelResponse + ): MutatedSubscriptionModel /** * This endpoint is used to fetch a [Subscription](/core-concepts##subscription) given an @@ -389,7 +387,7 @@ interface SubscriptionService { fun fetch( params: SubscriptionFetchParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Subscription + ): SubscriptionModel /** * This endpoint is used to fetch a day-by-day snapshot of a subscription's costs in Orb, @@ -673,7 +671,7 @@ interface SubscriptionService { fun priceIntervals( params: SubscriptionPriceIntervalsParams, requestOptions: RequestOptions = RequestOptions.none(), - ): SubscriptionPriceIntervalsResponse + ): MutatedSubscriptionModel /** * This endpoint can be used to change an existing subscription's plan. It returns the @@ -845,7 +843,7 @@ interface SubscriptionService { fun schedulePlanChange( params: SubscriptionSchedulePlanChangeParams, requestOptions: RequestOptions = RequestOptions.none(), - ): SubscriptionSchedulePlanChangeResponse + ): MutatedSubscriptionModel /** * Manually trigger a phase, effective the given date (or the current time, if not specified). @@ -854,7 +852,7 @@ interface SubscriptionService { fun triggerPhase( params: SubscriptionTriggerPhaseParams, requestOptions: RequestOptions = RequestOptions.none(), - ): SubscriptionTriggerPhaseResponse + ): MutatedSubscriptionModel /** * This endpoint can be used to unschedule any pending cancellations for a subscription. @@ -867,7 +865,7 @@ interface SubscriptionService { fun unscheduleCancellation( params: SubscriptionUnscheduleCancellationParams, requestOptions: RequestOptions = RequestOptions.none(), - ): SubscriptionUnscheduleCancellationResponse + ): MutatedSubscriptionModel /** * This endpoint can be used to clear scheduled updates to the quantity for a fixed fee. @@ -879,7 +877,7 @@ interface SubscriptionService { fun unscheduleFixedFeeQuantityUpdates( params: SubscriptionUnscheduleFixedFeeQuantityUpdatesParams, requestOptions: RequestOptions = RequestOptions.none(), - ): SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse + ): MutatedSubscriptionModel /** * This endpoint can be used to unschedule any pending plan changes on an existing subscription. @@ -888,7 +886,7 @@ interface SubscriptionService { fun unschedulePendingPlanChanges( params: SubscriptionUnschedulePendingPlanChangesParams, requestOptions: RequestOptions = RequestOptions.none(), - ): SubscriptionUnschedulePendingPlanChangesResponse + ): MutatedSubscriptionModel /** * This endpoint can be used to update the quantity for a fixed fee. @@ -908,7 +906,7 @@ interface SubscriptionService { fun updateFixedFeeQuantity( params: SubscriptionUpdateFixedFeeQuantityParams, requestOptions: RequestOptions = RequestOptions.none(), - ): SubscriptionUpdateFixedFeeQuantityResponse + ): MutatedSubscriptionModel /** * This endpoint is used to update the trial end date for a subscription. The new trial end date @@ -932,5 +930,200 @@ interface SubscriptionService { fun updateTrial( params: SubscriptionUpdateTrialParams, requestOptions: RequestOptions = RequestOptions.none(), - ): SubscriptionUpdateTrialResponse + ): MutatedSubscriptionModel + + /** + * A view of [SubscriptionService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /subscriptions`, but is otherwise the same as + * [SubscriptionService.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: SubscriptionCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `put /subscriptions/{subscription_id}`, but is otherwise + * the same as [SubscriptionService.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: SubscriptionUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /subscriptions`, but is otherwise the same as + * [SubscriptionService.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: SubscriptionListParams = SubscriptionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /subscriptions`, but is otherwise the same as + * [SubscriptionService.list]. + */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(SubscriptionListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /subscriptions/{subscription_id}/cancel`, but is + * otherwise the same as [SubscriptionService.cancel]. + */ + @JvmOverloads + @MustBeClosed + fun cancel( + params: SubscriptionCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /subscriptions/{subscription_id}`, but is otherwise + * the same as [SubscriptionService.fetch]. + */ + @JvmOverloads + @MustBeClosed + fun fetch( + params: SubscriptionFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /subscriptions/{subscription_id}/costs`, but is + * otherwise the same as [SubscriptionService.fetchCosts]. + */ + @JvmOverloads + @MustBeClosed + fun fetchCosts( + params: SubscriptionFetchCostsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /subscriptions/{subscription_id}/schedule`, but is + * otherwise the same as [SubscriptionService.fetchSchedule]. + */ + @JvmOverloads + @MustBeClosed + fun fetchSchedule( + params: SubscriptionFetchScheduleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /subscriptions/{subscription_id}/usage`, but is + * otherwise the same as [SubscriptionService.fetchUsage]. + */ + @JvmOverloads + @MustBeClosed + fun fetchUsage( + params: SubscriptionFetchUsageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /subscriptions/{subscription_id}/price_intervals`, + * but is otherwise the same as [SubscriptionService.priceIntervals]. + */ + @JvmOverloads + @MustBeClosed + fun priceIntervals( + params: SubscriptionPriceIntervalsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post + * /subscriptions/{subscription_id}/schedule_plan_change`, but is otherwise the same as + * [SubscriptionService.schedulePlanChange]. + */ + @JvmOverloads + @MustBeClosed + fun schedulePlanChange( + params: SubscriptionSchedulePlanChangeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /subscriptions/{subscription_id}/trigger_phase`, + * but is otherwise the same as [SubscriptionService.triggerPhase]. + */ + @JvmOverloads + @MustBeClosed + fun triggerPhase( + params: SubscriptionTriggerPhaseParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post + * /subscriptions/{subscription_id}/unschedule_cancellation`, but is otherwise the same as + * [SubscriptionService.unscheduleCancellation]. + */ + @JvmOverloads + @MustBeClosed + fun unscheduleCancellation( + params: SubscriptionUnscheduleCancellationParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post + * /subscriptions/{subscription_id}/unschedule_fixed_fee_quantity_updates`, but is otherwise + * the same as [SubscriptionService.unscheduleFixedFeeQuantityUpdates]. + */ + @JvmOverloads + @MustBeClosed + fun unscheduleFixedFeeQuantityUpdates( + params: SubscriptionUnscheduleFixedFeeQuantityUpdatesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post + * /subscriptions/{subscription_id}/unschedule_pending_plan_changes`, but is otherwise the + * same as [SubscriptionService.unschedulePendingPlanChanges]. + */ + @JvmOverloads + @MustBeClosed + fun unschedulePendingPlanChanges( + params: SubscriptionUnschedulePendingPlanChangesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post + * /subscriptions/{subscription_id}/update_fixed_fee_quantity`, but is otherwise the same as + * [SubscriptionService.updateFixedFeeQuantity]. + */ + @JvmOverloads + @MustBeClosed + fun updateFixedFeeQuantity( + params: SubscriptionUpdateFixedFeeQuantityParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /subscriptions/{subscription_id}/update_trial`, but + * is otherwise the same as [SubscriptionService.updateTrial]. + */ + @JvmOverloads + @MustBeClosed + fun updateTrial( + params: SubscriptionUpdateTrialParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionServiceImpl.kt index 31bfaaf6f..a8b8caaf9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionServiceImpl.kt @@ -10,14 +10,14 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest import com.withorb.api.core.http.HttpResponse.Handler -import com.withorb.api.core.json +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.errors.OrbError -import com.withorb.api.models.Subscription +import com.withorb.api.models.MutatedSubscriptionModel import com.withorb.api.models.SubscriptionCancelParams -import com.withorb.api.models.SubscriptionCancelResponse import com.withorb.api.models.SubscriptionCreateParams -import com.withorb.api.models.SubscriptionCreateResponse import com.withorb.api.models.SubscriptionFetchCostsParams import com.withorb.api.models.SubscriptionFetchCostsResponse import com.withorb.api.models.SubscriptionFetchParams @@ -26,1221 +26,612 @@ import com.withorb.api.models.SubscriptionFetchScheduleParams import com.withorb.api.models.SubscriptionFetchUsageParams import com.withorb.api.models.SubscriptionListPage import com.withorb.api.models.SubscriptionListParams +import com.withorb.api.models.SubscriptionModel import com.withorb.api.models.SubscriptionPriceIntervalsParams -import com.withorb.api.models.SubscriptionPriceIntervalsResponse import com.withorb.api.models.SubscriptionSchedulePlanChangeParams -import com.withorb.api.models.SubscriptionSchedulePlanChangeResponse import com.withorb.api.models.SubscriptionTriggerPhaseParams -import com.withorb.api.models.SubscriptionTriggerPhaseResponse import com.withorb.api.models.SubscriptionUnscheduleCancellationParams -import com.withorb.api.models.SubscriptionUnscheduleCancellationResponse import com.withorb.api.models.SubscriptionUnscheduleFixedFeeQuantityUpdatesParams -import com.withorb.api.models.SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse import com.withorb.api.models.SubscriptionUnschedulePendingPlanChangesParams -import com.withorb.api.models.SubscriptionUnschedulePendingPlanChangesResponse import com.withorb.api.models.SubscriptionUpdateFixedFeeQuantityParams -import com.withorb.api.models.SubscriptionUpdateFixedFeeQuantityResponse import com.withorb.api.models.SubscriptionUpdateParams import com.withorb.api.models.SubscriptionUpdateTrialParams -import com.withorb.api.models.SubscriptionUpdateTrialResponse import com.withorb.api.models.SubscriptionUsage class SubscriptionServiceImpl internal constructor(private val clientOptions: ClientOptions) : SubscriptionService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: SubscriptionService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): SubscriptionService.WithRawResponse = withRawResponse - /** - * A subscription represents the purchase of a plan by a customer. The customer is identified by - * either the `customer_id` or the `external_customer_id`, and exactly one of these fields must - * be provided. - * - * By default, subscriptions begin on the day that they're created and renew automatically for - * each billing cycle at the cadence that's configured in the plan definition. - * - * The default configuration for subscriptions in Orb is **In-advance billing** and **Beginning - * of month alignment** (see [Subscription](/core-concepts##subscription) for more details). - * - * In order to change the alignment behavior, Orb also supports billing subscriptions on the day - * of the month they are created. If `align_billing_with_subscription_start_date = true` is - * specified, subscriptions have billing cycles that are aligned with their `start_date`. For - * example, a subscription that begins on January 15th will have a billing cycle from January - * 15th to February 15th. Every subsequent billing cycle will continue to start and invoice on - * the 15th. - * - * If the "day" value is greater than the number of days in the month, the next billing cycle - * will start at the end of the month. For example, if the start_date is January 31st, the next - * billing cycle will start on February 28th. - * - * If a customer was created with a currency, Orb only allows subscribing the customer to a plan - * with a matching `invoicing_currency`. If the customer does not have a currency set, on - * subscription creation, we set the customer's currency to be the `invoicing_currency` of the - * plan. - * - * ## Customize your customer's subscriptions - * - * Prices and adjustments in a plan can be added, removed, or replaced for the subscription - * being created. This is useful when a customer has prices that differ from the default prices - * for a specific plan. - * - * This feature is only available for accounts that have migrated to Subscription - * Overrides Version 2. You can find your Subscription Overrides Version at the bottom of your - * [Plans page](https://app.withorb.com/plans) - * - * ### Adding Prices - * - * To add prices, provide a list of objects with the key `add_prices`. An object in the list - * must specify an existing add-on price with a `price_id` or `external_price_id` field, or - * create a new add-on price by including an object with the key `price`, identical to what - * would be used in the request body for the - * [create price endpoint](/api-reference/price/create-price). See the - * [Price resource](/product-catalog/price-configuration) for the specification of different - * price model configurations possible in this object. - * - * If the plan has phases, each object in the list must include a number with `plan_phase_order` - * key to indicate which phase the price should be added to. - * - * An object in the list can specify an optional `start_date` and optional `end_date`. This is - * equivalent to creating a price interval with the - * [add/edit price intervals endpoint](/api-reference/price-interval/add-or-edit-price-intervals). - * If unspecified, the start or end date of the phase or subscription will be used. - * - * An object in the list can specify an optional `minimum_amount`, `maximum_amount`, or - * `discounts`. This will create adjustments which apply only to this price. - * - * Additionally, an object in the list can specify an optional `reference_id`. This ID can be - * used to reference this price when [adding an adjustment](#adding-adjustments) in the same API - * call. However the ID is _transient_ and cannot be used to refer to the price in future API - * calls. - * - * ### Removing Prices - * - * To remove prices, provide a list of objects with the key `remove_prices`. An object in the - * list must specify a plan price with either a `price_id` or `external_price_id` field. - * - * ### Replacing Prices - * - * To replace prices, provide a list of objects with the key `replace_prices`. An object in the - * list must specify a plan price to replace with the `replaces_price_id` key, and it must - * specify a price to replace it with by either referencing an existing add-on price with a - * `price_id` or `external_price_id` field, or by creating a new add-on price by including an - * object with the key `price`, identical to what would be used in the request body for the - * [create price endpoint](/api-reference/price/create-price). See the - * [Price resource](/product-catalog/price-configuration) for the specification of different - * price model configurations possible in this object. - * - * For fixed fees, an object in the list can supply a `fixed_price_quantity` instead of a - * `price`, `price_id`, or `external_price_id` field. This will update only the quantity for the - * price, similar to the - * [Update price quantity](/api-reference/subscription/update-price-quantity) endpoint. - * - * The replacement price will have the same phase, if applicable, and the same start and end - * dates as the price it replaces. - * - * An object in the list can specify an optional `minimum_amount`, `maximum_amount`, or - * `discounts`. This will create adjustments which apply only to this price. - * - * Additionally, an object in the list can specify an optional `reference_id`. This ID can be - * used to reference the replacement price when [adding an adjustment](#adding-adjustments) in - * the same API call. However the ID is _transient_ and cannot be used to refer to the price in - * future API calls. - * - * ### Adding adjustments - * - * To add adjustments, provide a list of objects with the key `add_adjustments`. An object in - * the list must include an object with the key `adjustment`, identical to the adjustment object - * in the - * [add/edit price intervals endpoint](/api-reference/price-interval/add-or-edit-price-intervals). - * - * If the plan has phases, each object in the list must include a number with `plan_phase_order` - * key to indicate which phase the adjustment should be added to. - * - * An object in the list can specify an optional `start_date` and optional `end_date`. If - * unspecified, the start or end date of the phase or subscription will be used. - * - * ### Removing adjustments - * - * To remove adjustments, provide a list of objects with the key `remove_adjustments`. An object - * in the list must include a key, `adjustment_id`, with the ID of the adjustment to be removed. - * - * ### Replacing adjustments - * - * To replace adjustments, provide a list of objects with the key `replace_adjustments`. An - * object in the list must specify a plan adjustment to replace with the - * `replaces_adjustment_id` key, and it must specify an adjustment to replace it with by - * including an object with the key `adjustment`, identical to the adjustment object in the - * [add/edit price intervals endpoint](/api-reference/price-interval/add-or-edit-price-intervals). - * - * The replacement adjustment will have the same phase, if applicable, and the same start and - * end dates as the adjustment it replaces. - * - * ## Price overrides (DEPRECATED) - * - * Price overrides are being phased out in favor adding/removing/replacing prices. (See - * [Customize your customer's subscriptions](/api-reference/subscription/create-subscription)) - * - * - * Price overrides are used to update some or all prices in a plan for the specific subscription - * being created. This is useful when a new customer has negotiated a rate that is unique to the - * customer. - * - * To override prices, provide a list of objects with the key `price_overrides`. The price - * object in the list of overrides is expected to contain the existing price id, the - * `model_type` and configuration. (See the - * [Price resource](/product-catalog/price-configuration) for the specification of different - * price model configurations.) The numerical values can be updated, but the billable metric, - * cadence, type, and name of a price can not be overridden. - * - * ### Maximums and Minimums - * - * Minimums and maximums, much like price overrides, can be useful when a new customer has - * negotiated a new or different minimum or maximum spend cap than the default for a given - * price. If one exists for a price and null is provided for the minimum/maximum override on - * creation, then there will be no minimum/maximum on the new subscription. If no value is - * provided, then the default price maximum or minimum is used. - * - * To add a minimum for a specific price, add `minimum_amount` to the specific price in the - * `price_overrides` object. - * - * To add a maximum for a specific price, add `maximum_amount` to the specific price in the - * `price_overrides` object. - * - * ### Minimum override example - * - * Price minimum override example: - * ```json - * { - * ... - * "id": "price_id", - * "model_type": "unit", - * "unit_config": { - * "unit_amount": "0.50" - * }, - * "minimum_amount": "100.00" - * ... - * } - * ``` - * - * Removing an existing minimum example - * - * ```json - * { - * ... - * "id": "price_id", - * "model_type": "unit", - * "unit_config": { - * "unit_amount": "0.50" - * }, - * "minimum_amount": null - * ... - * } - * ``` - * - * ### Discounts - * - * Discounts, like price overrides, can be useful when a new customer has negotiated a new or - * different discount than the default for a price. If a discount exists for a price and a null - * discount is provided on creation, then there will be no discount on the new subscription. - * - * To add a discount for a specific price, add `discount` to the price in the `price_overrides` - * object. Discount should be a dictionary of the format: - * ```ts - * { - * "discount_type": "amount" | "percentage" | "usage", - * "amount_discount": string, - * "percentage_discount": string, - * "usage_discount": string - * } - * ``` - * - * where either `amount_discount`, `percentage_discount`, or `usage_discount` is provided. - * - * Price discount example - * - * ```json - * { - * ... - * "id": "price_id", - * "model_type": "unit", - * "unit_config": { - * "unit_amount": "0.50" - * }, - * "discount": {"discount_type": "amount", "amount_discount": "175"}, - * } - * ``` - * - * Removing an existing discount example - * - * ```json - * { - * "customer_id": "customer_id", - * "plan_id": "plan_id", - * "discount": null, - * "price_overrides": [ ... ] - * ... - * } - * ``` - * - * ## Threshold Billing - * - * Orb supports invoicing for a subscription when a preconfigured usage threshold is hit. To - * enable threshold billing, pass in an `invoicing_threshold`, which is specified in the - * subscription's invoicing currency, when creating a subscription. E.g. pass in `10.00` to - * issue an invoice when usage amounts hit $10.00 for a subscription that invoices in USD. - */ override fun create( params: SubscriptionCreateParams, requestOptions: RequestOptions, - ): SubscriptionCreateResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("subscriptions") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): MutatedSubscriptionModel = + // post /subscriptions + withRawResponse().create(params, requestOptions).parse() - /** - * This endpoint can be used to update the `metadata`, `net terms`, `auto_collection`, - * `invoicing_threshold`, and `default_invoice_memo` properties on a subscription. - */ override fun update( params: SubscriptionUpdateParams, requestOptions: RequestOptions, - ): Subscription { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("subscriptions", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } + ): SubscriptionModel = + // put /subscriptions/{subscription_id} + withRawResponse().update(params, requestOptions).parse() - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * This endpoint returns a list of all subscriptions for an account as a - * [paginated](/api-reference/pagination) list, ordered starting from the most recently created - * subscription. For a full discussion of the subscription resource, see - * [Subscription](/core-concepts##subscription). - * - * Subscriptions can be filtered for a specific customer by using either the customer_id or - * external_customer_id query parameters. To filter subscriptions for multiple customers, use - * the customer_id[] or external_customer_id[] query parameters. - */ override fun list( params: SubscriptionListParams, requestOptions: RequestOptions, - ): SubscriptionListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("subscriptions") - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - .let { SubscriptionListPage.of(this, params, it) } - } - - private val cancelHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + ): SubscriptionListPage = + // get /subscriptions + withRawResponse().list(params, requestOptions).parse() - /** - * This endpoint can be used to cancel an existing subscription. It returns the serialized - * subscription object with an `end_date` parameter that signifies when the subscription will - * transition to an ended state. - * - * The body parameter `cancel_option` determines the cancellation behavior. Orb supports three - * cancellation options: - * - `end_of_subscription_term`: stops the subscription from auto-renewing. Subscriptions that - * have been cancelled with this option can still incur charges for the remainder of their - * term: - * - Issuing this cancellation request for a monthly subscription will keep the subscription - * active until the start of the subsequent month, and potentially issue an invoice for - * any usage charges incurred in the intervening period. - * - Issuing this cancellation request for a quarterly subscription will keep the - * subscription active until the end of the quarter and potentially issue an invoice for - * any usage charges incurred in the intervening period. - * - Issuing this cancellation request for a yearly subscription will keep the subscription - * active for the full year. For example, a yearly subscription starting on 2021-11-01 and - * cancelled on 2021-12-08 will remain active until 2022-11-01 and potentially issue - * charges in the intervening months for any recurring monthly usage charges in its plan. - * - **Note**: If a subscription's plan contains prices with difference cadences, the end of - * term date will be determined by the largest cadence value. For example, cancelling end - * of term for a subscription with a quarterly fixed fee with a monthly usage fee will - * result in the subscription ending at the end of the quarter. - * - `immediate`: ends the subscription immediately, setting the `end_date` to the current time: - * - Subscriptions that have been cancelled with this option will be invoiced immediately. - * This invoice will include any usage fees incurred in the billing period up to the - * cancellation, along with any prorated recurring fees for the billing period, if - * applicable. - * - **Note**: If the subscription has a recurring fee that was paid in-advance, the - * prorated amount for the remaining time period will be added to the - * [customer's balance](list-balance-transactions) upon immediate cancellation. However, - * if the customer is ineligible to use the customer balance, the subscription cannot be - * cancelled immediately. - * - `requested_date`: ends the subscription on a specified date, which requires a - * `cancellation_date` to be passed in. If no timezone is provided, the customer's timezone is - * used. For example, a subscription starting on January 1st with a monthly price can be set - * to be cancelled on the first of any month after January 1st (e.g. March 1st, April 1st, May - * 1st). A subscription with multiple prices with different cadences defines the "term" to be - * the highest cadence of the prices. - * - * Upcoming subscriptions are only eligible for immediate cancellation, which will set the - * `end_date` equal to the `start_date` upon cancellation. - * - * ## Backdated cancellations - * - * Orb allows you to cancel a subscription in the past as long as there are no paid invoices - * between the `requested_date` and the current time. If the cancellation is after the latest - * issued invoice, Orb will generate a balance refund for the current period. If the - * cancellation is before the most recently issued invoice, Orb will void the intervening - * invoice and generate a new one based on the new dates for the subscription. See the section - * on [cancellation behaviors](/product-catalog/creating-subscriptions#cancellation-behaviors). - */ override fun cancel( params: SubscriptionCancelParams, requestOptions: RequestOptions, - ): SubscriptionCancelResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("subscriptions", params.getPathParam(0), "cancel") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { cancelHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } + ): MutatedSubscriptionModel = + // post /subscriptions/{subscription_id}/cancel + withRawResponse().cancel(params, requestOptions).parse() - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint is used to fetch a [Subscription](/core-concepts##subscription) given an - * identifier. - */ override fun fetch( params: SubscriptionFetchParams, requestOptions: RequestOptions, - ): Subscription { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("subscriptions", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - - private val fetchCostsHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + ): SubscriptionModel = + // get /subscriptions/{subscription_id} + withRawResponse().fetch(params, requestOptions).parse() - /** - * This endpoint is used to fetch a day-by-day snapshot of a subscription's costs in Orb, - * calculated by applying pricing information to the underlying usage (see the - * [subscription usage endpoint](fetch-subscription-usage) to fetch usage per metric, in usage - * 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). - */ override fun fetchCosts( params: SubscriptionFetchCostsParams, requestOptions: RequestOptions, - ): SubscriptionFetchCostsResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("subscriptions", params.getPathParam(0), "costs") - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { fetchCostsHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } + ): SubscriptionFetchCostsResponse = + // get /subscriptions/{subscription_id}/costs + withRawResponse().fetchCosts(params, requestOptions).parse() - private val fetchScheduleHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * This endpoint returns a [paginated](/api-reference/pagination) list of all plans associated - * with a subscription along with their start and end dates. This list contains the - * subscription's initial plan along with past and future plan changes. - */ override fun fetchSchedule( params: SubscriptionFetchScheduleParams, requestOptions: RequestOptions, - ): SubscriptionFetchSchedulePage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("subscriptions", params.getPathParam(0), "schedule") - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { fetchScheduleHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - .let { SubscriptionFetchSchedulePage.of(this, params, it) } - } - - private val fetchUsageHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + ): SubscriptionFetchSchedulePage = + // get /subscriptions/{subscription_id}/schedule + withRawResponse().fetchSchedule(params, requestOptions).parse() - /** - * This endpoint is used to fetch a subscription's usage in Orb. Especially when combined with - * optional query parameters, this endpoint is a powerful way to build visualizations on top of - * Orb's event data and metrics. - * - * With no query parameters specified, this endpoint returns usage for the subscription's - * _current billing period_ across each billable metric that participates in the subscription. - * Usage quantities returned are the result of evaluating the metric definition for the entirety - * of the customer's billing period. - * - * ### Default response shape - * - * Orb returns a `data` array with an object corresponding to each billable metric. Nested - * within this object is a `usage` array which has a `quantity` value and a corresponding - * `timeframe_start` and `timeframe_end`. The `quantity` value represents the calculated usage - * value for the billable metric over the specified timeframe (inclusive of the - * `timeframe_start` timestamp and exclusive of the `timeframe_end` timestamp). - * - * Orb will include _every_ window in the response starting from the beginning of the billing - * period, even when there were no events (and therefore no usage) in the window. This increases - * the size of the response but prevents the caller from filling in gaps and handling cumbersome - * time-based logic. - * - * The query parameters in this endpoint serve to override this behavior and provide some key - * functionality, as listed below. Note that this functionality can also be used _in - * conjunction_ with each other, e.g. to display grouped usage on a custom timeframe. - * - * ## Custom timeframe - * - * In order to view usage for a custom timeframe rather than the current billing period, specify - * a `timeframe_start` and `timeframe_end`. This will calculate quantities for usage incurred - * between timeframe_start (inclusive) and timeframe_end (exclusive), i.e. `[timeframe_start, - * timeframe_end)`. - * - * Note: - * - These timestamps must be specified in ISO 8601 format and UTC timezone, e.g. - * `2022-02-01T05:00:00Z`. - * - Both parameters must be specified if either is specified. - * - * ## Grouping by custom attributes - * - * In order to view a single metric grouped by a specific _attribute_ that each event is tagged - * with (e.g. `cluster`), you must additionally specify a `billable_metric_id` and a `group_by` - * key. The `group_by` key denotes the event property on which to group. - * - * When returning grouped usage, only usage for `billable_metric_id` is returned, and a separate - * object in the `data` array is returned for each value of the `group_by` key present in your - * events. The `quantity` value is the result of evaluating the billable metric for events - * filtered to a single value of the `group_by` key. - * - * Orb expects that events that match the billable metric will contain values in the - * `properties` dictionary that correspond to the `group_by` key specified. By default, Orb will - * not return a `null` group (i.e. events that match the metric but do not have the key set). - * Currently, it is only possible to view usage grouped by a single attribute at a time. - * - * When viewing grouped usage, Orb uses pagination to limit the response size to 1000 groups by - * default. If there are more groups for a given subscription, pagination metadata in the - * response can be used to fetch all of the data. - * - * The following example shows usage for an "API Requests" billable metric grouped by `region`. - * Note the extra `metric_group` dictionary in the response, which provides metadata about the - * group: - * ```json - * { - * "data": [ - * { - * "usage": [ - * { - * "quantity": 0.19291, - * "timeframe_start": "2021-10-01T07:00:00Z", - * "timeframe_end": "2021-10-02T07:00:00Z", - * }, - * ... - * ], - * "metric_group": { - * "property_key": "region", - * "property_value": "asia/pacific" - * }, - * "billable_metric": { - * "id": "Fe9pbpMk86xpwdGB", - * "name": "API Requests" - * }, - * "view_mode": "periodic" - * }, - * ... - * ] - * } - * ``` - * - * ## Windowed usage - * - * The `granularity` parameter can be used to _window_ the usage `quantity` value into periods. - * When not specified, usage is returned for the entirety of the time range. - * - * When `granularity = day` is specified with a timeframe longer than a day, Orb will return a - * `quantity` value for each full day between `timeframe_start` and `timeframe_end`. Note that - * the days are demarcated by the _customer's local midnight_. - * - * For example, with `timeframe_start = 2022-02-01T05:00:00Z`, `timeframe_end = - * 2022-02-04T01:00:00Z` and `granularity=day`, the following windows will be returned for a - * customer in the `America/Los_Angeles` timezone since local midnight is `08:00` UTC: - * - `[2022-02-01T05:00:00Z, 2022-02-01T08:00:00Z)` - * - `[2022-02-01T08:00:00, 2022-02-02T08:00:00Z)` - * - `[2022-02-02T08:00:00, 2022-02-03T08:00:00Z)` - * - `[2022-02-03T08:00:00, 2022-02-04T01:00:00Z)` - * - * ```json - * { - * "data": [ - * { - * "billable_metric": { - * "id": "Q8w89wjTtBdejXKsm", - * "name": "API Requests" - * }, - * "usage": [ - * { - * "quantity": 0, - * "timeframe_end": "2022-02-01T08:00:00+00:00", - * "timeframe_start": "2022-02-01T05:00:00+00:00" - * }, - * { - * - * "quantity": 0, - * "timeframe_end": "2022-02-02T08:00:00+00:00", - * "timeframe_start": "2022-02-01T08:00:00+00:00" - * }, - * { - * "quantity": 0, - * "timeframe_end": "2022-02-03T08:00:00+00:00", - * "timeframe_start": "2022-02-02T08:00:00+00:00" - * }, - * { - * "quantity": 0, - * "timeframe_end": "2022-02-04T01:00:00+00:00", - * "timeframe_start": "2022-02-03T08:00:00+00:00" - * } - * ], - * "view_mode": "periodic" - * }, - * ... - * ] - * } - * ``` - * - * ## Decomposable vs. non-decomposable metrics - * - * Billable metrics fall into one of two categories: decomposable and non-decomposable. A - * decomposable billable metric, such as a sum or a count, can be displayed and aggregated - * across arbitrary timescales. On the other hand, a non-decomposable metric is not meaningful - * when only a slice of the billing window is considered. - * - * As an example, if we have a billable metric that's defined to count unique users, displaying - * a graph of unique users for each day is not representative of the billable metric value over - * the month (days could have an overlapping set of 'unique' users). Instead, what's useful for - * any given day is the number of unique users in the billing period so far, which are the - * _cumulative_ unique users. - * - * Accordingly, this endpoint returns treats these two types of metrics differently when - * `group_by` is specified: - * - Decomposable metrics can be grouped by any event property. - * - Non-decomposable metrics can only be grouped by the corresponding price's invoice grouping - * key. If no invoice grouping key is present, the metric does not support `group_by`. - * - * ## Matrix prices - * - * When a billable metric is attached to a price that uses matrix pricing, it's important to - * view usage grouped by those matrix dimensions. In this case, use the query parameters - * `first_dimension_key`, `first_dimension_value` and `second_dimension_key`, - * `second_dimension_value` while filtering to a specific `billable_metric_id`. - * - * For example, if your compute metric has a separate unit price (i.e. a matrix pricing model) - * per `region` and `provider`, your request might provide the following parameters: - * - `first_dimension_key`: `region` - * - `first_dimension_value`: `us-east-1` - * - `second_dimension_key`: `provider` - * - `second_dimension_value`: `aws` - */ override fun fetchUsage( params: SubscriptionFetchUsageParams, requestOptions: RequestOptions, - ): SubscriptionUsage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("subscriptions", params.getPathParam(0), "usage") - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { fetchUsageHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } + ): SubscriptionUsage = + // get /subscriptions/{subscription_id}/usage + withRawResponse().fetchUsage(params, requestOptions).parse() - private val priceIntervalsHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * This endpoint is used to add and edit subscription - * [price intervals](/api-reference/price-interval/add-or-edit-price-intervals). By making - * modifications to a subscription’s price intervals, you can - * [flexibly and atomically control the billing behavior of a subscription](/product-catalog/modifying-subscriptions). - * - * ## Adding price intervals - * - * Prices can be added as price intervals to a subscription by specifying them in the `add` - * array. A `price_id` or `external_price_id` from an add-on price or previously removed plan - * price can be specified to reuse an existing price definition (however, please note that - * prices from other plans cannot be added to the subscription). Additionally, a new price can - * be specified using the `price` field — this price will be created automatically. - * - * A `start_date` must be specified for the price interval. This is the date when the price will - * start billing on the subscription, so this will notably result in an immediate charge at this - * time for any billed in advance fixed fees. The `end_date` will default to null, resulting in - * a price interval that will bill on a continually recurring basis. Both of these dates can be - * set in the past or the future and Orb will generate or modify invoices to ensure the - * subscription’s invoicing behavior is correct. - * - * Additionally, a discount, minimum, or maximum can be specified on the price interval. This - * will only apply to this price interval, not any other price intervals on the subscription. - * - * ## Adjustment intervals - * - * An adjustment interval represents the time period that a particular adjustment (a discount, - * minimum, or maximum) applies to the prices on a subscription. Adjustment intervals can be - * added to a subscription by specifying them in the `add_adjustments` array, or modified via - * the `edit_adjustments` array. When creating an adjustment interval, you'll need to provide - * the definition of the new adjustment (the type of adjustment, and which prices it applies - * to), as well as the start and end dates for the adjustment interval. The start and end dates - * of an existing adjustment interval can be edited via the `edit_adjustments` field (just like - * price intervals). (To "change" the amount of a discount, minimum, or maximum, then, you'll - * need to end the existing interval, and create a new adjustment interval with the new amount - * and a start date that matches the end date of the previous interval.) - * - * ## Editing price intervals - * - * Price intervals can be adjusted by specifying edits to make in the `edit` array. A - * `price_interval_id` to edit must be specified — this can be retrieved from the - * `price_intervals` field on the subscription. - * - * A new `start_date` or `end_date` can be specified to change the range of the price interval, - * which will modify past or future invoices to ensure correctness. If either of these dates are - * unspecified, they will default to the existing date on the price interval. To remove a price - * interval entirely from a subscription, set the `end_date` to be equivalent to the - * `start_date`. - * - * ## Fixed fee quantity transitions - * - * The fixed fee quantity transitions for a fixed fee price interval can also be specified when - * adding or editing by passing an array for `fixed_fee_quantity_transitions`. A fixed fee - * quantity transition must have a `quantity` and an `effective_date`, which is the date after - * which the new quantity will be used for billing. If a fixed fee quantity transition is - * scheduled at a billing period boundary, the full quantity will be billed on an invoice with - * the other prices on the subscription. If the fixed fee quantity transition is scheduled - * mid-billing period, the difference between the existing quantity and quantity specified in - * the transition will be prorated for the rest of the billing period and billed immediately, - * which will generate a new invoice. - * - * Notably, the list of fixed fee quantity transitions passed will overwrite the existing fixed - * fee quantity transitions on the price interval, so the entire list of transitions must be - * specified to add additional transitions. The existing list of transitions can be retrieved - * using the `fixed_fee_quantity_transitions` property on a subscription’s serialized price - * intervals. - */ override fun priceIntervals( params: SubscriptionPriceIntervalsParams, requestOptions: RequestOptions, - ): SubscriptionPriceIntervalsResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("subscriptions", params.getPathParam(0), "price_intervals") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { priceIntervalsHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - - private val schedulePlanChangeHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + ): MutatedSubscriptionModel = + // post /subscriptions/{subscription_id}/price_intervals + withRawResponse().priceIntervals(params, requestOptions).parse() - /** - * This endpoint can be used to change an existing subscription's plan. It returns the - * serialized updated subscription object. - * - * The body parameter `change_option` determines when the plan change occurrs. Orb supports - * three options: - * - `end_of_subscription_term`: changes the plan at the end of the existing plan's term. - * - Issuing this plan change request for a monthly subscription will keep the existing plan - * active until the start of the subsequent month. Issuing this plan change request for a - * yearly subscription will keep the existing plan active for the full year. Charges - * incurred in the remaining period will be invoiced as normal. - * - Example: The plan is billed monthly on the 1st of the month, the request is made on - * January 15th, so the plan will be changed on February 1st, and invoice will be issued - * on February 1st for the last month of the original plan. - * - `immediate`: changes the plan immediately. - * - Subscriptions that have their plan changed with this option will move to the new plan - * immediately, and be invoiced immediately. - * - This invoice will include any usage fees incurred in the billing period up to the - * change, along with any prorated recurring fees for the billing period, if applicable. - * - Example: The plan is billed monthly on the 1st of the month, the request is made on - * January 15th, so the plan will be changed on January 15th, and an invoice will be - * issued for the partial month, from January 1 to January 15, on the original plan. - * - `requested_date`: changes the plan on the requested date (`change_date`). - * - If no timezone is provided, the customer's timezone is used. The `change_date` body - * parameter is required if this option is chosen. - * - Example: The plan is billed monthly on the 1st of the month, the request is made on - * January 15th, with a requested `change_date` of February 15th, so the plan will be - * changed on February 15th, and invoices will be issued on February 1st and February - * 15th. - * - * Note that one of `plan_id` or `external_plan_id` is required in the request body for this - * operation. - * - * ## Customize your customer's subscriptions - * - * Prices and adjustments in a plan can be added, removed, or replaced on the subscription when - * you schedule the plan change. This is useful when a customer has prices that differ from the - * default prices for a specific plan. - * - * This feature is only available for accounts that have migrated to Subscription - * Overrides Version 2. You can find your Subscription Overrides Version at the bottom of your - * [Plans page](https://app.withorb.com/plans) - * - * ### Adding Prices - * - * To add prices, provide a list of objects with the key `add_prices`. An object in the list - * must specify an existing add-on price with a `price_id` or `external_price_id` field, or - * create a new add-on price by including an object with the key `price`, identical to what - * would be used in the request body for the - * [create price endpoint](/api-reference/price/create-price). See the - * [Price resource](/product-catalog/price-configuration) for the specification of different - * price model configurations possible in this object. - * - * If the plan has phases, each object in the list must include a number with `plan_phase_order` - * key to indicate which phase the price should be added to. - * - * An object in the list can specify an optional `start_date` and optional `end_date`. If - * `start_date` is unspecified, the start of the phase / plan change time will be used. If - * `end_date` is unspecified, it will finish at the end of the phase / have no end time. - * - * An object in the list can specify an optional `minimum_amount`, `maximum_amount`, or - * `discounts`. This will create adjustments which apply only to this price. - * - * Additionally, an object in the list can specify an optional `reference_id`. This ID can be - * used to reference this price when [adding an adjustment](#adding-adjustments) in the same API - * call. However the ID is _transient_ and cannot be used to refer to the price in future API - * calls. - * - * ### Removing Prices - * - * To remove prices, provide a list of objects with the key `remove_prices`. An object in the - * list must specify a plan price with either a `price_id` or `external_price_id` field. - * - * ### Replacing Prices - * - * To replace prices, provide a list of objects with the key `replace_prices`. An object in the - * list must specify a plan price to replace with the `replaces_price_id` key, and it must - * specify a price to replace it with by either referencing an existing add-on price with a - * `price_id` or `external_price_id` field, or by creating a new add-on price by including an - * object with the key `price`, identical to what would be used in the request body for the - * [create price endpoint](/api-reference/price/create-price). See the - * [Price resource](/product-catalog/price-configuration) for the specification of different - * price model configurations possible in this object. - * - * For fixed fees, an object in the list can supply a `fixed_price_quantity` instead of a - * `price`, `price_id`, or `external_price_id` field. This will update only the quantity for the - * price, similar to the - * [Update price quantity](/api-reference/subscription/update-price-quantity) endpoint. - * - * The replacement price will have the same phase, if applicable, and the same start and end - * dates as the price it replaces. - * - * An object in the list can specify an optional `minimum_amount`, `maximum_amount`, or - * `discounts`. This will create adjustments which apply only to this price. - * - * Additionally, an object in the list can specify an optional `reference_id`. This ID can be - * used to reference the replacement price when [adding an adjustment](#adding-adjustments) in - * the same API call. However the ID is _transient_ and cannot be used to refer to the price in - * future API calls. - * - * ### Adding adjustments - * - * To add adjustments, provide a list of objects with the key `add_adjustments`. An object in - * the list must include an object with the key `adjustment`, identical to the adjustment object - * in the - * [add/edit price intervals endpoint](/api-reference/price-interval/add-or-edit-price-intervals). - * - * If the plan has phases, each object in the list must include a number with `plan_phase_order` - * key to indicate which phase the adjustment should be added to. - * - * An object in the list can specify an optional `start_date` and optional `end_date`. If - * `start_date` is unspecified, the start of the phase / plan change time will be used. If - * `end_date` is unspecified, it will finish at the end of the phase / have no end time. - * - * ### Removing adjustments - * - * To remove adjustments, provide a list of objects with the key `remove_adjustments`. An object - * in the list must include a key, `adjustment_id`, with the ID of the adjustment to be removed. - * - * ### Replacing adjustments - * - * To replace adjustments, provide a list of objects with the key `replace_adjustments`. An - * object in the list must specify a plan adjustment to replace with the - * `replaces_adjustment_id` key, and it must specify an adjustment to replace it with by - * including an object with the key `adjustment`, identical to the adjustment object in the - * [add/edit price intervals endpoint](/api-reference/price-interval/add-or-edit-price-intervals). - * - * The replacement adjustment will have the same phase, if applicable, and the same start and - * end dates as the adjustment it replaces. - * - * ## Price overrides (DEPRECATED) - * - * Price overrides are being phased out in favor adding/removing/replacing prices. (See - * [Customize your customer's subscriptions](/api-reference/subscription/schedule-plan-change)) - * - * - * Price overrides are used to update some or all prices in a plan for the specific subscription - * being created. This is useful when a new customer has negotiated a rate that is unique to the - * customer. - * - * To override prices, provide a list of objects with the key `price_overrides`. The price - * object in the list of overrides is expected to contain the existing price id, the - * `model_type` and configuration. (See the - * [Price resource](/product-catalog/price-configuration) for the specification of different - * price model configurations.) The numerical values can be updated, but the billable metric, - * cadence, type, and name of a price can not be overridden. - * - * ### Maximums, and minimums - * - * Price overrides are used to update some or all prices in the target plan. Minimums and - * maximums, much like price overrides, can be useful when a new customer has negotiated a new - * or different minimum or maximum spend cap than the default for the plan. The request format - * for maximums and minimums is the same as those in - * [subscription creation](create-subscription). - * - * ## Scheduling multiple plan changes - * - * When scheduling multiple plan changes with the same date, the latest plan change on that day - * takes effect. - * - * ## Prorations for in-advance fees - * - * By default, Orb calculates the prorated difference in any fixed fees when making a plan - * change, adjusting the customer balance as needed. For details on this behavior, see - * [Modifying subscriptions](/product-catalog/modifying-subscriptions#prorations-for-in-advance-fees). - */ override fun schedulePlanChange( params: SubscriptionSchedulePlanChangeParams, requestOptions: RequestOptions, - ): SubscriptionSchedulePlanChangeResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("subscriptions", params.getPathParam(0), "schedule_plan_change") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { schedulePlanChangeHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - - private val triggerPhaseHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + ): MutatedSubscriptionModel = + // post /subscriptions/{subscription_id}/schedule_plan_change + withRawResponse().schedulePlanChange(params, requestOptions).parse() - /** - * Manually trigger a phase, effective the given date (or the current time, if not specified). - */ override fun triggerPhase( params: SubscriptionTriggerPhaseParams, requestOptions: RequestOptions, - ): SubscriptionTriggerPhaseResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("subscriptions", params.getPathParam(0), "trigger_phase") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { triggerPhaseHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } + ): MutatedSubscriptionModel = + // post /subscriptions/{subscription_id}/trigger_phase + withRawResponse().triggerPhase(params, requestOptions).parse() - private val unscheduleCancellationHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * This endpoint can be used to unschedule any pending cancellations for a subscription. - * - * 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. - */ override fun unscheduleCancellation( params: SubscriptionUnscheduleCancellationParams, requestOptions: RequestOptions, - ): SubscriptionUnscheduleCancellationResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("subscriptions", params.getPathParam(0), "unschedule_cancellation") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { unscheduleCancellationHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - - private val unscheduleFixedFeeQuantityUpdatesHandler: - Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + ): MutatedSubscriptionModel = + // post /subscriptions/{subscription_id}/unschedule_cancellation + withRawResponse().unscheduleCancellation(params, requestOptions).parse() - /** - * This endpoint can be used to clear scheduled updates to the quantity for a fixed fee. - * - * If there are no updates scheduled, a request validation error will be returned with a 400 - * status code. - */ override fun unscheduleFixedFeeQuantityUpdates( params: SubscriptionUnscheduleFixedFeeQuantityUpdatesParams, requestOptions: RequestOptions, - ): SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments( - "subscriptions", - params.getPathParam(0), - "unschedule_fixed_fee_quantity_updates", - ) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { unscheduleFixedFeeQuantityUpdatesHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } + ): MutatedSubscriptionModel = + // post /subscriptions/{subscription_id}/unschedule_fixed_fee_quantity_updates + withRawResponse().unscheduleFixedFeeQuantityUpdates(params, requestOptions).parse() - private val unschedulePendingPlanChangesHandler: - Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * This endpoint can be used to unschedule any pending plan changes on an existing subscription. - */ override fun unschedulePendingPlanChanges( params: SubscriptionUnschedulePendingPlanChangesParams, requestOptions: RequestOptions, - ): SubscriptionUnschedulePendingPlanChangesResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments( - "subscriptions", - params.getPathParam(0), - "unschedule_pending_plan_changes", - ) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { unschedulePendingPlanChangesHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - - private val updateFixedFeeQuantityHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + ): MutatedSubscriptionModel = + // post /subscriptions/{subscription_id}/unschedule_pending_plan_changes + withRawResponse().unschedulePendingPlanChanges(params, requestOptions).parse() - /** - * This endpoint can be used to update the quantity for a fixed fee. - * - * To be eligible, the subscription must currently be active and the price specified must be a - * fixed fee (not usage-based). This operation will immediately update the quantity for the fee, - * or if a `effective_date` is passed in, will update the quantity on the requested date at - * midnight in the customer's timezone. - * - * In order to change the fixed fee quantity as of the next draft invoice for this subscription, - * pass `change_option=upcoming_invoice` without an `effective_date` specified. - * - * If the fee is an in-advance fixed fee, it will also issue an immediate invoice for the - * difference for the remainder of the billing period. - */ override fun updateFixedFeeQuantity( params: SubscriptionUpdateFixedFeeQuantityParams, requestOptions: RequestOptions, - ): SubscriptionUpdateFixedFeeQuantityResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments( - "subscriptions", - params.getPathParam(0), - "update_fixed_fee_quantity", - ) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { updateFixedFeeQuantityHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - - private val updateTrialHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + ): MutatedSubscriptionModel = + // post /subscriptions/{subscription_id}/update_fixed_fee_quantity + withRawResponse().updateFixedFeeQuantity(params, requestOptions).parse() - /** - * This endpoint is used to update the trial end date for a subscription. The new trial end date - * must be within the time range of the current plan (i.e. the new trial end date must be on or - * after the subscription's start date on the current plan, and on or before the subscription - * end date). - * - * In order to retroactively remove a trial completely, the end date can be set to the - * transition date of the subscription to this plan (or, if this is the first plan for this - * subscription, the subscription's start date). In order to end a trial immediately, the - * keyword `immediate` can be provided as the trial end date. - * - * By default, Orb will shift only the trial end date (and price intervals that start or end on - * the previous trial end date), and leave all other future price intervals untouched. If the - * `shift` parameter is set to `true`, Orb will shift all subsequent price and adjustment - * intervals by the same amount as the trial end date shift (so, e.g., if a plan change is - * scheduled or an add-on price was added, that change will be pushed back by the same amount of - * time the trial is extended). - */ override fun updateTrial( params: SubscriptionUpdateTrialParams, requestOptions: RequestOptions, - ): SubscriptionUpdateTrialResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("subscriptions", params.getPathParam(0), "update_trial") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { updateTrialHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): MutatedSubscriptionModel = + // post /subscriptions/{subscription_id}/update_trial + withRawResponse().updateTrial(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SubscriptionService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun create( + params: SubscriptionCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("subscriptions") + .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 response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: SubscriptionUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("subscriptions", params.getPathParam(0)) + .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 response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: SubscriptionListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("subscriptions") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + SubscriptionListPage.of(SubscriptionServiceImpl(clientOptions), params, it) + } + } + } + + private val cancelHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun cancel( + params: SubscriptionCancelParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("subscriptions", params.getPathParam(0), "cancel") + .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 response.parseable { + response + .use { cancelHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetch( + params: SubscriptionFetchParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("subscriptions", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val fetchCostsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun fetchCosts( + params: SubscriptionFetchCostsParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("subscriptions", params.getPathParam(0), "costs") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { fetchCostsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val fetchScheduleHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun fetchSchedule( + params: SubscriptionFetchScheduleParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("subscriptions", params.getPathParam(0), "schedule") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { fetchScheduleHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + SubscriptionFetchSchedulePage.of( + SubscriptionServiceImpl(clientOptions), + params, + it, + ) + } + } + } + + private val fetchUsageHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetchUsage( + params: SubscriptionFetchUsageParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("subscriptions", params.getPathParam(0), "usage") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { fetchUsageHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val priceIntervalsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun priceIntervals( + params: SubscriptionPriceIntervalsParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("subscriptions", params.getPathParam(0), "price_intervals") + .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 response.parseable { + response + .use { priceIntervalsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val schedulePlanChangeHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun schedulePlanChange( + params: SubscriptionSchedulePlanChangeParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments( + "subscriptions", + params.getPathParam(0), + "schedule_plan_change", + ) + .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 response.parseable { + response + .use { schedulePlanChangeHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val triggerPhaseHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun triggerPhase( + params: SubscriptionTriggerPhaseParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("subscriptions", params.getPathParam(0), "trigger_phase") + .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 response.parseable { + response + .use { triggerPhaseHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val unscheduleCancellationHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun unscheduleCancellation( + params: SubscriptionUnscheduleCancellationParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments( + "subscriptions", + params.getPathParam(0), + "unschedule_cancellation", + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { unscheduleCancellationHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val unscheduleFixedFeeQuantityUpdatesHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun unscheduleFixedFeeQuantityUpdates( + params: SubscriptionUnscheduleFixedFeeQuantityUpdatesParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments( + "subscriptions", + params.getPathParam(0), + "unschedule_fixed_fee_quantity_updates", + ) + .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 response.parseable { + response + .use { unscheduleFixedFeeQuantityUpdatesHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val unschedulePendingPlanChangesHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun unschedulePendingPlanChanges( + params: SubscriptionUnschedulePendingPlanChangesParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments( + "subscriptions", + params.getPathParam(0), + "unschedule_pending_plan_changes", + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { unschedulePendingPlanChangesHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateFixedFeeQuantityHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun updateFixedFeeQuantity( + params: SubscriptionUpdateFixedFeeQuantityParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments( + "subscriptions", + params.getPathParam(0), + "update_fixed_fee_quantity", + ) + .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 response.parseable { + response + .use { updateFixedFeeQuantityHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateTrialHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun updateTrial( + params: SubscriptionUpdateTrialParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("subscriptions", params.getPathParam(0), "update_trial") + .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 response.parseable { + response + .use { updateTrialHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/TopLevelService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/TopLevelService.kt index 809628c0b..19e588155 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/TopLevelService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/TopLevelService.kt @@ -4,12 +4,19 @@ package com.withorb.api.services.blocking +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.TopLevelPingParams import com.withorb.api.models.TopLevelPingResponse interface TopLevelService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * This endpoint allows you to test your connection to the Orb API and check the validity of * your API key, passed in the Authorization header. This is particularly useful for checking @@ -34,4 +41,27 @@ interface TopLevelService { */ fun ping(requestOptions: RequestOptions): TopLevelPingResponse = ping(TopLevelPingParams.none(), requestOptions) + + /** A view of [TopLevelService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /ping`, but is otherwise the same as + * [TopLevelService.ping]. + */ + @JvmOverloads + @MustBeClosed + fun ping( + params: TopLevelPingParams = TopLevelPingParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /ping`, but is otherwise the same as + * [TopLevelService.ping]. + */ + @MustBeClosed + fun ping(requestOptions: RequestOptions): HttpResponseFor = + ping(TopLevelPingParams.none(), requestOptions) + } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/TopLevelServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/TopLevelServiceImpl.kt index 29ac973cc..2b7c37b13 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/TopLevelServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/TopLevelServiceImpl.kt @@ -10,6 +10,8 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest 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.errors.OrbError import com.withorb.api.models.TopLevelPingParams @@ -18,36 +20,49 @@ import com.withorb.api.models.TopLevelPingResponse class TopLevelServiceImpl internal constructor(private val clientOptions: ClientOptions) : TopLevelService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: TopLevelService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val pingHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): TopLevelService.WithRawResponse = withRawResponse - /** - * This endpoint allows you to test your connection to the Orb API and check the validity of - * your API key, passed in the Authorization header. This is particularly useful for checking - * that your environment is set up properly, and is a great choice for connectors and - * integrations. - * - * This API does not have any side-effects or return any Orb resources. - */ override fun ping( params: TopLevelPingParams, requestOptions: RequestOptions, - ): TopLevelPingResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("ping") - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { pingHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): TopLevelPingResponse = + // get /ping + withRawResponse().ping(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TopLevelService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val pingHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun ping( + params: TopLevelPingParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("ping") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { pingHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } 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 ec4d80a71..56f585531 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 @@ -4,12 +4,19 @@ package com.withorb.api.services.blocking.coupons +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.CouponSubscriptionListPage import com.withorb.api.models.CouponSubscriptionListParams interface SubscriptionService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * This endpoint returns a list of all subscriptions that have redeemed a given coupon as a * [paginated](/api-reference/pagination) list, ordered starting from the most recently created @@ -21,4 +28,21 @@ interface SubscriptionService { params: CouponSubscriptionListParams, requestOptions: RequestOptions = RequestOptions.none(), ): CouponSubscriptionListPage + + /** + * A view of [SubscriptionService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /coupons/{coupon_id}/subscriptions`, but is + * otherwise the same as [SubscriptionService.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: CouponSubscriptionListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } 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 64b3f593c..5b824f4f5 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 @@ -10,6 +10,8 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest 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.errors.OrbError import com.withorb.api.models.CouponSubscriptionListPage @@ -18,36 +20,56 @@ import com.withorb.api.models.CouponSubscriptionListParams class SubscriptionServiceImpl internal constructor(private val clientOptions: ClientOptions) : SubscriptionService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: SubscriptionService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): SubscriptionService.WithRawResponse = withRawResponse - /** - * This endpoint returns a list of all subscriptions that have redeemed a given coupon as a - * [paginated](/api-reference/pagination) list, ordered starting from the most recently created - * subscription. For a full discussion of the subscription resource, see - * [Subscription](/core-concepts#subscription). - */ override fun list( params: CouponSubscriptionListParams, requestOptions: RequestOptions, - ): CouponSubscriptionListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("coupons", params.getPathParam(0), "subscriptions") - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): CouponSubscriptionListPage = + // get /coupons/{coupon_id}/subscriptions + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SubscriptionService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: CouponSubscriptionListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("coupons", params.getPathParam(0), "subscriptions") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + CouponSubscriptionListPage.of( + SubscriptionServiceImpl(clientOptions), + params, + it, + ) + } } - .let { CouponSubscriptionListPage.of(this, params, it) } + } } } 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 8995b8be8..e96ae2a1e 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 @@ -4,14 +4,21 @@ package com.withorb.api.services.blocking.customers +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.CustomerBalanceTransactionCreateParams -import com.withorb.api.models.CustomerBalanceTransactionCreateResponse import com.withorb.api.models.CustomerBalanceTransactionListPage import com.withorb.api.models.CustomerBalanceTransactionListParams +import com.withorb.api.models.CustomerBalanceTransactionModel interface BalanceTransactionService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * Creates an immutable balance transaction that updates the customer's balance and returns back * the newly created transaction. @@ -20,7 +27,7 @@ interface BalanceTransactionService { fun create( params: CustomerBalanceTransactionCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CustomerBalanceTransactionCreateResponse + ): CustomerBalanceTransactionModel /** * ## The customer balance @@ -54,4 +61,33 @@ interface BalanceTransactionService { params: CustomerBalanceTransactionListParams, requestOptions: RequestOptions = RequestOptions.none(), ): CustomerBalanceTransactionListPage + + /** + * A view of [BalanceTransactionService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /customers/{customer_id}/balance_transactions`, but + * is otherwise the same as [BalanceTransactionService.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: CustomerBalanceTransactionCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /customers/{customer_id}/balance_transactions`, but + * is otherwise the same as [BalanceTransactionService.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: CustomerBalanceTransactionListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } 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 a45f2c199..481ad889a 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 @@ -10,97 +10,104 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest import com.withorb.api.core.http.HttpResponse.Handler -import com.withorb.api.core.json +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.errors.OrbError import com.withorb.api.models.CustomerBalanceTransactionCreateParams -import com.withorb.api.models.CustomerBalanceTransactionCreateResponse import com.withorb.api.models.CustomerBalanceTransactionListPage import com.withorb.api.models.CustomerBalanceTransactionListParams +import com.withorb.api.models.CustomerBalanceTransactionModel class BalanceTransactionServiceImpl internal constructor(private val clientOptions: ClientOptions) : BalanceTransactionService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: BalanceTransactionService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): BalanceTransactionService.WithRawResponse = withRawResponse - /** - * Creates an immutable balance transaction that updates the customer's balance and returns back - * the newly created transaction. - */ override fun create( params: CustomerBalanceTransactionCreateParams, requestOptions: RequestOptions, - ): CustomerBalanceTransactionCreateResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("customers", params.getPathParam(0), "balance_transactions") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } + ): CustomerBalanceTransactionModel = + // post /customers/{customer_id}/balance_transactions + withRawResponse().create(params, requestOptions).parse() - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * ## The customer balance - * - * The customer balance is an amount in the customer's currency, which Orb automatically applies - * to subsequent invoices. This balance can be adjusted manually via Orb's webapp on the - * customer details page. You can use this balance to provide a fixed mid-period credit to the - * customer. Commonly, this is done due to system downtime/SLA violation, or an adhoc adjustment - * discussed with the customer. - * - * If the balance is a positive value at the time of invoicing, it represents that the customer - * has credit that should be used to offset the amount due on the next issued invoice. In this - * case, Orb will automatically reduce the next invoice by the balance amount, and roll over any - * remaining balance if the invoice is fully discounted. - * - * If the balance is a negative value at the time of invoicing, Orb will increase the invoice's - * amount due with a positive adjustment, and reset the balance to 0. - * - * This endpoint retrieves all customer balance transactions in reverse chronological order for - * a single customer, providing a complete audit trail of all adjustments and invoice - * applications. - * - * ## Eligibility - * - * The customer balance can only be applied to invoices or adjusted manually if invoices are not - * synced to a separate invoicing provider. If a payment gateway such as Stripe is used, the - * balance will be applied to the invoice before forwarding payment to the gateway. - */ override fun list( params: CustomerBalanceTransactionListParams, requestOptions: RequestOptions, - ): CustomerBalanceTransactionListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("customers", params.getPathParam(0), "balance_transactions") - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): CustomerBalanceTransactionListPage = + // get /customers/{customer_id}/balance_transactions + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BalanceTransactionService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun create( + params: CustomerBalanceTransactionCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("customers", params.getPathParam(0), "balance_transactions") + .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 response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: CustomerBalanceTransactionListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("customers", params.getPathParam(0), "balance_transactions") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + CustomerBalanceTransactionListPage.of( + BalanceTransactionServiceImpl(clientOptions), + params, + it, + ) + } } - .let { CustomerBalanceTransactionListPage.of(this, params, it) } + } } } 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 4485b6227..a48599499 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 @@ -4,14 +4,20 @@ package com.withorb.api.services.blocking.customers +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.CustomerCostListByExternalIdParams -import com.withorb.api.models.CustomerCostListByExternalIdResponse import com.withorb.api.models.CustomerCostListParams -import com.withorb.api.models.CustomerCostListResponse +import com.withorb.api.models.CustomerCostsModel interface CostService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * This endpoint is used to fetch a day-by-day snapshot of a customer's costs in Orb, calculated * by applying pricing information to the underlying usage (see the @@ -126,7 +132,7 @@ interface CostService { fun list( params: CustomerCostListParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CustomerCostListResponse + ): CustomerCostsModel /** * This endpoint is used to fetch a day-by-day snapshot of a customer's costs in Orb, calculated @@ -242,5 +248,32 @@ interface CostService { fun listByExternalId( params: CustomerCostListByExternalIdParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CustomerCostListByExternalIdResponse + ): CustomerCostsModel + + /** A view of [CostService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /customers/{customer_id}/costs`, but is otherwise + * the same as [CostService.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: CustomerCostListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get + * /customers/external_customer_id/{external_customer_id}/costs`, but is otherwise the same + * as [CostService.listByExternalId]. + */ + @JvmOverloads + @MustBeClosed + fun listByExternalId( + params: CustomerCostListByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } 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 13c858b54..ebd95a7ec 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 @@ -10,287 +10,96 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest 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.errors.OrbError import com.withorb.api.models.CustomerCostListByExternalIdParams -import com.withorb.api.models.CustomerCostListByExternalIdResponse import com.withorb.api.models.CustomerCostListParams -import com.withorb.api.models.CustomerCostListResponse +import com.withorb.api.models.CustomerCostsModel class CostServiceImpl internal constructor(private val clientOptions: ClientOptions) : CostService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: CostService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): CostService.WithRawResponse = withRawResponse - /** - * This endpoint is used to fetch a day-by-day snapshot of a customer's costs in Orb, calculated - * by applying pricing information to the underlying usage (see the - * [subscription usage endpoint](/api-reference/subscription/fetch-subscription-usage) to fetch - * usage per metric, in usage units rather than a currency). - * - * This endpoint can be leveraged for internal tooling and to provide a more transparent billing - * experience for your end users: - * 1. Understand the cost breakdown per line item historically and in real-time for the current - * billing period. - * 2. Provide customer visibility into how different services are contributing to the overall - * invoice with a per-day timeseries (as compared to the - * [upcoming invoice](/api-reference/invoice/fetch-upcoming-invoice) resource, which - * represents a snapshot for the current period). - * 3. Assess how minimums and discounts affect your customers by teasing apart costs directly as - * a result of usage, as opposed to minimums and discounts at the plan and price level. - * 4. Gain insight into key customer health metrics, such as the percent utilization of the - * minimum committed spend. - * - * ## Fetching subscriptions - * - * By default, this endpoint fetches the currently active subscription for the customer, and - * returns cost information for the subscription's current billing period, broken down by each - * participating price. If there are no currently active subscriptions, this will instead - * default to the most recently active subscription or return an empty series if none are found. - * For example, if your plan charges for compute hours, job runs, and data syncs, then this - * endpoint would provide a daily breakdown of your customer's cost for each of those axes. - * - * If timeframe bounds are specified, Orb fetches all subscriptions that were active in that - * timeframe. If two subscriptions overlap on a single day, costs from each price will be - * summed, and prices for both subscriptions will be included in the breakdown. - * - * ## Prepaid plans - * - * For plans that include prices which deduct credits rather than accrue in-arrears charges in a - * billable currency, this endpoint will return the total deduction amount, in credits, for the - * specified timeframe. - * - * ## Cumulative subtotals and totals - * - * Since the subtotal and total must factor in any billing-period level discounts and minimums, - * it's most meaningful to consider costs relative to the start of the subscription's billing - * period. As a result, by default this endpoint returns cumulative totals since the beginning - * of the billing period. In particular, the `timeframe_start` of a returned timeframe window is - * _always_ the beginning of the billing period and `timeframe_end` is incremented one day at a - * time to build the result. - * - * A customer that uses a few API calls a day but has a minimum commitment might exhibit the - * following pattern for their subtotal and total in the first few days of the month. Here, we - * assume that each API call is $2.50, the customer's plan has a monthly minimum of $50 for this - * price, and that the subscription's billing period bounds are aligned to the first of the - * month: - * - * | timeframe_start | timeframe_end | Cumulative usage | Subtotal | Total (incl. commitment) | - * |-----------------|---------------|------------------|----------|--------------------------| - * | 2023-02-01 | 2023-02-02 | 9 | $22.50 | $50.00 | - * | 2023-02-01 | 2023-02-03 | 19 | $47.50 | $50.00 | - * | 2023-02-01 | 2023-02-04 | 20 | $50.00 | $50.00 | - * | 2023-02-01 | 2023-02-05 | 28 | $70.00 | $70.00 | - * | 2023-02-01 | 2023-02-06 | 36 | $90.00 | $90.00 | - * - * ### Periodic values - * - * When the query parameter `view_mode=periodic` is specified, Orb will return an incremental - * day-by-day view of costs. In this case, there will always be a one-day difference between - * `timeframe_start` and `timeframe_end` for the timeframes returned. This is a transform on top - * of the cumulative costs, calculated by taking the difference of each timeframe with the last. - * Note that in the above example, the `Total` value would be 0 for the second two data points, - * since the minimum commitment has not yet been hit and each day is not contributing anything - * to the total cost. - * - * ## Timeframe bounds - * - * For an active subscription, both timeframes should be specified in the request. If a - * subscription starts or ends within the timeframe, the response will only include windows - * where the subscription is active. If a subscription has ended, no timeframe bounds need to be - * specified and the response will default to the billing period when the subscription was last - * active. - * - * As noted above, `timeframe_start` for a given cumulative datapoint is always the beginning of - * the billing period, and `timeframe_end` is incremented one day at a time to construct the - * response. When a timeframe is passed in that is not aligned to the current subscription's - * billing period, the response will contain cumulative totals from multiple billing periods. - * - * Suppose the queried customer has a subscription aligned to the 15th of every month. If this - * endpoint is queried with the date range `2023-06-01` - `2023-07-01`, the first data point - * will represent about half a billing period's worth of costs, accounting for accruals from the - * start of the billing period and inclusive of the first day of the timeframe (`timeframe_start - * = 2023-05-15 00:00:00`, `timeframe_end = 2023-06-02 00:00:00`) - * - * | datapoint index | timeframe_start | timeframe_end | - * |-----------------|-----------------|---------------| - * | 0 | 2023-05-15 | 2023-06-02 | - * | 1 | 2023-05-15 | 2023-06-03 | - * | 2 | ... | ... | - * | 3 | 2023-05-15 | 2023-06-14 | - * | 4 | 2023-06-15 | 2023-06-16 | - * | 5 | 2023-06-15 | 2023-06-17 | - * | 6 | ... | ... | - * | 7 | 2023-06-15 | 2023-07-01 | - * - * You can see this sliced timeframe visualized [here](https://i.imgur.com/TXhYgme.png). - * - * ### Matrix prices - * - * When a price uses matrix pricing, it's important to view costs grouped by those matrix - * dimensions. Orb will return `price_groups` with the `grouping_key` and - * `secondary_grouping_key` based on the matrix price definition, for each `grouping_value` and - * `secondary_grouping_value` available. - */ override fun list( params: CustomerCostListParams, requestOptions: RequestOptions, - ): CustomerCostListResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("customers", params.getPathParam(0), "costs") - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } + ): CustomerCostsModel = + // get /customers/{customer_id}/costs + withRawResponse().list(params, requestOptions).parse() - private val listByExternalIdHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * This endpoint is used to fetch a day-by-day snapshot of a customer's costs in Orb, calculated - * by applying pricing information to the underlying usage (see the - * [subscription usage endpoint](/api-reference/subscription/fetch-subscription-usage) to fetch - * usage per metric, in usage units rather than a currency). - * - * This endpoint can be leveraged for internal tooling and to provide a more transparent billing - * experience for your end users: - * 1. Understand the cost breakdown per line item historically and in real-time for the current - * billing period. - * 2. Provide customer visibility into how different services are contributing to the overall - * invoice with a per-day timeseries (as compared to the - * [upcoming invoice](/api-reference/invoice/fetch-upcoming-invoice) resource, which - * represents a snapshot for the current period). - * 3. Assess how minimums and discounts affect your customers by teasing apart costs directly as - * a result of usage, as opposed to minimums and discounts at the plan and price level. - * 4. Gain insight into key customer health metrics, such as the percent utilization of the - * minimum committed spend. - * - * ## Fetching subscriptions - * - * By default, this endpoint fetches the currently active subscription for the customer, and - * returns cost information for the subscription's current billing period, broken down by each - * participating price. If there are no currently active subscriptions, this will instead - * default to the most recently active subscription or return an empty series if none are found. - * For example, if your plan charges for compute hours, job runs, and data syncs, then this - * endpoint would provide a daily breakdown of your customer's cost for each of those axes. - * - * If timeframe bounds are specified, Orb fetches all subscriptions that were active in that - * timeframe. If two subscriptions overlap on a single day, costs from each price will be - * summed, and prices for both subscriptions will be included in the breakdown. - * - * ## Prepaid plans - * - * For plans that include prices which deduct credits rather than accrue in-arrears charges in a - * billable currency, this endpoint will return the total deduction amount, in credits, for the - * specified timeframe. - * - * ## Cumulative subtotals and totals - * - * Since the subtotal and total must factor in any billing-period level discounts and minimums, - * it's most meaningful to consider costs relative to the start of the subscription's billing - * period. As a result, by default this endpoint returns cumulative totals since the beginning - * of the billing period. In particular, the `timeframe_start` of a returned timeframe window is - * _always_ the beginning of the billing period and `timeframe_end` is incremented one day at a - * time to build the result. - * - * A customer that uses a few API calls a day but has a minimum commitment might exhibit the - * following pattern for their subtotal and total in the first few days of the month. Here, we - * assume that each API call is $2.50, the customer's plan has a monthly minimum of $50 for this - * price, and that the subscription's billing period bounds are aligned to the first of the - * month: - * - * | timeframe_start | timeframe_end | Cumulative usage | Subtotal | Total (incl. commitment) | - * |-----------------|---------------|------------------|----------|--------------------------| - * | 2023-02-01 | 2023-02-02 | 9 | $22.50 | $50.00 | - * | 2023-02-01 | 2023-02-03 | 19 | $47.50 | $50.00 | - * | 2023-02-01 | 2023-02-04 | 20 | $50.00 | $50.00 | - * | 2023-02-01 | 2023-02-05 | 28 | $70.00 | $70.00 | - * | 2023-02-01 | 2023-02-06 | 36 | $90.00 | $90.00 | - * - * ### Periodic values - * - * When the query parameter `view_mode=periodic` is specified, Orb will return an incremental - * day-by-day view of costs. In this case, there will always be a one-day difference between - * `timeframe_start` and `timeframe_end` for the timeframes returned. This is a transform on top - * of the cumulative costs, calculated by taking the difference of each timeframe with the last. - * Note that in the above example, the `Total` value would be 0 for the second two data points, - * since the minimum commitment has not yet been hit and each day is not contributing anything - * to the total cost. - * - * ## Timeframe bounds - * - * For an active subscription, both timeframes should be specified in the request. If a - * subscription starts or ends within the timeframe, the response will only include windows - * where the subscription is active. If a subscription has ended, no timeframe bounds need to be - * specified and the response will default to the billing period when the subscription was last - * active. - * - * As noted above, `timeframe_start` for a given cumulative datapoint is always the beginning of - * the billing period, and `timeframe_end` is incremented one day at a time to construct the - * response. When a timeframe is passed in that is not aligned to the current subscription's - * billing period, the response will contain cumulative totals from multiple billing periods. - * - * Suppose the queried customer has a subscription aligned to the 15th of every month. If this - * endpoint is queried with the date range `2023-06-01` - `2023-07-01`, the first data point - * will represent about half a billing period's worth of costs, accounting for accruals from the - * start of the billing period and inclusive of the first day of the timeframe (`timeframe_start - * = 2023-05-15 00:00:00`, `timeframe_end = 2023-06-02 00:00:00`) - * - * | datapoint index | timeframe_start | timeframe_end | - * |-----------------|-----------------|---------------| - * | 0 | 2023-05-15 | 2023-06-02 | - * | 1 | 2023-05-15 | 2023-06-03 | - * | 2 | ... | ... | - * | 3 | 2023-05-15 | 2023-06-14 | - * | 4 | 2023-06-15 | 2023-06-16 | - * | 5 | 2023-06-15 | 2023-06-17 | - * | 6 | ... | ... | - * | 7 | 2023-06-15 | 2023-07-01 | - * - * You can see this sliced timeframe visualized [here](https://i.imgur.com/TXhYgme.png). - * - * ### Matrix prices - * - * When a price uses matrix pricing, it's important to view costs grouped by those matrix - * dimensions. Orb will return `price_groups` with the `grouping_key` and - * `secondary_grouping_key` based on the matrix price definition, for each `grouping_value` and - * `secondary_grouping_value` available. - */ override fun listByExternalId( params: CustomerCostListByExternalIdParams, requestOptions: RequestOptions, - ): CustomerCostListByExternalIdResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "customers", - "external_customer_id", - params.getPathParam(0), - "costs", - ) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listByExternalIdHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): CustomerCostsModel = + // get /customers/external_customer_id/{external_customer_id}/costs + withRawResponse().listByExternalId(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CostService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list( + params: CustomerCostListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("customers", params.getPathParam(0), "costs") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listByExternalIdHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun listByExternalId( + params: CustomerCostListByExternalIdParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "customers", + "external_customer_id", + params.getPathParam(0), + "costs", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listByExternalIdHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } 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 cee46dcdc..1f6fdeb2c 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 @@ -4,7 +4,9 @@ package com.withorb.api.services.blocking.customers +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.CustomerCreditListByExternalIdPage import com.withorb.api.models.CustomerCreditListByExternalIdParams import com.withorb.api.models.CustomerCreditListPage @@ -14,6 +16,11 @@ import com.withorb.api.services.blocking.customers.credits.TopUpService interface CreditService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + fun ledger(): LedgerService fun topUps(): TopUpService @@ -47,4 +54,35 @@ interface CreditService { params: CustomerCreditListByExternalIdParams, requestOptions: RequestOptions = RequestOptions.none(), ): CustomerCreditListByExternalIdPage + + /** A view of [CreditService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + fun ledger(): LedgerService.WithRawResponse + + fun topUps(): TopUpService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /customers/{customer_id}/credits`, but is otherwise + * the same as [CreditService.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: CustomerCreditListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get + * /customers/external_customer_id/{external_customer_id}/credits`, but is otherwise the + * same as [CreditService.listByExternalId]. + */ + @JvmOverloads + @MustBeClosed + fun listByExternalId( + params: CustomerCreditListByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } 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 86b5c91bd..5cfbbe646 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 @@ -10,6 +10,8 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest 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.errors.OrbError import com.withorb.api.models.CustomerCreditListByExternalIdPage @@ -24,86 +26,116 @@ import com.withorb.api.services.blocking.customers.credits.TopUpServiceImpl class CreditServiceImpl internal constructor(private val clientOptions: ClientOptions) : CreditService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: CreditService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } private val ledger: LedgerService by lazy { LedgerServiceImpl(clientOptions) } private val topUps: TopUpService by lazy { TopUpServiceImpl(clientOptions) } + override fun withRawResponse(): CreditService.WithRawResponse = withRawResponse + override fun ledger(): LedgerService = ledger override fun topUps(): TopUpService = topUps - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * Returns a paginated list of unexpired, non-zero credit blocks for a customer. - * - * If `include_all_blocks` is set to `true`, all credit blocks (including expired and depleted - * blocks) will be included in the response. - * - * Note that `currency` defaults to credits if not specified. To use a real world currency, set - * `currency` to an ISO 4217 string. - */ override fun list( params: CustomerCreditListParams, requestOptions: RequestOptions, - ): CustomerCreditListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("customers", params.getPathParam(0), "credits") - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - .let { CustomerCreditListPage.of(this, params, it) } - } + ): CustomerCreditListPage = + // get /customers/{customer_id}/credits + withRawResponse().list(params, requestOptions).parse() - private val listByExternalIdHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * Returns a paginated list of unexpired, non-zero credit blocks for a customer. - * - * If `include_all_blocks` is set to `true`, all credit blocks (including expired and depleted - * blocks) will be included in the response. - * - * Note that `currency` defaults to credits if not specified. To use a real world currency, set - * `currency` to an ISO 4217 string. - */ override fun listByExternalId( params: CustomerCreditListByExternalIdParams, requestOptions: RequestOptions, - ): CustomerCreditListByExternalIdPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "customers", - "external_customer_id", - params.getPathParam(0), - "credits", - ) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listByExternalIdHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): CustomerCreditListByExternalIdPage = + // get /customers/external_customer_id/{external_customer_id}/credits + withRawResponse().listByExternalId(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CreditService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val ledger: LedgerService.WithRawResponse by lazy { + LedgerServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val topUps: TopUpService.WithRawResponse by lazy { + TopUpServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun ledger(): LedgerService.WithRawResponse = ledger + + override fun topUps(): TopUpService.WithRawResponse = topUps + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: CustomerCreditListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("customers", params.getPathParam(0), "credits") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { CustomerCreditListPage.of(CreditServiceImpl(clientOptions), params, it) } + } + } + + private val listByExternalIdHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun listByExternalId( + params: CustomerCreditListByExternalIdParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "customers", + "external_customer_id", + params.getPathParam(0), + "credits", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listByExternalIdHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + CustomerCreditListByExternalIdPage.of( + CreditServiceImpl(clientOptions), + params, + it, + ) + } } - .let { CustomerCreditListByExternalIdPage.of(this, params, it) } + } } } 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 ca718a607..b7d2eb449 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 @@ -4,11 +4,12 @@ package com.withorb.api.services.blocking.customers.credits +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.CreditLedgerEntryModel import com.withorb.api.models.CustomerCreditLedgerCreateEntryByExternalIdParams -import com.withorb.api.models.CustomerCreditLedgerCreateEntryByExternalIdResponse import com.withorb.api.models.CustomerCreditLedgerCreateEntryParams -import com.withorb.api.models.CustomerCreditLedgerCreateEntryResponse import com.withorb.api.models.CustomerCreditLedgerListByExternalIdPage import com.withorb.api.models.CustomerCreditLedgerListByExternalIdParams import com.withorb.api.models.CustomerCreditLedgerListPage @@ -16,6 +17,11 @@ import com.withorb.api.models.CustomerCreditLedgerListParams interface LedgerService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * The credits ledger provides _auditing_ functionality over Orb's credits system with a list of * actions that have taken place to modify a customer's credit balance. This @@ -208,7 +214,7 @@ interface LedgerService { fun createEntry( params: CustomerCreditLedgerCreateEntryParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CustomerCreditLedgerCreateEntryResponse + ): CreditLedgerEntryModel /** * This endpoint allows you to create a new ledger entry for a specified customer's balance. @@ -317,7 +323,7 @@ interface LedgerService { fun createEntryByExternalId( params: CustomerCreditLedgerCreateEntryByExternalIdParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CustomerCreditLedgerCreateEntryByExternalIdResponse + ): CreditLedgerEntryModel /** * The credits ledger provides _auditing_ functionality over Orb's credits system with a list of @@ -403,4 +409,54 @@ interface LedgerService { params: CustomerCreditLedgerListByExternalIdParams, requestOptions: RequestOptions = RequestOptions.none(), ): CustomerCreditLedgerListByExternalIdPage + + /** A view of [LedgerService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /customers/{customer_id}/credits/ledger`, but is + * otherwise the same as [LedgerService.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: CustomerCreditLedgerListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /customers/{customer_id}/credits/ledger_entry`, but + * is otherwise the same as [LedgerService.createEntry]. + */ + @JvmOverloads + @MustBeClosed + fun createEntry( + params: CustomerCreditLedgerCreateEntryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post + * /customers/external_customer_id/{external_customer_id}/credits/ledger_entry`, but is + * otherwise the same as [LedgerService.createEntryByExternalId]. + */ + @JvmOverloads + @MustBeClosed + fun createEntryByExternalId( + params: CustomerCreditLedgerCreateEntryByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get + * /customers/external_customer_id/{external_customer_id}/credits/ledger`, but is otherwise + * the same as [LedgerService.listByExternalId]. + */ + @JvmOverloads + @MustBeClosed + fun listByExternalId( + params: CustomerCreditLedgerListByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } 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 909995a85..5b3df9e93 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 @@ -10,13 +10,14 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest import com.withorb.api.core.http.HttpResponse.Handler -import com.withorb.api.core.json +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.errors.OrbError +import com.withorb.api.models.CreditLedgerEntryModel import com.withorb.api.models.CustomerCreditLedgerCreateEntryByExternalIdParams -import com.withorb.api.models.CustomerCreditLedgerCreateEntryByExternalIdResponse import com.withorb.api.models.CustomerCreditLedgerCreateEntryParams -import com.withorb.api.models.CustomerCreditLedgerCreateEntryResponse import com.withorb.api.models.CustomerCreditLedgerListByExternalIdPage import com.withorb.api.models.CustomerCreditLedgerListByExternalIdParams import com.withorb.api.models.CustomerCreditLedgerListPage @@ -25,483 +26,180 @@ import com.withorb.api.models.CustomerCreditLedgerListParams class LedgerServiceImpl internal constructor(private val clientOptions: ClientOptions) : LedgerService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: LedgerService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): LedgerService.WithRawResponse = withRawResponse - /** - * The credits ledger provides _auditing_ functionality over Orb's credits system with a list of - * actions that have taken place to modify a customer's credit balance. This - * [paginated endpoint](/api-reference/pagination) lists these entries, starting from the most - * recent ledger entry. - * - * More details on using Orb's real-time credit feature are - * [here](/product-catalog/prepurchase). - * - * There are four major types of modifications to credit balance, detailed below. - * - * ## Increment - * - * Credits (which optionally expire on a future date) can be added via the API ([Add Ledger - * Entry](create-ledger-entry)). The ledger entry for such an action will always contain the - * total eligible starting and ending balance for the customer at the time the entry was added - * to the ledger. - * - * ## Decrement - * - * Deductions can occur as a result of an API call to create a ledger entry (see - * [Add Ledger Entry](create-ledger-entry)), or automatically as a result of incurring usage. - * Both ledger entries present the `decrement` entry type. - * - * 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. - * - * By default, Orb uses an algorithm that automatically deducts from the _soonest expiring - * credit block_ first in order to ensure that all credits are utilized appropriately. As an - * example, if trial credits with an expiration date of 2 weeks from now are present for a - * customer, they will be used before any deductions take place from a non-expiring credit - * block. - * - * If there are multiple blocks with the same expiration date, Orb will deduct from the block - * with the _lower cost basis_ first (e.g. trial credits with a $0 cost basis before paid - * credits with a $5.00 cost basis). - * - * It's also possible for a single usage event's deduction to _span_ credit blocks. In this - * case, Orb will deduct from the next block, ending at the credit block which consists of - * unexpiring credits. Each of these deductions will lead to a _separate_ ledger entry, one per - * credit block that is deducted from. By default, the customer's total credit balance in Orb - * can be negative as a result of a decrement. - * - * ## Expiration change - * - * The expiry of credits can be changed as a result of the API (See - * [Add Ledger Entry](create-ledger-entry)). This will create a ledger entry that specifies the - * balance as well as the initial and target expiry dates. - * - * Note that for this entry type, `starting_balance` will equal `ending_balance`, and the - * `amount` represents the balance transferred. The credit block linked to the ledger entry is - * the source credit block from which there was an expiration change - * - * ## Credits expiry - * - * When a set of credits expire on pre-set expiration date, the customer's balance automatically - * reflects this change and adds an entry to the ledger indicating this event. Note that credit - * expiry should always happen close to a date boundary in the customer's timezone. - * - * ## Void initiated - * - * Credit blocks can be voided via the API. The `amount` on this entry corresponds to the number - * of credits that were remaining in the block at time of void. `void_reason` will be populated - * if the void is created with a reason. - * - * ## Void - * - * When a set of credits is voided, the customer's balance automatically reflects this change - * and adds an entry to the ledger indicating this event. - * - * ## Amendment - * - * When credits are added to a customer's balance as a result of a correction, this entry will - * be added to the ledger to indicate the adjustment of credits. - */ override fun list( params: CustomerCreditLedgerListParams, requestOptions: RequestOptions, - ): CustomerCreditLedgerListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("customers", params.getPathParam(0), "credits", "ledger") - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - .let { CustomerCreditLedgerListPage.of(this, params, it) } - } + ): CustomerCreditLedgerListPage = + // get /customers/{customer_id}/credits/ledger + withRawResponse().list(params, requestOptions).parse() - private val createEntryHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * This endpoint allows you to create a new ledger entry for a specified customer's balance. - * This can be used to increment balance, deduct credits, and change the expiry date of existing - * credits. - * - * ## Effects of adding a ledger entry - * 1. After calling this endpoint, [Fetch Credit Balance](fetch-customer-credits) will return a - * credit block that represents the changes (i.e. balance changes or transfers). - * 2. A ledger entry will be added to the credits ledger for this customer, and therefore - * returned in the [View Credits Ledger](fetch-customer-credits-ledger) response as well as - * serialized in the response to this request. In the case of deductions without a specified - * block, multiple ledger entries may be created if the deduction spans credit blocks. - * 3. If `invoice_settings` is specified, an invoice will be created that reflects the cost of - * the credits (based on `amount` and `per_unit_cost_basis`). - * - * ## Adding credits - * - * Adding credits is done by creating an entry of type `increment`. This requires the caller to - * specify a number of credits as well as an optional expiry date in `YYYY-MM-DD` format. Orb - * also recommends specifying a description to assist with auditing. When adding credits, the - * caller can also specify a cost basis per-credit, to indicate how much in USD a customer paid - * for a single credit in a block. This can later be used for revenue recognition. - * - * The following snippet illustrates a sample request body to increment credits which will - * expire in January of 2022. - * - * ```json - * { - * "entry_type": "increment", - * "amount": 100, - * "expiry_date": "2022-12-28", - * "per_unit_cost_basis": "0.20", - * "description": "Purchased 100 credits" - * } - * ``` - * - * Note that by default, Orb will always first increment any _negative_ balance in existing - * blocks before adding the remaining amount to the desired credit block. - * - * ### Invoicing for credits - * - * By default, Orb manipulates the credit ledger but does not charge for credits. However, if - * you pass `invoice_settings` in the body of this request, Orb will also generate a one-off - * invoice for the customer for the credits pre-purchase. Note that you _must_ provide the - * `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. - * - * ## 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. - * - * The following snippet illustrates a sample request body to decrement credits. - * - * ```json - * { - * "entry_type": "decrement", - * "amount": 20, - * "description": "Removing excess credits" - * } - * ``` - * - * ## Changing credits expiry - * - * If you'd like to change when existing credits expire, you should create a ledger entry of - * type `expiration_change`. For this entry, the required parameter `expiry_date` identifies the - * _originating_ block, and the required parameter `target_expiry_date` identifies when the - * transferred credits should now expire. A new credit block will be created with expiry date - * `target_expiry_date`, with the same cost basis data as the original credit block, if present. - * - * Note that the balance of the block with the given `expiry_date` must be at least equal to the - * desired transfer amount determined by the `amount` parameter. - * - * The following snippet illustrates a sample request body to extend the expiration date of - * credits by one year: - * ```json - * { - * "entry_type": "expiration_change", - * "amount": 10, - * "expiry_date": "2022-12-28", - * "block_id": "UiUhFWeLHPrBY4Ad", - * "target_expiry_date": "2023-12-28", - * "description": "Extending credit validity" - * } - * ``` - * - * ## Voiding credits - * - * If you'd like to void a credit block, create a ledger entry of type `void`. For this entry, - * `block_id` is required to identify the block, and `amount` indicates how many credits to - * void, up to the block's initial balance. Pass in a `void_reason` of `refund` if the void is - * due to a refund. - * - * ## Amendment - * - * If you'd like to undo a decrement on a credit block, create a ledger entry of type - * `amendment`. For this entry, `block_id` is required to identify the block that was originally - * decremented from, and `amount` indicates how many credits to return to the customer, up to - * the block's initial balance. - */ override fun createEntry( params: CustomerCreditLedgerCreateEntryParams, requestOptions: RequestOptions, - ): CustomerCreditLedgerCreateEntryResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("customers", params.getPathParam(0), "credits", "ledger_entry") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { createEntryHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } + ): CreditLedgerEntryModel = + // post /customers/{customer_id}/credits/ledger_entry + withRawResponse().createEntry(params, requestOptions).parse() - private val createEntryByExternalIdHandler: - Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * This endpoint allows you to create a new ledger entry for a specified customer's balance. - * This can be used to increment balance, deduct credits, and change the expiry date of existing - * credits. - * - * ## Effects of adding a ledger entry - * 1. After calling this endpoint, [Fetch Credit Balance](fetch-customer-credits) will return a - * credit block that represents the changes (i.e. balance changes or transfers). - * 2. A ledger entry will be added to the credits ledger for this customer, and therefore - * returned in the [View Credits Ledger](fetch-customer-credits-ledger) response as well as - * serialized in the response to this request. In the case of deductions without a specified - * block, multiple ledger entries may be created if the deduction spans credit blocks. - * 3. If `invoice_settings` is specified, an invoice will be created that reflects the cost of - * the credits (based on `amount` and `per_unit_cost_basis`). - * - * ## Adding credits - * - * Adding credits is done by creating an entry of type `increment`. This requires the caller to - * specify a number of credits as well as an optional expiry date in `YYYY-MM-DD` format. Orb - * also recommends specifying a description to assist with auditing. When adding credits, the - * caller can also specify a cost basis per-credit, to indicate how much in USD a customer paid - * for a single credit in a block. This can later be used for revenue recognition. - * - * The following snippet illustrates a sample request body to increment credits which will - * expire in January of 2022. - * - * ```json - * { - * "entry_type": "increment", - * "amount": 100, - * "expiry_date": "2022-12-28", - * "per_unit_cost_basis": "0.20", - * "description": "Purchased 100 credits" - * } - * ``` - * - * Note that by default, Orb will always first increment any _negative_ balance in existing - * blocks before adding the remaining amount to the desired credit block. - * - * ### Invoicing for credits - * - * By default, Orb manipulates the credit ledger but does not charge for credits. However, if - * you pass `invoice_settings` in the body of this request, Orb will also generate a one-off - * invoice for the customer for the credits pre-purchase. Note that you _must_ provide the - * `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. - * - * ## 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. - * - * The following snippet illustrates a sample request body to decrement credits. - * - * ```json - * { - * "entry_type": "decrement", - * "amount": 20, - * "description": "Removing excess credits" - * } - * ``` - * - * ## Changing credits expiry - * - * If you'd like to change when existing credits expire, you should create a ledger entry of - * type `expiration_change`. For this entry, the required parameter `expiry_date` identifies the - * _originating_ block, and the required parameter `target_expiry_date` identifies when the - * transferred credits should now expire. A new credit block will be created with expiry date - * `target_expiry_date`, with the same cost basis data as the original credit block, if present. - * - * Note that the balance of the block with the given `expiry_date` must be at least equal to the - * desired transfer amount determined by the `amount` parameter. - * - * The following snippet illustrates a sample request body to extend the expiration date of - * credits by one year: - * ```json - * { - * "entry_type": "expiration_change", - * "amount": 10, - * "expiry_date": "2022-12-28", - * "block_id": "UiUhFWeLHPrBY4Ad", - * "target_expiry_date": "2023-12-28", - * "description": "Extending credit validity" - * } - * ``` - * - * ## Voiding credits - * - * If you'd like to void a credit block, create a ledger entry of type `void`. For this entry, - * `block_id` is required to identify the block, and `amount` indicates how many credits to - * void, up to the block's initial balance. Pass in a `void_reason` of `refund` if the void is - * due to a refund. - * - * ## Amendment - * - * If you'd like to undo a decrement on a credit block, create a ledger entry of type - * `amendment`. For this entry, `block_id` is required to identify the block that was originally - * decremented from, and `amount` indicates how many credits to return to the customer, up to - * the block's initial balance. - */ override fun createEntryByExternalId( params: CustomerCreditLedgerCreateEntryByExternalIdParams, requestOptions: RequestOptions, - ): CustomerCreditLedgerCreateEntryByExternalIdResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments( - "customers", - "external_customer_id", - params.getPathParam(0), - "credits", - "ledger_entry", - ) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { createEntryByExternalIdHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } + ): CreditLedgerEntryModel = + // post /customers/external_customer_id/{external_customer_id}/credits/ledger_entry + withRawResponse().createEntryByExternalId(params, requestOptions).parse() - private val listByExternalIdHandler: - Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * The credits ledger provides _auditing_ functionality over Orb's credits system with a list of - * actions that have taken place to modify a customer's credit balance. This - * [paginated endpoint](/api-reference/pagination) lists these entries, starting from the most - * recent ledger entry. - * - * More details on using Orb's real-time credit feature are - * [here](/product-catalog/prepurchase). - * - * There are four major types of modifications to credit balance, detailed below. - * - * ## Increment - * - * Credits (which optionally expire on a future date) can be added via the API ([Add Ledger - * Entry](create-ledger-entry)). The ledger entry for such an action will always contain the - * total eligible starting and ending balance for the customer at the time the entry was added - * to the ledger. - * - * ## Decrement - * - * Deductions can occur as a result of an API call to create a ledger entry (see - * [Add Ledger Entry](create-ledger-entry)), or automatically as a result of incurring usage. - * Both ledger entries present the `decrement` entry type. - * - * 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. - * - * By default, Orb uses an algorithm that automatically deducts from the _soonest expiring - * credit block_ first in order to ensure that all credits are utilized appropriately. As an - * example, if trial credits with an expiration date of 2 weeks from now are present for a - * customer, they will be used before any deductions take place from a non-expiring credit - * block. - * - * If there are multiple blocks with the same expiration date, Orb will deduct from the block - * with the _lower cost basis_ first (e.g. trial credits with a $0 cost basis before paid - * credits with a $5.00 cost basis). - * - * It's also possible for a single usage event's deduction to _span_ credit blocks. In this - * case, Orb will deduct from the next block, ending at the credit block which consists of - * unexpiring credits. Each of these deductions will lead to a _separate_ ledger entry, one per - * credit block that is deducted from. By default, the customer's total credit balance in Orb - * can be negative as a result of a decrement. - * - * ## Expiration change - * - * The expiry of credits can be changed as a result of the API (See - * [Add Ledger Entry](create-ledger-entry)). This will create a ledger entry that specifies the - * balance as well as the initial and target expiry dates. - * - * Note that for this entry type, `starting_balance` will equal `ending_balance`, and the - * `amount` represents the balance transferred. The credit block linked to the ledger entry is - * the source credit block from which there was an expiration change - * - * ## Credits expiry - * - * When a set of credits expire on pre-set expiration date, the customer's balance automatically - * reflects this change and adds an entry to the ledger indicating this event. Note that credit - * expiry should always happen close to a date boundary in the customer's timezone. - * - * ## Void initiated - * - * Credit blocks can be voided via the API. The `amount` on this entry corresponds to the number - * of credits that were remaining in the block at time of void. `void_reason` will be populated - * if the void is created with a reason. - * - * ## Void - * - * When a set of credits is voided, the customer's balance automatically reflects this change - * and adds an entry to the ledger indicating this event. - * - * ## Amendment - * - * When credits are added to a customer's balance as a result of a correction, this entry will - * be added to the ledger to indicate the adjustment of credits. - */ override fun listByExternalId( params: CustomerCreditLedgerListByExternalIdParams, requestOptions: RequestOptions, - ): CustomerCreditLedgerListByExternalIdPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "customers", - "external_customer_id", - params.getPathParam(0), - "credits", - "ledger", - ) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listByExternalIdHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): CustomerCreditLedgerListByExternalIdPage = + // get /customers/external_customer_id/{external_customer_id}/credits/ledger + withRawResponse().listByExternalId(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + LedgerService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: CustomerCreditLedgerListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("customers", params.getPathParam(0), "credits", "ledger") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + CustomerCreditLedgerListPage.of( + LedgerServiceImpl(clientOptions), + params, + it, + ) + } + } + } + + private val createEntryHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun createEntry( + params: CustomerCreditLedgerCreateEntryParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("customers", params.getPathParam(0), "credits", "ledger_entry") + .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 response.parseable { + response + .use { createEntryHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val createEntryByExternalIdHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun createEntryByExternalId( + params: CustomerCreditLedgerCreateEntryByExternalIdParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments( + "customers", + "external_customer_id", + params.getPathParam(0), + "credits", + "ledger_entry", + ) + .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 response.parseable { + response + .use { createEntryByExternalIdHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listByExternalIdHandler: + Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun listByExternalId( + params: CustomerCreditLedgerListByExternalIdParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "customers", + "external_customer_id", + params.getPathParam(0), + "credits", + "ledger", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listByExternalIdHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + CustomerCreditLedgerListByExternalIdPage.of( + LedgerServiceImpl(clientOptions), + params, + it, + ) + } } - .let { CustomerCreditLedgerListByExternalIdPage.of(this, params, it) } + } } } 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 efdb4d593..af2280d67 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 @@ -4,20 +4,27 @@ package com.withorb.api.services.blocking.customers.credits +import com.google.errorprone.annotations.MustBeClosed 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.CustomerCreditTopUpCreateByExternalIdParams -import com.withorb.api.models.CustomerCreditTopUpCreateByExternalIdResponse import com.withorb.api.models.CustomerCreditTopUpCreateParams -import com.withorb.api.models.CustomerCreditTopUpCreateResponse import com.withorb.api.models.CustomerCreditTopUpDeleteByExternalIdParams import com.withorb.api.models.CustomerCreditTopUpDeleteParams import com.withorb.api.models.CustomerCreditTopUpListByExternalIdPage import com.withorb.api.models.CustomerCreditTopUpListByExternalIdParams import com.withorb.api.models.CustomerCreditTopUpListPage import com.withorb.api.models.CustomerCreditTopUpListParams +import com.withorb.api.models.TopUpModel interface TopUpService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * This endpoint allows you to create a new top-up for a specified customer's balance. While * this top-up is active, the customer's balance will added in increments of the specified @@ -30,7 +37,7 @@ interface TopUpService { fun create( params: CustomerCreditTopUpCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CustomerCreditTopUpCreateResponse + ): TopUpModel /** List top-ups */ @JvmOverloads @@ -61,7 +68,7 @@ interface TopUpService { fun createByExternalId( params: CustomerCreditTopUpCreateByExternalIdParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CustomerCreditTopUpCreateByExternalIdResponse + ): TopUpModel /** * This deactivates the top-up and voids any invoices associated with pending credit blocks @@ -79,4 +86,78 @@ interface TopUpService { params: CustomerCreditTopUpListByExternalIdParams, requestOptions: RequestOptions = RequestOptions.none(), ): CustomerCreditTopUpListByExternalIdPage + + /** A view of [TopUpService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /customers/{customer_id}/credits/top_ups`, but is + * otherwise the same as [TopUpService.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: CustomerCreditTopUpCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /customers/{customer_id}/credits/top_ups`, but is + * otherwise the same as [TopUpService.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: CustomerCreditTopUpListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `delete + * /customers/{customer_id}/credits/top_ups/{top_up_id}`, but is otherwise the same as + * [TopUpService.delete]. + */ + @JvmOverloads + @MustBeClosed + fun delete( + params: CustomerCreditTopUpDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** + * Returns a raw HTTP response for `post + * /customers/external_customer_id/{external_customer_id}/credits/top_ups`, but is otherwise + * the same as [TopUpService.createByExternalId]. + */ + @JvmOverloads + @MustBeClosed + fun createByExternalId( + params: CustomerCreditTopUpCreateByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `delete + * /customers/external_customer_id/{external_customer_id}/credits/top_ups/{top_up_id}`, but + * is otherwise the same as [TopUpService.deleteByExternalId]. + */ + @JvmOverloads + @MustBeClosed + fun deleteByExternalId( + params: CustomerCreditTopUpDeleteByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** + * Returns a raw HTTP response for `get + * /customers/external_customer_id/{external_customer_id}/credits/top_ups`, but is otherwise + * the same as [TopUpService.listByExternalId]. + */ + @JvmOverloads + @MustBeClosed + fun listByExternalId( + params: CustomerCreditTopUpListByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } 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 275ae5f12..f87309e89 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 @@ -10,206 +10,257 @@ import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler 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.json +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.errors.OrbError import com.withorb.api.models.CustomerCreditTopUpCreateByExternalIdParams -import com.withorb.api.models.CustomerCreditTopUpCreateByExternalIdResponse import com.withorb.api.models.CustomerCreditTopUpCreateParams -import com.withorb.api.models.CustomerCreditTopUpCreateResponse import com.withorb.api.models.CustomerCreditTopUpDeleteByExternalIdParams import com.withorb.api.models.CustomerCreditTopUpDeleteParams import com.withorb.api.models.CustomerCreditTopUpListByExternalIdPage import com.withorb.api.models.CustomerCreditTopUpListByExternalIdParams import com.withorb.api.models.CustomerCreditTopUpListPage import com.withorb.api.models.CustomerCreditTopUpListParams +import com.withorb.api.models.TopUpModel class TopUpServiceImpl internal constructor(private val clientOptions: ClientOptions) : TopUpService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: TopUpService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): TopUpService.WithRawResponse = withRawResponse - /** - * This endpoint allows you to create a new top-up for a specified customer's balance. While - * this top-up is active, the customer's balance will added in increments of the specified - * amount whenever the balance reaches the specified threshold. - * - * If a top-up already exists for this customer in the same currency, the existing top-up will - * be replaced. - */ override fun create( params: CustomerCreditTopUpCreateParams, requestOptions: RequestOptions, - ): CustomerCreditTopUpCreateResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("customers", params.getPathParam(0), "credits", "top_ups") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + ): TopUpModel = + // post /customers/{customer_id}/credits/top_ups + withRawResponse().create(params, requestOptions).parse() - /** List top-ups */ override fun list( params: CustomerCreditTopUpListParams, requestOptions: RequestOptions, - ): CustomerCreditTopUpListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("customers", params.getPathParam(0), "credits", "top_ups") - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - .let { CustomerCreditTopUpListPage.of(this, params, it) } - } - - private val deleteHandler: Handler = emptyHandler().withErrorHandler(errorHandler) + ): CustomerCreditTopUpListPage = + // get /customers/{customer_id}/credits/top_ups + withRawResponse().list(params, requestOptions).parse() - /** - * This deactivates the top-up and voids any invoices associated with pending credit blocks - * purchased through the top-up. - */ override fun delete(params: CustomerCreditTopUpDeleteParams, requestOptions: RequestOptions) { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments( - "customers", - params.getPathParam(0), - "credits", - "top_ups", - params.getPathParam(1), - ) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - response.use { deleteHandler.handle(it) } + // delete /customers/{customer_id}/credits/top_ups/{top_up_id} + withRawResponse().delete(params, requestOptions) } - private val createByExternalIdHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * This endpoint allows you to create a new top-up for a specified customer's balance. While - * this top-up is active, the customer's balance will added in increments of the specified - * amount whenever the balance reaches the specified threshold. - * - * If a top-up already exists for this customer in the same currency, the existing top-up will - * be replaced. - */ override fun createByExternalId( params: CustomerCreditTopUpCreateByExternalIdParams, requestOptions: RequestOptions, - ): CustomerCreditTopUpCreateByExternalIdResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments( - "customers", - "external_customer_id", - params.getPathParam(0), - "credits", - "top_ups", - ) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { createByExternalIdHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } + ): TopUpModel = + // post /customers/external_customer_id/{external_customer_id}/credits/top_ups + withRawResponse().createByExternalId(params, requestOptions).parse() - private val deleteByExternalIdHandler: Handler = - emptyHandler().withErrorHandler(errorHandler) - - /** - * This deactivates the top-up and voids any invoices associated with pending credit blocks - * purchased through the top-up. - */ override fun deleteByExternalId( params: CustomerCreditTopUpDeleteByExternalIdParams, requestOptions: RequestOptions, ) { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments( - "customers", - "external_customer_id", - params.getPathParam(0), - "credits", - "top_ups", - params.getPathParam(1), - ) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - response.use { deleteByExternalIdHandler.handle(it) } + // delete /customers/external_customer_id/{external_customer_id}/credits/top_ups/{top_up_id} + withRawResponse().deleteByExternalId(params, requestOptions) } - private val listByExternalIdHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** List top-ups by external ID */ override fun listByExternalId( params: CustomerCreditTopUpListByExternalIdParams, requestOptions: RequestOptions, - ): CustomerCreditTopUpListByExternalIdPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "customers", - "external_customer_id", - params.getPathParam(0), - "credits", - "top_ups", - ) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listByExternalIdHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): CustomerCreditTopUpListByExternalIdPage = + // get /customers/external_customer_id/{external_customer_id}/credits/top_ups + withRawResponse().listByExternalId(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TopUpService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: CustomerCreditTopUpCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("customers", params.getPathParam(0), "credits", "top_ups") + .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 response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: CustomerCreditTopUpListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("customers", params.getPathParam(0), "credits", "top_ups") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + CustomerCreditTopUpListPage.of(TopUpServiceImpl(clientOptions), params, it) + } + } + } + + private val deleteHandler: Handler = emptyHandler().withErrorHandler(errorHandler) + + override fun delete( + params: CustomerCreditTopUpDeleteParams, + requestOptions: RequestOptions, + ): HttpResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments( + "customers", + params.getPathParam(0), + "credits", + "top_ups", + params.getPathParam(1), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { response.use { deleteHandler.handle(it) } } + } + + private val createByExternalIdHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun createByExternalId( + params: CustomerCreditTopUpCreateByExternalIdParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments( + "customers", + "external_customer_id", + params.getPathParam(0), + "credits", + "top_ups", + ) + .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 response.parseable { + response + .use { createByExternalIdHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val deleteByExternalIdHandler: Handler = + emptyHandler().withErrorHandler(errorHandler) + + override fun deleteByExternalId( + params: CustomerCreditTopUpDeleteByExternalIdParams, + requestOptions: RequestOptions, + ): HttpResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments( + "customers", + "external_customer_id", + params.getPathParam(0), + "credits", + "top_ups", + params.getPathParam(1), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { response.use { deleteByExternalIdHandler.handle(it) } } + } + + private val listByExternalIdHandler: + Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun listByExternalId( + params: CustomerCreditTopUpListByExternalIdParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "customers", + "external_customer_id", + params.getPathParam(0), + "credits", + "top_ups", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listByExternalIdHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + CustomerCreditTopUpListByExternalIdPage.of( + TopUpServiceImpl(clientOptions), + params, + it, + ) + } } - .let { CustomerCreditTopUpListByExternalIdPage.of(this, params, it) } + } } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdService.kt index ebb4175e3..2df3b3ccf 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdService.kt @@ -4,16 +4,42 @@ package com.withorb.api.services.blocking.dimensionalPriceGroups +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions -import com.withorb.api.models.DimensionalPriceGroup +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams +import com.withorb.api.models.DimensionalPriceGroupModel interface ExternalDimensionalPriceGroupIdService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Fetch dimensional price group by external ID */ @JvmOverloads fun retrieve( params: DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): DimensionalPriceGroup + ): DimensionalPriceGroupModel + + /** + * A view of [ExternalDimensionalPriceGroupIdService] that provides access to raw HTTP responses + * for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get + * /dimensional_price_groups/external_dimensional_price_group_id/{external_dimensional_price_group_id}`, + * but is otherwise the same as [ExternalDimensionalPriceGroupIdService.retrieve]. + */ + @JvmOverloads + @MustBeClosed + fun retrieve( + params: DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceImpl.kt index a0c1a0cca..f315b7ae1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceImpl.kt @@ -10,42 +10,66 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest 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.errors.OrbError -import com.withorb.api.models.DimensionalPriceGroup import com.withorb.api.models.DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams +import com.withorb.api.models.DimensionalPriceGroupModel class ExternalDimensionalPriceGroupIdServiceImpl internal constructor(private val clientOptions: ClientOptions) : ExternalDimensionalPriceGroupIdService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ExternalDimensionalPriceGroupIdService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): ExternalDimensionalPriceGroupIdService.WithRawResponse = + withRawResponse - /** Fetch dimensional price group by external ID */ override fun retrieve( params: DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams, requestOptions: RequestOptions, - ): DimensionalPriceGroup { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments( - "dimensional_price_groups", - "external_dimensional_price_group_id", - params.getPathParam(0), - ) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): DimensionalPriceGroupModel = + // get + // /dimensional_price_groups/external_dimensional_price_group_id/{external_dimensional_price_group_id} + withRawResponse().retrieve(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ExternalDimensionalPriceGroupIdService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "dimensional_price_groups", + "external_dimensional_price_group_id", + params.getPathParam(0), + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } 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 ee5e02a4e..1a60d4985 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 @@ -4,20 +4,24 @@ package com.withorb.api.services.blocking.events +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor +import com.withorb.api.models.BackfillModel import com.withorb.api.models.EventBackfillCloseParams -import com.withorb.api.models.EventBackfillCloseResponse import com.withorb.api.models.EventBackfillCreateParams -import com.withorb.api.models.EventBackfillCreateResponse import com.withorb.api.models.EventBackfillFetchParams -import com.withorb.api.models.EventBackfillFetchResponse import com.withorb.api.models.EventBackfillListPage import com.withorb.api.models.EventBackfillListParams import com.withorb.api.models.EventBackfillRevertParams -import com.withorb.api.models.EventBackfillRevertResponse interface BackfillService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * 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: @@ -52,7 +56,7 @@ interface BackfillService { fun create( params: EventBackfillCreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): EventBackfillCreateResponse + ): BackfillModel /** * This endpoint returns a list of all backfills in a list format. @@ -88,14 +92,14 @@ interface BackfillService { fun close( params: EventBackfillCloseParams, requestOptions: RequestOptions = RequestOptions.none(), - ): EventBackfillCloseResponse + ): BackfillModel /** This endpoint is used to fetch a backfill given an identifier. */ @JvmOverloads fun fetch( params: EventBackfillFetchParams, requestOptions: RequestOptions = RequestOptions.none(), - ): EventBackfillFetchResponse + ): BackfillModel /** * Reverting a backfill undoes all the effects of closing the backfill. If the backfill is @@ -109,5 +113,72 @@ interface BackfillService { fun revert( params: EventBackfillRevertParams, requestOptions: RequestOptions = RequestOptions.none(), - ): EventBackfillRevertResponse + ): BackfillModel + + /** A view of [BackfillService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /events/backfills`, but is otherwise the same as + * [BackfillService.create]. + */ + @JvmOverloads + @MustBeClosed + fun create( + params: EventBackfillCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /events/backfills`, but is otherwise the same as + * [BackfillService.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: EventBackfillListParams = EventBackfillListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /events/backfills`, but is otherwise the same as + * [BackfillService.list]. + */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(EventBackfillListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /events/backfills/{backfill_id}/close`, but is + * otherwise the same as [BackfillService.close]. + */ + @JvmOverloads + @MustBeClosed + fun close( + params: EventBackfillCloseParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /events/backfills/{backfill_id}`, but is otherwise + * the same as [BackfillService.fetch]. + */ + @JvmOverloads + @MustBeClosed + fun fetch( + params: EventBackfillFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /events/backfills/{backfill_id}/revert`, but is + * otherwise the same as [BackfillService.revert]. + */ + @JvmOverloads + @MustBeClosed + fun revert( + params: EventBackfillRevertParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } 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 18286734e..5b752f39b 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 @@ -10,198 +10,203 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest import com.withorb.api.core.http.HttpResponse.Handler -import com.withorb.api.core.json +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.errors.OrbError +import com.withorb.api.models.BackfillModel import com.withorb.api.models.EventBackfillCloseParams -import com.withorb.api.models.EventBackfillCloseResponse import com.withorb.api.models.EventBackfillCreateParams -import com.withorb.api.models.EventBackfillCreateResponse import com.withorb.api.models.EventBackfillFetchParams -import com.withorb.api.models.EventBackfillFetchResponse import com.withorb.api.models.EventBackfillListPage import com.withorb.api.models.EventBackfillListParams import com.withorb.api.models.EventBackfillRevertParams -import com.withorb.api.models.EventBackfillRevertResponse class BackfillServiceImpl internal constructor(private val clientOptions: ClientOptions) : BackfillService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * 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`). - * 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 - * worry about your customers seeing partially updated usage data. Backfills are also - * reversible, so you’ll be able to revert a backfill if you’ve made a mistake. - * - * This endpoint will return a backfill object, which contains an `id`. That `id` can then be - * used as the `backfill_id` query parameter to the event ingestion endpoint to associate - * ingested events with this backfill. The effects (e.g. updated usage graphs) of this backfill - * will not take place until the backfill is closed. - * - * If the `replace_existing_events` is `true`, existing events in the backfill's timeframe will - * be replaced with the newly ingested events associated with the backfill. If `false`, newly - * ingested events will be added to the existing events. - * - * If a `customer_id` or `external_customer_id` is specified, the backfill will only affect - * events for that customer. If neither is specified, the backfill will affect all customers. - * - * When `replace_existing_events` is `true`, this indicates that existing events in the - * timeframe should no longer be counted towards invoiced usage. In this scenario, the parameter - * `filter` can be optionally added which enables filtering using - * [computed properties](/extensibility/advanced-metrics#computed-properties). The - * expressiveness of computed properties allows you to deprecate existing events based on both a - * period of time and specific property values. - */ + private val withRawResponse: BackfillService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): BackfillService.WithRawResponse = withRawResponse + override fun create( params: EventBackfillCreateParams, requestOptions: RequestOptions, - ): EventBackfillCreateResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("events", "backfills") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } + ): BackfillModel = + // post /events/backfills + withRawResponse().create(params, requestOptions).parse() - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * This endpoint returns a list of all backfills in a list format. - * - * 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). - */ override fun list( params: EventBackfillListParams, requestOptions: RequestOptions, - ): EventBackfillListPage { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("events", "backfills") - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - .let { EventBackfillListPage.of(this, params, it) } - } - - private val closeHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + ): EventBackfillListPage = + // get /events/backfills + withRawResponse().list(params, requestOptions).parse() - /** - * Closing a backfill makes the updated usage visible in Orb. Upon closing a backfill, Orb will - * asynchronously reflect the updated usage in invoice amounts and usage graphs. Once all of the - * updates are complete, the backfill's status will transition to `reflected`. - */ override fun close( params: EventBackfillCloseParams, requestOptions: RequestOptions, - ): EventBackfillCloseResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("events", "backfills", params.getPathParam(0), "close") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { closeHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } + ): BackfillModel = + // post /events/backfills/{backfill_id}/close + withRawResponse().close(params, requestOptions).parse() - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** This endpoint is used to fetch a backfill given an identifier. */ override fun fetch( params: EventBackfillFetchParams, requestOptions: RequestOptions, - ): EventBackfillFetchResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("events", "backfills", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } + ): BackfillModel = + // get /events/backfills/{backfill_id} + withRawResponse().fetch(params, requestOptions).parse() - private val revertHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** - * Reverting a backfill undoes all the effects of closing the backfill. If the backfill is - * reflected, the status will transition to `pending_revert` while the effects of the backfill - * are undone. Once all effects are undone, the backfill will transition to `reverted`. - * - * If a backfill is reverted before its closed, no usage will be updated as a result of the - * backfill and it will immediately transition to `reverted`. - */ override fun revert( params: EventBackfillRevertParams, requestOptions: RequestOptions, - ): EventBackfillRevertResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("events", "backfills", params.getPathParam(0), "revert") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { revertHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): BackfillModel = + // post /events/backfills/{backfill_id}/revert + withRawResponse().revert(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BackfillService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun create( + params: EventBackfillCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("events", "backfills") + .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 response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: EventBackfillListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("events", "backfills") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + EventBackfillListPage.of(BackfillServiceImpl(clientOptions), params, it) + } + } + } + + private val closeHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun close( + params: EventBackfillCloseParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("events", "backfills", params.getPathParam(0), "close") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { closeHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetch( + params: EventBackfillFetchParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("events", "backfills", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val revertHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun revert( + params: EventBackfillRevertParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("events", "backfills", params.getPathParam(0), "revert") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { revertHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } 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 ba6f13036..cd540600b 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 @@ -4,12 +4,19 @@ package com.withorb.api.services.blocking.events +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.EventVolumeListParams import com.withorb.api.models.EventVolumes interface VolumeService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * This endpoint returns the event volume for an account in a * [paginated list format](/api-reference/pagination). @@ -28,4 +35,19 @@ interface VolumeService { params: EventVolumeListParams, requestOptions: RequestOptions = RequestOptions.none(), ): EventVolumes + + /** A view of [VolumeService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /events/volume`, but is otherwise the same as + * [VolumeService.list]. + */ + @JvmOverloads + @MustBeClosed + fun list( + params: EventVolumeListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } 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 2bec8c2fa..c4ec970d5 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 @@ -10,6 +10,8 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest 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.errors.OrbError import com.withorb.api.models.EventVolumeListParams @@ -18,38 +20,45 @@ import com.withorb.api.models.EventVolumes class VolumeServiceImpl internal constructor(private val clientOptions: ClientOptions) : VolumeService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint returns the event volume for an account in a - * [paginated list format](/api-reference/pagination). - * - * The event volume is aggregated by the hour and the - * [timestamp](/api-reference/event/ingest-events) field is used to determine which hour an - * event is associated with. Note, this means that late-arriving events increment the volume - * count for the hour window the timestamp is in, not the latest hour window. - * - * Each item in the response contains the count of events aggregated by the hour where the start - * and end time are hour-aligned and in UTC. When a specific timestamp is passed in for either - * start or end time, the response includes the hours the timestamp falls in. - */ - override fun list(params: EventVolumeListParams, requestOptions: RequestOptions): EventVolumes { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("events", "volume") - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + private val withRawResponse: VolumeService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): VolumeService.WithRawResponse = withRawResponse + + override fun list(params: EventVolumeListParams, requestOptions: RequestOptions): EventVolumes = + // get /events/volume + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + VolumeService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun list( + params: EventVolumeListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("events", "volume") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.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 a21cf3d29..ac7b93ca6 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 @@ -4,13 +4,20 @@ package com.withorb.api.services.blocking.plans +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions -import com.withorb.api.models.Plan +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.PlanExternalPlanIdFetchParams import com.withorb.api.models.PlanExternalPlanIdUpdateParams +import com.withorb.api.models.PlanModel interface ExternalPlanIdService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * This endpoint can be used to update the `external_plan_id`, and `metadata` of an existing * plan. @@ -21,7 +28,7 @@ interface ExternalPlanIdService { fun update( params: PlanExternalPlanIdUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Plan + ): PlanModel /** * This endpoint is used to fetch [plan](/core-concepts##plan-and-price) details given an @@ -44,5 +51,33 @@ interface ExternalPlanIdService { fun fetch( params: PlanExternalPlanIdFetchParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Plan + ): PlanModel + + /** + * A view of [ExternalPlanIdService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `put /plans/external_plan_id/{external_plan_id}`, but is + * otherwise the same as [ExternalPlanIdService.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: PlanExternalPlanIdUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /plans/external_plan_id/{external_plan_id}`, but is + * otherwise the same as [ExternalPlanIdService.fetch]. + */ + @JvmOverloads + @MustBeClosed + fun fetch( + params: PlanExternalPlanIdFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } 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 d42483623..a2aa8938c 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 @@ -10,85 +10,94 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest import com.withorb.api.core.http.HttpResponse.Handler -import com.withorb.api.core.json +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.errors.OrbError -import com.withorb.api.models.Plan import com.withorb.api.models.PlanExternalPlanIdFetchParams import com.withorb.api.models.PlanExternalPlanIdUpdateParams +import com.withorb.api.models.PlanModel class ExternalPlanIdServiceImpl internal constructor(private val clientOptions: ClientOptions) : ExternalPlanIdService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ExternalPlanIdService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): ExternalPlanIdService.WithRawResponse = withRawResponse - /** - * This endpoint can be used to update the `external_plan_id`, and `metadata` of an existing - * plan. - * - * Other fields on a customer are currently immutable. - */ override fun update( params: PlanExternalPlanIdUpdateParams, requestOptions: RequestOptions, - ): Plan { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("plans", "external_plan_id", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } + ): PlanModel = + // put /plans/external_plan_id/{external_plan_id} + withRawResponse().update(params, requestOptions).parse() - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint is used to fetch [plan](/core-concepts##plan-and-price) details given an - * external_plan_id identifier. It returns information about the prices included in the plan and - * their configuration, as well as the product that the plan is attached to. - * - * If multiple plans are found to contain the specified external_plan_id, the active plans will - * take priority over archived ones, and among those, the endpoint will return the most recently - * created plan. - * - * ## Serialized prices - * - * Orb supports a few different pricing models out of the box. Each of these models is - * serialized differently in a given [Price](/core-concepts#plan-and-price) object. The - * `model_type` field determines the key for the configuration object that is present. A - * detailed explanation of price types can be found in the - * [Price schema](/core-concepts#plan-and-price). " - */ override fun fetch( params: PlanExternalPlanIdFetchParams, requestOptions: RequestOptions, - ): Plan { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("plans", "external_plan_id", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): PlanModel = + // get /plans/external_plan_id/{external_plan_id} + withRawResponse().fetch(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ExternalPlanIdService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: PlanExternalPlanIdUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("plans", "external_plan_id", params.getPathParam(0)) + .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 response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetch( + params: PlanExternalPlanIdFetchParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("plans", "external_plan_id", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } 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 23878048b..457dc4846 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 @@ -4,13 +4,20 @@ package com.withorb.api.services.blocking.prices +import com.google.errorprone.annotations.MustBeClosed import com.withorb.api.core.RequestOptions -import com.withorb.api.models.Price +import com.withorb.api.core.http.HttpResponseFor import com.withorb.api.models.PriceExternalPriceIdFetchParams import com.withorb.api.models.PriceExternalPriceIdUpdateParams +import com.withorb.api.models.PriceModel interface ExternalPriceIdService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** * 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. @@ -19,7 +26,7 @@ interface ExternalPriceIdService { fun update( params: PriceExternalPriceIdUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Price + ): PriceModel /** * This endpoint returns a price given an external price id. See the @@ -30,5 +37,34 @@ interface ExternalPriceIdService { fun fetch( params: PriceExternalPriceIdFetchParams, requestOptions: RequestOptions = RequestOptions.none(), - ): Price + ): PriceModel + + /** + * A view of [ExternalPriceIdService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `put /prices/external_price_id/{external_price_id}`, but + * is otherwise the same as [ExternalPriceIdService.update]. + */ + @JvmOverloads + @MustBeClosed + fun update( + params: PriceExternalPriceIdUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /prices/external_price_id/{external_price_id}`, but + * is otherwise the same as [ExternalPriceIdService.fetch]. + */ + @JvmOverloads + @MustBeClosed + fun fetch( + params: PriceExternalPriceIdFetchParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } 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 1e2a6c9ed..5ae11e259 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 @@ -10,71 +10,94 @@ import com.withorb.api.core.handlers.withErrorHandler import com.withorb.api.core.http.HttpMethod import com.withorb.api.core.http.HttpRequest import com.withorb.api.core.http.HttpResponse.Handler -import com.withorb.api.core.json +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.errors.OrbError -import com.withorb.api.models.Price import com.withorb.api.models.PriceExternalPriceIdFetchParams import com.withorb.api.models.PriceExternalPriceIdUpdateParams +import com.withorb.api.models.PriceModel class ExternalPriceIdServiceImpl internal constructor(private val clientOptions: ClientOptions) : ExternalPriceIdService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ExternalPriceIdService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + override fun withRawResponse(): ExternalPriceIdService.WithRawResponse = withRawResponse - /** - * 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. - */ override fun update( params: PriceExternalPriceIdUpdateParams, requestOptions: RequestOptions, - ): Price { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("prices", "external_price_id", params.getPathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } - } - } + ): PriceModel = + // put /prices/external_price_id/{external_price_id} + withRawResponse().update(params, requestOptions).parse() - private val fetchHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** - * This endpoint returns a price given an external price id. See the - * [price creation API](/api-reference/price/create-price) for more information about external - * price aliases. - */ override fun fetch( params: PriceExternalPriceIdFetchParams, requestOptions: RequestOptions, - ): Price { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("prices", "external_price_id", params.getPathParam(0)) - .build() - .prepare(clientOptions, params) - val response = clientOptions.httpClient.execute(request, requestOptions) - return response - .use { fetchHandler.handle(it) } - .also { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - it.validate() - } + ): PriceModel = + // get /prices/external_price_id/{external_price_id} + withRawResponse().fetch(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ExternalPriceIdService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: PriceExternalPriceIdUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("prices", "external_price_id", params.getPathParam(0)) + .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 response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val fetchHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun fetch( + params: PriceExternalPriceIdFetchParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("prices", "external_price_id", params.getPathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { fetchHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } + } } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/AddCreditTopUpRequestTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/AddCreditTopUpRequestTest.kt new file mode 100644 index 000000000..1643cd921 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/AddCreditTopUpRequestTest.kt @@ -0,0 +1,51 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class AddCreditTopUpRequestTest { + + @Test + fun createAddCreditTopUpRequest() { + val addCreditTopUpRequest = + AddCreditTopUpRequest.builder() + .amount("amount") + .currency("currency") + .invoiceSettings( + AddCreditTopUpRequest.InvoiceSettings.builder() + .autoCollection(true) + .netTerms(0L) + .memo("memo") + .requireSuccessfulPayment(true) + .build() + ) + .perUnitCostBasis("per_unit_cost_basis") + .threshold("threshold") + .activeFrom(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiresAfter(0L) + .expiresAfterUnit(AddCreditTopUpRequest.ExpiresAfterUnit.DAY) + .build() + assertThat(addCreditTopUpRequest).isNotNull + assertThat(addCreditTopUpRequest.amount()).isEqualTo("amount") + assertThat(addCreditTopUpRequest.currency()).isEqualTo("currency") + assertThat(addCreditTopUpRequest.invoiceSettings()) + .isEqualTo( + AddCreditTopUpRequest.InvoiceSettings.builder() + .autoCollection(true) + .netTerms(0L) + .memo("memo") + .requireSuccessfulPayment(true) + .build() + ) + assertThat(addCreditTopUpRequest.perUnitCostBasis()).isEqualTo("per_unit_cost_basis") + assertThat(addCreditTopUpRequest.threshold()).isEqualTo("threshold") + assertThat(addCreditTopUpRequest.activeFrom()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(addCreditTopUpRequest.expiresAfter()).contains(0L) + assertThat(addCreditTopUpRequest.expiresAfterUnit()) + .contains(AddCreditTopUpRequest.ExpiresAfterUnit.DAY) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/AddSubscriptionAdjustmentParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/AddSubscriptionAdjustmentParamsTest.kt new file mode 100644 index 000000000..516ef9486 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/AddSubscriptionAdjustmentParamsTest.kt @@ -0,0 +1,53 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class AddSubscriptionAdjustmentParamsTest { + + @Test + fun createAddSubscriptionAdjustmentParams() { + val addSubscriptionAdjustmentParams = + AddSubscriptionAdjustmentParams.builder() + .adjustment( + NewAdjustmentModel.NewPercentageDiscount.builder() + .adjustmentType( + NewAdjustmentModel.NewPercentageDiscount.AdjustmentType + .PERCENTAGE_DISCOUNT + ) + .addAppliesToPriceId("price_1") + .addAppliesToPriceId("price_2") + .percentageDiscount(0.0) + .isInvoiceLevel(true) + .build() + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .planPhaseOrder(0L) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + assertThat(addSubscriptionAdjustmentParams).isNotNull + assertThat(addSubscriptionAdjustmentParams.adjustment()) + .isEqualTo( + NewAdjustmentModel.ofPercentageDiscount( + NewAdjustmentModel.NewPercentageDiscount.builder() + .adjustmentType( + NewAdjustmentModel.NewPercentageDiscount.AdjustmentType + .PERCENTAGE_DISCOUNT + ) + .addAppliesToPriceId("price_1") + .addAppliesToPriceId("price_2") + .percentageDiscount(0.0) + .isInvoiceLevel(true) + .build() + ) + ) + assertThat(addSubscriptionAdjustmentParams.endDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(addSubscriptionAdjustmentParams.planPhaseOrder()).contains(0L) + assertThat(addSubscriptionAdjustmentParams.startDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/AddSubscriptionPriceParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/AddSubscriptionPriceParamsTest.kt new file mode 100644 index 000000000..88ca0b111 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/AddSubscriptionPriceParamsTest.kt @@ -0,0 +1,144 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.JsonValue +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class AddSubscriptionPriceParamsTest { + + @Test + fun createAddSubscriptionPriceParams() { + val addSubscriptionPriceParams = + AddSubscriptionPriceParams.builder() + .allocationPrice( + NewAllocationPriceModel.builder() + .amount("10.00") + .cadence(NewAllocationPriceModel.Cadence.ONE_TIME) + .currency("USD") + .expiresAtEndOfCadence(true) + .build() + ) + .addDiscount( + DiscountOverrideModel.builder() + .discountType(DiscountOverrideModel.DiscountType.PERCENTAGE) + .amountDiscount("amount_discount") + .percentageDiscount(0.15) + .usageDiscount(0.0) + .build() + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalPriceId("external_price_id") + .maximumAmount("1.23") + .minimumAmount("1.23") + .planPhaseOrder(0L) + .price( + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.builder() + .cadence(NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Cadence.ANNUAL) + .itemId("item_id") + .modelType( + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.ModelType.UNIT + ) + .name("Annual fee") + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfigurationModel.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfigurationModel.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .currency("currency") + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") + .invoicingCycleConfiguration( + NewBillingCycleConfigurationModel.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfigurationModel.DurationUnit.DAY) + .build() + ) + .metadata( + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) + .priceId("h74gfhdjvn7ujokd") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + assertThat(addSubscriptionPriceParams).isNotNull + assertThat(addSubscriptionPriceParams.allocationPrice()) + .contains( + NewAllocationPriceModel.builder() + .amount("10.00") + .cadence(NewAllocationPriceModel.Cadence.ONE_TIME) + .currency("USD") + .expiresAtEndOfCadence(true) + .build() + ) + assertThat(addSubscriptionPriceParams.discounts().get()) + .containsExactly( + DiscountOverrideModel.builder() + .discountType(DiscountOverrideModel.DiscountType.PERCENTAGE) + .amountDiscount("amount_discount") + .percentageDiscount(0.15) + .usageDiscount(0.0) + .build() + ) + assertThat(addSubscriptionPriceParams.endDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(addSubscriptionPriceParams.externalPriceId()).contains("external_price_id") + assertThat(addSubscriptionPriceParams.maximumAmount()).contains("1.23") + assertThat(addSubscriptionPriceParams.minimumAmount()).contains("1.23") + assertThat(addSubscriptionPriceParams.planPhaseOrder()).contains(0L) + assertThat(addSubscriptionPriceParams.price()) + .contains( + NewSubscriptionPriceModel.ofUnitPrice( + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.builder() + .cadence(NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Cadence.ANNUAL) + .itemId("item_id") + .modelType( + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.ModelType.UNIT + ) + .name("Annual fee") + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfigurationModel.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfigurationModel.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .currency("currency") + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") + .invoicingCycleConfiguration( + NewBillingCycleConfigurationModel.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfigurationModel.DurationUnit.DAY) + .build() + ) + .metadata( + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) + ) + assertThat(addSubscriptionPriceParams.priceId()).contains("h74gfhdjvn7ujokd") + assertThat(addSubscriptionPriceParams.startDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/AddressInputModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/AddressInputModelTest.kt new file mode 100644 index 000000000..2afca0d3b --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/AddressInputModelTest.kt @@ -0,0 +1,29 @@ +// 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 + +class AddressInputModelTest { + + @Test + fun createAddressInputModel() { + val addressInputModel = + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + assertThat(addressInputModel).isNotNull + assertThat(addressInputModel.city()).contains("city") + assertThat(addressInputModel.country()).contains("country") + assertThat(addressInputModel.line1()).contains("line1") + assertThat(addressInputModel.line2()).contains("line2") + assertThat(addressInputModel.postalCode()).contains("postal_code") + assertThat(addressInputModel.state()).contains("state") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/AddressModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/AddressModelTest.kt new file mode 100644 index 000000000..6e052bba9 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/AddressModelTest.kt @@ -0,0 +1,29 @@ +// 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 + +class AddressModelTest { + + @Test + fun createAddressModel() { + val addressModel = + AddressModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + assertThat(addressModel).isNotNull + assertThat(addressModel.city()).contains("city") + assertThat(addressModel.country()).contains("country") + assertThat(addressModel.line1()).contains("line1") + assertThat(addressModel.line2()).contains("line2") + assertThat(addressModel.postalCode()).contains("postal_code") + assertThat(addressModel.state()).contains("state") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/AdjustmentIntervalModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/AdjustmentIntervalModelTest.kt new file mode 100644 index 000000000..8cc869839 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/AdjustmentIntervalModelTest.kt @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class AdjustmentIntervalModelTest { + + @Test + fun createAdjustmentIntervalModel() { + val adjustmentIntervalModel = + AdjustmentIntervalModel.builder() + .id("id") + .adjustment( + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.builder() + .id("id") + .adjustmentType( + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + assertThat(adjustmentIntervalModel).isNotNull + assertThat(adjustmentIntervalModel.id()).isEqualTo("id") + assertThat(adjustmentIntervalModel.adjustment()) + .isEqualTo( + AdjustmentModel.ofPlanPhaseUsageDiscountAdjustment( + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.builder() + .id("id") + .adjustmentType( + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + ) + assertThat(adjustmentIntervalModel.appliesToPriceIntervalIds()).containsExactly("string") + assertThat(adjustmentIntervalModel.endDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(adjustmentIntervalModel.startDate()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/AffectedBlockModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/AffectedBlockModelTest.kt new file mode 100644 index 000000000..87e3498c3 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/AffectedBlockModelTest.kt @@ -0,0 +1,25 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class AffectedBlockModelTest { + + @Test + fun createAffectedBlockModel() { + val affectedBlockModel = + AffectedBlockModel.builder() + .id("id") + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .perUnitCostBasis("per_unit_cost_basis") + .build() + assertThat(affectedBlockModel).isNotNull + assertThat(affectedBlockModel.id()).isEqualTo("id") + assertThat(affectedBlockModel.expiryDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(affectedBlockModel.perUnitCostBasis()).contains("per_unit_cost_basis") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/AggregatedCostModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/AggregatedCostModelTest.kt new file mode 100644 index 000000000..36eee4627 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/AggregatedCostModelTest.kt @@ -0,0 +1,192 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.JsonValue +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class AggregatedCostModelTest { + + @Test + fun createAggregatedCostModel() { + val aggregatedCostModel = + AggregatedCostModel.builder() + .addPerPriceCost( + AggregatedCostModel.PerPriceCost.builder() + .price( + PriceModel.UnitPrice.builder() + .id("id") + .billableMetric(BillableMetricTinyModel.builder().id("id").build()) + .billingCycleConfiguration( + BillingCycleConfigurationModel.builder() + .duration(0L) + .durationUnit( + BillingCycleConfigurationModel.DurationUnit.DAY + ) + .build() + ) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + AllocationModel.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + BillingCycleConfigurationModel.builder() + .duration(0L) + .durationUnit( + BillingCycleConfigurationModel.DurationUnit.DAY + ) + .build() + ) + .item(ItemSlimModel.builder().id("id").name("name").build()) + .maximum( + MaximumModel.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + PriceModel.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + MinimumModel.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(PriceModel.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + UnitConfigModel.builder().unitAmount("unit_amount").build() + ) + .dimensionalPriceConfiguration( + DimensionalPriceConfigurationModel.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .priceId("price_id") + .subtotal("subtotal") + .total("total") + .quantity(0.0) + .build() + ) + .subtotal("subtotal") + .timeframeEnd(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .timeframeStart(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .total("total") + .build() + assertThat(aggregatedCostModel).isNotNull + assertThat(aggregatedCostModel.perPriceCosts()) + .containsExactly( + AggregatedCostModel.PerPriceCost.builder() + .price( + PriceModel.UnitPrice.builder() + .id("id") + .billableMetric(BillableMetricTinyModel.builder().id("id").build()) + .billingCycleConfiguration( + BillingCycleConfigurationModel.builder() + .duration(0L) + .durationUnit(BillingCycleConfigurationModel.DurationUnit.DAY) + .build() + ) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + AllocationModel.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + BillingCycleConfigurationModel.builder() + .duration(0L) + .durationUnit(BillingCycleConfigurationModel.DurationUnit.DAY) + .build() + ) + .item(ItemSlimModel.builder().id("id").name("name").build()) + .maximum( + MaximumModel.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + PriceModel.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + MinimumModel.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(PriceModel.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) + .dimensionalPriceConfiguration( + DimensionalPriceConfigurationModel.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .priceId("price_id") + .subtotal("subtotal") + .total("total") + .quantity(0.0) + .build() + ) + assertThat(aggregatedCostModel.subtotal()).isEqualTo("subtotal") + assertThat(aggregatedCostModel.timeframeEnd()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(aggregatedCostModel.timeframeStart()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(aggregatedCostModel.total()).isEqualTo("total") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertCreateForCustomerParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertCreateForCustomerParamsTest.kt index 7276a96b7..5679abb52 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertCreateForCustomerParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertCreateForCustomerParamsTest.kt @@ -2,7 +2,6 @@ package com.withorb.api.models -import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -12,9 +11,13 @@ class AlertCreateForCustomerParamsTest { fun create() { AlertCreateForCustomerParams.builder() .customerId("customer_id") - .currency("currency") - .type(AlertCreateForCustomerParams.Type.USAGE_EXCEEDED) - .addThreshold(AlertCreateForCustomerParams.Threshold.builder().value(0.0).build()) + .createCustomerAlertRequest( + CreateCustomerAlertRequest.builder() + .currency("currency") + .type(CreateCustomerAlertRequest.Type.USAGE_EXCEEDED) + .addThreshold(ThresholdModel.builder().value(0.0).build()) + .build() + ) .build() } @@ -23,18 +26,25 @@ class AlertCreateForCustomerParamsTest { val params = AlertCreateForCustomerParams.builder() .customerId("customer_id") - .currency("currency") - .type(AlertCreateForCustomerParams.Type.USAGE_EXCEEDED) - .addThreshold(AlertCreateForCustomerParams.Threshold.builder().value(0.0).build()) + .createCustomerAlertRequest( + CreateCustomerAlertRequest.builder() + .currency("currency") + .type(CreateCustomerAlertRequest.Type.USAGE_EXCEEDED) + .addThreshold(ThresholdModel.builder().value(0.0).build()) + .build() + ) .build() val body = params._body() - assertNotNull(body) - assertThat(body.currency()).isEqualTo("currency") - assertThat(body.type()).isEqualTo(AlertCreateForCustomerParams.Type.USAGE_EXCEEDED) - assertThat(body.thresholds()) - .contains(listOf(AlertCreateForCustomerParams.Threshold.builder().value(0.0).build())) + assertThat(body) + .isEqualTo( + CreateCustomerAlertRequest.builder() + .currency("currency") + .type(CreateCustomerAlertRequest.Type.USAGE_EXCEEDED) + .addThreshold(ThresholdModel.builder().value(0.0).build()) + .build() + ) } @Test @@ -42,15 +52,23 @@ class AlertCreateForCustomerParamsTest { val params = AlertCreateForCustomerParams.builder() .customerId("customer_id") - .currency("currency") - .type(AlertCreateForCustomerParams.Type.USAGE_EXCEEDED) + .createCustomerAlertRequest( + CreateCustomerAlertRequest.builder() + .currency("currency") + .type(CreateCustomerAlertRequest.Type.USAGE_EXCEEDED) + .build() + ) .build() val body = params._body() - assertNotNull(body) - assertThat(body.currency()).isEqualTo("currency") - assertThat(body.type()).isEqualTo(AlertCreateForCustomerParams.Type.USAGE_EXCEEDED) + assertThat(body) + .isEqualTo( + CreateCustomerAlertRequest.builder() + .currency("currency") + .type(CreateCustomerAlertRequest.Type.USAGE_EXCEEDED) + .build() + ) } @Test @@ -58,8 +76,12 @@ class AlertCreateForCustomerParamsTest { val params = AlertCreateForCustomerParams.builder() .customerId("customer_id") - .currency("currency") - .type(AlertCreateForCustomerParams.Type.USAGE_EXCEEDED) + .createCustomerAlertRequest( + CreateCustomerAlertRequest.builder() + .currency("currency") + .type(CreateCustomerAlertRequest.Type.USAGE_EXCEEDED) + .build() + ) .build() assertThat(params).isNotNull // path param "customerId" diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertCreateForExternalCustomerParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertCreateForExternalCustomerParamsTest.kt index 9fc3acdb8..94664fb79 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertCreateForExternalCustomerParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertCreateForExternalCustomerParamsTest.kt @@ -2,7 +2,6 @@ package com.withorb.api.models -import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -12,10 +11,12 @@ class AlertCreateForExternalCustomerParamsTest { fun create() { AlertCreateForExternalCustomerParams.builder() .externalCustomerId("external_customer_id") - .currency("currency") - .type(AlertCreateForExternalCustomerParams.Type.USAGE_EXCEEDED) - .addThreshold( - AlertCreateForExternalCustomerParams.Threshold.builder().value(0.0).build() + .createCustomerAlertRequest( + CreateCustomerAlertRequest.builder() + .currency("currency") + .type(CreateCustomerAlertRequest.Type.USAGE_EXCEEDED) + .addThreshold(ThresholdModel.builder().value(0.0).build()) + .build() ) .build() } @@ -25,21 +26,24 @@ class AlertCreateForExternalCustomerParamsTest { val params = AlertCreateForExternalCustomerParams.builder() .externalCustomerId("external_customer_id") - .currency("currency") - .type(AlertCreateForExternalCustomerParams.Type.USAGE_EXCEEDED) - .addThreshold( - AlertCreateForExternalCustomerParams.Threshold.builder().value(0.0).build() + .createCustomerAlertRequest( + CreateCustomerAlertRequest.builder() + .currency("currency") + .type(CreateCustomerAlertRequest.Type.USAGE_EXCEEDED) + .addThreshold(ThresholdModel.builder().value(0.0).build()) + .build() ) .build() val body = params._body() - assertNotNull(body) - assertThat(body.currency()).isEqualTo("currency") - assertThat(body.type()).isEqualTo(AlertCreateForExternalCustomerParams.Type.USAGE_EXCEEDED) - assertThat(body.thresholds()) - .contains( - listOf(AlertCreateForExternalCustomerParams.Threshold.builder().value(0.0).build()) + assertThat(body) + .isEqualTo( + CreateCustomerAlertRequest.builder() + .currency("currency") + .type(CreateCustomerAlertRequest.Type.USAGE_EXCEEDED) + .addThreshold(ThresholdModel.builder().value(0.0).build()) + .build() ) } @@ -48,15 +52,23 @@ class AlertCreateForExternalCustomerParamsTest { val params = AlertCreateForExternalCustomerParams.builder() .externalCustomerId("external_customer_id") - .currency("currency") - .type(AlertCreateForExternalCustomerParams.Type.USAGE_EXCEEDED) + .createCustomerAlertRequest( + CreateCustomerAlertRequest.builder() + .currency("currency") + .type(CreateCustomerAlertRequest.Type.USAGE_EXCEEDED) + .build() + ) .build() val body = params._body() - assertNotNull(body) - assertThat(body.currency()).isEqualTo("currency") - assertThat(body.type()).isEqualTo(AlertCreateForExternalCustomerParams.Type.USAGE_EXCEEDED) + assertThat(body) + .isEqualTo( + CreateCustomerAlertRequest.builder() + .currency("currency") + .type(CreateCustomerAlertRequest.Type.USAGE_EXCEEDED) + .build() + ) } @Test @@ -64,8 +76,12 @@ class AlertCreateForExternalCustomerParamsTest { val params = AlertCreateForExternalCustomerParams.builder() .externalCustomerId("external_customer_id") - .currency("currency") - .type(AlertCreateForExternalCustomerParams.Type.USAGE_EXCEEDED) + .createCustomerAlertRequest( + CreateCustomerAlertRequest.builder() + .currency("currency") + .type(CreateCustomerAlertRequest.Type.USAGE_EXCEEDED) + .build() + ) .build() assertThat(params).isNotNull // path param "externalCustomerId" 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 5d6facff8..7e8269188 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 @@ -12,7 +12,7 @@ class AlertCreateForSubscriptionParamsTest { fun create() { AlertCreateForSubscriptionParams.builder() .subscriptionId("subscription_id") - .addThreshold(AlertCreateForSubscriptionParams.Threshold.builder().value(0.0).build()) + .addThreshold(ThresholdModel.builder().value(0.0).build()) .type(AlertCreateForSubscriptionParams.Type.USAGE_EXCEEDED) .metricId("metric_id") .build() @@ -23,9 +23,7 @@ class AlertCreateForSubscriptionParamsTest { val params = AlertCreateForSubscriptionParams.builder() .subscriptionId("subscription_id") - .addThreshold( - AlertCreateForSubscriptionParams.Threshold.builder().value(0.0).build() - ) + .addThreshold(ThresholdModel.builder().value(0.0).build()) .type(AlertCreateForSubscriptionParams.Type.USAGE_EXCEEDED) .metricId("metric_id") .build() @@ -33,10 +31,7 @@ class AlertCreateForSubscriptionParamsTest { val body = params._body() assertNotNull(body) - assertThat(body.thresholds()) - .isEqualTo( - listOf(AlertCreateForSubscriptionParams.Threshold.builder().value(0.0).build()) - ) + assertThat(body.thresholds()).isEqualTo(listOf(ThresholdModel.builder().value(0.0).build())) assertThat(body.type()).isEqualTo(AlertCreateForSubscriptionParams.Type.USAGE_EXCEEDED) assertThat(body.metricId()).contains("metric_id") } @@ -46,19 +41,14 @@ class AlertCreateForSubscriptionParamsTest { val params = AlertCreateForSubscriptionParams.builder() .subscriptionId("subscription_id") - .addThreshold( - AlertCreateForSubscriptionParams.Threshold.builder().value(0.0).build() - ) + .addThreshold(ThresholdModel.builder().value(0.0).build()) .type(AlertCreateForSubscriptionParams.Type.USAGE_EXCEEDED) .build() val body = params._body() assertNotNull(body) - assertThat(body.thresholds()) - .isEqualTo( - listOf(AlertCreateForSubscriptionParams.Threshold.builder().value(0.0).build()) - ) + assertThat(body.thresholds()).isEqualTo(listOf(ThresholdModel.builder().value(0.0).build())) assertThat(body.type()).isEqualTo(AlertCreateForSubscriptionParams.Type.USAGE_EXCEEDED) } @@ -67,9 +57,7 @@ class AlertCreateForSubscriptionParamsTest { val params = AlertCreateForSubscriptionParams.builder() .subscriptionId("subscription_id") - .addThreshold( - AlertCreateForSubscriptionParams.Threshold.builder().value(0.0).build() - ) + .addThreshold(ThresholdModel.builder().value(0.0).build()) .type(AlertCreateForSubscriptionParams.Type.USAGE_EXCEEDED) .build() assertThat(params).isNotNull diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertModelTest.kt new file mode 100644 index 000000000..7009853b0 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertModelTest.kt @@ -0,0 +1,67 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class AlertModelTest { + + @Test + fun createAlertModel() { + val alertModel = + AlertModel.builder() + .id("XuxCbt7x9L82yyeF") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .customer( + CustomerMinifiedModel.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .enabled(true) + .metric(AlertModel.Metric.builder().id("id").build()) + .plan( + AlertModel.Plan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .planVersion("plan_version") + .build() + ) + .subscription(SubscriptionMinifiedModel.builder().id("VDGsT23osdLb84KD").build()) + .addThreshold(ThresholdModel.builder().value(0.0).build()) + .type(AlertModel.Type.USAGE_EXCEEDED) + .build() + assertThat(alertModel).isNotNull + assertThat(alertModel.id()).isEqualTo("XuxCbt7x9L82yyeF") + assertThat(alertModel.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(alertModel.currency()).contains("currency") + assertThat(alertModel.customer()) + .contains( + CustomerMinifiedModel.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + assertThat(alertModel.enabled()).isEqualTo(true) + assertThat(alertModel.metric()).contains(AlertModel.Metric.builder().id("id").build()) + assertThat(alertModel.plan()) + .contains( + AlertModel.Plan.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .planVersion("plan_version") + .build() + ) + assertThat(alertModel.subscription()) + .contains(SubscriptionMinifiedModel.builder().id("VDGsT23osdLb84KD").build()) + assertThat(alertModel.thresholds().get()) + .containsExactly(ThresholdModel.builder().value(0.0).build()) + assertThat(alertModel.type()).isEqualTo(AlertModel.Type.USAGE_EXCEEDED) + } +} 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 02b182bc4..e9260f076 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 @@ -16,7 +16,7 @@ class AlertTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("currency") .customer( - Alert.Customer.builder() + CustomerMinifiedModel.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -31,8 +31,8 @@ class AlertTest { .planVersion("plan_version") .build() ) - .subscription(Alert.Subscription.builder().id("VDGsT23osdLb84KD").build()) - .addThreshold(Alert.Threshold.builder().value(0.0).build()) + .subscription(SubscriptionMinifiedModel.builder().id("VDGsT23osdLb84KD").build()) + .addThreshold(ThresholdModel.builder().value(0.0).build()) .type(Alert.Type.USAGE_EXCEEDED) .build() assertThat(alert).isNotNull @@ -41,7 +41,10 @@ class AlertTest { assertThat(alert.currency()).contains("currency") assertThat(alert.customer()) .contains( - Alert.Customer.builder().id("id").externalCustomerId("external_customer_id").build() + CustomerMinifiedModel.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() ) assertThat(alert.enabled()).isEqualTo(true) assertThat(alert.metric()).contains(Alert.Metric.builder().id("id").build()) @@ -55,9 +58,9 @@ class AlertTest { .build() ) assertThat(alert.subscription()) - .contains(Alert.Subscription.builder().id("VDGsT23osdLb84KD").build()) + .contains(SubscriptionMinifiedModel.builder().id("VDGsT23osdLb84KD").build()) assertThat(alert.thresholds().get()) - .containsExactly(Alert.Threshold.builder().value(0.0).build()) + .containsExactly(ThresholdModel.builder().value(0.0).build()) assertThat(alert.type()).isEqualTo(Alert.Type.USAGE_EXCEEDED) } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertUpdateParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertUpdateParamsTest.kt index b679d723f..ec11ec519 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertUpdateParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/AlertUpdateParamsTest.kt @@ -12,7 +12,7 @@ class AlertUpdateParamsTest { fun create() { AlertUpdateParams.builder() .alertConfigurationId("alert_configuration_id") - .addThreshold(AlertUpdateParams.Threshold.builder().value(0.0).build()) + .addThreshold(ThresholdModel.builder().value(0.0).build()) .build() } @@ -21,14 +21,13 @@ class AlertUpdateParamsTest { val params = AlertUpdateParams.builder() .alertConfigurationId("alert_configuration_id") - .addThreshold(AlertUpdateParams.Threshold.builder().value(0.0).build()) + .addThreshold(ThresholdModel.builder().value(0.0).build()) .build() val body = params._body() assertNotNull(body) - assertThat(body.thresholds()) - .isEqualTo(listOf(AlertUpdateParams.Threshold.builder().value(0.0).build())) + assertThat(body.thresholds()).isEqualTo(listOf(ThresholdModel.builder().value(0.0).build())) } @Test @@ -36,14 +35,13 @@ class AlertUpdateParamsTest { val params = AlertUpdateParams.builder() .alertConfigurationId("alert_configuration_id") - .addThreshold(AlertUpdateParams.Threshold.builder().value(0.0).build()) + .addThreshold(ThresholdModel.builder().value(0.0).build()) .build() val body = params._body() assertNotNull(body) - assertThat(body.thresholds()) - .isEqualTo(listOf(AlertUpdateParams.Threshold.builder().value(0.0).build())) + assertThat(body.thresholds()).isEqualTo(listOf(ThresholdModel.builder().value(0.0).build())) } @Test @@ -51,7 +49,7 @@ class AlertUpdateParamsTest { val params = AlertUpdateParams.builder() .alertConfigurationId("alert_configuration_id") - .addThreshold(AlertUpdateParams.Threshold.builder().value(0.0).build()) + .addThreshold(ThresholdModel.builder().value(0.0).build()) .build() assertThat(params).isNotNull // path param "alertConfigurationId" diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/AllocationModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/AllocationModelTest.kt new file mode 100644 index 000000000..43626aab5 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/AllocationModelTest.kt @@ -0,0 +1,18 @@ +// 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 + +class AllocationModelTest { + + @Test + fun createAllocationModel() { + val allocationModel = + AllocationModel.builder().allowsRollover(true).currency("currency").build() + assertThat(allocationModel).isNotNull + assertThat(allocationModel.allowsRollover()).isEqualTo(true) + assertThat(allocationModel.currency()).isEqualTo("currency") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/AmountDiscountIntervalModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/AmountDiscountIntervalModelTest.kt new file mode 100644 index 000000000..90dd5bdc6 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/AmountDiscountIntervalModelTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class AmountDiscountIntervalModelTest { + + @Test + fun createAmountDiscountIntervalModel() { + val amountDiscountIntervalModel = + AmountDiscountIntervalModel.builder() + .amountDiscount("amount_discount") + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .discountType(AmountDiscountIntervalModel.DiscountType.AMOUNT) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + assertThat(amountDiscountIntervalModel).isNotNull + assertThat(amountDiscountIntervalModel.amountDiscount()).isEqualTo("amount_discount") + assertThat(amountDiscountIntervalModel.appliesToPriceIds()).containsExactly("string") + assertThat(amountDiscountIntervalModel.appliesToPriceIntervalIds()) + .containsExactly("string") + assertThat(amountDiscountIntervalModel.discountType()) + .isEqualTo(AmountDiscountIntervalModel.DiscountType.AMOUNT) + assertThat(amountDiscountIntervalModel.endDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(amountDiscountIntervalModel.startDate()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/AmountDiscountModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/AmountDiscountModelTest.kt new file mode 100644 index 000000000..1a9ca0ed2 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/AmountDiscountModelTest.kt @@ -0,0 +1,28 @@ +// 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 + +class AmountDiscountModelTest { + + @Test + fun createAmountDiscountModel() { + val amountDiscountModel = + AmountDiscountModel.builder() + .amountDiscount("amount_discount") + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(AmountDiscountModel.DiscountType.AMOUNT) + .reason("reason") + .build() + assertThat(amountDiscountModel).isNotNull + assertThat(amountDiscountModel.amountDiscount()).isEqualTo("amount_discount") + assertThat(amountDiscountModel.appliesToPriceIds()) + .containsExactly("h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl") + assertThat(amountDiscountModel.discountType()) + .isEqualTo(AmountDiscountModel.DiscountType.AMOUNT) + assertThat(amountDiscountModel.reason()).contains("reason") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/AutoCollectionModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/AutoCollectionModelTest.kt new file mode 100644 index 000000000..016913b55 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/AutoCollectionModelTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class AutoCollectionModelTest { + + @Test + fun createAutoCollectionModel() { + val autoCollectionModel = + AutoCollectionModel.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(autoCollectionModel).isNotNull + assertThat(autoCollectionModel.enabled()).contains(true) + assertThat(autoCollectionModel.nextAttemptAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(autoCollectionModel.numAttempts()).contains(0L) + assertThat(autoCollectionModel.previouslyAttemptedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/EventBackfillListResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/BackfillModelTest.kt similarity index 55% rename from orb-java-core/src/test/kotlin/com/withorb/api/models/EventBackfillListResponseTest.kt rename to orb-java-core/src/test/kotlin/com/withorb/api/models/BackfillModelTest.kt index a8acf264b..f76b4315f 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/EventBackfillListResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/BackfillModelTest.kt @@ -6,12 +6,12 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class EventBackfillListResponseTest { +class BackfillModelTest { @Test - fun createEventBackfillListResponse() { - val eventBackfillListResponse = - EventBackfillListResponse.builder() + fun createBackfillModel() { + val backfillModel = + BackfillModel.builder() .id("id") .closeTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -19,29 +19,28 @@ class EventBackfillListResponseTest { .eventsIngested(0L) .replaceExistingEvents(true) .revertedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .status(EventBackfillListResponse.Status.PENDING) + .status(BackfillModel.Status.PENDING) .timeframeEnd(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .timeframeStart(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .deprecationFilter("my_numeric_property > 100 AND my_other_property = 'bar'") .build() - assertThat(eventBackfillListResponse).isNotNull - assertThat(eventBackfillListResponse.id()).isEqualTo("id") - assertThat(eventBackfillListResponse.closeTime()) + assertThat(backfillModel).isNotNull + assertThat(backfillModel.id()).isEqualTo("id") + assertThat(backfillModel.closeTime()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(eventBackfillListResponse.createdAt()) + assertThat(backfillModel.createdAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(eventBackfillListResponse.customerId()).contains("customer_id") - assertThat(eventBackfillListResponse.eventsIngested()).isEqualTo(0L) - assertThat(eventBackfillListResponse.replaceExistingEvents()).isEqualTo(true) - assertThat(eventBackfillListResponse.revertedAt()) + assertThat(backfillModel.customerId()).contains("customer_id") + assertThat(backfillModel.eventsIngested()).isEqualTo(0L) + assertThat(backfillModel.replaceExistingEvents()).isEqualTo(true) + assertThat(backfillModel.revertedAt()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(eventBackfillListResponse.status()) - .isEqualTo(EventBackfillListResponse.Status.PENDING) - assertThat(eventBackfillListResponse.timeframeEnd()) + assertThat(backfillModel.status()).isEqualTo(BackfillModel.Status.PENDING) + assertThat(backfillModel.timeframeEnd()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(eventBackfillListResponse.timeframeStart()) + assertThat(backfillModel.timeframeStart()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(eventBackfillListResponse.deprecationFilter()) + assertThat(backfillModel.deprecationFilter()) .contains("my_numeric_property > 100 AND my_other_property = 'bar'") } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/BillableMetricModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/BillableMetricModelTest.kt new file mode 100644 index 000000000..c869e99bc --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/BillableMetricModelTest.kt @@ -0,0 +1,69 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.JsonValue +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class BillableMetricModelTest { + + @Test + fun createBillableMetricModel() { + val billableMetricModel = + BillableMetricModel.builder() + .id("id") + .description("description") + .item( + ItemModel.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addExternalConnection( + ItemExternalConnectionModel.builder() + .externalConnectionName( + ItemExternalConnectionModel.ExternalConnectionName.STRIPE + ) + .externalEntityId("external_entity_id") + .build() + ) + .name("name") + .build() + ) + .metadata( + BillableMetricModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .status(BillableMetricModel.Status.ACTIVE) + .build() + assertThat(billableMetricModel).isNotNull + assertThat(billableMetricModel.id()).isEqualTo("id") + assertThat(billableMetricModel.description()).contains("description") + assertThat(billableMetricModel.item()) + .isEqualTo( + ItemModel.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addExternalConnection( + ItemExternalConnectionModel.builder() + .externalConnectionName( + ItemExternalConnectionModel.ExternalConnectionName.STRIPE + ) + .externalEntityId("external_entity_id") + .build() + ) + .name("name") + .build() + ) + assertThat(billableMetricModel.metadata()) + .isEqualTo( + BillableMetricModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(billableMetricModel.name()).isEqualTo("name") + assertThat(billableMetricModel.status()).isEqualTo(BillableMetricModel.Status.ACTIVE) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/BillableMetricSimpleModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/BillableMetricSimpleModelTest.kt new file mode 100644 index 000000000..ab76b8f8c --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/BillableMetricSimpleModelTest.kt @@ -0,0 +1,18 @@ +// 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 + +class BillableMetricSimpleModelTest { + + @Test + fun createBillableMetricSimpleModel() { + val billableMetricSimpleModel = + BillableMetricSimpleModel.builder().id("id").name("name").build() + assertThat(billableMetricSimpleModel).isNotNull + assertThat(billableMetricSimpleModel.id()).isEqualTo("id") + assertThat(billableMetricSimpleModel.name()).isEqualTo("name") + } +} 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 e81200813..68ae4ac0d 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 @@ -16,13 +16,13 @@ class BillableMetricTest { .id("id") .description("description") .item( - Item.builder() + ItemModel.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addExternalConnection( - Item.ExternalConnection.builder() + ItemExternalConnectionModel.builder() .externalConnectionName( - Item.ExternalConnection.ExternalConnectionName.STRIPE + ItemExternalConnectionModel.ExternalConnectionName.STRIPE ) .externalEntityId("external_entity_id") .build() @@ -43,13 +43,13 @@ class BillableMetricTest { assertThat(billableMetric.description()).contains("description") assertThat(billableMetric.item()) .isEqualTo( - Item.builder() + ItemModel.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addExternalConnection( - Item.ExternalConnection.builder() + ItemExternalConnectionModel.builder() .externalConnectionName( - Item.ExternalConnection.ExternalConnectionName.STRIPE + ItemExternalConnectionModel.ExternalConnectionName.STRIPE ) .externalEntityId("external_entity_id") .build() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/BillableMetricTinyModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/BillableMetricTinyModelTest.kt new file mode 100644 index 000000000..757be1d21 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/BillableMetricTinyModelTest.kt @@ -0,0 +1,16 @@ +// 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 + +class BillableMetricTinyModelTest { + + @Test + fun createBillableMetricTinyModel() { + val billableMetricTinyModel = BillableMetricTinyModel.builder().id("id").build() + assertThat(billableMetricTinyModel).isNotNull + assertThat(billableMetricTinyModel.id()).isEqualTo("id") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/BillingCycleAnchorConfigurationModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/BillingCycleAnchorConfigurationModelTest.kt new file mode 100644 index 000000000..c9621f3c9 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/BillingCycleAnchorConfigurationModelTest.kt @@ -0,0 +1,19 @@ +// 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 + +class BillingCycleAnchorConfigurationModelTest { + + @Test + fun createBillingCycleAnchorConfigurationModel() { + val billingCycleAnchorConfigurationModel = + BillingCycleAnchorConfigurationModel.builder().day(1L).month(1L).year(0L).build() + assertThat(billingCycleAnchorConfigurationModel).isNotNull + assertThat(billingCycleAnchorConfigurationModel.day()).isEqualTo(1L) + assertThat(billingCycleAnchorConfigurationModel.month()).contains(1L) + assertThat(billingCycleAnchorConfigurationModel.year()).contains(0L) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/BillingCycleConfigurationModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/BillingCycleConfigurationModelTest.kt new file mode 100644 index 000000000..e08017d55 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/BillingCycleConfigurationModelTest.kt @@ -0,0 +1,22 @@ +// 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 + +class BillingCycleConfigurationModelTest { + + @Test + fun createBillingCycleConfigurationModel() { + val billingCycleConfigurationModel = + BillingCycleConfigurationModel.builder() + .duration(0L) + .durationUnit(BillingCycleConfigurationModel.DurationUnit.DAY) + .build() + assertThat(billingCycleConfigurationModel).isNotNull + assertThat(billingCycleConfigurationModel.duration()).isEqualTo(0L) + assertThat(billingCycleConfigurationModel.durationUnit()) + .isEqualTo(BillingCycleConfigurationModel.DurationUnit.DAY) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/BpsConfigModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/BpsConfigModelTest.kt new file mode 100644 index 000000000..4a8d68754 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/BpsConfigModelTest.kt @@ -0,0 +1,18 @@ +// 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 + +class BpsConfigModelTest { + + @Test + fun createBpsConfigModel() { + val bpsConfigModel = + BpsConfigModel.builder().bps(0.0).perUnitMaximum("per_unit_maximum").build() + assertThat(bpsConfigModel).isNotNull + assertThat(bpsConfigModel.bps()).isEqualTo(0.0) + assertThat(bpsConfigModel.perUnitMaximum()).contains("per_unit_maximum") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/BulkBpsConfigModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/BulkBpsConfigModelTest.kt new file mode 100644 index 000000000..0285a1348 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/BulkBpsConfigModelTest.kt @@ -0,0 +1,32 @@ +// 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 + +class BulkBpsConfigModelTest { + + @Test + fun createBulkBpsConfigModel() { + val bulkBpsConfigModel = + BulkBpsConfigModel.builder() + .addTier( + BulkBpsConfigModel.Tier.builder() + .bps(0.0) + .maximumAmount("maximum_amount") + .perUnitMaximum("per_unit_maximum") + .build() + ) + .build() + assertThat(bulkBpsConfigModel).isNotNull + assertThat(bulkBpsConfigModel.tiers()) + .containsExactly( + BulkBpsConfigModel.Tier.builder() + .bps(0.0) + .maximumAmount("maximum_amount") + .perUnitMaximum("per_unit_maximum") + .build() + ) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/BulkConfigModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/BulkConfigModelTest.kt new file mode 100644 index 000000000..d4776754a --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/BulkConfigModelTest.kt @@ -0,0 +1,27 @@ +// 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 + +class BulkConfigModelTest { + + @Test + fun createBulkConfigModel() { + val bulkConfigModel = + BulkConfigModel.builder() + .addTier( + BulkConfigModel.Tier.builder() + .unitAmount("unit_amount") + .maximumUnits(0.0) + .build() + ) + .build() + assertThat(bulkConfigModel).isNotNull + assertThat(bulkConfigModel.tiers()) + .containsExactly( + BulkConfigModel.Tier.builder().unitAmount("unit_amount").maximumUnits(0.0).build() + ) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CouponModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CouponModelTest.kt new file mode 100644 index 000000000..c79e61d6f --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CouponModelTest.kt @@ -0,0 +1,52 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class CouponModelTest { + + @Test + fun createCouponModel() { + val couponModel = + CouponModel.builder() + .id("7iz2yanVjQoBZhyH") + .archivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .durationInMonths(12L) + .maxRedemptions(0L) + .redemptionCode("HALFOFF") + .timesRedeemed(0L) + .build() + assertThat(couponModel).isNotNull + assertThat(couponModel.id()).isEqualTo("7iz2yanVjQoBZhyH") + assertThat(couponModel.archivedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(couponModel.discount()) + .isEqualTo( + CouponModel.Discount.ofPercentage( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + ) + assertThat(couponModel.durationInMonths()).contains(12L) + assertThat(couponModel.maxRedemptions()).contains(0L) + assertThat(couponModel.redemptionCode()).isEqualTo("HALFOFF") + assertThat(couponModel.timesRedeemed()).isEqualTo(0L) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CouponRedemptionModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CouponRedemptionModelTest.kt new file mode 100644 index 000000000..45e99cb31 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CouponRedemptionModelTest.kt @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class CouponRedemptionModelTest { + + @Test + fun createCouponRedemptionModel() { + val couponRedemptionModel = + CouponRedemptionModel.builder() + .couponId("coupon_id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + assertThat(couponRedemptionModel).isNotNull + assertThat(couponRedemptionModel.couponId()).isEqualTo("coupon_id") + assertThat(couponRedemptionModel.endDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(couponRedemptionModel.startDate()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CreateCustomerAlertRequestTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CreateCustomerAlertRequestTest.kt new file mode 100644 index 000000000..654b63937 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CreateCustomerAlertRequestTest.kt @@ -0,0 +1,25 @@ +// 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 + +class CreateCustomerAlertRequestTest { + + @Test + fun createCreateCustomerAlertRequest() { + val createCustomerAlertRequest = + CreateCustomerAlertRequest.builder() + .currency("currency") + .type(CreateCustomerAlertRequest.Type.USAGE_EXCEEDED) + .addThreshold(ThresholdModel.builder().value(0.0).build()) + .build() + assertThat(createCustomerAlertRequest).isNotNull + assertThat(createCustomerAlertRequest.currency()).isEqualTo("currency") + assertThat(createCustomerAlertRequest.type()) + .isEqualTo(CreateCustomerAlertRequest.Type.USAGE_EXCEEDED) + assertThat(createCustomerAlertRequest.thresholds().get()) + .containsExactly(ThresholdModel.builder().value(0.0).build()) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditLedgerEntriesModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditLedgerEntriesModelTest.kt new file mode 100644 index 000000000..40cc5d36a --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditLedgerEntriesModelTest.kt @@ -0,0 +1,95 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.JsonValue +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class CreditLedgerEntriesModelTest { + + @Test + fun createCreditLedgerEntriesModel() { + val creditLedgerEntriesModel = + CreditLedgerEntriesModel.builder() + .addData( + CreditLedgerEntryModel.IncrementLedgerEntry.builder() + .id("id") + .amount(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditBlock( + AffectedBlockModel.builder() + .id("id") + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .perUnitCostBasis("per_unit_cost_basis") + .build() + ) + .currency("currency") + .customer( + CustomerMinifiedModel.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .description("description") + .endingBalance(0.0) + .entryStatus( + CreditLedgerEntryModel.IncrementLedgerEntry.EntryStatus.COMMITTED + ) + .entryType(CreditLedgerEntryModel.IncrementLedgerEntry.EntryType.INCREMENT) + .ledgerSequenceNumber(0L) + .metadata( + CreditLedgerEntryModel.IncrementLedgerEntry.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .startingBalance(0.0) + .build() + ) + .paginationMetadata( + PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build() + ) + .build() + assertThat(creditLedgerEntriesModel).isNotNull + assertThat(creditLedgerEntriesModel.data()) + .containsExactly( + CreditLedgerEntryModel.ofIncrementLedgerEntry( + CreditLedgerEntryModel.IncrementLedgerEntry.builder() + .id("id") + .amount(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditBlock( + AffectedBlockModel.builder() + .id("id") + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .perUnitCostBasis("per_unit_cost_basis") + .build() + ) + .currency("currency") + .customer( + CustomerMinifiedModel.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .description("description") + .endingBalance(0.0) + .entryStatus( + CreditLedgerEntryModel.IncrementLedgerEntry.EntryStatus.COMMITTED + ) + .entryType(CreditLedgerEntryModel.IncrementLedgerEntry.EntryType.INCREMENT) + .ledgerSequenceNumber(0L) + .metadata( + CreditLedgerEntryModel.IncrementLedgerEntry.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .startingBalance(0.0) + .build() + ) + ) + assertThat(creditLedgerEntriesModel.paginationMetadata()) + .isEqualTo(PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build()) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditNoteDiscountModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditNoteDiscountModelTest.kt new file mode 100644 index 000000000..081d9b0a0 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditNoteDiscountModelTest.kt @@ -0,0 +1,33 @@ +// 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 + +class CreditNoteDiscountModelTest { + + @Test + fun createCreditNoteDiscountModel() { + val creditNoteDiscountModel = + CreditNoteDiscountModel.builder() + .amountApplied("amount_applied") + .discountType(CreditNoteDiscountModel.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNoteDiscountModel.AppliesToPrice.builder().id("id").name("name").build() + ) + .reason("reason") + .build() + assertThat(creditNoteDiscountModel).isNotNull + assertThat(creditNoteDiscountModel.amountApplied()).isEqualTo("amount_applied") + assertThat(creditNoteDiscountModel.discountType()) + .isEqualTo(CreditNoteDiscountModel.DiscountType.PERCENTAGE) + assertThat(creditNoteDiscountModel.percentageDiscount()).isEqualTo(0.0) + assertThat(creditNoteDiscountModel.appliesToPrices().get()) + .containsExactly( + CreditNoteDiscountModel.AppliesToPrice.builder().id("id").name("name").build() + ) + assertThat(creditNoteDiscountModel.reason()).contains("reason") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditNoteModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditNoteModelTest.kt new file mode 100644 index 000000000..003ef9360 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditNoteModelTest.kt @@ -0,0 +1,174 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class CreditNoteModelTest { + + @Test + fun createCreditNoteModel() { + val creditNoteModel = + CreditNoteModel.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditNoteNumber("credit_note_number") + .creditNotePdf("credit_note_pdf") + .customer( + CustomerMinifiedModel.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .invoiceId("invoice_id") + .addLineItem( + CreditNoteModel.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + TaxAmountModel.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNoteModel.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType( + CreditNoteModel.LineItem.Discount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + .maximumAmountAdjustment( + CreditNoteDiscountModel.builder() + .amountApplied("amount_applied") + .discountType(CreditNoteDiscountModel.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNoteDiscountModel.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .memo("memo") + .minimumAmountRefunded("minimum_amount_refunded") + .reason(CreditNoteModel.Reason.DUPLICATE) + .subtotal("subtotal") + .total("total") + .type(CreditNoteModel.Type.REFUND) + .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDiscount( + CreditNoteDiscountModel.builder() + .amountApplied("amount_applied") + .discountType(CreditNoteDiscountModel.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNoteDiscountModel.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + .build() + assertThat(creditNoteModel).isNotNull + assertThat(creditNoteModel.id()).isEqualTo("id") + assertThat(creditNoteModel.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(creditNoteModel.creditNoteNumber()).isEqualTo("credit_note_number") + assertThat(creditNoteModel.creditNotePdf()).contains("credit_note_pdf") + assertThat(creditNoteModel.customer()) + .isEqualTo( + CustomerMinifiedModel.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + assertThat(creditNoteModel.invoiceId()).isEqualTo("invoice_id") + assertThat(creditNoteModel.lineItems()) + .containsExactly( + CreditNoteModel.LineItem.builder() + .id("id") + .amount("amount") + .itemId("item_id") + .name("name") + .quantity(0.0) + .subtotal("subtotal") + .addTaxAmount( + TaxAmountModel.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addDiscount( + CreditNoteModel.LineItem.Discount.builder() + .id("id") + .amountApplied("amount_applied") + .addAppliesToPriceId("string") + .discountType(CreditNoteModel.LineItem.Discount.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .amountDiscount("amount_discount") + .reason("reason") + .build() + ) + .build() + ) + assertThat(creditNoteModel.maximumAmountAdjustment()) + .contains( + CreditNoteDiscountModel.builder() + .amountApplied("amount_applied") + .discountType(CreditNoteDiscountModel.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNoteDiscountModel.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + assertThat(creditNoteModel.memo()).contains("memo") + assertThat(creditNoteModel.minimumAmountRefunded()).contains("minimum_amount_refunded") + assertThat(creditNoteModel.reason()).contains(CreditNoteModel.Reason.DUPLICATE) + assertThat(creditNoteModel.subtotal()).isEqualTo("subtotal") + assertThat(creditNoteModel.total()).isEqualTo("total") + assertThat(creditNoteModel.type()).isEqualTo(CreditNoteModel.Type.REFUND) + assertThat(creditNoteModel.voidedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(creditNoteModel.discounts().get()) + .containsExactly( + CreditNoteDiscountModel.builder() + .amountApplied("amount_applied") + .discountType(CreditNoteDiscountModel.DiscountType.PERCENTAGE) + .percentageDiscount(0.0) + .addAppliesToPrice( + CreditNoteDiscountModel.AppliesToPrice.builder() + .id("id") + .name("name") + .build() + ) + .reason("reason") + .build() + ) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditNoteSummaryModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditNoteSummaryModelTest.kt new file mode 100644 index 000000000..02902c7b2 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditNoteSummaryModelTest.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class CreditNoteSummaryModelTest { + + @Test + fun createCreditNoteSummaryModel() { + val creditNoteSummaryModel = + CreditNoteSummaryModel.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(creditNoteSummaryModel).isNotNull + assertThat(creditNoteSummaryModel.id()).isEqualTo("id") + assertThat(creditNoteSummaryModel.creditNoteNumber()).isEqualTo("credit_note_number") + assertThat(creditNoteSummaryModel.memo()).contains("memo") + assertThat(creditNoteSummaryModel.reason()).isEqualTo("reason") + assertThat(creditNoteSummaryModel.total()).isEqualTo("total") + assertThat(creditNoteSummaryModel.type()).isEqualTo("type") + assertThat(creditNoteSummaryModel.voidedAt()) + .contains(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditNoteTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditNoteTest.kt index 63cd1bda4..5073b0267 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditNoteTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CreditNoteTest.kt @@ -17,7 +17,7 @@ class CreditNoteTest { .creditNoteNumber("credit_note_number") .creditNotePdf("credit_note_pdf") .customer( - CreditNote.Customer.builder() + CustomerMinifiedModel.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -32,7 +32,7 @@ class CreditNoteTest { .quantity(0.0) .subtotal("subtotal") .addTaxAmount( - CreditNote.LineItem.TaxAmount.builder() + TaxAmountModel.builder() .amount("amount") .taxRateDescription("tax_rate_description") .taxRatePercentage("tax_rate_percentage") @@ -52,12 +52,12 @@ class CreditNoteTest { .build() ) .maximumAmountAdjustment( - CreditNote.MaximumAmountAdjustment.builder() + CreditNoteDiscountModel.builder() .amountApplied("amount_applied") - .discountType(CreditNote.MaximumAmountAdjustment.DiscountType.PERCENTAGE) + .discountType(CreditNoteDiscountModel.DiscountType.PERCENTAGE) .percentageDiscount(0.0) .addAppliesToPrice( - CreditNote.MaximumAmountAdjustment.AppliesToPrice.builder() + CreditNoteDiscountModel.AppliesToPrice.builder() .id("id") .name("name") .build() @@ -73,12 +73,12 @@ class CreditNoteTest { .type(CreditNote.Type.REFUND) .voidedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addDiscount( - CreditNote.Discount.builder() + CreditNoteDiscountModel.builder() .amountApplied("amount_applied") - .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .discountType(CreditNoteDiscountModel.DiscountType.PERCENTAGE) .percentageDiscount(0.0) .addAppliesToPrice( - CreditNote.Discount.AppliesToPrice.builder() + CreditNoteDiscountModel.AppliesToPrice.builder() .id("id") .name("name") .build() @@ -95,7 +95,7 @@ class CreditNoteTest { assertThat(creditNote.creditNotePdf()).contains("credit_note_pdf") assertThat(creditNote.customer()) .isEqualTo( - CreditNote.Customer.builder() + CustomerMinifiedModel.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -111,7 +111,7 @@ class CreditNoteTest { .quantity(0.0) .subtotal("subtotal") .addTaxAmount( - CreditNote.LineItem.TaxAmount.builder() + TaxAmountModel.builder() .amount("amount") .taxRateDescription("tax_rate_description") .taxRatePercentage("tax_rate_percentage") @@ -132,12 +132,12 @@ class CreditNoteTest { ) assertThat(creditNote.maximumAmountAdjustment()) .contains( - CreditNote.MaximumAmountAdjustment.builder() + CreditNoteDiscountModel.builder() .amountApplied("amount_applied") - .discountType(CreditNote.MaximumAmountAdjustment.DiscountType.PERCENTAGE) + .discountType(CreditNoteDiscountModel.DiscountType.PERCENTAGE) .percentageDiscount(0.0) .addAppliesToPrice( - CreditNote.MaximumAmountAdjustment.AppliesToPrice.builder() + CreditNoteDiscountModel.AppliesToPrice.builder() .id("id") .name("name") .build() @@ -154,12 +154,15 @@ class CreditNoteTest { assertThat(creditNote.voidedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(creditNote.discounts().get()) .containsExactly( - CreditNote.Discount.builder() + CreditNoteDiscountModel.builder() .amountApplied("amount_applied") - .discountType(CreditNote.Discount.DiscountType.PERCENTAGE) + .discountType(CreditNoteDiscountModel.DiscountType.PERCENTAGE) .percentageDiscount(0.0) .addAppliesToPrice( - CreditNote.Discount.AppliesToPrice.builder().id("id").name("name").build() + CreditNoteDiscountModel.AppliesToPrice.builder() + .id("id") + .name("name") + .build() ) .reason("reason") .build() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomRatingFunctionConfigModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomRatingFunctionConfigModelTest.kt new file mode 100644 index 000000000..7c33844be --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomRatingFunctionConfigModelTest.kt @@ -0,0 +1,19 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class CustomRatingFunctionConfigModelTest { + + @Test + fun createCustomRatingFunctionConfigModel() { + val customRatingFunctionConfigModel = + CustomRatingFunctionConfigModel.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + assertThat(customRatingFunctionConfigModel).isNotNull + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponseTest.kt deleted file mode 100644 index fdf580644..000000000 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponseTest.kt +++ /dev/null @@ -1,56 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class CustomerBalanceTransactionCreateResponseTest { - - @Test - fun createCustomerBalanceTransactionCreateResponse() { - val customerBalanceTransactionCreateResponse = - CustomerBalanceTransactionCreateResponse.builder() - .id("cgZa3SXcsPTVyC4Y") - .action(CustomerBalanceTransactionCreateResponse.Action.APPLIED_TO_INVOICE) - .amount("11.00") - .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) - .creditNote( - CustomerBalanceTransactionCreateResponse.CreditNote.builder().id("id").build() - ) - .description("An optional description") - .endingBalance("22.00") - .invoice( - CustomerBalanceTransactionCreateResponse.Invoice.builder() - .id("gXcsPTVyC4YZa3Sc") - .build() - ) - .startingBalance("33.00") - .type(CustomerBalanceTransactionCreateResponse.Type.INCREMENT) - .build() - assertThat(customerBalanceTransactionCreateResponse).isNotNull - assertThat(customerBalanceTransactionCreateResponse.id()).isEqualTo("cgZa3SXcsPTVyC4Y") - assertThat(customerBalanceTransactionCreateResponse.action()) - .isEqualTo(CustomerBalanceTransactionCreateResponse.Action.APPLIED_TO_INVOICE) - assertThat(customerBalanceTransactionCreateResponse.amount()).isEqualTo("11.00") - assertThat(customerBalanceTransactionCreateResponse.createdAt()) - .isEqualTo(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) - assertThat(customerBalanceTransactionCreateResponse.creditNote()) - .contains( - CustomerBalanceTransactionCreateResponse.CreditNote.builder().id("id").build() - ) - assertThat(customerBalanceTransactionCreateResponse.description()) - .contains("An optional description") - assertThat(customerBalanceTransactionCreateResponse.endingBalance()).isEqualTo("22.00") - assertThat(customerBalanceTransactionCreateResponse.invoice()) - .contains( - CustomerBalanceTransactionCreateResponse.Invoice.builder() - .id("gXcsPTVyC4YZa3Sc") - .build() - ) - assertThat(customerBalanceTransactionCreateResponse.startingBalance()).isEqualTo("33.00") - assertThat(customerBalanceTransactionCreateResponse.type()) - .isEqualTo(CustomerBalanceTransactionCreateResponse.Type.INCREMENT) - } -} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponseTest.kt deleted file mode 100644 index 3df33f230..000000000 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponseTest.kt +++ /dev/null @@ -1,54 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class CustomerBalanceTransactionListResponseTest { - - @Test - fun createCustomerBalanceTransactionListResponse() { - val customerBalanceTransactionListResponse = - CustomerBalanceTransactionListResponse.builder() - .id("cgZa3SXcsPTVyC4Y") - .action(CustomerBalanceTransactionListResponse.Action.APPLIED_TO_INVOICE) - .amount("11.00") - .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) - .creditNote( - CustomerBalanceTransactionListResponse.CreditNote.builder().id("id").build() - ) - .description("An optional description") - .endingBalance("22.00") - .invoice( - CustomerBalanceTransactionListResponse.Invoice.builder() - .id("gXcsPTVyC4YZa3Sc") - .build() - ) - .startingBalance("33.00") - .type(CustomerBalanceTransactionListResponse.Type.INCREMENT) - .build() - assertThat(customerBalanceTransactionListResponse).isNotNull - assertThat(customerBalanceTransactionListResponse.id()).isEqualTo("cgZa3SXcsPTVyC4Y") - assertThat(customerBalanceTransactionListResponse.action()) - .isEqualTo(CustomerBalanceTransactionListResponse.Action.APPLIED_TO_INVOICE) - assertThat(customerBalanceTransactionListResponse.amount()).isEqualTo("11.00") - assertThat(customerBalanceTransactionListResponse.createdAt()) - .isEqualTo(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) - assertThat(customerBalanceTransactionListResponse.creditNote()) - .contains(CustomerBalanceTransactionListResponse.CreditNote.builder().id("id").build()) - assertThat(customerBalanceTransactionListResponse.description()) - .contains("An optional description") - assertThat(customerBalanceTransactionListResponse.endingBalance()).isEqualTo("22.00") - assertThat(customerBalanceTransactionListResponse.invoice()) - .contains( - CustomerBalanceTransactionListResponse.Invoice.builder() - .id("gXcsPTVyC4YZa3Sc") - .build() - ) - assertThat(customerBalanceTransactionListResponse.startingBalance()).isEqualTo("33.00") - assertThat(customerBalanceTransactionListResponse.type()) - .isEqualTo(CustomerBalanceTransactionListResponse.Type.INCREMENT) - } -} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerBalanceTransactionModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerBalanceTransactionModelTest.kt new file mode 100644 index 000000000..d195e4fa2 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerBalanceTransactionModelTest.kt @@ -0,0 +1,48 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class CustomerBalanceTransactionModelTest { + + @Test + fun createCustomerBalanceTransactionModel() { + val customerBalanceTransactionModel = + CustomerBalanceTransactionModel.builder() + .id("cgZa3SXcsPTVyC4Y") + .action(CustomerBalanceTransactionModel.Action.APPLIED_TO_INVOICE) + .amount("11.00") + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .creditNote(CustomerBalanceTransactionModel.CreditNote.builder().id("id").build()) + .description("An optional description") + .endingBalance("22.00") + .invoice( + CustomerBalanceTransactionModel.Invoice.builder().id("gXcsPTVyC4YZa3Sc").build() + ) + .startingBalance("33.00") + .type(CustomerBalanceTransactionModel.Type.INCREMENT) + .build() + assertThat(customerBalanceTransactionModel).isNotNull + assertThat(customerBalanceTransactionModel.id()).isEqualTo("cgZa3SXcsPTVyC4Y") + assertThat(customerBalanceTransactionModel.action()) + .isEqualTo(CustomerBalanceTransactionModel.Action.APPLIED_TO_INVOICE) + assertThat(customerBalanceTransactionModel.amount()).isEqualTo("11.00") + assertThat(customerBalanceTransactionModel.createdAt()) + .isEqualTo(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + assertThat(customerBalanceTransactionModel.creditNote()) + .contains(CustomerBalanceTransactionModel.CreditNote.builder().id("id").build()) + assertThat(customerBalanceTransactionModel.description()) + .contains("An optional description") + assertThat(customerBalanceTransactionModel.endingBalance()).isEqualTo("22.00") + assertThat(customerBalanceTransactionModel.invoice()) + .contains( + CustomerBalanceTransactionModel.Invoice.builder().id("gXcsPTVyC4YZa3Sc").build() + ) + assertThat(customerBalanceTransactionModel.startingBalance()).isEqualTo("33.00") + assertThat(customerBalanceTransactionModel.type()) + .isEqualTo(CustomerBalanceTransactionModel.Type.INCREMENT) + } +} 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 deleted file mode 100644 index 1900e026f..000000000 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponseTest.kt +++ /dev/null @@ -1,238 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.withorb.api.core.JsonValue -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class CustomerCostListByExternalIdResponseTest { - - @Test - fun createCustomerCostListByExternalIdResponse() { - val customerCostListByExternalIdResponse = - CustomerCostListByExternalIdResponse.builder() - .addData( - CustomerCostListByExternalIdResponse.Data.builder() - .addPerPriceCost( - CustomerCostListByExternalIdResponse.Data.PerPriceCost.builder() - .price( - Price.UnitPrice.builder() - .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() - ) - .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration - .DurationUnit - .DAY - ) - .build() - ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) - .conversionRate(0.0) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() - .allowsRollover(true) - .currency("currency") - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType( - PercentageDiscount.DiscountType.PERCENTAGE - ) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration - .DurationUnit - .DAY - ) - .build() - ) - .item( - Price.UnitPrice.Item.builder() - .id("id") - .name("name") - .build() - ) - .maximum( - Price.UnitPrice.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.UnitPrice.Metadata.builder() - .putAdditionalProperty( - "foo", - JsonValue.from("string"), - ) - .build() - ) - .minimum( - Price.UnitPrice.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) - .name("name") - .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) - .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId( - "dimensional_price_group_id" - ) - .build() - ) - .build() - ) - .priceId("price_id") - .subtotal("subtotal") - .total("total") - .quantity(0.0) - .build() - ) - .subtotal("subtotal") - .timeframeEnd(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .timeframeStart(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .total("total") - .build() - ) - .build() - assertThat(customerCostListByExternalIdResponse).isNotNull - assertThat(customerCostListByExternalIdResponse.data()) - .containsExactly( - CustomerCostListByExternalIdResponse.Data.builder() - .addPerPriceCost( - CustomerCostListByExternalIdResponse.Data.PerPriceCost.builder() - .price( - Price.UnitPrice.builder() - .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) - .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration - .DurationUnit - .DAY - ) - .build() - ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) - .conversionRate(0.0) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() - .allowsRollover(true) - .currency("currency") - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType( - PercentageDiscount.DiscountType.PERCENTAGE - ) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration - .DurationUnit - .DAY - ) - .build() - ) - .item( - Price.UnitPrice.Item.builder().id("id").name("name").build() - ) - .maximum( - Price.UnitPrice.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.UnitPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Price.UnitPrice.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) - .name("name") - .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) - .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) - .build() - ) - .priceId("price_id") - .subtotal("subtotal") - .total("total") - .quantity(0.0) - .build() - ) - .subtotal("subtotal") - .timeframeEnd(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .timeframeStart(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .total("total") - .build() - ) - } -} 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/CustomerCostsModelTest.kt similarity index 68% rename from orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCostListResponseTest.kt rename to orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCostsModelTest.kt index 6181b9b29..60cf1d094 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/CustomerCostsModelTest.kt @@ -7,39 +7,35 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class CustomerCostListResponseTest { +class CustomerCostsModelTest { @Test - fun createCustomerCostListResponse() { - val customerCostListResponse = - CustomerCostListResponse.builder() + fun createCustomerCostsModel() { + val customerCostsModel = + CustomerCostsModel.builder() .addData( - CustomerCostListResponse.Data.builder() + AggregatedCostModel.builder() .addPerPriceCost( - CustomerCostListResponse.Data.PerPriceCost.builder() + AggregatedCostModel.PerPriceCost.builder() .price( - Price.UnitPrice.builder() + PriceModel.UnitPrice.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + BillableMetricTinyModel.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration - .DurationUnit - .DAY + BillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + AllocationModel.builder() .allowsRollover(true) .currency("currency") .build() @@ -59,30 +55,23 @@ class CustomerCostListResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration - .DurationUnit - .DAY + BillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) - .item( - Price.UnitPrice.Item.builder() - .id("id") - .name("name") - .build() - ) + .item(ItemSlimModel.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + PriceModel.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -90,23 +79,23 @@ class CustomerCostListResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) + .modelType(PriceModel.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + UnitConfigModel.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + DimensionalPriceConfigurationModel.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -128,33 +117,31 @@ class CustomerCostListResponseTest { .build() ) .build() - assertThat(customerCostListResponse).isNotNull - assertThat(customerCostListResponse.data()) + assertThat(customerCostsModel).isNotNull + assertThat(customerCostsModel.data()) .containsExactly( - CustomerCostListResponse.Data.builder() + AggregatedCostModel.builder() .addPerPriceCost( - CustomerCostListResponse.Data.PerPriceCost.builder() + AggregatedCostModel.PerPriceCost.builder() .price( - Price.UnitPrice.builder() + PriceModel.UnitPrice.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + BillableMetricTinyModel.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration - .DurationUnit - .DAY + BillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + AllocationModel.builder() .allowsRollover(true) .currency("currency") .build() @@ -174,48 +161,42 @@ class CustomerCostListResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration - .DurationUnit - .DAY + BillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) - .item( - Price.UnitPrice.Item.builder().id("id").name("name").build() - ) + .item(ItemSlimModel.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + PriceModel.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) + .modelType(PriceModel.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() + UnitConfigModel.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + DimensionalPriceConfigurationModel.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() 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 c9c304082..72ce616f2 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 @@ -15,10 +15,9 @@ class CustomerCreateParamsTest { .email("dev@stainless.com") .name("x") .accountingSyncConfiguration( - CustomerCreateParams.AccountingSyncConfiguration.builder() + NewAccountingSyncConfigurationModel.builder() .addAccountingProvider( - CustomerCreateParams.AccountingSyncConfiguration.AccountingProvider - .builder() + NewAccountingSyncConfigurationModel.AccountingProvider.builder() .externalProviderId("external_provider_id") .providerType("provider_type") .build() @@ -29,7 +28,7 @@ class CustomerCreateParamsTest { .addAdditionalEmail("string") .autoCollection(true) .billingAddress( - CustomerCreateParams.BillingAddress.builder() + AddressInputModel.builder() .city("city") .country("country") .line1("line1") @@ -42,7 +41,7 @@ class CustomerCreateParamsTest { .emailDelivery(true) .externalCustomerId("external_customer_id") .hierarchy( - CustomerCreateParams.Hierarchy.builder() + CustomerHierarchyConfigModel.builder() .addChildCustomerId("string") .parentCustomerId("parent_customer_id") .build() @@ -54,11 +53,9 @@ class CustomerCreateParamsTest { ) .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") - .reportingConfiguration( - CustomerCreateParams.ReportingConfiguration.builder().exempt(true).build() - ) + .reportingConfiguration(NewReportingConfigurationModel.builder().exempt(true).build()) .shippingAddress( - CustomerCreateParams.ShippingAddress.builder() + AddressInputModel.builder() .city("city") .country("country") .line1("line1") @@ -68,19 +65,18 @@ class CustomerCreateParamsTest { .build() ) .taxConfiguration( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration.builder() + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration.TaxProvider - .AVALARA + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.TaxProvider.AVALARA ) .taxExemptionCode("tax_exemption_code") .build() ) .taxId( - CustomerCreateParams.TaxId.builder() - .country(CustomerCreateParams.TaxId.Country.AD) - .type(CustomerCreateParams.TaxId.Type.AD_NRT) + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) .value("value") .build() ) @@ -95,10 +91,9 @@ class CustomerCreateParamsTest { .email("dev@stainless.com") .name("x") .accountingSyncConfiguration( - CustomerCreateParams.AccountingSyncConfiguration.builder() + NewAccountingSyncConfigurationModel.builder() .addAccountingProvider( - CustomerCreateParams.AccountingSyncConfiguration.AccountingProvider - .builder() + NewAccountingSyncConfigurationModel.AccountingProvider.builder() .externalProviderId("external_provider_id") .providerType("provider_type") .build() @@ -109,7 +104,7 @@ class CustomerCreateParamsTest { .addAdditionalEmail("string") .autoCollection(true) .billingAddress( - CustomerCreateParams.BillingAddress.builder() + AddressInputModel.builder() .city("city") .country("country") .line1("line1") @@ -122,7 +117,7 @@ class CustomerCreateParamsTest { .emailDelivery(true) .externalCustomerId("external_customer_id") .hierarchy( - CustomerCreateParams.Hierarchy.builder() + CustomerHierarchyConfigModel.builder() .addChildCustomerId("string") .parentCustomerId("parent_customer_id") .build() @@ -135,10 +130,10 @@ class CustomerCreateParamsTest { .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .reportingConfiguration( - CustomerCreateParams.ReportingConfiguration.builder().exempt(true).build() + NewReportingConfigurationModel.builder().exempt(true).build() ) .shippingAddress( - CustomerCreateParams.ShippingAddress.builder() + AddressInputModel.builder() .city("city") .country("country") .line1("line1") @@ -148,20 +143,18 @@ class CustomerCreateParamsTest { .build() ) .taxConfiguration( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration.builder() + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.TaxProvider.AVALARA ) .taxExemptionCode("tax_exemption_code") .build() ) .taxId( - CustomerCreateParams.TaxId.builder() - .country(CustomerCreateParams.TaxId.Country.AD) - .type(CustomerCreateParams.TaxId.Type.AD_NRT) + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) .value("value") .build() ) @@ -175,10 +168,9 @@ class CustomerCreateParamsTest { assertThat(body.name()).isEqualTo("x") assertThat(body.accountingSyncConfiguration()) .contains( - CustomerCreateParams.AccountingSyncConfiguration.builder() + NewAccountingSyncConfigurationModel.builder() .addAccountingProvider( - CustomerCreateParams.AccountingSyncConfiguration.AccountingProvider - .builder() + NewAccountingSyncConfigurationModel.AccountingProvider.builder() .externalProviderId("external_provider_id") .providerType("provider_type") .build() @@ -190,7 +182,7 @@ class CustomerCreateParamsTest { assertThat(body.autoCollection()).contains(true) assertThat(body.billingAddress()) .contains( - CustomerCreateParams.BillingAddress.builder() + AddressInputModel.builder() .city("city") .country("country") .line1("line1") @@ -204,7 +196,7 @@ class CustomerCreateParamsTest { assertThat(body.externalCustomerId()).contains("external_customer_id") assertThat(body.hierarchy()) .contains( - CustomerCreateParams.Hierarchy.builder() + CustomerHierarchyConfigModel.builder() .addChildCustomerId("string") .parentCustomerId("parent_customer_id") .build() @@ -218,10 +210,10 @@ class CustomerCreateParamsTest { assertThat(body.paymentProvider()).contains(CustomerCreateParams.PaymentProvider.QUICKBOOKS) assertThat(body.paymentProviderId()).contains("payment_provider_id") assertThat(body.reportingConfiguration()) - .contains(CustomerCreateParams.ReportingConfiguration.builder().exempt(true).build()) + .contains(NewReportingConfigurationModel.builder().exempt(true).build()) assertThat(body.shippingAddress()) .contains( - CustomerCreateParams.ShippingAddress.builder() + AddressInputModel.builder() .city("city") .country("country") .line1("line1") @@ -232,13 +224,11 @@ class CustomerCreateParamsTest { ) assertThat(body.taxConfiguration()) .contains( - CustomerCreateParams.TaxConfiguration.ofNewAvalara( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration.builder() + NewTaxConfigurationModel.ofAvalaraTaxConfiguration( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.TaxProvider.AVALARA ) .taxExemptionCode("tax_exemption_code") .build() @@ -246,9 +236,9 @@ class CustomerCreateParamsTest { ) assertThat(body.taxId()) .contains( - CustomerCreateParams.TaxId.builder() - .country(CustomerCreateParams.TaxId.Country.AD) - .type(CustomerCreateParams.TaxId.Type.AD_NRT) + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) .value("value") .build() ) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditBalancesModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditBalancesModelTest.kt new file mode 100644 index 000000000..92dc6f0f1 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditBalancesModelTest.kt @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class CustomerCreditBalancesModelTest { + + @Test + fun createCustomerCreditBalancesModel() { + val customerCreditBalancesModel = + CustomerCreditBalancesModel.builder() + .addData( + CustomerCreditBalancesModel.Data.builder() + .id("id") + .balance(0.0) + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .maximumInitialBalance(0.0) + .perUnitCostBasis("per_unit_cost_basis") + .status(CustomerCreditBalancesModel.Data.Status.ACTIVE) + .build() + ) + .paginationMetadata( + PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build() + ) + .build() + assertThat(customerCreditBalancesModel).isNotNull + assertThat(customerCreditBalancesModel.data()) + .containsExactly( + CustomerCreditBalancesModel.Data.builder() + .id("id") + .balance(0.0) + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .maximumInitialBalance(0.0) + .perUnitCostBasis("per_unit_cost_basis") + .status(CustomerCreditBalancesModel.Data.Status.ACTIVE) + .build() + ) + assertThat(customerCreditBalancesModel.paginationMetadata()) + .isEqualTo(PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").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 ae551b207..2c61c4af6 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 @@ -13,14 +13,11 @@ class CustomerCreditLedgerCreateEntryByExternalIdParamsTest { fun create() { CustomerCreditLedgerCreateEntryByExternalIdParams.builder() .externalCustomerId("external_customer_id") - .body( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .builder() + .addCreditLedgerEntryRequest( + AddCreditLedgerEntryRequest.AddIncrementCreditLedgerEntryRequestParams.builder() .amount(0.0) .entryType( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams + AddCreditLedgerEntryRequest.AddIncrementCreditLedgerEntryRequestParams .EntryType .INCREMENT ) @@ -29,8 +26,7 @@ class CustomerCreditLedgerCreateEntryByExternalIdParamsTest { .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .invoiceSettings( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams + AddCreditLedgerEntryRequest.AddIncrementCreditLedgerEntryRequestParams .InvoiceSettings .builder() .autoCollection(true) @@ -40,8 +36,7 @@ class CustomerCreditLedgerCreateEntryByExternalIdParamsTest { .build() ) .metadata( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams + AddCreditLedgerEntryRequest.AddIncrementCreditLedgerEntryRequestParams .Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -58,14 +53,11 @@ class CustomerCreditLedgerCreateEntryByExternalIdParamsTest { val params = CustomerCreditLedgerCreateEntryByExternalIdParams.builder() .externalCustomerId("external_customer_id") - .body( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .builder() + .addCreditLedgerEntryRequest( + AddCreditLedgerEntryRequest.AddIncrementCreditLedgerEntryRequestParams.builder() .amount(0.0) .entryType( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams + AddCreditLedgerEntryRequest.AddIncrementCreditLedgerEntryRequestParams .EntryType .INCREMENT ) @@ -74,8 +66,7 @@ class CustomerCreditLedgerCreateEntryByExternalIdParamsTest { .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .invoiceSettings( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams + AddCreditLedgerEntryRequest.AddIncrementCreditLedgerEntryRequestParams .InvoiceSettings .builder() .autoCollection(true) @@ -85,8 +76,7 @@ class CustomerCreditLedgerCreateEntryByExternalIdParamsTest { .build() ) .metadata( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams + AddCreditLedgerEntryRequest.AddIncrementCreditLedgerEntryRequestParams .Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -101,44 +91,38 @@ class CustomerCreditLedgerCreateEntryByExternalIdParamsTest { assertThat(body) .isEqualTo( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .ofAddIncrementCreditLedgerEntryRequestParams( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .builder() - .amount(0.0) - .entryType( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .EntryType - .INCREMENT - ) - .currency("currency") - .description("description") - .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .invoiceSettings( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .InvoiceSettings - .builder() - .autoCollection(true) - .netTerms(0L) - .memo("memo") - .requireSuccessfulPayment(true) - .build() - ) - .metadata( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .Metadata - .builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .perUnitCostBasis("per_unit_cost_basis") - .build() - ) + AddCreditLedgerEntryRequest.ofIncrementCreditLedgerEntryRequestParams( + AddCreditLedgerEntryRequest.AddIncrementCreditLedgerEntryRequestParams.builder() + .amount(0.0) + .entryType( + AddCreditLedgerEntryRequest.AddIncrementCreditLedgerEntryRequestParams + .EntryType + .INCREMENT + ) + .currency("currency") + .description("description") + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .invoiceSettings( + AddCreditLedgerEntryRequest.AddIncrementCreditLedgerEntryRequestParams + .InvoiceSettings + .builder() + .autoCollection(true) + .netTerms(0L) + .memo("memo") + .requireSuccessfulPayment(true) + .build() + ) + .metadata( + AddCreditLedgerEntryRequest.AddIncrementCreditLedgerEntryRequestParams + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .perUnitCostBasis("per_unit_cost_basis") + .build() + ) ) } @@ -147,27 +131,23 @@ class CustomerCreditLedgerCreateEntryByExternalIdParamsTest { val params = CustomerCreditLedgerCreateEntryByExternalIdParams.builder() .externalCustomerId("external_customer_id") - .addIncrementCreditLedgerEntryRequestParamsBody(0.0) + .addIncrementCreditLedgerEntryRequestParamsCreditLedgerEntryRequest(0.0) .build() val body = params._body() assertThat(body) .isEqualTo( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .ofAddIncrementCreditLedgerEntryRequestParams( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .builder() - .amount(0.0) - .entryType( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .EntryType - .INCREMENT - ) - .build() - ) + AddCreditLedgerEntryRequest.ofIncrementCreditLedgerEntryRequestParams( + AddCreditLedgerEntryRequest.AddIncrementCreditLedgerEntryRequestParams.builder() + .amount(0.0) + .entryType( + AddCreditLedgerEntryRequest.AddIncrementCreditLedgerEntryRequestParams + .EntryType + .INCREMENT + ) + .build() + ) ) } @@ -176,7 +156,7 @@ class CustomerCreditLedgerCreateEntryByExternalIdParamsTest { val params = CustomerCreditLedgerCreateEntryByExternalIdParams.builder() .externalCustomerId("external_customer_id") - .addIncrementCreditLedgerEntryRequestParamsBody(0.0) + .addIncrementCreditLedgerEntryRequestParamsCreditLedgerEntryRequest(0.0) .build() assertThat(params).isNotNull // path param "externalCustomerId" 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 5dffd32eb..e249e10bc 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 @@ -13,14 +13,11 @@ class CustomerCreditLedgerCreateEntryParamsTest { fun create() { CustomerCreditLedgerCreateEntryParams.builder() .customerId("customer_id") - .body( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .builder() + .addCreditLedgerEntryRequest( + AddCreditLedgerEntryRequest.AddIncrementCreditLedgerEntryRequestParams.builder() .amount(0.0) .entryType( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams + AddCreditLedgerEntryRequest.AddIncrementCreditLedgerEntryRequestParams .EntryType .INCREMENT ) @@ -29,8 +26,7 @@ class CustomerCreditLedgerCreateEntryParamsTest { .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .invoiceSettings( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams + AddCreditLedgerEntryRequest.AddIncrementCreditLedgerEntryRequestParams .InvoiceSettings .builder() .autoCollection(true) @@ -40,8 +36,7 @@ class CustomerCreditLedgerCreateEntryParamsTest { .build() ) .metadata( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams + AddCreditLedgerEntryRequest.AddIncrementCreditLedgerEntryRequestParams .Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -58,14 +53,11 @@ class CustomerCreditLedgerCreateEntryParamsTest { val params = CustomerCreditLedgerCreateEntryParams.builder() .customerId("customer_id") - .body( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .builder() + .addCreditLedgerEntryRequest( + AddCreditLedgerEntryRequest.AddIncrementCreditLedgerEntryRequestParams.builder() .amount(0.0) .entryType( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams + AddCreditLedgerEntryRequest.AddIncrementCreditLedgerEntryRequestParams .EntryType .INCREMENT ) @@ -74,8 +66,7 @@ class CustomerCreditLedgerCreateEntryParamsTest { .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .invoiceSettings( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams + AddCreditLedgerEntryRequest.AddIncrementCreditLedgerEntryRequestParams .InvoiceSettings .builder() .autoCollection(true) @@ -85,8 +76,7 @@ class CustomerCreditLedgerCreateEntryParamsTest { .build() ) .metadata( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams + AddCreditLedgerEntryRequest.AddIncrementCreditLedgerEntryRequestParams .Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -101,44 +91,38 @@ class CustomerCreditLedgerCreateEntryParamsTest { assertThat(body) .isEqualTo( - CustomerCreditLedgerCreateEntryParams.Body - .ofAddIncrementCreditLedgerEntryRequestParams( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .builder() - .amount(0.0) - .entryType( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .EntryType - .INCREMENT - ) - .currency("currency") - .description("description") - .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .invoiceSettings( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .InvoiceSettings - .builder() - .autoCollection(true) - .netTerms(0L) - .memo("memo") - .requireSuccessfulPayment(true) - .build() - ) - .metadata( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .Metadata - .builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .perUnitCostBasis("per_unit_cost_basis") - .build() - ) + AddCreditLedgerEntryRequest.ofIncrementCreditLedgerEntryRequestParams( + AddCreditLedgerEntryRequest.AddIncrementCreditLedgerEntryRequestParams.builder() + .amount(0.0) + .entryType( + AddCreditLedgerEntryRequest.AddIncrementCreditLedgerEntryRequestParams + .EntryType + .INCREMENT + ) + .currency("currency") + .description("description") + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .invoiceSettings( + AddCreditLedgerEntryRequest.AddIncrementCreditLedgerEntryRequestParams + .InvoiceSettings + .builder() + .autoCollection(true) + .netTerms(0L) + .memo("memo") + .requireSuccessfulPayment(true) + .build() + ) + .metadata( + AddCreditLedgerEntryRequest.AddIncrementCreditLedgerEntryRequestParams + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .perUnitCostBasis("per_unit_cost_basis") + .build() + ) ) } @@ -147,27 +131,23 @@ class CustomerCreditLedgerCreateEntryParamsTest { val params = CustomerCreditLedgerCreateEntryParams.builder() .customerId("customer_id") - .addIncrementCreditLedgerEntryRequestParamsBody(0.0) + .addIncrementCreditLedgerEntryRequestParamsCreditLedgerEntryRequest(0.0) .build() val body = params._body() assertThat(body) .isEqualTo( - CustomerCreditLedgerCreateEntryParams.Body - .ofAddIncrementCreditLedgerEntryRequestParams( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .builder() - .amount(0.0) - .entryType( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .EntryType - .INCREMENT - ) - .build() - ) + AddCreditLedgerEntryRequest.ofIncrementCreditLedgerEntryRequestParams( + AddCreditLedgerEntryRequest.AddIncrementCreditLedgerEntryRequestParams.builder() + .amount(0.0) + .entryType( + AddCreditLedgerEntryRequest.AddIncrementCreditLedgerEntryRequestParams + .EntryType + .INCREMENT + ) + .build() + ) ) } @@ -176,7 +156,7 @@ class CustomerCreditLedgerCreateEntryParamsTest { val params = CustomerCreditLedgerCreateEntryParams.builder() .customerId("customer_id") - .addIncrementCreditLedgerEntryRequestParamsBody(0.0) + .addIncrementCreditLedgerEntryRequestParamsCreditLedgerEntryRequest(0.0) .build() assertThat(params).isNotNull // path param "customerId" 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 deleted file mode 100644 index 32664946d..000000000 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponseTest.kt +++ /dev/null @@ -1,36 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class CustomerCreditListByExternalIdResponseTest { - - @Test - fun createCustomerCreditListByExternalIdResponse() { - val customerCreditListByExternalIdResponse = - CustomerCreditListByExternalIdResponse.builder() - .id("id") - .balance(0.0) - .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .maximumInitialBalance(0.0) - .perUnitCostBasis("per_unit_cost_basis") - .status(CustomerCreditListByExternalIdResponse.Status.ACTIVE) - .build() - assertThat(customerCreditListByExternalIdResponse).isNotNull - assertThat(customerCreditListByExternalIdResponse.id()).isEqualTo("id") - assertThat(customerCreditListByExternalIdResponse.balance()).isEqualTo(0.0) - assertThat(customerCreditListByExternalIdResponse.effectiveDate()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(customerCreditListByExternalIdResponse.expiryDate()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(customerCreditListByExternalIdResponse.maximumInitialBalance()).contains(0.0) - assertThat(customerCreditListByExternalIdResponse.perUnitCostBasis()) - .contains("per_unit_cost_basis") - assertThat(customerCreditListByExternalIdResponse.status()) - .isEqualTo(CustomerCreditListByExternalIdResponse.Status.ACTIVE) - } -} 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 deleted file mode 100644 index f41301617..000000000 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditListResponseTest.kt +++ /dev/null @@ -1,35 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class CustomerCreditListResponseTest { - - @Test - fun createCustomerCreditListResponse() { - val customerCreditListResponse = - CustomerCreditListResponse.builder() - .id("id") - .balance(0.0) - .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .maximumInitialBalance(0.0) - .perUnitCostBasis("per_unit_cost_basis") - .status(CustomerCreditListResponse.Status.ACTIVE) - .build() - assertThat(customerCreditListResponse).isNotNull - assertThat(customerCreditListResponse.id()).isEqualTo("id") - assertThat(customerCreditListResponse.balance()).isEqualTo(0.0) - assertThat(customerCreditListResponse.effectiveDate()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(customerCreditListResponse.expiryDate()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(customerCreditListResponse.maximumInitialBalance()).contains(0.0) - assertThat(customerCreditListResponse.perUnitCostBasis()).contains("per_unit_cost_basis") - assertThat(customerCreditListResponse.status()) - .isEqualTo(CustomerCreditListResponse.Status.ACTIVE) - } -} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdParamsTest.kt index 24843f644..b4982dea5 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdParamsTest.kt @@ -3,7 +3,6 @@ package com.withorb.api.models import java.time.OffsetDateTime -import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -13,21 +12,25 @@ class CustomerCreditTopUpCreateByExternalIdParamsTest { fun create() { CustomerCreditTopUpCreateByExternalIdParams.builder() .externalCustomerId("external_customer_id") - .amount("amount") - .currency("currency") - .invoiceSettings( - CustomerCreditTopUpCreateByExternalIdParams.InvoiceSettings.builder() - .autoCollection(true) - .netTerms(0L) - .memo("memo") - .requireSuccessfulPayment(true) + .addCreditTopUpRequest( + AddCreditTopUpRequest.builder() + .amount("amount") + .currency("currency") + .invoiceSettings( + AddCreditTopUpRequest.InvoiceSettings.builder() + .autoCollection(true) + .netTerms(0L) + .memo("memo") + .requireSuccessfulPayment(true) + .build() + ) + .perUnitCostBasis("per_unit_cost_basis") + .threshold("threshold") + .activeFrom(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiresAfter(0L) + .expiresAfterUnit(AddCreditTopUpRequest.ExpiresAfterUnit.DAY) .build() ) - .perUnitCostBasis("per_unit_cost_basis") - .threshold("threshold") - .activeFrom(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expiresAfter(0L) - .expiresAfterUnit(CustomerCreditTopUpCreateByExternalIdParams.ExpiresAfterUnit.DAY) .build() } @@ -36,43 +39,49 @@ class CustomerCreditTopUpCreateByExternalIdParamsTest { val params = CustomerCreditTopUpCreateByExternalIdParams.builder() .externalCustomerId("external_customer_id") - .amount("amount") - .currency("currency") - .invoiceSettings( - CustomerCreditTopUpCreateByExternalIdParams.InvoiceSettings.builder() - .autoCollection(true) - .netTerms(0L) - .memo("memo") - .requireSuccessfulPayment(true) + .addCreditTopUpRequest( + AddCreditTopUpRequest.builder() + .amount("amount") + .currency("currency") + .invoiceSettings( + AddCreditTopUpRequest.InvoiceSettings.builder() + .autoCollection(true) + .netTerms(0L) + .memo("memo") + .requireSuccessfulPayment(true) + .build() + ) + .perUnitCostBasis("per_unit_cost_basis") + .threshold("threshold") + .activeFrom(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiresAfter(0L) + .expiresAfterUnit(AddCreditTopUpRequest.ExpiresAfterUnit.DAY) .build() ) - .perUnitCostBasis("per_unit_cost_basis") - .threshold("threshold") - .activeFrom(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expiresAfter(0L) - .expiresAfterUnit(CustomerCreditTopUpCreateByExternalIdParams.ExpiresAfterUnit.DAY) .build() val body = params._body() - assertNotNull(body) - assertThat(body.amount()).isEqualTo("amount") - assertThat(body.currency()).isEqualTo("currency") - assertThat(body.invoiceSettings()) + assertThat(body) .isEqualTo( - CustomerCreditTopUpCreateByExternalIdParams.InvoiceSettings.builder() - .autoCollection(true) - .netTerms(0L) - .memo("memo") - .requireSuccessfulPayment(true) + AddCreditTopUpRequest.builder() + .amount("amount") + .currency("currency") + .invoiceSettings( + AddCreditTopUpRequest.InvoiceSettings.builder() + .autoCollection(true) + .netTerms(0L) + .memo("memo") + .requireSuccessfulPayment(true) + .build() + ) + .perUnitCostBasis("per_unit_cost_basis") + .threshold("threshold") + .activeFrom(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiresAfter(0L) + .expiresAfterUnit(AddCreditTopUpRequest.ExpiresAfterUnit.DAY) .build() ) - assertThat(body.perUnitCostBasis()).isEqualTo("per_unit_cost_basis") - assertThat(body.threshold()).isEqualTo("threshold") - assertThat(body.activeFrom()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(body.expiresAfter()).contains(0L) - assertThat(body.expiresAfterUnit()) - .contains(CustomerCreditTopUpCreateByExternalIdParams.ExpiresAfterUnit.DAY) } @Test @@ -80,32 +89,39 @@ class CustomerCreditTopUpCreateByExternalIdParamsTest { val params = CustomerCreditTopUpCreateByExternalIdParams.builder() .externalCustomerId("external_customer_id") - .amount("amount") - .currency("currency") - .invoiceSettings( - CustomerCreditTopUpCreateByExternalIdParams.InvoiceSettings.builder() - .autoCollection(true) - .netTerms(0L) + .addCreditTopUpRequest( + AddCreditTopUpRequest.builder() + .amount("amount") + .currency("currency") + .invoiceSettings( + AddCreditTopUpRequest.InvoiceSettings.builder() + .autoCollection(true) + .netTerms(0L) + .build() + ) + .perUnitCostBasis("per_unit_cost_basis") + .threshold("threshold") .build() ) - .perUnitCostBasis("per_unit_cost_basis") - .threshold("threshold") .build() val body = params._body() - assertNotNull(body) - assertThat(body.amount()).isEqualTo("amount") - assertThat(body.currency()).isEqualTo("currency") - assertThat(body.invoiceSettings()) + assertThat(body) .isEqualTo( - CustomerCreditTopUpCreateByExternalIdParams.InvoiceSettings.builder() - .autoCollection(true) - .netTerms(0L) + AddCreditTopUpRequest.builder() + .amount("amount") + .currency("currency") + .invoiceSettings( + AddCreditTopUpRequest.InvoiceSettings.builder() + .autoCollection(true) + .netTerms(0L) + .build() + ) + .perUnitCostBasis("per_unit_cost_basis") + .threshold("threshold") .build() ) - assertThat(body.perUnitCostBasis()).isEqualTo("per_unit_cost_basis") - assertThat(body.threshold()).isEqualTo("threshold") } @Test @@ -113,16 +129,20 @@ class CustomerCreditTopUpCreateByExternalIdParamsTest { val params = CustomerCreditTopUpCreateByExternalIdParams.builder() .externalCustomerId("external_customer_id") - .amount("amount") - .currency("currency") - .invoiceSettings( - CustomerCreditTopUpCreateByExternalIdParams.InvoiceSettings.builder() - .autoCollection(true) - .netTerms(0L) + .addCreditTopUpRequest( + AddCreditTopUpRequest.builder() + .amount("amount") + .currency("currency") + .invoiceSettings( + AddCreditTopUpRequest.InvoiceSettings.builder() + .autoCollection(true) + .netTerms(0L) + .build() + ) + .perUnitCostBasis("per_unit_cost_basis") + .threshold("threshold") .build() ) - .perUnitCostBasis("per_unit_cost_basis") - .threshold("threshold") .build() assertThat(params).isNotNull // path param "externalCustomerId" diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdResponseTest.kt deleted file mode 100644 index b79e220ef..000000000 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdResponseTest.kt +++ /dev/null @@ -1,52 +0,0 @@ -// 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 - -class CustomerCreditTopUpCreateByExternalIdResponseTest { - - @Test - fun createCustomerCreditTopUpCreateByExternalIdResponse() { - val customerCreditTopUpCreateByExternalIdResponse = - CustomerCreditTopUpCreateByExternalIdResponse.builder() - .id("id") - .amount("amount") - .currency("currency") - .invoiceSettings( - CustomerCreditTopUpCreateByExternalIdResponse.InvoiceSettings.builder() - .autoCollection(true) - .netTerms(0L) - .memo("memo") - .requireSuccessfulPayment(true) - .build() - ) - .perUnitCostBasis("per_unit_cost_basis") - .threshold("threshold") - .expiresAfter(0L) - .expiresAfterUnit( - CustomerCreditTopUpCreateByExternalIdResponse.ExpiresAfterUnit.DAY - ) - .build() - assertThat(customerCreditTopUpCreateByExternalIdResponse).isNotNull - assertThat(customerCreditTopUpCreateByExternalIdResponse.id()).isEqualTo("id") - assertThat(customerCreditTopUpCreateByExternalIdResponse.amount()).isEqualTo("amount") - assertThat(customerCreditTopUpCreateByExternalIdResponse.currency()).isEqualTo("currency") - assertThat(customerCreditTopUpCreateByExternalIdResponse.invoiceSettings()) - .isEqualTo( - CustomerCreditTopUpCreateByExternalIdResponse.InvoiceSettings.builder() - .autoCollection(true) - .netTerms(0L) - .memo("memo") - .requireSuccessfulPayment(true) - .build() - ) - assertThat(customerCreditTopUpCreateByExternalIdResponse.perUnitCostBasis()) - .isEqualTo("per_unit_cost_basis") - assertThat(customerCreditTopUpCreateByExternalIdResponse.threshold()).isEqualTo("threshold") - assertThat(customerCreditTopUpCreateByExternalIdResponse.expiresAfter()).contains(0L) - assertThat(customerCreditTopUpCreateByExternalIdResponse.expiresAfterUnit()) - .contains(CustomerCreditTopUpCreateByExternalIdResponse.ExpiresAfterUnit.DAY) - } -} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateParamsTest.kt index fe37d9cad..0d18171c0 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateParamsTest.kt @@ -3,7 +3,6 @@ package com.withorb.api.models import java.time.OffsetDateTime -import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -13,21 +12,25 @@ class CustomerCreditTopUpCreateParamsTest { fun create() { CustomerCreditTopUpCreateParams.builder() .customerId("customer_id") - .amount("amount") - .currency("currency") - .invoiceSettings( - CustomerCreditTopUpCreateParams.InvoiceSettings.builder() - .autoCollection(true) - .netTerms(0L) - .memo("memo") - .requireSuccessfulPayment(true) + .addCreditTopUpRequest( + AddCreditTopUpRequest.builder() + .amount("amount") + .currency("currency") + .invoiceSettings( + AddCreditTopUpRequest.InvoiceSettings.builder() + .autoCollection(true) + .netTerms(0L) + .memo("memo") + .requireSuccessfulPayment(true) + .build() + ) + .perUnitCostBasis("per_unit_cost_basis") + .threshold("threshold") + .activeFrom(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiresAfter(0L) + .expiresAfterUnit(AddCreditTopUpRequest.ExpiresAfterUnit.DAY) .build() ) - .perUnitCostBasis("per_unit_cost_basis") - .threshold("threshold") - .activeFrom(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expiresAfter(0L) - .expiresAfterUnit(CustomerCreditTopUpCreateParams.ExpiresAfterUnit.DAY) .build() } @@ -36,43 +39,49 @@ class CustomerCreditTopUpCreateParamsTest { val params = CustomerCreditTopUpCreateParams.builder() .customerId("customer_id") - .amount("amount") - .currency("currency") - .invoiceSettings( - CustomerCreditTopUpCreateParams.InvoiceSettings.builder() - .autoCollection(true) - .netTerms(0L) - .memo("memo") - .requireSuccessfulPayment(true) + .addCreditTopUpRequest( + AddCreditTopUpRequest.builder() + .amount("amount") + .currency("currency") + .invoiceSettings( + AddCreditTopUpRequest.InvoiceSettings.builder() + .autoCollection(true) + .netTerms(0L) + .memo("memo") + .requireSuccessfulPayment(true) + .build() + ) + .perUnitCostBasis("per_unit_cost_basis") + .threshold("threshold") + .activeFrom(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiresAfter(0L) + .expiresAfterUnit(AddCreditTopUpRequest.ExpiresAfterUnit.DAY) .build() ) - .perUnitCostBasis("per_unit_cost_basis") - .threshold("threshold") - .activeFrom(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expiresAfter(0L) - .expiresAfterUnit(CustomerCreditTopUpCreateParams.ExpiresAfterUnit.DAY) .build() val body = params._body() - assertNotNull(body) - assertThat(body.amount()).isEqualTo("amount") - assertThat(body.currency()).isEqualTo("currency") - assertThat(body.invoiceSettings()) + assertThat(body) .isEqualTo( - CustomerCreditTopUpCreateParams.InvoiceSettings.builder() - .autoCollection(true) - .netTerms(0L) - .memo("memo") - .requireSuccessfulPayment(true) + AddCreditTopUpRequest.builder() + .amount("amount") + .currency("currency") + .invoiceSettings( + AddCreditTopUpRequest.InvoiceSettings.builder() + .autoCollection(true) + .netTerms(0L) + .memo("memo") + .requireSuccessfulPayment(true) + .build() + ) + .perUnitCostBasis("per_unit_cost_basis") + .threshold("threshold") + .activeFrom(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiresAfter(0L) + .expiresAfterUnit(AddCreditTopUpRequest.ExpiresAfterUnit.DAY) .build() ) - assertThat(body.perUnitCostBasis()).isEqualTo("per_unit_cost_basis") - assertThat(body.threshold()).isEqualTo("threshold") - assertThat(body.activeFrom()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(body.expiresAfter()).contains(0L) - assertThat(body.expiresAfterUnit()) - .contains(CustomerCreditTopUpCreateParams.ExpiresAfterUnit.DAY) } @Test @@ -80,32 +89,39 @@ class CustomerCreditTopUpCreateParamsTest { val params = CustomerCreditTopUpCreateParams.builder() .customerId("customer_id") - .amount("amount") - .currency("currency") - .invoiceSettings( - CustomerCreditTopUpCreateParams.InvoiceSettings.builder() - .autoCollection(true) - .netTerms(0L) + .addCreditTopUpRequest( + AddCreditTopUpRequest.builder() + .amount("amount") + .currency("currency") + .invoiceSettings( + AddCreditTopUpRequest.InvoiceSettings.builder() + .autoCollection(true) + .netTerms(0L) + .build() + ) + .perUnitCostBasis("per_unit_cost_basis") + .threshold("threshold") .build() ) - .perUnitCostBasis("per_unit_cost_basis") - .threshold("threshold") .build() val body = params._body() - assertNotNull(body) - assertThat(body.amount()).isEqualTo("amount") - assertThat(body.currency()).isEqualTo("currency") - assertThat(body.invoiceSettings()) + assertThat(body) .isEqualTo( - CustomerCreditTopUpCreateParams.InvoiceSettings.builder() - .autoCollection(true) - .netTerms(0L) + AddCreditTopUpRequest.builder() + .amount("amount") + .currency("currency") + .invoiceSettings( + AddCreditTopUpRequest.InvoiceSettings.builder() + .autoCollection(true) + .netTerms(0L) + .build() + ) + .perUnitCostBasis("per_unit_cost_basis") + .threshold("threshold") .build() ) - assertThat(body.perUnitCostBasis()).isEqualTo("per_unit_cost_basis") - assertThat(body.threshold()).isEqualTo("threshold") } @Test @@ -113,16 +129,20 @@ class CustomerCreditTopUpCreateParamsTest { val params = CustomerCreditTopUpCreateParams.builder() .customerId("customer_id") - .amount("amount") - .currency("currency") - .invoiceSettings( - CustomerCreditTopUpCreateParams.InvoiceSettings.builder() - .autoCollection(true) - .netTerms(0L) + .addCreditTopUpRequest( + AddCreditTopUpRequest.builder() + .amount("amount") + .currency("currency") + .invoiceSettings( + AddCreditTopUpRequest.InvoiceSettings.builder() + .autoCollection(true) + .netTerms(0L) + .build() + ) + .perUnitCostBasis("per_unit_cost_basis") + .threshold("threshold") .build() ) - .perUnitCostBasis("per_unit_cost_basis") - .threshold("threshold") .build() assertThat(params).isNotNull // path param "customerId" diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateResponseTest.kt deleted file mode 100644 index 7cfe93182..000000000 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateResponseTest.kt +++ /dev/null @@ -1,50 +0,0 @@ -// 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 - -class CustomerCreditTopUpCreateResponseTest { - - @Test - fun createCustomerCreditTopUpCreateResponse() { - val customerCreditTopUpCreateResponse = - CustomerCreditTopUpCreateResponse.builder() - .id("id") - .amount("amount") - .currency("currency") - .invoiceSettings( - CustomerCreditTopUpCreateResponse.InvoiceSettings.builder() - .autoCollection(true) - .netTerms(0L) - .memo("memo") - .requireSuccessfulPayment(true) - .build() - ) - .perUnitCostBasis("per_unit_cost_basis") - .threshold("threshold") - .expiresAfter(0L) - .expiresAfterUnit(CustomerCreditTopUpCreateResponse.ExpiresAfterUnit.DAY) - .build() - assertThat(customerCreditTopUpCreateResponse).isNotNull - assertThat(customerCreditTopUpCreateResponse.id()).isEqualTo("id") - assertThat(customerCreditTopUpCreateResponse.amount()).isEqualTo("amount") - assertThat(customerCreditTopUpCreateResponse.currency()).isEqualTo("currency") - assertThat(customerCreditTopUpCreateResponse.invoiceSettings()) - .isEqualTo( - CustomerCreditTopUpCreateResponse.InvoiceSettings.builder() - .autoCollection(true) - .netTerms(0L) - .memo("memo") - .requireSuccessfulPayment(true) - .build() - ) - assertThat(customerCreditTopUpCreateResponse.perUnitCostBasis()) - .isEqualTo("per_unit_cost_basis") - assertThat(customerCreditTopUpCreateResponse.threshold()).isEqualTo("threshold") - assertThat(customerCreditTopUpCreateResponse.expiresAfter()).contains(0L) - assertThat(customerCreditTopUpCreateResponse.expiresAfterUnit()) - .contains(CustomerCreditTopUpCreateResponse.ExpiresAfterUnit.DAY) - } -} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdResponseTest.kt deleted file mode 100644 index e0e178051..000000000 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdResponseTest.kt +++ /dev/null @@ -1,50 +0,0 @@ -// 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 - -class CustomerCreditTopUpListByExternalIdResponseTest { - - @Test - fun createCustomerCreditTopUpListByExternalIdResponse() { - val customerCreditTopUpListByExternalIdResponse = - CustomerCreditTopUpListByExternalIdResponse.builder() - .id("id") - .amount("amount") - .currency("currency") - .invoiceSettings( - CustomerCreditTopUpListByExternalIdResponse.InvoiceSettings.builder() - .autoCollection(true) - .netTerms(0L) - .memo("memo") - .requireSuccessfulPayment(true) - .build() - ) - .perUnitCostBasis("per_unit_cost_basis") - .threshold("threshold") - .expiresAfter(0L) - .expiresAfterUnit(CustomerCreditTopUpListByExternalIdResponse.ExpiresAfterUnit.DAY) - .build() - assertThat(customerCreditTopUpListByExternalIdResponse).isNotNull - assertThat(customerCreditTopUpListByExternalIdResponse.id()).isEqualTo("id") - assertThat(customerCreditTopUpListByExternalIdResponse.amount()).isEqualTo("amount") - assertThat(customerCreditTopUpListByExternalIdResponse.currency()).isEqualTo("currency") - assertThat(customerCreditTopUpListByExternalIdResponse.invoiceSettings()) - .isEqualTo( - CustomerCreditTopUpListByExternalIdResponse.InvoiceSettings.builder() - .autoCollection(true) - .netTerms(0L) - .memo("memo") - .requireSuccessfulPayment(true) - .build() - ) - assertThat(customerCreditTopUpListByExternalIdResponse.perUnitCostBasis()) - .isEqualTo("per_unit_cost_basis") - assertThat(customerCreditTopUpListByExternalIdResponse.threshold()).isEqualTo("threshold") - assertThat(customerCreditTopUpListByExternalIdResponse.expiresAfter()).contains(0L) - assertThat(customerCreditTopUpListByExternalIdResponse.expiresAfterUnit()) - .contains(CustomerCreditTopUpListByExternalIdResponse.ExpiresAfterUnit.DAY) - } -} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditTopUpListResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditTopUpListResponseTest.kt deleted file mode 100644 index 1bba8d29b..000000000 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerCreditTopUpListResponseTest.kt +++ /dev/null @@ -1,50 +0,0 @@ -// 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 - -class CustomerCreditTopUpListResponseTest { - - @Test - fun createCustomerCreditTopUpListResponse() { - val customerCreditTopUpListResponse = - CustomerCreditTopUpListResponse.builder() - .id("id") - .amount("amount") - .currency("currency") - .invoiceSettings( - CustomerCreditTopUpListResponse.InvoiceSettings.builder() - .autoCollection(true) - .netTerms(0L) - .memo("memo") - .requireSuccessfulPayment(true) - .build() - ) - .perUnitCostBasis("per_unit_cost_basis") - .threshold("threshold") - .expiresAfter(0L) - .expiresAfterUnit(CustomerCreditTopUpListResponse.ExpiresAfterUnit.DAY) - .build() - assertThat(customerCreditTopUpListResponse).isNotNull - assertThat(customerCreditTopUpListResponse.id()).isEqualTo("id") - assertThat(customerCreditTopUpListResponse.amount()).isEqualTo("amount") - assertThat(customerCreditTopUpListResponse.currency()).isEqualTo("currency") - assertThat(customerCreditTopUpListResponse.invoiceSettings()) - .isEqualTo( - CustomerCreditTopUpListResponse.InvoiceSettings.builder() - .autoCollection(true) - .netTerms(0L) - .memo("memo") - .requireSuccessfulPayment(true) - .build() - ) - assertThat(customerCreditTopUpListResponse.perUnitCostBasis()) - .isEqualTo("per_unit_cost_basis") - assertThat(customerCreditTopUpListResponse.threshold()).isEqualTo("threshold") - assertThat(customerCreditTopUpListResponse.expiresAfter()).contains(0L) - assertThat(customerCreditTopUpListResponse.expiresAfterUnit()) - .contains(CustomerCreditTopUpListResponse.ExpiresAfterUnit.DAY) - } -} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerHierarchyConfigModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerHierarchyConfigModelTest.kt new file mode 100644 index 000000000..1e60bd827 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerHierarchyConfigModelTest.kt @@ -0,0 +1,21 @@ +// 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 + +class CustomerHierarchyConfigModelTest { + + @Test + fun createCustomerHierarchyConfigModel() { + val customerHierarchyConfigModel = + CustomerHierarchyConfigModel.builder() + .addChildCustomerId("string") + .parentCustomerId("parent_customer_id") + .build() + assertThat(customerHierarchyConfigModel).isNotNull + assertThat(customerHierarchyConfigModel.childCustomerIds().get()).containsExactly("string") + assertThat(customerHierarchyConfigModel.parentCustomerId()).contains("parent_customer_id") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerMinifiedModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerMinifiedModelTest.kt new file mode 100644 index 000000000..3c19e8197 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerMinifiedModelTest.kt @@ -0,0 +1,21 @@ +// 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 + +class CustomerMinifiedModelTest { + + @Test + fun createCustomerMinifiedModel() { + val customerMinifiedModel = + CustomerMinifiedModel.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + assertThat(customerMinifiedModel).isNotNull + assertThat(customerMinifiedModel.id()).isEqualTo("id") + assertThat(customerMinifiedModel.externalCustomerId()).contains("external_customer_id") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerModelTest.kt new file mode 100644 index 000000000..bc5e6041c --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerModelTest.kt @@ -0,0 +1,188 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.JsonValue +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class CustomerModelTest { + + @Test + fun createCustomerModel() { + val customerModel = + CustomerModel.builder() + .id("id") + .addAdditionalEmail("string") + .autoCollection(true) + .balance("balance") + .billingAddress( + AddressModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .email("email") + .emailDelivery(true) + .exemptFromAutomatedTax(true) + .externalCustomerId("external_customer_id") + .hierarchy( + CustomerModel.Hierarchy.builder() + .addChild( + CustomerMinifiedModel.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .parent( + CustomerMinifiedModel.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .build() + ) + .metadata( + CustomerModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .paymentProvider(CustomerModel.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .portalUrl("portal_url") + .shippingAddress( + AddressModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxId( + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) + .value("value") + .build() + ) + .timezone("timezone") + .accountingSyncConfiguration( + CustomerModel.AccountingSyncConfiguration.builder() + .addAccountingProvider( + CustomerModel.AccountingSyncConfiguration.AccountingProvider.builder() + .externalProviderId("external_provider_id") + .providerType( + CustomerModel.AccountingSyncConfiguration.AccountingProvider + .ProviderType + .QUICKBOOKS + ) + .build() + ) + .excluded(true) + .build() + ) + .reportingConfiguration( + CustomerModel.ReportingConfiguration.builder().exempt(true).build() + ) + .build() + assertThat(customerModel).isNotNull + assertThat(customerModel.id()).isEqualTo("id") + assertThat(customerModel.additionalEmails()).containsExactly("string") + assertThat(customerModel.autoCollection()).isEqualTo(true) + assertThat(customerModel.balance()).isEqualTo("balance") + assertThat(customerModel.billingAddress()) + .contains( + AddressModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + assertThat(customerModel.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(customerModel.currency()).contains("currency") + assertThat(customerModel.email()).isEqualTo("email") + assertThat(customerModel.emailDelivery()).isEqualTo(true) + assertThat(customerModel.exemptFromAutomatedTax()).contains(true) + assertThat(customerModel.externalCustomerId()).contains("external_customer_id") + assertThat(customerModel.hierarchy()) + .isEqualTo( + CustomerModel.Hierarchy.builder() + .addChild( + CustomerMinifiedModel.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .parent( + CustomerMinifiedModel.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .build() + ) + assertThat(customerModel.metadata()) + .isEqualTo( + CustomerModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(customerModel.name()).isEqualTo("name") + assertThat(customerModel.paymentProvider()) + .contains(CustomerModel.PaymentProvider.QUICKBOOKS) + assertThat(customerModel.paymentProviderId()).contains("payment_provider_id") + assertThat(customerModel.portalUrl()).contains("portal_url") + assertThat(customerModel.shippingAddress()) + .contains( + AddressModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + assertThat(customerModel.taxId()) + .contains( + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) + .value("value") + .build() + ) + assertThat(customerModel.timezone()).isEqualTo("timezone") + assertThat(customerModel.accountingSyncConfiguration()) + .contains( + CustomerModel.AccountingSyncConfiguration.builder() + .addAccountingProvider( + CustomerModel.AccountingSyncConfiguration.AccountingProvider.builder() + .externalProviderId("external_provider_id") + .providerType( + CustomerModel.AccountingSyncConfiguration.AccountingProvider + .ProviderType + .QUICKBOOKS + ) + .build() + ) + .excluded(true) + .build() + ) + assertThat(customerModel.reportingConfiguration()) + .contains(CustomerModel.ReportingConfiguration.builder().exempt(true).build()) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerTaxIdModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerTaxIdModelTest.kt new file mode 100644 index 000000000..f81d69396 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerTaxIdModelTest.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 + +class CustomerTaxIdModelTest { + + @Test + fun createCustomerTaxIdModel() { + val customerTaxIdModel = + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) + .value("value") + .build() + assertThat(customerTaxIdModel).isNotNull + assertThat(customerTaxIdModel.country()).isEqualTo(CustomerTaxIdModel.Country.AD) + assertThat(customerTaxIdModel.type()).isEqualTo(CustomerTaxIdModel.Type.AD_NRT) + assertThat(customerTaxIdModel.value()).isEqualTo("value") + } +} 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 ff8af944c..db758cb65 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CustomerTest.kt @@ -18,7 +18,7 @@ class CustomerTest { .autoCollection(true) .balance("balance") .billingAddress( - Customer.BillingAddress.builder() + AddressModel.builder() .city("city") .country("country") .line1("line1") @@ -36,13 +36,13 @@ class CustomerTest { .hierarchy( Customer.Hierarchy.builder() .addChild( - Customer.Hierarchy.Child.builder() + CustomerMinifiedModel.builder() .id("id") .externalCustomerId("external_customer_id") .build() ) .parent( - Customer.Hierarchy.Parent.builder() + CustomerMinifiedModel.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -59,7 +59,7 @@ class CustomerTest { .paymentProviderId("payment_provider_id") .portalUrl("portal_url") .shippingAddress( - Customer.ShippingAddress.builder() + AddressModel.builder() .city("city") .country("country") .line1("line1") @@ -69,9 +69,9 @@ class CustomerTest { .build() ) .taxId( - Customer.TaxId.builder() - .country(Customer.TaxId.Country.AD) - .type(Customer.TaxId.Type.AD_NRT) + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) .value("value") .build() ) @@ -102,7 +102,7 @@ class CustomerTest { assertThat(customer.balance()).isEqualTo("balance") assertThat(customer.billingAddress()) .contains( - Customer.BillingAddress.builder() + AddressModel.builder() .city("city") .country("country") .line1("line1") @@ -121,13 +121,13 @@ class CustomerTest { .isEqualTo( Customer.Hierarchy.builder() .addChild( - Customer.Hierarchy.Child.builder() + CustomerMinifiedModel.builder() .id("id") .externalCustomerId("external_customer_id") .build() ) .parent( - Customer.Hierarchy.Parent.builder() + CustomerMinifiedModel.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -146,7 +146,7 @@ class CustomerTest { assertThat(customer.portalUrl()).contains("portal_url") assertThat(customer.shippingAddress()) .contains( - Customer.ShippingAddress.builder() + AddressModel.builder() .city("city") .country("country") .line1("line1") @@ -157,9 +157,9 @@ class CustomerTest { ) assertThat(customer.taxId()) .contains( - Customer.TaxId.builder() - .country(Customer.TaxId.Country.AD) - .type(Customer.TaxId.Type.AD_NRT) + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) .value("value") .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 9fedb1e90..09d09e1fb 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 @@ -3,7 +3,6 @@ package com.withorb.api.models import com.withorb.api.core.JsonValue -import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -13,81 +12,79 @@ class CustomerUpdateByExternalIdParamsTest { fun create() { CustomerUpdateByExternalIdParams.builder() .id("external_customer_id") - .accountingSyncConfiguration( - CustomerUpdateByExternalIdParams.AccountingSyncConfiguration.builder() - .addAccountingProvider( - CustomerUpdateByExternalIdParams.AccountingSyncConfiguration - .AccountingProvider - .builder() - .externalProviderId("external_provider_id") - .providerType("provider_type") + .editCustomerModel( + EditCustomerModel.builder() + .accountingSyncConfiguration( + NewAccountingSyncConfigurationModel.builder() + .addAccountingProvider( + NewAccountingSyncConfigurationModel.AccountingProvider.builder() + .externalProviderId("external_provider_id") + .providerType("provider_type") + .build() + ) + .excluded(true) .build() ) - .excluded(true) - .build() - ) - .addAdditionalEmail("string") - .autoCollection(true) - .billingAddress( - CustomerUpdateByExternalIdParams.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .currency("currency") - .email("dev@stainless.com") - .emailDelivery(true) - .externalCustomerId("external_customer_id") - .hierarchy( - CustomerUpdateByExternalIdParams.Hierarchy.builder() - .addChildCustomerId("string") - .parentCustomerId("parent_customer_id") - .build() - ) - .metadata( - CustomerUpdateByExternalIdParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .name("name") - .paymentProvider(CustomerUpdateByExternalIdParams.PaymentProvider.QUICKBOOKS) - .paymentProviderId("payment_provider_id") - .reportingConfiguration( - CustomerUpdateByExternalIdParams.ReportingConfiguration.builder() - .exempt(true) - .build() - ) - .shippingAddress( - CustomerUpdateByExternalIdParams.ShippingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .taxConfiguration( - CustomerUpdateByExternalIdParams.TaxConfiguration.NewAvalaraTaxConfiguration - .builder() - .taxExempt(true) - .taxProvider( - CustomerUpdateByExternalIdParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA + .addAdditionalEmail("string") + .autoCollection(true) + .billingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .currency("currency") + .email("dev@stainless.com") + .emailDelivery(true) + .externalCustomerId("external_customer_id") + .hierarchy( + CustomerHierarchyConfigModel.builder() + .addChildCustomerId("string") + .parentCustomerId("parent_customer_id") + .build() + ) + .metadata( + EditCustomerModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .paymentProvider(EditCustomerModel.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .reportingConfiguration( + NewReportingConfigurationModel.builder().exempt(true).build() + ) + .shippingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxConfiguration( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.builder() + .taxExempt(true) + .taxProvider( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.TaxProvider + .AVALARA + ) + .taxExemptionCode("tax_exemption_code") + .build() + ) + .taxId( + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) + .value("value") + .build() ) - .taxExemptionCode("tax_exemption_code") - .build() - ) - .taxId( - CustomerUpdateByExternalIdParams.TaxId.builder() - .country(CustomerUpdateByExternalIdParams.TaxId.Country.AD) - .type(CustomerUpdateByExternalIdParams.TaxId.Type.AD_NRT) - .value("value") .build() ) .build() @@ -98,192 +95,183 @@ class CustomerUpdateByExternalIdParamsTest { val params = CustomerUpdateByExternalIdParams.builder() .id("external_customer_id") - .accountingSyncConfiguration( - CustomerUpdateByExternalIdParams.AccountingSyncConfiguration.builder() - .addAccountingProvider( - CustomerUpdateByExternalIdParams.AccountingSyncConfiguration - .AccountingProvider - .builder() - .externalProviderId("external_provider_id") - .providerType("provider_type") + .editCustomerModel( + EditCustomerModel.builder() + .accountingSyncConfiguration( + NewAccountingSyncConfigurationModel.builder() + .addAccountingProvider( + NewAccountingSyncConfigurationModel.AccountingProvider.builder() + .externalProviderId("external_provider_id") + .providerType("provider_type") + .build() + ) + .excluded(true) .build() ) - .excluded(true) - .build() - ) - .addAdditionalEmail("string") - .autoCollection(true) - .billingAddress( - CustomerUpdateByExternalIdParams.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .currency("currency") - .email("dev@stainless.com") - .emailDelivery(true) - .externalCustomerId("external_customer_id") - .hierarchy( - CustomerUpdateByExternalIdParams.Hierarchy.builder() - .addChildCustomerId("string") - .parentCustomerId("parent_customer_id") - .build() - ) - .metadata( - CustomerUpdateByExternalIdParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .name("name") - .paymentProvider(CustomerUpdateByExternalIdParams.PaymentProvider.QUICKBOOKS) - .paymentProviderId("payment_provider_id") - .reportingConfiguration( - CustomerUpdateByExternalIdParams.ReportingConfiguration.builder() - .exempt(true) - .build() - ) - .shippingAddress( - CustomerUpdateByExternalIdParams.ShippingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .taxConfiguration( - CustomerUpdateByExternalIdParams.TaxConfiguration.NewAvalaraTaxConfiguration - .builder() - .taxExempt(true) - .taxProvider( - CustomerUpdateByExternalIdParams.TaxConfiguration - .NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA + .addAdditionalEmail("string") + .autoCollection(true) + .billingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .currency("currency") + .email("dev@stainless.com") + .emailDelivery(true) + .externalCustomerId("external_customer_id") + .hierarchy( + CustomerHierarchyConfigModel.builder() + .addChildCustomerId("string") + .parentCustomerId("parent_customer_id") + .build() + ) + .metadata( + EditCustomerModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .paymentProvider(EditCustomerModel.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .reportingConfiguration( + NewReportingConfigurationModel.builder().exempt(true).build() + ) + .shippingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxConfiguration( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.builder() + .taxExempt(true) + .taxProvider( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.TaxProvider + .AVALARA + ) + .taxExemptionCode("tax_exemption_code") + .build() + ) + .taxId( + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) + .value("value") + .build() ) - .taxExemptionCode("tax_exemption_code") - .build() - ) - .taxId( - CustomerUpdateByExternalIdParams.TaxId.builder() - .country(CustomerUpdateByExternalIdParams.TaxId.Country.AD) - .type(CustomerUpdateByExternalIdParams.TaxId.Type.AD_NRT) - .value("value") .build() ) .build() val body = params._body() - assertNotNull(body) - assertThat(body.accountingSyncConfiguration()) - .contains( - CustomerUpdateByExternalIdParams.AccountingSyncConfiguration.builder() - .addAccountingProvider( - CustomerUpdateByExternalIdParams.AccountingSyncConfiguration - .AccountingProvider - .builder() - .externalProviderId("external_provider_id") - .providerType("provider_type") + assertThat(body) + .isEqualTo( + EditCustomerModel.builder() + .accountingSyncConfiguration( + NewAccountingSyncConfigurationModel.builder() + .addAccountingProvider( + NewAccountingSyncConfigurationModel.AccountingProvider.builder() + .externalProviderId("external_provider_id") + .providerType("provider_type") + .build() + ) + .excluded(true) + .build() + ) + .addAdditionalEmail("string") + .autoCollection(true) + .billingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .currency("currency") + .email("dev@stainless.com") + .emailDelivery(true) + .externalCustomerId("external_customer_id") + .hierarchy( + CustomerHierarchyConfigModel.builder() + .addChildCustomerId("string") + .parentCustomerId("parent_customer_id") + .build() + ) + .metadata( + EditCustomerModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .paymentProvider(EditCustomerModel.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .reportingConfiguration( + NewReportingConfigurationModel.builder().exempt(true).build() + ) + .shippingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxConfiguration( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.builder() + .taxExempt(true) + .taxProvider( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.TaxProvider + .AVALARA + ) + .taxExemptionCode("tax_exemption_code") + .build() + ) + .taxId( + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) + .value("value") .build() ) - .excluded(true) - .build() - ) - assertThat(body.additionalEmails()).contains(listOf("string")) - assertThat(body.autoCollection()).contains(true) - assertThat(body.billingAddress()) - .contains( - CustomerUpdateByExternalIdParams.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - assertThat(body.currency()).contains("currency") - assertThat(body.email()).contains("dev@stainless.com") - assertThat(body.emailDelivery()).contains(true) - assertThat(body.externalCustomerId()).contains("external_customer_id") - assertThat(body.hierarchy()) - .contains( - CustomerUpdateByExternalIdParams.Hierarchy.builder() - .addChildCustomerId("string") - .parentCustomerId("parent_customer_id") - .build() - ) - assertThat(body.metadata()) - .contains( - CustomerUpdateByExternalIdParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - assertThat(body.name()).contains("name") - assertThat(body.paymentProvider()) - .contains(CustomerUpdateByExternalIdParams.PaymentProvider.QUICKBOOKS) - assertThat(body.paymentProviderId()).contains("payment_provider_id") - assertThat(body.reportingConfiguration()) - .contains( - CustomerUpdateByExternalIdParams.ReportingConfiguration.builder() - .exempt(true) - .build() - ) - assertThat(body.shippingAddress()) - .contains( - CustomerUpdateByExternalIdParams.ShippingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - assertThat(body.taxConfiguration()) - .contains( - CustomerUpdateByExternalIdParams.TaxConfiguration.ofNewAvalara( - CustomerUpdateByExternalIdParams.TaxConfiguration.NewAvalaraTaxConfiguration - .builder() - .taxExempt(true) - .taxProvider( - CustomerUpdateByExternalIdParams.TaxConfiguration - .NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) - .taxExemptionCode("tax_exemption_code") - .build() - ) - ) - assertThat(body.taxId()) - .contains( - CustomerUpdateByExternalIdParams.TaxId.builder() - .country(CustomerUpdateByExternalIdParams.TaxId.Country.AD) - .type(CustomerUpdateByExternalIdParams.TaxId.Type.AD_NRT) - .value("value") .build() ) } @Test fun bodyWithoutOptionalFields() { - val params = CustomerUpdateByExternalIdParams.builder().id("external_customer_id").build() + val params = + CustomerUpdateByExternalIdParams.builder() + .id("external_customer_id") + .editCustomerModel(EditCustomerModel.builder().build()) + .build() val body = params._body() - assertNotNull(body) + assertThat(body).isEqualTo(EditCustomerModel.builder().build()) } @Test fun getPathParam() { - val params = CustomerUpdateByExternalIdParams.builder().id("external_customer_id").build() + val params = + CustomerUpdateByExternalIdParams.builder() + .id("external_customer_id") + .editCustomerModel(EditCustomerModel.builder().build()) + .build() assertThat(params).isNotNull // path param "id" assertThat(params.getPathParam(0)).isEqualTo("external_customer_id") 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 c9708dbad..1af9c08d9 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 @@ -3,7 +3,6 @@ package com.withorb.api.models import com.withorb.api.core.JsonValue -import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -13,76 +12,79 @@ class CustomerUpdateParamsTest { fun create() { CustomerUpdateParams.builder() .customerId("customer_id") - .accountingSyncConfiguration( - CustomerUpdateParams.AccountingSyncConfiguration.builder() - .addAccountingProvider( - CustomerUpdateParams.AccountingSyncConfiguration.AccountingProvider - .builder() - .externalProviderId("external_provider_id") - .providerType("provider_type") + .editCustomerModel( + EditCustomerModel.builder() + .accountingSyncConfiguration( + NewAccountingSyncConfigurationModel.builder() + .addAccountingProvider( + NewAccountingSyncConfigurationModel.AccountingProvider.builder() + .externalProviderId("external_provider_id") + .providerType("provider_type") + .build() + ) + .excluded(true) .build() ) - .excluded(true) - .build() - ) - .addAdditionalEmail("string") - .autoCollection(true) - .billingAddress( - CustomerUpdateParams.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .currency("currency") - .email("dev@stainless.com") - .emailDelivery(true) - .externalCustomerId("external_customer_id") - .hierarchy( - CustomerUpdateParams.Hierarchy.builder() - .addChildCustomerId("string") - .parentCustomerId("parent_customer_id") - .build() - ) - .metadata( - CustomerUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .name("name") - .paymentProvider(CustomerUpdateParams.PaymentProvider.QUICKBOOKS) - .paymentProviderId("payment_provider_id") - .reportingConfiguration( - CustomerUpdateParams.ReportingConfiguration.builder().exempt(true).build() - ) - .shippingAddress( - CustomerUpdateParams.ShippingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .taxConfiguration( - CustomerUpdateParams.TaxConfiguration.NewAvalaraTaxConfiguration.builder() - .taxExempt(true) - .taxProvider( - CustomerUpdateParams.TaxConfiguration.NewAvalaraTaxConfiguration.TaxProvider - .AVALARA + .addAdditionalEmail("string") + .autoCollection(true) + .billingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .currency("currency") + .email("dev@stainless.com") + .emailDelivery(true) + .externalCustomerId("external_customer_id") + .hierarchy( + CustomerHierarchyConfigModel.builder() + .addChildCustomerId("string") + .parentCustomerId("parent_customer_id") + .build() + ) + .metadata( + EditCustomerModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .paymentProvider(EditCustomerModel.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .reportingConfiguration( + NewReportingConfigurationModel.builder().exempt(true).build() + ) + .shippingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxConfiguration( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.builder() + .taxExempt(true) + .taxProvider( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.TaxProvider + .AVALARA + ) + .taxExemptionCode("tax_exemption_code") + .build() + ) + .taxId( + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) + .value("value") + .build() ) - .taxExemptionCode("tax_exemption_code") - .build() - ) - .taxId( - CustomerUpdateParams.TaxId.builder() - .country(CustomerUpdateParams.TaxId.Country.AD) - .type(CustomerUpdateParams.TaxId.Type.AD_NRT) - .value("value") .build() ) .build() @@ -93,179 +95,183 @@ class CustomerUpdateParamsTest { val params = CustomerUpdateParams.builder() .customerId("customer_id") - .accountingSyncConfiguration( - CustomerUpdateParams.AccountingSyncConfiguration.builder() - .addAccountingProvider( - CustomerUpdateParams.AccountingSyncConfiguration.AccountingProvider - .builder() - .externalProviderId("external_provider_id") - .providerType("provider_type") + .editCustomerModel( + EditCustomerModel.builder() + .accountingSyncConfiguration( + NewAccountingSyncConfigurationModel.builder() + .addAccountingProvider( + NewAccountingSyncConfigurationModel.AccountingProvider.builder() + .externalProviderId("external_provider_id") + .providerType("provider_type") + .build() + ) + .excluded(true) .build() ) - .excluded(true) - .build() - ) - .addAdditionalEmail("string") - .autoCollection(true) - .billingAddress( - CustomerUpdateParams.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .currency("currency") - .email("dev@stainless.com") - .emailDelivery(true) - .externalCustomerId("external_customer_id") - .hierarchy( - CustomerUpdateParams.Hierarchy.builder() - .addChildCustomerId("string") - .parentCustomerId("parent_customer_id") - .build() - ) - .metadata( - CustomerUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .name("name") - .paymentProvider(CustomerUpdateParams.PaymentProvider.QUICKBOOKS) - .paymentProviderId("payment_provider_id") - .reportingConfiguration( - CustomerUpdateParams.ReportingConfiguration.builder().exempt(true).build() - ) - .shippingAddress( - CustomerUpdateParams.ShippingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .taxConfiguration( - CustomerUpdateParams.TaxConfiguration.NewAvalaraTaxConfiguration.builder() - .taxExempt(true) - .taxProvider( - CustomerUpdateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA + .addAdditionalEmail("string") + .autoCollection(true) + .billingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .currency("currency") + .email("dev@stainless.com") + .emailDelivery(true) + .externalCustomerId("external_customer_id") + .hierarchy( + CustomerHierarchyConfigModel.builder() + .addChildCustomerId("string") + .parentCustomerId("parent_customer_id") + .build() + ) + .metadata( + EditCustomerModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .paymentProvider(EditCustomerModel.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .reportingConfiguration( + NewReportingConfigurationModel.builder().exempt(true).build() + ) + .shippingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxConfiguration( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.builder() + .taxExempt(true) + .taxProvider( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.TaxProvider + .AVALARA + ) + .taxExemptionCode("tax_exemption_code") + .build() + ) + .taxId( + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) + .value("value") + .build() ) - .taxExemptionCode("tax_exemption_code") - .build() - ) - .taxId( - CustomerUpdateParams.TaxId.builder() - .country(CustomerUpdateParams.TaxId.Country.AD) - .type(CustomerUpdateParams.TaxId.Type.AD_NRT) - .value("value") .build() ) .build() val body = params._body() - assertNotNull(body) - assertThat(body.accountingSyncConfiguration()) - .contains( - CustomerUpdateParams.AccountingSyncConfiguration.builder() - .addAccountingProvider( - CustomerUpdateParams.AccountingSyncConfiguration.AccountingProvider - .builder() - .externalProviderId("external_provider_id") - .providerType("provider_type") + assertThat(body) + .isEqualTo( + EditCustomerModel.builder() + .accountingSyncConfiguration( + NewAccountingSyncConfigurationModel.builder() + .addAccountingProvider( + NewAccountingSyncConfigurationModel.AccountingProvider.builder() + .externalProviderId("external_provider_id") + .providerType("provider_type") + .build() + ) + .excluded(true) + .build() + ) + .addAdditionalEmail("string") + .autoCollection(true) + .billingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .currency("currency") + .email("dev@stainless.com") + .emailDelivery(true) + .externalCustomerId("external_customer_id") + .hierarchy( + CustomerHierarchyConfigModel.builder() + .addChildCustomerId("string") + .parentCustomerId("parent_customer_id") + .build() + ) + .metadata( + EditCustomerModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .paymentProvider(EditCustomerModel.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .reportingConfiguration( + NewReportingConfigurationModel.builder().exempt(true).build() + ) + .shippingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxConfiguration( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.builder() + .taxExempt(true) + .taxProvider( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.TaxProvider + .AVALARA + ) + .taxExemptionCode("tax_exemption_code") + .build() + ) + .taxId( + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) + .value("value") .build() ) - .excluded(true) - .build() - ) - assertThat(body.additionalEmails()).contains(listOf("string")) - assertThat(body.autoCollection()).contains(true) - assertThat(body.billingAddress()) - .contains( - CustomerUpdateParams.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - assertThat(body.currency()).contains("currency") - assertThat(body.email()).contains("dev@stainless.com") - assertThat(body.emailDelivery()).contains(true) - assertThat(body.externalCustomerId()).contains("external_customer_id") - assertThat(body.hierarchy()) - .contains( - CustomerUpdateParams.Hierarchy.builder() - .addChildCustomerId("string") - .parentCustomerId("parent_customer_id") - .build() - ) - assertThat(body.metadata()) - .contains( - CustomerUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - assertThat(body.name()).contains("name") - assertThat(body.paymentProvider()).contains(CustomerUpdateParams.PaymentProvider.QUICKBOOKS) - assertThat(body.paymentProviderId()).contains("payment_provider_id") - assertThat(body.reportingConfiguration()) - .contains(CustomerUpdateParams.ReportingConfiguration.builder().exempt(true).build()) - assertThat(body.shippingAddress()) - .contains( - CustomerUpdateParams.ShippingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - assertThat(body.taxConfiguration()) - .contains( - CustomerUpdateParams.TaxConfiguration.ofNewAvalara( - CustomerUpdateParams.TaxConfiguration.NewAvalaraTaxConfiguration.builder() - .taxExempt(true) - .taxProvider( - CustomerUpdateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) - .taxExemptionCode("tax_exemption_code") - .build() - ) - ) - assertThat(body.taxId()) - .contains( - CustomerUpdateParams.TaxId.builder() - .country(CustomerUpdateParams.TaxId.Country.AD) - .type(CustomerUpdateParams.TaxId.Type.AD_NRT) - .value("value") .build() ) } @Test fun bodyWithoutOptionalFields() { - val params = CustomerUpdateParams.builder().customerId("customer_id").build() + val params = + CustomerUpdateParams.builder() + .customerId("customer_id") + .editCustomerModel(EditCustomerModel.builder().build()) + .build() val body = params._body() - assertNotNull(body) + assertThat(body).isEqualTo(EditCustomerModel.builder().build()) } @Test fun getPathParam() { - val params = CustomerUpdateParams.builder().customerId("customer_id").build() + val params = + CustomerUpdateParams.builder() + .customerId("customer_id") + .editCustomerModel(EditCustomerModel.builder().build()) + .build() assertThat(params).isNotNull // path param "customerId" assertThat(params.getPathParam(0)).isEqualTo("customer_id") diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/DimensionalPriceConfigurationModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/DimensionalPriceConfigurationModelTest.kt new file mode 100644 index 000000000..cfd73f6b2 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/DimensionalPriceConfigurationModelTest.kt @@ -0,0 +1,22 @@ +// 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 + +class DimensionalPriceConfigurationModelTest { + + @Test + fun createDimensionalPriceConfigurationModel() { + val dimensionalPriceConfigurationModel = + DimensionalPriceConfigurationModel.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + assertThat(dimensionalPriceConfigurationModel).isNotNull + assertThat(dimensionalPriceConfigurationModel.dimensionValues()).containsExactly("string") + assertThat(dimensionalPriceConfigurationModel.dimensionalPriceGroupId()) + .isEqualTo("dimensional_price_group_id") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/DimensionalPriceGroupModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/DimensionalPriceGroupModelTest.kt new file mode 100644 index 000000000..ed72d83fa --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/DimensionalPriceGroupModelTest.kt @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class DimensionalPriceGroupModelTest { + + @Test + fun createDimensionalPriceGroupModel() { + val dimensionalPriceGroupModel = + DimensionalPriceGroupModel.builder() + .id("id") + .billableMetricId("billable_metric_id") + .addDimension("region") + .addDimension("instance_type") + .externalDimensionalPriceGroupId("my_dimensional_price_group_id") + .metadata( + DimensionalPriceGroupModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .build() + assertThat(dimensionalPriceGroupModel).isNotNull + assertThat(dimensionalPriceGroupModel.id()).isEqualTo("id") + assertThat(dimensionalPriceGroupModel.billableMetricId()).isEqualTo("billable_metric_id") + assertThat(dimensionalPriceGroupModel.dimensions()) + .containsExactly("region", "instance_type") + assertThat(dimensionalPriceGroupModel.externalDimensionalPriceGroupId()) + .contains("my_dimensional_price_group_id") + assertThat(dimensionalPriceGroupModel.metadata()) + .isEqualTo( + DimensionalPriceGroupModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(dimensionalPriceGroupModel.name()).isEqualTo("name") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/DimensionalPriceGroupsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/DimensionalPriceGroupsTest.kt index db038de88..08a5021e0 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/DimensionalPriceGroupsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/DimensionalPriceGroupsTest.kt @@ -13,14 +13,14 @@ class DimensionalPriceGroupsTest { val dimensionalPriceGroups = DimensionalPriceGroups.builder() .addData( - DimensionalPriceGroup.builder() + DimensionalPriceGroupModel.builder() .id("id") .billableMetricId("billable_metric_id") .addDimension("region") .addDimension("instance_type") .externalDimensionalPriceGroupId("my_dimensional_price_group_id") .metadata( - DimensionalPriceGroup.Metadata.builder() + DimensionalPriceGroupModel.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -34,14 +34,14 @@ class DimensionalPriceGroupsTest { assertThat(dimensionalPriceGroups).isNotNull assertThat(dimensionalPriceGroups.data()) .containsExactly( - DimensionalPriceGroup.builder() + DimensionalPriceGroupModel.builder() .id("id") .billableMetricId("billable_metric_id") .addDimension("region") .addDimension("instance_type") .externalDimensionalPriceGroupId("my_dimensional_price_group_id") .metadata( - DimensionalPriceGroup.Metadata.builder() + DimensionalPriceGroupModel.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/DiscountOverrideModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/DiscountOverrideModelTest.kt new file mode 100644 index 000000000..edf6b5b13 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/DiscountOverrideModelTest.kt @@ -0,0 +1,26 @@ +// 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 + +class DiscountOverrideModelTest { + + @Test + fun createDiscountOverrideModel() { + val discountOverrideModel = + DiscountOverrideModel.builder() + .discountType(DiscountOverrideModel.DiscountType.PERCENTAGE) + .amountDiscount("amount_discount") + .percentageDiscount(0.15) + .usageDiscount(0.0) + .build() + assertThat(discountOverrideModel).isNotNull + assertThat(discountOverrideModel.discountType()) + .isEqualTo(DiscountOverrideModel.DiscountType.PERCENTAGE) + assertThat(discountOverrideModel.amountDiscount()).contains("amount_discount") + assertThat(discountOverrideModel.percentageDiscount()).contains(0.15) + assertThat(discountOverrideModel.usageDiscount()).contains(0.0) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/EditCustomerModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/EditCustomerModelTest.kt new file mode 100644 index 000000000..ca0dac2b6 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/EditCustomerModelTest.kt @@ -0,0 +1,167 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class EditCustomerModelTest { + + @Test + fun createEditCustomerModel() { + val editCustomerModel = + EditCustomerModel.builder() + .accountingSyncConfiguration( + NewAccountingSyncConfigurationModel.builder() + .addAccountingProvider( + NewAccountingSyncConfigurationModel.AccountingProvider.builder() + .externalProviderId("external_provider_id") + .providerType("provider_type") + .build() + ) + .excluded(true) + .build() + ) + .addAdditionalEmail("string") + .autoCollection(true) + .billingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .currency("currency") + .email("dev@stainless.com") + .emailDelivery(true) + .externalCustomerId("external_customer_id") + .hierarchy( + CustomerHierarchyConfigModel.builder() + .addChildCustomerId("string") + .parentCustomerId("parent_customer_id") + .build() + ) + .metadata( + EditCustomerModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .paymentProvider(EditCustomerModel.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .reportingConfiguration( + NewReportingConfigurationModel.builder().exempt(true).build() + ) + .shippingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxConfiguration( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.builder() + .taxExempt(true) + .taxProvider( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.TaxProvider.AVALARA + ) + .taxExemptionCode("tax_exemption_code") + .build() + ) + .taxId( + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) + .value("value") + .build() + ) + .build() + assertThat(editCustomerModel).isNotNull + assertThat(editCustomerModel.accountingSyncConfiguration()) + .contains( + NewAccountingSyncConfigurationModel.builder() + .addAccountingProvider( + NewAccountingSyncConfigurationModel.AccountingProvider.builder() + .externalProviderId("external_provider_id") + .providerType("provider_type") + .build() + ) + .excluded(true) + .build() + ) + assertThat(editCustomerModel.additionalEmails().get()).containsExactly("string") + assertThat(editCustomerModel.autoCollection()).contains(true) + assertThat(editCustomerModel.billingAddress()) + .contains( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + assertThat(editCustomerModel.currency()).contains("currency") + assertThat(editCustomerModel.email()).contains("dev@stainless.com") + assertThat(editCustomerModel.emailDelivery()).contains(true) + assertThat(editCustomerModel.externalCustomerId()).contains("external_customer_id") + assertThat(editCustomerModel.hierarchy()) + .contains( + CustomerHierarchyConfigModel.builder() + .addChildCustomerId("string") + .parentCustomerId("parent_customer_id") + .build() + ) + assertThat(editCustomerModel.metadata()) + .contains( + EditCustomerModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(editCustomerModel.name()).contains("name") + assertThat(editCustomerModel.paymentProvider()) + .contains(EditCustomerModel.PaymentProvider.QUICKBOOKS) + assertThat(editCustomerModel.paymentProviderId()).contains("payment_provider_id") + assertThat(editCustomerModel.reportingConfiguration()) + .contains(NewReportingConfigurationModel.builder().exempt(true).build()) + assertThat(editCustomerModel.shippingAddress()) + .contains( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + assertThat(editCustomerModel.taxConfiguration()) + .contains( + NewTaxConfigurationModel.ofAvalaraTaxConfiguration( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.builder() + .taxExempt(true) + .taxProvider( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.TaxProvider.AVALARA + ) + .taxExemptionCode("tax_exemption_code") + .build() + ) + ) + assertThat(editCustomerModel.taxId()) + .contains( + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) + .value("value") + .build() + ) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/EditPlanModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/EditPlanModelTest.kt new file mode 100644 index 000000000..acf441e65 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/EditPlanModelTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class EditPlanModelTest { + + @Test + fun createEditPlanModel() { + val editPlanModel = + EditPlanModel.builder() + .externalPlanId("external_plan_id") + .metadata( + EditPlanModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + assertThat(editPlanModel).isNotNull + assertThat(editPlanModel.externalPlanId()).contains("external_plan_id") + assertThat(editPlanModel.metadata()) + .contains( + EditPlanModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/EventBackfillCloseResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/EventBackfillCloseResponseTest.kt deleted file mode 100644 index d333c14e6..000000000 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/EventBackfillCloseResponseTest.kt +++ /dev/null @@ -1,47 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class EventBackfillCloseResponseTest { - - @Test - fun createEventBackfillCloseResponse() { - val eventBackfillCloseResponse = - EventBackfillCloseResponse.builder() - .id("id") - .closeTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .customerId("customer_id") - .eventsIngested(0L) - .replaceExistingEvents(true) - .revertedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .status(EventBackfillCloseResponse.Status.PENDING) - .timeframeEnd(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .timeframeStart(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .deprecationFilter("my_numeric_property > 100 AND my_other_property = 'bar'") - .build() - assertThat(eventBackfillCloseResponse).isNotNull - assertThat(eventBackfillCloseResponse.id()).isEqualTo("id") - assertThat(eventBackfillCloseResponse.closeTime()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(eventBackfillCloseResponse.createdAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(eventBackfillCloseResponse.customerId()).contains("customer_id") - assertThat(eventBackfillCloseResponse.eventsIngested()).isEqualTo(0L) - assertThat(eventBackfillCloseResponse.replaceExistingEvents()).isEqualTo(true) - assertThat(eventBackfillCloseResponse.revertedAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(eventBackfillCloseResponse.status()) - .isEqualTo(EventBackfillCloseResponse.Status.PENDING) - assertThat(eventBackfillCloseResponse.timeframeEnd()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(eventBackfillCloseResponse.timeframeStart()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(eventBackfillCloseResponse.deprecationFilter()) - .contains("my_numeric_property > 100 AND my_other_property = 'bar'") - } -} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/EventBackfillCreateResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/EventBackfillCreateResponseTest.kt deleted file mode 100644 index 5b47bf752..000000000 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/EventBackfillCreateResponseTest.kt +++ /dev/null @@ -1,47 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class EventBackfillCreateResponseTest { - - @Test - fun createEventBackfillCreateResponse() { - val eventBackfillCreateResponse = - EventBackfillCreateResponse.builder() - .id("id") - .closeTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .customerId("customer_id") - .eventsIngested(0L) - .replaceExistingEvents(true) - .revertedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .status(EventBackfillCreateResponse.Status.PENDING) - .timeframeEnd(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .timeframeStart(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .deprecationFilter("my_numeric_property > 100 AND my_other_property = 'bar'") - .build() - assertThat(eventBackfillCreateResponse).isNotNull - assertThat(eventBackfillCreateResponse.id()).isEqualTo("id") - assertThat(eventBackfillCreateResponse.closeTime()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(eventBackfillCreateResponse.createdAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(eventBackfillCreateResponse.customerId()).contains("customer_id") - assertThat(eventBackfillCreateResponse.eventsIngested()).isEqualTo(0L) - assertThat(eventBackfillCreateResponse.replaceExistingEvents()).isEqualTo(true) - assertThat(eventBackfillCreateResponse.revertedAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(eventBackfillCreateResponse.status()) - .isEqualTo(EventBackfillCreateResponse.Status.PENDING) - assertThat(eventBackfillCreateResponse.timeframeEnd()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(eventBackfillCreateResponse.timeframeStart()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(eventBackfillCreateResponse.deprecationFilter()) - .contains("my_numeric_property > 100 AND my_other_property = 'bar'") - } -} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/EventBackfillFetchResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/EventBackfillFetchResponseTest.kt deleted file mode 100644 index ad82be8c6..000000000 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/EventBackfillFetchResponseTest.kt +++ /dev/null @@ -1,47 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class EventBackfillFetchResponseTest { - - @Test - fun createEventBackfillFetchResponse() { - val eventBackfillFetchResponse = - EventBackfillFetchResponse.builder() - .id("id") - .closeTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .customerId("customer_id") - .eventsIngested(0L) - .replaceExistingEvents(true) - .revertedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .status(EventBackfillFetchResponse.Status.PENDING) - .timeframeEnd(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .timeframeStart(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .deprecationFilter("my_numeric_property > 100 AND my_other_property = 'bar'") - .build() - assertThat(eventBackfillFetchResponse).isNotNull - assertThat(eventBackfillFetchResponse.id()).isEqualTo("id") - assertThat(eventBackfillFetchResponse.closeTime()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(eventBackfillFetchResponse.createdAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(eventBackfillFetchResponse.customerId()).contains("customer_id") - assertThat(eventBackfillFetchResponse.eventsIngested()).isEqualTo(0L) - assertThat(eventBackfillFetchResponse.replaceExistingEvents()).isEqualTo(true) - assertThat(eventBackfillFetchResponse.revertedAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(eventBackfillFetchResponse.status()) - .isEqualTo(EventBackfillFetchResponse.Status.PENDING) - assertThat(eventBackfillFetchResponse.timeframeEnd()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(eventBackfillFetchResponse.timeframeStart()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(eventBackfillFetchResponse.deprecationFilter()) - .contains("my_numeric_property > 100 AND my_other_property = 'bar'") - } -} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/EventBackfillRevertResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/EventBackfillRevertResponseTest.kt deleted file mode 100644 index a8765b504..000000000 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/EventBackfillRevertResponseTest.kt +++ /dev/null @@ -1,47 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class EventBackfillRevertResponseTest { - - @Test - fun createEventBackfillRevertResponse() { - val eventBackfillRevertResponse = - EventBackfillRevertResponse.builder() - .id("id") - .closeTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .customerId("customer_id") - .eventsIngested(0L) - .replaceExistingEvents(true) - .revertedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .status(EventBackfillRevertResponse.Status.PENDING) - .timeframeEnd(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .timeframeStart(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .deprecationFilter("my_numeric_property > 100 AND my_other_property = 'bar'") - .build() - assertThat(eventBackfillRevertResponse).isNotNull - assertThat(eventBackfillRevertResponse.id()).isEqualTo("id") - assertThat(eventBackfillRevertResponse.closeTime()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(eventBackfillRevertResponse.createdAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(eventBackfillRevertResponse.customerId()).contains("customer_id") - assertThat(eventBackfillRevertResponse.eventsIngested()).isEqualTo(0L) - assertThat(eventBackfillRevertResponse.replaceExistingEvents()).isEqualTo(true) - assertThat(eventBackfillRevertResponse.revertedAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(eventBackfillRevertResponse.status()) - .isEqualTo(EventBackfillRevertResponse.Status.PENDING) - assertThat(eventBackfillRevertResponse.timeframeEnd()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(eventBackfillRevertResponse.timeframeStart()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(eventBackfillRevertResponse.deprecationFilter()) - .contains("my_numeric_property > 100 AND my_other_property = 'bar'") - } -} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/FixedFeeQuantityScheduleEntryModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/FixedFeeQuantityScheduleEntryModelTest.kt new file mode 100644 index 000000000..ca957086f --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/FixedFeeQuantityScheduleEntryModelTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class FixedFeeQuantityScheduleEntryModelTest { + + @Test + fun createFixedFeeQuantityScheduleEntryModel() { + val fixedFeeQuantityScheduleEntryModel = + FixedFeeQuantityScheduleEntryModel.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0.0) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + assertThat(fixedFeeQuantityScheduleEntryModel).isNotNull + assertThat(fixedFeeQuantityScheduleEntryModel.endDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(fixedFeeQuantityScheduleEntryModel.priceId()).isEqualTo("price_id") + assertThat(fixedFeeQuantityScheduleEntryModel.quantity()).isEqualTo(0.0) + assertThat(fixedFeeQuantityScheduleEntryModel.startDate()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } +} 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 a8a9c303b..2e4540cf5 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 @@ -24,11 +24,7 @@ class InvoiceCreateParamsTest { .name("Line Item Name") .quantity(1.0) .startDate(LocalDate.parse("2023-09-22")) - .unitConfig( - InvoiceCreateParams.LineItem.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) .build() ) .netTerms(0L) @@ -67,11 +63,7 @@ class InvoiceCreateParamsTest { .name("Line Item Name") .quantity(1.0) .startDate(LocalDate.parse("2023-09-22")) - .unitConfig( - InvoiceCreateParams.LineItem.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) .build() ) .netTerms(0L) @@ -110,11 +102,7 @@ class InvoiceCreateParamsTest { .name("Line Item Name") .quantity(1.0) .startDate(LocalDate.parse("2023-09-22")) - .unitConfig( - InvoiceCreateParams.LineItem.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) .build() ) ) @@ -157,11 +145,7 @@ class InvoiceCreateParamsTest { .name("Line Item Name") .quantity(1.0) .startDate(LocalDate.parse("2023-09-22")) - .unitConfig( - InvoiceCreateParams.LineItem.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) .build() ) .netTerms(0L) @@ -182,11 +166,7 @@ class InvoiceCreateParamsTest { .name("Line Item Name") .quantity(1.0) .startDate(LocalDate.parse("2023-09-22")) - .unitConfig( - InvoiceCreateParams.LineItem.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) .build() ) ) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponseTest.kt index 15cc7641a..b11c2c979 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 @@ -16,7 +16,7 @@ class InvoiceFetchUpcomingResponseTest { .id("id") .amountDue("8.00") .autoCollection( - InvoiceFetchUpcomingResponse.AutoCollection.builder() + AutoCollectionModel.builder() .enabled(true) .nextAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .numAttempts(0L) @@ -24,7 +24,7 @@ class InvoiceFetchUpcomingResponseTest { .build() ) .billingAddress( - InvoiceFetchUpcomingResponse.BillingAddress.builder() + AddressModel.builder() .city("city") .country("country") .line1("line1") @@ -35,7 +35,7 @@ class InvoiceFetchUpcomingResponseTest { ) .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) .addCreditNote( - InvoiceFetchUpcomingResponse.CreditNote.builder() + CreditNoteSummaryModel.builder() .id("id") .creditNoteNumber("credit_note_number") .memo("memo") @@ -47,44 +47,35 @@ class InvoiceFetchUpcomingResponseTest { ) .currency("USD") .customer( - InvoiceFetchUpcomingResponse.Customer.builder() + CustomerMinifiedModel.builder() .id("id") .externalCustomerId("external_customer_id") .build() ) .addCustomerBalanceTransaction( - InvoiceFetchUpcomingResponse.CustomerBalanceTransaction.builder() + CustomerBalanceTransactionModel.builder() .id("cgZa3SXcsPTVyC4Y") - .action( - InvoiceFetchUpcomingResponse.CustomerBalanceTransaction.Action - .APPLIED_TO_INVOICE - ) + .action(CustomerBalanceTransactionModel.Action.APPLIED_TO_INVOICE) .amount("11.00") .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) .creditNote( - InvoiceFetchUpcomingResponse.CustomerBalanceTransaction.CreditNote - .builder() - .id("id") - .build() + CustomerBalanceTransactionModel.CreditNote.builder().id("id").build() ) .description("An optional description") .endingBalance("22.00") .invoice( - InvoiceFetchUpcomingResponse.CustomerBalanceTransaction.Invoice - .builder() + CustomerBalanceTransactionModel.Invoice.builder() .id("gXcsPTVyC4YZa3Sc") .build() ) .startingBalance("33.00") - .type( - InvoiceFetchUpcomingResponse.CustomerBalanceTransaction.Type.INCREMENT - ) + .type(CustomerBalanceTransactionModel.Type.INCREMENT) .build() ) .customerTaxId( - InvoiceFetchUpcomingResponse.CustomerTaxId.builder() - .country(InvoiceFetchUpcomingResponse.CustomerTaxId.Country.AD) - .type(InvoiceFetchUpcomingResponse.CustomerTaxId.Type.AD_NRT) + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) .value("value") .build() ) @@ -107,17 +98,15 @@ class InvoiceFetchUpcomingResponseTest { .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addLineItem( - InvoiceFetchUpcomingResponse.LineItem.builder() + InvoiceLineItemModel.builder() .id("id") .adjustedSubtotal("5.00") .addAdjustment( - InvoiceFetchUpcomingResponse.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment + InvoiceLineItemModel.Adjustment.MonetaryUsageDiscountAdjustment .builder() .id("id") .adjustmentType( - InvoiceFetchUpcomingResponse.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment + InvoiceLineItemModel.Adjustment.MonetaryUsageDiscountAdjustment .AdjustmentType .USAGE_DISCOUNT ) @@ -143,14 +132,14 @@ class InvoiceFetchUpcomingResponseTest { .filter("filter") .grouping("grouping") .maximum( - InvoiceFetchUpcomingResponse.LineItem.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .minimum( - InvoiceFetchUpcomingResponse.LineItem.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() @@ -159,25 +148,22 @@ class InvoiceFetchUpcomingResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + PriceModel.UnitPrice.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(BillableMetricTinyModel.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + BillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + AllocationModel.builder() .allowsRollover(true) .currency("currency") .build() @@ -195,45 +181,42 @@ class InvoiceFetchUpcomingResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + BillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(ItemSlimModel.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + PriceModel.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) + .modelType(PriceModel.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() + UnitConfigModel.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + DimensionalPriceConfigurationModel.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -243,22 +226,16 @@ class InvoiceFetchUpcomingResponseTest { .quantity(1.0) .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .addSubLineItem( - InvoiceFetchUpcomingResponse.LineItem.SubLineItem.MatrixSubLineItem - .builder() + InvoiceLineItemModel.SubLineItem.MatrixSubLineItem.builder() .amount("9.00") .grouping( - InvoiceFetchUpcomingResponse.LineItem.SubLineItem - .MatrixSubLineItem - .Grouping - .builder() + SubLineItemGroupingModel.builder() .key("region") .value("west") .build() ) .matrixConfig( - InvoiceFetchUpcomingResponse.LineItem.SubLineItem - .MatrixSubLineItem - .MatrixConfig + InvoiceLineItemModel.SubLineItem.MatrixSubLineItem.MatrixConfig .builder() .addDimensionValue("string") .build() @@ -266,16 +243,13 @@ class InvoiceFetchUpcomingResponseTest { .name("Tier One") .quantity(5.0) .type( - InvoiceFetchUpcomingResponse.LineItem.SubLineItem - .MatrixSubLineItem - .Type - .MATRIX + InvoiceLineItemModel.SubLineItem.MatrixSubLineItem.Type.MATRIX ) .build() ) .subtotal("9.00") .addTaxAmount( - InvoiceFetchUpcomingResponse.LineItem.TaxAmount.builder() + TaxAmountModel.builder() .amount("amount") .taxRateDescription("tax_rate_description") .taxRatePercentage("tax_rate_percentage") @@ -285,7 +259,7 @@ class InvoiceFetchUpcomingResponseTest { .build() ) .maximum( - InvoiceFetchUpcomingResponse.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() @@ -298,7 +272,7 @@ class InvoiceFetchUpcomingResponseTest { .build() ) .minimum( - InvoiceFetchUpcomingResponse.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() @@ -306,13 +280,11 @@ class InvoiceFetchUpcomingResponseTest { .minimumAmount("minimum_amount") .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addPaymentAttempt( - InvoiceFetchUpcomingResponse.PaymentAttempt.builder() + PaymentAttemptModel.builder() .id("id") .amount("amount") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .paymentProvider( - InvoiceFetchUpcomingResponse.PaymentAttempt.PaymentProvider.STRIPE - ) + .paymentProvider(PaymentAttemptModel.PaymentProvider.STRIPE) .paymentProviderId("payment_provider_id") .succeeded(true) .build() @@ -321,7 +293,7 @@ class InvoiceFetchUpcomingResponseTest { .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .shippingAddress( - InvoiceFetchUpcomingResponse.ShippingAddress.builder() + AddressModel.builder() .city("city") .country("country") .line1("line1") @@ -331,11 +303,7 @@ class InvoiceFetchUpcomingResponseTest { .build() ) .status(InvoiceFetchUpcomingResponse.Status.ISSUED) - .subscription( - InvoiceFetchUpcomingResponse.Subscription.builder() - .id("VDGsT23osdLb84KD") - .build() - ) + .subscription(SubscriptionMinifiedModel.builder().id("VDGsT23osdLb84KD").build()) .subtotal("8.00") .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .targetDate(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) @@ -348,7 +316,7 @@ class InvoiceFetchUpcomingResponseTest { assertThat(invoiceFetchUpcomingResponse.amountDue()).isEqualTo("8.00") assertThat(invoiceFetchUpcomingResponse.autoCollection()) .isEqualTo( - InvoiceFetchUpcomingResponse.AutoCollection.builder() + AutoCollectionModel.builder() .enabled(true) .nextAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .numAttempts(0L) @@ -357,7 +325,7 @@ class InvoiceFetchUpcomingResponseTest { ) assertThat(invoiceFetchUpcomingResponse.billingAddress()) .contains( - InvoiceFetchUpcomingResponse.BillingAddress.builder() + AddressModel.builder() .city("city") .country("country") .line1("line1") @@ -370,7 +338,7 @@ class InvoiceFetchUpcomingResponseTest { .isEqualTo(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) assertThat(invoiceFetchUpcomingResponse.creditNotes()) .containsExactly( - InvoiceFetchUpcomingResponse.CreditNote.builder() + CreditNoteSummaryModel.builder() .id("id") .creditNoteNumber("credit_note_number") .memo("memo") @@ -383,42 +351,37 @@ class InvoiceFetchUpcomingResponseTest { assertThat(invoiceFetchUpcomingResponse.currency()).isEqualTo("USD") assertThat(invoiceFetchUpcomingResponse.customer()) .isEqualTo( - InvoiceFetchUpcomingResponse.Customer.builder() + CustomerMinifiedModel.builder() .id("id") .externalCustomerId("external_customer_id") .build() ) assertThat(invoiceFetchUpcomingResponse.customerBalanceTransactions()) .containsExactly( - InvoiceFetchUpcomingResponse.CustomerBalanceTransaction.builder() + CustomerBalanceTransactionModel.builder() .id("cgZa3SXcsPTVyC4Y") - .action( - InvoiceFetchUpcomingResponse.CustomerBalanceTransaction.Action - .APPLIED_TO_INVOICE - ) + .action(CustomerBalanceTransactionModel.Action.APPLIED_TO_INVOICE) .amount("11.00") .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) .creditNote( - InvoiceFetchUpcomingResponse.CustomerBalanceTransaction.CreditNote.builder() - .id("id") - .build() + CustomerBalanceTransactionModel.CreditNote.builder().id("id").build() ) .description("An optional description") .endingBalance("22.00") .invoice( - InvoiceFetchUpcomingResponse.CustomerBalanceTransaction.Invoice.builder() + CustomerBalanceTransactionModel.Invoice.builder() .id("gXcsPTVyC4YZa3Sc") .build() ) .startingBalance("33.00") - .type(InvoiceFetchUpcomingResponse.CustomerBalanceTransaction.Type.INCREMENT) + .type(CustomerBalanceTransactionModel.Type.INCREMENT) .build() ) assertThat(invoiceFetchUpcomingResponse.customerTaxId()) .contains( - InvoiceFetchUpcomingResponse.CustomerTaxId.builder() - .country(InvoiceFetchUpcomingResponse.CustomerTaxId.Country.AD) - .type(InvoiceFetchUpcomingResponse.CustomerTaxId.Type.AD_NRT) + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) .value("value") .build() ) @@ -452,17 +415,14 @@ class InvoiceFetchUpcomingResponseTest { .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(invoiceFetchUpcomingResponse.lineItems()) .containsExactly( - InvoiceFetchUpcomingResponse.LineItem.builder() + InvoiceLineItemModel.builder() .id("id") .adjustedSubtotal("5.00") .addAdjustment( - InvoiceFetchUpcomingResponse.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + InvoiceLineItemModel.Adjustment.MonetaryUsageDiscountAdjustment.builder() .id("id") .adjustmentType( - InvoiceFetchUpcomingResponse.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment + InvoiceLineItemModel.Adjustment.MonetaryUsageDiscountAdjustment .AdjustmentType .USAGE_DISCOUNT ) @@ -488,14 +448,14 @@ class InvoiceFetchUpcomingResponseTest { .filter("filter") .grouping("grouping") .maximum( - InvoiceFetchUpcomingResponse.LineItem.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .minimum( - InvoiceFetchUpcomingResponse.LineItem.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() @@ -504,24 +464,20 @@ class InvoiceFetchUpcomingResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + PriceModel.UnitPrice.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(BillableMetricTinyModel.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(BillingCycleConfigurationModel.DurationUnit.DAY) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + AllocationModel.builder() .allowsRollover(true) .currency("currency") .build() @@ -539,44 +495,38 @@ class InvoiceFetchUpcomingResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(BillingCycleConfigurationModel.DurationUnit.DAY) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(ItemSlimModel.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + PriceModel.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) + .modelType(PriceModel.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + DimensionalPriceConfigurationModel.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -586,36 +536,28 @@ class InvoiceFetchUpcomingResponseTest { .quantity(1.0) .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .addSubLineItem( - InvoiceFetchUpcomingResponse.LineItem.SubLineItem.MatrixSubLineItem - .builder() + InvoiceLineItemModel.SubLineItem.MatrixSubLineItem.builder() .amount("9.00") .grouping( - InvoiceFetchUpcomingResponse.LineItem.SubLineItem.MatrixSubLineItem - .Grouping - .builder() + SubLineItemGroupingModel.builder() .key("region") .value("west") .build() ) .matrixConfig( - InvoiceFetchUpcomingResponse.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + InvoiceLineItemModel.SubLineItem.MatrixSubLineItem.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - InvoiceFetchUpcomingResponse.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) + .type(InvoiceLineItemModel.SubLineItem.MatrixSubLineItem.Type.MATRIX) .build() ) .subtotal("9.00") .addTaxAmount( - InvoiceFetchUpcomingResponse.LineItem.TaxAmount.builder() + TaxAmountModel.builder() .amount("amount") .taxRateDescription("tax_rate_description") .taxRatePercentage("tax_rate_percentage") @@ -626,7 +568,7 @@ class InvoiceFetchUpcomingResponseTest { ) assertThat(invoiceFetchUpcomingResponse.maximum()) .contains( - InvoiceFetchUpcomingResponse.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() @@ -641,7 +583,7 @@ class InvoiceFetchUpcomingResponseTest { ) assertThat(invoiceFetchUpcomingResponse.minimum()) .contains( - InvoiceFetchUpcomingResponse.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() @@ -651,13 +593,11 @@ class InvoiceFetchUpcomingResponseTest { .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(invoiceFetchUpcomingResponse.paymentAttempts()) .containsExactly( - InvoiceFetchUpcomingResponse.PaymentAttempt.builder() + PaymentAttemptModel.builder() .id("id") .amount("amount") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .paymentProvider( - InvoiceFetchUpcomingResponse.PaymentAttempt.PaymentProvider.STRIPE - ) + .paymentProvider(PaymentAttemptModel.PaymentProvider.STRIPE) .paymentProviderId("payment_provider_id") .succeeded(true) .build() @@ -670,7 +610,7 @@ class InvoiceFetchUpcomingResponseTest { .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(invoiceFetchUpcomingResponse.shippingAddress()) .contains( - InvoiceFetchUpcomingResponse.ShippingAddress.builder() + AddressModel.builder() .city("city") .country("country") .line1("line1") @@ -682,9 +622,7 @@ class InvoiceFetchUpcomingResponseTest { assertThat(invoiceFetchUpcomingResponse.status()) .isEqualTo(InvoiceFetchUpcomingResponse.Status.ISSUED) assertThat(invoiceFetchUpcomingResponse.subscription()) - .contains( - InvoiceFetchUpcomingResponse.Subscription.builder().id("VDGsT23osdLb84KD").build() - ) + .contains(SubscriptionMinifiedModel.builder().id("VDGsT23osdLb84KD").build()) assertThat(invoiceFetchUpcomingResponse.subtotal()).isEqualTo("8.00") assertThat(invoiceFetchUpcomingResponse.syncFailedAt()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) 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/InvoiceLineItemModelTest.kt similarity index 59% rename from orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponseTest.kt rename to orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemModelTest.kt index 63ddc6625..b9d56858d 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/InvoiceLineItemModelTest.kt @@ -7,20 +7,19 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class InvoiceLineItemCreateResponseTest { +class InvoiceLineItemModelTest { @Test - fun createInvoiceLineItemCreateResponse() { - val invoiceLineItemCreateResponse = - InvoiceLineItemCreateResponse.builder() + fun createInvoiceLineItemModel() { + val invoiceLineItemModel = + InvoiceLineItemModel.builder() .id("id") .adjustedSubtotal("5.00") .addAdjustment( - InvoiceLineItemCreateResponse.Adjustment.MonetaryUsageDiscountAdjustment - .builder() + InvoiceLineItemModel.Adjustment.MonetaryUsageDiscountAdjustment.builder() .id("id") .adjustmentType( - InvoiceLineItemCreateResponse.Adjustment.MonetaryUsageDiscountAdjustment + InvoiceLineItemModel.Adjustment.MonetaryUsageDiscountAdjustment .AdjustmentType .USAGE_DISCOUNT ) @@ -46,14 +45,14 @@ class InvoiceLineItemCreateResponseTest { .filter("filter") .grouping("grouping") .maximum( - InvoiceLineItemCreateResponse.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .minimum( - InvoiceLineItemCreateResponse.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() @@ -62,22 +61,20 @@ class InvoiceLineItemCreateResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + PriceModel.UnitPrice.builder() .id("id") - .billableMetric(Price.UnitPrice.BillableMetric.builder().id("id").build()) + .billableMetric(BillableMetricTinyModel.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(BillingCycleConfigurationModel.DurationUnit.DAY) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + AllocationModel.builder() .allowsRollover(true) .currency("currency") .build() @@ -95,42 +92,38 @@ class InvoiceLineItemCreateResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(BillingCycleConfigurationModel.DurationUnit.DAY) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(ItemSlimModel.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + PriceModel.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) + .modelType(PriceModel.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder().unitAmount("unit_amount").build() - ) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + DimensionalPriceConfigurationModel.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -140,31 +133,25 @@ class InvoiceLineItemCreateResponseTest { .quantity(1.0) .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .addSubLineItem( - InvoiceLineItemCreateResponse.SubLineItem.MatrixSubLineItem.builder() + InvoiceLineItemModel.SubLineItem.MatrixSubLineItem.builder() .amount("9.00") .grouping( - InvoiceLineItemCreateResponse.SubLineItem.MatrixSubLineItem.Grouping - .builder() - .key("region") - .value("west") - .build() + SubLineItemGroupingModel.builder().key("region").value("west").build() ) .matrixConfig( - InvoiceLineItemCreateResponse.SubLineItem.MatrixSubLineItem.MatrixConfig + InvoiceLineItemModel.SubLineItem.MatrixSubLineItem.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - InvoiceLineItemCreateResponse.SubLineItem.MatrixSubLineItem.Type.MATRIX - ) + .type(InvoiceLineItemModel.SubLineItem.MatrixSubLineItem.Type.MATRIX) .build() ) .subtotal("9.00") .addTaxAmount( - InvoiceLineItemCreateResponse.TaxAmount.builder() + TaxAmountModel.builder() .amount("amount") .taxRateDescription("tax_rate_description") .taxRatePercentage("tax_rate_percentage") @@ -172,17 +159,16 @@ class InvoiceLineItemCreateResponseTest { ) .addUsageCustomerId("string") .build() - assertThat(invoiceLineItemCreateResponse).isNotNull - assertThat(invoiceLineItemCreateResponse.id()).isEqualTo("id") - assertThat(invoiceLineItemCreateResponse.adjustedSubtotal()).isEqualTo("5.00") - assertThat(invoiceLineItemCreateResponse.adjustments()) + assertThat(invoiceLineItemModel).isNotNull + assertThat(invoiceLineItemModel.id()).isEqualTo("id") + assertThat(invoiceLineItemModel.adjustedSubtotal()).isEqualTo("5.00") + assertThat(invoiceLineItemModel.adjustments()) .containsExactly( - InvoiceLineItemCreateResponse.Adjustment.ofMonetaryUsageDiscount( - InvoiceLineItemCreateResponse.Adjustment.MonetaryUsageDiscountAdjustment - .builder() + InvoiceLineItemModel.Adjustment.ofMonetaryUsageDiscount( + InvoiceLineItemModel.Adjustment.MonetaryUsageDiscountAdjustment.builder() .id("id") .adjustmentType( - InvoiceLineItemCreateResponse.Adjustment.MonetaryUsageDiscountAdjustment + InvoiceLineItemModel.Adjustment.MonetaryUsageDiscountAdjustment .AdjustmentType .USAGE_DISCOUNT ) @@ -194,9 +180,9 @@ class InvoiceLineItemCreateResponseTest { .build() ) ) - assertThat(invoiceLineItemCreateResponse.amount()).isEqualTo("7.00") - assertThat(invoiceLineItemCreateResponse.creditsApplied()).isEqualTo("6.00") - assertThat(invoiceLineItemCreateResponse.discount()) + assertThat(invoiceLineItemModel.amount()).isEqualTo("7.00") + assertThat(invoiceLineItemModel.creditsApplied()).isEqualTo("6.00") + assertThat(invoiceLineItemModel.discount()) .contains( Discount.ofPercentage( PercentageDiscount.builder() @@ -208,47 +194,45 @@ class InvoiceLineItemCreateResponseTest { .build() ) ) - assertThat(invoiceLineItemCreateResponse.endDate()) + assertThat(invoiceLineItemModel.endDate()) .isEqualTo(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) - assertThat(invoiceLineItemCreateResponse.filter()).contains("filter") - assertThat(invoiceLineItemCreateResponse.grouping()).contains("grouping") - assertThat(invoiceLineItemCreateResponse.maximum()) + assertThat(invoiceLineItemModel.filter()).contains("filter") + assertThat(invoiceLineItemModel.grouping()).contains("grouping") + assertThat(invoiceLineItemModel.maximum()) .contains( - InvoiceLineItemCreateResponse.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) - assertThat(invoiceLineItemCreateResponse.maximumAmount()).contains("maximum_amount") - assertThat(invoiceLineItemCreateResponse.minimum()) + assertThat(invoiceLineItemModel.maximumAmount()).contains("maximum_amount") + assertThat(invoiceLineItemModel.minimum()) .contains( - InvoiceLineItemCreateResponse.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) - assertThat(invoiceLineItemCreateResponse.minimumAmount()).contains("minimum_amount") - assertThat(invoiceLineItemCreateResponse.name()).isEqualTo("Fixed Fee") - assertThat(invoiceLineItemCreateResponse.partiallyInvoicedAmount()).isEqualTo("4.00") - assertThat(invoiceLineItemCreateResponse.price()) + assertThat(invoiceLineItemModel.minimumAmount()).contains("minimum_amount") + assertThat(invoiceLineItemModel.name()).isEqualTo("Fixed Fee") + assertThat(invoiceLineItemModel.partiallyInvoicedAmount()).isEqualTo("4.00") + assertThat(invoiceLineItemModel.price()) .contains( - Price.ofUnit( - Price.UnitPrice.builder() + PriceModel.ofUnitPrice( + PriceModel.UnitPrice.builder() .id("id") - .billableMetric(Price.UnitPrice.BillableMetric.builder().id("id").build()) + .billableMetric(BillableMetricTinyModel.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(BillingCycleConfigurationModel.DurationUnit.DAY) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + AllocationModel.builder() .allowsRollover(true) .currency("currency") .build() @@ -266,42 +250,38 @@ class InvoiceLineItemCreateResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(BillingCycleConfigurationModel.DurationUnit.DAY) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(ItemSlimModel.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + PriceModel.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) + .modelType(PriceModel.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder().unitAmount("unit_amount").build() - ) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + DimensionalPriceConfigurationModel.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -309,44 +289,38 @@ class InvoiceLineItemCreateResponseTest { .build() ) ) - assertThat(invoiceLineItemCreateResponse.quantity()).isEqualTo(1.0) - assertThat(invoiceLineItemCreateResponse.startDate()) + assertThat(invoiceLineItemModel.quantity()).isEqualTo(1.0) + assertThat(invoiceLineItemModel.startDate()) .isEqualTo(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) - assertThat(invoiceLineItemCreateResponse.subLineItems()) + assertThat(invoiceLineItemModel.subLineItems()) .containsExactly( - InvoiceLineItemCreateResponse.SubLineItem.ofMatrix( - InvoiceLineItemCreateResponse.SubLineItem.MatrixSubLineItem.builder() + InvoiceLineItemModel.SubLineItem.ofMatrix( + InvoiceLineItemModel.SubLineItem.MatrixSubLineItem.builder() .amount("9.00") .grouping( - InvoiceLineItemCreateResponse.SubLineItem.MatrixSubLineItem.Grouping - .builder() - .key("region") - .value("west") - .build() + SubLineItemGroupingModel.builder().key("region").value("west").build() ) .matrixConfig( - InvoiceLineItemCreateResponse.SubLineItem.MatrixSubLineItem.MatrixConfig + InvoiceLineItemModel.SubLineItem.MatrixSubLineItem.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - InvoiceLineItemCreateResponse.SubLineItem.MatrixSubLineItem.Type.MATRIX - ) + .type(InvoiceLineItemModel.SubLineItem.MatrixSubLineItem.Type.MATRIX) .build() ) ) - assertThat(invoiceLineItemCreateResponse.subtotal()).isEqualTo("9.00") - assertThat(invoiceLineItemCreateResponse.taxAmounts()) + assertThat(invoiceLineItemModel.subtotal()).isEqualTo("9.00") + assertThat(invoiceLineItemModel.taxAmounts()) .containsExactly( - InvoiceLineItemCreateResponse.TaxAmount.builder() + TaxAmountModel.builder() .amount("amount") .taxRateDescription("tax_rate_description") .taxRatePercentage("tax_rate_percentage") .build() ) - assertThat(invoiceLineItemCreateResponse.usageCustomerIds().get()).containsExactly("string") + assertThat(invoiceLineItemModel.usageCustomerIds().get()).containsExactly("string") } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceModelTest.kt new file mode 100644 index 000000000..2cb02cf88 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceModelTest.kt @@ -0,0 +1,632 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.JsonValue +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class InvoiceModelTest { + + @Test + fun createInvoiceModel() { + val invoiceModel = + InvoiceModel.builder() + .id("id") + .amountDue("8.00") + .autoCollection( + AutoCollectionModel.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( + AddressModel.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( + CreditNoteSummaryModel.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( + CustomerMinifiedModel.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .addCustomerBalanceTransaction( + CustomerBalanceTransactionModel.builder() + .id("cgZa3SXcsPTVyC4Y") + .action(CustomerBalanceTransactionModel.Action.APPLIED_TO_INVOICE) + .amount("11.00") + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .creditNote( + CustomerBalanceTransactionModel.CreditNote.builder().id("id").build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + CustomerBalanceTransactionModel.Invoice.builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(CustomerBalanceTransactionModel.Type.INCREMENT) + .build() + ) + .customerTaxId( + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) + .value("value") + .build() + ) + .discount(JsonValue.from(mapOf())) + .addDiscount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .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(InvoiceModel.InvoiceSource.SUBSCRIPTION) + .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addLineItem( + InvoiceLineItemModel.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + InvoiceLineItemModel.Adjustment.MonetaryUsageDiscountAdjustment + .builder() + .id("id") + .adjustmentType( + InvoiceLineItemModel.Adjustment.MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + MaximumModel.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + MinimumModel.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + PriceModel.UnitPrice.builder() + .id("id") + .billableMetric(BillableMetricTinyModel.builder().id("id").build()) + .billingCycleConfiguration( + BillingCycleConfigurationModel.builder() + .duration(0L) + .durationUnit( + BillingCycleConfigurationModel.DurationUnit.DAY + ) + .build() + ) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + AllocationModel.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + BillingCycleConfigurationModel.builder() + .duration(0L) + .durationUnit( + BillingCycleConfigurationModel.DurationUnit.DAY + ) + .build() + ) + .item(ItemSlimModel.builder().id("id").name("name").build()) + .maximum( + MaximumModel.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + PriceModel.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + MinimumModel.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(PriceModel.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + UnitConfigModel.builder().unitAmount("unit_amount").build() + ) + .dimensionalPriceConfiguration( + DimensionalPriceConfigurationModel.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .quantity(1.0) + .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .addSubLineItem( + InvoiceLineItemModel.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + SubLineItemGroupingModel.builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + InvoiceLineItemModel.SubLineItem.MatrixSubLineItem.MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type( + InvoiceLineItemModel.SubLineItem.MatrixSubLineItem.Type.MATRIX + ) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + TaxAmountModel.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + .maximum( + MaximumModel.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .memo("memo") + .metadata( + InvoiceModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + MinimumModel.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addPaymentAttempt( + PaymentAttemptModel.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider(PaymentAttemptModel.PaymentProvider.STRIPE) + .paymentProviderId("payment_provider_id") + .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( + AddressModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .status(InvoiceModel.Status.ISSUED) + .subscription(SubscriptionMinifiedModel.builder().id("VDGsT23osdLb84KD").build()) + .subtotal("8.00") + .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(invoiceModel).isNotNull + assertThat(invoiceModel.id()).isEqualTo("id") + assertThat(invoiceModel.amountDue()).isEqualTo("8.00") + assertThat(invoiceModel.autoCollection()) + .isEqualTo( + AutoCollectionModel.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(invoiceModel.billingAddress()) + .contains( + AddressModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + assertThat(invoiceModel.createdAt()) + .isEqualTo(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + assertThat(invoiceModel.creditNotes()) + .containsExactly( + CreditNoteSummaryModel.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(invoiceModel.currency()).isEqualTo("USD") + assertThat(invoiceModel.customer()) + .isEqualTo( + CustomerMinifiedModel.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + assertThat(invoiceModel.customerBalanceTransactions()) + .containsExactly( + CustomerBalanceTransactionModel.builder() + .id("cgZa3SXcsPTVyC4Y") + .action(CustomerBalanceTransactionModel.Action.APPLIED_TO_INVOICE) + .amount("11.00") + .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) + .creditNote( + CustomerBalanceTransactionModel.CreditNote.builder().id("id").build() + ) + .description("An optional description") + .endingBalance("22.00") + .invoice( + CustomerBalanceTransactionModel.Invoice.builder() + .id("gXcsPTVyC4YZa3Sc") + .build() + ) + .startingBalance("33.00") + .type(CustomerBalanceTransactionModel.Type.INCREMENT) + .build() + ) + assertThat(invoiceModel.customerTaxId()) + .contains( + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) + .value("value") + .build() + ) + assertThat(invoiceModel._discount()).isEqualTo(JsonValue.from(mapOf())) + assertThat(invoiceModel.discounts()) + .containsExactly( + InvoiceLevelDiscount.ofPercentage( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + ) + assertThat(invoiceModel.dueDate()) + .contains(OffsetDateTime.parse("2022-05-30T07:00:00+00:00")) + assertThat(invoiceModel.eligibleToIssueAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(invoiceModel.hostedInvoiceUrl()).contains("hosted_invoice_url") + assertThat(invoiceModel.invoiceDate()) + .isEqualTo(OffsetDateTime.parse("2022-05-01T07:00:00+00:00")) + assertThat(invoiceModel.invoiceNumber()).isEqualTo("JYEFHK-00001") + assertThat(invoiceModel.invoicePdf()) + .contains("https://assets.withorb.com/invoice/rUHdhmg45vY45DX/qEAeuYePaphGMdFb") + assertThat(invoiceModel.invoiceSource()).isEqualTo(InvoiceModel.InvoiceSource.SUBSCRIPTION) + assertThat(invoiceModel.issueFailedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(invoiceModel.issuedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(invoiceModel.lineItems()) + .containsExactly( + InvoiceLineItemModel.builder() + .id("id") + .adjustedSubtotal("5.00") + .addAdjustment( + InvoiceLineItemModel.Adjustment.MonetaryUsageDiscountAdjustment.builder() + .id("id") + .adjustmentType( + InvoiceLineItemModel.Adjustment.MonetaryUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .amount("amount") + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .amount("7.00") + .creditsApplied("6.00") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .endDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .filter("filter") + .grouping("grouping") + .maximum( + MaximumModel.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + MinimumModel.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("Fixed Fee") + .partiallyInvoicedAmount("4.00") + .price( + PriceModel.UnitPrice.builder() + .id("id") + .billableMetric(BillableMetricTinyModel.builder().id("id").build()) + .billingCycleConfiguration( + BillingCycleConfigurationModel.builder() + .duration(0L) + .durationUnit(BillingCycleConfigurationModel.DurationUnit.DAY) + .build() + ) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + AllocationModel.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + BillingCycleConfigurationModel.builder() + .duration(0L) + .durationUnit(BillingCycleConfigurationModel.DurationUnit.DAY) + .build() + ) + .item(ItemSlimModel.builder().id("id").name("name").build()) + .maximum( + MaximumModel.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + PriceModel.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + MinimumModel.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(PriceModel.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) + .dimensionalPriceConfiguration( + DimensionalPriceConfigurationModel.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .quantity(1.0) + .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) + .addSubLineItem( + InvoiceLineItemModel.SubLineItem.MatrixSubLineItem.builder() + .amount("9.00") + .grouping( + SubLineItemGroupingModel.builder() + .key("region") + .value("west") + .build() + ) + .matrixConfig( + InvoiceLineItemModel.SubLineItem.MatrixSubLineItem.MatrixConfig + .builder() + .addDimensionValue("string") + .build() + ) + .name("Tier One") + .quantity(5.0) + .type(InvoiceLineItemModel.SubLineItem.MatrixSubLineItem.Type.MATRIX) + .build() + ) + .subtotal("9.00") + .addTaxAmount( + TaxAmountModel.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + ) + .addUsageCustomerId("string") + .build() + ) + assertThat(invoiceModel.maximum()) + .contains( + MaximumModel.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + assertThat(invoiceModel.maximumAmount()).contains("maximum_amount") + assertThat(invoiceModel.memo()).contains("memo") + assertThat(invoiceModel.metadata()) + .isEqualTo( + InvoiceModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(invoiceModel.minimum()) + .contains( + MinimumModel.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + assertThat(invoiceModel.minimumAmount()).contains("minimum_amount") + assertThat(invoiceModel.paidAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(invoiceModel.paymentAttempts()) + .containsExactly( + PaymentAttemptModel.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider(PaymentAttemptModel.PaymentProvider.STRIPE) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + ) + assertThat(invoiceModel.paymentFailedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(invoiceModel.paymentStartedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(invoiceModel.scheduledIssueAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(invoiceModel.shippingAddress()) + .contains( + AddressModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + assertThat(invoiceModel.status()).isEqualTo(InvoiceModel.Status.ISSUED) + assertThat(invoiceModel.subscription()) + .contains(SubscriptionMinifiedModel.builder().id("VDGsT23osdLb84KD").build()) + assertThat(invoiceModel.subtotal()).isEqualTo("8.00") + assertThat(invoiceModel.syncFailedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(invoiceModel.total()).isEqualTo("8.00") + assertThat(invoiceModel.voidedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(invoiceModel.willAutoIssue()).isEqualTo(true) + } +} 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 2a625cd7f..f195350ec 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 @@ -16,7 +16,7 @@ class InvoiceTest { .id("id") .amountDue("8.00") .autoCollection( - Invoice.AutoCollection.builder() + AutoCollectionModel.builder() .enabled(true) .nextAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .numAttempts(0L) @@ -24,7 +24,7 @@ class InvoiceTest { .build() ) .billingAddress( - Invoice.BillingAddress.builder() + AddressModel.builder() .city("city") .country("country") .line1("line1") @@ -35,7 +35,7 @@ class InvoiceTest { ) .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) .addCreditNote( - Invoice.CreditNote.builder() + CreditNoteSummaryModel.builder() .id("id") .creditNoteNumber("credit_note_number") .memo("memo") @@ -47,35 +47,35 @@ class InvoiceTest { ) .currency("USD") .customer( - Invoice.Customer.builder() + CustomerMinifiedModel.builder() .id("id") .externalCustomerId("external_customer_id") .build() ) .addCustomerBalanceTransaction( - Invoice.CustomerBalanceTransaction.builder() + CustomerBalanceTransactionModel.builder() .id("cgZa3SXcsPTVyC4Y") - .action(Invoice.CustomerBalanceTransaction.Action.APPLIED_TO_INVOICE) + .action(CustomerBalanceTransactionModel.Action.APPLIED_TO_INVOICE) .amount("11.00") .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) .creditNote( - Invoice.CustomerBalanceTransaction.CreditNote.builder().id("id").build() + CustomerBalanceTransactionModel.CreditNote.builder().id("id").build() ) .description("An optional description") .endingBalance("22.00") .invoice( - Invoice.CustomerBalanceTransaction.InnerInvoice.builder() + CustomerBalanceTransactionModel.Invoice.builder() .id("gXcsPTVyC4YZa3Sc") .build() ) .startingBalance("33.00") - .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .type(CustomerBalanceTransactionModel.Type.INCREMENT) .build() ) .customerTaxId( - Invoice.CustomerTaxId.builder() - .country(Invoice.CustomerTaxId.Country.AD) - .type(Invoice.CustomerTaxId.Type.AD_NRT) + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) .value("value") .build() ) @@ -99,14 +99,15 @@ class InvoiceTest { .issueFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addLineItem( - Invoice.LineItem.builder() + InvoiceLineItemModel.builder() .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment.builder() + InvoiceLineItemModel.Adjustment.MonetaryUsageDiscountAdjustment + .builder() .id("id") .adjustmentType( - Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment + InvoiceLineItemModel.Adjustment.MonetaryUsageDiscountAdjustment .AdjustmentType .USAGE_DISCOUNT ) @@ -132,14 +133,14 @@ class InvoiceTest { .filter("filter") .grouping("grouping") .maximum( - Invoice.LineItem.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .minimum( - Invoice.LineItem.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() @@ -148,25 +149,22 @@ class InvoiceTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + PriceModel.UnitPrice.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(BillableMetricTinyModel.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + BillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + AllocationModel.builder() .allowsRollover(true) .currency("currency") .build() @@ -184,45 +182,42 @@ class InvoiceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + BillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(ItemSlimModel.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + PriceModel.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) + .modelType(PriceModel.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() + UnitConfigModel.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + DimensionalPriceConfigurationModel.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -232,29 +227,30 @@ class InvoiceTest { .quantity(1.0) .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + InvoiceLineItemModel.SubLineItem.MatrixSubLineItem.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.Grouping - .builder() + SubLineItemGroupingModel.builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.MatrixConfig + InvoiceLineItemModel.SubLineItem.MatrixSubLineItem.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type(Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type.MATRIX) + .type( + InvoiceLineItemModel.SubLineItem.MatrixSubLineItem.Type.MATRIX + ) .build() ) .subtotal("9.00") .addTaxAmount( - Invoice.LineItem.TaxAmount.builder() + TaxAmountModel.builder() .amount("amount") .taxRateDescription("tax_rate_description") .taxRatePercentage("tax_rate_percentage") @@ -264,7 +260,7 @@ class InvoiceTest { .build() ) .maximum( - Invoice.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() @@ -277,7 +273,7 @@ class InvoiceTest { .build() ) .minimum( - Invoice.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() @@ -285,11 +281,11 @@ class InvoiceTest { .minimumAmount("minimum_amount") .paidAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addPaymentAttempt( - Invoice.PaymentAttempt.builder() + PaymentAttemptModel.builder() .id("id") .amount("amount") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) + .paymentProvider(PaymentAttemptModel.PaymentProvider.STRIPE) .paymentProviderId("payment_provider_id") .succeeded(true) .build() @@ -298,7 +294,7 @@ class InvoiceTest { .paymentStartedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .scheduledIssueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .shippingAddress( - Invoice.ShippingAddress.builder() + AddressModel.builder() .city("city") .country("country") .line1("line1") @@ -308,7 +304,7 @@ class InvoiceTest { .build() ) .status(Invoice.Status.ISSUED) - .subscription(Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build()) + .subscription(SubscriptionMinifiedModel.builder().id("VDGsT23osdLb84KD").build()) .subtotal("8.00") .syncFailedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .total("8.00") @@ -320,7 +316,7 @@ class InvoiceTest { assertThat(invoice.amountDue()).isEqualTo("8.00") assertThat(invoice.autoCollection()) .isEqualTo( - Invoice.AutoCollection.builder() + AutoCollectionModel.builder() .enabled(true) .nextAttemptAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .numAttempts(0L) @@ -329,7 +325,7 @@ class InvoiceTest { ) assertThat(invoice.billingAddress()) .contains( - Invoice.BillingAddress.builder() + AddressModel.builder() .city("city") .country("country") .line1("line1") @@ -341,7 +337,7 @@ class InvoiceTest { assertThat(invoice.createdAt()).isEqualTo(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) assertThat(invoice.creditNotes()) .containsExactly( - Invoice.CreditNote.builder() + CreditNoteSummaryModel.builder() .id("id") .creditNoteNumber("credit_note_number") .memo("memo") @@ -354,37 +350,37 @@ class InvoiceTest { assertThat(invoice.currency()).isEqualTo("USD") assertThat(invoice.customer()) .isEqualTo( - Invoice.Customer.builder() + CustomerMinifiedModel.builder() .id("id") .externalCustomerId("external_customer_id") .build() ) assertThat(invoice.customerBalanceTransactions()) .containsExactly( - Invoice.CustomerBalanceTransaction.builder() + CustomerBalanceTransactionModel.builder() .id("cgZa3SXcsPTVyC4Y") - .action(Invoice.CustomerBalanceTransaction.Action.APPLIED_TO_INVOICE) + .action(CustomerBalanceTransactionModel.Action.APPLIED_TO_INVOICE) .amount("11.00") .createdAt(OffsetDateTime.parse("2022-05-01T07:01:31+00:00")) .creditNote( - Invoice.CustomerBalanceTransaction.CreditNote.builder().id("id").build() + CustomerBalanceTransactionModel.CreditNote.builder().id("id").build() ) .description("An optional description") .endingBalance("22.00") .invoice( - Invoice.CustomerBalanceTransaction.InnerInvoice.builder() + CustomerBalanceTransactionModel.Invoice.builder() .id("gXcsPTVyC4YZa3Sc") .build() ) .startingBalance("33.00") - .type(Invoice.CustomerBalanceTransaction.Type.INCREMENT) + .type(CustomerBalanceTransactionModel.Type.INCREMENT) .build() ) assertThat(invoice.customerTaxId()) .contains( - Invoice.CustomerTaxId.builder() - .country(Invoice.CustomerTaxId.Country.AD) - .type(Invoice.CustomerTaxId.Type.AD_NRT) + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) .value("value") .build() ) @@ -416,14 +412,14 @@ class InvoiceTest { assertThat(invoice.issuedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(invoice.lineItems()) .containsExactly( - Invoice.LineItem.builder() + InvoiceLineItemModel.builder() .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment.builder() + InvoiceLineItemModel.Adjustment.MonetaryUsageDiscountAdjustment.builder() .id("id") .adjustmentType( - Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment + InvoiceLineItemModel.Adjustment.MonetaryUsageDiscountAdjustment .AdjustmentType .USAGE_DISCOUNT ) @@ -449,14 +445,14 @@ class InvoiceTest { .filter("filter") .grouping("grouping") .maximum( - Invoice.LineItem.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .minimum( - Invoice.LineItem.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() @@ -465,24 +461,20 @@ class InvoiceTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + PriceModel.UnitPrice.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(BillableMetricTinyModel.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(BillingCycleConfigurationModel.DurationUnit.DAY) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + AllocationModel.builder() .allowsRollover(true) .currency("currency") .build() @@ -500,44 +492,38 @@ class InvoiceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(BillingCycleConfigurationModel.DurationUnit.DAY) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(ItemSlimModel.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + PriceModel.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) + .modelType(PriceModel.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + DimensionalPriceConfigurationModel.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -547,28 +533,28 @@ class InvoiceTest { .quantity(1.0) .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + InvoiceLineItemModel.SubLineItem.MatrixSubLineItem.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.Grouping.builder() + SubLineItemGroupingModel.builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.MatrixConfig + InvoiceLineItemModel.SubLineItem.MatrixSubLineItem.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type(Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type.MATRIX) + .type(InvoiceLineItemModel.SubLineItem.MatrixSubLineItem.Type.MATRIX) .build() ) .subtotal("9.00") .addTaxAmount( - Invoice.LineItem.TaxAmount.builder() + TaxAmountModel.builder() .amount("amount") .taxRateDescription("tax_rate_description") .taxRatePercentage("tax_rate_percentage") @@ -579,7 +565,7 @@ class InvoiceTest { ) assertThat(invoice.maximum()) .contains( - Invoice.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() @@ -594,7 +580,7 @@ class InvoiceTest { ) assertThat(invoice.minimum()) .contains( - Invoice.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() @@ -603,11 +589,11 @@ class InvoiceTest { assertThat(invoice.paidAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(invoice.paymentAttempts()) .containsExactly( - Invoice.PaymentAttempt.builder() + PaymentAttemptModel.builder() .id("id") .amount("amount") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .paymentProvider(Invoice.PaymentAttempt.PaymentProvider.STRIPE) + .paymentProvider(PaymentAttemptModel.PaymentProvider.STRIPE) .paymentProviderId("payment_provider_id") .succeeded(true) .build() @@ -620,7 +606,7 @@ class InvoiceTest { .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(invoice.shippingAddress()) .contains( - Invoice.ShippingAddress.builder() + AddressModel.builder() .city("city") .country("country") .line1("line1") @@ -631,7 +617,7 @@ class InvoiceTest { ) assertThat(invoice.status()).isEqualTo(Invoice.Status.ISSUED) assertThat(invoice.subscription()) - .contains(Invoice.Subscription.builder().id("VDGsT23osdLb84KD").build()) + .contains(SubscriptionMinifiedModel.builder().id("VDGsT23osdLb84KD").build()) assertThat(invoice.subtotal()).isEqualTo("8.00") assertThat(invoice.syncFailedAt()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/ItemExternalConnectionModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/ItemExternalConnectionModelTest.kt new file mode 100644 index 000000000..b0f578810 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/ItemExternalConnectionModelTest.kt @@ -0,0 +1,22 @@ +// 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 + +class ItemExternalConnectionModelTest { + + @Test + fun createItemExternalConnectionModel() { + val itemExternalConnectionModel = + ItemExternalConnectionModel.builder() + .externalConnectionName(ItemExternalConnectionModel.ExternalConnectionName.STRIPE) + .externalEntityId("external_entity_id") + .build() + assertThat(itemExternalConnectionModel).isNotNull + assertThat(itemExternalConnectionModel.externalConnectionName()) + .isEqualTo(ItemExternalConnectionModel.ExternalConnectionName.STRIPE) + assertThat(itemExternalConnectionModel.externalEntityId()).isEqualTo("external_entity_id") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/ItemModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/ItemModelTest.kt new file mode 100644 index 000000000..59826f566 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/ItemModelTest.kt @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ItemModelTest { + + @Test + fun createItemModel() { + val itemModel = + ItemModel.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addExternalConnection( + ItemExternalConnectionModel.builder() + .externalConnectionName( + ItemExternalConnectionModel.ExternalConnectionName.STRIPE + ) + .externalEntityId("external_entity_id") + .build() + ) + .name("name") + .build() + assertThat(itemModel).isNotNull + assertThat(itemModel.id()).isEqualTo("id") + assertThat(itemModel.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(itemModel.externalConnections()) + .containsExactly( + ItemExternalConnectionModel.builder() + .externalConnectionName( + ItemExternalConnectionModel.ExternalConnectionName.STRIPE + ) + .externalEntityId("external_entity_id") + .build() + ) + assertThat(itemModel.name()).isEqualTo("name") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/ItemSlimModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/ItemSlimModelTest.kt new file mode 100644 index 000000000..90d82f64b --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/ItemSlimModelTest.kt @@ -0,0 +1,17 @@ +// 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 + +class ItemSlimModelTest { + + @Test + fun createItemSlimModel() { + val itemSlimModel = ItemSlimModel.builder().id("id").name("name").build() + assertThat(itemSlimModel).isNotNull + assertThat(itemSlimModel.id()).isEqualTo("id") + assertThat(itemSlimModel.name()).isEqualTo("name") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/ItemTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/ItemTest.kt index c934af60c..1debe02fc 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/ItemTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/ItemTest.kt @@ -15,9 +15,9 @@ class ItemTest { .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addExternalConnection( - Item.ExternalConnection.builder() + ItemExternalConnectionModel.builder() .externalConnectionName( - Item.ExternalConnection.ExternalConnectionName.STRIPE + ItemExternalConnectionModel.ExternalConnectionName.STRIPE ) .externalEntityId("external_entity_id") .build() @@ -29,8 +29,10 @@ class ItemTest { assertThat(item.createdAt()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(item.externalConnections()) .containsExactly( - Item.ExternalConnection.builder() - .externalConnectionName(Item.ExternalConnection.ExternalConnectionName.STRIPE) + ItemExternalConnectionModel.builder() + .externalConnectionName( + ItemExternalConnectionModel.ExternalConnectionName.STRIPE + ) .externalEntityId("external_entity_id") .build() ) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/ItemUpdateParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/ItemUpdateParamsTest.kt index cb063dcab..d6a4cabb4 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/ItemUpdateParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/ItemUpdateParamsTest.kt @@ -13,9 +13,9 @@ class ItemUpdateParamsTest { ItemUpdateParams.builder() .itemId("item_id") .addExternalConnection( - ItemUpdateParams.ExternalConnection.builder() + ItemExternalConnectionModel.builder() .externalConnectionName( - ItemUpdateParams.ExternalConnection.ExternalConnectionName.STRIPE + ItemExternalConnectionModel.ExternalConnectionName.STRIPE ) .externalEntityId("external_entity_id") .build() @@ -30,9 +30,9 @@ class ItemUpdateParamsTest { ItemUpdateParams.builder() .itemId("item_id") .addExternalConnection( - ItemUpdateParams.ExternalConnection.builder() + ItemExternalConnectionModel.builder() .externalConnectionName( - ItemUpdateParams.ExternalConnection.ExternalConnectionName.STRIPE + ItemExternalConnectionModel.ExternalConnectionName.STRIPE ) .externalEntityId("external_entity_id") .build() @@ -46,9 +46,9 @@ class ItemUpdateParamsTest { assertThat(body.externalConnections()) .contains( listOf( - ItemUpdateParams.ExternalConnection.builder() + ItemExternalConnectionModel.builder() .externalConnectionName( - ItemUpdateParams.ExternalConnection.ExternalConnectionName.STRIPE + ItemExternalConnectionModel.ExternalConnectionName.STRIPE ) .externalEntityId("external_entity_id") .build() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/MatrixConfigModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/MatrixConfigModelTest.kt new file mode 100644 index 000000000..a840fd02f --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/MatrixConfigModelTest.kt @@ -0,0 +1,34 @@ +// 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 + +class MatrixConfigModelTest { + + @Test + fun createMatrixConfigModel() { + val matrixConfigModel = + MatrixConfigModel.builder() + .defaultUnitAmount("default_unit_amount") + .addDimension("string") + .addMatrixValue( + MatrixValueModel.builder() + .addDimensionValue("string") + .unitAmount("unit_amount") + .build() + ) + .build() + assertThat(matrixConfigModel).isNotNull + assertThat(matrixConfigModel.defaultUnitAmount()).isEqualTo("default_unit_amount") + assertThat(matrixConfigModel.dimensions()).containsExactly("string") + assertThat(matrixConfigModel.matrixValues()) + .containsExactly( + MatrixValueModel.builder() + .addDimensionValue("string") + .unitAmount("unit_amount") + .build() + ) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/MatrixValueModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/MatrixValueModelTest.kt new file mode 100644 index 000000000..ba64caab7 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/MatrixValueModelTest.kt @@ -0,0 +1,18 @@ +// 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 + +class MatrixValueModelTest { + + @Test + fun createMatrixValueModel() { + val matrixValueModel = + MatrixValueModel.builder().addDimensionValue("string").unitAmount("unit_amount").build() + assertThat(matrixValueModel).isNotNull + assertThat(matrixValueModel.dimensionValues()).containsExactly("string") + assertThat(matrixValueModel.unitAmount()).isEqualTo("unit_amount") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/MatrixWithAllocationConfigModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/MatrixWithAllocationConfigModelTest.kt new file mode 100644 index 000000000..f29845930 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/MatrixWithAllocationConfigModelTest.kt @@ -0,0 +1,37 @@ +// 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 + +class MatrixWithAllocationConfigModelTest { + + @Test + fun createMatrixWithAllocationConfigModel() { + val matrixWithAllocationConfigModel = + MatrixWithAllocationConfigModel.builder() + .allocation(0.0) + .defaultUnitAmount("default_unit_amount") + .addDimension("string") + .addMatrixValue( + MatrixValueModel.builder() + .addDimensionValue("string") + .unitAmount("unit_amount") + .build() + ) + .build() + assertThat(matrixWithAllocationConfigModel).isNotNull + assertThat(matrixWithAllocationConfigModel.allocation()).isEqualTo(0.0) + assertThat(matrixWithAllocationConfigModel.defaultUnitAmount()) + .isEqualTo("default_unit_amount") + assertThat(matrixWithAllocationConfigModel.dimensions()).containsExactly("string") + assertThat(matrixWithAllocationConfigModel.matrixValues()) + .containsExactly( + MatrixValueModel.builder() + .addDimensionValue("string") + .unitAmount("unit_amount") + .build() + ) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/MaximumIntervalModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/MaximumIntervalModelTest.kt new file mode 100644 index 000000000..227813849 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/MaximumIntervalModelTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class MaximumIntervalModelTest { + + @Test + fun createMaximumIntervalModel() { + val maximumIntervalModel = + MaximumIntervalModel.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .maximumAmount("maximum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + assertThat(maximumIntervalModel).isNotNull + assertThat(maximumIntervalModel.appliesToPriceIds()).containsExactly("string") + assertThat(maximumIntervalModel.appliesToPriceIntervalIds()).containsExactly("string") + assertThat(maximumIntervalModel.endDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(maximumIntervalModel.maximumAmount()).isEqualTo("maximum_amount") + assertThat(maximumIntervalModel.startDate()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/MaximumModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/MaximumModelTest.kt new file mode 100644 index 000000000..fecc06075 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/MaximumModelTest.kt @@ -0,0 +1,21 @@ +// 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 + +class MaximumModelTest { + + @Test + fun createMaximumModel() { + val maximumModel = + MaximumModel.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + assertThat(maximumModel).isNotNull + assertThat(maximumModel.appliesToPriceIds()).containsExactly("string") + assertThat(maximumModel.maximumAmount()).isEqualTo("maximum_amount") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/MinimumIntervalModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/MinimumIntervalModelTest.kt new file mode 100644 index 000000000..623be5203 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/MinimumIntervalModelTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class MinimumIntervalModelTest { + + @Test + fun createMinimumIntervalModel() { + val minimumIntervalModel = + MinimumIntervalModel.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minimumAmount("minimum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + assertThat(minimumIntervalModel).isNotNull + assertThat(minimumIntervalModel.appliesToPriceIds()).containsExactly("string") + assertThat(minimumIntervalModel.appliesToPriceIntervalIds()).containsExactly("string") + assertThat(minimumIntervalModel.endDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(minimumIntervalModel.minimumAmount()).isEqualTo("minimum_amount") + assertThat(minimumIntervalModel.startDate()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/MinimumModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/MinimumModelTest.kt new file mode 100644 index 000000000..356ea3aea --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/MinimumModelTest.kt @@ -0,0 +1,21 @@ +// 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 + +class MinimumModelTest { + + @Test + fun createMinimumModel() { + val minimumModel = + MinimumModel.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + assertThat(minimumModel).isNotNull + assertThat(minimumModel.appliesToPriceIds()).containsExactly("string") + assertThat(minimumModel.minimumAmount()).isEqualTo("minimum_amount") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCancelResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionModelTest.kt similarity index 70% rename from orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCancelResponseTest.kt rename to orb-java-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionModelTest.kt index 0472d181b..882eb414e 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCancelResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/MutatedSubscriptionModelTest.kt @@ -7,26 +7,22 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class SubscriptionCancelResponseTest { +class MutatedSubscriptionModelTest { @Test - fun createSubscriptionCancelResponse() { - val subscriptionCancelResponse = - SubscriptionCancelResponse.builder() + fun createMutatedSubscriptionModel() { + val mutatedSubscriptionModel = + MutatedSubscriptionModel.builder() .id("id") .activePlanPhaseOrder(0L) .addAdjustmentInterval( - SubscriptionCancelResponse.AdjustmentInterval.builder() + AdjustmentIntervalModel.builder() .id("id") .adjustment( - SubscriptionCancelResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .builder() + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.builder() .id("id") .adjustmentType( - SubscriptionCancelResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.AdjustmentType .USAGE_DISCOUNT ) .addAppliesToPriceId("string") @@ -43,7 +39,7 @@ class SubscriptionCancelResponseTest { ) .autoCollection(true) .billingCycleAnchorConfiguration( - SubscriptionCancelResponse.BillingCycleAnchorConfiguration.builder() + BillingCycleAnchorConfigurationModel.builder() .day(1L) .month(1L) .year(0L) @@ -54,13 +50,13 @@ class SubscriptionCancelResponseTest { .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customer( - Customer.builder() + CustomerModel.builder() .id("id") .addAdditionalEmail("string") .autoCollection(true) .balance("balance") .billingAddress( - Customer.BillingAddress.builder() + AddressModel.builder() .city("city") .country("country") .line1("line1") @@ -76,15 +72,15 @@ class SubscriptionCancelResponseTest { .exemptFromAutomatedTax(true) .externalCustomerId("external_customer_id") .hierarchy( - Customer.Hierarchy.builder() + CustomerModel.Hierarchy.builder() .addChild( - Customer.Hierarchy.Child.builder() + CustomerMinifiedModel.builder() .id("id") .externalCustomerId("external_customer_id") .build() ) .parent( - Customer.Hierarchy.Parent.builder() + CustomerMinifiedModel.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -92,16 +88,16 @@ class SubscriptionCancelResponseTest { .build() ) .metadata( - Customer.Metadata.builder() + CustomerModel.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .name("name") - .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) + .paymentProvider(CustomerModel.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .portalUrl("portal_url") .shippingAddress( - Customer.ShippingAddress.builder() + AddressModel.builder() .city("city") .country("country") .line1("line1") @@ -111,21 +107,22 @@ class SubscriptionCancelResponseTest { .build() ) .taxId( - Customer.TaxId.builder() - .country(Customer.TaxId.Country.AD) - .type(Customer.TaxId.Type.AD_NRT) + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) .value("value") .build() ) .timezone("timezone") .accountingSyncConfiguration( - Customer.AccountingSyncConfiguration.builder() + CustomerModel.AccountingSyncConfiguration.builder() .addAccountingProvider( - Customer.AccountingSyncConfiguration.AccountingProvider + CustomerModel.AccountingSyncConfiguration.AccountingProvider .builder() .externalProviderId("external_provider_id") .providerType( - Customer.AccountingSyncConfiguration.AccountingProvider + CustomerModel.AccountingSyncConfiguration + .AccountingProvider .ProviderType .QUICKBOOKS ) @@ -135,28 +132,24 @@ class SubscriptionCancelResponseTest { .build() ) .reportingConfiguration( - Customer.ReportingConfiguration.builder().exempt(true).build() + CustomerModel.ReportingConfiguration.builder().exempt(true).build() ) .build() ) .defaultInvoiceMemo("default_invoice_memo") .addDiscountInterval( - SubscriptionCancelResponse.DiscountInterval.AmountDiscountInterval.builder() + AmountDiscountIntervalModel.builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionCancelResponse.DiscountInterval.AmountDiscountInterval - .DiscountType - .AMOUNT - ) + .discountType(AmountDiscountIntervalModel.DiscountType.AMOUNT) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFixedFeeQuantitySchedule( - SubscriptionCancelResponse.FixedFeeQuantitySchedule.builder() + FixedFeeQuantityScheduleEntryModel.builder() .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .priceId("price_id") .quantity(0.0) @@ -165,7 +158,7 @@ class SubscriptionCancelResponseTest { ) .invoicingThreshold("invoicing_threshold") .addMaximumInterval( - SubscriptionCancelResponse.MaximumInterval.builder() + MaximumIntervalModel.builder() .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -174,12 +167,12 @@ class SubscriptionCancelResponseTest { .build() ) .metadata( - SubscriptionCancelResponse.Metadata.builder() + MutatedSubscriptionModel.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .addMinimumInterval( - SubscriptionCancelResponse.MinimumInterval.builder() + MinimumIntervalModel.builder() .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -189,13 +182,13 @@ class SubscriptionCancelResponseTest { ) .netTerms(0L) .plan( - Plan.builder() + PlanModel.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.builder() .id("id") .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.AdjustmentType .USAGE_DISCOUNT ) .addAppliesToPriceId("string") @@ -206,7 +199,7 @@ class SubscriptionCancelResponseTest { .build() ) .basePlan( - Plan.BasePlan.builder() + PlanMinifiedModel.builder() .id("m2t5akQeh2obwxeU") .externalPlanId("m2t5akQeh2obwxeU") .name("Example plan") @@ -229,19 +222,19 @@ class SubscriptionCancelResponseTest { .externalPlanId("external_plan_id") .invoicingCurrency("invoicing_currency") .maximum( - Plan.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Plan.Metadata.builder() + PlanModel.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Plan.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() @@ -250,7 +243,7 @@ class SubscriptionCancelResponseTest { .name("name") .netTerms(0L) .addPlanPhase( - Plan.PlanPhase.builder() + PlanModel.PlanPhase.builder() .id("id") .description("description") .discount( @@ -263,16 +256,16 @@ class SubscriptionCancelResponseTest { .build() ) .duration(0L) - .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .durationUnit(PlanModel.PlanPhase.DurationUnit.DAILY) .maximum( - Plan.PlanPhase.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .minimum( - Plan.PlanPhase.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() @@ -283,25 +276,22 @@ class SubscriptionCancelResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + PriceModel.UnitPrice.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(BillableMetricTinyModel.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + BillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + AllocationModel.builder() .allowsRollover(true) .currency("currency") .build() @@ -319,45 +309,42 @@ class SubscriptionCancelResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + BillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(ItemSlimModel.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + PriceModel.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) + .modelType(PriceModel.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() + UnitConfigModel.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + DimensionalPriceConfigurationModel.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -365,24 +352,24 @@ class SubscriptionCancelResponseTest { .build() ) .product( - Plan.Product.builder() + PlanModel.Product.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .name("name") .build() ) - .status(Plan.Status.ACTIVE) + .status(PlanModel.Status.ACTIVE) .trialConfig( - Plan.TrialConfig.builder() + PlanModel.TrialConfig.builder() .trialPeriod(0L) - .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .trialPeriodUnit(PlanModel.TrialConfig.TrialPeriodUnit.DAYS) .build() ) .version(0L) .build() ) .addPriceInterval( - SubscriptionCancelResponse.PriceInterval.builder() + PriceIntervalModel.builder() .id("id") .billingCycleDay(0L) .currentBillingPeriodEndDate( @@ -394,33 +381,29 @@ class SubscriptionCancelResponseTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .filter("filter") .addFixedFeeQuantityTransition( - SubscriptionCancelResponse.PriceInterval.FixedFeeQuantityTransition - .builder() + PriceIntervalModel.FixedFeeQuantityTransition.builder() .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .priceId("price_id") .quantity(0L) .build() ) .price( - Price.UnitPrice.builder() + PriceModel.UnitPrice.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(BillableMetricTinyModel.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + BillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + AllocationModel.builder() .allowsRollover(true) .currency("currency") .build() @@ -438,45 +421,42 @@ class SubscriptionCancelResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + BillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(ItemSlimModel.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + PriceModel.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) + .modelType(PriceModel.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() + UnitConfigModel.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + DimensionalPriceConfigurationModel.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -488,36 +468,32 @@ class SubscriptionCancelResponseTest { .build() ) .redeemedCoupon( - SubscriptionCancelResponse.RedeemedCoupon.builder() + CouponRedemptionModel.builder() .couponId("coupon_id") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .status(SubscriptionCancelResponse.Status.ACTIVE) + .status(MutatedSubscriptionModel.Status.ACTIVE) .trialInfo( - SubscriptionCancelResponse.TrialInfo.builder() + SubscriptionTrialInfoModel.builder() .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) .build() - assertThat(subscriptionCancelResponse).isNotNull - assertThat(subscriptionCancelResponse.id()).isEqualTo("id") - assertThat(subscriptionCancelResponse.activePlanPhaseOrder()).contains(0L) - assertThat(subscriptionCancelResponse.adjustmentIntervals()) + assertThat(mutatedSubscriptionModel).isNotNull + assertThat(mutatedSubscriptionModel.id()).isEqualTo("id") + assertThat(mutatedSubscriptionModel.activePlanPhaseOrder()).contains(0L) + assertThat(mutatedSubscriptionModel.adjustmentIntervals()) .containsExactly( - SubscriptionCancelResponse.AdjustmentInterval.builder() + AdjustmentIntervalModel.builder() .id("id") .adjustment( - SubscriptionCancelResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .builder() + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.builder() .id("id") .adjustmentType( - SubscriptionCancelResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.AdjustmentType .USAGE_DISCOUNT ) .addAppliesToPriceId("string") @@ -532,31 +508,27 @@ class SubscriptionCancelResponseTest { .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) - assertThat(subscriptionCancelResponse.autoCollection()).contains(true) - assertThat(subscriptionCancelResponse.billingCycleAnchorConfiguration()) + assertThat(mutatedSubscriptionModel.autoCollection()).contains(true) + assertThat(mutatedSubscriptionModel.billingCycleAnchorConfiguration()) .isEqualTo( - SubscriptionCancelResponse.BillingCycleAnchorConfiguration.builder() - .day(1L) - .month(1L) - .year(0L) - .build() + BillingCycleAnchorConfigurationModel.builder().day(1L).month(1L).year(0L).build() ) - assertThat(subscriptionCancelResponse.billingCycleDay()).isEqualTo(1L) - assertThat(subscriptionCancelResponse.createdAt()) + assertThat(mutatedSubscriptionModel.billingCycleDay()).isEqualTo(1L) + assertThat(mutatedSubscriptionModel.createdAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionCancelResponse.currentBillingPeriodEndDate()) + assertThat(mutatedSubscriptionModel.currentBillingPeriodEndDate()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionCancelResponse.currentBillingPeriodStartDate()) + assertThat(mutatedSubscriptionModel.currentBillingPeriodStartDate()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionCancelResponse.customer()) + assertThat(mutatedSubscriptionModel.customer()) .isEqualTo( - Customer.builder() + CustomerModel.builder() .id("id") .addAdditionalEmail("string") .autoCollection(true) .balance("balance") .billingAddress( - Customer.BillingAddress.builder() + AddressModel.builder() .city("city") .country("country") .line1("line1") @@ -572,15 +544,15 @@ class SubscriptionCancelResponseTest { .exemptFromAutomatedTax(true) .externalCustomerId("external_customer_id") .hierarchy( - Customer.Hierarchy.builder() + CustomerModel.Hierarchy.builder() .addChild( - Customer.Hierarchy.Child.builder() + CustomerMinifiedModel.builder() .id("id") .externalCustomerId("external_customer_id") .build() ) .parent( - Customer.Hierarchy.Parent.builder() + CustomerMinifiedModel.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -588,16 +560,16 @@ class SubscriptionCancelResponseTest { .build() ) .metadata( - Customer.Metadata.builder() + CustomerModel.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .name("name") - .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) + .paymentProvider(CustomerModel.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .portalUrl("portal_url") .shippingAddress( - Customer.ShippingAddress.builder() + AddressModel.builder() .city("city") .country("country") .line1("line1") @@ -607,20 +579,21 @@ class SubscriptionCancelResponseTest { .build() ) .taxId( - Customer.TaxId.builder() - .country(Customer.TaxId.Country.AD) - .type(Customer.TaxId.Type.AD_NRT) + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) .value("value") .build() ) .timezone("timezone") .accountingSyncConfiguration( - Customer.AccountingSyncConfiguration.builder() + CustomerModel.AccountingSyncConfiguration.builder() .addAccountingProvider( - Customer.AccountingSyncConfiguration.AccountingProvider.builder() + CustomerModel.AccountingSyncConfiguration.AccountingProvider + .builder() .externalProviderId("external_provider_id") .providerType( - Customer.AccountingSyncConfiguration.AccountingProvider + CustomerModel.AccountingSyncConfiguration.AccountingProvider .ProviderType .QUICKBOOKS ) @@ -630,43 +603,39 @@ class SubscriptionCancelResponseTest { .build() ) .reportingConfiguration( - Customer.ReportingConfiguration.builder().exempt(true).build() + CustomerModel.ReportingConfiguration.builder().exempt(true).build() ) .build() ) - assertThat(subscriptionCancelResponse.defaultInvoiceMemo()).contains("default_invoice_memo") - assertThat(subscriptionCancelResponse.discountIntervals()) + assertThat(mutatedSubscriptionModel.defaultInvoiceMemo()).contains("default_invoice_memo") + assertThat(mutatedSubscriptionModel.discountIntervals()) .containsExactly( - SubscriptionCancelResponse.DiscountInterval.ofAmount( - SubscriptionCancelResponse.DiscountInterval.AmountDiscountInterval.builder() + MutatedSubscriptionModel.DiscountInterval.ofAmountDiscountIntervalModel( + AmountDiscountIntervalModel.builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionCancelResponse.DiscountInterval.AmountDiscountInterval - .DiscountType - .AMOUNT - ) + .discountType(AmountDiscountIntervalModel.DiscountType.AMOUNT) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) ) - assertThat(subscriptionCancelResponse.endDate()) + assertThat(mutatedSubscriptionModel.endDate()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionCancelResponse.fixedFeeQuantitySchedule()) + assertThat(mutatedSubscriptionModel.fixedFeeQuantitySchedule()) .containsExactly( - SubscriptionCancelResponse.FixedFeeQuantitySchedule.builder() + FixedFeeQuantityScheduleEntryModel.builder() .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .priceId("price_id") .quantity(0.0) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) - assertThat(subscriptionCancelResponse.invoicingThreshold()).contains("invoicing_threshold") - assertThat(subscriptionCancelResponse.maximumIntervals()) + assertThat(mutatedSubscriptionModel.invoicingThreshold()).contains("invoicing_threshold") + assertThat(mutatedSubscriptionModel.maximumIntervals()) .containsExactly( - SubscriptionCancelResponse.MaximumInterval.builder() + MaximumIntervalModel.builder() .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -674,15 +643,15 @@ class SubscriptionCancelResponseTest { .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) - assertThat(subscriptionCancelResponse.metadata()) + assertThat(mutatedSubscriptionModel.metadata()) .isEqualTo( - SubscriptionCancelResponse.Metadata.builder() + MutatedSubscriptionModel.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - assertThat(subscriptionCancelResponse.minimumIntervals()) + assertThat(mutatedSubscriptionModel.minimumIntervals()) .containsExactly( - SubscriptionCancelResponse.MinimumInterval.builder() + MinimumIntervalModel.builder() .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -690,16 +659,16 @@ class SubscriptionCancelResponseTest { .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) - assertThat(subscriptionCancelResponse.netTerms()).isEqualTo(0L) - assertThat(subscriptionCancelResponse.plan()) + assertThat(mutatedSubscriptionModel.netTerms()).isEqualTo(0L) + assertThat(mutatedSubscriptionModel.plan()) .isEqualTo( - Plan.builder() + PlanModel.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.builder() .id("id") .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.AdjustmentType .USAGE_DISCOUNT ) .addAppliesToPriceId("string") @@ -710,7 +679,7 @@ class SubscriptionCancelResponseTest { .build() ) .basePlan( - Plan.BasePlan.builder() + PlanMinifiedModel.builder() .id("m2t5akQeh2obwxeU") .externalPlanId("m2t5akQeh2obwxeU") .name("Example plan") @@ -733,19 +702,19 @@ class SubscriptionCancelResponseTest { .externalPlanId("external_plan_id") .invoicingCurrency("invoicing_currency") .maximum( - Plan.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Plan.Metadata.builder() + PlanModel.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Plan.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() @@ -754,7 +723,7 @@ class SubscriptionCancelResponseTest { .name("name") .netTerms(0L) .addPlanPhase( - Plan.PlanPhase.builder() + PlanModel.PlanPhase.builder() .id("id") .description("description") .discount( @@ -767,16 +736,16 @@ class SubscriptionCancelResponseTest { .build() ) .duration(0L) - .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .durationUnit(PlanModel.PlanPhase.DurationUnit.DAILY) .maximum( - Plan.PlanPhase.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .minimum( - Plan.PlanPhase.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() @@ -787,24 +756,20 @@ class SubscriptionCancelResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + PriceModel.UnitPrice.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(BillableMetricTinyModel.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(BillingCycleConfigurationModel.DurationUnit.DAY) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + AllocationModel.builder() .allowsRollover(true) .currency("currency") .build() @@ -822,44 +787,38 @@ class SubscriptionCancelResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(BillingCycleConfigurationModel.DurationUnit.DAY) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(ItemSlimModel.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + PriceModel.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) + .modelType(PriceModel.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + DimensionalPriceConfigurationModel.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -867,25 +826,25 @@ class SubscriptionCancelResponseTest { .build() ) .product( - Plan.Product.builder() + PlanModel.Product.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .name("name") .build() ) - .status(Plan.Status.ACTIVE) + .status(PlanModel.Status.ACTIVE) .trialConfig( - Plan.TrialConfig.builder() + PlanModel.TrialConfig.builder() .trialPeriod(0L) - .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .trialPeriodUnit(PlanModel.TrialConfig.TrialPeriodUnit.DAYS) .build() ) .version(0L) .build() ) - assertThat(subscriptionCancelResponse.priceIntervals()) + assertThat(mutatedSubscriptionModel.priceIntervals()) .containsExactly( - SubscriptionCancelResponse.PriceInterval.builder() + PriceIntervalModel.builder() .id("id") .billingCycleDay(0L) .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -893,32 +852,27 @@ class SubscriptionCancelResponseTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .filter("filter") .addFixedFeeQuantityTransition( - SubscriptionCancelResponse.PriceInterval.FixedFeeQuantityTransition - .builder() + PriceIntervalModel.FixedFeeQuantityTransition.builder() .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .priceId("price_id") .quantity(0L) .build() ) .price( - Price.UnitPrice.builder() + PriceModel.UnitPrice.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(BillableMetricTinyModel.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(BillingCycleConfigurationModel.DurationUnit.DAY) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + AllocationModel.builder() .allowsRollover(true) .currency("currency") .build() @@ -936,44 +890,38 @@ class SubscriptionCancelResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(BillingCycleConfigurationModel.DurationUnit.DAY) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(ItemSlimModel.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + PriceModel.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) + .modelType(PriceModel.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + DimensionalPriceConfigurationModel.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -984,21 +932,21 @@ class SubscriptionCancelResponseTest { .addUsageCustomerId("string") .build() ) - assertThat(subscriptionCancelResponse.redeemedCoupon()) + assertThat(mutatedSubscriptionModel.redeemedCoupon()) .contains( - SubscriptionCancelResponse.RedeemedCoupon.builder() + CouponRedemptionModel.builder() .couponId("coupon_id") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) - assertThat(subscriptionCancelResponse.startDate()) + assertThat(mutatedSubscriptionModel.startDate()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionCancelResponse.status()) - .isEqualTo(SubscriptionCancelResponse.Status.ACTIVE) - assertThat(subscriptionCancelResponse.trialInfo()) + assertThat(mutatedSubscriptionModel.status()) + .isEqualTo(MutatedSubscriptionModel.Status.ACTIVE) + assertThat(mutatedSubscriptionModel.trialInfo()) .isEqualTo( - SubscriptionCancelResponse.TrialInfo.builder() + SubscriptionTrialInfoModel.builder() .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewAccountingSyncConfigurationModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewAccountingSyncConfigurationModelTest.kt new file mode 100644 index 000000000..6b7269540 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewAccountingSyncConfigurationModelTest.kt @@ -0,0 +1,32 @@ +// 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 + +class NewAccountingSyncConfigurationModelTest { + + @Test + fun createNewAccountingSyncConfigurationModel() { + val newAccountingSyncConfigurationModel = + NewAccountingSyncConfigurationModel.builder() + .addAccountingProvider( + NewAccountingSyncConfigurationModel.AccountingProvider.builder() + .externalProviderId("external_provider_id") + .providerType("provider_type") + .build() + ) + .excluded(true) + .build() + assertThat(newAccountingSyncConfigurationModel).isNotNull + assertThat(newAccountingSyncConfigurationModel.accountingProviders().get()) + .containsExactly( + NewAccountingSyncConfigurationModel.AccountingProvider.builder() + .externalProviderId("external_provider_id") + .providerType("provider_type") + .build() + ) + assertThat(newAccountingSyncConfigurationModel.excluded()).contains(true) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewAllocationPriceModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewAllocationPriceModelTest.kt new file mode 100644 index 000000000..9e89e2da5 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewAllocationPriceModelTest.kt @@ -0,0 +1,26 @@ +// 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 + +class NewAllocationPriceModelTest { + + @Test + fun createNewAllocationPriceModel() { + val newAllocationPriceModel = + NewAllocationPriceModel.builder() + .amount("10.00") + .cadence(NewAllocationPriceModel.Cadence.ONE_TIME) + .currency("USD") + .expiresAtEndOfCadence(true) + .build() + assertThat(newAllocationPriceModel).isNotNull + assertThat(newAllocationPriceModel.amount()).isEqualTo("10.00") + assertThat(newAllocationPriceModel.cadence()) + .isEqualTo(NewAllocationPriceModel.Cadence.ONE_TIME) + assertThat(newAllocationPriceModel.currency()).isEqualTo("USD") + assertThat(newAllocationPriceModel.expiresAtEndOfCadence()).isEqualTo(true) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewBillingCycleConfigurationModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewBillingCycleConfigurationModelTest.kt new file mode 100644 index 000000000..6d9006c52 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewBillingCycleConfigurationModelTest.kt @@ -0,0 +1,22 @@ +// 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 + +class NewBillingCycleConfigurationModelTest { + + @Test + fun createNewBillingCycleConfigurationModel() { + val newBillingCycleConfigurationModel = + NewBillingCycleConfigurationModel.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfigurationModel.DurationUnit.DAY) + .build() + assertThat(newBillingCycleConfigurationModel).isNotNull + assertThat(newBillingCycleConfigurationModel.duration()).isEqualTo(0L) + assertThat(newBillingCycleConfigurationModel.durationUnit()) + .isEqualTo(NewBillingCycleConfigurationModel.DurationUnit.DAY) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/NewReportingConfigurationModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewReportingConfigurationModelTest.kt new file mode 100644 index 000000000..ade92e71f --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/NewReportingConfigurationModelTest.kt @@ -0,0 +1,17 @@ +// 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 + +class NewReportingConfigurationModelTest { + + @Test + fun createNewReportingConfigurationModel() { + val newReportingConfigurationModel = + NewReportingConfigurationModel.builder().exempt(true).build() + assertThat(newReportingConfigurationModel).isNotNull + assertThat(newReportingConfigurationModel.exempt()).isEqualTo(true) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PackageConfigModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PackageConfigModelTest.kt new file mode 100644 index 000000000..152e5e1a1 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PackageConfigModelTest.kt @@ -0,0 +1,18 @@ +// 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 + +class PackageConfigModelTest { + + @Test + fun createPackageConfigModel() { + val packageConfigModel = + PackageConfigModel.builder().packageAmount("package_amount").packageSize(0L).build() + assertThat(packageConfigModel).isNotNull + assertThat(packageConfigModel.packageAmount()).isEqualTo("package_amount") + assertThat(packageConfigModel.packageSize()).isEqualTo(0L) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PaginationMetadataModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PaginationMetadataModelTest.kt new file mode 100644 index 000000000..e7d1b90ea --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PaginationMetadataModelTest.kt @@ -0,0 +1,18 @@ +// 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 + +class PaginationMetadataModelTest { + + @Test + fun createPaginationMetadataModel() { + val paginationMetadataModel = + PaginationMetadataModel.builder().hasMore(true).nextCursor("next_cursor").build() + assertThat(paginationMetadataModel).isNotNull + assertThat(paginationMetadataModel.hasMore()).isEqualTo(true) + assertThat(paginationMetadataModel.nextCursor()).contains("next_cursor") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PaymentAttemptModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PaymentAttemptModelTest.kt new file mode 100644 index 000000000..dea1c4884 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PaymentAttemptModelTest.kt @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class PaymentAttemptModelTest { + + @Test + fun createPaymentAttemptModel() { + val paymentAttemptModel = + PaymentAttemptModel.builder() + .id("id") + .amount("amount") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .paymentProvider(PaymentAttemptModel.PaymentProvider.STRIPE) + .paymentProviderId("payment_provider_id") + .succeeded(true) + .build() + assertThat(paymentAttemptModel).isNotNull + assertThat(paymentAttemptModel.id()).isEqualTo("id") + assertThat(paymentAttemptModel.amount()).isEqualTo("amount") + assertThat(paymentAttemptModel.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(paymentAttemptModel.paymentProvider()) + .contains(PaymentAttemptModel.PaymentProvider.STRIPE) + assertThat(paymentAttemptModel.paymentProviderId()).contains("payment_provider_id") + assertThat(paymentAttemptModel.succeeded()).isEqualTo(true) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PercentageDiscountIntervalModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PercentageDiscountIntervalModelTest.kt new file mode 100644 index 000000000..ad835f6c4 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PercentageDiscountIntervalModelTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class PercentageDiscountIntervalModelTest { + + @Test + fun createPercentageDiscountIntervalModel() { + val percentageDiscountIntervalModel = + PercentageDiscountIntervalModel.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .discountType(PercentageDiscountIntervalModel.DiscountType.PERCENTAGE) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .percentageDiscount(0.15) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + assertThat(percentageDiscountIntervalModel).isNotNull + assertThat(percentageDiscountIntervalModel.appliesToPriceIds()).containsExactly("string") + assertThat(percentageDiscountIntervalModel.appliesToPriceIntervalIds()) + .containsExactly("string") + assertThat(percentageDiscountIntervalModel.discountType()) + .isEqualTo(PercentageDiscountIntervalModel.DiscountType.PERCENTAGE) + assertThat(percentageDiscountIntervalModel.endDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(percentageDiscountIntervalModel.percentageDiscount()).isEqualTo(0.15) + assertThat(percentageDiscountIntervalModel.startDate()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PercentageDiscountModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PercentageDiscountModelTest.kt new file mode 100644 index 000000000..ea77b4617 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PercentageDiscountModelTest.kt @@ -0,0 +1,28 @@ +// 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 + +class PercentageDiscountModelTest { + + @Test + fun createPercentageDiscountModel() { + val percentageDiscountModel = + PercentageDiscountModel.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscountModel.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + assertThat(percentageDiscountModel).isNotNull + assertThat(percentageDiscountModel.appliesToPriceIds()) + .containsExactly("h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl") + assertThat(percentageDiscountModel.discountType()) + .isEqualTo(PercentageDiscountModel.DiscountType.PERCENTAGE) + assertThat(percentageDiscountModel.percentageDiscount()).isEqualTo(0.15) + assertThat(percentageDiscountModel.reason()).contains("reason") + } +} 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 4d32ce36e..c4b3f754d 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 @@ -20,21 +20,13 @@ class PlanCreateParamsTest { .itemId("item_id") .modelType(PlanCreateParams.Price.NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - PlanCreateParams.Price.NewPlanUnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - PlanCreateParams.Price.NewPlanUnitPrice.BillingCycleConfiguration.builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) - .durationUnit( - PlanCreateParams.Price.NewPlanUnitPrice.BillingCycleConfiguration - .DurationUnit - .DAY - ) + .durationUnit(NewBillingCycleConfigurationModel.DurationUnit.DAY) .build() ) .conversionRate(0.0) @@ -43,14 +35,9 @@ class PlanCreateParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - PlanCreateParams.Price.NewPlanUnitPrice.InvoicingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) - .durationUnit( - PlanCreateParams.Price.NewPlanUnitPrice.InvoicingCycleConfiguration - .DurationUnit - .DAY - ) + .durationUnit(NewBillingCycleConfigurationModel.DurationUnit.DAY) .build() ) .metadata( @@ -84,23 +71,13 @@ class PlanCreateParamsTest { .itemId("item_id") .modelType(PlanCreateParams.Price.NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - PlanCreateParams.Price.NewPlanUnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - PlanCreateParams.Price.NewPlanUnitPrice.BillingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) - .durationUnit( - PlanCreateParams.Price.NewPlanUnitPrice - .BillingCycleConfiguration - .DurationUnit - .DAY - ) + .durationUnit(NewBillingCycleConfigurationModel.DurationUnit.DAY) .build() ) .conversionRate(0.0) @@ -109,15 +86,9 @@ class PlanCreateParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - PlanCreateParams.Price.NewPlanUnitPrice.InvoicingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) - .durationUnit( - PlanCreateParams.Price.NewPlanUnitPrice - .InvoicingCycleConfiguration - .DurationUnit - .DAY - ) + .durationUnit(NewBillingCycleConfigurationModel.DurationUnit.DAY) .build() ) .metadata( @@ -152,22 +123,14 @@ class PlanCreateParamsTest { .itemId("item_id") .modelType(PlanCreateParams.Price.NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - PlanCreateParams.Price.NewPlanUnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - PlanCreateParams.Price.NewPlanUnitPrice.BillingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - PlanCreateParams.Price.NewPlanUnitPrice - .BillingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) @@ -177,14 +140,10 @@ class PlanCreateParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - PlanCreateParams.Price.NewPlanUnitPrice.InvoicingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - PlanCreateParams.Price.NewPlanUnitPrice - .InvoicingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) @@ -221,11 +180,7 @@ class PlanCreateParamsTest { .itemId("item_id") .modelType(PlanCreateParams.Price.NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - PlanCreateParams.Price.NewPlanUnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) .build() ) .build() @@ -244,11 +199,7 @@ class PlanCreateParamsTest { .itemId("item_id") .modelType(PlanCreateParams.Price.NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - PlanCreateParams.Price.NewPlanUnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) .build() ) ) 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 470017d74..2bd5f0ed4 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 @@ -3,7 +3,6 @@ package com.withorb.api.models import com.withorb.api.core.JsonValue -import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -13,10 +12,14 @@ class PlanExternalPlanIdUpdateParamsTest { fun create() { PlanExternalPlanIdUpdateParams.builder() .otherExternalPlanId("external_plan_id") - .externalPlanId("external_plan_id") - .metadata( - PlanExternalPlanIdUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .editPlanModel( + EditPlanModel.builder() + .externalPlanId("external_plan_id") + .metadata( + EditPlanModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .build() ) .build() @@ -27,22 +30,29 @@ class PlanExternalPlanIdUpdateParamsTest { val params = PlanExternalPlanIdUpdateParams.builder() .otherExternalPlanId("external_plan_id") - .externalPlanId("external_plan_id") - .metadata( - PlanExternalPlanIdUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .editPlanModel( + EditPlanModel.builder() + .externalPlanId("external_plan_id") + .metadata( + EditPlanModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .build() ) .build() val body = params._body() - assertNotNull(body) - assertThat(body.externalPlanId()).contains("external_plan_id") - assertThat(body.metadata()) - .contains( - PlanExternalPlanIdUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + assertThat(body) + .isEqualTo( + EditPlanModel.builder() + .externalPlanId("external_plan_id") + .metadata( + EditPlanModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .build() ) } @@ -50,17 +60,23 @@ class PlanExternalPlanIdUpdateParamsTest { @Test fun bodyWithoutOptionalFields() { val params = - PlanExternalPlanIdUpdateParams.builder().otherExternalPlanId("external_plan_id").build() + PlanExternalPlanIdUpdateParams.builder() + .otherExternalPlanId("external_plan_id") + .editPlanModel(EditPlanModel.builder().build()) + .build() val body = params._body() - assertNotNull(body) + assertThat(body).isEqualTo(EditPlanModel.builder().build()) } @Test fun getPathParam() { val params = - PlanExternalPlanIdUpdateParams.builder().otherExternalPlanId("external_plan_id").build() + PlanExternalPlanIdUpdateParams.builder() + .otherExternalPlanId("external_plan_id") + .editPlanModel(EditPlanModel.builder().build()) + .build() assertThat(params).isNotNull // path param "otherExternalPlanId" assertThat(params.getPathParam(0)).isEqualTo("external_plan_id") diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanMinifiedModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanMinifiedModelTest.kt new file mode 100644 index 000000000..40c2ecb75 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanMinifiedModelTest.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 + +class PlanMinifiedModelTest { + + @Test + fun createPlanMinifiedModel() { + val planMinifiedModel = + PlanMinifiedModel.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + assertThat(planMinifiedModel).isNotNull + assertThat(planMinifiedModel.id()).contains("m2t5akQeh2obwxeU") + assertThat(planMinifiedModel.externalPlanId()).contains("m2t5akQeh2obwxeU") + assertThat(planMinifiedModel.name()).contains("Example plan") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanModelTest.kt new file mode 100644 index 000000000..137a403e8 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanModelTest.kt @@ -0,0 +1,390 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.JsonValue +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class PlanModelTest { + + @Test + fun createPlanModel() { + val planModel = + PlanModel.builder() + .id("id") + .addAdjustment( + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.builder() + .id("id") + .adjustmentType( + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .basePlan( + PlanMinifiedModel.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .defaultInvoiceMemo("default_invoice_memo") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + MaximumModel.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + PlanModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + MinimumModel.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(0L) + .addPlanPhase( + PlanModel.PlanPhase.builder() + .id("id") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .duration(0L) + .durationUnit(PlanModel.PlanPhase.DurationUnit.DAILY) + .maximum( + MaximumModel.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + MinimumModel.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(0L) + .build() + ) + .addPrice( + PriceModel.UnitPrice.builder() + .id("id") + .billableMetric(BillableMetricTinyModel.builder().id("id").build()) + .billingCycleConfiguration( + BillingCycleConfigurationModel.builder() + .duration(0L) + .durationUnit(BillingCycleConfigurationModel.DurationUnit.DAY) + .build() + ) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + AllocationModel.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + BillingCycleConfigurationModel.builder() + .duration(0L) + .durationUnit(BillingCycleConfigurationModel.DurationUnit.DAY) + .build() + ) + .item(ItemSlimModel.builder().id("id").name("name").build()) + .maximum( + MaximumModel.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + PriceModel.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + MinimumModel.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(PriceModel.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) + .dimensionalPriceConfiguration( + DimensionalPriceConfigurationModel.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .product( + PlanModel.Product.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .build() + ) + .status(PlanModel.Status.ACTIVE) + .trialConfig( + PlanModel.TrialConfig.builder() + .trialPeriod(0L) + .trialPeriodUnit(PlanModel.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(0L) + .build() + assertThat(planModel).isNotNull + assertThat(planModel.id()).isEqualTo("id") + assertThat(planModel.adjustments()) + .containsExactly( + AdjustmentModel.ofPlanPhaseUsageDiscountAdjustment( + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.builder() + .id("id") + .adjustmentType( + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + ) + assertThat(planModel.basePlan()) + .contains( + PlanMinifiedModel.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + assertThat(planModel.basePlanId()).contains("base_plan_id") + assertThat(planModel.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(planModel.currency()).isEqualTo("currency") + assertThat(planModel.defaultInvoiceMemo()).contains("default_invoice_memo") + assertThat(planModel.description()).isEqualTo("description") + assertThat(planModel.discount()) + .contains( + Discount.ofPercentage( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + ) + assertThat(planModel.externalPlanId()).contains("external_plan_id") + assertThat(planModel.invoicingCurrency()).isEqualTo("invoicing_currency") + assertThat(planModel.maximum()) + .contains( + MaximumModel.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + assertThat(planModel.maximumAmount()).contains("maximum_amount") + assertThat(planModel.metadata()) + .isEqualTo( + PlanModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(planModel.minimum()) + .contains( + MinimumModel.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + assertThat(planModel.minimumAmount()).contains("minimum_amount") + assertThat(planModel.name()).isEqualTo("name") + assertThat(planModel.netTerms()).contains(0L) + assertThat(planModel.planPhases().get()) + .containsExactly( + PlanModel.PlanPhase.builder() + .id("id") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .duration(0L) + .durationUnit(PlanModel.PlanPhase.DurationUnit.DAILY) + .maximum( + MaximumModel.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + MinimumModel.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(0L) + .build() + ) + assertThat(planModel.prices()) + .containsExactly( + PriceModel.ofUnitPrice( + PriceModel.UnitPrice.builder() + .id("id") + .billableMetric(BillableMetricTinyModel.builder().id("id").build()) + .billingCycleConfiguration( + BillingCycleConfigurationModel.builder() + .duration(0L) + .durationUnit(BillingCycleConfigurationModel.DurationUnit.DAY) + .build() + ) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + AllocationModel.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + BillingCycleConfigurationModel.builder() + .duration(0L) + .durationUnit(BillingCycleConfigurationModel.DurationUnit.DAY) + .build() + ) + .item(ItemSlimModel.builder().id("id").name("name").build()) + .maximum( + MaximumModel.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + PriceModel.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + MinimumModel.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(PriceModel.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) + .dimensionalPriceConfiguration( + DimensionalPriceConfigurationModel.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + ) + assertThat(planModel.product()) + .isEqualTo( + PlanModel.Product.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .build() + ) + assertThat(planModel.status()).isEqualTo(PlanModel.Status.ACTIVE) + assertThat(planModel.trialConfig()) + .isEqualTo( + PlanModel.TrialConfig.builder() + .trialPeriod(0L) + .trialPeriodUnit(PlanModel.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + assertThat(planModel.version()).isEqualTo(0L) + } +} 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 6b3ff4b00..86718ac3c 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 @@ -15,10 +15,10 @@ class PlanTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.builder() .id("id") .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.AdjustmentType .USAGE_DISCOUNT ) .addAppliesToPriceId("string") @@ -29,7 +29,7 @@ class PlanTest { .build() ) .basePlan( - Plan.BasePlan.builder() + PlanMinifiedModel.builder() .id("m2t5akQeh2obwxeU") .externalPlanId("m2t5akQeh2obwxeU") .name("Example plan") @@ -52,7 +52,7 @@ class PlanTest { .externalPlanId("external_plan_id") .invoicingCurrency("invoicing_currency") .maximum( - Plan.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() @@ -64,7 +64,7 @@ class PlanTest { .build() ) .minimum( - Plan.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() @@ -88,14 +88,14 @@ class PlanTest { .duration(0L) .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) .maximum( - Plan.PlanPhase.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .minimum( - Plan.PlanPhase.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() @@ -106,22 +106,20 @@ class PlanTest { .build() ) .addPrice( - Price.UnitPrice.builder() + PriceModel.UnitPrice.builder() .id("id") - .billableMetric(Price.UnitPrice.BillableMetric.builder().id("id").build()) + .billableMetric(BillableMetricTinyModel.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(BillingCycleConfigurationModel.DurationUnit.DAY) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + AllocationModel.builder() .allowsRollover(true) .currency("currency") .build() @@ -139,42 +137,38 @@ class PlanTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(BillingCycleConfigurationModel.DurationUnit.DAY) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(ItemSlimModel.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + PriceModel.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) + .modelType(PriceModel.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder().unitAmount("unit_amount").build() - ) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + DimensionalPriceConfigurationModel.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -201,11 +195,11 @@ class PlanTest { assertThat(plan.id()).isEqualTo("id") assertThat(plan.adjustments()) .containsExactly( - Plan.Adjustment.ofPlanPhaseUsageDiscount( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + AdjustmentModel.ofPlanPhaseUsageDiscountAdjustment( + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.builder() .id("id") .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.AdjustmentType .USAGE_DISCOUNT ) .addAppliesToPriceId("string") @@ -218,7 +212,7 @@ class PlanTest { ) assertThat(plan.basePlan()) .contains( - Plan.BasePlan.builder() + PlanMinifiedModel.builder() .id("m2t5akQeh2obwxeU") .externalPlanId("m2t5akQeh2obwxeU") .name("Example plan") @@ -245,7 +239,7 @@ class PlanTest { assertThat(plan.invoicingCurrency()).isEqualTo("invoicing_currency") assertThat(plan.maximum()) .contains( - Plan.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() @@ -259,7 +253,7 @@ class PlanTest { ) assertThat(plan.minimum()) .contains( - Plan.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() @@ -284,14 +278,14 @@ class PlanTest { .duration(0L) .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) .maximum( - Plan.PlanPhase.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .minimum( - Plan.PlanPhase.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() @@ -303,23 +297,21 @@ class PlanTest { ) assertThat(plan.prices()) .containsExactly( - Price.ofUnit( - Price.UnitPrice.builder() + PriceModel.ofUnitPrice( + PriceModel.UnitPrice.builder() .id("id") - .billableMetric(Price.UnitPrice.BillableMetric.builder().id("id").build()) + .billableMetric(BillableMetricTinyModel.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(BillingCycleConfigurationModel.DurationUnit.DAY) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + AllocationModel.builder() .allowsRollover(true) .currency("currency") .build() @@ -337,42 +329,38 @@ class PlanTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(BillingCycleConfigurationModel.DurationUnit.DAY) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(ItemSlimModel.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + PriceModel.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) + .modelType(PriceModel.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder().unitAmount("unit_amount").build() - ) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + DimensionalPriceConfigurationModel.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() 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 c1358e18a..2c83b3427 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 @@ -3,7 +3,6 @@ package com.withorb.api.models import com.withorb.api.core.JsonValue -import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -13,10 +12,14 @@ class PlanUpdateParamsTest { fun create() { PlanUpdateParams.builder() .planId("plan_id") - .externalPlanId("external_plan_id") - .metadata( - PlanUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .editPlanModel( + EditPlanModel.builder() + .externalPlanId("external_plan_id") + .metadata( + EditPlanModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .build() ) .build() @@ -27,38 +30,53 @@ class PlanUpdateParamsTest { val params = PlanUpdateParams.builder() .planId("plan_id") - .externalPlanId("external_plan_id") - .metadata( - PlanUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .editPlanModel( + EditPlanModel.builder() + .externalPlanId("external_plan_id") + .metadata( + EditPlanModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .build() ) .build() val body = params._body() - assertNotNull(body) - assertThat(body.externalPlanId()).contains("external_plan_id") - assertThat(body.metadata()) - .contains( - PlanUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + assertThat(body) + .isEqualTo( + EditPlanModel.builder() + .externalPlanId("external_plan_id") + .metadata( + EditPlanModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .build() ) } @Test fun bodyWithoutOptionalFields() { - val params = PlanUpdateParams.builder().planId("plan_id").build() + val params = + PlanUpdateParams.builder() + .planId("plan_id") + .editPlanModel(EditPlanModel.builder().build()) + .build() val body = params._body() - assertNotNull(body) + assertThat(body).isEqualTo(EditPlanModel.builder().build()) } @Test fun getPathParam() { - val params = PlanUpdateParams.builder().planId("plan_id").build() + val params = + PlanUpdateParams.builder() + .planId("plan_id") + .editPlanModel(EditPlanModel.builder().build()) + .build() assertThat(params).isNotNull // path param "planId" assertThat(params.getPathParam(0)).isEqualTo("plan_id") 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 90447ac0b..c1acb4280 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 @@ -11,30 +11,20 @@ class PriceCreateParamsTest { @Test fun create() { PriceCreateParams.builder() - .body( - PriceCreateParams.Body.NewFloatingUnitPrice.builder() - .cadence(PriceCreateParams.Body.NewFloatingUnitPrice.Cadence.ANNUAL) + .newFloatingPriceModel( + NewFloatingPriceModel.NewFloatingUnitPrice.builder() + .cadence(NewFloatingPriceModel.NewFloatingUnitPrice.Cadence.ANNUAL) .currency("currency") .itemId("item_id") - .modelType(PriceCreateParams.Body.NewFloatingUnitPrice.ModelType.UNIT) + .modelType(NewFloatingPriceModel.NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - PriceCreateParams.Body.NewFloatingUnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - PriceCreateParams.Body.NewFloatingUnitPrice.BillingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) - .durationUnit( - PriceCreateParams.Body.NewFloatingUnitPrice - .BillingCycleConfiguration - .DurationUnit - .DAY - ) + .durationUnit(NewBillingCycleConfigurationModel.DurationUnit.DAY) .build() ) .conversionRate(0.0) @@ -42,19 +32,13 @@ class PriceCreateParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - PriceCreateParams.Body.NewFloatingUnitPrice.InvoicingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) - .durationUnit( - PriceCreateParams.Body.NewFloatingUnitPrice - .InvoicingCycleConfiguration - .DurationUnit - .DAY - ) + .durationUnit(NewBillingCycleConfigurationModel.DurationUnit.DAY) .build() ) .metadata( - PriceCreateParams.Body.NewFloatingUnitPrice.Metadata.builder() + NewFloatingPriceModel.NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -67,30 +51,20 @@ class PriceCreateParamsTest { fun body() { val params = PriceCreateParams.builder() - .body( - PriceCreateParams.Body.NewFloatingUnitPrice.builder() - .cadence(PriceCreateParams.Body.NewFloatingUnitPrice.Cadence.ANNUAL) + .newFloatingPriceModel( + NewFloatingPriceModel.NewFloatingUnitPrice.builder() + .cadence(NewFloatingPriceModel.NewFloatingUnitPrice.Cadence.ANNUAL) .currency("currency") .itemId("item_id") - .modelType(PriceCreateParams.Body.NewFloatingUnitPrice.ModelType.UNIT) + .modelType(NewFloatingPriceModel.NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - PriceCreateParams.Body.NewFloatingUnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - PriceCreateParams.Body.NewFloatingUnitPrice.BillingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) - .durationUnit( - PriceCreateParams.Body.NewFloatingUnitPrice - .BillingCycleConfiguration - .DurationUnit - .DAY - ) + .durationUnit(NewBillingCycleConfigurationModel.DurationUnit.DAY) .build() ) .conversionRate(0.0) @@ -98,19 +72,13 @@ class PriceCreateParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - PriceCreateParams.Body.NewFloatingUnitPrice.InvoicingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) - .durationUnit( - PriceCreateParams.Body.NewFloatingUnitPrice - .InvoicingCycleConfiguration - .DurationUnit - .DAY - ) + .durationUnit(NewBillingCycleConfigurationModel.DurationUnit.DAY) .build() ) .metadata( - PriceCreateParams.Body.NewFloatingUnitPrice.Metadata.builder() + NewFloatingPriceModel.NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -122,30 +90,20 @@ class PriceCreateParamsTest { assertThat(body) .isEqualTo( - PriceCreateParams.Body.ofNewFloatingUnitPrice( - PriceCreateParams.Body.NewFloatingUnitPrice.builder() - .cadence(PriceCreateParams.Body.NewFloatingUnitPrice.Cadence.ANNUAL) + NewFloatingPriceModel.ofUnitPrice( + NewFloatingPriceModel.NewFloatingUnitPrice.builder() + .cadence(NewFloatingPriceModel.NewFloatingUnitPrice.Cadence.ANNUAL) .currency("currency") .itemId("item_id") - .modelType(PriceCreateParams.Body.NewFloatingUnitPrice.ModelType.UNIT) + .modelType(NewFloatingPriceModel.NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - PriceCreateParams.Body.NewFloatingUnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - PriceCreateParams.Body.NewFloatingUnitPrice.BillingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) - .durationUnit( - PriceCreateParams.Body.NewFloatingUnitPrice - .BillingCycleConfiguration - .DurationUnit - .DAY - ) + .durationUnit(NewBillingCycleConfigurationModel.DurationUnit.DAY) .build() ) .conversionRate(0.0) @@ -153,19 +111,13 @@ class PriceCreateParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - PriceCreateParams.Body.NewFloatingUnitPrice.InvoicingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) - .durationUnit( - PriceCreateParams.Body.NewFloatingUnitPrice - .InvoicingCycleConfiguration - .DurationUnit - .DAY - ) + .durationUnit(NewBillingCycleConfigurationModel.DurationUnit.DAY) .build() ) .metadata( - PriceCreateParams.Body.NewFloatingUnitPrice.Metadata.builder() + NewFloatingPriceModel.NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -178,18 +130,14 @@ class PriceCreateParamsTest { fun bodyWithoutOptionalFields() { val params = PriceCreateParams.builder() - .body( - PriceCreateParams.Body.NewFloatingUnitPrice.builder() - .cadence(PriceCreateParams.Body.NewFloatingUnitPrice.Cadence.ANNUAL) + .newFloatingPriceModel( + NewFloatingPriceModel.NewFloatingUnitPrice.builder() + .cadence(NewFloatingPriceModel.NewFloatingUnitPrice.Cadence.ANNUAL) .currency("currency") .itemId("item_id") - .modelType(PriceCreateParams.Body.NewFloatingUnitPrice.ModelType.UNIT) + .modelType(NewFloatingPriceModel.NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - PriceCreateParams.Body.NewFloatingUnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) .build() ) .build() @@ -198,18 +146,14 @@ class PriceCreateParamsTest { assertThat(body) .isEqualTo( - PriceCreateParams.Body.ofNewFloatingUnitPrice( - PriceCreateParams.Body.NewFloatingUnitPrice.builder() - .cadence(PriceCreateParams.Body.NewFloatingUnitPrice.Cadence.ANNUAL) + NewFloatingPriceModel.ofUnitPrice( + NewFloatingPriceModel.NewFloatingUnitPrice.builder() + .cadence(NewFloatingPriceModel.NewFloatingUnitPrice.Cadence.ANNUAL) .currency("currency") .itemId("item_id") - .modelType(PriceCreateParams.Body.NewFloatingUnitPrice.ModelType.UNIT) + .modelType(NewFloatingPriceModel.NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - PriceCreateParams.Body.NewFloatingUnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) .build() ) ) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceExternalPriceIdUpdateParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceExternalPriceIdUpdateParamsTest.kt index 47f3734e9..d57739260 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceExternalPriceIdUpdateParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceExternalPriceIdUpdateParamsTest.kt @@ -3,7 +3,6 @@ package com.withorb.api.models import com.withorb.api.core.JsonValue -import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -13,9 +12,13 @@ class PriceExternalPriceIdUpdateParamsTest { fun create() { PriceExternalPriceIdUpdateParams.builder() .externalPriceId("external_price_id") - .metadata( - PriceExternalPriceIdUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .updatePriceRequestParams( + UpdatePriceRequestParams.builder() + .metadata( + UpdatePriceRequestParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .build() ) .build() @@ -26,20 +29,27 @@ class PriceExternalPriceIdUpdateParamsTest { val params = PriceExternalPriceIdUpdateParams.builder() .externalPriceId("external_price_id") - .metadata( - PriceExternalPriceIdUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .updatePriceRequestParams( + UpdatePriceRequestParams.builder() + .metadata( + UpdatePriceRequestParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .build() ) .build() val body = params._body() - assertNotNull(body) - assertThat(body.metadata()) - .contains( - PriceExternalPriceIdUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + assertThat(body) + .isEqualTo( + UpdatePriceRequestParams.builder() + .metadata( + UpdatePriceRequestParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .build() ) } @@ -47,17 +57,23 @@ class PriceExternalPriceIdUpdateParamsTest { @Test fun bodyWithoutOptionalFields() { val params = - PriceExternalPriceIdUpdateParams.builder().externalPriceId("external_price_id").build() + PriceExternalPriceIdUpdateParams.builder() + .externalPriceId("external_price_id") + .updatePriceRequestParams(UpdatePriceRequestParams.builder().build()) + .build() val body = params._body() - assertNotNull(body) + assertThat(body).isEqualTo(UpdatePriceRequestParams.builder().build()) } @Test fun getPathParam() { val params = - PriceExternalPriceIdUpdateParams.builder().externalPriceId("external_price_id").build() + PriceExternalPriceIdUpdateParams.builder() + .externalPriceId("external_price_id") + .updatePriceRequestParams(UpdatePriceRequestParams.builder().build()) + .build() assertThat(params).isNotNull // path param "externalPriceId" assertThat(params.getPathParam(0)).isEqualTo("external_price_id") diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceIntervalFixedFeeQuantityTransitionModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceIntervalFixedFeeQuantityTransitionModelTest.kt new file mode 100644 index 000000000..4c2163904 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceIntervalFixedFeeQuantityTransitionModelTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class PriceIntervalFixedFeeQuantityTransitionModelTest { + + @Test + fun createPriceIntervalFixedFeeQuantityTransitionModel() { + val priceIntervalFixedFeeQuantityTransitionModel = + PriceIntervalFixedFeeQuantityTransitionModel.builder() + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .quantity(5L) + .build() + assertThat(priceIntervalFixedFeeQuantityTransitionModel).isNotNull + assertThat(priceIntervalFixedFeeQuantityTransitionModel.effectiveDate()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(priceIntervalFixedFeeQuantityTransitionModel.quantity()).isEqualTo(5L) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceIntervalModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceIntervalModelTest.kt new file mode 100644 index 000000000..217260737 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceIntervalModelTest.kt @@ -0,0 +1,197 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.JsonValue +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class PriceIntervalModelTest { + + @Test + fun createPriceIntervalModel() { + val priceIntervalModel = + PriceIntervalModel.builder() + .id("id") + .billingCycleDay(0L) + .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addFixedFeeQuantityTransition( + PriceIntervalModel.FixedFeeQuantityTransition.builder() + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0L) + .build() + ) + .price( + PriceModel.UnitPrice.builder() + .id("id") + .billableMetric(BillableMetricTinyModel.builder().id("id").build()) + .billingCycleConfiguration( + BillingCycleConfigurationModel.builder() + .duration(0L) + .durationUnit(BillingCycleConfigurationModel.DurationUnit.DAY) + .build() + ) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + AllocationModel.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + BillingCycleConfigurationModel.builder() + .duration(0L) + .durationUnit(BillingCycleConfigurationModel.DurationUnit.DAY) + .build() + ) + .item(ItemSlimModel.builder().id("id").name("name").build()) + .maximum( + MaximumModel.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + PriceModel.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + MinimumModel.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(PriceModel.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) + .dimensionalPriceConfiguration( + DimensionalPriceConfigurationModel.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addUsageCustomerId("string") + .build() + assertThat(priceIntervalModel).isNotNull + assertThat(priceIntervalModel.id()).isEqualTo("id") + assertThat(priceIntervalModel.billingCycleDay()).isEqualTo(0L) + assertThat(priceIntervalModel.currentBillingPeriodEndDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(priceIntervalModel.currentBillingPeriodStartDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(priceIntervalModel.endDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(priceIntervalModel.filter()).contains("filter") + assertThat(priceIntervalModel.fixedFeeQuantityTransitions().get()) + .containsExactly( + PriceIntervalModel.FixedFeeQuantityTransition.builder() + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0L) + .build() + ) + assertThat(priceIntervalModel.price()) + .isEqualTo( + PriceModel.ofUnitPrice( + PriceModel.UnitPrice.builder() + .id("id") + .billableMetric(BillableMetricTinyModel.builder().id("id").build()) + .billingCycleConfiguration( + BillingCycleConfigurationModel.builder() + .duration(0L) + .durationUnit(BillingCycleConfigurationModel.DurationUnit.DAY) + .build() + ) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + AllocationModel.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + BillingCycleConfigurationModel.builder() + .duration(0L) + .durationUnit(BillingCycleConfigurationModel.DurationUnit.DAY) + .build() + ) + .item(ItemSlimModel.builder().id("id").name("name").build()) + .maximum( + MaximumModel.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + PriceModel.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + MinimumModel.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(PriceModel.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) + .dimensionalPriceConfiguration( + DimensionalPriceConfigurationModel.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + ) + assertThat(priceIntervalModel.startDate()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(priceIntervalModel.usageCustomerIds().get()).containsExactly("string") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceUpdateParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceUpdateParamsTest.kt index 37f35fa6a..a6dfb60df 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceUpdateParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceUpdateParamsTest.kt @@ -3,7 +3,6 @@ package com.withorb.api.models import com.withorb.api.core.JsonValue -import kotlin.test.assertNotNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -13,9 +12,13 @@ class PriceUpdateParamsTest { fun create() { PriceUpdateParams.builder() .priceId("price_id") - .metadata( - PriceUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .updatePriceRequestParams( + UpdatePriceRequestParams.builder() + .metadata( + UpdatePriceRequestParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .build() ) .build() @@ -26,36 +29,51 @@ class PriceUpdateParamsTest { val params = PriceUpdateParams.builder() .priceId("price_id") - .metadata( - PriceUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .updatePriceRequestParams( + UpdatePriceRequestParams.builder() + .metadata( + UpdatePriceRequestParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .build() ) .build() val body = params._body() - assertNotNull(body) - assertThat(body.metadata()) - .contains( - PriceUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + assertThat(body) + .isEqualTo( + UpdatePriceRequestParams.builder() + .metadata( + UpdatePriceRequestParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .build() ) } @Test fun bodyWithoutOptionalFields() { - val params = PriceUpdateParams.builder().priceId("price_id").build() + val params = + PriceUpdateParams.builder() + .priceId("price_id") + .updatePriceRequestParams(UpdatePriceRequestParams.builder().build()) + .build() val body = params._body() - assertNotNull(body) + assertThat(body).isEqualTo(UpdatePriceRequestParams.builder().build()) } @Test fun getPathParam() { - val params = PriceUpdateParams.builder().priceId("price_id").build() + val params = + PriceUpdateParams.builder() + .priceId("price_id") + .updatePriceRequestParams(UpdatePriceRequestParams.builder().build()) + .build() assertThat(params).isNotNull // path param "priceId" assertThat(params.getPathParam(0)).isEqualTo("price_id") diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/RemoveSubscriptionAdjustmentParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/RemoveSubscriptionAdjustmentParamsTest.kt new file mode 100644 index 000000000..ab0b4fa44 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/RemoveSubscriptionAdjustmentParamsTest.kt @@ -0,0 +1,17 @@ +// 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 + +class RemoveSubscriptionAdjustmentParamsTest { + + @Test + fun createRemoveSubscriptionAdjustmentParams() { + val removeSubscriptionAdjustmentParams = + RemoveSubscriptionAdjustmentParams.builder().adjustmentId("h74gfhdjvn7ujokd").build() + assertThat(removeSubscriptionAdjustmentParams).isNotNull + assertThat(removeSubscriptionAdjustmentParams.adjustmentId()).isEqualTo("h74gfhdjvn7ujokd") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/RemoveSubscriptionPriceParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/RemoveSubscriptionPriceParamsTest.kt new file mode 100644 index 000000000..8182195ca --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/RemoveSubscriptionPriceParamsTest.kt @@ -0,0 +1,21 @@ +// 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 + +class RemoveSubscriptionPriceParamsTest { + + @Test + fun createRemoveSubscriptionPriceParams() { + val removeSubscriptionPriceParams = + RemoveSubscriptionPriceParams.builder() + .externalPriceId("external_price_id") + .priceId("h74gfhdjvn7ujokd") + .build() + assertThat(removeSubscriptionPriceParams).isNotNull + assertThat(removeSubscriptionPriceParams.externalPriceId()).contains("external_price_id") + assertThat(removeSubscriptionPriceParams.priceId()).contains("h74gfhdjvn7ujokd") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/ReplaceSubscriptionAdjustmentParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/ReplaceSubscriptionAdjustmentParamsTest.kt new file mode 100644 index 000000000..3b22591a7 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/ReplaceSubscriptionAdjustmentParamsTest.kt @@ -0,0 +1,47 @@ +// 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 + +class ReplaceSubscriptionAdjustmentParamsTest { + + @Test + fun createReplaceSubscriptionAdjustmentParams() { + val replaceSubscriptionAdjustmentParams = + ReplaceSubscriptionAdjustmentParams.builder() + .adjustment( + NewAdjustmentModel.NewPercentageDiscount.builder() + .adjustmentType( + NewAdjustmentModel.NewPercentageDiscount.AdjustmentType + .PERCENTAGE_DISCOUNT + ) + .addAppliesToPriceId("price_1") + .addAppliesToPriceId("price_2") + .percentageDiscount(0.0) + .isInvoiceLevel(true) + .build() + ) + .replacesAdjustmentId("replaces_adjustment_id") + .build() + assertThat(replaceSubscriptionAdjustmentParams).isNotNull + assertThat(replaceSubscriptionAdjustmentParams.adjustment()) + .isEqualTo( + NewAdjustmentModel.ofPercentageDiscount( + NewAdjustmentModel.NewPercentageDiscount.builder() + .adjustmentType( + NewAdjustmentModel.NewPercentageDiscount.AdjustmentType + .PERCENTAGE_DISCOUNT + ) + .addAppliesToPriceId("price_1") + .addAppliesToPriceId("price_2") + .percentageDiscount(0.0) + .isInvoiceLevel(true) + .build() + ) + ) + assertThat(replaceSubscriptionAdjustmentParams.replacesAdjustmentId()) + .isEqualTo("replaces_adjustment_id") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/ReplaceSubscriptionPriceParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/ReplaceSubscriptionPriceParamsTest.kt new file mode 100644 index 000000000..77bcdf52c --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/ReplaceSubscriptionPriceParamsTest.kt @@ -0,0 +1,139 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ReplaceSubscriptionPriceParamsTest { + + @Test + fun createReplaceSubscriptionPriceParams() { + val replaceSubscriptionPriceParams = + ReplaceSubscriptionPriceParams.builder() + .replacesPriceId("replaces_price_id") + .allocationPrice( + NewAllocationPriceModel.builder() + .amount("10.00") + .cadence(NewAllocationPriceModel.Cadence.ONE_TIME) + .currency("USD") + .expiresAtEndOfCadence(true) + .build() + ) + .addDiscount( + DiscountOverrideModel.builder() + .discountType(DiscountOverrideModel.DiscountType.PERCENTAGE) + .amountDiscount("amount_discount") + .percentageDiscount(0.15) + .usageDiscount(0.0) + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(2.0) + .maximumAmount("1.23") + .minimumAmount("1.23") + .price( + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.builder() + .cadence(NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Cadence.ANNUAL) + .itemId("item_id") + .modelType( + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.ModelType.UNIT + ) + .name("Annual fee") + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfigurationModel.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfigurationModel.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .currency("currency") + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") + .invoicingCycleConfiguration( + NewBillingCycleConfigurationModel.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfigurationModel.DurationUnit.DAY) + .build() + ) + .metadata( + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) + .priceId("h74gfhdjvn7ujokd") + .build() + assertThat(replaceSubscriptionPriceParams).isNotNull + assertThat(replaceSubscriptionPriceParams.replacesPriceId()).isEqualTo("replaces_price_id") + assertThat(replaceSubscriptionPriceParams.allocationPrice()) + .contains( + NewAllocationPriceModel.builder() + .amount("10.00") + .cadence(NewAllocationPriceModel.Cadence.ONE_TIME) + .currency("USD") + .expiresAtEndOfCadence(true) + .build() + ) + assertThat(replaceSubscriptionPriceParams.discounts().get()) + .containsExactly( + DiscountOverrideModel.builder() + .discountType(DiscountOverrideModel.DiscountType.PERCENTAGE) + .amountDiscount("amount_discount") + .percentageDiscount(0.15) + .usageDiscount(0.0) + .build() + ) + assertThat(replaceSubscriptionPriceParams.externalPriceId()).contains("external_price_id") + assertThat(replaceSubscriptionPriceParams.fixedPriceQuantity()).contains(2.0) + assertThat(replaceSubscriptionPriceParams.maximumAmount()).contains("1.23") + assertThat(replaceSubscriptionPriceParams.minimumAmount()).contains("1.23") + assertThat(replaceSubscriptionPriceParams.price()) + .contains( + NewSubscriptionPriceModel.ofUnitPrice( + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.builder() + .cadence(NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Cadence.ANNUAL) + .itemId("item_id") + .modelType( + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.ModelType.UNIT + ) + .name("Annual fee") + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) + .billableMetricId("billable_metric_id") + .billedInAdvance(true) + .billingCycleConfiguration( + NewBillingCycleConfigurationModel.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfigurationModel.DurationUnit.DAY) + .build() + ) + .conversionRate(0.0) + .currency("currency") + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoiceGroupingKey("invoice_grouping_key") + .invoicingCycleConfiguration( + NewBillingCycleConfigurationModel.builder() + .duration(0L) + .durationUnit(NewBillingCycleConfigurationModel.DurationUnit.DAY) + .build() + ) + .metadata( + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .referenceId("reference_id") + .build() + ) + ) + assertThat(replaceSubscriptionPriceParams.priceId()).contains("h74gfhdjvn7ujokd") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubLineItemGroupingModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubLineItemGroupingModelTest.kt new file mode 100644 index 000000000..3d32040c7 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubLineItemGroupingModelTest.kt @@ -0,0 +1,18 @@ +// 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 + +class SubLineItemGroupingModelTest { + + @Test + fun createSubLineItemGroupingModel() { + val subLineItemGroupingModel = + SubLineItemGroupingModel.builder().key("region").value("west").build() + assertThat(subLineItemGroupingModel).isNotNull + assertThat(subLineItemGroupingModel.key()).isEqualTo("region") + assertThat(subLineItemGroupingModel.value()).contains("west") + } +} 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 440779bad..44d7a10b6 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 @@ -14,14 +14,11 @@ class SubscriptionCreateParamsTest { fun create() { SubscriptionCreateParams.builder() .addAddAdjustment( - SubscriptionCreateParams.AddAdjustment.builder() + AddSubscriptionAdjustmentParams.builder() .adjustment( - SubscriptionCreateParams.AddAdjustment.Adjustment.NewPercentageDiscount - .builder() + NewAdjustmentModel.NewPercentageDiscount.builder() .adjustmentType( - SubscriptionCreateParams.AddAdjustment.Adjustment - .NewPercentageDiscount - .AdjustmentType + NewAdjustmentModel.NewPercentageDiscount.AdjustmentType .PERCENTAGE_DISCOUNT ) .addAppliesToPriceId("price_1") @@ -36,22 +33,18 @@ class SubscriptionCreateParamsTest { .build() ) .addAddPrice( - SubscriptionCreateParams.AddPrice.builder() + AddSubscriptionPriceParams.builder() .allocationPrice( - SubscriptionCreateParams.AddPrice.AllocationPrice.builder() + NewAllocationPriceModel.builder() .amount("10.00") - .cadence( - SubscriptionCreateParams.AddPrice.AllocationPrice.Cadence.ONE_TIME - ) + .cadence(NewAllocationPriceModel.Cadence.ONE_TIME) .currency("USD") .expiresAtEndOfCadence(true) .build() ) .addDiscount( - SubscriptionCreateParams.AddPrice.Discount.builder() - .discountType( - SubscriptionCreateParams.AddPrice.Discount.DiscountType.PERCENTAGE - ) + DiscountOverrideModel.builder() + .discountType(DiscountOverrideModel.DiscountType.PERCENTAGE) .amountDiscount("amount_discount") .percentageDiscount(0.15) .usageDiscount(0.0) @@ -63,39 +56,23 @@ class SubscriptionCreateParamsTest { .minimumAmount("1.23") .planPhaseOrder(0L) .price( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice.builder() + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.builder() .cadence( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice - .Cadence - .ANNUAL + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Cadence.ANNUAL ) .itemId("item_id") .modelType( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice - .ModelType - .UNIT + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.ModelType.UNIT ) .name("Annual fee") - .unitConfig( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice - .UnitConfig - .builder() - .unitAmount("unit_amount") - .build() - ) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice - .BillingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice - .BillingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) @@ -105,22 +82,15 @@ class SubscriptionCreateParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) .metadata( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice - .Metadata + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -136,11 +106,7 @@ class SubscriptionCreateParamsTest { .autoCollection(true) .awsRegion("aws_region") .billingCycleAnchorConfiguration( - SubscriptionCreateParams.BillingCycleAnchorConfiguration.builder() - .day(1L) - .month(1L) - .year(0L) - .build() + BillingCycleAnchorConfigurationModel.builder().day(1L).month(1L).year(0L).build() ) .couponRedemptionCode("coupon_redemption_code") .creditsOverageRate(0.0) @@ -165,25 +131,22 @@ class SubscriptionCreateParamsTest { .planVersionNumber(0L) .addPriceOverride(JsonValue.from(mapOf())) .addRemoveAdjustment( - SubscriptionCreateParams.RemoveAdjustment.builder() + RemoveSubscriptionAdjustmentParams.builder() .adjustmentId("h74gfhdjvn7ujokd") .build() ) .addRemovePrice( - SubscriptionCreateParams.RemovePrice.builder() + RemoveSubscriptionPriceParams.builder() .externalPriceId("external_price_id") .priceId("h74gfhdjvn7ujokd") .build() ) .addReplaceAdjustment( - SubscriptionCreateParams.ReplaceAdjustment.builder() + ReplaceSubscriptionAdjustmentParams.builder() .adjustment( - SubscriptionCreateParams.ReplaceAdjustment.Adjustment.NewPercentageDiscount - .builder() + NewAdjustmentModel.NewPercentageDiscount.builder() .adjustmentType( - SubscriptionCreateParams.ReplaceAdjustment.Adjustment - .NewPercentageDiscount - .AdjustmentType + NewAdjustmentModel.NewPercentageDiscount.AdjustmentType .PERCENTAGE_DISCOUNT ) .addAppliesToPriceId("price_1") @@ -196,25 +159,19 @@ class SubscriptionCreateParamsTest { .build() ) .addReplacePrice( - SubscriptionCreateParams.ReplacePrice.builder() + ReplaceSubscriptionPriceParams.builder() .replacesPriceId("replaces_price_id") .allocationPrice( - SubscriptionCreateParams.ReplacePrice.AllocationPrice.builder() + NewAllocationPriceModel.builder() .amount("10.00") - .cadence( - SubscriptionCreateParams.ReplacePrice.AllocationPrice.Cadence - .ONE_TIME - ) + .cadence(NewAllocationPriceModel.Cadence.ONE_TIME) .currency("USD") .expiresAtEndOfCadence(true) .build() ) .addDiscount( - SubscriptionCreateParams.ReplacePrice.Discount.builder() - .discountType( - SubscriptionCreateParams.ReplacePrice.Discount.DiscountType - .PERCENTAGE - ) + DiscountOverrideModel.builder() + .discountType(DiscountOverrideModel.DiscountType.PERCENTAGE) .amountDiscount("amount_discount") .percentageDiscount(0.15) .usageDiscount(0.0) @@ -225,40 +182,23 @@ class SubscriptionCreateParamsTest { .maximumAmount("1.23") .minimumAmount("1.23") .price( - SubscriptionCreateParams.ReplacePrice.Price.NewSubscriptionUnitPrice - .builder() + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.builder() .cadence( - SubscriptionCreateParams.ReplacePrice.Price.NewSubscriptionUnitPrice - .Cadence - .ANNUAL + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Cadence.ANNUAL ) .itemId("item_id") .modelType( - SubscriptionCreateParams.ReplacePrice.Price.NewSubscriptionUnitPrice - .ModelType - .UNIT + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.ModelType.UNIT ) .name("Annual fee") - .unitConfig( - SubscriptionCreateParams.ReplacePrice.Price.NewSubscriptionUnitPrice - .UnitConfig - .builder() - .unitAmount("unit_amount") - .build() - ) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionCreateParams.ReplacePrice.Price.NewSubscriptionUnitPrice - .BillingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .BillingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) @@ -268,22 +208,15 @@ class SubscriptionCreateParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionCreateParams.ReplacePrice.Price.NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) .metadata( - SubscriptionCreateParams.ReplacePrice.Price.NewSubscriptionUnitPrice - .Metadata + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -305,14 +238,11 @@ class SubscriptionCreateParamsTest { val params = SubscriptionCreateParams.builder() .addAddAdjustment( - SubscriptionCreateParams.AddAdjustment.builder() + AddSubscriptionAdjustmentParams.builder() .adjustment( - SubscriptionCreateParams.AddAdjustment.Adjustment.NewPercentageDiscount - .builder() + NewAdjustmentModel.NewPercentageDiscount.builder() .adjustmentType( - SubscriptionCreateParams.AddAdjustment.Adjustment - .NewPercentageDiscount - .AdjustmentType + NewAdjustmentModel.NewPercentageDiscount.AdjustmentType .PERCENTAGE_DISCOUNT ) .addAppliesToPriceId("price_1") @@ -327,24 +257,18 @@ class SubscriptionCreateParamsTest { .build() ) .addAddPrice( - SubscriptionCreateParams.AddPrice.builder() + AddSubscriptionPriceParams.builder() .allocationPrice( - SubscriptionCreateParams.AddPrice.AllocationPrice.builder() + NewAllocationPriceModel.builder() .amount("10.00") - .cadence( - SubscriptionCreateParams.AddPrice.AllocationPrice.Cadence - .ONE_TIME - ) + .cadence(NewAllocationPriceModel.Cadence.ONE_TIME) .currency("USD") .expiresAtEndOfCadence(true) .build() ) .addDiscount( - SubscriptionCreateParams.AddPrice.Discount.builder() - .discountType( - SubscriptionCreateParams.AddPrice.Discount.DiscountType - .PERCENTAGE - ) + DiscountOverrideModel.builder() + .discountType(DiscountOverrideModel.DiscountType.PERCENTAGE) .amountDiscount("amount_discount") .percentageDiscount(0.15) .usageDiscount(0.0) @@ -356,40 +280,27 @@ class SubscriptionCreateParamsTest { .minimumAmount("1.23") .planPhaseOrder(0L) .price( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice - .builder() + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.builder() .cadence( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice - .Cadence + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Cadence .ANNUAL ) .itemId("item_id") .modelType( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice - .ModelType + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.ModelType .UNIT ) .name("Annual fee") .unitConfig( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice - .UnitConfig - .builder() - .unitAmount("unit_amount") - .build() + UnitConfigModel.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice - .BillingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice - .BillingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) @@ -399,22 +310,15 @@ class SubscriptionCreateParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) .metadata( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice - .Metadata + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -430,7 +334,7 @@ class SubscriptionCreateParamsTest { .autoCollection(true) .awsRegion("aws_region") .billingCycleAnchorConfiguration( - SubscriptionCreateParams.BillingCycleAnchorConfiguration.builder() + BillingCycleAnchorConfigurationModel.builder() .day(1L) .month(1L) .year(0L) @@ -459,26 +363,22 @@ class SubscriptionCreateParamsTest { .planVersionNumber(0L) .addPriceOverride(JsonValue.from(mapOf())) .addRemoveAdjustment( - SubscriptionCreateParams.RemoveAdjustment.builder() + RemoveSubscriptionAdjustmentParams.builder() .adjustmentId("h74gfhdjvn7ujokd") .build() ) .addRemovePrice( - SubscriptionCreateParams.RemovePrice.builder() + RemoveSubscriptionPriceParams.builder() .externalPriceId("external_price_id") .priceId("h74gfhdjvn7ujokd") .build() ) .addReplaceAdjustment( - SubscriptionCreateParams.ReplaceAdjustment.builder() + ReplaceSubscriptionAdjustmentParams.builder() .adjustment( - SubscriptionCreateParams.ReplaceAdjustment.Adjustment - .NewPercentageDiscount - .builder() + NewAdjustmentModel.NewPercentageDiscount.builder() .adjustmentType( - SubscriptionCreateParams.ReplaceAdjustment.Adjustment - .NewPercentageDiscount - .AdjustmentType + NewAdjustmentModel.NewPercentageDiscount.AdjustmentType .PERCENTAGE_DISCOUNT ) .addAppliesToPriceId("price_1") @@ -491,25 +391,19 @@ class SubscriptionCreateParamsTest { .build() ) .addReplacePrice( - SubscriptionCreateParams.ReplacePrice.builder() + ReplaceSubscriptionPriceParams.builder() .replacesPriceId("replaces_price_id") .allocationPrice( - SubscriptionCreateParams.ReplacePrice.AllocationPrice.builder() + NewAllocationPriceModel.builder() .amount("10.00") - .cadence( - SubscriptionCreateParams.ReplacePrice.AllocationPrice.Cadence - .ONE_TIME - ) + .cadence(NewAllocationPriceModel.Cadence.ONE_TIME) .currency("USD") .expiresAtEndOfCadence(true) .build() ) .addDiscount( - SubscriptionCreateParams.ReplacePrice.Discount.builder() - .discountType( - SubscriptionCreateParams.ReplacePrice.Discount.DiscountType - .PERCENTAGE - ) + DiscountOverrideModel.builder() + .discountType(DiscountOverrideModel.DiscountType.PERCENTAGE) .amountDiscount("amount_discount") .percentageDiscount(0.15) .usageDiscount(0.0) @@ -520,44 +414,27 @@ class SubscriptionCreateParamsTest { .maximumAmount("1.23") .minimumAmount("1.23") .price( - SubscriptionCreateParams.ReplacePrice.Price.NewSubscriptionUnitPrice - .builder() + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.builder() .cadence( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .Cadence + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Cadence .ANNUAL ) .itemId("item_id") .modelType( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .ModelType + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.ModelType .UNIT ) .name("Annual fee") .unitConfig( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .UnitConfig - .builder() - .unitAmount("unit_amount") - .build() + UnitConfigModel.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .BillingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .BillingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) @@ -567,24 +444,15 @@ class SubscriptionCreateParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) .metadata( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .Metadata + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -606,14 +474,11 @@ class SubscriptionCreateParamsTest { assertThat(body.addAdjustments()) .contains( listOf( - SubscriptionCreateParams.AddAdjustment.builder() + AddSubscriptionAdjustmentParams.builder() .adjustment( - SubscriptionCreateParams.AddAdjustment.Adjustment.NewPercentageDiscount - .builder() + NewAdjustmentModel.NewPercentageDiscount.builder() .adjustmentType( - SubscriptionCreateParams.AddAdjustment.Adjustment - .NewPercentageDiscount - .AdjustmentType + NewAdjustmentModel.NewPercentageDiscount.AdjustmentType .PERCENTAGE_DISCOUNT ) .addAppliesToPriceId("price_1") @@ -631,24 +496,18 @@ class SubscriptionCreateParamsTest { assertThat(body.addPrices()) .contains( listOf( - SubscriptionCreateParams.AddPrice.builder() + AddSubscriptionPriceParams.builder() .allocationPrice( - SubscriptionCreateParams.AddPrice.AllocationPrice.builder() + NewAllocationPriceModel.builder() .amount("10.00") - .cadence( - SubscriptionCreateParams.AddPrice.AllocationPrice.Cadence - .ONE_TIME - ) + .cadence(NewAllocationPriceModel.Cadence.ONE_TIME) .currency("USD") .expiresAtEndOfCadence(true) .build() ) .addDiscount( - SubscriptionCreateParams.AddPrice.Discount.builder() - .discountType( - SubscriptionCreateParams.AddPrice.Discount.DiscountType - .PERCENTAGE - ) + DiscountOverrideModel.builder() + .discountType(DiscountOverrideModel.DiscountType.PERCENTAGE) .amountDiscount("amount_discount") .percentageDiscount(0.15) .usageDiscount(0.0) @@ -660,40 +519,27 @@ class SubscriptionCreateParamsTest { .minimumAmount("1.23") .planPhaseOrder(0L) .price( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice - .builder() + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.builder() .cadence( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice - .Cadence + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Cadence .ANNUAL ) .itemId("item_id") .modelType( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice - .ModelType + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.ModelType .UNIT ) .name("Annual fee") .unitConfig( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice - .UnitConfig - .builder() - .unitAmount("unit_amount") - .build() + UnitConfigModel.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice - .BillingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice - .BillingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) @@ -703,22 +549,15 @@ class SubscriptionCreateParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) .metadata( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice - .Metadata + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -736,11 +575,7 @@ class SubscriptionCreateParamsTest { assertThat(body.awsRegion()).contains("aws_region") assertThat(body.billingCycleAnchorConfiguration()) .contains( - SubscriptionCreateParams.BillingCycleAnchorConfiguration.builder() - .day(1L) - .month(1L) - .year(0L) - .build() + BillingCycleAnchorConfigurationModel.builder().day(1L).month(1L).year(0L).build() ) assertThat(body.couponRedemptionCode()).contains("coupon_redemption_code") assertThat(body.creditsOverageRate()).contains(0.0) @@ -770,7 +605,7 @@ class SubscriptionCreateParamsTest { assertThat(body.removeAdjustments()) .contains( listOf( - SubscriptionCreateParams.RemoveAdjustment.builder() + RemoveSubscriptionAdjustmentParams.builder() .adjustmentId("h74gfhdjvn7ujokd") .build() ) @@ -778,7 +613,7 @@ class SubscriptionCreateParamsTest { assertThat(body.removePrices()) .contains( listOf( - SubscriptionCreateParams.RemovePrice.builder() + RemoveSubscriptionPriceParams.builder() .externalPriceId("external_price_id") .priceId("h74gfhdjvn7ujokd") .build() @@ -787,15 +622,11 @@ class SubscriptionCreateParamsTest { assertThat(body.replaceAdjustments()) .contains( listOf( - SubscriptionCreateParams.ReplaceAdjustment.builder() + ReplaceSubscriptionAdjustmentParams.builder() .adjustment( - SubscriptionCreateParams.ReplaceAdjustment.Adjustment - .NewPercentageDiscount - .builder() + NewAdjustmentModel.NewPercentageDiscount.builder() .adjustmentType( - SubscriptionCreateParams.ReplaceAdjustment.Adjustment - .NewPercentageDiscount - .AdjustmentType + NewAdjustmentModel.NewPercentageDiscount.AdjustmentType .PERCENTAGE_DISCOUNT ) .addAppliesToPriceId("price_1") @@ -811,25 +642,19 @@ class SubscriptionCreateParamsTest { assertThat(body.replacePrices()) .contains( listOf( - SubscriptionCreateParams.ReplacePrice.builder() + ReplaceSubscriptionPriceParams.builder() .replacesPriceId("replaces_price_id") .allocationPrice( - SubscriptionCreateParams.ReplacePrice.AllocationPrice.builder() + NewAllocationPriceModel.builder() .amount("10.00") - .cadence( - SubscriptionCreateParams.ReplacePrice.AllocationPrice.Cadence - .ONE_TIME - ) + .cadence(NewAllocationPriceModel.Cadence.ONE_TIME) .currency("USD") .expiresAtEndOfCadence(true) .build() ) .addDiscount( - SubscriptionCreateParams.ReplacePrice.Discount.builder() - .discountType( - SubscriptionCreateParams.ReplacePrice.Discount.DiscountType - .PERCENTAGE - ) + DiscountOverrideModel.builder() + .discountType(DiscountOverrideModel.DiscountType.PERCENTAGE) .amountDiscount("amount_discount") .percentageDiscount(0.15) .usageDiscount(0.0) @@ -840,44 +665,27 @@ class SubscriptionCreateParamsTest { .maximumAmount("1.23") .minimumAmount("1.23") .price( - SubscriptionCreateParams.ReplacePrice.Price.NewSubscriptionUnitPrice - .builder() + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.builder() .cadence( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .Cadence + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Cadence .ANNUAL ) .itemId("item_id") .modelType( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .ModelType + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.ModelType .UNIT ) .name("Annual fee") .unitConfig( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .UnitConfig - .builder() - .unitAmount("unit_amount") - .build() + UnitConfigModel.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .BillingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .BillingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) @@ -887,24 +695,15 @@ class SubscriptionCreateParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) .metadata( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .Metadata + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponseTest.kt index bbfeb1b40..1a3e89d4c 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 @@ -14,32 +14,28 @@ class SubscriptionFetchCostsResponseTest { val subscriptionFetchCostsResponse = SubscriptionFetchCostsResponse.builder() .addData( - SubscriptionFetchCostsResponse.Data.builder() + AggregatedCostModel.builder() .addPerPriceCost( - SubscriptionFetchCostsResponse.Data.PerPriceCost.builder() + AggregatedCostModel.PerPriceCost.builder() .price( - Price.UnitPrice.builder() + PriceModel.UnitPrice.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + BillableMetricTinyModel.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration - .DurationUnit - .DAY + BillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + AllocationModel.builder() .allowsRollover(true) .currency("currency") .build() @@ -59,30 +55,23 @@ class SubscriptionFetchCostsResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration - .DurationUnit - .DAY + BillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) - .item( - Price.UnitPrice.Item.builder() - .id("id") - .name("name") - .build() - ) + .item(ItemSlimModel.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + PriceModel.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -90,23 +79,23 @@ class SubscriptionFetchCostsResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) + .modelType(PriceModel.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + UnitConfigModel.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + DimensionalPriceConfigurationModel.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -131,30 +120,28 @@ class SubscriptionFetchCostsResponseTest { assertThat(subscriptionFetchCostsResponse).isNotNull assertThat(subscriptionFetchCostsResponse.data()) .containsExactly( - SubscriptionFetchCostsResponse.Data.builder() + AggregatedCostModel.builder() .addPerPriceCost( - SubscriptionFetchCostsResponse.Data.PerPriceCost.builder() + AggregatedCostModel.PerPriceCost.builder() .price( - Price.UnitPrice.builder() + PriceModel.UnitPrice.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + BillableMetricTinyModel.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration - .DurationUnit - .DAY + BillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + AllocationModel.builder() .allowsRollover(true) .currency("currency") .build() @@ -174,48 +161,42 @@ class SubscriptionFetchCostsResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration - .DurationUnit - .DAY + BillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) - .item( - Price.UnitPrice.Item.builder().id("id").name("name").build() - ) + .item(ItemSlimModel.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + PriceModel.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) + .modelType(PriceModel.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() + UnitConfigModel.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + DimensionalPriceConfigurationModel.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchScheduleResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchScheduleResponseTest.kt index 019ae3c13..31c9ad83b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchScheduleResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionFetchScheduleResponseTest.kt @@ -15,7 +15,7 @@ class SubscriptionFetchScheduleResponseTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .plan( - SubscriptionFetchScheduleResponse.Plan.builder() + PlanMinifiedModel.builder() .id("m2t5akQeh2obwxeU") .externalPlanId("m2t5akQeh2obwxeU") .name("Example plan") @@ -30,7 +30,7 @@ class SubscriptionFetchScheduleResponseTest { .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(subscriptionFetchScheduleResponse.plan()) .isEqualTo( - SubscriptionFetchScheduleResponse.Plan.builder() + PlanMinifiedModel.builder() .id("m2t5akQeh2obwxeU") .externalPlanId("m2t5akQeh2obwxeU") .name("Example plan") diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionMinifiedModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionMinifiedModelTest.kt new file mode 100644 index 000000000..b9b7f7d06 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionMinifiedModelTest.kt @@ -0,0 +1,17 @@ +// 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 + +class SubscriptionMinifiedModelTest { + + @Test + fun createSubscriptionMinifiedModel() { + val subscriptionMinifiedModel = + SubscriptionMinifiedModel.builder().id("VDGsT23osdLb84KD").build() + assertThat(subscriptionMinifiedModel).isNotNull + assertThat(subscriptionMinifiedModel.id()).isEqualTo("VDGsT23osdLb84KD") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionModelTest.kt similarity index 70% rename from orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateResponseTest.kt rename to orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionModelTest.kt index c78dc3ab4..8c33351db 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionModelTest.kt @@ -7,26 +7,22 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class SubscriptionCreateResponseTest { +class SubscriptionModelTest { @Test - fun createSubscriptionCreateResponse() { - val subscriptionCreateResponse = - SubscriptionCreateResponse.builder() + fun createSubscriptionModel() { + val subscriptionModel = + SubscriptionModel.builder() .id("id") .activePlanPhaseOrder(0L) .addAdjustmentInterval( - SubscriptionCreateResponse.AdjustmentInterval.builder() + AdjustmentIntervalModel.builder() .id("id") .adjustment( - SubscriptionCreateResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .builder() + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.builder() .id("id") .adjustmentType( - SubscriptionCreateResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.AdjustmentType .USAGE_DISCOUNT ) .addAppliesToPriceId("string") @@ -43,7 +39,7 @@ class SubscriptionCreateResponseTest { ) .autoCollection(true) .billingCycleAnchorConfiguration( - SubscriptionCreateResponse.BillingCycleAnchorConfiguration.builder() + BillingCycleAnchorConfigurationModel.builder() .day(1L) .month(1L) .year(0L) @@ -54,13 +50,13 @@ class SubscriptionCreateResponseTest { .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customer( - Customer.builder() + CustomerModel.builder() .id("id") .addAdditionalEmail("string") .autoCollection(true) .balance("balance") .billingAddress( - Customer.BillingAddress.builder() + AddressModel.builder() .city("city") .country("country") .line1("line1") @@ -76,15 +72,15 @@ class SubscriptionCreateResponseTest { .exemptFromAutomatedTax(true) .externalCustomerId("external_customer_id") .hierarchy( - Customer.Hierarchy.builder() + CustomerModel.Hierarchy.builder() .addChild( - Customer.Hierarchy.Child.builder() + CustomerMinifiedModel.builder() .id("id") .externalCustomerId("external_customer_id") .build() ) .parent( - Customer.Hierarchy.Parent.builder() + CustomerMinifiedModel.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -92,16 +88,16 @@ class SubscriptionCreateResponseTest { .build() ) .metadata( - Customer.Metadata.builder() + CustomerModel.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .name("name") - .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) + .paymentProvider(CustomerModel.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .portalUrl("portal_url") .shippingAddress( - Customer.ShippingAddress.builder() + AddressModel.builder() .city("city") .country("country") .line1("line1") @@ -111,21 +107,22 @@ class SubscriptionCreateResponseTest { .build() ) .taxId( - Customer.TaxId.builder() - .country(Customer.TaxId.Country.AD) - .type(Customer.TaxId.Type.AD_NRT) + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) .value("value") .build() ) .timezone("timezone") .accountingSyncConfiguration( - Customer.AccountingSyncConfiguration.builder() + CustomerModel.AccountingSyncConfiguration.builder() .addAccountingProvider( - Customer.AccountingSyncConfiguration.AccountingProvider + CustomerModel.AccountingSyncConfiguration.AccountingProvider .builder() .externalProviderId("external_provider_id") .providerType( - Customer.AccountingSyncConfiguration.AccountingProvider + CustomerModel.AccountingSyncConfiguration + .AccountingProvider .ProviderType .QUICKBOOKS ) @@ -135,28 +132,24 @@ class SubscriptionCreateResponseTest { .build() ) .reportingConfiguration( - Customer.ReportingConfiguration.builder().exempt(true).build() + CustomerModel.ReportingConfiguration.builder().exempt(true).build() ) .build() ) .defaultInvoiceMemo("default_invoice_memo") .addDiscountInterval( - SubscriptionCreateResponse.DiscountInterval.AmountDiscountInterval.builder() + AmountDiscountIntervalModel.builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionCreateResponse.DiscountInterval.AmountDiscountInterval - .DiscountType - .AMOUNT - ) + .discountType(AmountDiscountIntervalModel.DiscountType.AMOUNT) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFixedFeeQuantitySchedule( - SubscriptionCreateResponse.FixedFeeQuantitySchedule.builder() + FixedFeeQuantityScheduleEntryModel.builder() .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .priceId("price_id") .quantity(0.0) @@ -165,7 +158,7 @@ class SubscriptionCreateResponseTest { ) .invoicingThreshold("invoicing_threshold") .addMaximumInterval( - SubscriptionCreateResponse.MaximumInterval.builder() + MaximumIntervalModel.builder() .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -174,12 +167,12 @@ class SubscriptionCreateResponseTest { .build() ) .metadata( - SubscriptionCreateResponse.Metadata.builder() + SubscriptionModel.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .addMinimumInterval( - SubscriptionCreateResponse.MinimumInterval.builder() + MinimumIntervalModel.builder() .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -189,13 +182,13 @@ class SubscriptionCreateResponseTest { ) .netTerms(0L) .plan( - Plan.builder() + PlanModel.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.builder() .id("id") .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.AdjustmentType .USAGE_DISCOUNT ) .addAppliesToPriceId("string") @@ -206,7 +199,7 @@ class SubscriptionCreateResponseTest { .build() ) .basePlan( - Plan.BasePlan.builder() + PlanMinifiedModel.builder() .id("m2t5akQeh2obwxeU") .externalPlanId("m2t5akQeh2obwxeU") .name("Example plan") @@ -229,19 +222,19 @@ class SubscriptionCreateResponseTest { .externalPlanId("external_plan_id") .invoicingCurrency("invoicing_currency") .maximum( - Plan.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Plan.Metadata.builder() + PlanModel.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Plan.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() @@ -250,7 +243,7 @@ class SubscriptionCreateResponseTest { .name("name") .netTerms(0L) .addPlanPhase( - Plan.PlanPhase.builder() + PlanModel.PlanPhase.builder() .id("id") .description("description") .discount( @@ -263,16 +256,16 @@ class SubscriptionCreateResponseTest { .build() ) .duration(0L) - .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .durationUnit(PlanModel.PlanPhase.DurationUnit.DAILY) .maximum( - Plan.PlanPhase.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .minimum( - Plan.PlanPhase.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() @@ -283,25 +276,22 @@ class SubscriptionCreateResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + PriceModel.UnitPrice.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(BillableMetricTinyModel.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + BillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + AllocationModel.builder() .allowsRollover(true) .currency("currency") .build() @@ -319,45 +309,42 @@ class SubscriptionCreateResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + BillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(ItemSlimModel.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + PriceModel.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) + .modelType(PriceModel.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() + UnitConfigModel.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + DimensionalPriceConfigurationModel.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -365,24 +352,24 @@ class SubscriptionCreateResponseTest { .build() ) .product( - Plan.Product.builder() + PlanModel.Product.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .name("name") .build() ) - .status(Plan.Status.ACTIVE) + .status(PlanModel.Status.ACTIVE) .trialConfig( - Plan.TrialConfig.builder() + PlanModel.TrialConfig.builder() .trialPeriod(0L) - .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .trialPeriodUnit(PlanModel.TrialConfig.TrialPeriodUnit.DAYS) .build() ) .version(0L) .build() ) .addPriceInterval( - SubscriptionCreateResponse.PriceInterval.builder() + PriceIntervalModel.builder() .id("id") .billingCycleDay(0L) .currentBillingPeriodEndDate( @@ -394,33 +381,29 @@ class SubscriptionCreateResponseTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .filter("filter") .addFixedFeeQuantityTransition( - SubscriptionCreateResponse.PriceInterval.FixedFeeQuantityTransition - .builder() + PriceIntervalModel.FixedFeeQuantityTransition.builder() .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .priceId("price_id") .quantity(0L) .build() ) .price( - Price.UnitPrice.builder() + PriceModel.UnitPrice.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(BillableMetricTinyModel.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + BillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + AllocationModel.builder() .allowsRollover(true) .currency("currency") .build() @@ -438,45 +421,42 @@ class SubscriptionCreateResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + BillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(ItemSlimModel.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + PriceModel.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) + .modelType(PriceModel.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() + UnitConfigModel.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + DimensionalPriceConfigurationModel.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -488,36 +468,32 @@ class SubscriptionCreateResponseTest { .build() ) .redeemedCoupon( - SubscriptionCreateResponse.RedeemedCoupon.builder() + CouponRedemptionModel.builder() .couponId("coupon_id") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .status(SubscriptionCreateResponse.Status.ACTIVE) + .status(SubscriptionModel.Status.ACTIVE) .trialInfo( - SubscriptionCreateResponse.TrialInfo.builder() + SubscriptionTrialInfoModel.builder() .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) .build() - assertThat(subscriptionCreateResponse).isNotNull - assertThat(subscriptionCreateResponse.id()).isEqualTo("id") - assertThat(subscriptionCreateResponse.activePlanPhaseOrder()).contains(0L) - assertThat(subscriptionCreateResponse.adjustmentIntervals()) + assertThat(subscriptionModel).isNotNull + assertThat(subscriptionModel.id()).isEqualTo("id") + assertThat(subscriptionModel.activePlanPhaseOrder()).contains(0L) + assertThat(subscriptionModel.adjustmentIntervals()) .containsExactly( - SubscriptionCreateResponse.AdjustmentInterval.builder() + AdjustmentIntervalModel.builder() .id("id") .adjustment( - SubscriptionCreateResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .builder() + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.builder() .id("id") .adjustmentType( - SubscriptionCreateResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.AdjustmentType .USAGE_DISCOUNT ) .addAppliesToPriceId("string") @@ -532,31 +508,27 @@ class SubscriptionCreateResponseTest { .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) - assertThat(subscriptionCreateResponse.autoCollection()).contains(true) - assertThat(subscriptionCreateResponse.billingCycleAnchorConfiguration()) + assertThat(subscriptionModel.autoCollection()).contains(true) + assertThat(subscriptionModel.billingCycleAnchorConfiguration()) .isEqualTo( - SubscriptionCreateResponse.BillingCycleAnchorConfiguration.builder() - .day(1L) - .month(1L) - .year(0L) - .build() + BillingCycleAnchorConfigurationModel.builder().day(1L).month(1L).year(0L).build() ) - assertThat(subscriptionCreateResponse.billingCycleDay()).isEqualTo(1L) - assertThat(subscriptionCreateResponse.createdAt()) + assertThat(subscriptionModel.billingCycleDay()).isEqualTo(1L) + assertThat(subscriptionModel.createdAt()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionCreateResponse.currentBillingPeriodEndDate()) + assertThat(subscriptionModel.currentBillingPeriodEndDate()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionCreateResponse.currentBillingPeriodStartDate()) + assertThat(subscriptionModel.currentBillingPeriodStartDate()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionCreateResponse.customer()) + assertThat(subscriptionModel.customer()) .isEqualTo( - Customer.builder() + CustomerModel.builder() .id("id") .addAdditionalEmail("string") .autoCollection(true) .balance("balance") .billingAddress( - Customer.BillingAddress.builder() + AddressModel.builder() .city("city") .country("country") .line1("line1") @@ -572,15 +544,15 @@ class SubscriptionCreateResponseTest { .exemptFromAutomatedTax(true) .externalCustomerId("external_customer_id") .hierarchy( - Customer.Hierarchy.builder() + CustomerModel.Hierarchy.builder() .addChild( - Customer.Hierarchy.Child.builder() + CustomerMinifiedModel.builder() .id("id") .externalCustomerId("external_customer_id") .build() ) .parent( - Customer.Hierarchy.Parent.builder() + CustomerMinifiedModel.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -588,16 +560,16 @@ class SubscriptionCreateResponseTest { .build() ) .metadata( - Customer.Metadata.builder() + CustomerModel.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .name("name") - .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) + .paymentProvider(CustomerModel.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .portalUrl("portal_url") .shippingAddress( - Customer.ShippingAddress.builder() + AddressModel.builder() .city("city") .country("country") .line1("line1") @@ -607,20 +579,21 @@ class SubscriptionCreateResponseTest { .build() ) .taxId( - Customer.TaxId.builder() - .country(Customer.TaxId.Country.AD) - .type(Customer.TaxId.Type.AD_NRT) + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) .value("value") .build() ) .timezone("timezone") .accountingSyncConfiguration( - Customer.AccountingSyncConfiguration.builder() + CustomerModel.AccountingSyncConfiguration.builder() .addAccountingProvider( - Customer.AccountingSyncConfiguration.AccountingProvider.builder() + CustomerModel.AccountingSyncConfiguration.AccountingProvider + .builder() .externalProviderId("external_provider_id") .providerType( - Customer.AccountingSyncConfiguration.AccountingProvider + CustomerModel.AccountingSyncConfiguration.AccountingProvider .ProviderType .QUICKBOOKS ) @@ -630,43 +603,39 @@ class SubscriptionCreateResponseTest { .build() ) .reportingConfiguration( - Customer.ReportingConfiguration.builder().exempt(true).build() + CustomerModel.ReportingConfiguration.builder().exempt(true).build() ) .build() ) - assertThat(subscriptionCreateResponse.defaultInvoiceMemo()).contains("default_invoice_memo") - assertThat(subscriptionCreateResponse.discountIntervals()) + assertThat(subscriptionModel.defaultInvoiceMemo()).contains("default_invoice_memo") + assertThat(subscriptionModel.discountIntervals()) .containsExactly( - SubscriptionCreateResponse.DiscountInterval.ofAmount( - SubscriptionCreateResponse.DiscountInterval.AmountDiscountInterval.builder() + SubscriptionModel.DiscountInterval.ofAmountDiscountIntervalModel( + AmountDiscountIntervalModel.builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionCreateResponse.DiscountInterval.AmountDiscountInterval - .DiscountType - .AMOUNT - ) + .discountType(AmountDiscountIntervalModel.DiscountType.AMOUNT) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) ) - assertThat(subscriptionCreateResponse.endDate()) + assertThat(subscriptionModel.endDate()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionCreateResponse.fixedFeeQuantitySchedule()) + assertThat(subscriptionModel.fixedFeeQuantitySchedule()) .containsExactly( - SubscriptionCreateResponse.FixedFeeQuantitySchedule.builder() + FixedFeeQuantityScheduleEntryModel.builder() .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .priceId("price_id") .quantity(0.0) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) - assertThat(subscriptionCreateResponse.invoicingThreshold()).contains("invoicing_threshold") - assertThat(subscriptionCreateResponse.maximumIntervals()) + assertThat(subscriptionModel.invoicingThreshold()).contains("invoicing_threshold") + assertThat(subscriptionModel.maximumIntervals()) .containsExactly( - SubscriptionCreateResponse.MaximumInterval.builder() + MaximumIntervalModel.builder() .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -674,15 +643,15 @@ class SubscriptionCreateResponseTest { .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) - assertThat(subscriptionCreateResponse.metadata()) + assertThat(subscriptionModel.metadata()) .isEqualTo( - SubscriptionCreateResponse.Metadata.builder() + SubscriptionModel.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) - assertThat(subscriptionCreateResponse.minimumIntervals()) + assertThat(subscriptionModel.minimumIntervals()) .containsExactly( - SubscriptionCreateResponse.MinimumInterval.builder() + MinimumIntervalModel.builder() .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -690,16 +659,16 @@ class SubscriptionCreateResponseTest { .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) - assertThat(subscriptionCreateResponse.netTerms()).isEqualTo(0L) - assertThat(subscriptionCreateResponse.plan()) + assertThat(subscriptionModel.netTerms()).isEqualTo(0L) + assertThat(subscriptionModel.plan()) .isEqualTo( - Plan.builder() + PlanModel.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.builder() .id("id") .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.AdjustmentType .USAGE_DISCOUNT ) .addAppliesToPriceId("string") @@ -710,7 +679,7 @@ class SubscriptionCreateResponseTest { .build() ) .basePlan( - Plan.BasePlan.builder() + PlanMinifiedModel.builder() .id("m2t5akQeh2obwxeU") .externalPlanId("m2t5akQeh2obwxeU") .name("Example plan") @@ -733,19 +702,19 @@ class SubscriptionCreateResponseTest { .externalPlanId("external_plan_id") .invoicingCurrency("invoicing_currency") .maximum( - Plan.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Plan.Metadata.builder() + PlanModel.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Plan.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() @@ -754,7 +723,7 @@ class SubscriptionCreateResponseTest { .name("name") .netTerms(0L) .addPlanPhase( - Plan.PlanPhase.builder() + PlanModel.PlanPhase.builder() .id("id") .description("description") .discount( @@ -767,16 +736,16 @@ class SubscriptionCreateResponseTest { .build() ) .duration(0L) - .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .durationUnit(PlanModel.PlanPhase.DurationUnit.DAILY) .maximum( - Plan.PlanPhase.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .minimum( - Plan.PlanPhase.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() @@ -787,24 +756,20 @@ class SubscriptionCreateResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + PriceModel.UnitPrice.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(BillableMetricTinyModel.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(BillingCycleConfigurationModel.DurationUnit.DAY) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + AllocationModel.builder() .allowsRollover(true) .currency("currency") .build() @@ -822,44 +787,38 @@ class SubscriptionCreateResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(BillingCycleConfigurationModel.DurationUnit.DAY) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(ItemSlimModel.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + PriceModel.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) + .modelType(PriceModel.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + DimensionalPriceConfigurationModel.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -867,25 +826,25 @@ class SubscriptionCreateResponseTest { .build() ) .product( - Plan.Product.builder() + PlanModel.Product.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .name("name") .build() ) - .status(Plan.Status.ACTIVE) + .status(PlanModel.Status.ACTIVE) .trialConfig( - Plan.TrialConfig.builder() + PlanModel.TrialConfig.builder() .trialPeriod(0L) - .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .trialPeriodUnit(PlanModel.TrialConfig.TrialPeriodUnit.DAYS) .build() ) .version(0L) .build() ) - assertThat(subscriptionCreateResponse.priceIntervals()) + assertThat(subscriptionModel.priceIntervals()) .containsExactly( - SubscriptionCreateResponse.PriceInterval.builder() + PriceIntervalModel.builder() .id("id") .billingCycleDay(0L) .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -893,32 +852,27 @@ class SubscriptionCreateResponseTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .filter("filter") .addFixedFeeQuantityTransition( - SubscriptionCreateResponse.PriceInterval.FixedFeeQuantityTransition - .builder() + PriceIntervalModel.FixedFeeQuantityTransition.builder() .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .priceId("price_id") .quantity(0L) .build() ) .price( - Price.UnitPrice.builder() + PriceModel.UnitPrice.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(BillableMetricTinyModel.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(BillingCycleConfigurationModel.DurationUnit.DAY) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + AllocationModel.builder() .allowsRollover(true) .currency("currency") .build() @@ -936,44 +890,38 @@ class SubscriptionCreateResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(BillingCycleConfigurationModel.DurationUnit.DAY) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(ItemSlimModel.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + PriceModel.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) + .modelType(PriceModel.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + DimensionalPriceConfigurationModel.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -984,21 +932,20 @@ class SubscriptionCreateResponseTest { .addUsageCustomerId("string") .build() ) - assertThat(subscriptionCreateResponse.redeemedCoupon()) + assertThat(subscriptionModel.redeemedCoupon()) .contains( - SubscriptionCreateResponse.RedeemedCoupon.builder() + CouponRedemptionModel.builder() .couponId("coupon_id") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) - assertThat(subscriptionCreateResponse.startDate()) + assertThat(subscriptionModel.startDate()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionCreateResponse.status()) - .isEqualTo(SubscriptionCreateResponse.Status.ACTIVE) - assertThat(subscriptionCreateResponse.trialInfo()) + assertThat(subscriptionModel.status()).isEqualTo(SubscriptionModel.Status.ACTIVE) + assertThat(subscriptionModel.trialInfo()) .isEqualTo( - SubscriptionCreateResponse.TrialInfo.builder() + SubscriptionTrialInfoModel.builder() .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParamsTest.kt index 17ef7804e..56a08417d 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 @@ -18,12 +18,9 @@ class SubscriptionPriceIntervalsParamsTest { SubscriptionPriceIntervalsParams.Add.builder() .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .allocationPrice( - SubscriptionPriceIntervalsParams.Add.AllocationPrice.builder() + NewAllocationPriceModel.builder() .amount("10.00") - .cadence( - SubscriptionPriceIntervalsParams.Add.AllocationPrice.Cadence - .ONE_TIME - ) + .cadence(NewAllocationPriceModel.Cadence.ONE_TIME) .currency("USD") .expiresAtEndOfCadence(true) .build() @@ -33,7 +30,7 @@ class SubscriptionPriceIntervalsParamsTest { .externalPriceId("external_price_id") .filter("my_property > 100 AND my_other_property = 'bar'") .addFixedFeeQuantityTransition( - SubscriptionPriceIntervalsParams.Add.FixedFeeQuantityTransition.builder() + PriceIntervalFixedFeeQuantityTransitionModel.builder() .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .quantity(5L) .build() @@ -41,40 +38,20 @@ class SubscriptionPriceIntervalsParamsTest { .maximumAmount(0.0) .minimumAmount(0.0) .price( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice.builder() - .cadence( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice - .Cadence - .ANNUAL - ) + NewFloatingPriceModel.NewFloatingUnitPrice.builder() + .cadence(NewFloatingPriceModel.NewFloatingUnitPrice.Cadence.ANNUAL) .currency("currency") .itemId("item_id") - .modelType( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice - .ModelType - .UNIT - ) + .modelType(NewFloatingPriceModel.NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice - .UnitConfig - .builder() - .unitAmount("unit_amount") - .build() - ) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice - .BillingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice - .BillingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) @@ -83,23 +60,15 @@ class SubscriptionPriceIntervalsParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice - .InvoicingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice - .InvoicingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) .metadata( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice - .Metadata - .builder() + NewFloatingPriceModel.NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -112,13 +81,9 @@ class SubscriptionPriceIntervalsParamsTest { .addAddAdjustment( SubscriptionPriceIntervalsParams.AddAdjustment.builder() .adjustment( - SubscriptionPriceIntervalsParams.AddAdjustment.Adjustment - .NewPercentageDiscount - .builder() + NewAdjustmentModel.NewPercentageDiscount.builder() .adjustmentType( - SubscriptionPriceIntervalsParams.AddAdjustment.Adjustment - .NewPercentageDiscount - .AdjustmentType + NewAdjustmentModel.NewPercentageDiscount.AdjustmentType .PERCENTAGE_DISCOUNT ) .addAppliesToPriceId("price_1") @@ -139,7 +104,7 @@ class SubscriptionPriceIntervalsParamsTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .filter("my_property > 100 AND my_other_property = 'bar'") .addFixedFeeQuantityTransition( - SubscriptionPriceIntervalsParams.Edit.FixedFeeQuantityTransition.builder() + PriceIntervalFixedFeeQuantityTransitionModel.builder() .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .quantity(5L) .build() @@ -167,12 +132,9 @@ class SubscriptionPriceIntervalsParamsTest { SubscriptionPriceIntervalsParams.Add.builder() .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .allocationPrice( - SubscriptionPriceIntervalsParams.Add.AllocationPrice.builder() + NewAllocationPriceModel.builder() .amount("10.00") - .cadence( - SubscriptionPriceIntervalsParams.Add.AllocationPrice.Cadence - .ONE_TIME - ) + .cadence(NewAllocationPriceModel.Cadence.ONE_TIME) .currency("USD") .expiresAtEndOfCadence(true) .build() @@ -182,8 +144,7 @@ class SubscriptionPriceIntervalsParamsTest { .externalPriceId("external_price_id") .filter("my_property > 100 AND my_other_property = 'bar'") .addFixedFeeQuantityTransition( - SubscriptionPriceIntervalsParams.Add.FixedFeeQuantityTransition - .builder() + PriceIntervalFixedFeeQuantityTransitionModel.builder() .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .quantity(5L) .build() @@ -191,41 +152,24 @@ class SubscriptionPriceIntervalsParamsTest { .maximumAmount(0.0) .minimumAmount(0.0) .price( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice - .builder() - .cadence( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice - .Cadence - .ANNUAL - ) + NewFloatingPriceModel.NewFloatingUnitPrice.builder() + .cadence(NewFloatingPriceModel.NewFloatingUnitPrice.Cadence.ANNUAL) .currency("currency") .itemId("item_id") .modelType( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice - .ModelType - .UNIT + NewFloatingPriceModel.NewFloatingUnitPrice.ModelType.UNIT ) .name("Annual fee") .unitConfig( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice - .UnitConfig - .builder() - .unitAmount("unit_amount") - .build() + UnitConfigModel.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice - .BillingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice - .BillingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) @@ -234,23 +178,15 @@ class SubscriptionPriceIntervalsParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice - .InvoicingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice - .InvoicingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) .metadata( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice - .Metadata - .builder() + NewFloatingPriceModel.NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -263,13 +199,9 @@ class SubscriptionPriceIntervalsParamsTest { .addAddAdjustment( SubscriptionPriceIntervalsParams.AddAdjustment.builder() .adjustment( - SubscriptionPriceIntervalsParams.AddAdjustment.Adjustment - .NewPercentageDiscount - .builder() + NewAdjustmentModel.NewPercentageDiscount.builder() .adjustmentType( - SubscriptionPriceIntervalsParams.AddAdjustment.Adjustment - .NewPercentageDiscount - .AdjustmentType + NewAdjustmentModel.NewPercentageDiscount.AdjustmentType .PERCENTAGE_DISCOUNT ) .addAppliesToPriceId("price_1") @@ -290,8 +222,7 @@ class SubscriptionPriceIntervalsParamsTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .filter("my_property > 100 AND my_other_property = 'bar'") .addFixedFeeQuantityTransition( - SubscriptionPriceIntervalsParams.Edit.FixedFeeQuantityTransition - .builder() + PriceIntervalFixedFeeQuantityTransitionModel.builder() .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .quantity(5L) .build() @@ -318,12 +249,9 @@ class SubscriptionPriceIntervalsParamsTest { SubscriptionPriceIntervalsParams.Add.builder() .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .allocationPrice( - SubscriptionPriceIntervalsParams.Add.AllocationPrice.builder() + NewAllocationPriceModel.builder() .amount("10.00") - .cadence( - SubscriptionPriceIntervalsParams.Add.AllocationPrice.Cadence - .ONE_TIME - ) + .cadence(NewAllocationPriceModel.Cadence.ONE_TIME) .currency("USD") .expiresAtEndOfCadence(true) .build() @@ -333,8 +261,7 @@ class SubscriptionPriceIntervalsParamsTest { .externalPriceId("external_price_id") .filter("my_property > 100 AND my_other_property = 'bar'") .addFixedFeeQuantityTransition( - SubscriptionPriceIntervalsParams.Add.FixedFeeQuantityTransition - .builder() + PriceIntervalFixedFeeQuantityTransitionModel.builder() .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .quantity(5L) .build() @@ -342,41 +269,24 @@ class SubscriptionPriceIntervalsParamsTest { .maximumAmount(0.0) .minimumAmount(0.0) .price( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice - .builder() - .cadence( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice - .Cadence - .ANNUAL - ) + NewFloatingPriceModel.NewFloatingUnitPrice.builder() + .cadence(NewFloatingPriceModel.NewFloatingUnitPrice.Cadence.ANNUAL) .currency("currency") .itemId("item_id") .modelType( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice - .ModelType - .UNIT + NewFloatingPriceModel.NewFloatingUnitPrice.ModelType.UNIT ) .name("Annual fee") .unitConfig( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice - .UnitConfig - .builder() - .unitAmount("unit_amount") - .build() + UnitConfigModel.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice - .BillingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice - .BillingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) @@ -385,23 +295,15 @@ class SubscriptionPriceIntervalsParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice - .InvoicingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice - .InvoicingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) .metadata( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice - .Metadata - .builder() + NewFloatingPriceModel.NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -417,13 +319,9 @@ class SubscriptionPriceIntervalsParamsTest { listOf( SubscriptionPriceIntervalsParams.AddAdjustment.builder() .adjustment( - SubscriptionPriceIntervalsParams.AddAdjustment.Adjustment - .NewPercentageDiscount - .builder() + NewAdjustmentModel.NewPercentageDiscount.builder() .adjustmentType( - SubscriptionPriceIntervalsParams.AddAdjustment.Adjustment - .NewPercentageDiscount - .AdjustmentType + NewAdjustmentModel.NewPercentageDiscount.AdjustmentType .PERCENTAGE_DISCOUNT ) .addAppliesToPriceId("price_1") @@ -447,8 +345,7 @@ class SubscriptionPriceIntervalsParamsTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .filter("my_property > 100 AND my_other_property = 'bar'") .addFixedFeeQuantityTransition( - SubscriptionPriceIntervalsParams.Edit.FixedFeeQuantityTransition - .builder() + PriceIntervalFixedFeeQuantityTransitionModel.builder() .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .quantity(5L) .build() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsResponseTest.kt deleted file mode 100644 index efa99c311..000000000 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsResponseTest.kt +++ /dev/null @@ -1,1013 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.withorb.api.core.JsonValue -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class SubscriptionPriceIntervalsResponseTest { - - @Test - fun createSubscriptionPriceIntervalsResponse() { - val subscriptionPriceIntervalsResponse = - SubscriptionPriceIntervalsResponse.builder() - .id("id") - .activePlanPhaseOrder(0L) - .addAdjustmentInterval( - SubscriptionPriceIntervalsResponse.AdjustmentInterval.builder() - .id("id") - .adjustment( - SubscriptionPriceIntervalsResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .builder() - .id("id") - .adjustmentType( - SubscriptionPriceIntervalsResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .autoCollection(true) - .billingCycleAnchorConfiguration( - SubscriptionPriceIntervalsResponse.BillingCycleAnchorConfiguration.builder() - .day(1L) - .month(1L) - .year(0L) - .build() - ) - .billingCycleDay(1L) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .customer( - Customer.builder() - .id("id") - .addAdditionalEmail("string") - .autoCollection(true) - .balance("balance") - .billingAddress( - Customer.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currency("currency") - .email("email") - .emailDelivery(true) - .exemptFromAutomatedTax(true) - .externalCustomerId("external_customer_id") - .hierarchy( - Customer.Hierarchy.builder() - .addChild( - Customer.Hierarchy.Child.builder() - .id("id") - .externalCustomerId("external_customer_id") - .build() - ) - .parent( - Customer.Hierarchy.Parent.builder() - .id("id") - .externalCustomerId("external_customer_id") - .build() - ) - .build() - ) - .metadata( - Customer.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .name("name") - .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) - .paymentProviderId("payment_provider_id") - .portalUrl("portal_url") - .shippingAddress( - Customer.ShippingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .taxId( - Customer.TaxId.builder() - .country(Customer.TaxId.Country.AD) - .type(Customer.TaxId.Type.AD_NRT) - .value("value") - .build() - ) - .timezone("timezone") - .accountingSyncConfiguration( - Customer.AccountingSyncConfiguration.builder() - .addAccountingProvider( - Customer.AccountingSyncConfiguration.AccountingProvider - .builder() - .externalProviderId("external_provider_id") - .providerType( - Customer.AccountingSyncConfiguration.AccountingProvider - .ProviderType - .QUICKBOOKS - ) - .build() - ) - .excluded(true) - .build() - ) - .reportingConfiguration( - Customer.ReportingConfiguration.builder().exempt(true).build() - ) - .build() - ) - .defaultInvoiceMemo("default_invoice_memo") - .addDiscountInterval( - SubscriptionPriceIntervalsResponse.DiscountInterval.AmountDiscountInterval - .builder() - .amountDiscount("amount_discount") - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionPriceIntervalsResponse.DiscountInterval - .AmountDiscountInterval - .DiscountType - .AMOUNT - ) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addFixedFeeQuantitySchedule( - SubscriptionPriceIntervalsResponse.FixedFeeQuantitySchedule.builder() - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .priceId("price_id") - .quantity(0.0) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .invoicingThreshold("invoicing_threshold") - .addMaximumInterval( - SubscriptionPriceIntervalsResponse.MaximumInterval.builder() - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .maximumAmount("maximum_amount") - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .metadata( - SubscriptionPriceIntervalsResponse.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .addMinimumInterval( - SubscriptionPriceIntervalsResponse.MinimumInterval.builder() - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .minimumAmount("minimum_amount") - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .netTerms(0L) - .plan( - Plan.builder() - .id("id") - .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() - .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currency("currency") - .defaultInvoiceMemo("default_invoice_memo") - .description("description") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPlanId("external_plan_id") - .invoicingCurrency("invoicing_currency") - .maximum( - Plan.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Plan.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Plan.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .name("name") - .netTerms(0L) - .addPlanPhase( - Plan.PlanPhase.builder() - .id("id") - .description("description") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .duration(0L) - .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) - .maximum( - Plan.PlanPhase.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Plan.PlanPhase.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .name("name") - .order(0L) - .build() - ) - .addPrice( - Price.UnitPrice.builder() - .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) - .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY - ) - .build() - ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) - .conversionRate(0.0) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() - .allowsRollover(true) - .currency("currency") - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY - ) - .build() - ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) - .maximum( - Price.UnitPrice.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.UnitPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Price.UnitPrice.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) - .name("name") - .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) - .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) - .build() - ) - .product( - Plan.Product.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .name("name") - .build() - ) - .status(Plan.Status.ACTIVE) - .trialConfig( - Plan.TrialConfig.builder() - .trialPeriod(0L) - .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) - .build() - ) - .version(0L) - .build() - ) - .addPriceInterval( - SubscriptionPriceIntervalsResponse.PriceInterval.builder() - .id("id") - .billingCycleDay(0L) - .currentBillingPeriodEndDate( - OffsetDateTime.parse("2019-12-27T18:11:19.117Z") - ) - .currentBillingPeriodStartDate( - OffsetDateTime.parse("2019-12-27T18:11:19.117Z") - ) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .filter("filter") - .addFixedFeeQuantityTransition( - SubscriptionPriceIntervalsResponse.PriceInterval - .FixedFeeQuantityTransition - .builder() - .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .priceId("price_id") - .quantity(0L) - .build() - ) - .price( - Price.UnitPrice.builder() - .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) - .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY - ) - .build() - ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) - .conversionRate(0.0) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() - .allowsRollover(true) - .currency("currency") - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY - ) - .build() - ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) - .maximum( - Price.UnitPrice.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.UnitPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Price.UnitPrice.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) - .name("name") - .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) - .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) - .build() - ) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addUsageCustomerId("string") - .build() - ) - .redeemedCoupon( - SubscriptionPriceIntervalsResponse.RedeemedCoupon.builder() - .couponId("coupon_id") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .status(SubscriptionPriceIntervalsResponse.Status.ACTIVE) - .trialInfo( - SubscriptionPriceIntervalsResponse.TrialInfo.builder() - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .build() - assertThat(subscriptionPriceIntervalsResponse).isNotNull - assertThat(subscriptionPriceIntervalsResponse.id()).isEqualTo("id") - assertThat(subscriptionPriceIntervalsResponse.activePlanPhaseOrder()).contains(0L) - assertThat(subscriptionPriceIntervalsResponse.adjustmentIntervals()) - .containsExactly( - SubscriptionPriceIntervalsResponse.AdjustmentInterval.builder() - .id("id") - .adjustment( - SubscriptionPriceIntervalsResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .builder() - .id("id") - .adjustmentType( - SubscriptionPriceIntervalsResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionPriceIntervalsResponse.autoCollection()).contains(true) - assertThat(subscriptionPriceIntervalsResponse.billingCycleAnchorConfiguration()) - .isEqualTo( - SubscriptionPriceIntervalsResponse.BillingCycleAnchorConfiguration.builder() - .day(1L) - .month(1L) - .year(0L) - .build() - ) - assertThat(subscriptionPriceIntervalsResponse.billingCycleDay()).isEqualTo(1L) - assertThat(subscriptionPriceIntervalsResponse.createdAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionPriceIntervalsResponse.currentBillingPeriodEndDate()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionPriceIntervalsResponse.currentBillingPeriodStartDate()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionPriceIntervalsResponse.customer()) - .isEqualTo( - Customer.builder() - .id("id") - .addAdditionalEmail("string") - .autoCollection(true) - .balance("balance") - .billingAddress( - Customer.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currency("currency") - .email("email") - .emailDelivery(true) - .exemptFromAutomatedTax(true) - .externalCustomerId("external_customer_id") - .hierarchy( - Customer.Hierarchy.builder() - .addChild( - Customer.Hierarchy.Child.builder() - .id("id") - .externalCustomerId("external_customer_id") - .build() - ) - .parent( - Customer.Hierarchy.Parent.builder() - .id("id") - .externalCustomerId("external_customer_id") - .build() - ) - .build() - ) - .metadata( - Customer.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .name("name") - .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) - .paymentProviderId("payment_provider_id") - .portalUrl("portal_url") - .shippingAddress( - Customer.ShippingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .taxId( - Customer.TaxId.builder() - .country(Customer.TaxId.Country.AD) - .type(Customer.TaxId.Type.AD_NRT) - .value("value") - .build() - ) - .timezone("timezone") - .accountingSyncConfiguration( - Customer.AccountingSyncConfiguration.builder() - .addAccountingProvider( - Customer.AccountingSyncConfiguration.AccountingProvider.builder() - .externalProviderId("external_provider_id") - .providerType( - Customer.AccountingSyncConfiguration.AccountingProvider - .ProviderType - .QUICKBOOKS - ) - .build() - ) - .excluded(true) - .build() - ) - .reportingConfiguration( - Customer.ReportingConfiguration.builder().exempt(true).build() - ) - .build() - ) - assertThat(subscriptionPriceIntervalsResponse.defaultInvoiceMemo()) - .contains("default_invoice_memo") - assertThat(subscriptionPriceIntervalsResponse.discountIntervals()) - .containsExactly( - SubscriptionPriceIntervalsResponse.DiscountInterval.ofAmount( - SubscriptionPriceIntervalsResponse.DiscountInterval.AmountDiscountInterval - .builder() - .amountDiscount("amount_discount") - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionPriceIntervalsResponse.DiscountInterval - .AmountDiscountInterval - .DiscountType - .AMOUNT - ) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - ) - assertThat(subscriptionPriceIntervalsResponse.endDate()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionPriceIntervalsResponse.fixedFeeQuantitySchedule()) - .containsExactly( - SubscriptionPriceIntervalsResponse.FixedFeeQuantitySchedule.builder() - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .priceId("price_id") - .quantity(0.0) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionPriceIntervalsResponse.invoicingThreshold()) - .contains("invoicing_threshold") - assertThat(subscriptionPriceIntervalsResponse.maximumIntervals()) - .containsExactly( - SubscriptionPriceIntervalsResponse.MaximumInterval.builder() - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .maximumAmount("maximum_amount") - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionPriceIntervalsResponse.metadata()) - .isEqualTo( - SubscriptionPriceIntervalsResponse.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - assertThat(subscriptionPriceIntervalsResponse.minimumIntervals()) - .containsExactly( - SubscriptionPriceIntervalsResponse.MinimumInterval.builder() - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .minimumAmount("minimum_amount") - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionPriceIntervalsResponse.netTerms()).isEqualTo(0L) - assertThat(subscriptionPriceIntervalsResponse.plan()) - .isEqualTo( - Plan.builder() - .id("id") - .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() - .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currency("currency") - .defaultInvoiceMemo("default_invoice_memo") - .description("description") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPlanId("external_plan_id") - .invoicingCurrency("invoicing_currency") - .maximum( - Plan.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Plan.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Plan.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .name("name") - .netTerms(0L) - .addPlanPhase( - Plan.PlanPhase.builder() - .id("id") - .description("description") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .duration(0L) - .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) - .maximum( - Plan.PlanPhase.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Plan.PlanPhase.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .name("name") - .order(0L) - .build() - ) - .addPrice( - Price.UnitPrice.builder() - .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) - .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY - ) - .build() - ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) - .conversionRate(0.0) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() - .allowsRollover(true) - .currency("currency") - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY - ) - .build() - ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) - .maximum( - Price.UnitPrice.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.UnitPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Price.UnitPrice.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) - .name("name") - .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) - .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) - .build() - ) - .product( - Plan.Product.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .name("name") - .build() - ) - .status(Plan.Status.ACTIVE) - .trialConfig( - Plan.TrialConfig.builder() - .trialPeriod(0L) - .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) - .build() - ) - .version(0L) - .build() - ) - assertThat(subscriptionPriceIntervalsResponse.priceIntervals()) - .containsExactly( - SubscriptionPriceIntervalsResponse.PriceInterval.builder() - .id("id") - .billingCycleDay(0L) - .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .filter("filter") - .addFixedFeeQuantityTransition( - SubscriptionPriceIntervalsResponse.PriceInterval.FixedFeeQuantityTransition - .builder() - .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .priceId("price_id") - .quantity(0L) - .build() - ) - .price( - Price.UnitPrice.builder() - .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) - .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY - ) - .build() - ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) - .conversionRate(0.0) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() - .allowsRollover(true) - .currency("currency") - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY - ) - .build() - ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) - .maximum( - Price.UnitPrice.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.UnitPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Price.UnitPrice.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) - .name("name") - .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) - .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) - .build() - ) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addUsageCustomerId("string") - .build() - ) - assertThat(subscriptionPriceIntervalsResponse.redeemedCoupon()) - .contains( - SubscriptionPriceIntervalsResponse.RedeemedCoupon.builder() - .couponId("coupon_id") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionPriceIntervalsResponse.startDate()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionPriceIntervalsResponse.status()) - .isEqualTo(SubscriptionPriceIntervalsResponse.Status.ACTIVE) - assertThat(subscriptionPriceIntervalsResponse.trialInfo()) - .isEqualTo( - SubscriptionPriceIntervalsResponse.TrialInfo.builder() - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .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 d7a31cb18..c37d3168b 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 @@ -16,15 +16,11 @@ class SubscriptionSchedulePlanChangeParamsTest { .subscriptionId("subscription_id") .changeOption(SubscriptionSchedulePlanChangeParams.ChangeOption.REQUESTED_DATE) .addAddAdjustment( - SubscriptionSchedulePlanChangeParams.AddAdjustment.builder() + AddSubscriptionAdjustmentParams.builder() .adjustment( - SubscriptionSchedulePlanChangeParams.AddAdjustment.Adjustment - .NewPercentageDiscount - .builder() + NewAdjustmentModel.NewPercentageDiscount.builder() .adjustmentType( - SubscriptionSchedulePlanChangeParams.AddAdjustment.Adjustment - .NewPercentageDiscount - .AdjustmentType + NewAdjustmentModel.NewPercentageDiscount.AdjustmentType .PERCENTAGE_DISCOUNT ) .addAppliesToPriceId("price_1") @@ -39,25 +35,18 @@ class SubscriptionSchedulePlanChangeParamsTest { .build() ) .addAddPrice( - SubscriptionSchedulePlanChangeParams.AddPrice.builder() + AddSubscriptionPriceParams.builder() .allocationPrice( - SubscriptionSchedulePlanChangeParams.AddPrice.AllocationPrice.builder() + NewAllocationPriceModel.builder() .amount("10.00") - .cadence( - SubscriptionSchedulePlanChangeParams.AddPrice.AllocationPrice - .Cadence - .ONE_TIME - ) + .cadence(NewAllocationPriceModel.Cadence.ONE_TIME) .currency("USD") .expiresAtEndOfCadence(true) .build() ) .addDiscount( - SubscriptionSchedulePlanChangeParams.AddPrice.Discount.builder() - .discountType( - SubscriptionSchedulePlanChangeParams.AddPrice.Discount.DiscountType - .PERCENTAGE - ) + DiscountOverrideModel.builder() + .discountType(DiscountOverrideModel.DiscountType.PERCENTAGE) .amountDiscount("amount_discount") .percentageDiscount(0.15) .usageDiscount(0.0) @@ -69,44 +58,23 @@ class SubscriptionSchedulePlanChangeParamsTest { .minimumAmount("1.23") .planPhaseOrder(0L) .price( - SubscriptionSchedulePlanChangeParams.AddPrice.Price.NewSubscriptionUnitPrice - .builder() + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.builder() .cadence( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .Cadence - .ANNUAL + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Cadence.ANNUAL ) .itemId("item_id") .modelType( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .ModelType - .UNIT + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.ModelType.UNIT ) .name("Annual fee") - .unitConfig( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .UnitConfig - .builder() - .unitAmount("unit_amount") - .build() - ) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .BillingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .BillingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) @@ -116,24 +84,15 @@ class SubscriptionSchedulePlanChangeParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) .metadata( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .Metadata + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -151,11 +110,7 @@ class SubscriptionSchedulePlanChangeParamsTest { SubscriptionSchedulePlanChangeParams.BillingCycleAlignment.UNCHANGED ) .billingCycleAnchorConfiguration( - SubscriptionSchedulePlanChangeParams.BillingCycleAnchorConfiguration.builder() - .day(1L) - .month(1L) - .year(0L) - .build() + BillingCycleAnchorConfigurationModel.builder().day(1L).month(1L).year(0L).build() ) .changeDate(OffsetDateTime.parse("2017-07-21T17:32:28Z")) .couponRedemptionCode("coupon_redemption_code") @@ -171,26 +126,22 @@ class SubscriptionSchedulePlanChangeParamsTest { .planVersionNumber(0L) .addPriceOverride(JsonValue.from(mapOf())) .addRemoveAdjustment( - SubscriptionSchedulePlanChangeParams.RemoveAdjustment.builder() + RemoveSubscriptionAdjustmentParams.builder() .adjustmentId("h74gfhdjvn7ujokd") .build() ) .addRemovePrice( - SubscriptionSchedulePlanChangeParams.RemovePrice.builder() + RemoveSubscriptionPriceParams.builder() .externalPriceId("external_price_id") .priceId("h74gfhdjvn7ujokd") .build() ) .addReplaceAdjustment( - SubscriptionSchedulePlanChangeParams.ReplaceAdjustment.builder() + ReplaceSubscriptionAdjustmentParams.builder() .adjustment( - SubscriptionSchedulePlanChangeParams.ReplaceAdjustment.Adjustment - .NewPercentageDiscount - .builder() + NewAdjustmentModel.NewPercentageDiscount.builder() .adjustmentType( - SubscriptionSchedulePlanChangeParams.ReplaceAdjustment.Adjustment - .NewPercentageDiscount - .AdjustmentType + NewAdjustmentModel.NewPercentageDiscount.AdjustmentType .PERCENTAGE_DISCOUNT ) .addAppliesToPriceId("price_1") @@ -203,27 +154,19 @@ class SubscriptionSchedulePlanChangeParamsTest { .build() ) .addReplacePrice( - SubscriptionSchedulePlanChangeParams.ReplacePrice.builder() + ReplaceSubscriptionPriceParams.builder() .replacesPriceId("replaces_price_id") .allocationPrice( - SubscriptionSchedulePlanChangeParams.ReplacePrice.AllocationPrice.builder() + NewAllocationPriceModel.builder() .amount("10.00") - .cadence( - SubscriptionSchedulePlanChangeParams.ReplacePrice.AllocationPrice - .Cadence - .ONE_TIME - ) + .cadence(NewAllocationPriceModel.Cadence.ONE_TIME) .currency("USD") .expiresAtEndOfCadence(true) .build() ) .addDiscount( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Discount.builder() - .discountType( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Discount - .DiscountType - .PERCENTAGE - ) + DiscountOverrideModel.builder() + .discountType(DiscountOverrideModel.DiscountType.PERCENTAGE) .amountDiscount("amount_discount") .percentageDiscount(0.15) .usageDiscount(0.0) @@ -234,45 +177,23 @@ class SubscriptionSchedulePlanChangeParamsTest { .maximumAmount("1.23") .minimumAmount("1.23") .price( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .builder() + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.builder() .cadence( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .Cadence - .ANNUAL + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Cadence.ANNUAL ) .itemId("item_id") .modelType( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .ModelType - .UNIT + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.ModelType.UNIT ) .name("Annual fee") - .unitConfig( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .UnitConfig - .builder() - .unitAmount("unit_amount") - .build() - ) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .BillingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .BillingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) @@ -282,24 +203,15 @@ class SubscriptionSchedulePlanChangeParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) .metadata( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .Metadata + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -322,15 +234,11 @@ class SubscriptionSchedulePlanChangeParamsTest { .subscriptionId("subscription_id") .changeOption(SubscriptionSchedulePlanChangeParams.ChangeOption.REQUESTED_DATE) .addAddAdjustment( - SubscriptionSchedulePlanChangeParams.AddAdjustment.builder() + AddSubscriptionAdjustmentParams.builder() .adjustment( - SubscriptionSchedulePlanChangeParams.AddAdjustment.Adjustment - .NewPercentageDiscount - .builder() + NewAdjustmentModel.NewPercentageDiscount.builder() .adjustmentType( - SubscriptionSchedulePlanChangeParams.AddAdjustment.Adjustment - .NewPercentageDiscount - .AdjustmentType + NewAdjustmentModel.NewPercentageDiscount.AdjustmentType .PERCENTAGE_DISCOUNT ) .addAppliesToPriceId("price_1") @@ -345,26 +253,18 @@ class SubscriptionSchedulePlanChangeParamsTest { .build() ) .addAddPrice( - SubscriptionSchedulePlanChangeParams.AddPrice.builder() + AddSubscriptionPriceParams.builder() .allocationPrice( - SubscriptionSchedulePlanChangeParams.AddPrice.AllocationPrice.builder() + NewAllocationPriceModel.builder() .amount("10.00") - .cadence( - SubscriptionSchedulePlanChangeParams.AddPrice.AllocationPrice - .Cadence - .ONE_TIME - ) + .cadence(NewAllocationPriceModel.Cadence.ONE_TIME) .currency("USD") .expiresAtEndOfCadence(true) .build() ) .addDiscount( - SubscriptionSchedulePlanChangeParams.AddPrice.Discount.builder() - .discountType( - SubscriptionSchedulePlanChangeParams.AddPrice.Discount - .DiscountType - .PERCENTAGE - ) + DiscountOverrideModel.builder() + .discountType(DiscountOverrideModel.DiscountType.PERCENTAGE) .amountDiscount("amount_discount") .percentageDiscount(0.15) .usageDiscount(0.0) @@ -376,45 +276,27 @@ class SubscriptionSchedulePlanChangeParamsTest { .minimumAmount("1.23") .planPhaseOrder(0L) .price( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .builder() + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.builder() .cadence( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .Cadence + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Cadence .ANNUAL ) .itemId("item_id") .modelType( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .ModelType + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.ModelType .UNIT ) .name("Annual fee") .unitConfig( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .UnitConfig - .builder() - .unitAmount("unit_amount") - .build() + UnitConfigModel.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .BillingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .BillingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) @@ -424,24 +306,15 @@ class SubscriptionSchedulePlanChangeParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) .metadata( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .Metadata + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -459,7 +332,7 @@ class SubscriptionSchedulePlanChangeParamsTest { SubscriptionSchedulePlanChangeParams.BillingCycleAlignment.UNCHANGED ) .billingCycleAnchorConfiguration( - SubscriptionSchedulePlanChangeParams.BillingCycleAnchorConfiguration.builder() + BillingCycleAnchorConfigurationModel.builder() .day(1L) .month(1L) .year(0L) @@ -479,27 +352,22 @@ class SubscriptionSchedulePlanChangeParamsTest { .planVersionNumber(0L) .addPriceOverride(JsonValue.from(mapOf())) .addRemoveAdjustment( - SubscriptionSchedulePlanChangeParams.RemoveAdjustment.builder() + RemoveSubscriptionAdjustmentParams.builder() .adjustmentId("h74gfhdjvn7ujokd") .build() ) .addRemovePrice( - SubscriptionSchedulePlanChangeParams.RemovePrice.builder() + RemoveSubscriptionPriceParams.builder() .externalPriceId("external_price_id") .priceId("h74gfhdjvn7ujokd") .build() ) .addReplaceAdjustment( - SubscriptionSchedulePlanChangeParams.ReplaceAdjustment.builder() + ReplaceSubscriptionAdjustmentParams.builder() .adjustment( - SubscriptionSchedulePlanChangeParams.ReplaceAdjustment.Adjustment - .NewPercentageDiscount - .builder() + NewAdjustmentModel.NewPercentageDiscount.builder() .adjustmentType( - SubscriptionSchedulePlanChangeParams.ReplaceAdjustment - .Adjustment - .NewPercentageDiscount - .AdjustmentType + NewAdjustmentModel.NewPercentageDiscount.AdjustmentType .PERCENTAGE_DISCOUNT ) .addAppliesToPriceId("price_1") @@ -512,29 +380,19 @@ class SubscriptionSchedulePlanChangeParamsTest { .build() ) .addReplacePrice( - SubscriptionSchedulePlanChangeParams.ReplacePrice.builder() + ReplaceSubscriptionPriceParams.builder() .replacesPriceId("replaces_price_id") .allocationPrice( - SubscriptionSchedulePlanChangeParams.ReplacePrice.AllocationPrice - .builder() + NewAllocationPriceModel.builder() .amount("10.00") - .cadence( - SubscriptionSchedulePlanChangeParams.ReplacePrice - .AllocationPrice - .Cadence - .ONE_TIME - ) + .cadence(NewAllocationPriceModel.Cadence.ONE_TIME) .currency("USD") .expiresAtEndOfCadence(true) .build() ) .addDiscount( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Discount.builder() - .discountType( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Discount - .DiscountType - .PERCENTAGE - ) + DiscountOverrideModel.builder() + .discountType(DiscountOverrideModel.DiscountType.PERCENTAGE) .amountDiscount("amount_discount") .percentageDiscount(0.15) .usageDiscount(0.0) @@ -545,45 +403,27 @@ class SubscriptionSchedulePlanChangeParamsTest { .maximumAmount("1.23") .minimumAmount("1.23") .price( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .builder() + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.builder() .cadence( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .Cadence + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Cadence .ANNUAL ) .itemId("item_id") .modelType( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .ModelType + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.ModelType .UNIT ) .name("Annual fee") .unitConfig( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .UnitConfig - .builder() - .unitAmount("unit_amount") - .build() + UnitConfigModel.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .BillingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .BillingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) @@ -593,24 +433,15 @@ class SubscriptionSchedulePlanChangeParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) .metadata( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .Metadata + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -633,15 +464,11 @@ class SubscriptionSchedulePlanChangeParamsTest { assertThat(body.addAdjustments()) .contains( listOf( - SubscriptionSchedulePlanChangeParams.AddAdjustment.builder() + AddSubscriptionAdjustmentParams.builder() .adjustment( - SubscriptionSchedulePlanChangeParams.AddAdjustment.Adjustment - .NewPercentageDiscount - .builder() + NewAdjustmentModel.NewPercentageDiscount.builder() .adjustmentType( - SubscriptionSchedulePlanChangeParams.AddAdjustment.Adjustment - .NewPercentageDiscount - .AdjustmentType + NewAdjustmentModel.NewPercentageDiscount.AdjustmentType .PERCENTAGE_DISCOUNT ) .addAppliesToPriceId("price_1") @@ -659,26 +486,18 @@ class SubscriptionSchedulePlanChangeParamsTest { assertThat(body.addPrices()) .contains( listOf( - SubscriptionSchedulePlanChangeParams.AddPrice.builder() + AddSubscriptionPriceParams.builder() .allocationPrice( - SubscriptionSchedulePlanChangeParams.AddPrice.AllocationPrice.builder() + NewAllocationPriceModel.builder() .amount("10.00") - .cadence( - SubscriptionSchedulePlanChangeParams.AddPrice.AllocationPrice - .Cadence - .ONE_TIME - ) + .cadence(NewAllocationPriceModel.Cadence.ONE_TIME) .currency("USD") .expiresAtEndOfCadence(true) .build() ) .addDiscount( - SubscriptionSchedulePlanChangeParams.AddPrice.Discount.builder() - .discountType( - SubscriptionSchedulePlanChangeParams.AddPrice.Discount - .DiscountType - .PERCENTAGE - ) + DiscountOverrideModel.builder() + .discountType(DiscountOverrideModel.DiscountType.PERCENTAGE) .amountDiscount("amount_discount") .percentageDiscount(0.15) .usageDiscount(0.0) @@ -690,45 +509,27 @@ class SubscriptionSchedulePlanChangeParamsTest { .minimumAmount("1.23") .planPhaseOrder(0L) .price( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .builder() + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.builder() .cadence( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .Cadence + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Cadence .ANNUAL ) .itemId("item_id") .modelType( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .ModelType + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.ModelType .UNIT ) .name("Annual fee") .unitConfig( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .UnitConfig - .builder() - .unitAmount("unit_amount") - .build() + UnitConfigModel.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .BillingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .BillingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) @@ -738,24 +539,15 @@ class SubscriptionSchedulePlanChangeParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) .metadata( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .Metadata + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -774,11 +566,7 @@ class SubscriptionSchedulePlanChangeParamsTest { .contains(SubscriptionSchedulePlanChangeParams.BillingCycleAlignment.UNCHANGED) assertThat(body.billingCycleAnchorConfiguration()) .contains( - SubscriptionSchedulePlanChangeParams.BillingCycleAnchorConfiguration.builder() - .day(1L) - .month(1L) - .year(0L) - .build() + BillingCycleAnchorConfigurationModel.builder().day(1L).month(1L).year(0L).build() ) assertThat(body.changeDate()).contains(OffsetDateTime.parse("2017-07-21T17:32:28Z")) assertThat(body.couponRedemptionCode()).contains("coupon_redemption_code") @@ -796,7 +584,7 @@ class SubscriptionSchedulePlanChangeParamsTest { assertThat(body.removeAdjustments()) .contains( listOf( - SubscriptionSchedulePlanChangeParams.RemoveAdjustment.builder() + RemoveSubscriptionAdjustmentParams.builder() .adjustmentId("h74gfhdjvn7ujokd") .build() ) @@ -804,7 +592,7 @@ class SubscriptionSchedulePlanChangeParamsTest { assertThat(body.removePrices()) .contains( listOf( - SubscriptionSchedulePlanChangeParams.RemovePrice.builder() + RemoveSubscriptionPriceParams.builder() .externalPriceId("external_price_id") .priceId("h74gfhdjvn7ujokd") .build() @@ -813,16 +601,11 @@ class SubscriptionSchedulePlanChangeParamsTest { assertThat(body.replaceAdjustments()) .contains( listOf( - SubscriptionSchedulePlanChangeParams.ReplaceAdjustment.builder() + ReplaceSubscriptionAdjustmentParams.builder() .adjustment( - SubscriptionSchedulePlanChangeParams.ReplaceAdjustment.Adjustment - .NewPercentageDiscount - .builder() + NewAdjustmentModel.NewPercentageDiscount.builder() .adjustmentType( - SubscriptionSchedulePlanChangeParams.ReplaceAdjustment - .Adjustment - .NewPercentageDiscount - .AdjustmentType + NewAdjustmentModel.NewPercentageDiscount.AdjustmentType .PERCENTAGE_DISCOUNT ) .addAppliesToPriceId("price_1") @@ -838,29 +621,19 @@ class SubscriptionSchedulePlanChangeParamsTest { assertThat(body.replacePrices()) .contains( listOf( - SubscriptionSchedulePlanChangeParams.ReplacePrice.builder() + ReplaceSubscriptionPriceParams.builder() .replacesPriceId("replaces_price_id") .allocationPrice( - SubscriptionSchedulePlanChangeParams.ReplacePrice.AllocationPrice - .builder() + NewAllocationPriceModel.builder() .amount("10.00") - .cadence( - SubscriptionSchedulePlanChangeParams.ReplacePrice - .AllocationPrice - .Cadence - .ONE_TIME - ) + .cadence(NewAllocationPriceModel.Cadence.ONE_TIME) .currency("USD") .expiresAtEndOfCadence(true) .build() ) .addDiscount( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Discount.builder() - .discountType( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Discount - .DiscountType - .PERCENTAGE - ) + DiscountOverrideModel.builder() + .discountType(DiscountOverrideModel.DiscountType.PERCENTAGE) .amountDiscount("amount_discount") .percentageDiscount(0.15) .usageDiscount(0.0) @@ -871,45 +644,27 @@ class SubscriptionSchedulePlanChangeParamsTest { .maximumAmount("1.23") .minimumAmount("1.23") .price( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .builder() + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.builder() .cadence( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .Cadence + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Cadence .ANNUAL ) .itemId("item_id") .modelType( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .ModelType + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.ModelType .UNIT ) .name("Annual fee") .unitConfig( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .UnitConfig - .builder() - .unitAmount("unit_amount") - .build() + UnitConfigModel.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .BillingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .BillingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) @@ -919,24 +674,15 @@ class SubscriptionSchedulePlanChangeParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) .metadata( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .Metadata + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeResponseTest.kt deleted file mode 100644 index 51f812816..000000000 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeResponseTest.kt +++ /dev/null @@ -1,1015 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.withorb.api.core.JsonValue -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class SubscriptionSchedulePlanChangeResponseTest { - - @Test - fun createSubscriptionSchedulePlanChangeResponse() { - val subscriptionSchedulePlanChangeResponse = - SubscriptionSchedulePlanChangeResponse.builder() - .id("id") - .activePlanPhaseOrder(0L) - .addAdjustmentInterval( - SubscriptionSchedulePlanChangeResponse.AdjustmentInterval.builder() - .id("id") - .adjustment( - SubscriptionSchedulePlanChangeResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .builder() - .id("id") - .adjustmentType( - SubscriptionSchedulePlanChangeResponse.AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .autoCollection(true) - .billingCycleAnchorConfiguration( - SubscriptionSchedulePlanChangeResponse.BillingCycleAnchorConfiguration.builder() - .day(1L) - .month(1L) - .year(0L) - .build() - ) - .billingCycleDay(1L) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .customer( - Customer.builder() - .id("id") - .addAdditionalEmail("string") - .autoCollection(true) - .balance("balance") - .billingAddress( - Customer.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currency("currency") - .email("email") - .emailDelivery(true) - .exemptFromAutomatedTax(true) - .externalCustomerId("external_customer_id") - .hierarchy( - Customer.Hierarchy.builder() - .addChild( - Customer.Hierarchy.Child.builder() - .id("id") - .externalCustomerId("external_customer_id") - .build() - ) - .parent( - Customer.Hierarchy.Parent.builder() - .id("id") - .externalCustomerId("external_customer_id") - .build() - ) - .build() - ) - .metadata( - Customer.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .name("name") - .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) - .paymentProviderId("payment_provider_id") - .portalUrl("portal_url") - .shippingAddress( - Customer.ShippingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .taxId( - Customer.TaxId.builder() - .country(Customer.TaxId.Country.AD) - .type(Customer.TaxId.Type.AD_NRT) - .value("value") - .build() - ) - .timezone("timezone") - .accountingSyncConfiguration( - Customer.AccountingSyncConfiguration.builder() - .addAccountingProvider( - Customer.AccountingSyncConfiguration.AccountingProvider - .builder() - .externalProviderId("external_provider_id") - .providerType( - Customer.AccountingSyncConfiguration.AccountingProvider - .ProviderType - .QUICKBOOKS - ) - .build() - ) - .excluded(true) - .build() - ) - .reportingConfiguration( - Customer.ReportingConfiguration.builder().exempt(true).build() - ) - .build() - ) - .defaultInvoiceMemo("default_invoice_memo") - .addDiscountInterval( - SubscriptionSchedulePlanChangeResponse.DiscountInterval.AmountDiscountInterval - .builder() - .amountDiscount("amount_discount") - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionSchedulePlanChangeResponse.DiscountInterval - .AmountDiscountInterval - .DiscountType - .AMOUNT - ) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addFixedFeeQuantitySchedule( - SubscriptionSchedulePlanChangeResponse.FixedFeeQuantitySchedule.builder() - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .priceId("price_id") - .quantity(0.0) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .invoicingThreshold("invoicing_threshold") - .addMaximumInterval( - SubscriptionSchedulePlanChangeResponse.MaximumInterval.builder() - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .maximumAmount("maximum_amount") - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .metadata( - SubscriptionSchedulePlanChangeResponse.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .addMinimumInterval( - SubscriptionSchedulePlanChangeResponse.MinimumInterval.builder() - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .minimumAmount("minimum_amount") - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .netTerms(0L) - .plan( - Plan.builder() - .id("id") - .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() - .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currency("currency") - .defaultInvoiceMemo("default_invoice_memo") - .description("description") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPlanId("external_plan_id") - .invoicingCurrency("invoicing_currency") - .maximum( - Plan.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Plan.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Plan.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .name("name") - .netTerms(0L) - .addPlanPhase( - Plan.PlanPhase.builder() - .id("id") - .description("description") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .duration(0L) - .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) - .maximum( - Plan.PlanPhase.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Plan.PlanPhase.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .name("name") - .order(0L) - .build() - ) - .addPrice( - Price.UnitPrice.builder() - .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) - .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY - ) - .build() - ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) - .conversionRate(0.0) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() - .allowsRollover(true) - .currency("currency") - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY - ) - .build() - ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) - .maximum( - Price.UnitPrice.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.UnitPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Price.UnitPrice.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) - .name("name") - .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) - .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) - .build() - ) - .product( - Plan.Product.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .name("name") - .build() - ) - .status(Plan.Status.ACTIVE) - .trialConfig( - Plan.TrialConfig.builder() - .trialPeriod(0L) - .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) - .build() - ) - .version(0L) - .build() - ) - .addPriceInterval( - SubscriptionSchedulePlanChangeResponse.PriceInterval.builder() - .id("id") - .billingCycleDay(0L) - .currentBillingPeriodEndDate( - OffsetDateTime.parse("2019-12-27T18:11:19.117Z") - ) - .currentBillingPeriodStartDate( - OffsetDateTime.parse("2019-12-27T18:11:19.117Z") - ) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .filter("filter") - .addFixedFeeQuantityTransition( - SubscriptionSchedulePlanChangeResponse.PriceInterval - .FixedFeeQuantityTransition - .builder() - .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .priceId("price_id") - .quantity(0L) - .build() - ) - .price( - Price.UnitPrice.builder() - .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) - .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY - ) - .build() - ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) - .conversionRate(0.0) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() - .allowsRollover(true) - .currency("currency") - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY - ) - .build() - ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) - .maximum( - Price.UnitPrice.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.UnitPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Price.UnitPrice.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) - .name("name") - .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) - .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) - .build() - ) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addUsageCustomerId("string") - .build() - ) - .redeemedCoupon( - SubscriptionSchedulePlanChangeResponse.RedeemedCoupon.builder() - .couponId("coupon_id") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .status(SubscriptionSchedulePlanChangeResponse.Status.ACTIVE) - .trialInfo( - SubscriptionSchedulePlanChangeResponse.TrialInfo.builder() - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .build() - assertThat(subscriptionSchedulePlanChangeResponse).isNotNull - assertThat(subscriptionSchedulePlanChangeResponse.id()).isEqualTo("id") - assertThat(subscriptionSchedulePlanChangeResponse.activePlanPhaseOrder()).contains(0L) - assertThat(subscriptionSchedulePlanChangeResponse.adjustmentIntervals()) - .containsExactly( - SubscriptionSchedulePlanChangeResponse.AdjustmentInterval.builder() - .id("id") - .adjustment( - SubscriptionSchedulePlanChangeResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .builder() - .id("id") - .adjustmentType( - SubscriptionSchedulePlanChangeResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionSchedulePlanChangeResponse.autoCollection()).contains(true) - assertThat(subscriptionSchedulePlanChangeResponse.billingCycleAnchorConfiguration()) - .isEqualTo( - SubscriptionSchedulePlanChangeResponse.BillingCycleAnchorConfiguration.builder() - .day(1L) - .month(1L) - .year(0L) - .build() - ) - assertThat(subscriptionSchedulePlanChangeResponse.billingCycleDay()).isEqualTo(1L) - assertThat(subscriptionSchedulePlanChangeResponse.createdAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionSchedulePlanChangeResponse.currentBillingPeriodEndDate()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionSchedulePlanChangeResponse.currentBillingPeriodStartDate()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionSchedulePlanChangeResponse.customer()) - .isEqualTo( - Customer.builder() - .id("id") - .addAdditionalEmail("string") - .autoCollection(true) - .balance("balance") - .billingAddress( - Customer.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currency("currency") - .email("email") - .emailDelivery(true) - .exemptFromAutomatedTax(true) - .externalCustomerId("external_customer_id") - .hierarchy( - Customer.Hierarchy.builder() - .addChild( - Customer.Hierarchy.Child.builder() - .id("id") - .externalCustomerId("external_customer_id") - .build() - ) - .parent( - Customer.Hierarchy.Parent.builder() - .id("id") - .externalCustomerId("external_customer_id") - .build() - ) - .build() - ) - .metadata( - Customer.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .name("name") - .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) - .paymentProviderId("payment_provider_id") - .portalUrl("portal_url") - .shippingAddress( - Customer.ShippingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .taxId( - Customer.TaxId.builder() - .country(Customer.TaxId.Country.AD) - .type(Customer.TaxId.Type.AD_NRT) - .value("value") - .build() - ) - .timezone("timezone") - .accountingSyncConfiguration( - Customer.AccountingSyncConfiguration.builder() - .addAccountingProvider( - Customer.AccountingSyncConfiguration.AccountingProvider.builder() - .externalProviderId("external_provider_id") - .providerType( - Customer.AccountingSyncConfiguration.AccountingProvider - .ProviderType - .QUICKBOOKS - ) - .build() - ) - .excluded(true) - .build() - ) - .reportingConfiguration( - Customer.ReportingConfiguration.builder().exempt(true).build() - ) - .build() - ) - assertThat(subscriptionSchedulePlanChangeResponse.defaultInvoiceMemo()) - .contains("default_invoice_memo") - assertThat(subscriptionSchedulePlanChangeResponse.discountIntervals()) - .containsExactly( - SubscriptionSchedulePlanChangeResponse.DiscountInterval.ofAmount( - SubscriptionSchedulePlanChangeResponse.DiscountInterval.AmountDiscountInterval - .builder() - .amountDiscount("amount_discount") - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionSchedulePlanChangeResponse.DiscountInterval - .AmountDiscountInterval - .DiscountType - .AMOUNT - ) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - ) - assertThat(subscriptionSchedulePlanChangeResponse.endDate()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionSchedulePlanChangeResponse.fixedFeeQuantitySchedule()) - .containsExactly( - SubscriptionSchedulePlanChangeResponse.FixedFeeQuantitySchedule.builder() - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .priceId("price_id") - .quantity(0.0) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionSchedulePlanChangeResponse.invoicingThreshold()) - .contains("invoicing_threshold") - assertThat(subscriptionSchedulePlanChangeResponse.maximumIntervals()) - .containsExactly( - SubscriptionSchedulePlanChangeResponse.MaximumInterval.builder() - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .maximumAmount("maximum_amount") - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionSchedulePlanChangeResponse.metadata()) - .isEqualTo( - SubscriptionSchedulePlanChangeResponse.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - assertThat(subscriptionSchedulePlanChangeResponse.minimumIntervals()) - .containsExactly( - SubscriptionSchedulePlanChangeResponse.MinimumInterval.builder() - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .minimumAmount("minimum_amount") - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionSchedulePlanChangeResponse.netTerms()).isEqualTo(0L) - assertThat(subscriptionSchedulePlanChangeResponse.plan()) - .isEqualTo( - Plan.builder() - .id("id") - .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() - .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currency("currency") - .defaultInvoiceMemo("default_invoice_memo") - .description("description") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPlanId("external_plan_id") - .invoicingCurrency("invoicing_currency") - .maximum( - Plan.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Plan.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Plan.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .name("name") - .netTerms(0L) - .addPlanPhase( - Plan.PlanPhase.builder() - .id("id") - .description("description") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .duration(0L) - .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) - .maximum( - Plan.PlanPhase.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Plan.PlanPhase.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .name("name") - .order(0L) - .build() - ) - .addPrice( - Price.UnitPrice.builder() - .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) - .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY - ) - .build() - ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) - .conversionRate(0.0) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() - .allowsRollover(true) - .currency("currency") - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY - ) - .build() - ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) - .maximum( - Price.UnitPrice.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.UnitPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Price.UnitPrice.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) - .name("name") - .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) - .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) - .build() - ) - .product( - Plan.Product.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .name("name") - .build() - ) - .status(Plan.Status.ACTIVE) - .trialConfig( - Plan.TrialConfig.builder() - .trialPeriod(0L) - .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) - .build() - ) - .version(0L) - .build() - ) - assertThat(subscriptionSchedulePlanChangeResponse.priceIntervals()) - .containsExactly( - SubscriptionSchedulePlanChangeResponse.PriceInterval.builder() - .id("id") - .billingCycleDay(0L) - .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .filter("filter") - .addFixedFeeQuantityTransition( - SubscriptionSchedulePlanChangeResponse.PriceInterval - .FixedFeeQuantityTransition - .builder() - .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .priceId("price_id") - .quantity(0L) - .build() - ) - .price( - Price.UnitPrice.builder() - .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) - .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY - ) - .build() - ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) - .conversionRate(0.0) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() - .allowsRollover(true) - .currency("currency") - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY - ) - .build() - ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) - .maximum( - Price.UnitPrice.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.UnitPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Price.UnitPrice.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) - .name("name") - .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) - .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) - .build() - ) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addUsageCustomerId("string") - .build() - ) - assertThat(subscriptionSchedulePlanChangeResponse.redeemedCoupon()) - .contains( - SubscriptionSchedulePlanChangeResponse.RedeemedCoupon.builder() - .couponId("coupon_id") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionSchedulePlanChangeResponse.startDate()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionSchedulePlanChangeResponse.status()) - .isEqualTo(SubscriptionSchedulePlanChangeResponse.Status.ACTIVE) - assertThat(subscriptionSchedulePlanChangeResponse.trialInfo()) - .isEqualTo( - SubscriptionSchedulePlanChangeResponse.TrialInfo.builder() - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - } -} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionTest.kt index c09503dc8..f3fb7273c 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 @@ -16,17 +16,13 @@ class SubscriptionTest { .id("id") .activePlanPhaseOrder(0L) .addAdjustmentInterval( - Subscription.AdjustmentInterval.builder() + AdjustmentIntervalModel.builder() .id("id") .adjustment( - Subscription.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .builder() + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.builder() .id("id") .adjustmentType( - Subscription.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.AdjustmentType .USAGE_DISCOUNT ) .addAppliesToPriceId("string") @@ -43,7 +39,7 @@ class SubscriptionTest { ) .autoCollection(true) .billingCycleAnchorConfiguration( - Subscription.BillingCycleAnchorConfiguration.builder() + BillingCycleAnchorConfigurationModel.builder() .day(1L) .month(1L) .year(0L) @@ -54,13 +50,13 @@ class SubscriptionTest { .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customer( - Customer.builder() + CustomerModel.builder() .id("id") .addAdditionalEmail("string") .autoCollection(true) .balance("balance") .billingAddress( - Customer.BillingAddress.builder() + AddressModel.builder() .city("city") .country("country") .line1("line1") @@ -76,15 +72,15 @@ class SubscriptionTest { .exemptFromAutomatedTax(true) .externalCustomerId("external_customer_id") .hierarchy( - Customer.Hierarchy.builder() + CustomerModel.Hierarchy.builder() .addChild( - Customer.Hierarchy.Child.builder() + CustomerMinifiedModel.builder() .id("id") .externalCustomerId("external_customer_id") .build() ) .parent( - Customer.Hierarchy.Parent.builder() + CustomerMinifiedModel.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -92,16 +88,16 @@ class SubscriptionTest { .build() ) .metadata( - Customer.Metadata.builder() + CustomerModel.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .name("name") - .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) + .paymentProvider(CustomerModel.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .portalUrl("portal_url") .shippingAddress( - Customer.ShippingAddress.builder() + AddressModel.builder() .city("city") .country("country") .line1("line1") @@ -111,21 +107,22 @@ class SubscriptionTest { .build() ) .taxId( - Customer.TaxId.builder() - .country(Customer.TaxId.Country.AD) - .type(Customer.TaxId.Type.AD_NRT) + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) .value("value") .build() ) .timezone("timezone") .accountingSyncConfiguration( - Customer.AccountingSyncConfiguration.builder() + CustomerModel.AccountingSyncConfiguration.builder() .addAccountingProvider( - Customer.AccountingSyncConfiguration.AccountingProvider + CustomerModel.AccountingSyncConfiguration.AccountingProvider .builder() .externalProviderId("external_provider_id") .providerType( - Customer.AccountingSyncConfiguration.AccountingProvider + CustomerModel.AccountingSyncConfiguration + .AccountingProvider .ProviderType .QUICKBOOKS ) @@ -135,26 +132,24 @@ class SubscriptionTest { .build() ) .reportingConfiguration( - Customer.ReportingConfiguration.builder().exempt(true).build() + CustomerModel.ReportingConfiguration.builder().exempt(true).build() ) .build() ) .defaultInvoiceMemo("default_invoice_memo") .addDiscountInterval( - Subscription.DiscountInterval.AmountDiscountInterval.builder() + AmountDiscountIntervalModel.builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - Subscription.DiscountInterval.AmountDiscountInterval.DiscountType.AMOUNT - ) + .discountType(AmountDiscountIntervalModel.DiscountType.AMOUNT) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFixedFeeQuantitySchedule( - Subscription.FixedFeeQuantitySchedule.builder() + FixedFeeQuantityScheduleEntryModel.builder() .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .priceId("price_id") .quantity(0.0) @@ -163,7 +158,7 @@ class SubscriptionTest { ) .invoicingThreshold("invoicing_threshold") .addMaximumInterval( - Subscription.MaximumInterval.builder() + MaximumIntervalModel.builder() .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -177,7 +172,7 @@ class SubscriptionTest { .build() ) .addMinimumInterval( - Subscription.MinimumInterval.builder() + MinimumIntervalModel.builder() .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -187,13 +182,13 @@ class SubscriptionTest { ) .netTerms(0L) .plan( - Plan.builder() + PlanModel.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.builder() .id("id") .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.AdjustmentType .USAGE_DISCOUNT ) .addAppliesToPriceId("string") @@ -204,7 +199,7 @@ class SubscriptionTest { .build() ) .basePlan( - Plan.BasePlan.builder() + PlanMinifiedModel.builder() .id("m2t5akQeh2obwxeU") .externalPlanId("m2t5akQeh2obwxeU") .name("Example plan") @@ -227,19 +222,19 @@ class SubscriptionTest { .externalPlanId("external_plan_id") .invoicingCurrency("invoicing_currency") .maximum( - Plan.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Plan.Metadata.builder() + PlanModel.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Plan.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() @@ -248,7 +243,7 @@ class SubscriptionTest { .name("name") .netTerms(0L) .addPlanPhase( - Plan.PlanPhase.builder() + PlanModel.PlanPhase.builder() .id("id") .description("description") .discount( @@ -261,16 +256,16 @@ class SubscriptionTest { .build() ) .duration(0L) - .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .durationUnit(PlanModel.PlanPhase.DurationUnit.DAILY) .maximum( - Plan.PlanPhase.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .minimum( - Plan.PlanPhase.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() @@ -281,25 +276,22 @@ class SubscriptionTest { .build() ) .addPrice( - Price.UnitPrice.builder() + PriceModel.UnitPrice.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(BillableMetricTinyModel.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + BillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + AllocationModel.builder() .allowsRollover(true) .currency("currency") .build() @@ -317,45 +309,42 @@ class SubscriptionTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + BillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(ItemSlimModel.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + PriceModel.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) + .modelType(PriceModel.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() + UnitConfigModel.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + DimensionalPriceConfigurationModel.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -363,24 +352,24 @@ class SubscriptionTest { .build() ) .product( - Plan.Product.builder() + PlanModel.Product.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .name("name") .build() ) - .status(Plan.Status.ACTIVE) + .status(PlanModel.Status.ACTIVE) .trialConfig( - Plan.TrialConfig.builder() + PlanModel.TrialConfig.builder() .trialPeriod(0L) - .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .trialPeriodUnit(PlanModel.TrialConfig.TrialPeriodUnit.DAYS) .build() ) .version(0L) .build() ) .addPriceInterval( - Subscription.PriceInterval.builder() + PriceIntervalModel.builder() .id("id") .billingCycleDay(0L) .currentBillingPeriodEndDate( @@ -392,32 +381,29 @@ class SubscriptionTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .filter("filter") .addFixedFeeQuantityTransition( - Subscription.PriceInterval.FixedFeeQuantityTransition.builder() + PriceIntervalModel.FixedFeeQuantityTransition.builder() .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .priceId("price_id") .quantity(0L) .build() ) .price( - Price.UnitPrice.builder() + PriceModel.UnitPrice.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(BillableMetricTinyModel.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + BillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + AllocationModel.builder() .allowsRollover(true) .currency("currency") .build() @@ -435,45 +421,42 @@ class SubscriptionTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + BillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(ItemSlimModel.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + PriceModel.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) + .modelType(PriceModel.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() + UnitConfigModel.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + DimensionalPriceConfigurationModel.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -485,7 +468,7 @@ class SubscriptionTest { .build() ) .redeemedCoupon( - Subscription.RedeemedCoupon.builder() + CouponRedemptionModel.builder() .couponId("coupon_id") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -494,7 +477,7 @@ class SubscriptionTest { .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .status(Subscription.Status.ACTIVE) .trialInfo( - Subscription.TrialInfo.builder() + SubscriptionTrialInfoModel.builder() .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) @@ -504,16 +487,13 @@ class SubscriptionTest { assertThat(subscription.activePlanPhaseOrder()).contains(0L) assertThat(subscription.adjustmentIntervals()) .containsExactly( - Subscription.AdjustmentInterval.builder() + AdjustmentIntervalModel.builder() .id("id") .adjustment( - Subscription.AdjustmentInterval.Adjustment.PlanPhaseUsageDiscountAdjustment - .builder() + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.builder() .id("id") .adjustmentType( - Subscription.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.AdjustmentType .USAGE_DISCOUNT ) .addAppliesToPriceId("string") @@ -531,11 +511,7 @@ class SubscriptionTest { assertThat(subscription.autoCollection()).contains(true) assertThat(subscription.billingCycleAnchorConfiguration()) .isEqualTo( - Subscription.BillingCycleAnchorConfiguration.builder() - .day(1L) - .month(1L) - .year(0L) - .build() + BillingCycleAnchorConfigurationModel.builder().day(1L).month(1L).year(0L).build() ) assertThat(subscription.billingCycleDay()).isEqualTo(1L) assertThat(subscription.createdAt()) @@ -546,13 +522,13 @@ class SubscriptionTest { .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(subscription.customer()) .isEqualTo( - Customer.builder() + CustomerModel.builder() .id("id") .addAdditionalEmail("string") .autoCollection(true) .balance("balance") .billingAddress( - Customer.BillingAddress.builder() + AddressModel.builder() .city("city") .country("country") .line1("line1") @@ -568,15 +544,15 @@ class SubscriptionTest { .exemptFromAutomatedTax(true) .externalCustomerId("external_customer_id") .hierarchy( - Customer.Hierarchy.builder() + CustomerModel.Hierarchy.builder() .addChild( - Customer.Hierarchy.Child.builder() + CustomerMinifiedModel.builder() .id("id") .externalCustomerId("external_customer_id") .build() ) .parent( - Customer.Hierarchy.Parent.builder() + CustomerMinifiedModel.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -584,16 +560,16 @@ class SubscriptionTest { .build() ) .metadata( - Customer.Metadata.builder() + CustomerModel.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .name("name") - .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) + .paymentProvider(CustomerModel.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .portalUrl("portal_url") .shippingAddress( - Customer.ShippingAddress.builder() + AddressModel.builder() .city("city") .country("country") .line1("line1") @@ -603,20 +579,21 @@ class SubscriptionTest { .build() ) .taxId( - Customer.TaxId.builder() - .country(Customer.TaxId.Country.AD) - .type(Customer.TaxId.Type.AD_NRT) + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) .value("value") .build() ) .timezone("timezone") .accountingSyncConfiguration( - Customer.AccountingSyncConfiguration.builder() + CustomerModel.AccountingSyncConfiguration.builder() .addAccountingProvider( - Customer.AccountingSyncConfiguration.AccountingProvider.builder() + CustomerModel.AccountingSyncConfiguration.AccountingProvider + .builder() .externalProviderId("external_provider_id") .providerType( - Customer.AccountingSyncConfiguration.AccountingProvider + CustomerModel.AccountingSyncConfiguration.AccountingProvider .ProviderType .QUICKBOOKS ) @@ -626,21 +603,19 @@ class SubscriptionTest { .build() ) .reportingConfiguration( - Customer.ReportingConfiguration.builder().exempt(true).build() + CustomerModel.ReportingConfiguration.builder().exempt(true).build() ) .build() ) assertThat(subscription.defaultInvoiceMemo()).contains("default_invoice_memo") assertThat(subscription.discountIntervals()) .containsExactly( - Subscription.DiscountInterval.ofAmount( - Subscription.DiscountInterval.AmountDiscountInterval.builder() + Subscription.DiscountInterval.ofAmountDiscountIntervalModel( + AmountDiscountIntervalModel.builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - Subscription.DiscountInterval.AmountDiscountInterval.DiscountType.AMOUNT - ) + .discountType(AmountDiscountIntervalModel.DiscountType.AMOUNT) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -650,7 +625,7 @@ class SubscriptionTest { .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(subscription.fixedFeeQuantitySchedule()) .containsExactly( - Subscription.FixedFeeQuantitySchedule.builder() + FixedFeeQuantityScheduleEntryModel.builder() .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .priceId("price_id") .quantity(0.0) @@ -660,7 +635,7 @@ class SubscriptionTest { assertThat(subscription.invoicingThreshold()).contains("invoicing_threshold") assertThat(subscription.maximumIntervals()) .containsExactly( - Subscription.MaximumInterval.builder() + MaximumIntervalModel.builder() .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -676,7 +651,7 @@ class SubscriptionTest { ) assertThat(subscription.minimumIntervals()) .containsExactly( - Subscription.MinimumInterval.builder() + MinimumIntervalModel.builder() .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -687,13 +662,13 @@ class SubscriptionTest { assertThat(subscription.netTerms()).isEqualTo(0L) assertThat(subscription.plan()) .isEqualTo( - Plan.builder() + PlanModel.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.builder() .id("id") .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.AdjustmentType .USAGE_DISCOUNT ) .addAppliesToPriceId("string") @@ -704,7 +679,7 @@ class SubscriptionTest { .build() ) .basePlan( - Plan.BasePlan.builder() + PlanMinifiedModel.builder() .id("m2t5akQeh2obwxeU") .externalPlanId("m2t5akQeh2obwxeU") .name("Example plan") @@ -727,19 +702,19 @@ class SubscriptionTest { .externalPlanId("external_plan_id") .invoicingCurrency("invoicing_currency") .maximum( - Plan.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Plan.Metadata.builder() + PlanModel.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Plan.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() @@ -748,7 +723,7 @@ class SubscriptionTest { .name("name") .netTerms(0L) .addPlanPhase( - Plan.PlanPhase.builder() + PlanModel.PlanPhase.builder() .id("id") .description("description") .discount( @@ -761,16 +736,16 @@ class SubscriptionTest { .build() ) .duration(0L) - .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .durationUnit(PlanModel.PlanPhase.DurationUnit.DAILY) .maximum( - Plan.PlanPhase.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .minimum( - Plan.PlanPhase.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() @@ -781,24 +756,20 @@ class SubscriptionTest { .build() ) .addPrice( - Price.UnitPrice.builder() + PriceModel.UnitPrice.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(BillableMetricTinyModel.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(BillingCycleConfigurationModel.DurationUnit.DAY) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + AllocationModel.builder() .allowsRollover(true) .currency("currency") .build() @@ -816,44 +787,38 @@ class SubscriptionTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(BillingCycleConfigurationModel.DurationUnit.DAY) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(ItemSlimModel.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + PriceModel.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) + .modelType(PriceModel.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + DimensionalPriceConfigurationModel.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -861,17 +826,17 @@ class SubscriptionTest { .build() ) .product( - Plan.Product.builder() + PlanModel.Product.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .name("name") .build() ) - .status(Plan.Status.ACTIVE) + .status(PlanModel.Status.ACTIVE) .trialConfig( - Plan.TrialConfig.builder() + PlanModel.TrialConfig.builder() .trialPeriod(0L) - .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .trialPeriodUnit(PlanModel.TrialConfig.TrialPeriodUnit.DAYS) .build() ) .version(0L) @@ -879,7 +844,7 @@ class SubscriptionTest { ) assertThat(subscription.priceIntervals()) .containsExactly( - Subscription.PriceInterval.builder() + PriceIntervalModel.builder() .id("id") .billingCycleDay(0L) .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -887,31 +852,27 @@ class SubscriptionTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .filter("filter") .addFixedFeeQuantityTransition( - Subscription.PriceInterval.FixedFeeQuantityTransition.builder() + PriceIntervalModel.FixedFeeQuantityTransition.builder() .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .priceId("price_id") .quantity(0L) .build() ) .price( - Price.UnitPrice.builder() + PriceModel.UnitPrice.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(BillableMetricTinyModel.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(BillingCycleConfigurationModel.DurationUnit.DAY) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + AllocationModel.builder() .allowsRollover(true) .currency("currency") .build() @@ -929,44 +890,38 @@ class SubscriptionTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(BillingCycleConfigurationModel.DurationUnit.DAY) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(ItemSlimModel.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + PriceModel.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) + .modelType(PriceModel.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + DimensionalPriceConfigurationModel.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -979,7 +934,7 @@ class SubscriptionTest { ) assertThat(subscription.redeemedCoupon()) .contains( - Subscription.RedeemedCoupon.builder() + CouponRedemptionModel.builder() .couponId("coupon_id") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -990,7 +945,7 @@ class SubscriptionTest { assertThat(subscription.status()).isEqualTo(Subscription.Status.ACTIVE) assertThat(subscription.trialInfo()) .isEqualTo( - Subscription.TrialInfo.builder() + SubscriptionTrialInfoModel.builder() .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionTrialInfoModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionTrialInfoModelTest.kt new file mode 100644 index 000000000..eb92001cd --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionTrialInfoModelTest.kt @@ -0,0 +1,21 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class SubscriptionTrialInfoModelTest { + + @Test + fun createSubscriptionTrialInfoModel() { + val subscriptionTrialInfoModel = + SubscriptionTrialInfoModel.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + assertThat(subscriptionTrialInfoModel).isNotNull + assertThat(subscriptionTrialInfoModel.endDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseResponseTest.kt deleted file mode 100644 index d1b4a26bf..000000000 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseResponseTest.kt +++ /dev/null @@ -1,1011 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.withorb.api.core.JsonValue -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class SubscriptionTriggerPhaseResponseTest { - - @Test - fun createSubscriptionTriggerPhaseResponse() { - val subscriptionTriggerPhaseResponse = - SubscriptionTriggerPhaseResponse.builder() - .id("id") - .activePlanPhaseOrder(0L) - .addAdjustmentInterval( - SubscriptionTriggerPhaseResponse.AdjustmentInterval.builder() - .id("id") - .adjustment( - SubscriptionTriggerPhaseResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .builder() - .id("id") - .adjustmentType( - SubscriptionTriggerPhaseResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .autoCollection(true) - .billingCycleAnchorConfiguration( - SubscriptionTriggerPhaseResponse.BillingCycleAnchorConfiguration.builder() - .day(1L) - .month(1L) - .year(0L) - .build() - ) - .billingCycleDay(1L) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .customer( - Customer.builder() - .id("id") - .addAdditionalEmail("string") - .autoCollection(true) - .balance("balance") - .billingAddress( - Customer.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currency("currency") - .email("email") - .emailDelivery(true) - .exemptFromAutomatedTax(true) - .externalCustomerId("external_customer_id") - .hierarchy( - Customer.Hierarchy.builder() - .addChild( - Customer.Hierarchy.Child.builder() - .id("id") - .externalCustomerId("external_customer_id") - .build() - ) - .parent( - Customer.Hierarchy.Parent.builder() - .id("id") - .externalCustomerId("external_customer_id") - .build() - ) - .build() - ) - .metadata( - Customer.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .name("name") - .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) - .paymentProviderId("payment_provider_id") - .portalUrl("portal_url") - .shippingAddress( - Customer.ShippingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .taxId( - Customer.TaxId.builder() - .country(Customer.TaxId.Country.AD) - .type(Customer.TaxId.Type.AD_NRT) - .value("value") - .build() - ) - .timezone("timezone") - .accountingSyncConfiguration( - Customer.AccountingSyncConfiguration.builder() - .addAccountingProvider( - Customer.AccountingSyncConfiguration.AccountingProvider - .builder() - .externalProviderId("external_provider_id") - .providerType( - Customer.AccountingSyncConfiguration.AccountingProvider - .ProviderType - .QUICKBOOKS - ) - .build() - ) - .excluded(true) - .build() - ) - .reportingConfiguration( - Customer.ReportingConfiguration.builder().exempt(true).build() - ) - .build() - ) - .defaultInvoiceMemo("default_invoice_memo") - .addDiscountInterval( - SubscriptionTriggerPhaseResponse.DiscountInterval.AmountDiscountInterval - .builder() - .amountDiscount("amount_discount") - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionTriggerPhaseResponse.DiscountInterval.AmountDiscountInterval - .DiscountType - .AMOUNT - ) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addFixedFeeQuantitySchedule( - SubscriptionTriggerPhaseResponse.FixedFeeQuantitySchedule.builder() - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .priceId("price_id") - .quantity(0.0) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .invoicingThreshold("invoicing_threshold") - .addMaximumInterval( - SubscriptionTriggerPhaseResponse.MaximumInterval.builder() - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .maximumAmount("maximum_amount") - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .metadata( - SubscriptionTriggerPhaseResponse.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .addMinimumInterval( - SubscriptionTriggerPhaseResponse.MinimumInterval.builder() - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .minimumAmount("minimum_amount") - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .netTerms(0L) - .plan( - Plan.builder() - .id("id") - .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() - .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currency("currency") - .defaultInvoiceMemo("default_invoice_memo") - .description("description") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPlanId("external_plan_id") - .invoicingCurrency("invoicing_currency") - .maximum( - Plan.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Plan.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Plan.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .name("name") - .netTerms(0L) - .addPlanPhase( - Plan.PlanPhase.builder() - .id("id") - .description("description") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .duration(0L) - .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) - .maximum( - Plan.PlanPhase.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Plan.PlanPhase.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .name("name") - .order(0L) - .build() - ) - .addPrice( - Price.UnitPrice.builder() - .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) - .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY - ) - .build() - ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) - .conversionRate(0.0) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() - .allowsRollover(true) - .currency("currency") - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY - ) - .build() - ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) - .maximum( - Price.UnitPrice.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.UnitPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Price.UnitPrice.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) - .name("name") - .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) - .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) - .build() - ) - .product( - Plan.Product.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .name("name") - .build() - ) - .status(Plan.Status.ACTIVE) - .trialConfig( - Plan.TrialConfig.builder() - .trialPeriod(0L) - .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) - .build() - ) - .version(0L) - .build() - ) - .addPriceInterval( - SubscriptionTriggerPhaseResponse.PriceInterval.builder() - .id("id") - .billingCycleDay(0L) - .currentBillingPeriodEndDate( - OffsetDateTime.parse("2019-12-27T18:11:19.117Z") - ) - .currentBillingPeriodStartDate( - OffsetDateTime.parse("2019-12-27T18:11:19.117Z") - ) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .filter("filter") - .addFixedFeeQuantityTransition( - SubscriptionTriggerPhaseResponse.PriceInterval - .FixedFeeQuantityTransition - .builder() - .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .priceId("price_id") - .quantity(0L) - .build() - ) - .price( - Price.UnitPrice.builder() - .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) - .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY - ) - .build() - ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) - .conversionRate(0.0) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() - .allowsRollover(true) - .currency("currency") - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY - ) - .build() - ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) - .maximum( - Price.UnitPrice.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.UnitPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Price.UnitPrice.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) - .name("name") - .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) - .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) - .build() - ) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addUsageCustomerId("string") - .build() - ) - .redeemedCoupon( - SubscriptionTriggerPhaseResponse.RedeemedCoupon.builder() - .couponId("coupon_id") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .status(SubscriptionTriggerPhaseResponse.Status.ACTIVE) - .trialInfo( - SubscriptionTriggerPhaseResponse.TrialInfo.builder() - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .build() - assertThat(subscriptionTriggerPhaseResponse).isNotNull - assertThat(subscriptionTriggerPhaseResponse.id()).isEqualTo("id") - assertThat(subscriptionTriggerPhaseResponse.activePlanPhaseOrder()).contains(0L) - assertThat(subscriptionTriggerPhaseResponse.adjustmentIntervals()) - .containsExactly( - SubscriptionTriggerPhaseResponse.AdjustmentInterval.builder() - .id("id") - .adjustment( - SubscriptionTriggerPhaseResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .builder() - .id("id") - .adjustmentType( - SubscriptionTriggerPhaseResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionTriggerPhaseResponse.autoCollection()).contains(true) - assertThat(subscriptionTriggerPhaseResponse.billingCycleAnchorConfiguration()) - .isEqualTo( - SubscriptionTriggerPhaseResponse.BillingCycleAnchorConfiguration.builder() - .day(1L) - .month(1L) - .year(0L) - .build() - ) - assertThat(subscriptionTriggerPhaseResponse.billingCycleDay()).isEqualTo(1L) - assertThat(subscriptionTriggerPhaseResponse.createdAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionTriggerPhaseResponse.currentBillingPeriodEndDate()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionTriggerPhaseResponse.currentBillingPeriodStartDate()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionTriggerPhaseResponse.customer()) - .isEqualTo( - Customer.builder() - .id("id") - .addAdditionalEmail("string") - .autoCollection(true) - .balance("balance") - .billingAddress( - Customer.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currency("currency") - .email("email") - .emailDelivery(true) - .exemptFromAutomatedTax(true) - .externalCustomerId("external_customer_id") - .hierarchy( - Customer.Hierarchy.builder() - .addChild( - Customer.Hierarchy.Child.builder() - .id("id") - .externalCustomerId("external_customer_id") - .build() - ) - .parent( - Customer.Hierarchy.Parent.builder() - .id("id") - .externalCustomerId("external_customer_id") - .build() - ) - .build() - ) - .metadata( - Customer.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .name("name") - .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) - .paymentProviderId("payment_provider_id") - .portalUrl("portal_url") - .shippingAddress( - Customer.ShippingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .taxId( - Customer.TaxId.builder() - .country(Customer.TaxId.Country.AD) - .type(Customer.TaxId.Type.AD_NRT) - .value("value") - .build() - ) - .timezone("timezone") - .accountingSyncConfiguration( - Customer.AccountingSyncConfiguration.builder() - .addAccountingProvider( - Customer.AccountingSyncConfiguration.AccountingProvider.builder() - .externalProviderId("external_provider_id") - .providerType( - Customer.AccountingSyncConfiguration.AccountingProvider - .ProviderType - .QUICKBOOKS - ) - .build() - ) - .excluded(true) - .build() - ) - .reportingConfiguration( - Customer.ReportingConfiguration.builder().exempt(true).build() - ) - .build() - ) - assertThat(subscriptionTriggerPhaseResponse.defaultInvoiceMemo()) - .contains("default_invoice_memo") - assertThat(subscriptionTriggerPhaseResponse.discountIntervals()) - .containsExactly( - SubscriptionTriggerPhaseResponse.DiscountInterval.ofAmount( - SubscriptionTriggerPhaseResponse.DiscountInterval.AmountDiscountInterval - .builder() - .amountDiscount("amount_discount") - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionTriggerPhaseResponse.DiscountInterval.AmountDiscountInterval - .DiscountType - .AMOUNT - ) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - ) - assertThat(subscriptionTriggerPhaseResponse.endDate()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionTriggerPhaseResponse.fixedFeeQuantitySchedule()) - .containsExactly( - SubscriptionTriggerPhaseResponse.FixedFeeQuantitySchedule.builder() - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .priceId("price_id") - .quantity(0.0) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionTriggerPhaseResponse.invoicingThreshold()) - .contains("invoicing_threshold") - assertThat(subscriptionTriggerPhaseResponse.maximumIntervals()) - .containsExactly( - SubscriptionTriggerPhaseResponse.MaximumInterval.builder() - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .maximumAmount("maximum_amount") - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionTriggerPhaseResponse.metadata()) - .isEqualTo( - SubscriptionTriggerPhaseResponse.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - assertThat(subscriptionTriggerPhaseResponse.minimumIntervals()) - .containsExactly( - SubscriptionTriggerPhaseResponse.MinimumInterval.builder() - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .minimumAmount("minimum_amount") - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionTriggerPhaseResponse.netTerms()).isEqualTo(0L) - assertThat(subscriptionTriggerPhaseResponse.plan()) - .isEqualTo( - Plan.builder() - .id("id") - .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() - .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currency("currency") - .defaultInvoiceMemo("default_invoice_memo") - .description("description") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPlanId("external_plan_id") - .invoicingCurrency("invoicing_currency") - .maximum( - Plan.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Plan.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Plan.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .name("name") - .netTerms(0L) - .addPlanPhase( - Plan.PlanPhase.builder() - .id("id") - .description("description") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .duration(0L) - .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) - .maximum( - Plan.PlanPhase.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Plan.PlanPhase.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .name("name") - .order(0L) - .build() - ) - .addPrice( - Price.UnitPrice.builder() - .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) - .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY - ) - .build() - ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) - .conversionRate(0.0) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() - .allowsRollover(true) - .currency("currency") - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY - ) - .build() - ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) - .maximum( - Price.UnitPrice.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.UnitPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Price.UnitPrice.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) - .name("name") - .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) - .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) - .build() - ) - .product( - Plan.Product.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .name("name") - .build() - ) - .status(Plan.Status.ACTIVE) - .trialConfig( - Plan.TrialConfig.builder() - .trialPeriod(0L) - .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) - .build() - ) - .version(0L) - .build() - ) - assertThat(subscriptionTriggerPhaseResponse.priceIntervals()) - .containsExactly( - SubscriptionTriggerPhaseResponse.PriceInterval.builder() - .id("id") - .billingCycleDay(0L) - .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .filter("filter") - .addFixedFeeQuantityTransition( - SubscriptionTriggerPhaseResponse.PriceInterval.FixedFeeQuantityTransition - .builder() - .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .priceId("price_id") - .quantity(0L) - .build() - ) - .price( - Price.UnitPrice.builder() - .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) - .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY - ) - .build() - ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) - .conversionRate(0.0) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() - .allowsRollover(true) - .currency("currency") - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY - ) - .build() - ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) - .maximum( - Price.UnitPrice.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.UnitPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Price.UnitPrice.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) - .name("name") - .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) - .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) - .build() - ) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addUsageCustomerId("string") - .build() - ) - assertThat(subscriptionTriggerPhaseResponse.redeemedCoupon()) - .contains( - SubscriptionTriggerPhaseResponse.RedeemedCoupon.builder() - .couponId("coupon_id") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionTriggerPhaseResponse.startDate()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionTriggerPhaseResponse.status()) - .isEqualTo(SubscriptionTriggerPhaseResponse.Status.ACTIVE) - assertThat(subscriptionTriggerPhaseResponse.trialInfo()) - .isEqualTo( - SubscriptionTriggerPhaseResponse.TrialInfo.builder() - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - } -} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationResponseTest.kt deleted file mode 100644 index 5489206af..000000000 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationResponseTest.kt +++ /dev/null @@ -1,1019 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.withorb.api.core.JsonValue -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class SubscriptionUnscheduleCancellationResponseTest { - - @Test - fun createSubscriptionUnscheduleCancellationResponse() { - val subscriptionUnscheduleCancellationResponse = - SubscriptionUnscheduleCancellationResponse.builder() - .id("id") - .activePlanPhaseOrder(0L) - .addAdjustmentInterval( - SubscriptionUnscheduleCancellationResponse.AdjustmentInterval.builder() - .id("id") - .adjustment( - SubscriptionUnscheduleCancellationResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .builder() - .id("id") - .adjustmentType( - SubscriptionUnscheduleCancellationResponse.AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .autoCollection(true) - .billingCycleAnchorConfiguration( - SubscriptionUnscheduleCancellationResponse.BillingCycleAnchorConfiguration - .builder() - .day(1L) - .month(1L) - .year(0L) - .build() - ) - .billingCycleDay(1L) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .customer( - Customer.builder() - .id("id") - .addAdditionalEmail("string") - .autoCollection(true) - .balance("balance") - .billingAddress( - Customer.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currency("currency") - .email("email") - .emailDelivery(true) - .exemptFromAutomatedTax(true) - .externalCustomerId("external_customer_id") - .hierarchy( - Customer.Hierarchy.builder() - .addChild( - Customer.Hierarchy.Child.builder() - .id("id") - .externalCustomerId("external_customer_id") - .build() - ) - .parent( - Customer.Hierarchy.Parent.builder() - .id("id") - .externalCustomerId("external_customer_id") - .build() - ) - .build() - ) - .metadata( - Customer.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .name("name") - .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) - .paymentProviderId("payment_provider_id") - .portalUrl("portal_url") - .shippingAddress( - Customer.ShippingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .taxId( - Customer.TaxId.builder() - .country(Customer.TaxId.Country.AD) - .type(Customer.TaxId.Type.AD_NRT) - .value("value") - .build() - ) - .timezone("timezone") - .accountingSyncConfiguration( - Customer.AccountingSyncConfiguration.builder() - .addAccountingProvider( - Customer.AccountingSyncConfiguration.AccountingProvider - .builder() - .externalProviderId("external_provider_id") - .providerType( - Customer.AccountingSyncConfiguration.AccountingProvider - .ProviderType - .QUICKBOOKS - ) - .build() - ) - .excluded(true) - .build() - ) - .reportingConfiguration( - Customer.ReportingConfiguration.builder().exempt(true).build() - ) - .build() - ) - .defaultInvoiceMemo("default_invoice_memo") - .addDiscountInterval( - SubscriptionUnscheduleCancellationResponse.DiscountInterval - .AmountDiscountInterval - .builder() - .amountDiscount("amount_discount") - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionUnscheduleCancellationResponse.DiscountInterval - .AmountDiscountInterval - .DiscountType - .AMOUNT - ) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addFixedFeeQuantitySchedule( - SubscriptionUnscheduleCancellationResponse.FixedFeeQuantitySchedule.builder() - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .priceId("price_id") - .quantity(0.0) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .invoicingThreshold("invoicing_threshold") - .addMaximumInterval( - SubscriptionUnscheduleCancellationResponse.MaximumInterval.builder() - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .maximumAmount("maximum_amount") - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .metadata( - SubscriptionUnscheduleCancellationResponse.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .addMinimumInterval( - SubscriptionUnscheduleCancellationResponse.MinimumInterval.builder() - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .minimumAmount("minimum_amount") - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .netTerms(0L) - .plan( - Plan.builder() - .id("id") - .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() - .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currency("currency") - .defaultInvoiceMemo("default_invoice_memo") - .description("description") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPlanId("external_plan_id") - .invoicingCurrency("invoicing_currency") - .maximum( - Plan.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Plan.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Plan.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .name("name") - .netTerms(0L) - .addPlanPhase( - Plan.PlanPhase.builder() - .id("id") - .description("description") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .duration(0L) - .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) - .maximum( - Plan.PlanPhase.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Plan.PlanPhase.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .name("name") - .order(0L) - .build() - ) - .addPrice( - Price.UnitPrice.builder() - .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) - .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY - ) - .build() - ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) - .conversionRate(0.0) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() - .allowsRollover(true) - .currency("currency") - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY - ) - .build() - ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) - .maximum( - Price.UnitPrice.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.UnitPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Price.UnitPrice.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) - .name("name") - .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) - .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) - .build() - ) - .product( - Plan.Product.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .name("name") - .build() - ) - .status(Plan.Status.ACTIVE) - .trialConfig( - Plan.TrialConfig.builder() - .trialPeriod(0L) - .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) - .build() - ) - .version(0L) - .build() - ) - .addPriceInterval( - SubscriptionUnscheduleCancellationResponse.PriceInterval.builder() - .id("id") - .billingCycleDay(0L) - .currentBillingPeriodEndDate( - OffsetDateTime.parse("2019-12-27T18:11:19.117Z") - ) - .currentBillingPeriodStartDate( - OffsetDateTime.parse("2019-12-27T18:11:19.117Z") - ) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .filter("filter") - .addFixedFeeQuantityTransition( - SubscriptionUnscheduleCancellationResponse.PriceInterval - .FixedFeeQuantityTransition - .builder() - .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .priceId("price_id") - .quantity(0L) - .build() - ) - .price( - Price.UnitPrice.builder() - .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) - .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY - ) - .build() - ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) - .conversionRate(0.0) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() - .allowsRollover(true) - .currency("currency") - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY - ) - .build() - ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) - .maximum( - Price.UnitPrice.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.UnitPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Price.UnitPrice.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) - .name("name") - .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) - .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) - .build() - ) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addUsageCustomerId("string") - .build() - ) - .redeemedCoupon( - SubscriptionUnscheduleCancellationResponse.RedeemedCoupon.builder() - .couponId("coupon_id") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .status(SubscriptionUnscheduleCancellationResponse.Status.ACTIVE) - .trialInfo( - SubscriptionUnscheduleCancellationResponse.TrialInfo.builder() - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .build() - assertThat(subscriptionUnscheduleCancellationResponse).isNotNull - assertThat(subscriptionUnscheduleCancellationResponse.id()).isEqualTo("id") - assertThat(subscriptionUnscheduleCancellationResponse.activePlanPhaseOrder()).contains(0L) - assertThat(subscriptionUnscheduleCancellationResponse.adjustmentIntervals()) - .containsExactly( - SubscriptionUnscheduleCancellationResponse.AdjustmentInterval.builder() - .id("id") - .adjustment( - SubscriptionUnscheduleCancellationResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .builder() - .id("id") - .adjustmentType( - SubscriptionUnscheduleCancellationResponse.AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionUnscheduleCancellationResponse.autoCollection()).contains(true) - assertThat(subscriptionUnscheduleCancellationResponse.billingCycleAnchorConfiguration()) - .isEqualTo( - SubscriptionUnscheduleCancellationResponse.BillingCycleAnchorConfiguration.builder() - .day(1L) - .month(1L) - .year(0L) - .build() - ) - assertThat(subscriptionUnscheduleCancellationResponse.billingCycleDay()).isEqualTo(1L) - assertThat(subscriptionUnscheduleCancellationResponse.createdAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionUnscheduleCancellationResponse.currentBillingPeriodEndDate()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionUnscheduleCancellationResponse.currentBillingPeriodStartDate()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionUnscheduleCancellationResponse.customer()) - .isEqualTo( - Customer.builder() - .id("id") - .addAdditionalEmail("string") - .autoCollection(true) - .balance("balance") - .billingAddress( - Customer.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currency("currency") - .email("email") - .emailDelivery(true) - .exemptFromAutomatedTax(true) - .externalCustomerId("external_customer_id") - .hierarchy( - Customer.Hierarchy.builder() - .addChild( - Customer.Hierarchy.Child.builder() - .id("id") - .externalCustomerId("external_customer_id") - .build() - ) - .parent( - Customer.Hierarchy.Parent.builder() - .id("id") - .externalCustomerId("external_customer_id") - .build() - ) - .build() - ) - .metadata( - Customer.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .name("name") - .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) - .paymentProviderId("payment_provider_id") - .portalUrl("portal_url") - .shippingAddress( - Customer.ShippingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .taxId( - Customer.TaxId.builder() - .country(Customer.TaxId.Country.AD) - .type(Customer.TaxId.Type.AD_NRT) - .value("value") - .build() - ) - .timezone("timezone") - .accountingSyncConfiguration( - Customer.AccountingSyncConfiguration.builder() - .addAccountingProvider( - Customer.AccountingSyncConfiguration.AccountingProvider.builder() - .externalProviderId("external_provider_id") - .providerType( - Customer.AccountingSyncConfiguration.AccountingProvider - .ProviderType - .QUICKBOOKS - ) - .build() - ) - .excluded(true) - .build() - ) - .reportingConfiguration( - Customer.ReportingConfiguration.builder().exempt(true).build() - ) - .build() - ) - assertThat(subscriptionUnscheduleCancellationResponse.defaultInvoiceMemo()) - .contains("default_invoice_memo") - assertThat(subscriptionUnscheduleCancellationResponse.discountIntervals()) - .containsExactly( - SubscriptionUnscheduleCancellationResponse.DiscountInterval.ofAmount( - SubscriptionUnscheduleCancellationResponse.DiscountInterval - .AmountDiscountInterval - .builder() - .amountDiscount("amount_discount") - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionUnscheduleCancellationResponse.DiscountInterval - .AmountDiscountInterval - .DiscountType - .AMOUNT - ) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - ) - assertThat(subscriptionUnscheduleCancellationResponse.endDate()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionUnscheduleCancellationResponse.fixedFeeQuantitySchedule()) - .containsExactly( - SubscriptionUnscheduleCancellationResponse.FixedFeeQuantitySchedule.builder() - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .priceId("price_id") - .quantity(0.0) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionUnscheduleCancellationResponse.invoicingThreshold()) - .contains("invoicing_threshold") - assertThat(subscriptionUnscheduleCancellationResponse.maximumIntervals()) - .containsExactly( - SubscriptionUnscheduleCancellationResponse.MaximumInterval.builder() - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .maximumAmount("maximum_amount") - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionUnscheduleCancellationResponse.metadata()) - .isEqualTo( - SubscriptionUnscheduleCancellationResponse.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - assertThat(subscriptionUnscheduleCancellationResponse.minimumIntervals()) - .containsExactly( - SubscriptionUnscheduleCancellationResponse.MinimumInterval.builder() - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .minimumAmount("minimum_amount") - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionUnscheduleCancellationResponse.netTerms()).isEqualTo(0L) - assertThat(subscriptionUnscheduleCancellationResponse.plan()) - .isEqualTo( - Plan.builder() - .id("id") - .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() - .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currency("currency") - .defaultInvoiceMemo("default_invoice_memo") - .description("description") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPlanId("external_plan_id") - .invoicingCurrency("invoicing_currency") - .maximum( - Plan.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Plan.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Plan.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .name("name") - .netTerms(0L) - .addPlanPhase( - Plan.PlanPhase.builder() - .id("id") - .description("description") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .duration(0L) - .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) - .maximum( - Plan.PlanPhase.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Plan.PlanPhase.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .name("name") - .order(0L) - .build() - ) - .addPrice( - Price.UnitPrice.builder() - .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) - .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY - ) - .build() - ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) - .conversionRate(0.0) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() - .allowsRollover(true) - .currency("currency") - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY - ) - .build() - ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) - .maximum( - Price.UnitPrice.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.UnitPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Price.UnitPrice.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) - .name("name") - .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) - .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) - .build() - ) - .product( - Plan.Product.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .name("name") - .build() - ) - .status(Plan.Status.ACTIVE) - .trialConfig( - Plan.TrialConfig.builder() - .trialPeriod(0L) - .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) - .build() - ) - .version(0L) - .build() - ) - assertThat(subscriptionUnscheduleCancellationResponse.priceIntervals()) - .containsExactly( - SubscriptionUnscheduleCancellationResponse.PriceInterval.builder() - .id("id") - .billingCycleDay(0L) - .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .filter("filter") - .addFixedFeeQuantityTransition( - SubscriptionUnscheduleCancellationResponse.PriceInterval - .FixedFeeQuantityTransition - .builder() - .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .priceId("price_id") - .quantity(0L) - .build() - ) - .price( - Price.UnitPrice.builder() - .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) - .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY - ) - .build() - ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) - .conversionRate(0.0) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() - .allowsRollover(true) - .currency("currency") - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY - ) - .build() - ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) - .maximum( - Price.UnitPrice.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.UnitPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Price.UnitPrice.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) - .name("name") - .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) - .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) - .build() - ) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addUsageCustomerId("string") - .build() - ) - assertThat(subscriptionUnscheduleCancellationResponse.redeemedCoupon()) - .contains( - SubscriptionUnscheduleCancellationResponse.RedeemedCoupon.builder() - .couponId("coupon_id") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionUnscheduleCancellationResponse.startDate()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionUnscheduleCancellationResponse.status()) - .isEqualTo(SubscriptionUnscheduleCancellationResponse.Status.ACTIVE) - assertThat(subscriptionUnscheduleCancellationResponse.trialInfo()) - .isEqualTo( - SubscriptionUnscheduleCancellationResponse.TrialInfo.builder() - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - } -} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest.kt deleted file mode 100644 index d35cf6ece..000000000 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest.kt +++ /dev/null @@ -1,1040 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.withorb.api.core.JsonValue -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { - - @Test - fun createSubscriptionUnscheduleFixedFeeQuantityUpdatesResponse() { - val subscriptionUnscheduleFixedFeeQuantityUpdatesResponse = - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.builder() - .id("id") - .activePlanPhaseOrder(0L) - .addAdjustmentInterval( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.AdjustmentInterval - .builder() - .id("id") - .adjustment( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .builder() - .id("id") - .adjustmentType( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse - .AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .autoCollection(true) - .billingCycleAnchorConfiguration( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse - .BillingCycleAnchorConfiguration - .builder() - .day(1L) - .month(1L) - .year(0L) - .build() - ) - .billingCycleDay(1L) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .customer( - Customer.builder() - .id("id") - .addAdditionalEmail("string") - .autoCollection(true) - .balance("balance") - .billingAddress( - Customer.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currency("currency") - .email("email") - .emailDelivery(true) - .exemptFromAutomatedTax(true) - .externalCustomerId("external_customer_id") - .hierarchy( - Customer.Hierarchy.builder() - .addChild( - Customer.Hierarchy.Child.builder() - .id("id") - .externalCustomerId("external_customer_id") - .build() - ) - .parent( - Customer.Hierarchy.Parent.builder() - .id("id") - .externalCustomerId("external_customer_id") - .build() - ) - .build() - ) - .metadata( - Customer.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .name("name") - .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) - .paymentProviderId("payment_provider_id") - .portalUrl("portal_url") - .shippingAddress( - Customer.ShippingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .taxId( - Customer.TaxId.builder() - .country(Customer.TaxId.Country.AD) - .type(Customer.TaxId.Type.AD_NRT) - .value("value") - .build() - ) - .timezone("timezone") - .accountingSyncConfiguration( - Customer.AccountingSyncConfiguration.builder() - .addAccountingProvider( - Customer.AccountingSyncConfiguration.AccountingProvider - .builder() - .externalProviderId("external_provider_id") - .providerType( - Customer.AccountingSyncConfiguration.AccountingProvider - .ProviderType - .QUICKBOOKS - ) - .build() - ) - .excluded(true) - .build() - ) - .reportingConfiguration( - Customer.ReportingConfiguration.builder().exempt(true).build() - ) - .build() - ) - .defaultInvoiceMemo("default_invoice_memo") - .addDiscountInterval( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.DiscountInterval - .AmountDiscountInterval - .builder() - .amountDiscount("amount_discount") - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.DiscountInterval - .AmountDiscountInterval - .DiscountType - .AMOUNT - ) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addFixedFeeQuantitySchedule( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.FixedFeeQuantitySchedule - .builder() - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .priceId("price_id") - .quantity(0.0) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .invoicingThreshold("invoicing_threshold") - .addMaximumInterval( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.MaximumInterval.builder() - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .maximumAmount("maximum_amount") - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .metadata( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .addMinimumInterval( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.MinimumInterval.builder() - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .minimumAmount("minimum_amount") - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .netTerms(0L) - .plan( - Plan.builder() - .id("id") - .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() - .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currency("currency") - .defaultInvoiceMemo("default_invoice_memo") - .description("description") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPlanId("external_plan_id") - .invoicingCurrency("invoicing_currency") - .maximum( - Plan.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Plan.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Plan.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .name("name") - .netTerms(0L) - .addPlanPhase( - Plan.PlanPhase.builder() - .id("id") - .description("description") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .duration(0L) - .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) - .maximum( - Plan.PlanPhase.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Plan.PlanPhase.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .name("name") - .order(0L) - .build() - ) - .addPrice( - Price.UnitPrice.builder() - .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) - .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY - ) - .build() - ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) - .conversionRate(0.0) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() - .allowsRollover(true) - .currency("currency") - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY - ) - .build() - ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) - .maximum( - Price.UnitPrice.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.UnitPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Price.UnitPrice.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) - .name("name") - .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) - .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) - .build() - ) - .product( - Plan.Product.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .name("name") - .build() - ) - .status(Plan.Status.ACTIVE) - .trialConfig( - Plan.TrialConfig.builder() - .trialPeriod(0L) - .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) - .build() - ) - .version(0L) - .build() - ) - .addPriceInterval( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.PriceInterval.builder() - .id("id") - .billingCycleDay(0L) - .currentBillingPeriodEndDate( - OffsetDateTime.parse("2019-12-27T18:11:19.117Z") - ) - .currentBillingPeriodStartDate( - OffsetDateTime.parse("2019-12-27T18:11:19.117Z") - ) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .filter("filter") - .addFixedFeeQuantityTransition( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.PriceInterval - .FixedFeeQuantityTransition - .builder() - .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .priceId("price_id") - .quantity(0L) - .build() - ) - .price( - Price.UnitPrice.builder() - .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) - .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY - ) - .build() - ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) - .conversionRate(0.0) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() - .allowsRollover(true) - .currency("currency") - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY - ) - .build() - ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) - .maximum( - Price.UnitPrice.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.UnitPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Price.UnitPrice.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) - .name("name") - .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) - .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) - .build() - ) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addUsageCustomerId("string") - .build() - ) - .redeemedCoupon( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.RedeemedCoupon.builder() - .couponId("coupon_id") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .status(SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.Status.ACTIVE) - .trialInfo( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.TrialInfo.builder() - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .build() - assertThat(subscriptionUnscheduleFixedFeeQuantityUpdatesResponse).isNotNull - assertThat(subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.id()).isEqualTo("id") - assertThat(subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.activePlanPhaseOrder()) - .contains(0L) - assertThat(subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.adjustmentIntervals()) - .containsExactly( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.AdjustmentInterval.builder() - .id("id") - .adjustment( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .builder() - .id("id") - .adjustmentType( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse - .AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.autoCollection()) - .contains(true) - assertThat( - subscriptionUnscheduleFixedFeeQuantityUpdatesResponse - .billingCycleAnchorConfiguration() - ) - .isEqualTo( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse - .BillingCycleAnchorConfiguration - .builder() - .day(1L) - .month(1L) - .year(0L) - .build() - ) - assertThat(subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.billingCycleDay()) - .isEqualTo(1L) - assertThat(subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.createdAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat( - subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.currentBillingPeriodEndDate() - ) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat( - subscriptionUnscheduleFixedFeeQuantityUpdatesResponse - .currentBillingPeriodStartDate() - ) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.customer()) - .isEqualTo( - Customer.builder() - .id("id") - .addAdditionalEmail("string") - .autoCollection(true) - .balance("balance") - .billingAddress( - Customer.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currency("currency") - .email("email") - .emailDelivery(true) - .exemptFromAutomatedTax(true) - .externalCustomerId("external_customer_id") - .hierarchy( - Customer.Hierarchy.builder() - .addChild( - Customer.Hierarchy.Child.builder() - .id("id") - .externalCustomerId("external_customer_id") - .build() - ) - .parent( - Customer.Hierarchy.Parent.builder() - .id("id") - .externalCustomerId("external_customer_id") - .build() - ) - .build() - ) - .metadata( - Customer.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .name("name") - .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) - .paymentProviderId("payment_provider_id") - .portalUrl("portal_url") - .shippingAddress( - Customer.ShippingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .taxId( - Customer.TaxId.builder() - .country(Customer.TaxId.Country.AD) - .type(Customer.TaxId.Type.AD_NRT) - .value("value") - .build() - ) - .timezone("timezone") - .accountingSyncConfiguration( - Customer.AccountingSyncConfiguration.builder() - .addAccountingProvider( - Customer.AccountingSyncConfiguration.AccountingProvider.builder() - .externalProviderId("external_provider_id") - .providerType( - Customer.AccountingSyncConfiguration.AccountingProvider - .ProviderType - .QUICKBOOKS - ) - .build() - ) - .excluded(true) - .build() - ) - .reportingConfiguration( - Customer.ReportingConfiguration.builder().exempt(true).build() - ) - .build() - ) - assertThat(subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.defaultInvoiceMemo()) - .contains("default_invoice_memo") - assertThat(subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.discountIntervals()) - .containsExactly( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.DiscountInterval.ofAmount( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.DiscountInterval - .AmountDiscountInterval - .builder() - .amountDiscount("amount_discount") - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.DiscountInterval - .AmountDiscountInterval - .DiscountType - .AMOUNT - ) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - ) - assertThat(subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.endDate()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.fixedFeeQuantitySchedule()) - .containsExactly( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.FixedFeeQuantitySchedule - .builder() - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .priceId("price_id") - .quantity(0.0) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.invoicingThreshold()) - .contains("invoicing_threshold") - assertThat(subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.maximumIntervals()) - .containsExactly( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.MaximumInterval.builder() - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .maximumAmount("maximum_amount") - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.metadata()) - .isEqualTo( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - assertThat(subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.minimumIntervals()) - .containsExactly( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.MinimumInterval.builder() - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .minimumAmount("minimum_amount") - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.netTerms()).isEqualTo(0L) - assertThat(subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.plan()) - .isEqualTo( - Plan.builder() - .id("id") - .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() - .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currency("currency") - .defaultInvoiceMemo("default_invoice_memo") - .description("description") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPlanId("external_plan_id") - .invoicingCurrency("invoicing_currency") - .maximum( - Plan.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Plan.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Plan.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .name("name") - .netTerms(0L) - .addPlanPhase( - Plan.PlanPhase.builder() - .id("id") - .description("description") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .duration(0L) - .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) - .maximum( - Plan.PlanPhase.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Plan.PlanPhase.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .name("name") - .order(0L) - .build() - ) - .addPrice( - Price.UnitPrice.builder() - .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) - .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY - ) - .build() - ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) - .conversionRate(0.0) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() - .allowsRollover(true) - .currency("currency") - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY - ) - .build() - ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) - .maximum( - Price.UnitPrice.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.UnitPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Price.UnitPrice.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) - .name("name") - .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) - .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) - .build() - ) - .product( - Plan.Product.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .name("name") - .build() - ) - .status(Plan.Status.ACTIVE) - .trialConfig( - Plan.TrialConfig.builder() - .trialPeriod(0L) - .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) - .build() - ) - .version(0L) - .build() - ) - assertThat(subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.priceIntervals()) - .containsExactly( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.PriceInterval.builder() - .id("id") - .billingCycleDay(0L) - .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .filter("filter") - .addFixedFeeQuantityTransition( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.PriceInterval - .FixedFeeQuantityTransition - .builder() - .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .priceId("price_id") - .quantity(0L) - .build() - ) - .price( - Price.UnitPrice.builder() - .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) - .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY - ) - .build() - ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) - .conversionRate(0.0) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() - .allowsRollover(true) - .currency("currency") - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY - ) - .build() - ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) - .maximum( - Price.UnitPrice.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.UnitPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Price.UnitPrice.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) - .name("name") - .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) - .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) - .build() - ) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addUsageCustomerId("string") - .build() - ) - assertThat(subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.redeemedCoupon()) - .contains( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.RedeemedCoupon.builder() - .couponId("coupon_id") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.startDate()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.status()) - .isEqualTo(SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.Status.ACTIVE) - assertThat(subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.trialInfo()) - .isEqualTo( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.TrialInfo.builder() - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - } -} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesResponseTest.kt deleted file mode 100644 index 363045199..000000000 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesResponseTest.kt +++ /dev/null @@ -1,1027 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.withorb.api.core.JsonValue -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class SubscriptionUnschedulePendingPlanChangesResponseTest { - - @Test - fun createSubscriptionUnschedulePendingPlanChangesResponse() { - val subscriptionUnschedulePendingPlanChangesResponse = - SubscriptionUnschedulePendingPlanChangesResponse.builder() - .id("id") - .activePlanPhaseOrder(0L) - .addAdjustmentInterval( - SubscriptionUnschedulePendingPlanChangesResponse.AdjustmentInterval.builder() - .id("id") - .adjustment( - SubscriptionUnschedulePendingPlanChangesResponse.AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .builder() - .id("id") - .adjustmentType( - SubscriptionUnschedulePendingPlanChangesResponse - .AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .autoCollection(true) - .billingCycleAnchorConfiguration( - SubscriptionUnschedulePendingPlanChangesResponse.BillingCycleAnchorConfiguration - .builder() - .day(1L) - .month(1L) - .year(0L) - .build() - ) - .billingCycleDay(1L) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .customer( - Customer.builder() - .id("id") - .addAdditionalEmail("string") - .autoCollection(true) - .balance("balance") - .billingAddress( - Customer.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currency("currency") - .email("email") - .emailDelivery(true) - .exemptFromAutomatedTax(true) - .externalCustomerId("external_customer_id") - .hierarchy( - Customer.Hierarchy.builder() - .addChild( - Customer.Hierarchy.Child.builder() - .id("id") - .externalCustomerId("external_customer_id") - .build() - ) - .parent( - Customer.Hierarchy.Parent.builder() - .id("id") - .externalCustomerId("external_customer_id") - .build() - ) - .build() - ) - .metadata( - Customer.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .name("name") - .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) - .paymentProviderId("payment_provider_id") - .portalUrl("portal_url") - .shippingAddress( - Customer.ShippingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .taxId( - Customer.TaxId.builder() - .country(Customer.TaxId.Country.AD) - .type(Customer.TaxId.Type.AD_NRT) - .value("value") - .build() - ) - .timezone("timezone") - .accountingSyncConfiguration( - Customer.AccountingSyncConfiguration.builder() - .addAccountingProvider( - Customer.AccountingSyncConfiguration.AccountingProvider - .builder() - .externalProviderId("external_provider_id") - .providerType( - Customer.AccountingSyncConfiguration.AccountingProvider - .ProviderType - .QUICKBOOKS - ) - .build() - ) - .excluded(true) - .build() - ) - .reportingConfiguration( - Customer.ReportingConfiguration.builder().exempt(true).build() - ) - .build() - ) - .defaultInvoiceMemo("default_invoice_memo") - .addDiscountInterval( - SubscriptionUnschedulePendingPlanChangesResponse.DiscountInterval - .AmountDiscountInterval - .builder() - .amountDiscount("amount_discount") - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionUnschedulePendingPlanChangesResponse.DiscountInterval - .AmountDiscountInterval - .DiscountType - .AMOUNT - ) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addFixedFeeQuantitySchedule( - SubscriptionUnschedulePendingPlanChangesResponse.FixedFeeQuantitySchedule - .builder() - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .priceId("price_id") - .quantity(0.0) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .invoicingThreshold("invoicing_threshold") - .addMaximumInterval( - SubscriptionUnschedulePendingPlanChangesResponse.MaximumInterval.builder() - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .maximumAmount("maximum_amount") - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .metadata( - SubscriptionUnschedulePendingPlanChangesResponse.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .addMinimumInterval( - SubscriptionUnschedulePendingPlanChangesResponse.MinimumInterval.builder() - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .minimumAmount("minimum_amount") - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .netTerms(0L) - .plan( - Plan.builder() - .id("id") - .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() - .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currency("currency") - .defaultInvoiceMemo("default_invoice_memo") - .description("description") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPlanId("external_plan_id") - .invoicingCurrency("invoicing_currency") - .maximum( - Plan.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Plan.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Plan.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .name("name") - .netTerms(0L) - .addPlanPhase( - Plan.PlanPhase.builder() - .id("id") - .description("description") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .duration(0L) - .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) - .maximum( - Plan.PlanPhase.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Plan.PlanPhase.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .name("name") - .order(0L) - .build() - ) - .addPrice( - Price.UnitPrice.builder() - .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) - .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY - ) - .build() - ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) - .conversionRate(0.0) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() - .allowsRollover(true) - .currency("currency") - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY - ) - .build() - ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) - .maximum( - Price.UnitPrice.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.UnitPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Price.UnitPrice.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) - .name("name") - .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) - .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) - .build() - ) - .product( - Plan.Product.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .name("name") - .build() - ) - .status(Plan.Status.ACTIVE) - .trialConfig( - Plan.TrialConfig.builder() - .trialPeriod(0L) - .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) - .build() - ) - .version(0L) - .build() - ) - .addPriceInterval( - SubscriptionUnschedulePendingPlanChangesResponse.PriceInterval.builder() - .id("id") - .billingCycleDay(0L) - .currentBillingPeriodEndDate( - OffsetDateTime.parse("2019-12-27T18:11:19.117Z") - ) - .currentBillingPeriodStartDate( - OffsetDateTime.parse("2019-12-27T18:11:19.117Z") - ) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .filter("filter") - .addFixedFeeQuantityTransition( - SubscriptionUnschedulePendingPlanChangesResponse.PriceInterval - .FixedFeeQuantityTransition - .builder() - .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .priceId("price_id") - .quantity(0L) - .build() - ) - .price( - Price.UnitPrice.builder() - .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) - .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY - ) - .build() - ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) - .conversionRate(0.0) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() - .allowsRollover(true) - .currency("currency") - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY - ) - .build() - ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) - .maximum( - Price.UnitPrice.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.UnitPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Price.UnitPrice.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) - .name("name") - .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) - .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) - .build() - ) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addUsageCustomerId("string") - .build() - ) - .redeemedCoupon( - SubscriptionUnschedulePendingPlanChangesResponse.RedeemedCoupon.builder() - .couponId("coupon_id") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .status(SubscriptionUnschedulePendingPlanChangesResponse.Status.ACTIVE) - .trialInfo( - SubscriptionUnschedulePendingPlanChangesResponse.TrialInfo.builder() - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .build() - assertThat(subscriptionUnschedulePendingPlanChangesResponse).isNotNull - assertThat(subscriptionUnschedulePendingPlanChangesResponse.id()).isEqualTo("id") - assertThat(subscriptionUnschedulePendingPlanChangesResponse.activePlanPhaseOrder()) - .contains(0L) - assertThat(subscriptionUnschedulePendingPlanChangesResponse.adjustmentIntervals()) - .containsExactly( - SubscriptionUnschedulePendingPlanChangesResponse.AdjustmentInterval.builder() - .id("id") - .adjustment( - SubscriptionUnschedulePendingPlanChangesResponse.AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .builder() - .id("id") - .adjustmentType( - SubscriptionUnschedulePendingPlanChangesResponse.AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionUnschedulePendingPlanChangesResponse.autoCollection()).contains(true) - assertThat( - subscriptionUnschedulePendingPlanChangesResponse.billingCycleAnchorConfiguration() - ) - .isEqualTo( - SubscriptionUnschedulePendingPlanChangesResponse.BillingCycleAnchorConfiguration - .builder() - .day(1L) - .month(1L) - .year(0L) - .build() - ) - assertThat(subscriptionUnschedulePendingPlanChangesResponse.billingCycleDay()).isEqualTo(1L) - assertThat(subscriptionUnschedulePendingPlanChangesResponse.createdAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionUnschedulePendingPlanChangesResponse.currentBillingPeriodEndDate()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionUnschedulePendingPlanChangesResponse.currentBillingPeriodStartDate()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionUnschedulePendingPlanChangesResponse.customer()) - .isEqualTo( - Customer.builder() - .id("id") - .addAdditionalEmail("string") - .autoCollection(true) - .balance("balance") - .billingAddress( - Customer.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currency("currency") - .email("email") - .emailDelivery(true) - .exemptFromAutomatedTax(true) - .externalCustomerId("external_customer_id") - .hierarchy( - Customer.Hierarchy.builder() - .addChild( - Customer.Hierarchy.Child.builder() - .id("id") - .externalCustomerId("external_customer_id") - .build() - ) - .parent( - Customer.Hierarchy.Parent.builder() - .id("id") - .externalCustomerId("external_customer_id") - .build() - ) - .build() - ) - .metadata( - Customer.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .name("name") - .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) - .paymentProviderId("payment_provider_id") - .portalUrl("portal_url") - .shippingAddress( - Customer.ShippingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .taxId( - Customer.TaxId.builder() - .country(Customer.TaxId.Country.AD) - .type(Customer.TaxId.Type.AD_NRT) - .value("value") - .build() - ) - .timezone("timezone") - .accountingSyncConfiguration( - Customer.AccountingSyncConfiguration.builder() - .addAccountingProvider( - Customer.AccountingSyncConfiguration.AccountingProvider.builder() - .externalProviderId("external_provider_id") - .providerType( - Customer.AccountingSyncConfiguration.AccountingProvider - .ProviderType - .QUICKBOOKS - ) - .build() - ) - .excluded(true) - .build() - ) - .reportingConfiguration( - Customer.ReportingConfiguration.builder().exempt(true).build() - ) - .build() - ) - assertThat(subscriptionUnschedulePendingPlanChangesResponse.defaultInvoiceMemo()) - .contains("default_invoice_memo") - assertThat(subscriptionUnschedulePendingPlanChangesResponse.discountIntervals()) - .containsExactly( - SubscriptionUnschedulePendingPlanChangesResponse.DiscountInterval.ofAmount( - SubscriptionUnschedulePendingPlanChangesResponse.DiscountInterval - .AmountDiscountInterval - .builder() - .amountDiscount("amount_discount") - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionUnschedulePendingPlanChangesResponse.DiscountInterval - .AmountDiscountInterval - .DiscountType - .AMOUNT - ) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - ) - assertThat(subscriptionUnschedulePendingPlanChangesResponse.endDate()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionUnschedulePendingPlanChangesResponse.fixedFeeQuantitySchedule()) - .containsExactly( - SubscriptionUnschedulePendingPlanChangesResponse.FixedFeeQuantitySchedule.builder() - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .priceId("price_id") - .quantity(0.0) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionUnschedulePendingPlanChangesResponse.invoicingThreshold()) - .contains("invoicing_threshold") - assertThat(subscriptionUnschedulePendingPlanChangesResponse.maximumIntervals()) - .containsExactly( - SubscriptionUnschedulePendingPlanChangesResponse.MaximumInterval.builder() - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .maximumAmount("maximum_amount") - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionUnschedulePendingPlanChangesResponse.metadata()) - .isEqualTo( - SubscriptionUnschedulePendingPlanChangesResponse.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - assertThat(subscriptionUnschedulePendingPlanChangesResponse.minimumIntervals()) - .containsExactly( - SubscriptionUnschedulePendingPlanChangesResponse.MinimumInterval.builder() - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .minimumAmount("minimum_amount") - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionUnschedulePendingPlanChangesResponse.netTerms()).isEqualTo(0L) - assertThat(subscriptionUnschedulePendingPlanChangesResponse.plan()) - .isEqualTo( - Plan.builder() - .id("id") - .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() - .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currency("currency") - .defaultInvoiceMemo("default_invoice_memo") - .description("description") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPlanId("external_plan_id") - .invoicingCurrency("invoicing_currency") - .maximum( - Plan.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Plan.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Plan.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .name("name") - .netTerms(0L) - .addPlanPhase( - Plan.PlanPhase.builder() - .id("id") - .description("description") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .duration(0L) - .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) - .maximum( - Plan.PlanPhase.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Plan.PlanPhase.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .name("name") - .order(0L) - .build() - ) - .addPrice( - Price.UnitPrice.builder() - .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) - .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY - ) - .build() - ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) - .conversionRate(0.0) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() - .allowsRollover(true) - .currency("currency") - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY - ) - .build() - ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) - .maximum( - Price.UnitPrice.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.UnitPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Price.UnitPrice.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) - .name("name") - .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) - .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) - .build() - ) - .product( - Plan.Product.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .name("name") - .build() - ) - .status(Plan.Status.ACTIVE) - .trialConfig( - Plan.TrialConfig.builder() - .trialPeriod(0L) - .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) - .build() - ) - .version(0L) - .build() - ) - assertThat(subscriptionUnschedulePendingPlanChangesResponse.priceIntervals()) - .containsExactly( - SubscriptionUnschedulePendingPlanChangesResponse.PriceInterval.builder() - .id("id") - .billingCycleDay(0L) - .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .filter("filter") - .addFixedFeeQuantityTransition( - SubscriptionUnschedulePendingPlanChangesResponse.PriceInterval - .FixedFeeQuantityTransition - .builder() - .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .priceId("price_id") - .quantity(0L) - .build() - ) - .price( - Price.UnitPrice.builder() - .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) - .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY - ) - .build() - ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) - .conversionRate(0.0) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() - .allowsRollover(true) - .currency("currency") - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY - ) - .build() - ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) - .maximum( - Price.UnitPrice.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.UnitPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Price.UnitPrice.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) - .name("name") - .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) - .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) - .build() - ) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addUsageCustomerId("string") - .build() - ) - assertThat(subscriptionUnschedulePendingPlanChangesResponse.redeemedCoupon()) - .contains( - SubscriptionUnschedulePendingPlanChangesResponse.RedeemedCoupon.builder() - .couponId("coupon_id") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionUnschedulePendingPlanChangesResponse.startDate()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionUnschedulePendingPlanChangesResponse.status()) - .isEqualTo(SubscriptionUnschedulePendingPlanChangesResponse.Status.ACTIVE) - assertThat(subscriptionUnschedulePendingPlanChangesResponse.trialInfo()) - .isEqualTo( - SubscriptionUnschedulePendingPlanChangesResponse.TrialInfo.builder() - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - } -} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityResponseTest.kt deleted file mode 100644 index 3ddd5ffa4..000000000 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityResponseTest.kt +++ /dev/null @@ -1,1019 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.withorb.api.core.JsonValue -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class SubscriptionUpdateFixedFeeQuantityResponseTest { - - @Test - fun createSubscriptionUpdateFixedFeeQuantityResponse() { - val subscriptionUpdateFixedFeeQuantityResponse = - SubscriptionUpdateFixedFeeQuantityResponse.builder() - .id("id") - .activePlanPhaseOrder(0L) - .addAdjustmentInterval( - SubscriptionUpdateFixedFeeQuantityResponse.AdjustmentInterval.builder() - .id("id") - .adjustment( - SubscriptionUpdateFixedFeeQuantityResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .builder() - .id("id") - .adjustmentType( - SubscriptionUpdateFixedFeeQuantityResponse.AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .autoCollection(true) - .billingCycleAnchorConfiguration( - SubscriptionUpdateFixedFeeQuantityResponse.BillingCycleAnchorConfiguration - .builder() - .day(1L) - .month(1L) - .year(0L) - .build() - ) - .billingCycleDay(1L) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .customer( - Customer.builder() - .id("id") - .addAdditionalEmail("string") - .autoCollection(true) - .balance("balance") - .billingAddress( - Customer.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currency("currency") - .email("email") - .emailDelivery(true) - .exemptFromAutomatedTax(true) - .externalCustomerId("external_customer_id") - .hierarchy( - Customer.Hierarchy.builder() - .addChild( - Customer.Hierarchy.Child.builder() - .id("id") - .externalCustomerId("external_customer_id") - .build() - ) - .parent( - Customer.Hierarchy.Parent.builder() - .id("id") - .externalCustomerId("external_customer_id") - .build() - ) - .build() - ) - .metadata( - Customer.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .name("name") - .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) - .paymentProviderId("payment_provider_id") - .portalUrl("portal_url") - .shippingAddress( - Customer.ShippingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .taxId( - Customer.TaxId.builder() - .country(Customer.TaxId.Country.AD) - .type(Customer.TaxId.Type.AD_NRT) - .value("value") - .build() - ) - .timezone("timezone") - .accountingSyncConfiguration( - Customer.AccountingSyncConfiguration.builder() - .addAccountingProvider( - Customer.AccountingSyncConfiguration.AccountingProvider - .builder() - .externalProviderId("external_provider_id") - .providerType( - Customer.AccountingSyncConfiguration.AccountingProvider - .ProviderType - .QUICKBOOKS - ) - .build() - ) - .excluded(true) - .build() - ) - .reportingConfiguration( - Customer.ReportingConfiguration.builder().exempt(true).build() - ) - .build() - ) - .defaultInvoiceMemo("default_invoice_memo") - .addDiscountInterval( - SubscriptionUpdateFixedFeeQuantityResponse.DiscountInterval - .AmountDiscountInterval - .builder() - .amountDiscount("amount_discount") - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionUpdateFixedFeeQuantityResponse.DiscountInterval - .AmountDiscountInterval - .DiscountType - .AMOUNT - ) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addFixedFeeQuantitySchedule( - SubscriptionUpdateFixedFeeQuantityResponse.FixedFeeQuantitySchedule.builder() - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .priceId("price_id") - .quantity(0.0) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .invoicingThreshold("invoicing_threshold") - .addMaximumInterval( - SubscriptionUpdateFixedFeeQuantityResponse.MaximumInterval.builder() - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .maximumAmount("maximum_amount") - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .metadata( - SubscriptionUpdateFixedFeeQuantityResponse.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .addMinimumInterval( - SubscriptionUpdateFixedFeeQuantityResponse.MinimumInterval.builder() - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .minimumAmount("minimum_amount") - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .netTerms(0L) - .plan( - Plan.builder() - .id("id") - .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() - .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currency("currency") - .defaultInvoiceMemo("default_invoice_memo") - .description("description") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPlanId("external_plan_id") - .invoicingCurrency("invoicing_currency") - .maximum( - Plan.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Plan.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Plan.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .name("name") - .netTerms(0L) - .addPlanPhase( - Plan.PlanPhase.builder() - .id("id") - .description("description") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .duration(0L) - .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) - .maximum( - Plan.PlanPhase.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Plan.PlanPhase.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .name("name") - .order(0L) - .build() - ) - .addPrice( - Price.UnitPrice.builder() - .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) - .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY - ) - .build() - ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) - .conversionRate(0.0) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() - .allowsRollover(true) - .currency("currency") - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY - ) - .build() - ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) - .maximum( - Price.UnitPrice.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.UnitPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Price.UnitPrice.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) - .name("name") - .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) - .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) - .build() - ) - .product( - Plan.Product.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .name("name") - .build() - ) - .status(Plan.Status.ACTIVE) - .trialConfig( - Plan.TrialConfig.builder() - .trialPeriod(0L) - .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) - .build() - ) - .version(0L) - .build() - ) - .addPriceInterval( - SubscriptionUpdateFixedFeeQuantityResponse.PriceInterval.builder() - .id("id") - .billingCycleDay(0L) - .currentBillingPeriodEndDate( - OffsetDateTime.parse("2019-12-27T18:11:19.117Z") - ) - .currentBillingPeriodStartDate( - OffsetDateTime.parse("2019-12-27T18:11:19.117Z") - ) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .filter("filter") - .addFixedFeeQuantityTransition( - SubscriptionUpdateFixedFeeQuantityResponse.PriceInterval - .FixedFeeQuantityTransition - .builder() - .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .priceId("price_id") - .quantity(0L) - .build() - ) - .price( - Price.UnitPrice.builder() - .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) - .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY - ) - .build() - ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) - .conversionRate(0.0) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() - .allowsRollover(true) - .currency("currency") - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY - ) - .build() - ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) - .maximum( - Price.UnitPrice.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.UnitPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Price.UnitPrice.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) - .name("name") - .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) - .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) - .build() - ) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addUsageCustomerId("string") - .build() - ) - .redeemedCoupon( - SubscriptionUpdateFixedFeeQuantityResponse.RedeemedCoupon.builder() - .couponId("coupon_id") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .status(SubscriptionUpdateFixedFeeQuantityResponse.Status.ACTIVE) - .trialInfo( - SubscriptionUpdateFixedFeeQuantityResponse.TrialInfo.builder() - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .build() - assertThat(subscriptionUpdateFixedFeeQuantityResponse).isNotNull - assertThat(subscriptionUpdateFixedFeeQuantityResponse.id()).isEqualTo("id") - assertThat(subscriptionUpdateFixedFeeQuantityResponse.activePlanPhaseOrder()).contains(0L) - assertThat(subscriptionUpdateFixedFeeQuantityResponse.adjustmentIntervals()) - .containsExactly( - SubscriptionUpdateFixedFeeQuantityResponse.AdjustmentInterval.builder() - .id("id") - .adjustment( - SubscriptionUpdateFixedFeeQuantityResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .builder() - .id("id") - .adjustmentType( - SubscriptionUpdateFixedFeeQuantityResponse.AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionUpdateFixedFeeQuantityResponse.autoCollection()).contains(true) - assertThat(subscriptionUpdateFixedFeeQuantityResponse.billingCycleAnchorConfiguration()) - .isEqualTo( - SubscriptionUpdateFixedFeeQuantityResponse.BillingCycleAnchorConfiguration.builder() - .day(1L) - .month(1L) - .year(0L) - .build() - ) - assertThat(subscriptionUpdateFixedFeeQuantityResponse.billingCycleDay()).isEqualTo(1L) - assertThat(subscriptionUpdateFixedFeeQuantityResponse.createdAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionUpdateFixedFeeQuantityResponse.currentBillingPeriodEndDate()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionUpdateFixedFeeQuantityResponse.currentBillingPeriodStartDate()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionUpdateFixedFeeQuantityResponse.customer()) - .isEqualTo( - Customer.builder() - .id("id") - .addAdditionalEmail("string") - .autoCollection(true) - .balance("balance") - .billingAddress( - Customer.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currency("currency") - .email("email") - .emailDelivery(true) - .exemptFromAutomatedTax(true) - .externalCustomerId("external_customer_id") - .hierarchy( - Customer.Hierarchy.builder() - .addChild( - Customer.Hierarchy.Child.builder() - .id("id") - .externalCustomerId("external_customer_id") - .build() - ) - .parent( - Customer.Hierarchy.Parent.builder() - .id("id") - .externalCustomerId("external_customer_id") - .build() - ) - .build() - ) - .metadata( - Customer.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .name("name") - .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) - .paymentProviderId("payment_provider_id") - .portalUrl("portal_url") - .shippingAddress( - Customer.ShippingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .taxId( - Customer.TaxId.builder() - .country(Customer.TaxId.Country.AD) - .type(Customer.TaxId.Type.AD_NRT) - .value("value") - .build() - ) - .timezone("timezone") - .accountingSyncConfiguration( - Customer.AccountingSyncConfiguration.builder() - .addAccountingProvider( - Customer.AccountingSyncConfiguration.AccountingProvider.builder() - .externalProviderId("external_provider_id") - .providerType( - Customer.AccountingSyncConfiguration.AccountingProvider - .ProviderType - .QUICKBOOKS - ) - .build() - ) - .excluded(true) - .build() - ) - .reportingConfiguration( - Customer.ReportingConfiguration.builder().exempt(true).build() - ) - .build() - ) - assertThat(subscriptionUpdateFixedFeeQuantityResponse.defaultInvoiceMemo()) - .contains("default_invoice_memo") - assertThat(subscriptionUpdateFixedFeeQuantityResponse.discountIntervals()) - .containsExactly( - SubscriptionUpdateFixedFeeQuantityResponse.DiscountInterval.ofAmount( - SubscriptionUpdateFixedFeeQuantityResponse.DiscountInterval - .AmountDiscountInterval - .builder() - .amountDiscount("amount_discount") - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionUpdateFixedFeeQuantityResponse.DiscountInterval - .AmountDiscountInterval - .DiscountType - .AMOUNT - ) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - ) - assertThat(subscriptionUpdateFixedFeeQuantityResponse.endDate()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionUpdateFixedFeeQuantityResponse.fixedFeeQuantitySchedule()) - .containsExactly( - SubscriptionUpdateFixedFeeQuantityResponse.FixedFeeQuantitySchedule.builder() - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .priceId("price_id") - .quantity(0.0) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionUpdateFixedFeeQuantityResponse.invoicingThreshold()) - .contains("invoicing_threshold") - assertThat(subscriptionUpdateFixedFeeQuantityResponse.maximumIntervals()) - .containsExactly( - SubscriptionUpdateFixedFeeQuantityResponse.MaximumInterval.builder() - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .maximumAmount("maximum_amount") - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionUpdateFixedFeeQuantityResponse.metadata()) - .isEqualTo( - SubscriptionUpdateFixedFeeQuantityResponse.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - assertThat(subscriptionUpdateFixedFeeQuantityResponse.minimumIntervals()) - .containsExactly( - SubscriptionUpdateFixedFeeQuantityResponse.MinimumInterval.builder() - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .minimumAmount("minimum_amount") - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionUpdateFixedFeeQuantityResponse.netTerms()).isEqualTo(0L) - assertThat(subscriptionUpdateFixedFeeQuantityResponse.plan()) - .isEqualTo( - Plan.builder() - .id("id") - .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() - .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currency("currency") - .defaultInvoiceMemo("default_invoice_memo") - .description("description") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPlanId("external_plan_id") - .invoicingCurrency("invoicing_currency") - .maximum( - Plan.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Plan.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Plan.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .name("name") - .netTerms(0L) - .addPlanPhase( - Plan.PlanPhase.builder() - .id("id") - .description("description") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .duration(0L) - .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) - .maximum( - Plan.PlanPhase.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Plan.PlanPhase.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .name("name") - .order(0L) - .build() - ) - .addPrice( - Price.UnitPrice.builder() - .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) - .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY - ) - .build() - ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) - .conversionRate(0.0) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() - .allowsRollover(true) - .currency("currency") - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY - ) - .build() - ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) - .maximum( - Price.UnitPrice.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.UnitPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Price.UnitPrice.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) - .name("name") - .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) - .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) - .build() - ) - .product( - Plan.Product.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .name("name") - .build() - ) - .status(Plan.Status.ACTIVE) - .trialConfig( - Plan.TrialConfig.builder() - .trialPeriod(0L) - .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) - .build() - ) - .version(0L) - .build() - ) - assertThat(subscriptionUpdateFixedFeeQuantityResponse.priceIntervals()) - .containsExactly( - SubscriptionUpdateFixedFeeQuantityResponse.PriceInterval.builder() - .id("id") - .billingCycleDay(0L) - .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .filter("filter") - .addFixedFeeQuantityTransition( - SubscriptionUpdateFixedFeeQuantityResponse.PriceInterval - .FixedFeeQuantityTransition - .builder() - .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .priceId("price_id") - .quantity(0L) - .build() - ) - .price( - Price.UnitPrice.builder() - .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) - .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY - ) - .build() - ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) - .conversionRate(0.0) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() - .allowsRollover(true) - .currency("currency") - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY - ) - .build() - ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) - .maximum( - Price.UnitPrice.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.UnitPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Price.UnitPrice.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) - .name("name") - .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) - .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) - .build() - ) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addUsageCustomerId("string") - .build() - ) - assertThat(subscriptionUpdateFixedFeeQuantityResponse.redeemedCoupon()) - .contains( - SubscriptionUpdateFixedFeeQuantityResponse.RedeemedCoupon.builder() - .couponId("coupon_id") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionUpdateFixedFeeQuantityResponse.startDate()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionUpdateFixedFeeQuantityResponse.status()) - .isEqualTo(SubscriptionUpdateFixedFeeQuantityResponse.Status.ACTIVE) - assertThat(subscriptionUpdateFixedFeeQuantityResponse.trialInfo()) - .isEqualTo( - SubscriptionUpdateFixedFeeQuantityResponse.TrialInfo.builder() - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - } -} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUpdateTrialResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUpdateTrialResponseTest.kt deleted file mode 100644 index 78283d4ae..000000000 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUpdateTrialResponseTest.kt +++ /dev/null @@ -1,1010 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.withorb.api.models - -import com.withorb.api.core.JsonValue -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class SubscriptionUpdateTrialResponseTest { - - @Test - fun createSubscriptionUpdateTrialResponse() { - val subscriptionUpdateTrialResponse = - SubscriptionUpdateTrialResponse.builder() - .id("id") - .activePlanPhaseOrder(0L) - .addAdjustmentInterval( - SubscriptionUpdateTrialResponse.AdjustmentInterval.builder() - .id("id") - .adjustment( - SubscriptionUpdateTrialResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .builder() - .id("id") - .adjustmentType( - SubscriptionUpdateTrialResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .autoCollection(true) - .billingCycleAnchorConfiguration( - SubscriptionUpdateTrialResponse.BillingCycleAnchorConfiguration.builder() - .day(1L) - .month(1L) - .year(0L) - .build() - ) - .billingCycleDay(1L) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .customer( - Customer.builder() - .id("id") - .addAdditionalEmail("string") - .autoCollection(true) - .balance("balance") - .billingAddress( - Customer.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currency("currency") - .email("email") - .emailDelivery(true) - .exemptFromAutomatedTax(true) - .externalCustomerId("external_customer_id") - .hierarchy( - Customer.Hierarchy.builder() - .addChild( - Customer.Hierarchy.Child.builder() - .id("id") - .externalCustomerId("external_customer_id") - .build() - ) - .parent( - Customer.Hierarchy.Parent.builder() - .id("id") - .externalCustomerId("external_customer_id") - .build() - ) - .build() - ) - .metadata( - Customer.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .name("name") - .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) - .paymentProviderId("payment_provider_id") - .portalUrl("portal_url") - .shippingAddress( - Customer.ShippingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .taxId( - Customer.TaxId.builder() - .country(Customer.TaxId.Country.AD) - .type(Customer.TaxId.Type.AD_NRT) - .value("value") - .build() - ) - .timezone("timezone") - .accountingSyncConfiguration( - Customer.AccountingSyncConfiguration.builder() - .addAccountingProvider( - Customer.AccountingSyncConfiguration.AccountingProvider - .builder() - .externalProviderId("external_provider_id") - .providerType( - Customer.AccountingSyncConfiguration.AccountingProvider - .ProviderType - .QUICKBOOKS - ) - .build() - ) - .excluded(true) - .build() - ) - .reportingConfiguration( - Customer.ReportingConfiguration.builder().exempt(true).build() - ) - .build() - ) - .defaultInvoiceMemo("default_invoice_memo") - .addDiscountInterval( - SubscriptionUpdateTrialResponse.DiscountInterval.AmountDiscountInterval - .builder() - .amountDiscount("amount_discount") - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionUpdateTrialResponse.DiscountInterval.AmountDiscountInterval - .DiscountType - .AMOUNT - ) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addFixedFeeQuantitySchedule( - SubscriptionUpdateTrialResponse.FixedFeeQuantitySchedule.builder() - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .priceId("price_id") - .quantity(0.0) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .invoicingThreshold("invoicing_threshold") - .addMaximumInterval( - SubscriptionUpdateTrialResponse.MaximumInterval.builder() - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .maximumAmount("maximum_amount") - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .metadata( - SubscriptionUpdateTrialResponse.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .addMinimumInterval( - SubscriptionUpdateTrialResponse.MinimumInterval.builder() - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .minimumAmount("minimum_amount") - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .netTerms(0L) - .plan( - Plan.builder() - .id("id") - .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() - .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currency("currency") - .defaultInvoiceMemo("default_invoice_memo") - .description("description") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPlanId("external_plan_id") - .invoicingCurrency("invoicing_currency") - .maximum( - Plan.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Plan.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Plan.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .name("name") - .netTerms(0L) - .addPlanPhase( - Plan.PlanPhase.builder() - .id("id") - .description("description") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .duration(0L) - .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) - .maximum( - Plan.PlanPhase.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Plan.PlanPhase.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .name("name") - .order(0L) - .build() - ) - .addPrice( - Price.UnitPrice.builder() - .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) - .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY - ) - .build() - ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) - .conversionRate(0.0) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() - .allowsRollover(true) - .currency("currency") - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY - ) - .build() - ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) - .maximum( - Price.UnitPrice.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.UnitPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Price.UnitPrice.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) - .name("name") - .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) - .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) - .build() - ) - .product( - Plan.Product.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .name("name") - .build() - ) - .status(Plan.Status.ACTIVE) - .trialConfig( - Plan.TrialConfig.builder() - .trialPeriod(0L) - .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) - .build() - ) - .version(0L) - .build() - ) - .addPriceInterval( - SubscriptionUpdateTrialResponse.PriceInterval.builder() - .id("id") - .billingCycleDay(0L) - .currentBillingPeriodEndDate( - OffsetDateTime.parse("2019-12-27T18:11:19.117Z") - ) - .currentBillingPeriodStartDate( - OffsetDateTime.parse("2019-12-27T18:11:19.117Z") - ) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .filter("filter") - .addFixedFeeQuantityTransition( - SubscriptionUpdateTrialResponse.PriceInterval.FixedFeeQuantityTransition - .builder() - .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .priceId("price_id") - .quantity(0L) - .build() - ) - .price( - Price.UnitPrice.builder() - .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) - .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY - ) - .build() - ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) - .conversionRate(0.0) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() - .allowsRollover(true) - .currency("currency") - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY - ) - .build() - ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) - .maximum( - Price.UnitPrice.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.UnitPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Price.UnitPrice.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) - .name("name") - .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) - .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) - .build() - ) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addUsageCustomerId("string") - .build() - ) - .redeemedCoupon( - SubscriptionUpdateTrialResponse.RedeemedCoupon.builder() - .couponId("coupon_id") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .status(SubscriptionUpdateTrialResponse.Status.ACTIVE) - .trialInfo( - SubscriptionUpdateTrialResponse.TrialInfo.builder() - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .build() - assertThat(subscriptionUpdateTrialResponse).isNotNull - assertThat(subscriptionUpdateTrialResponse.id()).isEqualTo("id") - assertThat(subscriptionUpdateTrialResponse.activePlanPhaseOrder()).contains(0L) - assertThat(subscriptionUpdateTrialResponse.adjustmentIntervals()) - .containsExactly( - SubscriptionUpdateTrialResponse.AdjustmentInterval.builder() - .id("id") - .adjustment( - SubscriptionUpdateTrialResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .builder() - .id("id") - .adjustmentType( - SubscriptionUpdateTrialResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionUpdateTrialResponse.autoCollection()).contains(true) - assertThat(subscriptionUpdateTrialResponse.billingCycleAnchorConfiguration()) - .isEqualTo( - SubscriptionUpdateTrialResponse.BillingCycleAnchorConfiguration.builder() - .day(1L) - .month(1L) - .year(0L) - .build() - ) - assertThat(subscriptionUpdateTrialResponse.billingCycleDay()).isEqualTo(1L) - assertThat(subscriptionUpdateTrialResponse.createdAt()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionUpdateTrialResponse.currentBillingPeriodEndDate()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionUpdateTrialResponse.currentBillingPeriodStartDate()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionUpdateTrialResponse.customer()) - .isEqualTo( - Customer.builder() - .id("id") - .addAdditionalEmail("string") - .autoCollection(true) - .balance("balance") - .billingAddress( - Customer.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currency("currency") - .email("email") - .emailDelivery(true) - .exemptFromAutomatedTax(true) - .externalCustomerId("external_customer_id") - .hierarchy( - Customer.Hierarchy.builder() - .addChild( - Customer.Hierarchy.Child.builder() - .id("id") - .externalCustomerId("external_customer_id") - .build() - ) - .parent( - Customer.Hierarchy.Parent.builder() - .id("id") - .externalCustomerId("external_customer_id") - .build() - ) - .build() - ) - .metadata( - Customer.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .name("name") - .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) - .paymentProviderId("payment_provider_id") - .portalUrl("portal_url") - .shippingAddress( - Customer.ShippingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .taxId( - Customer.TaxId.builder() - .country(Customer.TaxId.Country.AD) - .type(Customer.TaxId.Type.AD_NRT) - .value("value") - .build() - ) - .timezone("timezone") - .accountingSyncConfiguration( - Customer.AccountingSyncConfiguration.builder() - .addAccountingProvider( - Customer.AccountingSyncConfiguration.AccountingProvider.builder() - .externalProviderId("external_provider_id") - .providerType( - Customer.AccountingSyncConfiguration.AccountingProvider - .ProviderType - .QUICKBOOKS - ) - .build() - ) - .excluded(true) - .build() - ) - .reportingConfiguration( - Customer.ReportingConfiguration.builder().exempt(true).build() - ) - .build() - ) - assertThat(subscriptionUpdateTrialResponse.defaultInvoiceMemo()) - .contains("default_invoice_memo") - assertThat(subscriptionUpdateTrialResponse.discountIntervals()) - .containsExactly( - SubscriptionUpdateTrialResponse.DiscountInterval.ofAmount( - SubscriptionUpdateTrialResponse.DiscountInterval.AmountDiscountInterval - .builder() - .amountDiscount("amount_discount") - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionUpdateTrialResponse.DiscountInterval.AmountDiscountInterval - .DiscountType - .AMOUNT - ) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - ) - assertThat(subscriptionUpdateTrialResponse.endDate()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionUpdateTrialResponse.fixedFeeQuantitySchedule()) - .containsExactly( - SubscriptionUpdateTrialResponse.FixedFeeQuantitySchedule.builder() - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .priceId("price_id") - .quantity(0.0) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionUpdateTrialResponse.invoicingThreshold()) - .contains("invoicing_threshold") - assertThat(subscriptionUpdateTrialResponse.maximumIntervals()) - .containsExactly( - SubscriptionUpdateTrialResponse.MaximumInterval.builder() - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .maximumAmount("maximum_amount") - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionUpdateTrialResponse.metadata()) - .isEqualTo( - SubscriptionUpdateTrialResponse.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - assertThat(subscriptionUpdateTrialResponse.minimumIntervals()) - .containsExactly( - SubscriptionUpdateTrialResponse.MinimumInterval.builder() - .addAppliesToPriceId("string") - .addAppliesToPriceIntervalId("string") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .minimumAmount("minimum_amount") - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionUpdateTrialResponse.netTerms()).isEqualTo(0L) - assertThat(subscriptionUpdateTrialResponse.plan()) - .isEqualTo( - Plan.builder() - .id("id") - .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() - .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) - .addAppliesToPriceId("string") - .isInvoiceLevel(true) - .planPhaseOrder(0L) - .reason("reason") - .usageDiscount(0.0) - .build() - ) - .basePlan( - Plan.BasePlan.builder() - .id("m2t5akQeh2obwxeU") - .externalPlanId("m2t5akQeh2obwxeU") - .name("Example plan") - .build() - ) - .basePlanId("base_plan_id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currency("currency") - .defaultInvoiceMemo("default_invoice_memo") - .description("description") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPlanId("external_plan_id") - .invoicingCurrency("invoicing_currency") - .maximum( - Plan.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Plan.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Plan.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .name("name") - .netTerms(0L) - .addPlanPhase( - Plan.PlanPhase.builder() - .id("id") - .description("description") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .duration(0L) - .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) - .maximum( - Plan.PlanPhase.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .minimum( - Plan.PlanPhase.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .name("name") - .order(0L) - .build() - ) - .addPrice( - Price.UnitPrice.builder() - .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) - .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY - ) - .build() - ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) - .conversionRate(0.0) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() - .allowsRollover(true) - .currency("currency") - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY - ) - .build() - ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) - .maximum( - Price.UnitPrice.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.UnitPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Price.UnitPrice.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) - .name("name") - .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) - .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) - .build() - ) - .product( - Plan.Product.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .name("name") - .build() - ) - .status(Plan.Status.ACTIVE) - .trialConfig( - Plan.TrialConfig.builder() - .trialPeriod(0L) - .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) - .build() - ) - .version(0L) - .build() - ) - assertThat(subscriptionUpdateTrialResponse.priceIntervals()) - .containsExactly( - SubscriptionUpdateTrialResponse.PriceInterval.builder() - .id("id") - .billingCycleDay(0L) - .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .filter("filter") - .addFixedFeeQuantityTransition( - SubscriptionUpdateTrialResponse.PriceInterval.FixedFeeQuantityTransition - .builder() - .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .priceId("price_id") - .quantity(0L) - .build() - ) - .price( - Price.UnitPrice.builder() - .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) - .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY - ) - .build() - ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) - .conversionRate(0.0) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() - .allowsRollover(true) - .currency("currency") - .build() - ) - .currency("currency") - .discount( - PercentageDiscount.builder() - .addAppliesToPriceId("h74gfhdjvn7ujokd") - .addAppliesToPriceId("7hfgtgjnbvc3ujkl") - .discountType(PercentageDiscount.DiscountType.PERCENTAGE) - .percentageDiscount(0.15) - .reason("reason") - .build() - ) - .externalPriceId("external_price_id") - .fixedPriceQuantity(0.0) - .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() - .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY - ) - .build() - ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) - .maximum( - Price.UnitPrice.Maximum.builder() - .addAppliesToPriceId("string") - .maximumAmount("maximum_amount") - .build() - ) - .maximumAmount("maximum_amount") - .metadata( - Price.UnitPrice.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .minimum( - Price.UnitPrice.Minimum.builder() - .addAppliesToPriceId("string") - .minimumAmount("minimum_amount") - .build() - ) - .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) - .name("name") - .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) - .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() - .addDimensionValue("string") - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) - .build() - ) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addUsageCustomerId("string") - .build() - ) - assertThat(subscriptionUpdateTrialResponse.redeemedCoupon()) - .contains( - SubscriptionUpdateTrialResponse.RedeemedCoupon.builder() - .couponId("coupon_id") - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(subscriptionUpdateTrialResponse.startDate()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(subscriptionUpdateTrialResponse.status()) - .isEqualTo(SubscriptionUpdateTrialResponse.Status.ACTIVE) - assertThat(subscriptionUpdateTrialResponse.trialInfo()) - .isEqualTo( - SubscriptionUpdateTrialResponse.TrialInfo.builder() - .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - } -} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionsModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionsModelTest.kt new file mode 100644 index 000000000..a0647a448 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionsModelTest.kt @@ -0,0 +1,1016 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.JsonValue +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class SubscriptionsModelTest { + + @Test + fun createSubscriptionsModel() { + val subscriptionsModel = + SubscriptionsModel.builder() + .addData( + SubscriptionModel.builder() + .id("id") + .activePlanPhaseOrder(0L) + .addAdjustmentInterval( + AdjustmentIntervalModel.builder() + .id("id") + .adjustment( + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.builder() + .id("id") + .adjustmentType( + AdjustmentModel.PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .autoCollection(true) + .billingCycleAnchorConfiguration( + BillingCycleAnchorConfigurationModel.builder() + .day(1L) + .month(1L) + .year(0L) + .build() + ) + .billingCycleDay(1L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodEndDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .currentBillingPeriodStartDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .customer( + CustomerModel.builder() + .id("id") + .addAdditionalEmail("string") + .autoCollection(true) + .balance("balance") + .billingAddress( + AddressModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .email("email") + .emailDelivery(true) + .exemptFromAutomatedTax(true) + .externalCustomerId("external_customer_id") + .hierarchy( + CustomerModel.Hierarchy.builder() + .addChild( + CustomerMinifiedModel.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .parent( + CustomerMinifiedModel.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .build() + ) + .metadata( + CustomerModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .paymentProvider(CustomerModel.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .portalUrl("portal_url") + .shippingAddress( + AddressModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxId( + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) + .value("value") + .build() + ) + .timezone("timezone") + .accountingSyncConfiguration( + CustomerModel.AccountingSyncConfiguration.builder() + .addAccountingProvider( + CustomerModel.AccountingSyncConfiguration + .AccountingProvider + .builder() + .externalProviderId("external_provider_id") + .providerType( + CustomerModel.AccountingSyncConfiguration + .AccountingProvider + .ProviderType + .QUICKBOOKS + ) + .build() + ) + .excluded(true) + .build() + ) + .reportingConfiguration( + CustomerModel.ReportingConfiguration.builder() + .exempt(true) + .build() + ) + .build() + ) + .defaultInvoiceMemo("default_invoice_memo") + .addDiscountInterval( + AmountDiscountIntervalModel.builder() + .amountDiscount("amount_discount") + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .discountType(AmountDiscountIntervalModel.DiscountType.AMOUNT) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFixedFeeQuantitySchedule( + FixedFeeQuantityScheduleEntryModel.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0.0) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .invoicingThreshold("invoicing_threshold") + .addMaximumInterval( + MaximumIntervalModel.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .maximumAmount("maximum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .metadata( + SubscriptionModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addMinimumInterval( + MinimumIntervalModel.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minimumAmount("minimum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .netTerms(0L) + .plan( + PlanModel.builder() + .id("id") + .addAdjustment( + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.builder() + .id("id") + .adjustmentType( + AdjustmentModel.PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .basePlan( + PlanMinifiedModel.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .defaultInvoiceMemo("default_invoice_memo") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + MaximumModel.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + PlanModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + MinimumModel.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(0L) + .addPlanPhase( + PlanModel.PlanPhase.builder() + .id("id") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .duration(0L) + .durationUnit(PlanModel.PlanPhase.DurationUnit.DAILY) + .maximum( + MaximumModel.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + MinimumModel.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(0L) + .build() + ) + .addPrice( + PriceModel.UnitPrice.builder() + .id("id") + .billableMetric( + BillableMetricTinyModel.builder().id("id").build() + ) + .billingCycleConfiguration( + BillingCycleConfigurationModel.builder() + .duration(0L) + .durationUnit( + BillingCycleConfigurationModel.DurationUnit.DAY + ) + .build() + ) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + AllocationModel.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + BillingCycleConfigurationModel.builder() + .duration(0L) + .durationUnit( + BillingCycleConfigurationModel.DurationUnit.DAY + ) + .build() + ) + .item(ItemSlimModel.builder().id("id").name("name").build()) + .maximum( + MaximumModel.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + PriceModel.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + MinimumModel.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(PriceModel.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + UnitConfigModel.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + DimensionalPriceConfigurationModel.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .product( + PlanModel.Product.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .build() + ) + .status(PlanModel.Status.ACTIVE) + .trialConfig( + PlanModel.TrialConfig.builder() + .trialPeriod(0L) + .trialPeriodUnit(PlanModel.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(0L) + .build() + ) + .addPriceInterval( + PriceIntervalModel.builder() + .id("id") + .billingCycleDay(0L) + .currentBillingPeriodEndDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .currentBillingPeriodStartDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addFixedFeeQuantityTransition( + PriceIntervalModel.FixedFeeQuantityTransition.builder() + .effectiveDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .priceId("price_id") + .quantity(0L) + .build() + ) + .price( + PriceModel.UnitPrice.builder() + .id("id") + .billableMetric( + BillableMetricTinyModel.builder().id("id").build() + ) + .billingCycleConfiguration( + BillingCycleConfigurationModel.builder() + .duration(0L) + .durationUnit( + BillingCycleConfigurationModel.DurationUnit.DAY + ) + .build() + ) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + AllocationModel.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + BillingCycleConfigurationModel.builder() + .duration(0L) + .durationUnit( + BillingCycleConfigurationModel.DurationUnit.DAY + ) + .build() + ) + .item(ItemSlimModel.builder().id("id").name("name").build()) + .maximum( + MaximumModel.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + PriceModel.UnitPrice.Metadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from("string"), + ) + .build() + ) + .minimum( + MinimumModel.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(PriceModel.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + UnitConfigModel.builder() + .unitAmount("unit_amount") + .build() + ) + .dimensionalPriceConfiguration( + DimensionalPriceConfigurationModel.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId( + "dimensional_price_group_id" + ) + .build() + ) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addUsageCustomerId("string") + .build() + ) + .redeemedCoupon( + CouponRedemptionModel.builder() + .couponId("coupon_id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(SubscriptionModel.Status.ACTIVE) + .trialInfo( + SubscriptionTrialInfoModel.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + ) + .paginationMetadata( + PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build() + ) + .build() + assertThat(subscriptionsModel).isNotNull + assertThat(subscriptionsModel.data()) + .containsExactly( + SubscriptionModel.builder() + .id("id") + .activePlanPhaseOrder(0L) + .addAdjustmentInterval( + AdjustmentIntervalModel.builder() + .id("id") + .adjustment( + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.builder() + .id("id") + .adjustmentType( + AdjustmentModel.PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .autoCollection(true) + .billingCycleAnchorConfiguration( + BillingCycleAnchorConfigurationModel.builder() + .day(1L) + .month(1L) + .year(0L) + .build() + ) + .billingCycleDay(1L) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customer( + CustomerModel.builder() + .id("id") + .addAdditionalEmail("string") + .autoCollection(true) + .balance("balance") + .billingAddress( + AddressModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .email("email") + .emailDelivery(true) + .exemptFromAutomatedTax(true) + .externalCustomerId("external_customer_id") + .hierarchy( + CustomerModel.Hierarchy.builder() + .addChild( + CustomerMinifiedModel.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .parent( + CustomerMinifiedModel.builder() + .id("id") + .externalCustomerId("external_customer_id") + .build() + ) + .build() + ) + .metadata( + CustomerModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .paymentProvider(CustomerModel.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .portalUrl("portal_url") + .shippingAddress( + AddressModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxId( + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) + .value("value") + .build() + ) + .timezone("timezone") + .accountingSyncConfiguration( + CustomerModel.AccountingSyncConfiguration.builder() + .addAccountingProvider( + CustomerModel.AccountingSyncConfiguration.AccountingProvider + .builder() + .externalProviderId("external_provider_id") + .providerType( + CustomerModel.AccountingSyncConfiguration + .AccountingProvider + .ProviderType + .QUICKBOOKS + ) + .build() + ) + .excluded(true) + .build() + ) + .reportingConfiguration( + CustomerModel.ReportingConfiguration.builder().exempt(true).build() + ) + .build() + ) + .defaultInvoiceMemo("default_invoice_memo") + .addDiscountInterval( + AmountDiscountIntervalModel.builder() + .amountDiscount("amount_discount") + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .discountType(AmountDiscountIntervalModel.DiscountType.AMOUNT) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addFixedFeeQuantitySchedule( + FixedFeeQuantityScheduleEntryModel.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0.0) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .invoicingThreshold("invoicing_threshold") + .addMaximumInterval( + MaximumIntervalModel.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .maximumAmount("maximum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .metadata( + SubscriptionModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .addMinimumInterval( + MinimumIntervalModel.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .minimumAmount("minimum_amount") + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .netTerms(0L) + .plan( + PlanModel.builder() + .id("id") + .addAdjustment( + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.builder() + .id("id") + .adjustmentType( + AdjustmentModel.PlanPhaseUsageDiscountAdjustment + .AdjustmentType + .USAGE_DISCOUNT + ) + .addAppliesToPriceId("string") + .isInvoiceLevel(true) + .planPhaseOrder(0L) + .reason("reason") + .usageDiscount(0.0) + .build() + ) + .basePlan( + PlanMinifiedModel.builder() + .id("m2t5akQeh2obwxeU") + .externalPlanId("m2t5akQeh2obwxeU") + .name("Example plan") + .build() + ) + .basePlanId("base_plan_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .defaultInvoiceMemo("default_invoice_memo") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(PercentageDiscount.DiscountType.PERCENTAGE) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPlanId("external_plan_id") + .invoicingCurrency("invoicing_currency") + .maximum( + MaximumModel.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + PlanModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + MinimumModel.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .netTerms(0L) + .addPlanPhase( + PlanModel.PlanPhase.builder() + .id("id") + .description("description") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .duration(0L) + .durationUnit(PlanModel.PlanPhase.DurationUnit.DAILY) + .maximum( + MaximumModel.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .minimum( + MinimumModel.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .name("name") + .order(0L) + .build() + ) + .addPrice( + PriceModel.UnitPrice.builder() + .id("id") + .billableMetric( + BillableMetricTinyModel.builder().id("id").build() + ) + .billingCycleConfiguration( + BillingCycleConfigurationModel.builder() + .duration(0L) + .durationUnit( + BillingCycleConfigurationModel.DurationUnit.DAY + ) + .build() + ) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + AllocationModel.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + BillingCycleConfigurationModel.builder() + .duration(0L) + .durationUnit( + BillingCycleConfigurationModel.DurationUnit.DAY + ) + .build() + ) + .item(ItemSlimModel.builder().id("id").name("name").build()) + .maximum( + MaximumModel.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + PriceModel.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + MinimumModel.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(PriceModel.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + UnitConfigModel.builder().unitAmount("unit_amount").build() + ) + .dimensionalPriceConfiguration( + DimensionalPriceConfigurationModel.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .product( + PlanModel.Product.builder() + .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .name("name") + .build() + ) + .status(PlanModel.Status.ACTIVE) + .trialConfig( + PlanModel.TrialConfig.builder() + .trialPeriod(0L) + .trialPeriodUnit(PlanModel.TrialConfig.TrialPeriodUnit.DAYS) + .build() + ) + .version(0L) + .build() + ) + .addPriceInterval( + PriceIntervalModel.builder() + .id("id") + .billingCycleDay(0L) + .currentBillingPeriodEndDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .currentBillingPeriodStartDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .filter("filter") + .addFixedFeeQuantityTransition( + PriceIntervalModel.FixedFeeQuantityTransition.builder() + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .priceId("price_id") + .quantity(0L) + .build() + ) + .price( + PriceModel.UnitPrice.builder() + .id("id") + .billableMetric( + BillableMetricTinyModel.builder().id("id").build() + ) + .billingCycleConfiguration( + BillingCycleConfigurationModel.builder() + .duration(0L) + .durationUnit( + BillingCycleConfigurationModel.DurationUnit.DAY + ) + .build() + ) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) + .conversionRate(0.0) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditAllocation( + AllocationModel.builder() + .allowsRollover(true) + .currency("currency") + .build() + ) + .currency("currency") + .discount( + PercentageDiscount.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType( + PercentageDiscount.DiscountType.PERCENTAGE + ) + .percentageDiscount(0.15) + .reason("reason") + .build() + ) + .externalPriceId("external_price_id") + .fixedPriceQuantity(0.0) + .invoicingCycleConfiguration( + BillingCycleConfigurationModel.builder() + .duration(0L) + .durationUnit( + BillingCycleConfigurationModel.DurationUnit.DAY + ) + .build() + ) + .item(ItemSlimModel.builder().id("id").name("name").build()) + .maximum( + MaximumModel.builder() + .addAppliesToPriceId("string") + .maximumAmount("maximum_amount") + .build() + ) + .maximumAmount("maximum_amount") + .metadata( + PriceModel.UnitPrice.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .minimum( + MinimumModel.builder() + .addAppliesToPriceId("string") + .minimumAmount("minimum_amount") + .build() + ) + .minimumAmount("minimum_amount") + .modelType(PriceModel.UnitPrice.ModelType.UNIT) + .name("name") + .planPhaseOrder(0L) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) + .unitConfig( + UnitConfigModel.builder().unitAmount("unit_amount").build() + ) + .dimensionalPriceConfiguration( + DimensionalPriceConfigurationModel.builder() + .addDimensionValue("string") + .dimensionalPriceGroupId("dimensional_price_group_id") + .build() + ) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addUsageCustomerId("string") + .build() + ) + .redeemedCoupon( + CouponRedemptionModel.builder() + .couponId("coupon_id") + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(SubscriptionModel.Status.ACTIVE) + .trialInfo( + SubscriptionTrialInfoModel.builder() + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + ) + assertThat(subscriptionsModel.paginationMetadata()) + .isEqualTo(PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build()) + } +} 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 e628922b1..b2d8e610b 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 @@ -14,20 +14,17 @@ class SubscriptionsTest { val subscriptions = Subscriptions.builder() .addData( - Subscription.builder() + SubscriptionModel.builder() .id("id") .activePlanPhaseOrder(0L) .addAdjustmentInterval( - Subscription.AdjustmentInterval.builder() + AdjustmentIntervalModel.builder() .id("id") .adjustment( - Subscription.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .builder() + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.builder() .id("id") .adjustmentType( - Subscription.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment + AdjustmentModel.PlanPhaseUsageDiscountAdjustment .AdjustmentType .USAGE_DISCOUNT ) @@ -45,7 +42,7 @@ class SubscriptionsTest { ) .autoCollection(true) .billingCycleAnchorConfiguration( - Subscription.BillingCycleAnchorConfiguration.builder() + BillingCycleAnchorConfigurationModel.builder() .day(1L) .month(1L) .year(0L) @@ -60,13 +57,13 @@ class SubscriptionsTest { OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .customer( - Customer.builder() + CustomerModel.builder() .id("id") .addAdditionalEmail("string") .autoCollection(true) .balance("balance") .billingAddress( - Customer.BillingAddress.builder() + AddressModel.builder() .city("city") .country("country") .line1("line1") @@ -82,15 +79,15 @@ class SubscriptionsTest { .exemptFromAutomatedTax(true) .externalCustomerId("external_customer_id") .hierarchy( - Customer.Hierarchy.builder() + CustomerModel.Hierarchy.builder() .addChild( - Customer.Hierarchy.Child.builder() + CustomerMinifiedModel.builder() .id("id") .externalCustomerId("external_customer_id") .build() ) .parent( - Customer.Hierarchy.Parent.builder() + CustomerMinifiedModel.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -98,16 +95,16 @@ class SubscriptionsTest { .build() ) .metadata( - Customer.Metadata.builder() + CustomerModel.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .name("name") - .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) + .paymentProvider(CustomerModel.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .portalUrl("portal_url") .shippingAddress( - Customer.ShippingAddress.builder() + AddressModel.builder() .city("city") .country("country") .line1("line1") @@ -117,21 +114,22 @@ class SubscriptionsTest { .build() ) .taxId( - Customer.TaxId.builder() - .country(Customer.TaxId.Country.AD) - .type(Customer.TaxId.Type.AD_NRT) + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) .value("value") .build() ) .timezone("timezone") .accountingSyncConfiguration( - Customer.AccountingSyncConfiguration.builder() + CustomerModel.AccountingSyncConfiguration.builder() .addAccountingProvider( - Customer.AccountingSyncConfiguration.AccountingProvider + CustomerModel.AccountingSyncConfiguration + .AccountingProvider .builder() .externalProviderId("external_provider_id") .providerType( - Customer.AccountingSyncConfiguration + CustomerModel.AccountingSyncConfiguration .AccountingProvider .ProviderType .QUICKBOOKS @@ -142,28 +140,26 @@ class SubscriptionsTest { .build() ) .reportingConfiguration( - Customer.ReportingConfiguration.builder().exempt(true).build() + CustomerModel.ReportingConfiguration.builder() + .exempt(true) + .build() ) .build() ) .defaultInvoiceMemo("default_invoice_memo") .addDiscountInterval( - Subscription.DiscountInterval.AmountDiscountInterval.builder() + AmountDiscountIntervalModel.builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - Subscription.DiscountInterval.AmountDiscountInterval - .DiscountType - .AMOUNT - ) + .discountType(AmountDiscountIntervalModel.DiscountType.AMOUNT) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFixedFeeQuantitySchedule( - Subscription.FixedFeeQuantitySchedule.builder() + FixedFeeQuantityScheduleEntryModel.builder() .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .priceId("price_id") .quantity(0.0) @@ -172,7 +168,7 @@ class SubscriptionsTest { ) .invoicingThreshold("invoicing_threshold") .addMaximumInterval( - Subscription.MaximumInterval.builder() + MaximumIntervalModel.builder() .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -181,12 +177,12 @@ class SubscriptionsTest { .build() ) .metadata( - Subscription.Metadata.builder() + SubscriptionModel.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .addMinimumInterval( - Subscription.MinimumInterval.builder() + MinimumIntervalModel.builder() .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -196,13 +192,13 @@ class SubscriptionsTest { ) .netTerms(0L) .plan( - Plan.builder() + PlanModel.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.builder() .id("id") .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment + AdjustmentModel.PlanPhaseUsageDiscountAdjustment .AdjustmentType .USAGE_DISCOUNT ) @@ -214,7 +210,7 @@ class SubscriptionsTest { .build() ) .basePlan( - Plan.BasePlan.builder() + PlanMinifiedModel.builder() .id("m2t5akQeh2obwxeU") .externalPlanId("m2t5akQeh2obwxeU") .name("Example plan") @@ -237,19 +233,19 @@ class SubscriptionsTest { .externalPlanId("external_plan_id") .invoicingCurrency("invoicing_currency") .maximum( - Plan.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Plan.Metadata.builder() + PlanModel.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Plan.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() @@ -258,7 +254,7 @@ class SubscriptionsTest { .name("name") .netTerms(0L) .addPlanPhase( - Plan.PlanPhase.builder() + PlanModel.PlanPhase.builder() .id("id") .description("description") .discount( @@ -273,16 +269,16 @@ class SubscriptionsTest { .build() ) .duration(0L) - .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .durationUnit(PlanModel.PlanPhase.DurationUnit.DAILY) .maximum( - Plan.PlanPhase.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .minimum( - Plan.PlanPhase.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() @@ -293,28 +289,24 @@ class SubscriptionsTest { .build() ) .addPrice( - Price.UnitPrice.builder() + PriceModel.UnitPrice.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + BillableMetricTinyModel.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration - .DurationUnit - .DAY + BillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + AllocationModel.builder() .allowsRollover(true) .currency("currency") .build() @@ -334,30 +326,23 @@ class SubscriptionsTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration - .DurationUnit - .DAY + BillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) - .item( - Price.UnitPrice.Item.builder() - .id("id") - .name("name") - .build() - ) + .item(ItemSlimModel.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + PriceModel.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -365,23 +350,23 @@ class SubscriptionsTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) + .modelType(PriceModel.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + UnitConfigModel.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + DimensionalPriceConfigurationModel.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -391,24 +376,24 @@ class SubscriptionsTest { .build() ) .product( - Plan.Product.builder() + PlanModel.Product.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .name("name") .build() ) - .status(Plan.Status.ACTIVE) + .status(PlanModel.Status.ACTIVE) .trialConfig( - Plan.TrialConfig.builder() + PlanModel.TrialConfig.builder() .trialPeriod(0L) - .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .trialPeriodUnit(PlanModel.TrialConfig.TrialPeriodUnit.DAYS) .build() ) .version(0L) .build() ) .addPriceInterval( - Subscription.PriceInterval.builder() + PriceIntervalModel.builder() .id("id") .billingCycleDay(0L) .currentBillingPeriodEndDate( @@ -420,7 +405,7 @@ class SubscriptionsTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .filter("filter") .addFixedFeeQuantityTransition( - Subscription.PriceInterval.FixedFeeQuantityTransition.builder() + PriceIntervalModel.FixedFeeQuantityTransition.builder() .effectiveDate( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) @@ -429,28 +414,24 @@ class SubscriptionsTest { .build() ) .price( - Price.UnitPrice.builder() + PriceModel.UnitPrice.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + BillableMetricTinyModel.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration - .DurationUnit - .DAY + BillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + AllocationModel.builder() .allowsRollover(true) .currency("currency") .build() @@ -470,30 +451,23 @@ class SubscriptionsTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration - .DurationUnit - .DAY + BillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) - .item( - Price.UnitPrice.Item.builder() - .id("id") - .name("name") - .build() - ) + .item(ItemSlimModel.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + PriceModel.UnitPrice.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -501,23 +475,23 @@ class SubscriptionsTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) + .modelType(PriceModel.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + UnitConfigModel.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + DimensionalPriceConfigurationModel.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -531,16 +505,16 @@ class SubscriptionsTest { .build() ) .redeemedCoupon( - Subscription.RedeemedCoupon.builder() + CouponRedemptionModel.builder() .couponId("coupon_id") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .status(Subscription.Status.ACTIVE) + .status(SubscriptionModel.Status.ACTIVE) .trialInfo( - Subscription.TrialInfo.builder() + SubscriptionTrialInfoModel.builder() .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) @@ -553,20 +527,17 @@ class SubscriptionsTest { assertThat(subscriptions).isNotNull assertThat(subscriptions.data()) .containsExactly( - Subscription.builder() + SubscriptionModel.builder() .id("id") .activePlanPhaseOrder(0L) .addAdjustmentInterval( - Subscription.AdjustmentInterval.builder() + AdjustmentIntervalModel.builder() .id("id") .adjustment( - Subscription.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .builder() + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.builder() .id("id") .adjustmentType( - Subscription.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment + AdjustmentModel.PlanPhaseUsageDiscountAdjustment .AdjustmentType .USAGE_DISCOUNT ) @@ -584,7 +555,7 @@ class SubscriptionsTest { ) .autoCollection(true) .billingCycleAnchorConfiguration( - Subscription.BillingCycleAnchorConfiguration.builder() + BillingCycleAnchorConfigurationModel.builder() .day(1L) .month(1L) .year(0L) @@ -595,13 +566,13 @@ class SubscriptionsTest { .currentBillingPeriodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currentBillingPeriodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .customer( - Customer.builder() + CustomerModel.builder() .id("id") .addAdditionalEmail("string") .autoCollection(true) .balance("balance") .billingAddress( - Customer.BillingAddress.builder() + AddressModel.builder() .city("city") .country("country") .line1("line1") @@ -617,15 +588,15 @@ class SubscriptionsTest { .exemptFromAutomatedTax(true) .externalCustomerId("external_customer_id") .hierarchy( - Customer.Hierarchy.builder() + CustomerModel.Hierarchy.builder() .addChild( - Customer.Hierarchy.Child.builder() + CustomerMinifiedModel.builder() .id("id") .externalCustomerId("external_customer_id") .build() ) .parent( - Customer.Hierarchy.Parent.builder() + CustomerMinifiedModel.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -633,16 +604,16 @@ class SubscriptionsTest { .build() ) .metadata( - Customer.Metadata.builder() + CustomerModel.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .name("name") - .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) + .paymentProvider(CustomerModel.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .portalUrl("portal_url") .shippingAddress( - Customer.ShippingAddress.builder() + AddressModel.builder() .city("city") .country("country") .line1("line1") @@ -652,21 +623,21 @@ class SubscriptionsTest { .build() ) .taxId( - Customer.TaxId.builder() - .country(Customer.TaxId.Country.AD) - .type(Customer.TaxId.Type.AD_NRT) + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) .value("value") .build() ) .timezone("timezone") .accountingSyncConfiguration( - Customer.AccountingSyncConfiguration.builder() + CustomerModel.AccountingSyncConfiguration.builder() .addAccountingProvider( - Customer.AccountingSyncConfiguration.AccountingProvider + CustomerModel.AccountingSyncConfiguration.AccountingProvider .builder() .externalProviderId("external_provider_id") .providerType( - Customer.AccountingSyncConfiguration + CustomerModel.AccountingSyncConfiguration .AccountingProvider .ProviderType .QUICKBOOKS @@ -677,27 +648,24 @@ class SubscriptionsTest { .build() ) .reportingConfiguration( - Customer.ReportingConfiguration.builder().exempt(true).build() + CustomerModel.ReportingConfiguration.builder().exempt(true).build() ) .build() ) .defaultInvoiceMemo("default_invoice_memo") .addDiscountInterval( - Subscription.DiscountInterval.AmountDiscountInterval.builder() + AmountDiscountIntervalModel.builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - Subscription.DiscountInterval.AmountDiscountInterval.DiscountType - .AMOUNT - ) + .discountType(AmountDiscountIntervalModel.DiscountType.AMOUNT) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addFixedFeeQuantitySchedule( - Subscription.FixedFeeQuantitySchedule.builder() + FixedFeeQuantityScheduleEntryModel.builder() .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .priceId("price_id") .quantity(0.0) @@ -706,7 +674,7 @@ class SubscriptionsTest { ) .invoicingThreshold("invoicing_threshold") .addMaximumInterval( - Subscription.MaximumInterval.builder() + MaximumIntervalModel.builder() .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -715,12 +683,12 @@ class SubscriptionsTest { .build() ) .metadata( - Subscription.Metadata.builder() + SubscriptionModel.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .addMinimumInterval( - Subscription.MinimumInterval.builder() + MinimumIntervalModel.builder() .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -730,13 +698,13 @@ class SubscriptionsTest { ) .netTerms(0L) .plan( - Plan.builder() + PlanModel.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + AdjustmentModel.PlanPhaseUsageDiscountAdjustment.builder() .id("id") .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment + AdjustmentModel.PlanPhaseUsageDiscountAdjustment .AdjustmentType .USAGE_DISCOUNT ) @@ -748,7 +716,7 @@ class SubscriptionsTest { .build() ) .basePlan( - Plan.BasePlan.builder() + PlanMinifiedModel.builder() .id("m2t5akQeh2obwxeU") .externalPlanId("m2t5akQeh2obwxeU") .name("Example plan") @@ -771,19 +739,19 @@ class SubscriptionsTest { .externalPlanId("external_plan_id") .invoicingCurrency("invoicing_currency") .maximum( - Plan.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Plan.Metadata.builder() + PlanModel.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Plan.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() @@ -792,7 +760,7 @@ class SubscriptionsTest { .name("name") .netTerms(0L) .addPlanPhase( - Plan.PlanPhase.builder() + PlanModel.PlanPhase.builder() .id("id") .description("description") .discount( @@ -807,16 +775,16 @@ class SubscriptionsTest { .build() ) .duration(0L) - .durationUnit(Plan.PlanPhase.DurationUnit.DAILY) + .durationUnit(PlanModel.PlanPhase.DurationUnit.DAILY) .maximum( - Plan.PlanPhase.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .minimum( - Plan.PlanPhase.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() @@ -827,26 +795,24 @@ class SubscriptionsTest { .build() ) .addPrice( - Price.UnitPrice.builder() + PriceModel.UnitPrice.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + BillableMetricTinyModel.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration - .DurationUnit - .DAY + BillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + AllocationModel.builder() .allowsRollover(true) .currency("currency") .build() @@ -866,48 +832,42 @@ class SubscriptionsTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration - .DurationUnit - .DAY + BillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) - .item( - Price.UnitPrice.Item.builder().id("id").name("name").build() - ) + .item(ItemSlimModel.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + PriceModel.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) + .modelType(PriceModel.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() + UnitConfigModel.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + DimensionalPriceConfigurationModel.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -915,24 +875,24 @@ class SubscriptionsTest { .build() ) .product( - Plan.Product.builder() + PlanModel.Product.builder() .id("id") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .name("name") .build() ) - .status(Plan.Status.ACTIVE) + .status(PlanModel.Status.ACTIVE) .trialConfig( - Plan.TrialConfig.builder() + PlanModel.TrialConfig.builder() .trialPeriod(0L) - .trialPeriodUnit(Plan.TrialConfig.TrialPeriodUnit.DAYS) + .trialPeriodUnit(PlanModel.TrialConfig.TrialPeriodUnit.DAYS) .build() ) .version(0L) .build() ) .addPriceInterval( - Subscription.PriceInterval.builder() + PriceIntervalModel.builder() .id("id") .billingCycleDay(0L) .currentBillingPeriodEndDate( @@ -944,33 +904,31 @@ class SubscriptionsTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .filter("filter") .addFixedFeeQuantityTransition( - Subscription.PriceInterval.FixedFeeQuantityTransition.builder() + PriceIntervalModel.FixedFeeQuantityTransition.builder() .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .priceId("price_id") .quantity(0L) .build() ) .price( - Price.UnitPrice.builder() + PriceModel.UnitPrice.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + BillableMetricTinyModel.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration - .DurationUnit - .DAY + BillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(PriceModel.UnitPrice.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + AllocationModel.builder() .allowsRollover(true) .currency("currency") .build() @@ -990,48 +948,42 @@ class SubscriptionsTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + BillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration - .DurationUnit - .DAY + BillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) - .item( - Price.UnitPrice.Item.builder().id("id").name("name").build() - ) + .item(ItemSlimModel.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + MaximumModel.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + PriceModel.UnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + MinimumModel.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) + .modelType(PriceModel.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(PriceModel.UnitPrice.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() + UnitConfigModel.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + DimensionalPriceConfigurationModel.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -1043,16 +995,16 @@ class SubscriptionsTest { .build() ) .redeemedCoupon( - Subscription.RedeemedCoupon.builder() + CouponRedemptionModel.builder() .couponId("coupon_id") .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .status(Subscription.Status.ACTIVE) + .status(SubscriptionModel.Status.ACTIVE) .trialInfo( - Subscription.TrialInfo.builder() + SubscriptionTrialInfoModel.builder() .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/TaxAmountModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/TaxAmountModelTest.kt new file mode 100644 index 000000000..39b571dc3 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/TaxAmountModelTest.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 + +class TaxAmountModelTest { + + @Test + fun createTaxAmountModel() { + val taxAmountModel = + TaxAmountModel.builder() + .amount("amount") + .taxRateDescription("tax_rate_description") + .taxRatePercentage("tax_rate_percentage") + .build() + assertThat(taxAmountModel).isNotNull + assertThat(taxAmountModel.amount()).isEqualTo("amount") + assertThat(taxAmountModel.taxRateDescription()).isEqualTo("tax_rate_description") + assertThat(taxAmountModel.taxRatePercentage()).contains("tax_rate_percentage") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/ThresholdModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/ThresholdModelTest.kt new file mode 100644 index 000000000..28027e063 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/ThresholdModelTest.kt @@ -0,0 +1,16 @@ +// 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 + +class ThresholdModelTest { + + @Test + fun createThresholdModel() { + val thresholdModel = ThresholdModel.builder().value(0.0).build() + assertThat(thresholdModel).isNotNull + assertThat(thresholdModel.value()).isEqualTo(0.0) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/TieredBpsConfigModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/TieredBpsConfigModelTest.kt new file mode 100644 index 000000000..ea494386e --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/TieredBpsConfigModelTest.kt @@ -0,0 +1,34 @@ +// 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 + +class TieredBpsConfigModelTest { + + @Test + fun createTieredBpsConfigModel() { + val tieredBpsConfigModel = + TieredBpsConfigModel.builder() + .addTier( + TieredBpsConfigModel.Tier.builder() + .bps(0.0) + .minimumAmount("minimum_amount") + .maximumAmount("maximum_amount") + .perUnitMaximum("per_unit_maximum") + .build() + ) + .build() + assertThat(tieredBpsConfigModel).isNotNull + assertThat(tieredBpsConfigModel.tiers()) + .containsExactly( + TieredBpsConfigModel.Tier.builder() + .bps(0.0) + .minimumAmount("minimum_amount") + .maximumAmount("maximum_amount") + .perUnitMaximum("per_unit_maximum") + .build() + ) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/TieredConfigModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/TieredConfigModelTest.kt new file mode 100644 index 000000000..27e913bcb --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/TieredConfigModelTest.kt @@ -0,0 +1,32 @@ +// 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 + +class TieredConfigModelTest { + + @Test + fun createTieredConfigModel() { + val tieredConfigModel = + TieredConfigModel.builder() + .addTier( + TieredConfigModel.Tier.builder() + .firstUnit(0.0) + .unitAmount("unit_amount") + .lastUnit(0.0) + .build() + ) + .build() + assertThat(tieredConfigModel).isNotNull + assertThat(tieredConfigModel.tiers()) + .containsExactly( + TieredConfigModel.Tier.builder() + .firstUnit(0.0) + .unitAmount("unit_amount") + .lastUnit(0.0) + .build() + ) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/TopUpModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/TopUpModelTest.kt new file mode 100644 index 000000000..63cbc40c3 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/TopUpModelTest.kt @@ -0,0 +1,48 @@ +// 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 + +class TopUpModelTest { + + @Test + fun createTopUpModel() { + val topUpModel = + TopUpModel.builder() + .id("id") + .amount("amount") + .currency("currency") + .invoiceSettings( + TopUpModel.InvoiceSettings.builder() + .autoCollection(true) + .netTerms(0L) + .memo("memo") + .requireSuccessfulPayment(true) + .build() + ) + .perUnitCostBasis("per_unit_cost_basis") + .threshold("threshold") + .expiresAfter(0L) + .expiresAfterUnit(TopUpModel.ExpiresAfterUnit.DAY) + .build() + assertThat(topUpModel).isNotNull + assertThat(topUpModel.id()).isEqualTo("id") + assertThat(topUpModel.amount()).isEqualTo("amount") + assertThat(topUpModel.currency()).isEqualTo("currency") + assertThat(topUpModel.invoiceSettings()) + .isEqualTo( + TopUpModel.InvoiceSettings.builder() + .autoCollection(true) + .netTerms(0L) + .memo("memo") + .requireSuccessfulPayment(true) + .build() + ) + assertThat(topUpModel.perUnitCostBasis()).isEqualTo("per_unit_cost_basis") + assertThat(topUpModel.threshold()).isEqualTo("threshold") + assertThat(topUpModel.expiresAfter()).contains(0L) + assertThat(topUpModel.expiresAfterUnit()).contains(TopUpModel.ExpiresAfterUnit.DAY) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/TopUpsModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/TopUpsModelTest.kt new file mode 100644 index 000000000..ee2b7eec1 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/TopUpsModelTest.kt @@ -0,0 +1,61 @@ +// 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 + +class TopUpsModelTest { + + @Test + fun createTopUpsModel() { + val topUpsModel = + TopUpsModel.builder() + .addData( + TopUpModel.builder() + .id("id") + .amount("amount") + .currency("currency") + .invoiceSettings( + TopUpModel.InvoiceSettings.builder() + .autoCollection(true) + .netTerms(0L) + .memo("memo") + .requireSuccessfulPayment(true) + .build() + ) + .perUnitCostBasis("per_unit_cost_basis") + .threshold("threshold") + .expiresAfter(0L) + .expiresAfterUnit(TopUpModel.ExpiresAfterUnit.DAY) + .build() + ) + .paginationMetadata( + PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build() + ) + .build() + assertThat(topUpsModel).isNotNull + assertThat(topUpsModel.data()) + .containsExactly( + TopUpModel.builder() + .id("id") + .amount("amount") + .currency("currency") + .invoiceSettings( + TopUpModel.InvoiceSettings.builder() + .autoCollection(true) + .netTerms(0L) + .memo("memo") + .requireSuccessfulPayment(true) + .build() + ) + .perUnitCostBasis("per_unit_cost_basis") + .threshold("threshold") + .expiresAfter(0L) + .expiresAfterUnit(TopUpModel.ExpiresAfterUnit.DAY) + .build() + ) + assertThat(topUpsModel.paginationMetadata()) + .isEqualTo(PaginationMetadata.builder().hasMore(true).nextCursor("next_cursor").build()) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/TrialDiscountModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/TrialDiscountModelTest.kt new file mode 100644 index 000000000..973a78c18 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/TrialDiscountModelTest.kt @@ -0,0 +1,30 @@ +// 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 + +class TrialDiscountModelTest { + + @Test + fun createTrialDiscountModel() { + val trialDiscountModel = + TrialDiscountModel.builder() + .addAppliesToPriceId("h74gfhdjvn7ujokd") + .addAppliesToPriceId("7hfgtgjnbvc3ujkl") + .discountType(TrialDiscountModel.DiscountType.TRIAL) + .reason("reason") + .trialAmountDiscount("trial_amount_discount") + .trialPercentageDiscount(0.0) + .build() + assertThat(trialDiscountModel).isNotNull + assertThat(trialDiscountModel.appliesToPriceIds()) + .containsExactly("h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl") + assertThat(trialDiscountModel.discountType()) + .isEqualTo(TrialDiscountModel.DiscountType.TRIAL) + assertThat(trialDiscountModel.reason()).contains("reason") + assertThat(trialDiscountModel.trialAmountDiscount()).contains("trial_amount_discount") + assertThat(trialDiscountModel.trialPercentageDiscount()).contains(0.0) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/UnitConfigModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/UnitConfigModelTest.kt new file mode 100644 index 000000000..b5d7b0a44 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/UnitConfigModelTest.kt @@ -0,0 +1,16 @@ +// 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 + +class UnitConfigModelTest { + + @Test + fun createUnitConfigModel() { + val unitConfigModel = UnitConfigModel.builder().unitAmount("unit_amount").build() + assertThat(unitConfigModel).isNotNull + assertThat(unitConfigModel.unitAmount()).isEqualTo("unit_amount") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/UpdatePriceRequestParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/UpdatePriceRequestParamsTest.kt new file mode 100644 index 000000000..174a8e0e6 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/UpdatePriceRequestParamsTest.kt @@ -0,0 +1,29 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import com.withorb.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class UpdatePriceRequestParamsTest { + + @Test + fun createUpdatePriceRequestParams() { + val updatePriceRequestParams = + UpdatePriceRequestParams.builder() + .metadata( + UpdatePriceRequestParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + assertThat(updatePriceRequestParams).isNotNull + assertThat(updatePriceRequestParams.metadata()) + .contains( + UpdatePriceRequestParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/UsageDiscountIntervalModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/UsageDiscountIntervalModelTest.kt new file mode 100644 index 000000000..cf7958f6c --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/UsageDiscountIntervalModelTest.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class UsageDiscountIntervalModelTest { + + @Test + fun createUsageDiscountIntervalModel() { + val usageDiscountIntervalModel = + UsageDiscountIntervalModel.builder() + .addAppliesToPriceId("string") + .addAppliesToPriceIntervalId("string") + .discountType(UsageDiscountIntervalModel.DiscountType.USAGE) + .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .usageDiscount(0.0) + .build() + assertThat(usageDiscountIntervalModel).isNotNull + assertThat(usageDiscountIntervalModel.appliesToPriceIds()).containsExactly("string") + assertThat(usageDiscountIntervalModel.appliesToPriceIntervalIds()).containsExactly("string") + assertThat(usageDiscountIntervalModel.discountType()) + .isEqualTo(UsageDiscountIntervalModel.DiscountType.USAGE) + assertThat(usageDiscountIntervalModel.endDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(usageDiscountIntervalModel.startDate()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(usageDiscountIntervalModel.usageDiscount()).isEqualTo(0.0) + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/UsageModelTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/UsageModelTest.kt new file mode 100644 index 000000000..c40c221f0 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/UsageModelTest.kt @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class UsageModelTest { + + @Test + fun createUsageModel() { + val usageModel = + UsageModel.builder() + .quantity(0.0) + .timeframeEnd(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .timeframeStart(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + assertThat(usageModel).isNotNull + assertThat(usageModel.quantity()).isEqualTo(0.0) + assertThat(usageModel.timeframeEnd()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(usageModel.timeframeStart()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } +} 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 452c5addc..3e4e95f78 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 @@ -2,9 +2,7 @@ package com.withorb.api.services -import com.fasterxml.jackson.databind.json.JsonMapper import com.github.tomakehurst.wiremock.client.WireMock.anyUrl -import com.github.tomakehurst.wiremock.client.WireMock.ok import com.github.tomakehurst.wiremock.client.WireMock.post import com.github.tomakehurst.wiremock.client.WireMock.status import com.github.tomakehurst.wiremock.client.WireMock.stubFor @@ -25,22 +23,35 @@ import com.withorb.api.errors.RateLimitException import com.withorb.api.errors.UnauthorizedException import com.withorb.api.errors.UnexpectedStatusCodeException import com.withorb.api.errors.UnprocessableEntityException -import com.withorb.api.models.Customer +import com.withorb.api.models.AddressInputModel import com.withorb.api.models.CustomerCreateParams -import java.time.OffsetDateTime +import com.withorb.api.models.CustomerHierarchyConfigModel +import com.withorb.api.models.CustomerTaxIdModel +import com.withorb.api.models.NewAccountingSyncConfigurationModel +import com.withorb.api.models.NewReportingConfigurationModel +import com.withorb.api.models.NewTaxConfigurationModel import org.assertj.core.api.Assertions.assertThat -import org.assertj.core.api.Assertions.assertThatThrownBy -import org.assertj.core.api.InstanceOfAssertFactories +import org.assertj.core.api.Assertions.entry import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows @WireMockTest class ErrorHandlingTest { - private val JSON_MAPPER: JsonMapper = jsonMapper() + companion object { - private val ORB_ERROR: OrbError = - OrbError.builder().putAdditionalProperty("key", JsonValue.from("value")).build() + private val ERROR: OrbError = + OrbError.builder().putAdditionalProperty("errorProperty", JsonValue.from("42")).build() + + private val ERROR_JSON: ByteArray = jsonMapper().writeValueAsBytes(ERROR) + + private const val HEADER_NAME: String = "Error-Header" + + private const val HEADER_VALUE: String = "42" + + private const val NOT_JSON: String = "Not JSON" + } private lateinit var client: OrbClient @@ -48,1186 +59,844 @@ class ErrorHandlingTest { fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { client = OrbOkHttpClient.builder() - .baseUrl(wmRuntimeInfo.getHttpBaseUrl()) + .baseUrl(wmRuntimeInfo.httpBaseUrl) .apiKey("My API Key") - .webhookSecret("My Webhook Secret") .build() } @Test - fun customersCreate200() { - val params = - CustomerCreateParams.builder() - .email("dev@stainless.com") - .name("x") - .accountingSyncConfiguration( - CustomerCreateParams.AccountingSyncConfiguration.builder() - .addAccountingProvider( - CustomerCreateParams.AccountingSyncConfiguration.AccountingProvider - .builder() - .externalProviderId("external_provider_id") - .providerType("provider_type") + fun customersCreate400() { + val customerService = client.customers() + stubFor( + post(anyUrl()) + .willReturn(status(400).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) + ) + + val e = + assertThrows { + customerService.create( + CustomerCreateParams.builder() + .email("dev@stainless.com") + .name("x") + .accountingSyncConfiguration( + NewAccountingSyncConfigurationModel.builder() + .addAccountingProvider( + NewAccountingSyncConfigurationModel.AccountingProvider.builder() + .externalProviderId("external_provider_id") + .providerType("provider_type") + .build() + ) + .excluded(true) .build() ) - .excluded(true) - .build() - ) - .addAdditionalEmail("string") - .autoCollection(true) - .billingAddress( - CustomerCreateParams.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .currency("currency") - .emailDelivery(true) - .externalCustomerId("external_customer_id") - .hierarchy( - CustomerCreateParams.Hierarchy.builder() - .addChildCustomerId("string") - .parentCustomerId("parent_customer_id") - .build() - ) - .metadata( - CustomerCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) - .paymentProviderId("payment_provider_id") - .reportingConfiguration( - CustomerCreateParams.ReportingConfiguration.builder().exempt(true).build() - ) - .shippingAddress( - CustomerCreateParams.ShippingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .taxConfiguration( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration.builder() - .taxExempt(true) - .taxProvider( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) - .taxExemptionCode("tax_exemption_code") - .build() - ) - .taxId( - CustomerCreateParams.TaxId.builder() - .country(CustomerCreateParams.TaxId.Country.AD) - .type(CustomerCreateParams.TaxId.Type.AD_NRT) - .value("value") - .build() - ) - .timezone("timezone") - .build() - - val expected = - Customer.builder() - .id("id") - .addAdditionalEmail("string") - .autoCollection(true) - .balance("balance") - .billingAddress( - Customer.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currency("currency") - .email("email") - .emailDelivery(true) - .exemptFromAutomatedTax(true) - .externalCustomerId("external_customer_id") - .hierarchy( - Customer.Hierarchy.builder() - .addChild( - Customer.Hierarchy.Child.builder() - .id("id") - .externalCustomerId("external_customer_id") + .addAdditionalEmail("string") + .autoCollection(true) + .billingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") .build() ) - .parent( - Customer.Hierarchy.Parent.builder() - .id("id") - .externalCustomerId("external_customer_id") + .currency("currency") + .emailDelivery(true) + .externalCustomerId("external_customer_id") + .hierarchy( + CustomerHierarchyConfigModel.builder() + .addChildCustomerId("string") + .parentCustomerId("parent_customer_id") .build() ) - .build() - ) - .metadata( - Customer.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .name("name") - .paymentProvider(Customer.PaymentProvider.QUICKBOOKS) - .paymentProviderId("payment_provider_id") - .portalUrl("portal_url") - .shippingAddress( - Customer.ShippingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .taxId( - Customer.TaxId.builder() - .country(Customer.TaxId.Country.AD) - .type(Customer.TaxId.Type.AD_NRT) - .value("value") - .build() - ) - .timezone("timezone") - .accountingSyncConfiguration( - Customer.AccountingSyncConfiguration.builder() - .addAccountingProvider( - Customer.AccountingSyncConfiguration.AccountingProvider.builder() - .externalProviderId("external_provider_id") - .providerType( - Customer.AccountingSyncConfiguration.AccountingProvider - .ProviderType - .QUICKBOOKS + .metadata( + CustomerCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .reportingConfiguration( + NewReportingConfigurationModel.builder().exempt(true).build() + ) + .shippingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxConfiguration( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.builder() + .taxExempt(true) + .taxProvider( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.TaxProvider + .AVALARA ) + .taxExemptionCode("tax_exemption_code") + .build() + ) + .taxId( + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) + .value("value") .build() ) - .excluded(true) + .timezone("timezone") .build() ) - .reportingConfiguration( - Customer.ReportingConfiguration.builder().exempt(true).build() - ) - .build() + } - stubFor(post(anyUrl()).willReturn(ok().withBody(toJson(expected)))) - - assertThat(client.customers().create(params)).isEqualTo(expected) + assertThat(e.statusCode()).isEqualTo(400) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) } @Test - fun customersCreate400() { - val params = - CustomerCreateParams.builder() - .email("dev@stainless.com") - .name("x") - .accountingSyncConfiguration( - CustomerCreateParams.AccountingSyncConfiguration.builder() - .addAccountingProvider( - CustomerCreateParams.AccountingSyncConfiguration.AccountingProvider - .builder() - .externalProviderId("external_provider_id") - .providerType("provider_type") - .build() - ) - .excluded(true) - .build() - ) - .addAdditionalEmail("string") - .autoCollection(true) - .billingAddress( - CustomerCreateParams.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .currency("currency") - .emailDelivery(true) - .externalCustomerId("external_customer_id") - .hierarchy( - CustomerCreateParams.Hierarchy.builder() - .addChildCustomerId("string") - .parentCustomerId("parent_customer_id") - .build() - ) - .metadata( - CustomerCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) - .paymentProviderId("payment_provider_id") - .reportingConfiguration( - CustomerCreateParams.ReportingConfiguration.builder().exempt(true).build() - ) - .shippingAddress( - CustomerCreateParams.ShippingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .taxConfiguration( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration.builder() - .taxExempt(true) - .taxProvider( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) - .taxExemptionCode("tax_exemption_code") - .build() - ) - .taxId( - CustomerCreateParams.TaxId.builder() - .country(CustomerCreateParams.TaxId.Country.AD) - .type(CustomerCreateParams.TaxId.Type.AD_NRT) - .value("value") - .build() - ) - .timezone("timezone") - .build() - + fun customersCreate401() { + val customerService = client.customers() stubFor( post(anyUrl()) - .willReturn(status(400).withHeader("Foo", "Bar").withBody(toJson(ORB_ERROR))) + .willReturn(status(401).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) ) - assertThatThrownBy({ client.customers().create(params) }) - .satisfies({ e -> - assertBadRequest(e, Headers.builder().put("Foo", "Bar").build(), ORB_ERROR) - }) - } - - @Test - fun customersCreate401() { - val params = - CustomerCreateParams.builder() - .email("dev@stainless.com") - .name("x") - .accountingSyncConfiguration( - CustomerCreateParams.AccountingSyncConfiguration.builder() - .addAccountingProvider( - CustomerCreateParams.AccountingSyncConfiguration.AccountingProvider - .builder() - .externalProviderId("external_provider_id") - .providerType("provider_type") + val e = + assertThrows { + customerService.create( + CustomerCreateParams.builder() + .email("dev@stainless.com") + .name("x") + .accountingSyncConfiguration( + NewAccountingSyncConfigurationModel.builder() + .addAccountingProvider( + NewAccountingSyncConfigurationModel.AccountingProvider.builder() + .externalProviderId("external_provider_id") + .providerType("provider_type") + .build() + ) + .excluded(true) .build() ) - .excluded(true) - .build() - ) - .addAdditionalEmail("string") - .autoCollection(true) - .billingAddress( - CustomerCreateParams.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .currency("currency") - .emailDelivery(true) - .externalCustomerId("external_customer_id") - .hierarchy( - CustomerCreateParams.Hierarchy.builder() - .addChildCustomerId("string") - .parentCustomerId("parent_customer_id") - .build() - ) - .metadata( - CustomerCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) - .paymentProviderId("payment_provider_id") - .reportingConfiguration( - CustomerCreateParams.ReportingConfiguration.builder().exempt(true).build() - ) - .shippingAddress( - CustomerCreateParams.ShippingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .taxConfiguration( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration.builder() - .taxExempt(true) - .taxProvider( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) - .taxExemptionCode("tax_exemption_code") - .build() - ) - .taxId( - CustomerCreateParams.TaxId.builder() - .country(CustomerCreateParams.TaxId.Country.AD) - .type(CustomerCreateParams.TaxId.Type.AD_NRT) - .value("value") + .addAdditionalEmail("string") + .autoCollection(true) + .billingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .currency("currency") + .emailDelivery(true) + .externalCustomerId("external_customer_id") + .hierarchy( + CustomerHierarchyConfigModel.builder() + .addChildCustomerId("string") + .parentCustomerId("parent_customer_id") + .build() + ) + .metadata( + CustomerCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .reportingConfiguration( + NewReportingConfigurationModel.builder().exempt(true).build() + ) + .shippingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxConfiguration( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.builder() + .taxExempt(true) + .taxProvider( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.TaxProvider + .AVALARA + ) + .taxExemptionCode("tax_exemption_code") + .build() + ) + .taxId( + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) + .value("value") + .build() + ) + .timezone("timezone") .build() ) - .timezone("timezone") - .build() - - stubFor( - post(anyUrl()) - .willReturn(status(401).withHeader("Foo", "Bar").withBody(toJson(ORB_ERROR))) - ) + } - assertThatThrownBy({ client.customers().create(params) }) - .satisfies({ e -> - assertUnauthorized(e, Headers.builder().put("Foo", "Bar").build(), ORB_ERROR) - }) + assertThat(e.statusCode()).isEqualTo(401) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) } @Test fun customersCreate403() { - val params = - CustomerCreateParams.builder() - .email("dev@stainless.com") - .name("x") - .accountingSyncConfiguration( - CustomerCreateParams.AccountingSyncConfiguration.builder() - .addAccountingProvider( - CustomerCreateParams.AccountingSyncConfiguration.AccountingProvider - .builder() - .externalProviderId("external_provider_id") - .providerType("provider_type") - .build() - ) - .excluded(true) - .build() - ) - .addAdditionalEmail("string") - .autoCollection(true) - .billingAddress( - CustomerCreateParams.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .currency("currency") - .emailDelivery(true) - .externalCustomerId("external_customer_id") - .hierarchy( - CustomerCreateParams.Hierarchy.builder() - .addChildCustomerId("string") - .parentCustomerId("parent_customer_id") - .build() - ) - .metadata( - CustomerCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) - .paymentProviderId("payment_provider_id") - .reportingConfiguration( - CustomerCreateParams.ReportingConfiguration.builder().exempt(true).build() - ) - .shippingAddress( - CustomerCreateParams.ShippingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .taxConfiguration( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration.builder() - .taxExempt(true) - .taxProvider( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) - .taxExemptionCode("tax_exemption_code") - .build() - ) - .taxId( - CustomerCreateParams.TaxId.builder() - .country(CustomerCreateParams.TaxId.Country.AD) - .type(CustomerCreateParams.TaxId.Type.AD_NRT) - .value("value") - .build() - ) - .timezone("timezone") - .build() - + val customerService = client.customers() stubFor( post(anyUrl()) - .willReturn(status(403).withHeader("Foo", "Bar").withBody(toJson(ORB_ERROR))) + .willReturn(status(403).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) ) - assertThatThrownBy({ client.customers().create(params) }) - .satisfies({ e -> - assertPermissionDenied(e, Headers.builder().put("Foo", "Bar").build(), ORB_ERROR) - }) - } - - @Test - fun customersCreate404() { - val params = - CustomerCreateParams.builder() - .email("dev@stainless.com") - .name("x") - .accountingSyncConfiguration( - CustomerCreateParams.AccountingSyncConfiguration.builder() - .addAccountingProvider( - CustomerCreateParams.AccountingSyncConfiguration.AccountingProvider - .builder() - .externalProviderId("external_provider_id") - .providerType("provider_type") + val e = + assertThrows { + customerService.create( + CustomerCreateParams.builder() + .email("dev@stainless.com") + .name("x") + .accountingSyncConfiguration( + NewAccountingSyncConfigurationModel.builder() + .addAccountingProvider( + NewAccountingSyncConfigurationModel.AccountingProvider.builder() + .externalProviderId("external_provider_id") + .providerType("provider_type") + .build() + ) + .excluded(true) .build() ) - .excluded(true) - .build() - ) - .addAdditionalEmail("string") - .autoCollection(true) - .billingAddress( - CustomerCreateParams.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .currency("currency") - .emailDelivery(true) - .externalCustomerId("external_customer_id") - .hierarchy( - CustomerCreateParams.Hierarchy.builder() - .addChildCustomerId("string") - .parentCustomerId("parent_customer_id") - .build() - ) - .metadata( - CustomerCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) - .paymentProviderId("payment_provider_id") - .reportingConfiguration( - CustomerCreateParams.ReportingConfiguration.builder().exempt(true).build() - ) - .shippingAddress( - CustomerCreateParams.ShippingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .taxConfiguration( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration.builder() - .taxExempt(true) - .taxProvider( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) - .taxExemptionCode("tax_exemption_code") - .build() - ) - .taxId( - CustomerCreateParams.TaxId.builder() - .country(CustomerCreateParams.TaxId.Country.AD) - .type(CustomerCreateParams.TaxId.Type.AD_NRT) - .value("value") + .addAdditionalEmail("string") + .autoCollection(true) + .billingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .currency("currency") + .emailDelivery(true) + .externalCustomerId("external_customer_id") + .hierarchy( + CustomerHierarchyConfigModel.builder() + .addChildCustomerId("string") + .parentCustomerId("parent_customer_id") + .build() + ) + .metadata( + CustomerCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .reportingConfiguration( + NewReportingConfigurationModel.builder().exempt(true).build() + ) + .shippingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxConfiguration( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.builder() + .taxExempt(true) + .taxProvider( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.TaxProvider + .AVALARA + ) + .taxExemptionCode("tax_exemption_code") + .build() + ) + .taxId( + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) + .value("value") + .build() + ) + .timezone("timezone") .build() ) - .timezone("timezone") - .build() + } + assertThat(e.statusCode()).isEqualTo(403) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + } + + @Test + fun customersCreate404() { + val customerService = client.customers() stubFor( post(anyUrl()) - .willReturn(status(404).withHeader("Foo", "Bar").withBody(toJson(ORB_ERROR))) + .willReturn(status(404).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) ) - assertThatThrownBy({ client.customers().create(params) }) - .satisfies({ e -> - assertNotFound(e, Headers.builder().put("Foo", "Bar").build(), ORB_ERROR) - }) - } - - @Test - fun customersCreate422() { - val params = - CustomerCreateParams.builder() - .email("dev@stainless.com") - .name("x") - .accountingSyncConfiguration( - CustomerCreateParams.AccountingSyncConfiguration.builder() - .addAccountingProvider( - CustomerCreateParams.AccountingSyncConfiguration.AccountingProvider - .builder() - .externalProviderId("external_provider_id") - .providerType("provider_type") + val e = + assertThrows { + customerService.create( + CustomerCreateParams.builder() + .email("dev@stainless.com") + .name("x") + .accountingSyncConfiguration( + NewAccountingSyncConfigurationModel.builder() + .addAccountingProvider( + NewAccountingSyncConfigurationModel.AccountingProvider.builder() + .externalProviderId("external_provider_id") + .providerType("provider_type") + .build() + ) + .excluded(true) .build() ) - .excluded(true) - .build() - ) - .addAdditionalEmail("string") - .autoCollection(true) - .billingAddress( - CustomerCreateParams.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .currency("currency") - .emailDelivery(true) - .externalCustomerId("external_customer_id") - .hierarchy( - CustomerCreateParams.Hierarchy.builder() - .addChildCustomerId("string") - .parentCustomerId("parent_customer_id") - .build() - ) - .metadata( - CustomerCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) - .paymentProviderId("payment_provider_id") - .reportingConfiguration( - CustomerCreateParams.ReportingConfiguration.builder().exempt(true).build() - ) - .shippingAddress( - CustomerCreateParams.ShippingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .taxConfiguration( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration.builder() - .taxExempt(true) - .taxProvider( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) - .taxExemptionCode("tax_exemption_code") - .build() - ) - .taxId( - CustomerCreateParams.TaxId.builder() - .country(CustomerCreateParams.TaxId.Country.AD) - .type(CustomerCreateParams.TaxId.Type.AD_NRT) - .value("value") + .addAdditionalEmail("string") + .autoCollection(true) + .billingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .currency("currency") + .emailDelivery(true) + .externalCustomerId("external_customer_id") + .hierarchy( + CustomerHierarchyConfigModel.builder() + .addChildCustomerId("string") + .parentCustomerId("parent_customer_id") + .build() + ) + .metadata( + CustomerCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .reportingConfiguration( + NewReportingConfigurationModel.builder().exempt(true).build() + ) + .shippingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxConfiguration( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.builder() + .taxExempt(true) + .taxProvider( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.TaxProvider + .AVALARA + ) + .taxExemptionCode("tax_exemption_code") + .build() + ) + .taxId( + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) + .value("value") + .build() + ) + .timezone("timezone") .build() ) - .timezone("timezone") - .build() + } + + assertThat(e.statusCode()).isEqualTo(404) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + } + @Test + fun customersCreate422() { + val customerService = client.customers() stubFor( post(anyUrl()) - .willReturn(status(422).withHeader("Foo", "Bar").withBody(toJson(ORB_ERROR))) + .willReturn(status(422).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) ) - assertThatThrownBy({ client.customers().create(params) }) - .satisfies({ e -> - assertUnprocessableEntity(e, Headers.builder().put("Foo", "Bar").build(), ORB_ERROR) - }) - } - - @Test - fun customersCreate429() { - val params = - CustomerCreateParams.builder() - .email("dev@stainless.com") - .name("x") - .accountingSyncConfiguration( - CustomerCreateParams.AccountingSyncConfiguration.builder() - .addAccountingProvider( - CustomerCreateParams.AccountingSyncConfiguration.AccountingProvider - .builder() - .externalProviderId("external_provider_id") - .providerType("provider_type") + val e = + assertThrows { + customerService.create( + CustomerCreateParams.builder() + .email("dev@stainless.com") + .name("x") + .accountingSyncConfiguration( + NewAccountingSyncConfigurationModel.builder() + .addAccountingProvider( + NewAccountingSyncConfigurationModel.AccountingProvider.builder() + .externalProviderId("external_provider_id") + .providerType("provider_type") + .build() + ) + .excluded(true) .build() ) - .excluded(true) - .build() - ) - .addAdditionalEmail("string") - .autoCollection(true) - .billingAddress( - CustomerCreateParams.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .currency("currency") - .emailDelivery(true) - .externalCustomerId("external_customer_id") - .hierarchy( - CustomerCreateParams.Hierarchy.builder() - .addChildCustomerId("string") - .parentCustomerId("parent_customer_id") - .build() - ) - .metadata( - CustomerCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) - .paymentProviderId("payment_provider_id") - .reportingConfiguration( - CustomerCreateParams.ReportingConfiguration.builder().exempt(true).build() - ) - .shippingAddress( - CustomerCreateParams.ShippingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .taxConfiguration( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration.builder() - .taxExempt(true) - .taxProvider( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) - .taxExemptionCode("tax_exemption_code") - .build() - ) - .taxId( - CustomerCreateParams.TaxId.builder() - .country(CustomerCreateParams.TaxId.Country.AD) - .type(CustomerCreateParams.TaxId.Type.AD_NRT) - .value("value") + .addAdditionalEmail("string") + .autoCollection(true) + .billingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .currency("currency") + .emailDelivery(true) + .externalCustomerId("external_customer_id") + .hierarchy( + CustomerHierarchyConfigModel.builder() + .addChildCustomerId("string") + .parentCustomerId("parent_customer_id") + .build() + ) + .metadata( + CustomerCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .reportingConfiguration( + NewReportingConfigurationModel.builder().exempt(true).build() + ) + .shippingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxConfiguration( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.builder() + .taxExempt(true) + .taxProvider( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.TaxProvider + .AVALARA + ) + .taxExemptionCode("tax_exemption_code") + .build() + ) + .taxId( + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) + .value("value") + .build() + ) + .timezone("timezone") .build() ) - .timezone("timezone") - .build() + } + assertThat(e.statusCode()).isEqualTo(422) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + } + + @Test + fun customersCreate429() { + val customerService = client.customers() stubFor( post(anyUrl()) - .willReturn(status(429).withHeader("Foo", "Bar").withBody(toJson(ORB_ERROR))) + .willReturn(status(429).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) ) - assertThatThrownBy({ client.customers().create(params) }) - .satisfies({ e -> - assertRateLimit(e, Headers.builder().put("Foo", "Bar").build(), ORB_ERROR) - }) - } - - @Test - fun customersCreate500() { - val params = - CustomerCreateParams.builder() - .email("dev@stainless.com") - .name("x") - .accountingSyncConfiguration( - CustomerCreateParams.AccountingSyncConfiguration.builder() - .addAccountingProvider( - CustomerCreateParams.AccountingSyncConfiguration.AccountingProvider - .builder() - .externalProviderId("external_provider_id") - .providerType("provider_type") + val e = + assertThrows { + customerService.create( + CustomerCreateParams.builder() + .email("dev@stainless.com") + .name("x") + .accountingSyncConfiguration( + NewAccountingSyncConfigurationModel.builder() + .addAccountingProvider( + NewAccountingSyncConfigurationModel.AccountingProvider.builder() + .externalProviderId("external_provider_id") + .providerType("provider_type") + .build() + ) + .excluded(true) .build() ) - .excluded(true) - .build() - ) - .addAdditionalEmail("string") - .autoCollection(true) - .billingAddress( - CustomerCreateParams.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .currency("currency") - .emailDelivery(true) - .externalCustomerId("external_customer_id") - .hierarchy( - CustomerCreateParams.Hierarchy.builder() - .addChildCustomerId("string") - .parentCustomerId("parent_customer_id") - .build() - ) - .metadata( - CustomerCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) - .paymentProviderId("payment_provider_id") - .reportingConfiguration( - CustomerCreateParams.ReportingConfiguration.builder().exempt(true).build() - ) - .shippingAddress( - CustomerCreateParams.ShippingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .taxConfiguration( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration.builder() - .taxExempt(true) - .taxProvider( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) - .taxExemptionCode("tax_exemption_code") - .build() - ) - .taxId( - CustomerCreateParams.TaxId.builder() - .country(CustomerCreateParams.TaxId.Country.AD) - .type(CustomerCreateParams.TaxId.Type.AD_NRT) - .value("value") + .addAdditionalEmail("string") + .autoCollection(true) + .billingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .currency("currency") + .emailDelivery(true) + .externalCustomerId("external_customer_id") + .hierarchy( + CustomerHierarchyConfigModel.builder() + .addChildCustomerId("string") + .parentCustomerId("parent_customer_id") + .build() + ) + .metadata( + CustomerCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .reportingConfiguration( + NewReportingConfigurationModel.builder().exempt(true).build() + ) + .shippingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxConfiguration( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.builder() + .taxExempt(true) + .taxProvider( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.TaxProvider + .AVALARA + ) + .taxExemptionCode("tax_exemption_code") + .build() + ) + .taxId( + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) + .value("value") + .build() + ) + .timezone("timezone") .build() ) - .timezone("timezone") - .build() + } + assertThat(e.statusCode()).isEqualTo(429) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + } + + @Test + fun customersCreate500() { + val customerService = client.customers() stubFor( post(anyUrl()) - .willReturn(status(500).withHeader("Foo", "Bar").withBody(toJson(ORB_ERROR))) + .willReturn(status(500).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) ) - assertThatThrownBy({ client.customers().create(params) }) - .satisfies({ e -> - assertInternalServer(e, Headers.builder().put("Foo", "Bar").build(), ORB_ERROR) - }) - } - - @Test - fun unexpectedStatusCode() { - val params = - CustomerCreateParams.builder() - .email("dev@stainless.com") - .name("x") - .accountingSyncConfiguration( - CustomerCreateParams.AccountingSyncConfiguration.builder() - .addAccountingProvider( - CustomerCreateParams.AccountingSyncConfiguration.AccountingProvider - .builder() - .externalProviderId("external_provider_id") - .providerType("provider_type") + val e = + assertThrows { + customerService.create( + CustomerCreateParams.builder() + .email("dev@stainless.com") + .name("x") + .accountingSyncConfiguration( + NewAccountingSyncConfigurationModel.builder() + .addAccountingProvider( + NewAccountingSyncConfigurationModel.AccountingProvider.builder() + .externalProviderId("external_provider_id") + .providerType("provider_type") + .build() + ) + .excluded(true) .build() ) - .excluded(true) - .build() - ) - .addAdditionalEmail("string") - .autoCollection(true) - .billingAddress( - CustomerCreateParams.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .currency("currency") - .emailDelivery(true) - .externalCustomerId("external_customer_id") - .hierarchy( - CustomerCreateParams.Hierarchy.builder() - .addChildCustomerId("string") - .parentCustomerId("parent_customer_id") - .build() - ) - .metadata( - CustomerCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) - .paymentProviderId("payment_provider_id") - .reportingConfiguration( - CustomerCreateParams.ReportingConfiguration.builder().exempt(true).build() - ) - .shippingAddress( - CustomerCreateParams.ShippingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .taxConfiguration( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration.builder() - .taxExempt(true) - .taxProvider( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) - .taxExemptionCode("tax_exemption_code") - .build() - ) - .taxId( - CustomerCreateParams.TaxId.builder() - .country(CustomerCreateParams.TaxId.Country.AD) - .type(CustomerCreateParams.TaxId.Type.AD_NRT) - .value("value") + .addAdditionalEmail("string") + .autoCollection(true) + .billingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .currency("currency") + .emailDelivery(true) + .externalCustomerId("external_customer_id") + .hierarchy( + CustomerHierarchyConfigModel.builder() + .addChildCustomerId("string") + .parentCustomerId("parent_customer_id") + .build() + ) + .metadata( + CustomerCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .reportingConfiguration( + NewReportingConfigurationModel.builder().exempt(true).build() + ) + .shippingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxConfiguration( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.builder() + .taxExempt(true) + .taxProvider( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.TaxProvider + .AVALARA + ) + .taxExemptionCode("tax_exemption_code") + .build() + ) + .taxId( + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) + .value("value") + .build() + ) + .timezone("timezone") .build() ) - .timezone("timezone") - .build() + } + + assertThat(e.statusCode()).isEqualTo(500) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + } + @Test + fun customersCreate999() { + val customerService = client.customers() stubFor( post(anyUrl()) - .willReturn(status(999).withHeader("Foo", "Bar").withBody(toJson(ORB_ERROR))) + .willReturn(status(999).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) ) - assertThatThrownBy({ client.customers().create(params) }) - .satisfies({ e -> - assertUnexpectedStatusCodeException( - e, - 999, - Headers.builder().put("Foo", "Bar").build(), - toJson(ORB_ERROR), - ) - }) - } - - @Test - fun invalidBody() { - val params = - CustomerCreateParams.builder() - .email("dev@stainless.com") - .name("x") - .accountingSyncConfiguration( - CustomerCreateParams.AccountingSyncConfiguration.builder() - .addAccountingProvider( - CustomerCreateParams.AccountingSyncConfiguration.AccountingProvider - .builder() - .externalProviderId("external_provider_id") - .providerType("provider_type") + val e = + assertThrows { + customerService.create( + CustomerCreateParams.builder() + .email("dev@stainless.com") + .name("x") + .accountingSyncConfiguration( + NewAccountingSyncConfigurationModel.builder() + .addAccountingProvider( + NewAccountingSyncConfigurationModel.AccountingProvider.builder() + .externalProviderId("external_provider_id") + .providerType("provider_type") + .build() + ) + .excluded(true) .build() ) - .excluded(true) - .build() - ) - .addAdditionalEmail("string") - .autoCollection(true) - .billingAddress( - CustomerCreateParams.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .currency("currency") - .emailDelivery(true) - .externalCustomerId("external_customer_id") - .hierarchy( - CustomerCreateParams.Hierarchy.builder() - .addChildCustomerId("string") - .parentCustomerId("parent_customer_id") - .build() - ) - .metadata( - CustomerCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) - .paymentProviderId("payment_provider_id") - .reportingConfiguration( - CustomerCreateParams.ReportingConfiguration.builder().exempt(true).build() - ) - .shippingAddress( - CustomerCreateParams.ShippingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .taxConfiguration( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration.builder() - .taxExempt(true) - .taxProvider( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) - .taxExemptionCode("tax_exemption_code") - .build() - ) - .taxId( - CustomerCreateParams.TaxId.builder() - .country(CustomerCreateParams.TaxId.Country.AD) - .type(CustomerCreateParams.TaxId.Type.AD_NRT) - .value("value") + .addAdditionalEmail("string") + .autoCollection(true) + .billingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .currency("currency") + .emailDelivery(true) + .externalCustomerId("external_customer_id") + .hierarchy( + CustomerHierarchyConfigModel.builder() + .addChildCustomerId("string") + .parentCustomerId("parent_customer_id") + .build() + ) + .metadata( + CustomerCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .reportingConfiguration( + NewReportingConfigurationModel.builder().exempt(true).build() + ) + .shippingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxConfiguration( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.builder() + .taxExempt(true) + .taxProvider( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.TaxProvider + .AVALARA + ) + .taxExemptionCode("tax_exemption_code") + .build() + ) + .taxId( + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) + .value("value") + .build() + ) + .timezone("timezone") .build() ) - .timezone("timezone") - .build() - - stubFor(post(anyUrl()).willReturn(status(200).withBody("Not JSON"))) + } - assertThatThrownBy({ client.customers().create(params) }) - .satisfies({ e -> - assertThat(e) - .isInstanceOf(OrbException::class.java) - .hasMessage("Error reading response") - }) + assertThat(e.statusCode()).isEqualTo(999) + assertThat(e.error()).isEqualTo(ERROR) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) } @Test - fun invalidErrorBody() { - val params = - CustomerCreateParams.builder() - .email("dev@stainless.com") - .name("x") - .accountingSyncConfiguration( - CustomerCreateParams.AccountingSyncConfiguration.builder() - .addAccountingProvider( - CustomerCreateParams.AccountingSyncConfiguration.AccountingProvider - .builder() - .externalProviderId("external_provider_id") - .providerType("provider_type") + fun customersCreateInvalidJsonBody() { + val customerService = client.customers() + stubFor( + post(anyUrl()) + .willReturn(status(200).withHeader(HEADER_NAME, HEADER_VALUE).withBody(NOT_JSON)) + ) + + val e = + assertThrows { + customerService.create( + CustomerCreateParams.builder() + .email("dev@stainless.com") + .name("x") + .accountingSyncConfiguration( + NewAccountingSyncConfigurationModel.builder() + .addAccountingProvider( + NewAccountingSyncConfigurationModel.AccountingProvider.builder() + .externalProviderId("external_provider_id") + .providerType("provider_type") + .build() + ) + .excluded(true) .build() ) - .excluded(true) - .build() - ) - .addAdditionalEmail("string") - .autoCollection(true) - .billingAddress( - CustomerCreateParams.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .currency("currency") - .emailDelivery(true) - .externalCustomerId("external_customer_id") - .hierarchy( - CustomerCreateParams.Hierarchy.builder() - .addChildCustomerId("string") - .parentCustomerId("parent_customer_id") - .build() - ) - .metadata( - CustomerCreateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) - .paymentProviderId("payment_provider_id") - .reportingConfiguration( - CustomerCreateParams.ReportingConfiguration.builder().exempt(true).build() - ) - .shippingAddress( - CustomerCreateParams.ShippingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .taxConfiguration( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration.builder() - .taxExempt(true) - .taxProvider( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) - .taxExemptionCode("tax_exemption_code") - .build() - ) - .taxId( - CustomerCreateParams.TaxId.builder() - .country(CustomerCreateParams.TaxId.Country.AD) - .type(CustomerCreateParams.TaxId.Type.AD_NRT) - .value("value") + .addAdditionalEmail("string") + .autoCollection(true) + .billingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .currency("currency") + .emailDelivery(true) + .externalCustomerId("external_customer_id") + .hierarchy( + CustomerHierarchyConfigModel.builder() + .addChildCustomerId("string") + .parentCustomerId("parent_customer_id") + .build() + ) + .metadata( + CustomerCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .reportingConfiguration( + NewReportingConfigurationModel.builder().exempt(true).build() + ) + .shippingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxConfiguration( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.builder() + .taxExempt(true) + .taxProvider( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.TaxProvider + .AVALARA + ) + .taxExemptionCode("tax_exemption_code") + .build() + ) + .taxId( + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) + .value("value") + .build() + ) + .timezone("timezone") .build() ) - .timezone("timezone") - .build() - - stubFor(post(anyUrl()).willReturn(status(400).withBody("Not JSON"))) - - assertThatThrownBy({ client.customers().create(params) }) - .satisfies({ e -> - assertBadRequest(e, Headers.builder().build(), OrbError.builder().build()) - }) - } - - private fun toJson(body: T): ByteArray { - return JSON_MAPPER.writeValueAsBytes(body) - } - - private fun assertUnexpectedStatusCodeException( - throwable: Throwable, - statusCode: Int, - headers: Headers, - responseBody: ByteArray, - ) { - assertThat(throwable) - .asInstanceOf( - InstanceOfAssertFactories.throwable(UnexpectedStatusCodeException::class.java) - ) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(statusCode) - assertThat(e.body()).isEqualTo(String(responseBody)) - assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) - }) - } - - private fun assertBadRequest(throwable: Throwable, headers: Headers, error: OrbError) { - assertThat(throwable) - .asInstanceOf(InstanceOfAssertFactories.throwable(BadRequestException::class.java)) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(400) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) - }) - } - - private fun assertUnauthorized(throwable: Throwable, headers: Headers, error: OrbError) { - assertThat(throwable) - .asInstanceOf(InstanceOfAssertFactories.throwable(UnauthorizedException::class.java)) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(401) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) - }) - } - - private fun assertPermissionDenied(throwable: Throwable, headers: Headers, error: OrbError) { - assertThat(throwable) - .asInstanceOf( - InstanceOfAssertFactories.throwable(PermissionDeniedException::class.java) - ) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(403) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) - }) - } - - private fun assertNotFound(throwable: Throwable, headers: Headers, error: OrbError) { - assertThat(throwable) - .asInstanceOf(InstanceOfAssertFactories.throwable(NotFoundException::class.java)) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(404) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) - }) - } - - private fun assertUnprocessableEntity(throwable: Throwable, headers: Headers, error: OrbError) { - assertThat(throwable) - .asInstanceOf( - InstanceOfAssertFactories.throwable(UnprocessableEntityException::class.java) - ) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(422) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) - }) - } - - private fun assertRateLimit(throwable: Throwable, headers: Headers, error: OrbError) { - assertThat(throwable) - .asInstanceOf(InstanceOfAssertFactories.throwable(RateLimitException::class.java)) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(429) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) - }) - } + } - private fun assertInternalServer(throwable: Throwable, headers: Headers, error: OrbError) { - assertThat(throwable) - .asInstanceOf(InstanceOfAssertFactories.throwable(InternalServerException::class.java)) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(500) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) - }) + assertThat(e).hasMessage("Error reading response") } private fun Headers.toMap(): Map> = 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 59b94c036..ba6e0f70f 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 @@ -15,7 +15,13 @@ import com.github.tomakehurst.wiremock.junit5.WireMockTest import com.withorb.api.client.OrbClient import com.withorb.api.client.okhttp.OrbOkHttpClient import com.withorb.api.core.JsonValue +import com.withorb.api.models.AddressInputModel import com.withorb.api.models.CustomerCreateParams +import com.withorb.api.models.CustomerHierarchyConfigModel +import com.withorb.api.models.CustomerTaxIdModel +import com.withorb.api.models.NewAccountingSyncConfigurationModel +import com.withorb.api.models.NewReportingConfigurationModel +import com.withorb.api.models.NewTaxConfigurationModel import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test @@ -43,10 +49,9 @@ internal class ServiceParamsTest { .email("dev@stainless.com") .name("x") .accountingSyncConfiguration( - CustomerCreateParams.AccountingSyncConfiguration.builder() + NewAccountingSyncConfigurationModel.builder() .addAccountingProvider( - CustomerCreateParams.AccountingSyncConfiguration.AccountingProvider - .builder() + NewAccountingSyncConfigurationModel.AccountingProvider.builder() .externalProviderId("external_provider_id") .providerType("provider_type") .build() @@ -57,7 +62,7 @@ internal class ServiceParamsTest { .addAdditionalEmail("string") .autoCollection(true) .billingAddress( - CustomerCreateParams.BillingAddress.builder() + AddressInputModel.builder() .city("city") .country("country") .line1("line1") @@ -70,7 +75,7 @@ internal class ServiceParamsTest { .emailDelivery(true) .externalCustomerId("external_customer_id") .hierarchy( - CustomerCreateParams.Hierarchy.builder() + CustomerHierarchyConfigModel.builder() .addChildCustomerId("string") .parentCustomerId("parent_customer_id") .build() @@ -83,10 +88,10 @@ internal class ServiceParamsTest { .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .reportingConfiguration( - CustomerCreateParams.ReportingConfiguration.builder().exempt(true).build() + NewReportingConfigurationModel.builder().exempt(true).build() ) .shippingAddress( - CustomerCreateParams.ShippingAddress.builder() + AddressInputModel.builder() .city("city") .country("country") .line1("line1") @@ -96,20 +101,18 @@ internal class ServiceParamsTest { .build() ) .taxConfiguration( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration.builder() + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.TaxProvider.AVALARA ) .taxExemptionCode("tax_exemption_code") .build() ) .taxId( - CustomerCreateParams.TaxId.builder() - .country(CustomerCreateParams.TaxId.Country.AD) - .type(CustomerCreateParams.TaxId.Type.AD_NRT) + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) .value("value") .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 744e38e4a..6ea896a6b 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 @@ -11,6 +11,8 @@ import com.withorb.api.models.AlertDisableParams import com.withorb.api.models.AlertEnableParams import com.withorb.api.models.AlertRetrieveParams import com.withorb.api.models.AlertUpdateParams +import com.withorb.api.models.CreateCustomerAlertRequest +import com.withorb.api.models.ThresholdModel import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -27,11 +29,11 @@ class AlertServiceAsyncTest { .build() val alertServiceAsync = client.alerts() - val alertFuture = + val alertModelFuture = alertServiceAsync.retrieve(AlertRetrieveParams.builder().alertId("alert_id").build()) - val alert = alertFuture.get() - alert.validate() + val alertModel = alertModelFuture.get() + alertModel.validate() } @Test @@ -43,16 +45,16 @@ class AlertServiceAsyncTest { .build() val alertServiceAsync = client.alerts() - val alertFuture = + val alertModelFuture = alertServiceAsync.update( AlertUpdateParams.builder() .alertConfigurationId("alert_configuration_id") - .addThreshold(AlertUpdateParams.Threshold.builder().value(0.0).build()) + .addThreshold(ThresholdModel.builder().value(0.0).build()) .build() ) - val alert = alertFuture.get() - alert.validate() + val alertModel = alertModelFuture.get() + alertModel.validate() } @Disabled("plan_version=0 breaks Prism") @@ -80,20 +82,22 @@ class AlertServiceAsyncTest { .build() val alertServiceAsync = client.alerts() - val alertFuture = + val alertModelFuture = alertServiceAsync.createForCustomer( AlertCreateForCustomerParams.builder() .customerId("customer_id") - .currency("currency") - .type(AlertCreateForCustomerParams.Type.USAGE_EXCEEDED) - .addThreshold( - AlertCreateForCustomerParams.Threshold.builder().value(0.0).build() + .createCustomerAlertRequest( + CreateCustomerAlertRequest.builder() + .currency("currency") + .type(CreateCustomerAlertRequest.Type.USAGE_EXCEEDED) + .addThreshold(ThresholdModel.builder().value(0.0).build()) + .build() ) .build() ) - val alert = alertFuture.get() - alert.validate() + val alertModel = alertModelFuture.get() + alertModel.validate() } @Test @@ -105,20 +109,22 @@ class AlertServiceAsyncTest { .build() val alertServiceAsync = client.alerts() - val alertFuture = + val alertModelFuture = alertServiceAsync.createForExternalCustomer( AlertCreateForExternalCustomerParams.builder() .externalCustomerId("external_customer_id") - .currency("currency") - .type(AlertCreateForExternalCustomerParams.Type.USAGE_EXCEEDED) - .addThreshold( - AlertCreateForExternalCustomerParams.Threshold.builder().value(0.0).build() + .createCustomerAlertRequest( + CreateCustomerAlertRequest.builder() + .currency("currency") + .type(CreateCustomerAlertRequest.Type.USAGE_EXCEEDED) + .addThreshold(ThresholdModel.builder().value(0.0).build()) + .build() ) .build() ) - val alert = alertFuture.get() - alert.validate() + val alertModel = alertModelFuture.get() + alertModel.validate() } @Test @@ -130,20 +136,18 @@ class AlertServiceAsyncTest { .build() val alertServiceAsync = client.alerts() - val alertFuture = + val alertModelFuture = alertServiceAsync.createForSubscription( AlertCreateForSubscriptionParams.builder() .subscriptionId("subscription_id") - .addThreshold( - AlertCreateForSubscriptionParams.Threshold.builder().value(0.0).build() - ) + .addThreshold(ThresholdModel.builder().value(0.0).build()) .type(AlertCreateForSubscriptionParams.Type.USAGE_EXCEEDED) .metricId("metric_id") .build() ) - val alert = alertFuture.get() - alert.validate() + val alertModel = alertModelFuture.get() + alertModel.validate() } @Test @@ -155,7 +159,7 @@ class AlertServiceAsyncTest { .build() val alertServiceAsync = client.alerts() - val alertFuture = + val alertModelFuture = alertServiceAsync.disable( AlertDisableParams.builder() .alertConfigurationId("alert_configuration_id") @@ -163,8 +167,8 @@ class AlertServiceAsyncTest { .build() ) - val alert = alertFuture.get() - alert.validate() + val alertModel = alertModelFuture.get() + alertModel.validate() } @Test @@ -176,7 +180,7 @@ class AlertServiceAsyncTest { .build() val alertServiceAsync = client.alerts() - val alertFuture = + val alertModelFuture = alertServiceAsync.enable( AlertEnableParams.builder() .alertConfigurationId("alert_configuration_id") @@ -184,7 +188,7 @@ class AlertServiceAsyncTest { .build() ) - val alert = alertFuture.get() - alert.validate() + val alertModel = alertModelFuture.get() + alertModel.validate() } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/CouponServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/CouponServiceAsyncTest.kt index 7cab25abe..6a115037b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/CouponServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/CouponServiceAsyncTest.kt @@ -22,7 +22,7 @@ class CouponServiceAsyncTest { .build() val couponServiceAsync = client.coupons() - val couponFuture = + val couponModelFuture = couponServiceAsync.create( CouponCreateParams.builder() .newCouponPercentageDiscount(0.0) @@ -32,8 +32,8 @@ class CouponServiceAsyncTest { .build() ) - val coupon = couponFuture.get() - coupon.validate() + val couponModel = couponModelFuture.get() + couponModel.validate() } @Test @@ -60,11 +60,11 @@ class CouponServiceAsyncTest { .build() val couponServiceAsync = client.coupons() - val couponFuture = + val couponModelFuture = couponServiceAsync.archive(CouponArchiveParams.builder().couponId("coupon_id").build()) - val coupon = couponFuture.get() - coupon.validate() + val couponModel = couponModelFuture.get() + couponModel.validate() } @Test @@ -76,10 +76,10 @@ class CouponServiceAsyncTest { .build() val couponServiceAsync = client.coupons() - val couponFuture = + val couponModelFuture = couponServiceAsync.fetch(CouponFetchParams.builder().couponId("coupon_id").build()) - val coupon = couponFuture.get() - coupon.validate() + val couponModel = couponModelFuture.get() + couponModel.validate() } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/CreditNoteServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/CreditNoteServiceAsyncTest.kt index fa50a9477..7ae1ccccb 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/CreditNoteServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/CreditNoteServiceAsyncTest.kt @@ -21,7 +21,7 @@ class CreditNoteServiceAsyncTest { .build() val creditNoteServiceAsync = client.creditNotes() - val creditNoteFuture = + val creditNoteModelFuture = creditNoteServiceAsync.create( CreditNoteCreateParams.builder() .addLineItem( @@ -35,8 +35,8 @@ class CreditNoteServiceAsyncTest { .build() ) - val creditNote = creditNoteFuture.get() - creditNote.validate() + val creditNoteModel = creditNoteModelFuture.get() + creditNoteModel.validate() } @Test @@ -63,12 +63,12 @@ class CreditNoteServiceAsyncTest { .build() val creditNoteServiceAsync = client.creditNotes() - val creditNoteFuture = + val creditNoteModelFuture = creditNoteServiceAsync.fetch( CreditNoteFetchParams.builder().creditNoteId("credit_note_id").build() ) - val creditNote = creditNoteFuture.get() - creditNote.validate() + val creditNoteModel = creditNoteModelFuture.get() + creditNoteModel.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 91d1a134b..5f197a316 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 @@ -5,14 +5,21 @@ package com.withorb.api.services.async import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClientAsync import com.withorb.api.core.JsonValue +import com.withorb.api.models.AddressInputModel import com.withorb.api.models.CustomerCreateParams import com.withorb.api.models.CustomerDeleteParams import com.withorb.api.models.CustomerFetchByExternalIdParams import com.withorb.api.models.CustomerFetchParams +import com.withorb.api.models.CustomerHierarchyConfigModel import com.withorb.api.models.CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams import com.withorb.api.models.CustomerSyncPaymentMethodsFromGatewayParams +import com.withorb.api.models.CustomerTaxIdModel import com.withorb.api.models.CustomerUpdateByExternalIdParams import com.withorb.api.models.CustomerUpdateParams +import com.withorb.api.models.EditCustomerModel +import com.withorb.api.models.NewAccountingSyncConfigurationModel +import com.withorb.api.models.NewReportingConfigurationModel +import com.withorb.api.models.NewTaxConfigurationModel import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -28,16 +35,15 @@ class CustomerServiceAsyncTest { .build() val customerServiceAsync = client.customers() - val customerFuture = + val customerModelFuture = customerServiceAsync.create( CustomerCreateParams.builder() .email("dev@stainless.com") .name("x") .accountingSyncConfiguration( - CustomerCreateParams.AccountingSyncConfiguration.builder() + NewAccountingSyncConfigurationModel.builder() .addAccountingProvider( - CustomerCreateParams.AccountingSyncConfiguration.AccountingProvider - .builder() + NewAccountingSyncConfigurationModel.AccountingProvider.builder() .externalProviderId("external_provider_id") .providerType("provider_type") .build() @@ -48,7 +54,7 @@ class CustomerServiceAsyncTest { .addAdditionalEmail("string") .autoCollection(true) .billingAddress( - CustomerCreateParams.BillingAddress.builder() + AddressInputModel.builder() .city("city") .country("country") .line1("line1") @@ -61,7 +67,7 @@ class CustomerServiceAsyncTest { .emailDelivery(true) .externalCustomerId("external_customer_id") .hierarchy( - CustomerCreateParams.Hierarchy.builder() + CustomerHierarchyConfigModel.builder() .addChildCustomerId("string") .parentCustomerId("parent_customer_id") .build() @@ -74,10 +80,10 @@ class CustomerServiceAsyncTest { .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .reportingConfiguration( - CustomerCreateParams.ReportingConfiguration.builder().exempt(true).build() + NewReportingConfigurationModel.builder().exempt(true).build() ) .shippingAddress( - CustomerCreateParams.ShippingAddress.builder() + AddressInputModel.builder() .city("city") .country("country") .line1("line1") @@ -87,20 +93,19 @@ class CustomerServiceAsyncTest { .build() ) .taxConfiguration( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration.builder() + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.TaxProvider .AVALARA ) .taxExemptionCode("tax_exemption_code") .build() ) .taxId( - CustomerCreateParams.TaxId.builder() - .country(CustomerCreateParams.TaxId.Country.AD) - .type(CustomerCreateParams.TaxId.Type.AD_NRT) + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) .value("value") .build() ) @@ -108,8 +113,8 @@ class CustomerServiceAsyncTest { .build() ) - val customer = customerFuture.get() - customer.validate() + val customerModel = customerModelFuture.get() + customerModel.validate() } @Test @@ -121,88 +126,92 @@ class CustomerServiceAsyncTest { .build() val customerServiceAsync = client.customers() - val customerFuture = + val customerModelFuture = customerServiceAsync.update( CustomerUpdateParams.builder() .customerId("customer_id") - .accountingSyncConfiguration( - CustomerUpdateParams.AccountingSyncConfiguration.builder() - .addAccountingProvider( - CustomerUpdateParams.AccountingSyncConfiguration.AccountingProvider - .builder() - .externalProviderId("external_provider_id") - .providerType("provider_type") + .editCustomerModel( + EditCustomerModel.builder() + .accountingSyncConfiguration( + NewAccountingSyncConfigurationModel.builder() + .addAccountingProvider( + NewAccountingSyncConfigurationModel.AccountingProvider + .builder() + .externalProviderId("external_provider_id") + .providerType("provider_type") + .build() + ) + .excluded(true) .build() ) - .excluded(true) - .build() - ) - .addAdditionalEmail("string") - .autoCollection(true) - .billingAddress( - CustomerUpdateParams.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .currency("currency") - .email("dev@stainless.com") - .emailDelivery(true) - .externalCustomerId("external_customer_id") - .hierarchy( - CustomerUpdateParams.Hierarchy.builder() - .addChildCustomerId("string") - .parentCustomerId("parent_customer_id") - .build() - ) - .metadata( - CustomerUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .name("name") - .paymentProvider(CustomerUpdateParams.PaymentProvider.QUICKBOOKS) - .paymentProviderId("payment_provider_id") - .reportingConfiguration( - CustomerUpdateParams.ReportingConfiguration.builder().exempt(true).build() - ) - .shippingAddress( - CustomerUpdateParams.ShippingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .taxConfiguration( - CustomerUpdateParams.TaxConfiguration.NewAvalaraTaxConfiguration.builder() - .taxExempt(true) - .taxProvider( - CustomerUpdateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA + .addAdditionalEmail("string") + .autoCollection(true) + .billingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .currency("currency") + .email("dev@stainless.com") + .emailDelivery(true) + .externalCustomerId("external_customer_id") + .hierarchy( + CustomerHierarchyConfigModel.builder() + .addChildCustomerId("string") + .parentCustomerId("parent_customer_id") + .build() + ) + .metadata( + EditCustomerModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .paymentProvider(EditCustomerModel.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .reportingConfiguration( + NewReportingConfigurationModel.builder().exempt(true).build() + ) + .shippingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxConfiguration( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.builder() + .taxExempt(true) + .taxProvider( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration + .TaxProvider + .AVALARA + ) + .taxExemptionCode("tax_exemption_code") + .build() + ) + .taxId( + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) + .value("value") + .build() ) - .taxExemptionCode("tax_exemption_code") - .build() - ) - .taxId( - CustomerUpdateParams.TaxId.builder() - .country(CustomerUpdateParams.TaxId.Country.AD) - .type(CustomerUpdateParams.TaxId.Type.AD_NRT) - .value("value") .build() ) .build() ) - val customer = customerFuture.get() - customer.validate() + val customerModel = customerModelFuture.get() + customerModel.validate() } @Test @@ -246,13 +255,13 @@ class CustomerServiceAsyncTest { .build() val customerServiceAsync = client.customers() - val customerFuture = + val customerModelFuture = customerServiceAsync.fetch( CustomerFetchParams.builder().customerId("customer_id").build() ) - val customer = customerFuture.get() - customer.validate() + val customerModel = customerModelFuture.get() + customerModel.validate() } @Test @@ -264,15 +273,15 @@ class CustomerServiceAsyncTest { .build() val customerServiceAsync = client.customers() - val customerFuture = + val customerModelFuture = customerServiceAsync.fetchByExternalId( CustomerFetchByExternalIdParams.builder() .externalCustomerId("external_customer_id") .build() ) - val customer = customerFuture.get() - customer.validate() + val customerModel = customerModelFuture.get() + customerModel.validate() } @Test @@ -322,92 +331,91 @@ class CustomerServiceAsyncTest { .build() val customerServiceAsync = client.customers() - val customerFuture = + val customerModelFuture = customerServiceAsync.updateByExternalId( CustomerUpdateByExternalIdParams.builder() .id("external_customer_id") - .accountingSyncConfiguration( - CustomerUpdateByExternalIdParams.AccountingSyncConfiguration.builder() - .addAccountingProvider( - CustomerUpdateByExternalIdParams.AccountingSyncConfiguration - .AccountingProvider - .builder() - .externalProviderId("external_provider_id") - .providerType("provider_type") + .editCustomerModel( + EditCustomerModel.builder() + .accountingSyncConfiguration( + NewAccountingSyncConfigurationModel.builder() + .addAccountingProvider( + NewAccountingSyncConfigurationModel.AccountingProvider + .builder() + .externalProviderId("external_provider_id") + .providerType("provider_type") + .build() + ) + .excluded(true) .build() ) - .excluded(true) - .build() - ) - .addAdditionalEmail("string") - .autoCollection(true) - .billingAddress( - CustomerUpdateByExternalIdParams.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .currency("currency") - .email("dev@stainless.com") - .emailDelivery(true) - .externalCustomerId("external_customer_id") - .hierarchy( - CustomerUpdateByExternalIdParams.Hierarchy.builder() - .addChildCustomerId("string") - .parentCustomerId("parent_customer_id") - .build() - ) - .metadata( - CustomerUpdateByExternalIdParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .name("name") - .paymentProvider(CustomerUpdateByExternalIdParams.PaymentProvider.QUICKBOOKS) - .paymentProviderId("payment_provider_id") - .reportingConfiguration( - CustomerUpdateByExternalIdParams.ReportingConfiguration.builder() - .exempt(true) - .build() - ) - .shippingAddress( - CustomerUpdateByExternalIdParams.ShippingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .taxConfiguration( - CustomerUpdateByExternalIdParams.TaxConfiguration.NewAvalaraTaxConfiguration - .builder() - .taxExempt(true) - .taxProvider( - CustomerUpdateByExternalIdParams.TaxConfiguration - .NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA + .addAdditionalEmail("string") + .autoCollection(true) + .billingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .currency("currency") + .email("dev@stainless.com") + .emailDelivery(true) + .externalCustomerId("external_customer_id") + .hierarchy( + CustomerHierarchyConfigModel.builder() + .addChildCustomerId("string") + .parentCustomerId("parent_customer_id") + .build() + ) + .metadata( + EditCustomerModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .paymentProvider(EditCustomerModel.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .reportingConfiguration( + NewReportingConfigurationModel.builder().exempt(true).build() + ) + .shippingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxConfiguration( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.builder() + .taxExempt(true) + .taxProvider( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration + .TaxProvider + .AVALARA + ) + .taxExemptionCode("tax_exemption_code") + .build() + ) + .taxId( + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) + .value("value") + .build() ) - .taxExemptionCode("tax_exemption_code") - .build() - ) - .taxId( - CustomerUpdateByExternalIdParams.TaxId.builder() - .country(CustomerUpdateByExternalIdParams.TaxId.Country.AD) - .type(CustomerUpdateByExternalIdParams.TaxId.Type.AD_NRT) - .value("value") .build() ) .build() ) - val customer = customerFuture.get() - customer.validate() + val customerModel = customerModelFuture.get() + customerModel.validate() } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/DimensionalPriceGroupServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/DimensionalPriceGroupServiceAsyncTest.kt index e0b7a9e05..e61a538d4 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/DimensionalPriceGroupServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/DimensionalPriceGroupServiceAsyncTest.kt @@ -22,7 +22,7 @@ class DimensionalPriceGroupServiceAsyncTest { .build() val dimensionalPriceGroupServiceAsync = client.dimensionalPriceGroups() - val dimensionalPriceGroupFuture = + val dimensionalPriceGroupModelFuture = dimensionalPriceGroupServiceAsync.create( DimensionalPriceGroupCreateParams.builder() .billableMetricId("billable_metric_id") @@ -38,8 +38,8 @@ class DimensionalPriceGroupServiceAsyncTest { .build() ) - val dimensionalPriceGroup = dimensionalPriceGroupFuture.get() - dimensionalPriceGroup.validate() + val dimensionalPriceGroupModel = dimensionalPriceGroupModelFuture.get() + dimensionalPriceGroupModel.validate() } @Test @@ -51,15 +51,15 @@ class DimensionalPriceGroupServiceAsyncTest { .build() val dimensionalPriceGroupServiceAsync = client.dimensionalPriceGroups() - val dimensionalPriceGroupFuture = + val dimensionalPriceGroupModelFuture = dimensionalPriceGroupServiceAsync.retrieve( DimensionalPriceGroupRetrieveParams.builder() .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) - val dimensionalPriceGroup = dimensionalPriceGroupFuture.get() - dimensionalPriceGroup.validate() + val dimensionalPriceGroupModel = dimensionalPriceGroupModelFuture.get() + dimensionalPriceGroupModel.validate() } @Test diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/InvoiceLineItemServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/InvoiceLineItemServiceAsyncTest.kt index 02006d5a8..3f85d0f32 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/InvoiceLineItemServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/InvoiceLineItemServiceAsyncTest.kt @@ -21,7 +21,7 @@ class InvoiceLineItemServiceAsyncTest { .build() val invoiceLineItemServiceAsync = client.invoiceLineItems() - val invoiceLineItemFuture = + val invoiceLineItemModelFuture = invoiceLineItemServiceAsync.create( InvoiceLineItemCreateParams.builder() .amount("12.00") @@ -33,7 +33,7 @@ class InvoiceLineItemServiceAsyncTest { .build() ) - val invoiceLineItem = invoiceLineItemFuture.get() - invoiceLineItem.validate() + val invoiceLineItemModel = invoiceLineItemModelFuture.get() + invoiceLineItemModel.validate() } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncTest.kt index ad640f8ad..1dd65c6f1 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 @@ -14,6 +14,7 @@ import com.withorb.api.models.InvoicePayParams import com.withorb.api.models.InvoiceUpdateParams import com.withorb.api.models.InvoiceVoidInvoiceParams import com.withorb.api.models.PercentageDiscount +import com.withorb.api.models.UnitConfigModel import java.time.LocalDate import java.time.OffsetDateTime import org.junit.jupiter.api.Test @@ -31,7 +32,7 @@ class InvoiceServiceAsyncTest { .build() val invoiceServiceAsync = client.invoices() - val invoiceFuture = + val invoiceModelFuture = invoiceServiceAsync.create( InvoiceCreateParams.builder() .currency("USD") @@ -44,11 +45,7 @@ class InvoiceServiceAsyncTest { .name("Line Item Name") .quantity(1.0) .startDate(LocalDate.parse("2023-09-22")) - .unitConfig( - InvoiceCreateParams.LineItem.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) .build() ) .netTerms(0L) @@ -73,8 +70,8 @@ class InvoiceServiceAsyncTest { .build() ) - val invoice = invoiceFuture.get() - invoice.validate() + val invoiceModel = invoiceModelFuture.get() + invoiceModel.validate() } @Test @@ -86,7 +83,7 @@ class InvoiceServiceAsyncTest { .build() val invoiceServiceAsync = client.invoices() - val invoiceFuture = + val invoiceModelFuture = invoiceServiceAsync.update( InvoiceUpdateParams.builder() .invoiceId("invoice_id") @@ -98,8 +95,8 @@ class InvoiceServiceAsyncTest { .build() ) - val invoice = invoiceFuture.get() - invoice.validate() + val invoiceModel = invoiceModelFuture.get() + invoiceModel.validate() } @Test @@ -126,11 +123,11 @@ class InvoiceServiceAsyncTest { .build() val invoiceServiceAsync = client.invoices() - val invoiceFuture = + val invoiceModelFuture = invoiceServiceAsync.fetch(InvoiceFetchParams.builder().invoiceId("invoice_id").build()) - val invoice = invoiceFuture.get() - invoice.validate() + val invoiceModel = invoiceModelFuture.get() + invoiceModel.validate() } @Test @@ -160,13 +157,13 @@ class InvoiceServiceAsyncTest { .build() val invoiceServiceAsync = client.invoices() - val invoiceFuture = + val invoiceModelFuture = invoiceServiceAsync.issue( InvoiceIssueParams.builder().invoiceId("invoice_id").synchronous(true).build() ) - val invoice = invoiceFuture.get() - invoice.validate() + val invoiceModel = invoiceModelFuture.get() + invoiceModel.validate() } @Test @@ -178,7 +175,7 @@ class InvoiceServiceAsyncTest { .build() val invoiceServiceAsync = client.invoices() - val invoiceFuture = + val invoiceModelFuture = invoiceServiceAsync.markPaid( InvoiceMarkPaidParams.builder() .invoiceId("invoice_id") @@ -188,8 +185,8 @@ class InvoiceServiceAsyncTest { .build() ) - val invoice = invoiceFuture.get() - invoice.validate() + val invoiceModel = invoiceModelFuture.get() + invoiceModel.validate() } @Test @@ -201,11 +198,11 @@ class InvoiceServiceAsyncTest { .build() val invoiceServiceAsync = client.invoices() - val invoiceFuture = + val invoiceModelFuture = invoiceServiceAsync.pay(InvoicePayParams.builder().invoiceId("invoice_id").build()) - val invoice = invoiceFuture.get() - invoice.validate() + val invoiceModel = invoiceModelFuture.get() + invoiceModel.validate() } @Test @@ -217,12 +214,12 @@ class InvoiceServiceAsyncTest { .build() val invoiceServiceAsync = client.invoices() - val invoiceFuture = + val invoiceModelFuture = invoiceServiceAsync.voidInvoice( InvoiceVoidInvoiceParams.builder().invoiceId("invoice_id").build() ) - val invoice = invoiceFuture.get() - invoice.validate() + val invoiceModel = invoiceModelFuture.get() + invoiceModel.validate() } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/ItemServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/ItemServiceAsyncTest.kt index 04afc4ae0..50f43f422 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/ItemServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/ItemServiceAsyncTest.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.async import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClientAsync import com.withorb.api.models.ItemCreateParams +import com.withorb.api.models.ItemExternalConnectionModel import com.withorb.api.models.ItemFetchParams import com.withorb.api.models.ItemUpdateParams import org.junit.jupiter.api.Test @@ -22,11 +23,11 @@ class ItemServiceAsyncTest { .build() val itemServiceAsync = client.items() - val itemFuture = + val itemModelFuture = itemServiceAsync.create(ItemCreateParams.builder().name("API requests").build()) - val item = itemFuture.get() - item.validate() + val itemModel = itemModelFuture.get() + itemModel.validate() } @Test @@ -38,14 +39,14 @@ class ItemServiceAsyncTest { .build() val itemServiceAsync = client.items() - val itemFuture = + val itemModelFuture = itemServiceAsync.update( ItemUpdateParams.builder() .itemId("item_id") .addExternalConnection( - ItemUpdateParams.ExternalConnection.builder() + ItemExternalConnectionModel.builder() .externalConnectionName( - ItemUpdateParams.ExternalConnection.ExternalConnectionName.STRIPE + ItemExternalConnectionModel.ExternalConnectionName.STRIPE ) .externalEntityId("external_entity_id") .build() @@ -54,8 +55,8 @@ class ItemServiceAsyncTest { .build() ) - val item = itemFuture.get() - item.validate() + val itemModel = itemModelFuture.get() + itemModel.validate() } @Test @@ -82,9 +83,10 @@ class ItemServiceAsyncTest { .build() val itemServiceAsync = client.items() - val itemFuture = itemServiceAsync.fetch(ItemFetchParams.builder().itemId("item_id").build()) + val itemModelFuture = + itemServiceAsync.fetch(ItemFetchParams.builder().itemId("item_id").build()) - val item = itemFuture.get() - item.validate() + val itemModel = itemModelFuture.get() + itemModel.validate() } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/MetricServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/MetricServiceAsyncTest.kt index aa6c6c8df..e737047cb 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/MetricServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/MetricServiceAsyncTest.kt @@ -23,7 +23,7 @@ class MetricServiceAsyncTest { .build() val metricServiceAsync = client.metrics() - val billableMetricFuture = + val billableMetricModelFuture = metricServiceAsync.create( MetricCreateParams.builder() .description("Sum of bytes downloaded in fast mode") @@ -38,8 +38,8 @@ class MetricServiceAsyncTest { .build() ) - val billableMetric = billableMetricFuture.get() - billableMetric.validate() + val billableMetricModel = billableMetricModelFuture.get() + billableMetricModel.validate() } @Test @@ -51,7 +51,7 @@ class MetricServiceAsyncTest { .build() val metricServiceAsync = client.metrics() - val billableMetricFuture = + val billableMetricModelFuture = metricServiceAsync.update( MetricUpdateParams.builder() .metricId("metric_id") @@ -63,8 +63,8 @@ class MetricServiceAsyncTest { .build() ) - val billableMetric = billableMetricFuture.get() - billableMetric.validate() + val billableMetricModel = billableMetricModelFuture.get() + billableMetricModel.validate() } @Test @@ -91,10 +91,10 @@ class MetricServiceAsyncTest { .build() val metricServiceAsync = client.metrics() - val billableMetricFuture = + val billableMetricModelFuture = metricServiceAsync.fetch(MetricFetchParams.builder().metricId("metric_id").build()) - val billableMetric = billableMetricFuture.get() - billableMetric.validate() + val billableMetricModel = billableMetricModelFuture.get() + billableMetricModel.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 c68e63685..dbaa74576 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 @@ -5,9 +5,12 @@ package com.withorb.api.services.async import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClientAsync import com.withorb.api.core.JsonValue +import com.withorb.api.models.EditPlanModel +import com.withorb.api.models.NewBillingCycleConfigurationModel import com.withorb.api.models.PlanCreateParams import com.withorb.api.models.PlanFetchParams import com.withorb.api.models.PlanUpdateParams +import com.withorb.api.models.UnitConfigModel import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -23,7 +26,7 @@ class PlanServiceAsyncTest { .build() val planServiceAsync = client.plans() - val planFuture = + val planModelFuture = planServiceAsync.create( PlanCreateParams.builder() .currency("currency") @@ -34,22 +37,14 @@ class PlanServiceAsyncTest { .itemId("item_id") .modelType(PlanCreateParams.Price.NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - PlanCreateParams.Price.NewPlanUnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - PlanCreateParams.Price.NewPlanUnitPrice.BillingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - PlanCreateParams.Price.NewPlanUnitPrice - .BillingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) @@ -59,14 +54,10 @@ class PlanServiceAsyncTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - PlanCreateParams.Price.NewPlanUnitPrice.InvoicingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - PlanCreateParams.Price.NewPlanUnitPrice - .InvoicingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) @@ -89,8 +80,8 @@ class PlanServiceAsyncTest { .build() ) - val plan = planFuture.get() - plan.validate() + val planModel = planModelFuture.get() + planModel.validate() } @Test @@ -102,21 +93,25 @@ class PlanServiceAsyncTest { .build() val planServiceAsync = client.plans() - val planFuture = + val planModelFuture = planServiceAsync.update( PlanUpdateParams.builder() .planId("plan_id") - .externalPlanId("external_plan_id") - .metadata( - PlanUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .editPlanModel( + EditPlanModel.builder() + .externalPlanId("external_plan_id") + .metadata( + EditPlanModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .build() ) .build() ) - val plan = planFuture.get() - plan.validate() + val planModel = planModelFuture.get() + planModel.validate() } @Test @@ -143,9 +138,10 @@ class PlanServiceAsyncTest { .build() val planServiceAsync = client.plans() - val planFuture = planServiceAsync.fetch(PlanFetchParams.builder().planId("plan_id").build()) + val planModelFuture = + planServiceAsync.fetch(PlanFetchParams.builder().planId("plan_id").build()) - val plan = planFuture.get() - plan.validate() + val planModel = planModelFuture.get() + planModel.validate() } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/PriceServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/PriceServiceAsyncTest.kt index 18e5da7f1..f9061bfc7 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 @@ -5,10 +5,14 @@ package com.withorb.api.services.async import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClientAsync import com.withorb.api.core.JsonValue +import com.withorb.api.models.NewBillingCycleConfigurationModel +import com.withorb.api.models.NewFloatingPriceModel import com.withorb.api.models.PriceCreateParams import com.withorb.api.models.PriceEvaluateParams import com.withorb.api.models.PriceFetchParams import com.withorb.api.models.PriceUpdateParams +import com.withorb.api.models.UnitConfigModel +import com.withorb.api.models.UpdatePriceRequestParams import java.time.OffsetDateTime import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -25,33 +29,24 @@ class PriceServiceAsyncTest { .build() val priceServiceAsync = client.prices() - val priceFuture = + val priceModelFuture = priceServiceAsync.create( PriceCreateParams.builder() - .body( - PriceCreateParams.Body.NewFloatingUnitPrice.builder() - .cadence(PriceCreateParams.Body.NewFloatingUnitPrice.Cadence.ANNUAL) + .newFloatingPriceModel( + NewFloatingPriceModel.NewFloatingUnitPrice.builder() + .cadence(NewFloatingPriceModel.NewFloatingUnitPrice.Cadence.ANNUAL) .currency("currency") .itemId("item_id") - .modelType(PriceCreateParams.Body.NewFloatingUnitPrice.ModelType.UNIT) + .modelType(NewFloatingPriceModel.NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - PriceCreateParams.Body.NewFloatingUnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - PriceCreateParams.Body.NewFloatingUnitPrice - .BillingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - PriceCreateParams.Body.NewFloatingUnitPrice - .BillingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) @@ -60,20 +55,15 @@ class PriceServiceAsyncTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - PriceCreateParams.Body.NewFloatingUnitPrice - .InvoicingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - PriceCreateParams.Body.NewFloatingUnitPrice - .InvoicingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) .metadata( - PriceCreateParams.Body.NewFloatingUnitPrice.Metadata.builder() + NewFloatingPriceModel.NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -82,8 +72,8 @@ class PriceServiceAsyncTest { .build() ) - val price = priceFuture.get() - price.validate() + val priceModel = priceModelFuture.get() + priceModel.validate() } @Test @@ -95,20 +85,24 @@ class PriceServiceAsyncTest { .build() val priceServiceAsync = client.prices() - val priceFuture = + val priceModelFuture = priceServiceAsync.update( PriceUpdateParams.builder() .priceId("price_id") - .metadata( - PriceUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .updatePriceRequestParams( + UpdatePriceRequestParams.builder() + .metadata( + UpdatePriceRequestParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .build() ) .build() ) - val price = priceFuture.get() - price.validate() + val priceModel = priceModelFuture.get() + priceModel.validate() } @Test @@ -161,10 +155,10 @@ class PriceServiceAsyncTest { .build() val priceServiceAsync = client.prices() - val priceFuture = + val priceModelFuture = priceServiceAsync.fetch(PriceFetchParams.builder().priceId("price_id").build()) - val price = priceFuture.get() - price.validate() + val priceModel = priceModelFuture.get() + priceModel.validate() } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncTest.kt index 43dd14800..862226e98 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 @@ -5,6 +5,20 @@ package com.withorb.api.services.async import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClientAsync import com.withorb.api.core.JsonValue +import com.withorb.api.models.AddSubscriptionAdjustmentParams +import com.withorb.api.models.AddSubscriptionPriceParams +import com.withorb.api.models.BillingCycleAnchorConfigurationModel +import com.withorb.api.models.DiscountOverrideModel +import com.withorb.api.models.NewAdjustmentModel +import com.withorb.api.models.NewAllocationPriceModel +import com.withorb.api.models.NewBillingCycleConfigurationModel +import com.withorb.api.models.NewFloatingPriceModel +import com.withorb.api.models.NewSubscriptionPriceModel +import com.withorb.api.models.PriceIntervalFixedFeeQuantityTransitionModel +import com.withorb.api.models.RemoveSubscriptionAdjustmentParams +import com.withorb.api.models.RemoveSubscriptionPriceParams +import com.withorb.api.models.ReplaceSubscriptionAdjustmentParams +import com.withorb.api.models.ReplaceSubscriptionPriceParams import com.withorb.api.models.SubscriptionCancelParams import com.withorb.api.models.SubscriptionCreateParams import com.withorb.api.models.SubscriptionFetchCostsParams @@ -20,6 +34,7 @@ import com.withorb.api.models.SubscriptionUnschedulePendingPlanChangesParams import com.withorb.api.models.SubscriptionUpdateFixedFeeQuantityParams import com.withorb.api.models.SubscriptionUpdateParams import com.withorb.api.models.SubscriptionUpdateTrialParams +import com.withorb.api.models.UnitConfigModel import java.time.LocalDate import java.time.OffsetDateTime import org.junit.jupiter.api.Disabled @@ -38,19 +53,15 @@ class SubscriptionServiceAsyncTest { .build() val subscriptionServiceAsync = client.subscriptions() - val subscriptionFuture = + val mutatedSubscriptionModelFuture = subscriptionServiceAsync.create( SubscriptionCreateParams.builder() .addAddAdjustment( - SubscriptionCreateParams.AddAdjustment.builder() + AddSubscriptionAdjustmentParams.builder() .adjustment( - SubscriptionCreateParams.AddAdjustment.Adjustment - .NewPercentageDiscount - .builder() + NewAdjustmentModel.NewPercentageDiscount.builder() .adjustmentType( - SubscriptionCreateParams.AddAdjustment.Adjustment - .NewPercentageDiscount - .AdjustmentType + NewAdjustmentModel.NewPercentageDiscount.AdjustmentType .PERCENTAGE_DISCOUNT ) .addAppliesToPriceId("price_1") @@ -65,24 +76,18 @@ class SubscriptionServiceAsyncTest { .build() ) .addAddPrice( - SubscriptionCreateParams.AddPrice.builder() + AddSubscriptionPriceParams.builder() .allocationPrice( - SubscriptionCreateParams.AddPrice.AllocationPrice.builder() + NewAllocationPriceModel.builder() .amount("10.00") - .cadence( - SubscriptionCreateParams.AddPrice.AllocationPrice.Cadence - .ONE_TIME - ) + .cadence(NewAllocationPriceModel.Cadence.ONE_TIME) .currency("USD") .expiresAtEndOfCadence(true) .build() ) .addDiscount( - SubscriptionCreateParams.AddPrice.Discount.builder() - .discountType( - SubscriptionCreateParams.AddPrice.Discount.DiscountType - .PERCENTAGE - ) + DiscountOverrideModel.builder() + .discountType(DiscountOverrideModel.DiscountType.PERCENTAGE) .amountDiscount("amount_discount") .percentageDiscount(0.15) .usageDiscount(0.0) @@ -94,44 +99,27 @@ class SubscriptionServiceAsyncTest { .minimumAmount("1.23") .planPhaseOrder(0L) .price( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice - .builder() + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.builder() .cadence( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice - .Cadence + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Cadence .ANNUAL ) .itemId("item_id") .modelType( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice - .ModelType + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.ModelType .UNIT ) .name("Annual fee") .unitConfig( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice - .UnitConfig - .builder() - .unitAmount("unit_amount") - .build() + UnitConfigModel.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice - .BillingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice - .BillingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) @@ -141,24 +129,15 @@ class SubscriptionServiceAsyncTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) .metadata( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice - .Metadata + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -174,7 +153,7 @@ class SubscriptionServiceAsyncTest { .autoCollection(true) .awsRegion("aws_region") .billingCycleAnchorConfiguration( - SubscriptionCreateParams.BillingCycleAnchorConfiguration.builder() + BillingCycleAnchorConfigurationModel.builder() .day(1L) .month(1L) .year(0L) @@ -203,26 +182,22 @@ class SubscriptionServiceAsyncTest { .planVersionNumber(0L) .addPriceOverride(JsonValue.from(mapOf())) .addRemoveAdjustment( - SubscriptionCreateParams.RemoveAdjustment.builder() + RemoveSubscriptionAdjustmentParams.builder() .adjustmentId("h74gfhdjvn7ujokd") .build() ) .addRemovePrice( - SubscriptionCreateParams.RemovePrice.builder() + RemoveSubscriptionPriceParams.builder() .externalPriceId("external_price_id") .priceId("h74gfhdjvn7ujokd") .build() ) .addReplaceAdjustment( - SubscriptionCreateParams.ReplaceAdjustment.builder() + ReplaceSubscriptionAdjustmentParams.builder() .adjustment( - SubscriptionCreateParams.ReplaceAdjustment.Adjustment - .NewPercentageDiscount - .builder() + NewAdjustmentModel.NewPercentageDiscount.builder() .adjustmentType( - SubscriptionCreateParams.ReplaceAdjustment.Adjustment - .NewPercentageDiscount - .AdjustmentType + NewAdjustmentModel.NewPercentageDiscount.AdjustmentType .PERCENTAGE_DISCOUNT ) .addAppliesToPriceId("price_1") @@ -235,26 +210,19 @@ class SubscriptionServiceAsyncTest { .build() ) .addReplacePrice( - SubscriptionCreateParams.ReplacePrice.builder() + ReplaceSubscriptionPriceParams.builder() .replacesPriceId("replaces_price_id") .allocationPrice( - SubscriptionCreateParams.ReplacePrice.AllocationPrice.builder() + NewAllocationPriceModel.builder() .amount("10.00") - .cadence( - SubscriptionCreateParams.ReplacePrice.AllocationPrice - .Cadence - .ONE_TIME - ) + .cadence(NewAllocationPriceModel.Cadence.ONE_TIME) .currency("USD") .expiresAtEndOfCadence(true) .build() ) .addDiscount( - SubscriptionCreateParams.ReplacePrice.Discount.builder() - .discountType( - SubscriptionCreateParams.ReplacePrice.Discount.DiscountType - .PERCENTAGE - ) + DiscountOverrideModel.builder() + .discountType(DiscountOverrideModel.DiscountType.PERCENTAGE) .amountDiscount("amount_discount") .percentageDiscount(0.15) .usageDiscount(0.0) @@ -265,44 +233,27 @@ class SubscriptionServiceAsyncTest { .maximumAmount("1.23") .minimumAmount("1.23") .price( - SubscriptionCreateParams.ReplacePrice.Price.NewSubscriptionUnitPrice - .builder() + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.builder() .cadence( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .Cadence + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Cadence .ANNUAL ) .itemId("item_id") .modelType( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .ModelType + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.ModelType .UNIT ) .name("Annual fee") .unitConfig( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .UnitConfig - .builder() - .unitAmount("unit_amount") - .build() + UnitConfigModel.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .BillingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .BillingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) @@ -312,24 +263,15 @@ class SubscriptionServiceAsyncTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) .metadata( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .Metadata + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -346,8 +288,8 @@ class SubscriptionServiceAsyncTest { .build() ) - val subscription = subscriptionFuture.get() - subscription.validate() + val mutatedSubscriptionModel = mutatedSubscriptionModelFuture.get() + mutatedSubscriptionModel.validate() } @Test @@ -359,7 +301,7 @@ class SubscriptionServiceAsyncTest { .build() val subscriptionServiceAsync = client.subscriptions() - val subscriptionFuture = + val subscriptionModelFuture = subscriptionServiceAsync.update( SubscriptionUpdateParams.builder() .subscriptionId("subscription_id") @@ -375,8 +317,8 @@ class SubscriptionServiceAsyncTest { .build() ) - val subscription = subscriptionFuture.get() - subscription.validate() + val subscriptionModel = subscriptionModelFuture.get() + subscriptionModel.validate() } @Test @@ -403,7 +345,7 @@ class SubscriptionServiceAsyncTest { .build() val subscriptionServiceAsync = client.subscriptions() - val responseFuture = + val mutatedSubscriptionModelFuture = subscriptionServiceAsync.cancel( SubscriptionCancelParams.builder() .subscriptionId("subscription_id") @@ -413,8 +355,8 @@ class SubscriptionServiceAsyncTest { .build() ) - val response = responseFuture.get() - response.validate() + val mutatedSubscriptionModel = mutatedSubscriptionModelFuture.get() + mutatedSubscriptionModel.validate() } @Test @@ -426,13 +368,13 @@ class SubscriptionServiceAsyncTest { .build() val subscriptionServiceAsync = client.subscriptions() - val subscriptionFuture = + val subscriptionModelFuture = subscriptionServiceAsync.fetch( SubscriptionFetchParams.builder().subscriptionId("subscription_id").build() ) - val subscription = subscriptionFuture.get() - subscription.validate() + val subscriptionModel = subscriptionModelFuture.get() + subscriptionModel.validate() } @Test @@ -518,7 +460,7 @@ class SubscriptionServiceAsyncTest { .build() val subscriptionServiceAsync = client.subscriptions() - val responseFuture = + val mutatedSubscriptionModelFuture = subscriptionServiceAsync.priceIntervals( SubscriptionPriceIntervalsParams.builder() .subscriptionId("subscription_id") @@ -526,12 +468,9 @@ class SubscriptionServiceAsyncTest { SubscriptionPriceIntervalsParams.Add.builder() .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .allocationPrice( - SubscriptionPriceIntervalsParams.Add.AllocationPrice.builder() + NewAllocationPriceModel.builder() .amount("10.00") - .cadence( - SubscriptionPriceIntervalsParams.Add.AllocationPrice.Cadence - .ONE_TIME - ) + .cadence(NewAllocationPriceModel.Cadence.ONE_TIME) .currency("USD") .expiresAtEndOfCadence(true) .build() @@ -541,8 +480,7 @@ class SubscriptionServiceAsyncTest { .externalPriceId("external_price_id") .filter("my_property > 100 AND my_other_property = 'bar'") .addFixedFeeQuantityTransition( - SubscriptionPriceIntervalsParams.Add.FixedFeeQuantityTransition - .builder() + PriceIntervalFixedFeeQuantityTransitionModel.builder() .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .quantity(5L) .build() @@ -550,45 +488,26 @@ class SubscriptionServiceAsyncTest { .maximumAmount(0.0) .minimumAmount(0.0) .price( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice - .builder() + NewFloatingPriceModel.NewFloatingUnitPrice.builder() .cadence( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice - .Cadence - .ANNUAL + NewFloatingPriceModel.NewFloatingUnitPrice.Cadence.ANNUAL ) .currency("currency") .itemId("item_id") .modelType( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice - .ModelType - .UNIT + NewFloatingPriceModel.NewFloatingUnitPrice.ModelType.UNIT ) .name("Annual fee") .unitConfig( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice - .UnitConfig - .builder() - .unitAmount("unit_amount") - .build() + UnitConfigModel.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice - .BillingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice - .BillingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) @@ -597,24 +516,15 @@ class SubscriptionServiceAsyncTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice - .InvoicingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice - .InvoicingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) .metadata( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice - .Metadata + NewFloatingPriceModel.NewFloatingUnitPrice.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -628,13 +538,9 @@ class SubscriptionServiceAsyncTest { .addAddAdjustment( SubscriptionPriceIntervalsParams.AddAdjustment.builder() .adjustment( - SubscriptionPriceIntervalsParams.AddAdjustment.Adjustment - .NewPercentageDiscount - .builder() + NewAdjustmentModel.NewPercentageDiscount.builder() .adjustmentType( - SubscriptionPriceIntervalsParams.AddAdjustment.Adjustment - .NewPercentageDiscount - .AdjustmentType + NewAdjustmentModel.NewPercentageDiscount.AdjustmentType .PERCENTAGE_DISCOUNT ) .addAppliesToPriceId("price_1") @@ -655,8 +561,7 @@ class SubscriptionServiceAsyncTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .filter("my_property > 100 AND my_other_property = 'bar'") .addFixedFeeQuantityTransition( - SubscriptionPriceIntervalsParams.Edit.FixedFeeQuantityTransition - .builder() + PriceIntervalFixedFeeQuantityTransitionModel.builder() .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .quantity(5L) .build() @@ -675,8 +580,8 @@ class SubscriptionServiceAsyncTest { .build() ) - val response = responseFuture.get() - response.validate() + val mutatedSubscriptionModel = mutatedSubscriptionModelFuture.get() + mutatedSubscriptionModel.validate() } @Test @@ -688,22 +593,17 @@ class SubscriptionServiceAsyncTest { .build() val subscriptionServiceAsync = client.subscriptions() - val responseFuture = + val mutatedSubscriptionModelFuture = subscriptionServiceAsync.schedulePlanChange( SubscriptionSchedulePlanChangeParams.builder() .subscriptionId("subscription_id") .changeOption(SubscriptionSchedulePlanChangeParams.ChangeOption.REQUESTED_DATE) .addAddAdjustment( - SubscriptionSchedulePlanChangeParams.AddAdjustment.builder() + AddSubscriptionAdjustmentParams.builder() .adjustment( - SubscriptionSchedulePlanChangeParams.AddAdjustment.Adjustment - .NewPercentageDiscount - .builder() + NewAdjustmentModel.NewPercentageDiscount.builder() .adjustmentType( - SubscriptionSchedulePlanChangeParams.AddAdjustment - .Adjustment - .NewPercentageDiscount - .AdjustmentType + NewAdjustmentModel.NewPercentageDiscount.AdjustmentType .PERCENTAGE_DISCOUNT ) .addAppliesToPriceId("price_1") @@ -718,28 +618,18 @@ class SubscriptionServiceAsyncTest { .build() ) .addAddPrice( - SubscriptionSchedulePlanChangeParams.AddPrice.builder() + AddSubscriptionPriceParams.builder() .allocationPrice( - SubscriptionSchedulePlanChangeParams.AddPrice.AllocationPrice - .builder() + NewAllocationPriceModel.builder() .amount("10.00") - .cadence( - SubscriptionSchedulePlanChangeParams.AddPrice - .AllocationPrice - .Cadence - .ONE_TIME - ) + .cadence(NewAllocationPriceModel.Cadence.ONE_TIME) .currency("USD") .expiresAtEndOfCadence(true) .build() ) .addDiscount( - SubscriptionSchedulePlanChangeParams.AddPrice.Discount.builder() - .discountType( - SubscriptionSchedulePlanChangeParams.AddPrice.Discount - .DiscountType - .PERCENTAGE - ) + DiscountOverrideModel.builder() + .discountType(DiscountOverrideModel.DiscountType.PERCENTAGE) .amountDiscount("amount_discount") .percentageDiscount(0.15) .usageDiscount(0.0) @@ -751,45 +641,27 @@ class SubscriptionServiceAsyncTest { .minimumAmount("1.23") .planPhaseOrder(0L) .price( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .builder() + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.builder() .cadence( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .Cadence + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Cadence .ANNUAL ) .itemId("item_id") .modelType( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .ModelType + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.ModelType .UNIT ) .name("Annual fee") .unitConfig( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .UnitConfig - .builder() - .unitAmount("unit_amount") - .build() + UnitConfigModel.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .BillingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .BillingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) @@ -799,24 +671,15 @@ class SubscriptionServiceAsyncTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) .metadata( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .Metadata + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -834,8 +697,7 @@ class SubscriptionServiceAsyncTest { SubscriptionSchedulePlanChangeParams.BillingCycleAlignment.UNCHANGED ) .billingCycleAnchorConfiguration( - SubscriptionSchedulePlanChangeParams.BillingCycleAnchorConfiguration - .builder() + BillingCycleAnchorConfigurationModel.builder() .day(1L) .month(1L) .year(0L) @@ -855,27 +717,22 @@ class SubscriptionServiceAsyncTest { .planVersionNumber(0L) .addPriceOverride(JsonValue.from(mapOf())) .addRemoveAdjustment( - SubscriptionSchedulePlanChangeParams.RemoveAdjustment.builder() + RemoveSubscriptionAdjustmentParams.builder() .adjustmentId("h74gfhdjvn7ujokd") .build() ) .addRemovePrice( - SubscriptionSchedulePlanChangeParams.RemovePrice.builder() + RemoveSubscriptionPriceParams.builder() .externalPriceId("external_price_id") .priceId("h74gfhdjvn7ujokd") .build() ) .addReplaceAdjustment( - SubscriptionSchedulePlanChangeParams.ReplaceAdjustment.builder() + ReplaceSubscriptionAdjustmentParams.builder() .adjustment( - SubscriptionSchedulePlanChangeParams.ReplaceAdjustment.Adjustment - .NewPercentageDiscount - .builder() + NewAdjustmentModel.NewPercentageDiscount.builder() .adjustmentType( - SubscriptionSchedulePlanChangeParams.ReplaceAdjustment - .Adjustment - .NewPercentageDiscount - .AdjustmentType + NewAdjustmentModel.NewPercentageDiscount.AdjustmentType .PERCENTAGE_DISCOUNT ) .addAppliesToPriceId("price_1") @@ -888,29 +745,19 @@ class SubscriptionServiceAsyncTest { .build() ) .addReplacePrice( - SubscriptionSchedulePlanChangeParams.ReplacePrice.builder() + ReplaceSubscriptionPriceParams.builder() .replacesPriceId("replaces_price_id") .allocationPrice( - SubscriptionSchedulePlanChangeParams.ReplacePrice.AllocationPrice - .builder() + NewAllocationPriceModel.builder() .amount("10.00") - .cadence( - SubscriptionSchedulePlanChangeParams.ReplacePrice - .AllocationPrice - .Cadence - .ONE_TIME - ) + .cadence(NewAllocationPriceModel.Cadence.ONE_TIME) .currency("USD") .expiresAtEndOfCadence(true) .build() ) .addDiscount( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Discount.builder() - .discountType( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Discount - .DiscountType - .PERCENTAGE - ) + DiscountOverrideModel.builder() + .discountType(DiscountOverrideModel.DiscountType.PERCENTAGE) .amountDiscount("amount_discount") .percentageDiscount(0.15) .usageDiscount(0.0) @@ -921,46 +768,27 @@ class SubscriptionServiceAsyncTest { .maximumAmount("1.23") .minimumAmount("1.23") .price( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .builder() + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.builder() .cadence( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .Cadence + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Cadence .ANNUAL ) .itemId("item_id") .modelType( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .ModelType + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.ModelType .UNIT ) .name("Annual fee") .unitConfig( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .UnitConfig - .builder() - .unitAmount("unit_amount") - .build() + UnitConfigModel.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .BillingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionSchedulePlanChangeParams.ReplacePrice - .Price - .NewSubscriptionUnitPrice - .BillingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) @@ -970,25 +798,15 @@ class SubscriptionServiceAsyncTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionSchedulePlanChangeParams.ReplacePrice - .Price - .NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) .metadata( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .Metadata + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -1004,8 +822,8 @@ class SubscriptionServiceAsyncTest { .build() ) - val response = responseFuture.get() - response.validate() + val mutatedSubscriptionModel = mutatedSubscriptionModelFuture.get() + mutatedSubscriptionModel.validate() } @Test @@ -1017,7 +835,7 @@ class SubscriptionServiceAsyncTest { .build() val subscriptionServiceAsync = client.subscriptions() - val responseFuture = + val mutatedSubscriptionModelFuture = subscriptionServiceAsync.triggerPhase( SubscriptionTriggerPhaseParams.builder() .subscriptionId("subscription_id") @@ -1026,8 +844,8 @@ class SubscriptionServiceAsyncTest { .build() ) - val response = responseFuture.get() - response.validate() + val mutatedSubscriptionModel = mutatedSubscriptionModelFuture.get() + mutatedSubscriptionModel.validate() } @Test @@ -1039,15 +857,15 @@ class SubscriptionServiceAsyncTest { .build() val subscriptionServiceAsync = client.subscriptions() - val responseFuture = + val mutatedSubscriptionModelFuture = subscriptionServiceAsync.unscheduleCancellation( SubscriptionUnscheduleCancellationParams.builder() .subscriptionId("subscription_id") .build() ) - val response = responseFuture.get() - response.validate() + val mutatedSubscriptionModel = mutatedSubscriptionModelFuture.get() + mutatedSubscriptionModel.validate() } @Test @@ -1059,7 +877,7 @@ class SubscriptionServiceAsyncTest { .build() val subscriptionServiceAsync = client.subscriptions() - val responseFuture = + val mutatedSubscriptionModelFuture = subscriptionServiceAsync.unscheduleFixedFeeQuantityUpdates( SubscriptionUnscheduleFixedFeeQuantityUpdatesParams.builder() .subscriptionId("subscription_id") @@ -1067,8 +885,8 @@ class SubscriptionServiceAsyncTest { .build() ) - val response = responseFuture.get() - response.validate() + val mutatedSubscriptionModel = mutatedSubscriptionModelFuture.get() + mutatedSubscriptionModel.validate() } @Test @@ -1080,15 +898,15 @@ class SubscriptionServiceAsyncTest { .build() val subscriptionServiceAsync = client.subscriptions() - val responseFuture = + val mutatedSubscriptionModelFuture = subscriptionServiceAsync.unschedulePendingPlanChanges( SubscriptionUnschedulePendingPlanChangesParams.builder() .subscriptionId("subscription_id") .build() ) - val response = responseFuture.get() - response.validate() + val mutatedSubscriptionModel = mutatedSubscriptionModelFuture.get() + mutatedSubscriptionModel.validate() } @Test @@ -1100,7 +918,7 @@ class SubscriptionServiceAsyncTest { .build() val subscriptionServiceAsync = client.subscriptions() - val responseFuture = + val mutatedSubscriptionModelFuture = subscriptionServiceAsync.updateFixedFeeQuantity( SubscriptionUpdateFixedFeeQuantityParams.builder() .subscriptionId("subscription_id") @@ -1112,8 +930,8 @@ class SubscriptionServiceAsyncTest { .build() ) - val response = responseFuture.get() - response.validate() + val mutatedSubscriptionModel = mutatedSubscriptionModelFuture.get() + mutatedSubscriptionModel.validate() } @Test @@ -1125,7 +943,7 @@ class SubscriptionServiceAsyncTest { .build() val subscriptionServiceAsync = client.subscriptions() - val responseFuture = + val mutatedSubscriptionModelFuture = subscriptionServiceAsync.updateTrial( SubscriptionUpdateTrialParams.builder() .subscriptionId("subscription_id") @@ -1134,7 +952,7 @@ class SubscriptionServiceAsyncTest { .build() ) - val response = responseFuture.get() - response.validate() + val mutatedSubscriptionModel = mutatedSubscriptionModelFuture.get() + mutatedSubscriptionModel.validate() } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/customers/BalanceTransactionServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/customers/BalanceTransactionServiceAsyncTest.kt index 93371c650..a2e14785e 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/customers/BalanceTransactionServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/customers/BalanceTransactionServiceAsyncTest.kt @@ -21,7 +21,7 @@ class BalanceTransactionServiceAsyncTest { .build() val balanceTransactionServiceAsync = client.customers().balanceTransactions() - val balanceTransactionFuture = + val customerBalanceTransactionModelFuture = balanceTransactionServiceAsync.create( CustomerBalanceTransactionCreateParams.builder() .customerId("customer_id") @@ -31,8 +31,8 @@ class BalanceTransactionServiceAsyncTest { .build() ) - val balanceTransaction = balanceTransactionFuture.get() - balanceTransaction.validate() + val customerBalanceTransactionModel = customerBalanceTransactionModelFuture.get() + customerBalanceTransactionModel.validate() } @Test diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/customers/CostServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/customers/CostServiceAsyncTest.kt index 5d9de169f..52bac3d13 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/customers/CostServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/customers/CostServiceAsyncTest.kt @@ -22,7 +22,7 @@ class CostServiceAsyncTest { .build() val costServiceAsync = client.customers().costs() - val costFuture = + val customerCostsModelFuture = costServiceAsync.list( CustomerCostListParams.builder() .customerId("customer_id") @@ -33,8 +33,8 @@ class CostServiceAsyncTest { .build() ) - val cost = costFuture.get() - cost.validate() + val customerCostsModel = customerCostsModelFuture.get() + customerCostsModel.validate() } @Test @@ -46,7 +46,7 @@ class CostServiceAsyncTest { .build() val costServiceAsync = client.customers().costs() - val responseFuture = + val customerCostsModelFuture = costServiceAsync.listByExternalId( CustomerCostListByExternalIdParams.builder() .externalCustomerId("external_customer_id") @@ -57,7 +57,7 @@ class CostServiceAsyncTest { .build() ) - val response = responseFuture.get() - response.validate() + val customerCostsModel = customerCostsModelFuture.get() + customerCostsModel.validate() } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncTest.kt index 238fab161..2adc27830 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 @@ -5,6 +5,7 @@ package com.withorb.api.services.async.customers.credits import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClientAsync import com.withorb.api.core.JsonValue +import com.withorb.api.models.AddCreditLedgerEntryRequest import com.withorb.api.models.CustomerCreditLedgerCreateEntryByExternalIdParams import com.withorb.api.models.CustomerCreditLedgerCreateEntryParams import com.withorb.api.models.CustomerCreditLedgerListByExternalIdParams @@ -43,17 +44,16 @@ class LedgerServiceAsyncTest { .build() val ledgerServiceAsync = client.customers().credits().ledger() - val responseFuture = + val creditLedgerEntryModelFuture = ledgerServiceAsync.createEntry( CustomerCreditLedgerCreateEntryParams.builder() .customerId("customer_id") - .body( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams + .addCreditLedgerEntryRequest( + AddCreditLedgerEntryRequest.AddIncrementCreditLedgerEntryRequestParams .builder() .amount(0.0) .entryType( - CustomerCreditLedgerCreateEntryParams.Body + AddCreditLedgerEntryRequest .AddIncrementCreditLedgerEntryRequestParams .EntryType .INCREMENT @@ -63,7 +63,7 @@ class LedgerServiceAsyncTest { .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .invoiceSettings( - CustomerCreditLedgerCreateEntryParams.Body + AddCreditLedgerEntryRequest .AddIncrementCreditLedgerEntryRequestParams .InvoiceSettings .builder() @@ -74,7 +74,7 @@ class LedgerServiceAsyncTest { .build() ) .metadata( - CustomerCreditLedgerCreateEntryParams.Body + AddCreditLedgerEntryRequest .AddIncrementCreditLedgerEntryRequestParams .Metadata .builder() @@ -87,8 +87,8 @@ class LedgerServiceAsyncTest { .build() ) - val response = responseFuture.get() - response.validate() + val creditLedgerEntryModel = creditLedgerEntryModelFuture.get() + creditLedgerEntryModel.validate() } @Test @@ -100,17 +100,16 @@ class LedgerServiceAsyncTest { .build() val ledgerServiceAsync = client.customers().credits().ledger() - val responseFuture = + val creditLedgerEntryModelFuture = ledgerServiceAsync.createEntryByExternalId( CustomerCreditLedgerCreateEntryByExternalIdParams.builder() .externalCustomerId("external_customer_id") - .body( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams + .addCreditLedgerEntryRequest( + AddCreditLedgerEntryRequest.AddIncrementCreditLedgerEntryRequestParams .builder() .amount(0.0) .entryType( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body + AddCreditLedgerEntryRequest .AddIncrementCreditLedgerEntryRequestParams .EntryType .INCREMENT @@ -120,7 +119,7 @@ class LedgerServiceAsyncTest { .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .invoiceSettings( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body + AddCreditLedgerEntryRequest .AddIncrementCreditLedgerEntryRequestParams .InvoiceSettings .builder() @@ -131,7 +130,7 @@ class LedgerServiceAsyncTest { .build() ) .metadata( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body + AddCreditLedgerEntryRequest .AddIncrementCreditLedgerEntryRequestParams .Metadata .builder() @@ -144,8 +143,8 @@ class LedgerServiceAsyncTest { .build() ) - val response = responseFuture.get() - response.validate() + val creditLedgerEntryModel = creditLedgerEntryModelFuture.get() + creditLedgerEntryModel.validate() } @Test diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/customers/credits/TopUpServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/customers/credits/TopUpServiceAsyncTest.kt index a96931539..54126d06d 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/customers/credits/TopUpServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/customers/credits/TopUpServiceAsyncTest.kt @@ -4,6 +4,7 @@ package com.withorb.api.services.async.customers.credits import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClientAsync +import com.withorb.api.models.AddCreditTopUpRequest import com.withorb.api.models.CustomerCreditTopUpCreateByExternalIdParams import com.withorb.api.models.CustomerCreditTopUpCreateParams import com.withorb.api.models.CustomerCreditTopUpDeleteByExternalIdParams @@ -26,30 +27,34 @@ class TopUpServiceAsyncTest { .build() val topUpServiceAsync = client.customers().credits().topUps() - val topUpFuture = + val topUpModelFuture = topUpServiceAsync.create( CustomerCreditTopUpCreateParams.builder() .customerId("customer_id") - .amount("amount") - .currency("currency") - .invoiceSettings( - CustomerCreditTopUpCreateParams.InvoiceSettings.builder() - .autoCollection(true) - .netTerms(0L) - .memo("memo") - .requireSuccessfulPayment(true) + .addCreditTopUpRequest( + AddCreditTopUpRequest.builder() + .amount("amount") + .currency("currency") + .invoiceSettings( + AddCreditTopUpRequest.InvoiceSettings.builder() + .autoCollection(true) + .netTerms(0L) + .memo("memo") + .requireSuccessfulPayment(true) + .build() + ) + .perUnitCostBasis("per_unit_cost_basis") + .threshold("threshold") + .activeFrom(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiresAfter(0L) + .expiresAfterUnit(AddCreditTopUpRequest.ExpiresAfterUnit.DAY) .build() ) - .perUnitCostBasis("per_unit_cost_basis") - .threshold("threshold") - .activeFrom(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expiresAfter(0L) - .expiresAfterUnit(CustomerCreditTopUpCreateParams.ExpiresAfterUnit.DAY) .build() ) - val topUp = topUpFuture.get() - topUp.validate() + val topUpModel = topUpModelFuture.get() + topUpModel.validate() } @Test @@ -99,32 +104,34 @@ class TopUpServiceAsyncTest { .build() val topUpServiceAsync = client.customers().credits().topUps() - val responseFuture = + val topUpModelFuture = topUpServiceAsync.createByExternalId( CustomerCreditTopUpCreateByExternalIdParams.builder() .externalCustomerId("external_customer_id") - .amount("amount") - .currency("currency") - .invoiceSettings( - CustomerCreditTopUpCreateByExternalIdParams.InvoiceSettings.builder() - .autoCollection(true) - .netTerms(0L) - .memo("memo") - .requireSuccessfulPayment(true) + .addCreditTopUpRequest( + AddCreditTopUpRequest.builder() + .amount("amount") + .currency("currency") + .invoiceSettings( + AddCreditTopUpRequest.InvoiceSettings.builder() + .autoCollection(true) + .netTerms(0L) + .memo("memo") + .requireSuccessfulPayment(true) + .build() + ) + .perUnitCostBasis("per_unit_cost_basis") + .threshold("threshold") + .activeFrom(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiresAfter(0L) + .expiresAfterUnit(AddCreditTopUpRequest.ExpiresAfterUnit.DAY) .build() ) - .perUnitCostBasis("per_unit_cost_basis") - .threshold("threshold") - .activeFrom(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expiresAfter(0L) - .expiresAfterUnit( - CustomerCreditTopUpCreateByExternalIdParams.ExpiresAfterUnit.DAY - ) .build() ) - val response = responseFuture.get() - response.validate() + val topUpModel = topUpModelFuture.get() + topUpModel.validate() } @Test diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceAsyncTest.kt index 51af7568b..8f8e90666 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceAsyncTest.kt @@ -21,14 +21,14 @@ class ExternalDimensionalPriceGroupIdServiceAsyncTest { val externalDimensionalPriceGroupIdServiceAsync = client.dimensionalPriceGroups().externalDimensionalPriceGroupId() - val dimensionalPriceGroupFuture = + val dimensionalPriceGroupModelFuture = externalDimensionalPriceGroupIdServiceAsync.retrieve( DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams.builder() .externalDimensionalPriceGroupId("external_dimensional_price_group_id") .build() ) - val dimensionalPriceGroup = dimensionalPriceGroupFuture.get() - dimensionalPriceGroup.validate() + val dimensionalPriceGroupModel = dimensionalPriceGroupModelFuture.get() + dimensionalPriceGroupModel.validate() } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/events/BackfillServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/events/BackfillServiceAsyncTest.kt index b5b37b150..4a6f8fec7 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/events/BackfillServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/events/BackfillServiceAsyncTest.kt @@ -24,7 +24,7 @@ class BackfillServiceAsyncTest { .build() val backfillServiceAsync = client.events().backfills() - val backfillFuture = + val backfillModelFuture = backfillServiceAsync.create( EventBackfillCreateParams.builder() .timeframeEnd(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -37,8 +37,8 @@ class BackfillServiceAsyncTest { .build() ) - val backfill = backfillFuture.get() - backfill.validate() + val backfillModel = backfillModelFuture.get() + backfillModel.validate() } @Test @@ -65,13 +65,13 @@ class BackfillServiceAsyncTest { .build() val backfillServiceAsync = client.events().backfills() - val responseFuture = + val backfillModelFuture = backfillServiceAsync.close( EventBackfillCloseParams.builder().backfillId("backfill_id").build() ) - val response = responseFuture.get() - response.validate() + val backfillModel = backfillModelFuture.get() + backfillModel.validate() } @Test @@ -83,13 +83,13 @@ class BackfillServiceAsyncTest { .build() val backfillServiceAsync = client.events().backfills() - val responseFuture = + val backfillModelFuture = backfillServiceAsync.fetch( EventBackfillFetchParams.builder().backfillId("backfill_id").build() ) - val response = responseFuture.get() - response.validate() + val backfillModel = backfillModelFuture.get() + backfillModel.validate() } @Test @@ -101,12 +101,12 @@ class BackfillServiceAsyncTest { .build() val backfillServiceAsync = client.events().backfills() - val responseFuture = + val backfillModelFuture = backfillServiceAsync.revert( EventBackfillRevertParams.builder().backfillId("backfill_id").build() ) - val response = responseFuture.get() - response.validate() + val backfillModel = backfillModelFuture.get() + backfillModel.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 a0fc75b8d..6d67ac2a8 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/plans/ExternalPlanIdServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/plans/ExternalPlanIdServiceAsyncTest.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.async.plans import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClientAsync import com.withorb.api.core.JsonValue +import com.withorb.api.models.EditPlanModel import com.withorb.api.models.PlanExternalPlanIdFetchParams import com.withorb.api.models.PlanExternalPlanIdUpdateParams import org.junit.jupiter.api.Test @@ -22,21 +23,25 @@ class ExternalPlanIdServiceAsyncTest { .build() val externalPlanIdServiceAsync = client.plans().externalPlanId() - val planFuture = + val planModelFuture = externalPlanIdServiceAsync.update( PlanExternalPlanIdUpdateParams.builder() .otherExternalPlanId("external_plan_id") - .externalPlanId("external_plan_id") - .metadata( - PlanExternalPlanIdUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .editPlanModel( + EditPlanModel.builder() + .externalPlanId("external_plan_id") + .metadata( + EditPlanModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .build() ) .build() ) - val plan = planFuture.get() - plan.validate() + val planModel = planModelFuture.get() + planModel.validate() } @Test @@ -48,12 +53,12 @@ class ExternalPlanIdServiceAsyncTest { .build() val externalPlanIdServiceAsync = client.plans().externalPlanId() - val planFuture = + val planModelFuture = externalPlanIdServiceAsync.fetch( PlanExternalPlanIdFetchParams.builder().externalPlanId("external_plan_id").build() ) - val plan = planFuture.get() - plan.validate() + val planModel = planModelFuture.get() + planModel.validate() } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/prices/ExternalPriceIdServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/prices/ExternalPriceIdServiceAsyncTest.kt index 4e342dfa9..43b6d29d7 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/prices/ExternalPriceIdServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/prices/ExternalPriceIdServiceAsyncTest.kt @@ -7,6 +7,7 @@ import com.withorb.api.client.okhttp.OrbOkHttpClientAsync import com.withorb.api.core.JsonValue import com.withorb.api.models.PriceExternalPriceIdFetchParams import com.withorb.api.models.PriceExternalPriceIdUpdateParams +import com.withorb.api.models.UpdatePriceRequestParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -22,20 +23,24 @@ class ExternalPriceIdServiceAsyncTest { .build() val externalPriceIdServiceAsync = client.prices().externalPriceId() - val priceFuture = + val priceModelFuture = externalPriceIdServiceAsync.update( PriceExternalPriceIdUpdateParams.builder() .externalPriceId("external_price_id") - .metadata( - PriceExternalPriceIdUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .updatePriceRequestParams( + UpdatePriceRequestParams.builder() + .metadata( + UpdatePriceRequestParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .build() ) .build() ) - val price = priceFuture.get() - price.validate() + val priceModel = priceModelFuture.get() + priceModel.validate() } @Test @@ -47,14 +52,14 @@ class ExternalPriceIdServiceAsyncTest { .build() val externalPriceIdServiceAsync = client.prices().externalPriceId() - val priceFuture = + val priceModelFuture = externalPriceIdServiceAsync.fetch( PriceExternalPriceIdFetchParams.builder() .externalPriceId("external_price_id") .build() ) - val price = priceFuture.get() - price.validate() + val priceModel = priceModelFuture.get() + priceModel.validate() } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/AlertServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/AlertServiceTest.kt index f3188cb5c..eb1e0e624 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 @@ -11,6 +11,8 @@ import com.withorb.api.models.AlertDisableParams import com.withorb.api.models.AlertEnableParams import com.withorb.api.models.AlertRetrieveParams import com.withorb.api.models.AlertUpdateParams +import com.withorb.api.models.CreateCustomerAlertRequest +import com.withorb.api.models.ThresholdModel import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -27,9 +29,10 @@ class AlertServiceTest { .build() val alertService = client.alerts() - val alert = alertService.retrieve(AlertRetrieveParams.builder().alertId("alert_id").build()) + val alertModel = + alertService.retrieve(AlertRetrieveParams.builder().alertId("alert_id").build()) - alert.validate() + alertModel.validate() } @Test @@ -41,15 +44,15 @@ class AlertServiceTest { .build() val alertService = client.alerts() - val alert = + val alertModel = alertService.update( AlertUpdateParams.builder() .alertConfigurationId("alert_configuration_id") - .addThreshold(AlertUpdateParams.Threshold.builder().value(0.0).build()) + .addThreshold(ThresholdModel.builder().value(0.0).build()) .build() ) - alert.validate() + alertModel.validate() } @Disabled("plan_version=0 breaks Prism") @@ -76,19 +79,21 @@ class AlertServiceTest { .build() val alertService = client.alerts() - val alert = + val alertModel = alertService.createForCustomer( AlertCreateForCustomerParams.builder() .customerId("customer_id") - .currency("currency") - .type(AlertCreateForCustomerParams.Type.USAGE_EXCEEDED) - .addThreshold( - AlertCreateForCustomerParams.Threshold.builder().value(0.0).build() + .createCustomerAlertRequest( + CreateCustomerAlertRequest.builder() + .currency("currency") + .type(CreateCustomerAlertRequest.Type.USAGE_EXCEEDED) + .addThreshold(ThresholdModel.builder().value(0.0).build()) + .build() ) .build() ) - alert.validate() + alertModel.validate() } @Test @@ -100,19 +105,21 @@ class AlertServiceTest { .build() val alertService = client.alerts() - val alert = + val alertModel = alertService.createForExternalCustomer( AlertCreateForExternalCustomerParams.builder() .externalCustomerId("external_customer_id") - .currency("currency") - .type(AlertCreateForExternalCustomerParams.Type.USAGE_EXCEEDED) - .addThreshold( - AlertCreateForExternalCustomerParams.Threshold.builder().value(0.0).build() + .createCustomerAlertRequest( + CreateCustomerAlertRequest.builder() + .currency("currency") + .type(CreateCustomerAlertRequest.Type.USAGE_EXCEEDED) + .addThreshold(ThresholdModel.builder().value(0.0).build()) + .build() ) .build() ) - alert.validate() + alertModel.validate() } @Test @@ -124,19 +131,17 @@ class AlertServiceTest { .build() val alertService = client.alerts() - val alert = + val alertModel = alertService.createForSubscription( AlertCreateForSubscriptionParams.builder() .subscriptionId("subscription_id") - .addThreshold( - AlertCreateForSubscriptionParams.Threshold.builder().value(0.0).build() - ) + .addThreshold(ThresholdModel.builder().value(0.0).build()) .type(AlertCreateForSubscriptionParams.Type.USAGE_EXCEEDED) .metricId("metric_id") .build() ) - alert.validate() + alertModel.validate() } @Test @@ -148,7 +153,7 @@ class AlertServiceTest { .build() val alertService = client.alerts() - val alert = + val alertModel = alertService.disable( AlertDisableParams.builder() .alertConfigurationId("alert_configuration_id") @@ -156,7 +161,7 @@ class AlertServiceTest { .build() ) - alert.validate() + alertModel.validate() } @Test @@ -168,7 +173,7 @@ class AlertServiceTest { .build() val alertService = client.alerts() - val alert = + val alertModel = alertService.enable( AlertEnableParams.builder() .alertConfigurationId("alert_configuration_id") @@ -176,6 +181,6 @@ class AlertServiceTest { .build() ) - alert.validate() + alertModel.validate() } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/CouponServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/CouponServiceTest.kt index 53f2ecf52..eea411254 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/CouponServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/CouponServiceTest.kt @@ -22,7 +22,7 @@ class CouponServiceTest { .build() val couponService = client.coupons() - val coupon = + val couponModel = couponService.create( CouponCreateParams.builder() .newCouponPercentageDiscount(0.0) @@ -32,7 +32,7 @@ class CouponServiceTest { .build() ) - coupon.validate() + couponModel.validate() } @Test @@ -58,10 +58,10 @@ class CouponServiceTest { .build() val couponService = client.coupons() - val coupon = + val couponModel = couponService.archive(CouponArchiveParams.builder().couponId("coupon_id").build()) - coupon.validate() + couponModel.validate() } @Test @@ -73,8 +73,9 @@ class CouponServiceTest { .build() val couponService = client.coupons() - val coupon = couponService.fetch(CouponFetchParams.builder().couponId("coupon_id").build()) + val couponModel = + couponService.fetch(CouponFetchParams.builder().couponId("coupon_id").build()) - coupon.validate() + couponModel.validate() } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/CreditNoteServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/CreditNoteServiceTest.kt index 0dac463d6..0b70f4698 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/CreditNoteServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/CreditNoteServiceTest.kt @@ -21,7 +21,7 @@ class CreditNoteServiceTest { .build() val creditNoteService = client.creditNotes() - val creditNote = + val creditNoteModel = creditNoteService.create( CreditNoteCreateParams.builder() .addLineItem( @@ -35,7 +35,7 @@ class CreditNoteServiceTest { .build() ) - creditNote.validate() + creditNoteModel.validate() } @Test @@ -61,11 +61,11 @@ class CreditNoteServiceTest { .build() val creditNoteService = client.creditNotes() - val creditNote = + val creditNoteModel = creditNoteService.fetch( CreditNoteFetchParams.builder().creditNoteId("credit_note_id").build() ) - creditNote.validate() + creditNoteModel.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 1cec0a8f0..7379e9d16 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 @@ -5,14 +5,21 @@ package com.withorb.api.services.blocking import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClient import com.withorb.api.core.JsonValue +import com.withorb.api.models.AddressInputModel import com.withorb.api.models.CustomerCreateParams import com.withorb.api.models.CustomerDeleteParams import com.withorb.api.models.CustomerFetchByExternalIdParams import com.withorb.api.models.CustomerFetchParams +import com.withorb.api.models.CustomerHierarchyConfigModel import com.withorb.api.models.CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams import com.withorb.api.models.CustomerSyncPaymentMethodsFromGatewayParams +import com.withorb.api.models.CustomerTaxIdModel import com.withorb.api.models.CustomerUpdateByExternalIdParams import com.withorb.api.models.CustomerUpdateParams +import com.withorb.api.models.EditCustomerModel +import com.withorb.api.models.NewAccountingSyncConfigurationModel +import com.withorb.api.models.NewReportingConfigurationModel +import com.withorb.api.models.NewTaxConfigurationModel import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -28,16 +35,15 @@ class CustomerServiceTest { .build() val customerService = client.customers() - val customer = + val customerModel = customerService.create( CustomerCreateParams.builder() .email("dev@stainless.com") .name("x") .accountingSyncConfiguration( - CustomerCreateParams.AccountingSyncConfiguration.builder() + NewAccountingSyncConfigurationModel.builder() .addAccountingProvider( - CustomerCreateParams.AccountingSyncConfiguration.AccountingProvider - .builder() + NewAccountingSyncConfigurationModel.AccountingProvider.builder() .externalProviderId("external_provider_id") .providerType("provider_type") .build() @@ -48,7 +54,7 @@ class CustomerServiceTest { .addAdditionalEmail("string") .autoCollection(true) .billingAddress( - CustomerCreateParams.BillingAddress.builder() + AddressInputModel.builder() .city("city") .country("country") .line1("line1") @@ -61,7 +67,7 @@ class CustomerServiceTest { .emailDelivery(true) .externalCustomerId("external_customer_id") .hierarchy( - CustomerCreateParams.Hierarchy.builder() + CustomerHierarchyConfigModel.builder() .addChildCustomerId("string") .parentCustomerId("parent_customer_id") .build() @@ -74,10 +80,10 @@ class CustomerServiceTest { .paymentProvider(CustomerCreateParams.PaymentProvider.QUICKBOOKS) .paymentProviderId("payment_provider_id") .reportingConfiguration( - CustomerCreateParams.ReportingConfiguration.builder().exempt(true).build() + NewReportingConfigurationModel.builder().exempt(true).build() ) .shippingAddress( - CustomerCreateParams.ShippingAddress.builder() + AddressInputModel.builder() .city("city") .country("country") .line1("line1") @@ -87,20 +93,19 @@ class CustomerServiceTest { .build() ) .taxConfiguration( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration.builder() + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.builder() .taxExempt(true) .taxProvider( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.TaxProvider .AVALARA ) .taxExemptionCode("tax_exemption_code") .build() ) .taxId( - CustomerCreateParams.TaxId.builder() - .country(CustomerCreateParams.TaxId.Country.AD) - .type(CustomerCreateParams.TaxId.Type.AD_NRT) + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) .value("value") .build() ) @@ -108,7 +113,7 @@ class CustomerServiceTest { .build() ) - customer.validate() + customerModel.validate() } @Test @@ -120,87 +125,91 @@ class CustomerServiceTest { .build() val customerService = client.customers() - val customer = + val customerModel = customerService.update( CustomerUpdateParams.builder() .customerId("customer_id") - .accountingSyncConfiguration( - CustomerUpdateParams.AccountingSyncConfiguration.builder() - .addAccountingProvider( - CustomerUpdateParams.AccountingSyncConfiguration.AccountingProvider - .builder() - .externalProviderId("external_provider_id") - .providerType("provider_type") + .editCustomerModel( + EditCustomerModel.builder() + .accountingSyncConfiguration( + NewAccountingSyncConfigurationModel.builder() + .addAccountingProvider( + NewAccountingSyncConfigurationModel.AccountingProvider + .builder() + .externalProviderId("external_provider_id") + .providerType("provider_type") + .build() + ) + .excluded(true) .build() ) - .excluded(true) - .build() - ) - .addAdditionalEmail("string") - .autoCollection(true) - .billingAddress( - CustomerUpdateParams.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .currency("currency") - .email("dev@stainless.com") - .emailDelivery(true) - .externalCustomerId("external_customer_id") - .hierarchy( - CustomerUpdateParams.Hierarchy.builder() - .addChildCustomerId("string") - .parentCustomerId("parent_customer_id") - .build() - ) - .metadata( - CustomerUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .name("name") - .paymentProvider(CustomerUpdateParams.PaymentProvider.QUICKBOOKS) - .paymentProviderId("payment_provider_id") - .reportingConfiguration( - CustomerUpdateParams.ReportingConfiguration.builder().exempt(true).build() - ) - .shippingAddress( - CustomerUpdateParams.ShippingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .taxConfiguration( - CustomerUpdateParams.TaxConfiguration.NewAvalaraTaxConfiguration.builder() - .taxExempt(true) - .taxProvider( - CustomerUpdateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA + .addAdditionalEmail("string") + .autoCollection(true) + .billingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .currency("currency") + .email("dev@stainless.com") + .emailDelivery(true) + .externalCustomerId("external_customer_id") + .hierarchy( + CustomerHierarchyConfigModel.builder() + .addChildCustomerId("string") + .parentCustomerId("parent_customer_id") + .build() + ) + .metadata( + EditCustomerModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .paymentProvider(EditCustomerModel.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .reportingConfiguration( + NewReportingConfigurationModel.builder().exempt(true).build() + ) + .shippingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxConfiguration( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.builder() + .taxExempt(true) + .taxProvider( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration + .TaxProvider + .AVALARA + ) + .taxExemptionCode("tax_exemption_code") + .build() + ) + .taxId( + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) + .value("value") + .build() ) - .taxExemptionCode("tax_exemption_code") - .build() - ) - .taxId( - CustomerUpdateParams.TaxId.builder() - .country(CustomerUpdateParams.TaxId.Country.AD) - .type(CustomerUpdateParams.TaxId.Type.AD_NRT) - .value("value") .build() ) .build() ) - customer.validate() + customerModel.validate() } @Test @@ -238,10 +247,10 @@ class CustomerServiceTest { .build() val customerService = client.customers() - val customer = + val customerModel = customerService.fetch(CustomerFetchParams.builder().customerId("customer_id").build()) - customer.validate() + customerModel.validate() } @Test @@ -253,14 +262,14 @@ class CustomerServiceTest { .build() val customerService = client.customers() - val customer = + val customerModel = customerService.fetchByExternalId( CustomerFetchByExternalIdParams.builder() .externalCustomerId("external_customer_id") .build() ) - customer.validate() + customerModel.validate() } @Test @@ -304,91 +313,90 @@ class CustomerServiceTest { .build() val customerService = client.customers() - val customer = + val customerModel = customerService.updateByExternalId( CustomerUpdateByExternalIdParams.builder() .id("external_customer_id") - .accountingSyncConfiguration( - CustomerUpdateByExternalIdParams.AccountingSyncConfiguration.builder() - .addAccountingProvider( - CustomerUpdateByExternalIdParams.AccountingSyncConfiguration - .AccountingProvider - .builder() - .externalProviderId("external_provider_id") - .providerType("provider_type") + .editCustomerModel( + EditCustomerModel.builder() + .accountingSyncConfiguration( + NewAccountingSyncConfigurationModel.builder() + .addAccountingProvider( + NewAccountingSyncConfigurationModel.AccountingProvider + .builder() + .externalProviderId("external_provider_id") + .providerType("provider_type") + .build() + ) + .excluded(true) .build() ) - .excluded(true) - .build() - ) - .addAdditionalEmail("string") - .autoCollection(true) - .billingAddress( - CustomerUpdateByExternalIdParams.BillingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .currency("currency") - .email("dev@stainless.com") - .emailDelivery(true) - .externalCustomerId("external_customer_id") - .hierarchy( - CustomerUpdateByExternalIdParams.Hierarchy.builder() - .addChildCustomerId("string") - .parentCustomerId("parent_customer_id") - .build() - ) - .metadata( - CustomerUpdateByExternalIdParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .name("name") - .paymentProvider(CustomerUpdateByExternalIdParams.PaymentProvider.QUICKBOOKS) - .paymentProviderId("payment_provider_id") - .reportingConfiguration( - CustomerUpdateByExternalIdParams.ReportingConfiguration.builder() - .exempt(true) - .build() - ) - .shippingAddress( - CustomerUpdateByExternalIdParams.ShippingAddress.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .build() - ) - .taxConfiguration( - CustomerUpdateByExternalIdParams.TaxConfiguration.NewAvalaraTaxConfiguration - .builder() - .taxExempt(true) - .taxProvider( - CustomerUpdateByExternalIdParams.TaxConfiguration - .NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA + .addAdditionalEmail("string") + .autoCollection(true) + .billingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .currency("currency") + .email("dev@stainless.com") + .emailDelivery(true) + .externalCustomerId("external_customer_id") + .hierarchy( + CustomerHierarchyConfigModel.builder() + .addChildCustomerId("string") + .parentCustomerId("parent_customer_id") + .build() + ) + .metadata( + EditCustomerModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .name("name") + .paymentProvider(EditCustomerModel.PaymentProvider.QUICKBOOKS) + .paymentProviderId("payment_provider_id") + .reportingConfiguration( + NewReportingConfigurationModel.builder().exempt(true).build() + ) + .shippingAddress( + AddressInputModel.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) + .taxConfiguration( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration.builder() + .taxExempt(true) + .taxProvider( + NewTaxConfigurationModel.NewAvalaraTaxConfiguration + .TaxProvider + .AVALARA + ) + .taxExemptionCode("tax_exemption_code") + .build() + ) + .taxId( + CustomerTaxIdModel.builder() + .country(CustomerTaxIdModel.Country.AD) + .type(CustomerTaxIdModel.Type.AD_NRT) + .value("value") + .build() ) - .taxExemptionCode("tax_exemption_code") - .build() - ) - .taxId( - CustomerUpdateByExternalIdParams.TaxId.builder() - .country(CustomerUpdateByExternalIdParams.TaxId.Country.AD) - .type(CustomerUpdateByExternalIdParams.TaxId.Type.AD_NRT) - .value("value") .build() ) .build() ) - customer.validate() + customerModel.validate() } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/DimensionalPriceGroupServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/DimensionalPriceGroupServiceTest.kt index bbd7ea613..479170e70 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/DimensionalPriceGroupServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/DimensionalPriceGroupServiceTest.kt @@ -22,7 +22,7 @@ class DimensionalPriceGroupServiceTest { .build() val dimensionalPriceGroupService = client.dimensionalPriceGroups() - val dimensionalPriceGroup = + val dimensionalPriceGroupModel = dimensionalPriceGroupService.create( DimensionalPriceGroupCreateParams.builder() .billableMetricId("billable_metric_id") @@ -38,7 +38,7 @@ class DimensionalPriceGroupServiceTest { .build() ) - dimensionalPriceGroup.validate() + dimensionalPriceGroupModel.validate() } @Test @@ -50,14 +50,14 @@ class DimensionalPriceGroupServiceTest { .build() val dimensionalPriceGroupService = client.dimensionalPriceGroups() - val dimensionalPriceGroup = + val dimensionalPriceGroupModel = dimensionalPriceGroupService.retrieve( DimensionalPriceGroupRetrieveParams.builder() .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) - dimensionalPriceGroup.validate() + dimensionalPriceGroupModel.validate() } @Test diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceLineItemServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceLineItemServiceTest.kt index 64b708c88..033a8124b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceLineItemServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceLineItemServiceTest.kt @@ -21,7 +21,7 @@ class InvoiceLineItemServiceTest { .build() val invoiceLineItemService = client.invoiceLineItems() - val invoiceLineItem = + val invoiceLineItemModel = invoiceLineItemService.create( InvoiceLineItemCreateParams.builder() .amount("12.00") @@ -33,6 +33,6 @@ class InvoiceLineItemServiceTest { .build() ) - invoiceLineItem.validate() + invoiceLineItemModel.validate() } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceServiceTest.kt index 3b10a43b7..189f8b78a 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 @@ -14,6 +14,7 @@ import com.withorb.api.models.InvoicePayParams import com.withorb.api.models.InvoiceUpdateParams import com.withorb.api.models.InvoiceVoidInvoiceParams import com.withorb.api.models.PercentageDiscount +import com.withorb.api.models.UnitConfigModel import java.time.LocalDate import java.time.OffsetDateTime import org.junit.jupiter.api.Test @@ -31,7 +32,7 @@ class InvoiceServiceTest { .build() val invoiceService = client.invoices() - val invoice = + val invoiceModel = invoiceService.create( InvoiceCreateParams.builder() .currency("USD") @@ -44,11 +45,7 @@ class InvoiceServiceTest { .name("Line Item Name") .quantity(1.0) .startDate(LocalDate.parse("2023-09-22")) - .unitConfig( - InvoiceCreateParams.LineItem.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) .build() ) .netTerms(0L) @@ -73,7 +70,7 @@ class InvoiceServiceTest { .build() ) - invoice.validate() + invoiceModel.validate() } @Test @@ -85,7 +82,7 @@ class InvoiceServiceTest { .build() val invoiceService = client.invoices() - val invoice = + val invoiceModel = invoiceService.update( InvoiceUpdateParams.builder() .invoiceId("invoice_id") @@ -97,7 +94,7 @@ class InvoiceServiceTest { .build() ) - invoice.validate() + invoiceModel.validate() } @Test @@ -123,10 +120,10 @@ class InvoiceServiceTest { .build() val invoiceService = client.invoices() - val invoice = + val invoiceModel = invoiceService.fetch(InvoiceFetchParams.builder().invoiceId("invoice_id").build()) - invoice.validate() + invoiceModel.validate() } @Test @@ -155,12 +152,12 @@ class InvoiceServiceTest { .build() val invoiceService = client.invoices() - val invoice = + val invoiceModel = invoiceService.issue( InvoiceIssueParams.builder().invoiceId("invoice_id").synchronous(true).build() ) - invoice.validate() + invoiceModel.validate() } @Test @@ -172,7 +169,7 @@ class InvoiceServiceTest { .build() val invoiceService = client.invoices() - val invoice = + val invoiceModel = invoiceService.markPaid( InvoiceMarkPaidParams.builder() .invoiceId("invoice_id") @@ -182,7 +179,7 @@ class InvoiceServiceTest { .build() ) - invoice.validate() + invoiceModel.validate() } @Test @@ -194,9 +191,10 @@ class InvoiceServiceTest { .build() val invoiceService = client.invoices() - val invoice = invoiceService.pay(InvoicePayParams.builder().invoiceId("invoice_id").build()) + val invoiceModel = + invoiceService.pay(InvoicePayParams.builder().invoiceId("invoice_id").build()) - invoice.validate() + invoiceModel.validate() } @Test @@ -208,11 +206,11 @@ class InvoiceServiceTest { .build() val invoiceService = client.invoices() - val invoice = + val invoiceModel = invoiceService.voidInvoice( InvoiceVoidInvoiceParams.builder().invoiceId("invoice_id").build() ) - invoice.validate() + invoiceModel.validate() } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/ItemServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/ItemServiceTest.kt index 3fa73e7ce..611dd0de6 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/ItemServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/ItemServiceTest.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.blocking import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClient import com.withorb.api.models.ItemCreateParams +import com.withorb.api.models.ItemExternalConnectionModel import com.withorb.api.models.ItemFetchParams import com.withorb.api.models.ItemUpdateParams import org.junit.jupiter.api.Test @@ -22,9 +23,9 @@ class ItemServiceTest { .build() val itemService = client.items() - val item = itemService.create(ItemCreateParams.builder().name("API requests").build()) + val itemModel = itemService.create(ItemCreateParams.builder().name("API requests").build()) - item.validate() + itemModel.validate() } @Test @@ -36,14 +37,14 @@ class ItemServiceTest { .build() val itemService = client.items() - val item = + val itemModel = itemService.update( ItemUpdateParams.builder() .itemId("item_id") .addExternalConnection( - ItemUpdateParams.ExternalConnection.builder() + ItemExternalConnectionModel.builder() .externalConnectionName( - ItemUpdateParams.ExternalConnection.ExternalConnectionName.STRIPE + ItemExternalConnectionModel.ExternalConnectionName.STRIPE ) .externalEntityId("external_entity_id") .build() @@ -52,7 +53,7 @@ class ItemServiceTest { .build() ) - item.validate() + itemModel.validate() } @Test @@ -78,8 +79,8 @@ class ItemServiceTest { .build() val itemService = client.items() - val item = itemService.fetch(ItemFetchParams.builder().itemId("item_id").build()) + val itemModel = itemService.fetch(ItemFetchParams.builder().itemId("item_id").build()) - item.validate() + itemModel.validate() } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/MetricServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/MetricServiceTest.kt index d8c003293..ba8517536 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/MetricServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/MetricServiceTest.kt @@ -23,7 +23,7 @@ class MetricServiceTest { .build() val metricService = client.metrics() - val billableMetric = + val billableMetricModel = metricService.create( MetricCreateParams.builder() .description("Sum of bytes downloaded in fast mode") @@ -38,7 +38,7 @@ class MetricServiceTest { .build() ) - billableMetric.validate() + billableMetricModel.validate() } @Test @@ -50,7 +50,7 @@ class MetricServiceTest { .build() val metricService = client.metrics() - val billableMetric = + val billableMetricModel = metricService.update( MetricUpdateParams.builder() .metricId("metric_id") @@ -62,7 +62,7 @@ class MetricServiceTest { .build() ) - billableMetric.validate() + billableMetricModel.validate() } @Test @@ -88,9 +88,9 @@ class MetricServiceTest { .build() val metricService = client.metrics() - val billableMetric = + val billableMetricModel = metricService.fetch(MetricFetchParams.builder().metricId("metric_id").build()) - billableMetric.validate() + billableMetricModel.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 bcf1edd84..912a8f313 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 @@ -5,9 +5,12 @@ package com.withorb.api.services.blocking import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClient import com.withorb.api.core.JsonValue +import com.withorb.api.models.EditPlanModel +import com.withorb.api.models.NewBillingCycleConfigurationModel import com.withorb.api.models.PlanCreateParams import com.withorb.api.models.PlanFetchParams import com.withorb.api.models.PlanUpdateParams +import com.withorb.api.models.UnitConfigModel import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -23,7 +26,7 @@ class PlanServiceTest { .build() val planService = client.plans() - val plan = + val planModel = planService.create( PlanCreateParams.builder() .currency("currency") @@ -34,22 +37,14 @@ class PlanServiceTest { .itemId("item_id") .modelType(PlanCreateParams.Price.NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - PlanCreateParams.Price.NewPlanUnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - PlanCreateParams.Price.NewPlanUnitPrice.BillingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - PlanCreateParams.Price.NewPlanUnitPrice - .BillingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) @@ -59,14 +54,10 @@ class PlanServiceTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - PlanCreateParams.Price.NewPlanUnitPrice.InvoicingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - PlanCreateParams.Price.NewPlanUnitPrice - .InvoicingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) @@ -89,7 +80,7 @@ class PlanServiceTest { .build() ) - plan.validate() + planModel.validate() } @Test @@ -101,20 +92,24 @@ class PlanServiceTest { .build() val planService = client.plans() - val plan = + val planModel = planService.update( PlanUpdateParams.builder() .planId("plan_id") - .externalPlanId("external_plan_id") - .metadata( - PlanUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .editPlanModel( + EditPlanModel.builder() + .externalPlanId("external_plan_id") + .metadata( + EditPlanModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .build() ) .build() ) - plan.validate() + planModel.validate() } @Test @@ -140,8 +135,8 @@ class PlanServiceTest { .build() val planService = client.plans() - val plan = planService.fetch(PlanFetchParams.builder().planId("plan_id").build()) + val planModel = planService.fetch(PlanFetchParams.builder().planId("plan_id").build()) - plan.validate() + planModel.validate() } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/PriceServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/PriceServiceTest.kt index b427e23fc..5e5eee28e 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 @@ -5,10 +5,14 @@ package com.withorb.api.services.blocking import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClient import com.withorb.api.core.JsonValue +import com.withorb.api.models.NewBillingCycleConfigurationModel +import com.withorb.api.models.NewFloatingPriceModel import com.withorb.api.models.PriceCreateParams import com.withorb.api.models.PriceEvaluateParams import com.withorb.api.models.PriceFetchParams import com.withorb.api.models.PriceUpdateParams +import com.withorb.api.models.UnitConfigModel +import com.withorb.api.models.UpdatePriceRequestParams import java.time.OffsetDateTime import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -25,33 +29,24 @@ class PriceServiceTest { .build() val priceService = client.prices() - val price = + val priceModel = priceService.create( PriceCreateParams.builder() - .body( - PriceCreateParams.Body.NewFloatingUnitPrice.builder() - .cadence(PriceCreateParams.Body.NewFloatingUnitPrice.Cadence.ANNUAL) + .newFloatingPriceModel( + NewFloatingPriceModel.NewFloatingUnitPrice.builder() + .cadence(NewFloatingPriceModel.NewFloatingUnitPrice.Cadence.ANNUAL) .currency("currency") .itemId("item_id") - .modelType(PriceCreateParams.Body.NewFloatingUnitPrice.ModelType.UNIT) + .modelType(NewFloatingPriceModel.NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") - .unitConfig( - PriceCreateParams.Body.NewFloatingUnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() - ) + .unitConfig(UnitConfigModel.builder().unitAmount("unit_amount").build()) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - PriceCreateParams.Body.NewFloatingUnitPrice - .BillingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - PriceCreateParams.Body.NewFloatingUnitPrice - .BillingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) @@ -60,20 +55,15 @@ class PriceServiceTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - PriceCreateParams.Body.NewFloatingUnitPrice - .InvoicingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - PriceCreateParams.Body.NewFloatingUnitPrice - .InvoicingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) .metadata( - PriceCreateParams.Body.NewFloatingUnitPrice.Metadata.builder() + NewFloatingPriceModel.NewFloatingUnitPrice.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -82,7 +72,7 @@ class PriceServiceTest { .build() ) - price.validate() + priceModel.validate() } @Test @@ -94,19 +84,23 @@ class PriceServiceTest { .build() val priceService = client.prices() - val price = + val priceModel = priceService.update( PriceUpdateParams.builder() .priceId("price_id") - .metadata( - PriceUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .updatePriceRequestParams( + UpdatePriceRequestParams.builder() + .metadata( + UpdatePriceRequestParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .build() ) .build() ) - price.validate() + priceModel.validate() } @Test @@ -157,8 +151,8 @@ class PriceServiceTest { .build() val priceService = client.prices() - val price = priceService.fetch(PriceFetchParams.builder().priceId("price_id").build()) + val priceModel = priceService.fetch(PriceFetchParams.builder().priceId("price_id").build()) - price.validate() + priceModel.validate() } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/SubscriptionServiceTest.kt index e92fdc67f..fe1b467f9 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 @@ -5,6 +5,20 @@ package com.withorb.api.services.blocking import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClient import com.withorb.api.core.JsonValue +import com.withorb.api.models.AddSubscriptionAdjustmentParams +import com.withorb.api.models.AddSubscriptionPriceParams +import com.withorb.api.models.BillingCycleAnchorConfigurationModel +import com.withorb.api.models.DiscountOverrideModel +import com.withorb.api.models.NewAdjustmentModel +import com.withorb.api.models.NewAllocationPriceModel +import com.withorb.api.models.NewBillingCycleConfigurationModel +import com.withorb.api.models.NewFloatingPriceModel +import com.withorb.api.models.NewSubscriptionPriceModel +import com.withorb.api.models.PriceIntervalFixedFeeQuantityTransitionModel +import com.withorb.api.models.RemoveSubscriptionAdjustmentParams +import com.withorb.api.models.RemoveSubscriptionPriceParams +import com.withorb.api.models.ReplaceSubscriptionAdjustmentParams +import com.withorb.api.models.ReplaceSubscriptionPriceParams import com.withorb.api.models.SubscriptionCancelParams import com.withorb.api.models.SubscriptionCreateParams import com.withorb.api.models.SubscriptionFetchCostsParams @@ -20,6 +34,7 @@ import com.withorb.api.models.SubscriptionUnschedulePendingPlanChangesParams import com.withorb.api.models.SubscriptionUpdateFixedFeeQuantityParams import com.withorb.api.models.SubscriptionUpdateParams import com.withorb.api.models.SubscriptionUpdateTrialParams +import com.withorb.api.models.UnitConfigModel import java.time.LocalDate import java.time.OffsetDateTime import org.junit.jupiter.api.Disabled @@ -38,19 +53,15 @@ class SubscriptionServiceTest { .build() val subscriptionService = client.subscriptions() - val subscription = + val mutatedSubscriptionModel = subscriptionService.create( SubscriptionCreateParams.builder() .addAddAdjustment( - SubscriptionCreateParams.AddAdjustment.builder() + AddSubscriptionAdjustmentParams.builder() .adjustment( - SubscriptionCreateParams.AddAdjustment.Adjustment - .NewPercentageDiscount - .builder() + NewAdjustmentModel.NewPercentageDiscount.builder() .adjustmentType( - SubscriptionCreateParams.AddAdjustment.Adjustment - .NewPercentageDiscount - .AdjustmentType + NewAdjustmentModel.NewPercentageDiscount.AdjustmentType .PERCENTAGE_DISCOUNT ) .addAppliesToPriceId("price_1") @@ -65,24 +76,18 @@ class SubscriptionServiceTest { .build() ) .addAddPrice( - SubscriptionCreateParams.AddPrice.builder() + AddSubscriptionPriceParams.builder() .allocationPrice( - SubscriptionCreateParams.AddPrice.AllocationPrice.builder() + NewAllocationPriceModel.builder() .amount("10.00") - .cadence( - SubscriptionCreateParams.AddPrice.AllocationPrice.Cadence - .ONE_TIME - ) + .cadence(NewAllocationPriceModel.Cadence.ONE_TIME) .currency("USD") .expiresAtEndOfCadence(true) .build() ) .addDiscount( - SubscriptionCreateParams.AddPrice.Discount.builder() - .discountType( - SubscriptionCreateParams.AddPrice.Discount.DiscountType - .PERCENTAGE - ) + DiscountOverrideModel.builder() + .discountType(DiscountOverrideModel.DiscountType.PERCENTAGE) .amountDiscount("amount_discount") .percentageDiscount(0.15) .usageDiscount(0.0) @@ -94,44 +99,27 @@ class SubscriptionServiceTest { .minimumAmount("1.23") .planPhaseOrder(0L) .price( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice - .builder() + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.builder() .cadence( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice - .Cadence + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Cadence .ANNUAL ) .itemId("item_id") .modelType( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice - .ModelType + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.ModelType .UNIT ) .name("Annual fee") .unitConfig( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice - .UnitConfig - .builder() - .unitAmount("unit_amount") - .build() + UnitConfigModel.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice - .BillingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice - .BillingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) @@ -141,24 +129,15 @@ class SubscriptionServiceTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) .metadata( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice - .Metadata + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -174,7 +153,7 @@ class SubscriptionServiceTest { .autoCollection(true) .awsRegion("aws_region") .billingCycleAnchorConfiguration( - SubscriptionCreateParams.BillingCycleAnchorConfiguration.builder() + BillingCycleAnchorConfigurationModel.builder() .day(1L) .month(1L) .year(0L) @@ -203,26 +182,22 @@ class SubscriptionServiceTest { .planVersionNumber(0L) .addPriceOverride(JsonValue.from(mapOf())) .addRemoveAdjustment( - SubscriptionCreateParams.RemoveAdjustment.builder() + RemoveSubscriptionAdjustmentParams.builder() .adjustmentId("h74gfhdjvn7ujokd") .build() ) .addRemovePrice( - SubscriptionCreateParams.RemovePrice.builder() + RemoveSubscriptionPriceParams.builder() .externalPriceId("external_price_id") .priceId("h74gfhdjvn7ujokd") .build() ) .addReplaceAdjustment( - SubscriptionCreateParams.ReplaceAdjustment.builder() + ReplaceSubscriptionAdjustmentParams.builder() .adjustment( - SubscriptionCreateParams.ReplaceAdjustment.Adjustment - .NewPercentageDiscount - .builder() + NewAdjustmentModel.NewPercentageDiscount.builder() .adjustmentType( - SubscriptionCreateParams.ReplaceAdjustment.Adjustment - .NewPercentageDiscount - .AdjustmentType + NewAdjustmentModel.NewPercentageDiscount.AdjustmentType .PERCENTAGE_DISCOUNT ) .addAppliesToPriceId("price_1") @@ -235,26 +210,19 @@ class SubscriptionServiceTest { .build() ) .addReplacePrice( - SubscriptionCreateParams.ReplacePrice.builder() + ReplaceSubscriptionPriceParams.builder() .replacesPriceId("replaces_price_id") .allocationPrice( - SubscriptionCreateParams.ReplacePrice.AllocationPrice.builder() + NewAllocationPriceModel.builder() .amount("10.00") - .cadence( - SubscriptionCreateParams.ReplacePrice.AllocationPrice - .Cadence - .ONE_TIME - ) + .cadence(NewAllocationPriceModel.Cadence.ONE_TIME) .currency("USD") .expiresAtEndOfCadence(true) .build() ) .addDiscount( - SubscriptionCreateParams.ReplacePrice.Discount.builder() - .discountType( - SubscriptionCreateParams.ReplacePrice.Discount.DiscountType - .PERCENTAGE - ) + DiscountOverrideModel.builder() + .discountType(DiscountOverrideModel.DiscountType.PERCENTAGE) .amountDiscount("amount_discount") .percentageDiscount(0.15) .usageDiscount(0.0) @@ -265,44 +233,27 @@ class SubscriptionServiceTest { .maximumAmount("1.23") .minimumAmount("1.23") .price( - SubscriptionCreateParams.ReplacePrice.Price.NewSubscriptionUnitPrice - .builder() + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.builder() .cadence( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .Cadence + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Cadence .ANNUAL ) .itemId("item_id") .modelType( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .ModelType + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.ModelType .UNIT ) .name("Annual fee") .unitConfig( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .UnitConfig - .builder() - .unitAmount("unit_amount") - .build() + UnitConfigModel.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .BillingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .BillingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) @@ -312,24 +263,15 @@ class SubscriptionServiceTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) .metadata( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .Metadata + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -346,7 +288,7 @@ class SubscriptionServiceTest { .build() ) - subscription.validate() + mutatedSubscriptionModel.validate() } @Test @@ -358,7 +300,7 @@ class SubscriptionServiceTest { .build() val subscriptionService = client.subscriptions() - val subscription = + val subscriptionModel = subscriptionService.update( SubscriptionUpdateParams.builder() .subscriptionId("subscription_id") @@ -374,7 +316,7 @@ class SubscriptionServiceTest { .build() ) - subscription.validate() + subscriptionModel.validate() } @Test @@ -400,7 +342,7 @@ class SubscriptionServiceTest { .build() val subscriptionService = client.subscriptions() - val response = + val mutatedSubscriptionModel = subscriptionService.cancel( SubscriptionCancelParams.builder() .subscriptionId("subscription_id") @@ -410,7 +352,7 @@ class SubscriptionServiceTest { .build() ) - response.validate() + mutatedSubscriptionModel.validate() } @Test @@ -422,12 +364,12 @@ class SubscriptionServiceTest { .build() val subscriptionService = client.subscriptions() - val subscription = + val subscriptionModel = subscriptionService.fetch( SubscriptionFetchParams.builder().subscriptionId("subscription_id").build() ) - subscription.validate() + subscriptionModel.validate() } @Test @@ -510,7 +452,7 @@ class SubscriptionServiceTest { .build() val subscriptionService = client.subscriptions() - val response = + val mutatedSubscriptionModel = subscriptionService.priceIntervals( SubscriptionPriceIntervalsParams.builder() .subscriptionId("subscription_id") @@ -518,12 +460,9 @@ class SubscriptionServiceTest { SubscriptionPriceIntervalsParams.Add.builder() .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .allocationPrice( - SubscriptionPriceIntervalsParams.Add.AllocationPrice.builder() + NewAllocationPriceModel.builder() .amount("10.00") - .cadence( - SubscriptionPriceIntervalsParams.Add.AllocationPrice.Cadence - .ONE_TIME - ) + .cadence(NewAllocationPriceModel.Cadence.ONE_TIME) .currency("USD") .expiresAtEndOfCadence(true) .build() @@ -533,8 +472,7 @@ class SubscriptionServiceTest { .externalPriceId("external_price_id") .filter("my_property > 100 AND my_other_property = 'bar'") .addFixedFeeQuantityTransition( - SubscriptionPriceIntervalsParams.Add.FixedFeeQuantityTransition - .builder() + PriceIntervalFixedFeeQuantityTransitionModel.builder() .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .quantity(5L) .build() @@ -542,45 +480,26 @@ class SubscriptionServiceTest { .maximumAmount(0.0) .minimumAmount(0.0) .price( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice - .builder() + NewFloatingPriceModel.NewFloatingUnitPrice.builder() .cadence( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice - .Cadence - .ANNUAL + NewFloatingPriceModel.NewFloatingUnitPrice.Cadence.ANNUAL ) .currency("currency") .itemId("item_id") .modelType( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice - .ModelType - .UNIT + NewFloatingPriceModel.NewFloatingUnitPrice.ModelType.UNIT ) .name("Annual fee") .unitConfig( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice - .UnitConfig - .builder() - .unitAmount("unit_amount") - .build() + UnitConfigModel.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice - .BillingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice - .BillingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) @@ -589,24 +508,15 @@ class SubscriptionServiceTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice - .InvoicingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice - .InvoicingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) .metadata( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice - .Metadata + NewFloatingPriceModel.NewFloatingUnitPrice.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -620,13 +530,9 @@ class SubscriptionServiceTest { .addAddAdjustment( SubscriptionPriceIntervalsParams.AddAdjustment.builder() .adjustment( - SubscriptionPriceIntervalsParams.AddAdjustment.Adjustment - .NewPercentageDiscount - .builder() + NewAdjustmentModel.NewPercentageDiscount.builder() .adjustmentType( - SubscriptionPriceIntervalsParams.AddAdjustment.Adjustment - .NewPercentageDiscount - .AdjustmentType + NewAdjustmentModel.NewPercentageDiscount.AdjustmentType .PERCENTAGE_DISCOUNT ) .addAppliesToPriceId("price_1") @@ -647,8 +553,7 @@ class SubscriptionServiceTest { .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .filter("my_property > 100 AND my_other_property = 'bar'") .addFixedFeeQuantityTransition( - SubscriptionPriceIntervalsParams.Edit.FixedFeeQuantityTransition - .builder() + PriceIntervalFixedFeeQuantityTransitionModel.builder() .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .quantity(5L) .build() @@ -667,7 +572,7 @@ class SubscriptionServiceTest { .build() ) - response.validate() + mutatedSubscriptionModel.validate() } @Test @@ -679,22 +584,17 @@ class SubscriptionServiceTest { .build() val subscriptionService = client.subscriptions() - val response = + val mutatedSubscriptionModel = subscriptionService.schedulePlanChange( SubscriptionSchedulePlanChangeParams.builder() .subscriptionId("subscription_id") .changeOption(SubscriptionSchedulePlanChangeParams.ChangeOption.REQUESTED_DATE) .addAddAdjustment( - SubscriptionSchedulePlanChangeParams.AddAdjustment.builder() + AddSubscriptionAdjustmentParams.builder() .adjustment( - SubscriptionSchedulePlanChangeParams.AddAdjustment.Adjustment - .NewPercentageDiscount - .builder() + NewAdjustmentModel.NewPercentageDiscount.builder() .adjustmentType( - SubscriptionSchedulePlanChangeParams.AddAdjustment - .Adjustment - .NewPercentageDiscount - .AdjustmentType + NewAdjustmentModel.NewPercentageDiscount.AdjustmentType .PERCENTAGE_DISCOUNT ) .addAppliesToPriceId("price_1") @@ -709,28 +609,18 @@ class SubscriptionServiceTest { .build() ) .addAddPrice( - SubscriptionSchedulePlanChangeParams.AddPrice.builder() + AddSubscriptionPriceParams.builder() .allocationPrice( - SubscriptionSchedulePlanChangeParams.AddPrice.AllocationPrice - .builder() + NewAllocationPriceModel.builder() .amount("10.00") - .cadence( - SubscriptionSchedulePlanChangeParams.AddPrice - .AllocationPrice - .Cadence - .ONE_TIME - ) + .cadence(NewAllocationPriceModel.Cadence.ONE_TIME) .currency("USD") .expiresAtEndOfCadence(true) .build() ) .addDiscount( - SubscriptionSchedulePlanChangeParams.AddPrice.Discount.builder() - .discountType( - SubscriptionSchedulePlanChangeParams.AddPrice.Discount - .DiscountType - .PERCENTAGE - ) + DiscountOverrideModel.builder() + .discountType(DiscountOverrideModel.DiscountType.PERCENTAGE) .amountDiscount("amount_discount") .percentageDiscount(0.15) .usageDiscount(0.0) @@ -742,45 +632,27 @@ class SubscriptionServiceTest { .minimumAmount("1.23") .planPhaseOrder(0L) .price( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .builder() + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.builder() .cadence( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .Cadence + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Cadence .ANNUAL ) .itemId("item_id") .modelType( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .ModelType + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.ModelType .UNIT ) .name("Annual fee") .unitConfig( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .UnitConfig - .builder() - .unitAmount("unit_amount") - .build() + UnitConfigModel.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .BillingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .BillingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) @@ -790,24 +662,15 @@ class SubscriptionServiceTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) .metadata( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .Metadata + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -825,8 +688,7 @@ class SubscriptionServiceTest { SubscriptionSchedulePlanChangeParams.BillingCycleAlignment.UNCHANGED ) .billingCycleAnchorConfiguration( - SubscriptionSchedulePlanChangeParams.BillingCycleAnchorConfiguration - .builder() + BillingCycleAnchorConfigurationModel.builder() .day(1L) .month(1L) .year(0L) @@ -846,27 +708,22 @@ class SubscriptionServiceTest { .planVersionNumber(0L) .addPriceOverride(JsonValue.from(mapOf())) .addRemoveAdjustment( - SubscriptionSchedulePlanChangeParams.RemoveAdjustment.builder() + RemoveSubscriptionAdjustmentParams.builder() .adjustmentId("h74gfhdjvn7ujokd") .build() ) .addRemovePrice( - SubscriptionSchedulePlanChangeParams.RemovePrice.builder() + RemoveSubscriptionPriceParams.builder() .externalPriceId("external_price_id") .priceId("h74gfhdjvn7ujokd") .build() ) .addReplaceAdjustment( - SubscriptionSchedulePlanChangeParams.ReplaceAdjustment.builder() + ReplaceSubscriptionAdjustmentParams.builder() .adjustment( - SubscriptionSchedulePlanChangeParams.ReplaceAdjustment.Adjustment - .NewPercentageDiscount - .builder() + NewAdjustmentModel.NewPercentageDiscount.builder() .adjustmentType( - SubscriptionSchedulePlanChangeParams.ReplaceAdjustment - .Adjustment - .NewPercentageDiscount - .AdjustmentType + NewAdjustmentModel.NewPercentageDiscount.AdjustmentType .PERCENTAGE_DISCOUNT ) .addAppliesToPriceId("price_1") @@ -879,29 +736,19 @@ class SubscriptionServiceTest { .build() ) .addReplacePrice( - SubscriptionSchedulePlanChangeParams.ReplacePrice.builder() + ReplaceSubscriptionPriceParams.builder() .replacesPriceId("replaces_price_id") .allocationPrice( - SubscriptionSchedulePlanChangeParams.ReplacePrice.AllocationPrice - .builder() + NewAllocationPriceModel.builder() .amount("10.00") - .cadence( - SubscriptionSchedulePlanChangeParams.ReplacePrice - .AllocationPrice - .Cadence - .ONE_TIME - ) + .cadence(NewAllocationPriceModel.Cadence.ONE_TIME) .currency("USD") .expiresAtEndOfCadence(true) .build() ) .addDiscount( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Discount.builder() - .discountType( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Discount - .DiscountType - .PERCENTAGE - ) + DiscountOverrideModel.builder() + .discountType(DiscountOverrideModel.DiscountType.PERCENTAGE) .amountDiscount("amount_discount") .percentageDiscount(0.15) .usageDiscount(0.0) @@ -912,46 +759,27 @@ class SubscriptionServiceTest { .maximumAmount("1.23") .minimumAmount("1.23") .price( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .builder() + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.builder() .cadence( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .Cadence + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Cadence .ANNUAL ) .itemId("item_id") .modelType( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .ModelType + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.ModelType .UNIT ) .name("Annual fee") .unitConfig( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .UnitConfig - .builder() - .unitAmount("unit_amount") - .build() + UnitConfigModel.builder().unitAmount("unit_amount").build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .BillingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionSchedulePlanChangeParams.ReplacePrice - .Price - .NewSubscriptionUnitPrice - .BillingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) @@ -961,25 +789,15 @@ class SubscriptionServiceTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .builder() + NewBillingCycleConfigurationModel.builder() .duration(0L) .durationUnit( - SubscriptionSchedulePlanChangeParams.ReplacePrice - .Price - .NewSubscriptionUnitPrice - .InvoicingCycleConfiguration - .DurationUnit - .DAY + NewBillingCycleConfigurationModel.DurationUnit.DAY ) .build() ) .metadata( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .Metadata + NewSubscriptionPriceModel.NewSubscriptionUnitPrice.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -995,7 +813,7 @@ class SubscriptionServiceTest { .build() ) - response.validate() + mutatedSubscriptionModel.validate() } @Test @@ -1007,7 +825,7 @@ class SubscriptionServiceTest { .build() val subscriptionService = client.subscriptions() - val response = + val mutatedSubscriptionModel = subscriptionService.triggerPhase( SubscriptionTriggerPhaseParams.builder() .subscriptionId("subscription_id") @@ -1016,7 +834,7 @@ class SubscriptionServiceTest { .build() ) - response.validate() + mutatedSubscriptionModel.validate() } @Test @@ -1028,14 +846,14 @@ class SubscriptionServiceTest { .build() val subscriptionService = client.subscriptions() - val response = + val mutatedSubscriptionModel = subscriptionService.unscheduleCancellation( SubscriptionUnscheduleCancellationParams.builder() .subscriptionId("subscription_id") .build() ) - response.validate() + mutatedSubscriptionModel.validate() } @Test @@ -1047,7 +865,7 @@ class SubscriptionServiceTest { .build() val subscriptionService = client.subscriptions() - val response = + val mutatedSubscriptionModel = subscriptionService.unscheduleFixedFeeQuantityUpdates( SubscriptionUnscheduleFixedFeeQuantityUpdatesParams.builder() .subscriptionId("subscription_id") @@ -1055,7 +873,7 @@ class SubscriptionServiceTest { .build() ) - response.validate() + mutatedSubscriptionModel.validate() } @Test @@ -1067,14 +885,14 @@ class SubscriptionServiceTest { .build() val subscriptionService = client.subscriptions() - val response = + val mutatedSubscriptionModel = subscriptionService.unschedulePendingPlanChanges( SubscriptionUnschedulePendingPlanChangesParams.builder() .subscriptionId("subscription_id") .build() ) - response.validate() + mutatedSubscriptionModel.validate() } @Test @@ -1086,7 +904,7 @@ class SubscriptionServiceTest { .build() val subscriptionService = client.subscriptions() - val response = + val mutatedSubscriptionModel = subscriptionService.updateFixedFeeQuantity( SubscriptionUpdateFixedFeeQuantityParams.builder() .subscriptionId("subscription_id") @@ -1098,7 +916,7 @@ class SubscriptionServiceTest { .build() ) - response.validate() + mutatedSubscriptionModel.validate() } @Test @@ -1110,7 +928,7 @@ class SubscriptionServiceTest { .build() val subscriptionService = client.subscriptions() - val response = + val mutatedSubscriptionModel = subscriptionService.updateTrial( SubscriptionUpdateTrialParams.builder() .subscriptionId("subscription_id") @@ -1119,6 +937,6 @@ class SubscriptionServiceTest { .build() ) - response.validate() + mutatedSubscriptionModel.validate() } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/customers/BalanceTransactionServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/customers/BalanceTransactionServiceTest.kt index 370c31f5a..8549a9f4f 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/customers/BalanceTransactionServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/customers/BalanceTransactionServiceTest.kt @@ -21,7 +21,7 @@ class BalanceTransactionServiceTest { .build() val balanceTransactionService = client.customers().balanceTransactions() - val balanceTransaction = + val customerBalanceTransactionModel = balanceTransactionService.create( CustomerBalanceTransactionCreateParams.builder() .customerId("customer_id") @@ -31,7 +31,7 @@ class BalanceTransactionServiceTest { .build() ) - balanceTransaction.validate() + customerBalanceTransactionModel.validate() } @Test diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/customers/CostServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/customers/CostServiceTest.kt index e37f38880..9dd738691 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/customers/CostServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/customers/CostServiceTest.kt @@ -22,7 +22,7 @@ class CostServiceTest { .build() val costService = client.customers().costs() - val cost = + val customerCostsModel = costService.list( CustomerCostListParams.builder() .customerId("customer_id") @@ -33,7 +33,7 @@ class CostServiceTest { .build() ) - cost.validate() + customerCostsModel.validate() } @Test @@ -45,7 +45,7 @@ class CostServiceTest { .build() val costService = client.customers().costs() - val response = + val customerCostsModel = costService.listByExternalId( CustomerCostListByExternalIdParams.builder() .externalCustomerId("external_customer_id") @@ -56,6 +56,6 @@ class CostServiceTest { .build() ) - response.validate() + customerCostsModel.validate() } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceTest.kt index f080078eb..a23e1a648 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 @@ -5,6 +5,7 @@ package com.withorb.api.services.blocking.customers.credits import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClient import com.withorb.api.core.JsonValue +import com.withorb.api.models.AddCreditLedgerEntryRequest import com.withorb.api.models.CustomerCreditLedgerCreateEntryByExternalIdParams import com.withorb.api.models.CustomerCreditLedgerCreateEntryParams import com.withorb.api.models.CustomerCreditLedgerListByExternalIdParams @@ -42,17 +43,16 @@ class LedgerServiceTest { .build() val ledgerService = client.customers().credits().ledger() - val response = + val creditLedgerEntryModel = ledgerService.createEntry( CustomerCreditLedgerCreateEntryParams.builder() .customerId("customer_id") - .body( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams + .addCreditLedgerEntryRequest( + AddCreditLedgerEntryRequest.AddIncrementCreditLedgerEntryRequestParams .builder() .amount(0.0) .entryType( - CustomerCreditLedgerCreateEntryParams.Body + AddCreditLedgerEntryRequest .AddIncrementCreditLedgerEntryRequestParams .EntryType .INCREMENT @@ -62,7 +62,7 @@ class LedgerServiceTest { .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .invoiceSettings( - CustomerCreditLedgerCreateEntryParams.Body + AddCreditLedgerEntryRequest .AddIncrementCreditLedgerEntryRequestParams .InvoiceSettings .builder() @@ -73,7 +73,7 @@ class LedgerServiceTest { .build() ) .metadata( - CustomerCreditLedgerCreateEntryParams.Body + AddCreditLedgerEntryRequest .AddIncrementCreditLedgerEntryRequestParams .Metadata .builder() @@ -86,7 +86,7 @@ class LedgerServiceTest { .build() ) - response.validate() + creditLedgerEntryModel.validate() } @Test @@ -98,17 +98,16 @@ class LedgerServiceTest { .build() val ledgerService = client.customers().credits().ledger() - val response = + val creditLedgerEntryModel = ledgerService.createEntryByExternalId( CustomerCreditLedgerCreateEntryByExternalIdParams.builder() .externalCustomerId("external_customer_id") - .body( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams + .addCreditLedgerEntryRequest( + AddCreditLedgerEntryRequest.AddIncrementCreditLedgerEntryRequestParams .builder() .amount(0.0) .entryType( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body + AddCreditLedgerEntryRequest .AddIncrementCreditLedgerEntryRequestParams .EntryType .INCREMENT @@ -118,7 +117,7 @@ class LedgerServiceTest { .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .invoiceSettings( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body + AddCreditLedgerEntryRequest .AddIncrementCreditLedgerEntryRequestParams .InvoiceSettings .builder() @@ -129,7 +128,7 @@ class LedgerServiceTest { .build() ) .metadata( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body + AddCreditLedgerEntryRequest .AddIncrementCreditLedgerEntryRequestParams .Metadata .builder() @@ -142,7 +141,7 @@ class LedgerServiceTest { .build() ) - response.validate() + creditLedgerEntryModel.validate() } @Test diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/customers/credits/TopUpServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/customers/credits/TopUpServiceTest.kt index 4d8b5f8a0..faa66afa0 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/customers/credits/TopUpServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/customers/credits/TopUpServiceTest.kt @@ -4,6 +4,7 @@ package com.withorb.api.services.blocking.customers.credits import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClient +import com.withorb.api.models.AddCreditTopUpRequest import com.withorb.api.models.CustomerCreditTopUpCreateByExternalIdParams import com.withorb.api.models.CustomerCreditTopUpCreateParams import com.withorb.api.models.CustomerCreditTopUpDeleteByExternalIdParams @@ -26,29 +27,33 @@ class TopUpServiceTest { .build() val topUpService = client.customers().credits().topUps() - val topUp = + val topUpModel = topUpService.create( CustomerCreditTopUpCreateParams.builder() .customerId("customer_id") - .amount("amount") - .currency("currency") - .invoiceSettings( - CustomerCreditTopUpCreateParams.InvoiceSettings.builder() - .autoCollection(true) - .netTerms(0L) - .memo("memo") - .requireSuccessfulPayment(true) + .addCreditTopUpRequest( + AddCreditTopUpRequest.builder() + .amount("amount") + .currency("currency") + .invoiceSettings( + AddCreditTopUpRequest.InvoiceSettings.builder() + .autoCollection(true) + .netTerms(0L) + .memo("memo") + .requireSuccessfulPayment(true) + .build() + ) + .perUnitCostBasis("per_unit_cost_basis") + .threshold("threshold") + .activeFrom(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiresAfter(0L) + .expiresAfterUnit(AddCreditTopUpRequest.ExpiresAfterUnit.DAY) .build() ) - .perUnitCostBasis("per_unit_cost_basis") - .threshold("threshold") - .activeFrom(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expiresAfter(0L) - .expiresAfterUnit(CustomerCreditTopUpCreateParams.ExpiresAfterUnit.DAY) .build() ) - topUp.validate() + topUpModel.validate() } @Test @@ -94,31 +99,33 @@ class TopUpServiceTest { .build() val topUpService = client.customers().credits().topUps() - val response = + val topUpModel = topUpService.createByExternalId( CustomerCreditTopUpCreateByExternalIdParams.builder() .externalCustomerId("external_customer_id") - .amount("amount") - .currency("currency") - .invoiceSettings( - CustomerCreditTopUpCreateByExternalIdParams.InvoiceSettings.builder() - .autoCollection(true) - .netTerms(0L) - .memo("memo") - .requireSuccessfulPayment(true) + .addCreditTopUpRequest( + AddCreditTopUpRequest.builder() + .amount("amount") + .currency("currency") + .invoiceSettings( + AddCreditTopUpRequest.InvoiceSettings.builder() + .autoCollection(true) + .netTerms(0L) + .memo("memo") + .requireSuccessfulPayment(true) + .build() + ) + .perUnitCostBasis("per_unit_cost_basis") + .threshold("threshold") + .activeFrom(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiresAfter(0L) + .expiresAfterUnit(AddCreditTopUpRequest.ExpiresAfterUnit.DAY) .build() ) - .perUnitCostBasis("per_unit_cost_basis") - .threshold("threshold") - .activeFrom(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expiresAfter(0L) - .expiresAfterUnit( - CustomerCreditTopUpCreateByExternalIdParams.ExpiresAfterUnit.DAY - ) .build() ) - response.validate() + topUpModel.validate() } @Test diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceTest.kt index 07c512bb8..f927fd8ce 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceTest.kt @@ -21,13 +21,13 @@ class ExternalDimensionalPriceGroupIdServiceTest { val externalDimensionalPriceGroupIdService = client.dimensionalPriceGroups().externalDimensionalPriceGroupId() - val dimensionalPriceGroup = + val dimensionalPriceGroupModel = externalDimensionalPriceGroupIdService.retrieve( DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams.builder() .externalDimensionalPriceGroupId("external_dimensional_price_group_id") .build() ) - dimensionalPriceGroup.validate() + dimensionalPriceGroupModel.validate() } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/events/BackfillServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/events/BackfillServiceTest.kt index 89c6695c5..5357d74aa 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/events/BackfillServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/events/BackfillServiceTest.kt @@ -24,7 +24,7 @@ class BackfillServiceTest { .build() val backfillService = client.events().backfills() - val backfill = + val backfillModel = backfillService.create( EventBackfillCreateParams.builder() .timeframeEnd(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -37,7 +37,7 @@ class BackfillServiceTest { .build() ) - backfill.validate() + backfillModel.validate() } @Test @@ -63,12 +63,12 @@ class BackfillServiceTest { .build() val backfillService = client.events().backfills() - val response = + val backfillModel = backfillService.close( EventBackfillCloseParams.builder().backfillId("backfill_id").build() ) - response.validate() + backfillModel.validate() } @Test @@ -80,12 +80,12 @@ class BackfillServiceTest { .build() val backfillService = client.events().backfills() - val response = + val backfillModel = backfillService.fetch( EventBackfillFetchParams.builder().backfillId("backfill_id").build() ) - response.validate() + backfillModel.validate() } @Test @@ -97,11 +97,11 @@ class BackfillServiceTest { .build() val backfillService = client.events().backfills() - val response = + val backfillModel = backfillService.revert( EventBackfillRevertParams.builder().backfillId("backfill_id").build() ) - response.validate() + backfillModel.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 af4affdd5..ccde7d829 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/plans/ExternalPlanIdServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/plans/ExternalPlanIdServiceTest.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.blocking.plans import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClient import com.withorb.api.core.JsonValue +import com.withorb.api.models.EditPlanModel import com.withorb.api.models.PlanExternalPlanIdFetchParams import com.withorb.api.models.PlanExternalPlanIdUpdateParams import org.junit.jupiter.api.Test @@ -22,20 +23,24 @@ class ExternalPlanIdServiceTest { .build() val externalPlanIdService = client.plans().externalPlanId() - val plan = + val planModel = externalPlanIdService.update( PlanExternalPlanIdUpdateParams.builder() .otherExternalPlanId("external_plan_id") - .externalPlanId("external_plan_id") - .metadata( - PlanExternalPlanIdUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .editPlanModel( + EditPlanModel.builder() + .externalPlanId("external_plan_id") + .metadata( + EditPlanModel.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .build() ) .build() ) - plan.validate() + planModel.validate() } @Test @@ -47,11 +52,11 @@ class ExternalPlanIdServiceTest { .build() val externalPlanIdService = client.plans().externalPlanId() - val plan = + val planModel = externalPlanIdService.fetch( PlanExternalPlanIdFetchParams.builder().externalPlanId("external_plan_id").build() ) - plan.validate() + planModel.validate() } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/prices/ExternalPriceIdServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/prices/ExternalPriceIdServiceTest.kt index 19947009e..86dfc67d7 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/prices/ExternalPriceIdServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/prices/ExternalPriceIdServiceTest.kt @@ -7,6 +7,7 @@ import com.withorb.api.client.okhttp.OrbOkHttpClient import com.withorb.api.core.JsonValue import com.withorb.api.models.PriceExternalPriceIdFetchParams import com.withorb.api.models.PriceExternalPriceIdUpdateParams +import com.withorb.api.models.UpdatePriceRequestParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -22,19 +23,23 @@ class ExternalPriceIdServiceTest { .build() val externalPriceIdService = client.prices().externalPriceId() - val price = + val priceModel = externalPriceIdService.update( PriceExternalPriceIdUpdateParams.builder() .externalPriceId("external_price_id") - .metadata( - PriceExternalPriceIdUpdateParams.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .updatePriceRequestParams( + UpdatePriceRequestParams.builder() + .metadata( + UpdatePriceRequestParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .build() ) .build() ) - price.validate() + priceModel.validate() } @Test @@ -46,13 +51,13 @@ class ExternalPriceIdServiceTest { .build() val externalPriceIdService = client.prices().externalPriceId() - val price = + val priceModel = externalPriceIdService.fetch( PriceExternalPriceIdFetchParams.builder() .externalPriceId("external_price_id") .build() ) - price.validate() + priceModel.validate() } }